file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
crates/swc_ecma_minifier/tests/fixture/issues/regexp/1/input.js
JavaScript
export default function () { return new RegExp("{.[^}]+}\n*", "g"); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/regexp/1/output.js
JavaScript
export default function() { return RegExp("{.[^}]+}\n*", "g"); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/stylis/1/input.js
JavaScript
import { MS, MOZ, WEBKIT } from "./Enum.js"; import { strlen, indexof, replace } from "./Utility.js"; function hash(value, length) { return ( (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) ); } function charat(value, index) { return value.charCodeAt(index) | 0; } /** * @param {string} value * @param {number} length * @return {string} */ export function prefix(value, length) { switch (hash(value, length)) { // color-adjust case 5103: return WEBKIT + "print-" + value + value; // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function) case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break case 5572: case 6356: case 5844: case 3191: case 6645: case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite, case 6391: case 5879: case 5623: case 6135: case 4599: case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width) case 4215: case 6389: case 5109: case 5365: case 5621: case 3829: return WEBKIT + value + value; // appearance, user-select, transform, hyphens, text-size-adjust case 5349: case 4246: case 4810: case 6968: case 2756: return WEBKIT + value + MOZ + value + MS + value + value; // flex, flex-direction case 6828: case 4268: return WEBKIT + value + MS + value + value; // order case 6165: return WEBKIT + value + MS + "flex-" + value + value; // align-items case 5187: return ( WEBKIT + value + replace( value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2" ) + value ); // align-self case 5443: return ( WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value ); // align-content case 4675: return ( WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value ); // flex-shrink case 5548: return ( WEBKIT + value + MS + replace(value, "shrink", "negative") + value ); // flex-basis case 5292: return ( WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value ); // flex-grow case 6060: return ( WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value ); // transition case 4554: return ( WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value ); // cursor case 6187: return ( replace( replace( replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1" ), value, "" ) + value ); // background, background-image case 5495: case 3959: return replace(value, /(image-set\([^]*)/, WEBKIT + "$1" + "$`$1"); // justify-content case 4968: return ( replace( replace( value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3" ), /s.+-b[^;]+/, "justify" ) + WEBKIT + value + value ); // (margin|padding)-inline-(start|end) case 4095: case 3583: case 4068: case 2532: return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value; // (min|max)?(width|height|inline-size|block-size) case 8116: case 7059: case 5753: case 5535: case 5445: case 5701: case 4933: case 4677: case 5533: case 5789: case 5021: case 4765: // stretch, max-content, min-content, fill-available if (strlen(value) - 1 - length > 6) switch (charat(value, length + 1)) { // (m)ax-content, (m)in-content case 109: // - if (charat(value, length + 4) !== 45) break; // (f)ill-available, (f)it-content case 102: return ( replace( value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3" + "$1" + MOZ + (charat(value, length + 3) == 108 ? "$3" : "$2-$3") ) + value ); // (s)tretch case 115: return ~indexof(value, "stretch") ? prefix( replace(value, "stretch", "fill-available"), length ) + value : value; } break; // position: sticky case 4949: // (s)ticky? if (charat(value, length + 1) !== 115) break; // display: (flex|inline-flex) case 6444: switch ( charat( value, strlen(value) - 3 - (~indexof(value, "!important") && 10) ) ) { // stic(k)y case 107: return replace(value, ":", ":" + WEBKIT) + value; // (inline-)?fl(e)x case 101: return ( replace( value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3" + "$1" + WEBKIT + "$2$3" + "$1" + MS + "$2box$3" ) + value ); } break; // writing-mode case 5936: switch (charat(value, length + 11)) { // vertical-l(r) case 114: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value ); // vertical-r(l) case 108: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value ); // horizontal(-)tb case 45: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value ); } return WEBKIT + value + MS + value + value; } return value; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/stylis/1/output.js
JavaScript
import { MS, MOZ, WEBKIT } from "./Enum.js"; import { strlen, indexof, replace } from "./Utility.js"; function charat(value, index) { return 0 | value.charCodeAt(index); } /** * @param {string} value * @param {number} length * @return {string} */ export function prefix(value, length) { switch((((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3)){ // color-adjust case 5103: return WEBKIT + "print-" + value + value; // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function) case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break case 5572: case 6356: case 5844: case 3191: case 6645: case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite, case 6391: case 5879: case 5623: case 6135: case 4599: case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width) case 4215: case 6389: case 5109: case 5365: case 5621: case 3829: return WEBKIT + value + value; // appearance, user-select, transform, hyphens, text-size-adjust case 5349: case 4246: case 4810: case 6968: case 2756: return WEBKIT + value + MOZ + value + MS + value + value; // flex, flex-direction case 6828: case 4268: return WEBKIT + value + MS + value + value; // order case 6165: return WEBKIT + value + MS + "flex-" + value + value; // align-items case 5187: return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value; // align-self case 5443: return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value; // align-content case 4675: return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value; // flex-shrink case 5548: return WEBKIT + value + MS + replace(value, "shrink", "negative") + value; // flex-basis case 5292: return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value; // flex-grow case 6060: return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value; // transition case 4554: return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value; // cursor case 6187: return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value; // background, background-image case 5495: case 3959: return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1"); // justify-content case 4968: return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value; // (margin|padding)-inline-(start|end) case 4095: case 3583: case 4068: case 2532: return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value; // (min|max)?(width|height|inline-size|block-size) case 8116: case 7059: case 5753: case 5535: case 5445: case 5701: case 4933: case 4677: case 5533: case 5789: case 5021: case 4765: // stretch, max-content, min-content, fill-available if (strlen(value) - 1 - length > 6) switch(charat(value, length + 1)){ // (m)ax-content, (m)in-content case 109: // - if (45 !== charat(value, length + 4)) break; // (f)ill-available, (f)it-content case 102: return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (108 == charat(value, length + 3) ? "$3" : "$2-$3")) + value; // (s)tretch case 115: return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length) + value : value; } break; // position: sticky case 4949: // (s)ticky? if (115 !== charat(value, length + 1)) break; // display: (flex|inline-flex) case 6444: switch(charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))){ // stic(k)y case 107: return replace(value, ":", ":" + WEBKIT) + value; // (inline-)?fl(e)x case 101: return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (45 === charat(value, 14) ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value; } break; // writing-mode case 5936: switch(charat(value, length + 11)){ // vertical-l(r) case 114: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value; // vertical-r(l) case 108: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value; // horizontal(-)tb case 45: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value; } return WEBKIT + value + MS + value + value; } return value; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/stylis/2/input.js
JavaScript
import { MS, MOZ, WEBKIT } from "./Enum.js.js"; import { strlen, indexof, replace } from "./Utility.js.js"; function charat(value, index) { return value.charCodeAt(index) | 0; } /** * @param {string} value * @param {number} length * @return {string} */ export function prefix(value, length) { function hash(value, length) { return ( (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) ); } switch (hash(value, length)) { // color-adjust case 5103: return WEBKIT + "print-" + value + value; // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function) case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break case 5572: case 6356: case 5844: case 3191: case 6645: case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite, case 6391: case 5879: case 5623: case 6135: case 4599: case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width) case 4215: case 6389: case 5109: case 5365: case 5621: case 3829: return WEBKIT + value + value; // appearance, user-select, transform, hyphens, text-size-adjust case 5349: case 4246: case 4810: case 6968: case 2756: return WEBKIT + value + MOZ + value + MS + value + value; // flex, flex-direction case 6828: case 4268: return WEBKIT + value + MS + value + value; // order case 6165: return WEBKIT + value + MS + "flex-" + value + value; // align-items case 5187: return ( WEBKIT + value + replace( value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2" ) + value ); // align-self case 5443: return ( WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value ); // align-content case 4675: return ( WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value ); // flex-shrink case 5548: return ( WEBKIT + value + MS + replace(value, "shrink", "negative") + value ); // flex-basis case 5292: return ( WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value ); // flex-grow case 6060: return ( WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value ); // transition case 4554: return ( WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value ); // cursor case 6187: return ( replace( replace( replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1" ), value, "" ) + value ); // background, background-image case 5495: case 3959: return replace(value, /(image-set\([^]*)/, WEBKIT + "$1" + "$`$1"); // justify-content case 4968: return ( replace( replace( value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3" ), /s.+-b[^;]+/, "justify" ) + WEBKIT + value + value ); // (margin|padding)-inline-(start|end) case 4095: case 3583: case 4068: case 2532: return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value; // (min|max)?(width|height|inline-size|block-size) case 8116: case 7059: case 5753: case 5535: case 5445: case 5701: case 4933: case 4677: case 5533: case 5789: case 5021: case 4765: // stretch, max-content, min-content, fill-available if (strlen(value) - 1 - length > 6) switch (charat(value, length + 1)) { // (m)ax-content, (m)in-content case 109: // - if (charat(value, length + 4) !== 45) break; // (f)ill-available, (f)it-content case 102: return ( replace( value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3" + "$1" + MOZ + (charat(value, length + 3) == 108 ? "$3" : "$2-$3") ) + value ); // (s)tretch case 115: return ~indexof(value, "stretch") ? prefix( replace(value, "stretch", "fill-available"), length ) + value : value; } break; // position: sticky case 4949: // (s)ticky? if (charat(value, length + 1) !== 115) break; // display: (flex|inline-flex) case 6444: switch ( charat( value, strlen(value) - 3 - (~indexof(value, "!important") && 10) ) ) { // stic(k)y case 107: return replace(value, ":", ":" + WEBKIT) + value; // (inline-)?fl(e)x case 101: return ( replace( value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3" + "$1" + WEBKIT + "$2$3" + "$1" + MS + "$2box$3" ) + value ); } break; // writing-mode case 5936: switch (charat(value, length + 11)) { // vertical-l(r) case 114: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value ); // vertical-r(l) case 108: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value ); // horizontal(-)tb case 45: return ( WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value ); } return WEBKIT + value + MS + value + value; } return value; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/stylis/2/output.js
JavaScript
import { MS, MOZ, WEBKIT } from "./Enum.js.js"; import { strlen, indexof, replace } from "./Utility.js.js"; function charat(value, index) { return 0 | value.charCodeAt(index); } /** * @param {string} value * @param {number} length * @return {string} */ export function prefix(value, length) { switch((((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3)){ // color-adjust case 5103: return WEBKIT + "print-" + value + value; // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function) case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break case 5572: case 6356: case 5844: case 3191: case 6645: case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite, case 6391: case 5879: case 5623: case 6135: case 4599: case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width) case 4215: case 6389: case 5109: case 5365: case 5621: case 3829: return WEBKIT + value + value; // appearance, user-select, transform, hyphens, text-size-adjust case 5349: case 4246: case 4810: case 6968: case 2756: return WEBKIT + value + MOZ + value + MS + value + value; // flex, flex-direction case 6828: case 4268: return WEBKIT + value + MS + value + value; // order case 6165: return WEBKIT + value + MS + "flex-" + value + value; // align-items case 5187: return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value; // align-self case 5443: return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value; // align-content case 4675: return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value; // flex-shrink case 5548: return WEBKIT + value + MS + replace(value, "shrink", "negative") + value; // flex-basis case 5292: return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value; // flex-grow case 6060: return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value; // transition case 4554: return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value; // cursor case 6187: return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value; // background, background-image case 5495: case 3959: return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1"); // justify-content case 4968: return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value; // (margin|padding)-inline-(start|end) case 4095: case 3583: case 4068: case 2532: return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value; // (min|max)?(width|height|inline-size|block-size) case 8116: case 7059: case 5753: case 5535: case 5445: case 5701: case 4933: case 4677: case 5533: case 5789: case 5021: case 4765: // stretch, max-content, min-content, fill-available if (strlen(value) - 1 - length > 6) switch(charat(value, length + 1)){ // (m)ax-content, (m)in-content case 109: // - if (45 !== charat(value, length + 4)) break; // (f)ill-available, (f)it-content case 102: return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (108 == charat(value, length + 3) ? "$3" : "$2-$3")) + value; // (s)tretch case 115: return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length) + value : value; } break; // position: sticky case 4949: // (s)ticky? if (115 !== charat(value, length + 1)) break; // display: (flex|inline-flex) case 6444: switch(charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))){ // stic(k)y case 107: return replace(value, ":", ":" + WEBKIT) + value; // (inline-)?fl(e)x case 101: return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (45 === charat(value, 14) ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value; } break; // writing-mode case 5936: switch(charat(value, length + 11)){ // vertical-l(r) case 114: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value; // vertical-r(l) case 108: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value; // horizontal(-)tb case 45: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value; } return WEBKIT + value + MS + value + value; } return value; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/input.js
JavaScript
var ts; (function (ts) { function transformModule(context) { function getTransformModuleDelegate(moduleKind) { switch (moduleKind) { case ts.ModuleKind.AMD: return transformAMDModule; case ts.ModuleKind.UMD: return transformUMDModule; default: return transformCommonJSModule; } } var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(207 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. context.enableSubstitution(209 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. context.enableSubstitution(220 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(303 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. var currentModuleInfo; // The ExternalModuleInfo for the current file. var noSubstitution = []; // Set of nodes for which substitution rules should be ignored. var needUMDDynamicImportHelper; return ts.chainBundle(context, transformSourceFile); /** * Transforms the module aspects of a SourceFile. * * @param node The SourceFile node. */ function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } currentSourceFile = node; currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions); moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; // Perform the transformation. var transformModule = getTransformModuleDelegate(moduleKind); var updated = transformModule(node); currentSourceFile = undefined; currentModuleInfo = undefined; needUMDDynamicImportHelper = false; return updated; } function shouldEmitUnderscoreUnderscoreESModule() { if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { return true; } return false; } /** * Transforms a SourceFile into a CommonJS module. * * @param node The SourceFile node. */ function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), topLevelVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } if (ts.length(currentModuleInfo.exportedNames)) { var chunkSize = 50; for (var i = 0; i < currentModuleInfo.exportedNames.length; i += chunkSize) { ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + chunkSize), function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); } } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); return updated; } /** * Transforms a SourceFile into an AMD module. * * @param node The SourceFile node. */ function transformAMDModule(node) { var define = factory.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions); var jsonSourceFile = ts.isJsonSourceFile(node) && node; // An AMD define function has the following shape: // // define(id?, dependencies?, factory); // // This has the shape of the following: // // define(name, ["module1", "module2"], function (module1Alias) { ... } // // The location of the alias in the parameter list in the factory function needs to // match the position of the module name in the dependency list. // // To ensure this is true in cases of modules with no aliases, e.g.: // // import "module" // // or // // /// <amd-dependency path= "a.css" /> // // we need to add modules without alias names to the end of the dependencies list var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; // Create an updated SourceFile: // // define(mofactory.updateSourceFile", "module2"], function ... var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(define, /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") ], aliasedModuleNames, true), unaliasedModuleNames, true)), // Add the module body function argument: // // function (require, exports, module1, module2) ... jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() : factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") ], importAliasNames, true), /*type*/ undefined, transformAsynchronousModuleBody(node)) ], false))) ]), /*location*/ node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); return updated; } /** * Transforms a SourceFile into a UMD module. * * @param node The SourceFile node. */ function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions); var umdHeader = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], /*type*/ undefined, ts.setTextRange(factory.createBlock([ factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([ factory.createVariableStatement( /*modifiers*/ undefined, [ factory.createVariableDeclaration("v", /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("factory"), /*typeArguments*/ undefined, [ factory.createIdentifier("require"), factory.createIdentifier("exports") ])) ]), ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ factory.createArrayLiteralExpression(__spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") ], aliasedModuleNames, true), unaliasedModuleNames, true)), factory.createIdentifier("factory") ], false))) ]))) ], /*multiLine*/ true), /*location*/ undefined)); // Create an updated SourceFile: // // (function (factory) { // if (typeof module === "object" && typeof module.exports === "object") { // var v = factory(require, exports); // if (v !== undefined) module.exports = v; // } // else if (typeof define === 'function' && define.amd) { // define(["require", "exports"], factory); // } // })(function ...) var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // // function (require, exports) ... factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") ], importAliasNames, true), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), /*location*/ node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); return updated; } /** * Collect the additional asynchronous dependencies for the module. * * @param node The source file. * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. */ function collectAsynchronousDependencies(node, includeNonAmdDependencies) { // names of modules with corresponding parameter in the factory function var aliasedModuleNames = []; // names of modules with no corresponding parameters in factory function var unaliasedModuleNames = []; // names of the parameters in the factory function; these // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. var importAliasNames = []; // Fill in amd-dependency tags for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { var amdDependency = _a[_i]; if (amdDependency.name) { aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); } } for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { var importNode = _c[_b]; // Find the name of the external module var externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions); // Find the name of the module alias, if there is one var importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile); // It is possible that externalModuleName is undefined if it is not string literal. // This can happen in the invalid import syntax. // E.g : "import * from alias from 'someLib';" if (externalModuleName) { if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } else { unaliasedModuleNames.push(externalModuleName); } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } function getAMDImportExpressionForImport(node) { if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) { return undefined; } var name = ts.getLocalNameForExternalImport(factory, node, currentSourceFile); // TODO: GH#18217 var expr = getHelperExpressionForImport(node, name); if (expr === name) { return undefined; } return factory.createExpressionStatement(factory.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. * * @param node The SourceFile node. */ function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; var statementOffset = factory.copyPrologue(node.statements, statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, topLevelVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } if (ts.length(currentModuleInfo.exportedNames)) { ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); } // Visit each statement of the module body. ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)); if (moduleKind === ts.ModuleKind.AMD) { ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)); } ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)); // Append the 'export =' statement if provided. addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var body = factory.createBlock(statements, /*multiLine*/ true); if (needUMDDynamicImportHelper) { ts.addEmitHelper(body, dynamicImportUMDHelper); } return body; } /** * Adds the down-level representation of `export=` to the statement list if one exists * in the source file. * * @param statements The Statement list to modify. * @param emitAsReturn A value indicating whether to emit the `export=` statement as a * return statement. */ function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, visitor); if (expressionResult) { if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); } } } } // // Top-Level Source Element Visitors // /** * Visits a node at the top level of the source file. * * @param node The node to visit. */ function topLevelVisitor(node) { switch (node.kind) { case 265 /* ImportDeclaration */: return visitImportDeclaration(node); case 264 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); case 271 /* ExportDeclaration */: return visitExportDeclaration(node); case 270 /* ExportAssignment */: return visitExportAssignment(node); case 236 /* VariableStatement */: return visitVariableStatement(node); case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 256 /* ClassDeclaration */: return visitClassDeclaration(node); case 350 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); case 351 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); } } function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { case 241 /* ForStatement */: return visitForStatement(node); case 237 /* ExpressionStatement */: return visitExpressionStatement(node); case 211 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); case 348 /* PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); case 207 /* CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; case 220 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; case 218 /* PrefixUnaryExpression */: case 219 /* PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } function visitor(node) { return visitorWorker(node, /*valueIsDiscarded*/ false); } function discardedValueVisitor(node) { return visitorWorker(node, /*valueIsDiscarded*/ true); } function destructuringNeedsFlattening(node) { if (ts.isObjectLiteralExpression(node)) { for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { case 294 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; case 295 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; case 296 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; case 168 /* MethodDeclaration */: case 171 /* GetAccessor */: case 172 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } } } else if (ts.isArrayLiteralExpression(node)) { for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { var elem = _c[_b]; if (ts.isSpreadElement(elem)) { if (destructuringNeedsFlattening(elem.expression)) { return true; } } else if (destructuringNeedsFlattening(elem)) { return true; } } } else if (ts.isIdentifier(node)) { return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0); } return false; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, discardedValueVisitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, discardedValueVisitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } function visitExpressionStatement(node) { return factory.updateExpressionStatement(node, ts.visitNode(node.expression, discardedValueVisitor, ts.isExpression)); } function visitParenthesizedExpression(node, valueIsDiscarded) { return factory.updateParenthesizedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); } function visitPartiallyEmittedExpression(node, valueIsDiscarded) { return factory.updatePartiallyEmittedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { // When we see a prefix or postfix increment expression whose operand is an exported // symbol, we should ensure all exports of that symbol are updated with the correct // value. // // - We do not transform generated identifiers for any reason. // - We do not transform identifiers tagged with the LocalName flag. // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { var temp = void 0; var expression = ts.visitNode(node.operand, visitor, ts.isExpression); if (ts.isPrefixUnaryExpression(node)) { expression = factory.updatePrefixUnaryExpression(node, expression); } else { expression = factory.updatePostfixUnaryExpression(node, expression); if (!valueIsDiscarded) { temp = factory.createTempVariable(hoistVariableDeclaration); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node); } expression = factory.createComma(expression, factory.cloneNode(node.operand)); ts.setTextRange(expression, node); } for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { var exportName = exportedNames_1[_i]; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); ts.setTextRange(expression, node); } if (temp) { noSubstitution[ts.getNodeId(expression)] = true; expression = factory.createComma(expression, temp); ts.setTextRange(expression, node); } return expression; } } return ts.visitEachChild(node, visitor, context); } function visitImportCallExpression(node) { var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions); var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); case ts.ModuleKind.UMD: return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis); case ts.ModuleKind.CommonJS: default: return createImportCallExpressionCommonJS(argument, containsLexicalThis); } } function createImportCallExpressionUMD(arg, containsLexicalThis) { // (function (factory) { // ... (regular UMD) // } // })(function (require, exports, useSyncRequire) { // "use strict"; // Object.defineProperty(exports, "__esModule", { value: true }); // var __syncRequire = typeof module === "object" && typeof module.exports === "object"; // var __resolved = new Promise(function (resolve) { resolve(); }); // ..... // __syncRequire // ? __resolved.then(function () { return require(x); }) /*CommonJs Require*/ // : new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis), /*colonToken*/ undefined, /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis)); } else { var temp = factory.createTempVariable(hoistVariableDeclaration); return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis), /*colonToken*/ undefined, /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis))); } } function createImportCallExpressionAMD(arg, containsLexicalThis) { // improt("./blah") // emit as // define(["require", "exports", "blah"], function (require, exports) { // ... // new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ // }); var resolve = factory.createUniqueName("resolve"); var reject = factory.createUniqueName("reject"); var parameters = [ factory.createParameterDeclaration(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ resolve), factory.createParameterDeclaration(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; if (languageVersion >= 2 /* ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, body); } else { func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // if there is a lexical 'this' in the import call arguments, ensure we indicate // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { ts.setEmitFlags(func, 8 /* CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (ts.getESModuleInterop(compilerOptions)) { return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]); } return promise; } function createImportCallExpressionCommonJS(arg, containsLexicalThis) { // import("./blah") // emit as // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/ // We have to wrap require in then callback so that require is done in asynchronously // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/[]); var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (ts.getESModuleInterop(compilerOptions)) { requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; if (languageVersion >= 2 /* ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, /*parameters*/[], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, requireCall); } else { func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/[], /*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)])); // if there is a lexical 'this' in the import call arguments, ensure we indicate // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { ts.setEmitFlags(func, 8 /* CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { return emitHelpers().createImportStarHelper(innerExpr); } return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { return emitHelpers().createImportStarHelper(innerExpr); } if (ts.getImportNeedsImportDefaultHelper(node)) { return emitHelpers().createImportDefaultHelper(innerExpr); } return innerExpr; } /** * Visits an ImportDeclaration node. * * @param node The node to visit. */ function visitImportDeclaration(node) { var statements; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node); } else { var variables = []; if (namespaceDeclaration && !ts.isDefaultImport(node)) { // import * as n from "mod"; variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ undefined, /*type*/ undefined, getHelperExpressionForImport(node, createRequireCall(node)))); } else { // import d from "mod"; // import { x, y } from "mod"; // import d, { x, y } from "mod"; // import d, * as n from "mod"; variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), /*exclamationToken*/ undefined, /*type*/ undefined, getHelperExpressionForImport(node, createRequireCall(node)))); if (namespaceDeclaration && ts.isDefaultImport(node)) { variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ undefined, /*type*/ undefined, factory.getGeneratedNameForNode(node))); } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), /*location*/ node), /*original*/ node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { // import d, * as n from "mod"; statements = ts.append(statements, factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ undefined, /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportDeclaration(statements, node); } return ts.singleOrMany(statements); } /** * Creates a `require()` call to import an external module. * * @param importNode The declararation to import. */ function createRequireCall(importNode) { var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions); var args = []; if (moduleName) { args.push(moduleName); } return factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, args); } /** * Visits an ImportEqualsDeclaration node. * * @param node The node to visit. */ function visitImportEqualsDeclaration(node) { ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.cloneNode(node.name), /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); } } else { if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportEqualsDeclaration(statements, node); } return ts.singleOrMany(statements); } /** * Visits an ExportDeclaration node. * * @param The node to visit. */ function visitExportDeclaration(node) { if (!node.moduleSpecifier) { // Elide export declarations with no module specifier as they are handled // elsewhere. return undefined; } var generatedName = factory.getGeneratedNameForNode(node); if (node.exportClause && ts.isNamedExports(node.exportClause)) { var statements = []; // export { x, y } from "mod"; if (moduleKind !== ts.ModuleKind.AMD) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(generatedName, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ])), /*location*/ node), /* original */ node)); } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; if (languageVersion === 0 /* ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); } } return ts.singleOrMany(statements); } else if (node.exportClause) { var statements = []; // export * as ns from "mod"; // export * as default from "mod"; statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), getHelperExpressionForExport(node, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node)); return ts.singleOrMany(statements); } else { // export * from "mod"; return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node); } } /** * Visits an ExportAssignment node. * * @param node The node to visit. */ function visitExportAssignment(node) { if (node.isExportEquals) { return undefined; } var statements; var original = node.original; if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ true); } else { statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ true); } return ts.singleOrMany(statements); } /** * Visits a FunctionDeclaration node. * * @param node The node to visit. */ function visitFunctionDeclaration(node) { var statements; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), /*location*/ node), /*original*/ node)); } else { statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } /** * Visits a ClassDeclaration node. * * @param node The node to visit. */ function visitClassDeclaration(node) { var statements; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } else { statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } /** * Visits a VariableStatement node. * * @param node The node to visit. */ function visitVariableStatement(node) { var statements; var variables; var expressions; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { if (!modifiers) { modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); } variables = ts.append(variables, variable); } else if (variable.initializer) { if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) { var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), /*location*/ variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name))); var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, visitor)); variables = ts.append(variables, updatedVariable); expressions = ts.append(expressions, expression); removeCommentsOnExpressions = true; } else { expressions = ts.append(expressions, transformInitializedVariable(variable)); } } } if (variables) { statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node); if (removeCommentsOnExpressions) { ts.removeAllComments(statement); } statements = ts.append(statements, statement); } } else { statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); } else { statements = appendExportsOfVariableStatement(statements, node); } return ts.singleOrMany(statements); } function createAllExportExpressions(name, value, location) { var exportedNames = getExports(name); if (exportedNames) { // For each additional export of the declaration, apply an export assignment. var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value); for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. ts.setEmitFlags(expression, 4 /* NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; } return factory.createAssignment(name, value); } /** * Transforms an exported variable with an initializer into an expression. * * @param node The node to transform. */ function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), /*visitor*/ undefined, context, 0 /* All */, /*needsValue*/ false, createAllExportExpressions); } else { return factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), node.name), /*location*/ node.name), node.initializer ? ts.visitNode(node.initializer, visitor) : factory.createVoidZero()); } } /** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged * and transformed declaration. * * @param node The node to visit. */ function visitMergeDeclarationMarker(node) { // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding // declaration we do not emit a leading variable declaration. To preserve the // begin/end semantics of the declararation and to properly handle exports // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. // // To balance the declaration, add the exports of the elided variable // statement. if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 236 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } /** * Determines whether a node has an associated EndOfDeclarationMarker. * * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed * declaration. * * @param node The node to visit. */ function visitEndOfDeclarationMarker(node) { // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual // end of the transformed declaration. We use this marker to emit any deferred exports // of the declaration. var id = ts.getOriginalNodeId(node); var statements = deferredExports[id]; if (statements) { delete deferredExports[id]; return ts.append(statements, node); } return node; } /** * Appends the exports of an ImportDeclaration to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfImportDeclaration(statements, decl) { if (currentModuleInfo.exportEquals) { return statements; } var importClause = decl.importClause; if (!importClause) { return statements; } if (importClause.name) { statements = appendExportsOfDeclaration(statements, importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { case 267 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; case 268 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); } break; } } return statements; } /** * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfImportEqualsDeclaration(statements, decl) { if (currentModuleInfo.exportEquals) { return statements; } return appendExportsOfDeclaration(statements, decl); } /** * Appends the exports of a VariableStatement to a statement list, returning the statement * list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param node The VariableStatement whose exports are to be recorded. */ function appendExportsOfVariableStatement(statements, node) { if (currentModuleInfo.exportEquals) { return statements; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; statements = appendExportsOfBindingElement(statements, decl); } return statements; } /** * Appends the exports of a VariableDeclaration or BindingElement to a statement list, * returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfBindingElement(statements, decl) { if (currentModuleInfo.exportEquals) { return statements; } if (ts.isBindingPattern(decl.name)) { for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { statements = appendExportsOfBindingElement(statements, element); } } } else if (!ts.isGeneratedIdentifier(decl.name)) { statements = appendExportsOfDeclaration(statements, decl); } return statements; } /** * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, * returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfHoistedDeclaration(statements, decl) { if (currentModuleInfo.exportEquals) { return statements; } if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { statements = appendExportsOfDeclaration(statements, decl); } return statements; } /** * Appends the exports of a declaration to a statement list, returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration to export. */ function appendExportsOfDeclaration(statements, decl, liveBinding) { var name = factory.getDeclarationName(decl); var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name)); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ undefined, liveBinding); } } return statements; } /** * Appends the down-level representation of an export to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param exportName The name of the export. * @param expression The expression to export. * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) { statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); return statements; } function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { statement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteral("__esModule"), factory.createObjectLiteralExpression([ factory.createPropertyAssignment("value", factory.createTrue()) ]) ])); } ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); return statement; } /** * Creates a call to the current file's export function to export a value. * * @param name The bound name of the export. * @param value The exported value. * @param location The location to use for source maps and comments for the export. * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, location, allowComments, liveBinding) { var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); } return statement; } /** * Creates a call to the current file's export function to export a value. * * @param name The bound name of the export. * @param value The exported value. * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), factory.createObjectLiteralExpression([ factory.createPropertyAssignment("enumerable", factory.createTrue()), factory.createPropertyAssignment("get", factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/[], /*type*/ undefined, factory.createBlock([factory.createReturnStatement(value)]))) ]) ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location); } // // Modifier Visitors // /** * Visit nodes to elide module-specific modifiers. * * @param node The node to visit. */ function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { case 93 /* ExportKeyword */: case 88 /* DefaultKeyword */: return undefined; } return node; } // // Emit Notification // /** * Hook for node emit notifications. * * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { if (node.kind === 303 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; } else { previousOnEmitNode(hint, node, emitCallback); } } // // Substitutions // /** * Hooks node substitutions. * * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } if (hint === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { return substituteShorthandPropertyAssignment(node); } return node; } /** * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported * or exported symbol. * * @param node The node to substitute. */ function substituteShorthandPropertyAssignment(node) { var name = node.name; var exportedOrImportedName = substituteExpressionIdentifier(name); if (exportedOrImportedName !== name) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node); } return ts.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node); } return node; } /** * Substitution for an Expression that may contain an imported or exported symbol. * * @param node The node to substitute. */ function substituteExpression(node) { switch (node.kind) { case 79 /* Identifier */: return substituteExpressionIdentifier(node); case 207 /* CallExpression */: return substituteCallExpression(node); case 209 /* TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); case 220 /* BinaryExpression */: return substituteBinaryExpression(node); } return node; } function substituteCallExpression(node) { if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); } } return node; } function substituteTaggedTemplateExpression(node) { if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); } } return node; } /** * Substitution for an Identifier expression that may contain an imported or exported * symbol. * * @param node The node to substitute. */ function substituteExpressionIdentifier(node) { var _a, _b; if (ts.getEmitFlags(node) & 4096 /* HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); if (exportContainer && exportContainer.kind === 303 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { var name = importDeclaration.propertyName || importDeclaration.name; return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(name)), /*location*/ node); } } } return node; } /** * Substitution for a BinaryExpression that may contain an imported or exported symbol. * * @param node The node to substitute. */ function substituteBinaryExpression(node) { // When we see an assignment expression whose left-hand side is an exported symbol, // we should ensure all exports of that symbol are updated with the correct value. // // - We do not substitute generated identifiers for any reason. // - We do not substitute identifiers tagged with the LocalName flag. // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. if (ts.isAssignmentOperator(node.operatorToken.kind) && ts.isIdentifier(node.left) && !ts.isGeneratedIdentifier(node.left) && !ts.isLocalName(node.left) && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { var exportedNames = getExports(node.left); if (exportedNames) { // For each additional export of the declaration, apply an export assignment. var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; // Mark the node to prevent triggering this rule again. noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression, /*location*/ node); } return expression; } } return node; } /** * Gets the additional exports of a name. * * @param name The name. */ function getExports(name) { if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { return currentModuleInfo && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; } } } } ts.transformModule = transformModule; // emit helper for dynamic import var dynamicImportUMDHelper = { name: "typescript:dynamicimport-sync-require", scoped: true, text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; })(ts || (ts = {}));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/output.js
JavaScript
var ts, ts1, dynamicImportUMDHelper; (ts1 = ts || (ts = {})).transformModule = function(context) { var currentSourceFile, currentModuleInfo, needUMDDynamicImportHelper, factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, compilerOptions = context.getCompilerOptions(), resolver = context.getEmitResolver(), host = context.getEmitHost(), languageVersion = ts1.getEmitScriptTarget(compilerOptions), moduleKind = ts1.getEmitModuleKind(compilerOptions), previousOnSubstituteNode = context.onSubstituteNode, previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = // // Substitutions // /** * Hooks node substitutions. * * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ function(hint, node) { return (node = previousOnSubstituteNode(hint, node)).id && noSubstitution[node.id] ? node : 1 /* Expression */ === hint ? /** * Substitution for an Expression that may contain an imported or exported symbol. * * @param node The node to substitute. */ function(node) { switch(node.kind){ case 79 /* Identifier */ : return substituteExpressionIdentifier(node); case 207 /* CallExpression */ : return function(node) { if (ts1.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); if (noSubstitution[ts1.getNodeId(expression)] = !0, !ts1.isIdentifier(expression) && !(4096 /* HelperName */ & ts1.getEmitFlags(node.expression))) return ts1.addEmitFlags(factory.updateCallExpression(node, expression, /*typeArguments*/ void 0, node.arguments), 536870912 /* IndirectCall */ ); } return node; }(node); case 209 /* TaggedTemplateExpression */ : return function(node) { if (ts1.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); if (noSubstitution[ts1.getNodeId(tag)] = !0, !ts1.isIdentifier(tag) && !(4096 /* HelperName */ & ts1.getEmitFlags(node.tag))) return ts1.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, /*typeArguments*/ void 0, node.template), 536870912 /* IndirectCall */ ); } return node; }(node); case 220 /* BinaryExpression */ : return(/** * Substitution for a BinaryExpression that may contain an imported or exported symbol. * * @param node The node to substitute. */ function(node) { // When we see an assignment expression whose left-hand side is an exported symbol, // we should ensure all exports of that symbol are updated with the correct value. // // - We do not substitute generated identifiers for any reason. // - We do not substitute identifiers tagged with the LocalName flag. // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. if (ts1.isAssignmentOperator(node.operatorToken.kind) && ts1.isIdentifier(node.left) && !ts1.isGeneratedIdentifier(node.left) && !ts1.isLocalName(node.left) && !ts1.isDeclarationNameOfEnumOrNamespace(node.left)) { var exportedNames = getExports(node.left); if (exportedNames) { for(var expression = node, _i = 0; _i < exportedNames.length; _i++){ var exportName = exportedNames[_i]; // Mark the node to prevent triggering this rule again. noSubstitution[ts1.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression, /*location*/ node); } return expression; } } return node; }(node)); } return node; }(node) : ts1.isShorthandPropertyAssignment(node) ? /** * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported * or exported symbol. * * @param node The node to substitute. */ function(node) { var name = node.name, exportedOrImportedName = substituteExpressionIdentifier(name); if (exportedOrImportedName !== name) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); return ts1.setTextRange(factory.createPropertyAssignment(name, initializer), node); } return ts1.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node); } return node; }(node) : node; }, context.onEmitNode = // // Emit Notification // /** * Hook for node emit notifications. * * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ function(hint, node, emitCallback) { 303 /* SourceFile */ === node.kind ? (currentSourceFile = node, currentModuleInfo = moduleInfoMap[ts1.getOriginalNodeId(currentSourceFile)], previousOnEmitNode(hint, node, emitCallback), currentSourceFile = void 0, currentModuleInfo = void 0) : previousOnEmitNode(hint, node, emitCallback); }, context.enableSubstitution(207 /* CallExpression */ ), context.enableSubstitution(209 /* TaggedTemplateExpression */ ), context.enableSubstitution(79 /* Identifier */ ), context.enableSubstitution(220 /* BinaryExpression */ ), context.enableSubstitution(295 /* ShorthandPropertyAssignment */ ), context.enableEmitNotification(303 /* SourceFile */ ); var moduleInfoMap = [], deferredExports = [], noSubstitution = []; // The ExternalModuleInfo for each file. return ts1.chainBundle(context, /** * Transforms the module aspects of a SourceFile. * * @param node The SourceFile node. */ function(node) { if (node.isDeclarationFile || !(ts1.isEffectiveExternalModule(node, compilerOptions) || 4194304 /* ContainsDynamicImport */ & node.transformFlags || ts1.isJsonSourceFile(node) && ts1.hasJsonModuleEmitEnabled(compilerOptions) && ts1.outFile(compilerOptions))) return node; currentSourceFile = node, currentModuleInfo = ts1.collectExternalModuleInfo(context, node, resolver, compilerOptions), moduleInfoMap[ts1.getOriginalNodeId(node)] = currentModuleInfo; var updated = (function(moduleKind) { switch(moduleKind){ case ts1.ModuleKind.AMD: return transformAMDModule; case ts1.ModuleKind.UMD: return transformUMDModule; default: return transformCommonJSModule; } })(moduleKind)(node); return currentSourceFile = void 0, currentModuleInfo = void 0, needUMDDynamicImportHelper = !1, updated; }); function shouldEmitUnderscoreUnderscoreESModule() { return !!(!currentModuleInfo.exportEquals && ts1.isExternalModule(currentSourceFile)); } /** * Transforms a SourceFile into a CommonJS module. * * @param node The SourceFile node. */ function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = [], ensureUseStrict = ts1.getStrictOptionValue(compilerOptions, "alwaysStrict") || !compilerOptions.noImplicitUseStrict && ts1.isExternalModule(currentSourceFile), statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts1.isJsonSourceFile(node), topLevelVisitor); if (shouldEmitUnderscoreUnderscoreESModule() && ts1.append(statements, createUnderscoreUnderscoreESModule()), ts1.length(currentModuleInfo.exportedNames)) for(var i = 0; i < currentModuleInfo.exportedNames.length; i += 50)ts1.append(statements, factory.createExpressionStatement(ts1.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + 50), function(prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts1.idText(nextId))), prev); }, factory.createVoidZero()))); ts1.append(statements, ts1.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts1.isStatement)), ts1.addRange(statements, ts1.visitNodes(node.statements, topLevelVisitor, ts1.isStatement, statementOffset)), addExportEqualsIfNeeded(statements, /*emitAsReturn*/ !1), ts1.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray(statements), node.statements)); return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; } /** * Transforms a SourceFile into an AMD module. * * @param node The SourceFile node. */ function transformAMDModule(node) { var define = factory.createIdentifier("define"), moduleName = ts1.tryGetModuleNameFromFile(factory, node, host, compilerOptions), jsonSourceFile = ts1.isJsonSourceFile(node) && node, _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ !0), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(define, /*typeArguments*/ void 0, __spreadArray(__spreadArray([], moduleName ? [ moduleName ] : [], !0), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] factory.createArrayLiteralExpression(jsonSourceFile ? ts1.emptyArray : __spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") ], aliasedModuleNames, !0), unaliasedModuleNames, !0)), // Add the module body function argument: // // function (require, exports, module1, module2) ... jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() : factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, "require"), factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, "exports") ], importAliasNames, !0), /*type*/ void 0, transformAsynchronousModuleBody(node)) ], !1))) ]), /*location*/ node.statements)); return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; } /** * Transforms a SourceFile into a UMD module. * * @param node The SourceFile node. */ function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ !1), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, moduleName = ts1.tryGetModuleNameFromFile(factory, node, host, compilerOptions), umdHeader = factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, [ factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, "factory") ], /*type*/ void 0, ts1.setTextRange(factory.createBlock([ factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([ factory.createVariableStatement(/*modifiers*/ void 0, [ factory.createVariableDeclaration("v", /*exclamationToken*/ void 0, /*type*/ void 0, factory.createCallExpression(factory.createIdentifier("factory"), /*typeArguments*/ void 0, [ factory.createIdentifier("require"), factory.createIdentifier("exports") ])) ]), ts1.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */ ) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ void 0, __spreadArray(__spreadArray([], moduleName ? [ moduleName ] : [], !0), [ factory.createArrayLiteralExpression(__spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") ], aliasedModuleNames, !0), unaliasedModuleNames, !0)), factory.createIdentifier("factory") ], !1))) ]))) ], /*multiLine*/ !0), /*location*/ void 0)), updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(umdHeader, /*typeArguments*/ void 0, [ // Add the module body function argument: // // function (require, exports) ... factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, "require"), factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, "exports") ], importAliasNames, !0), /*type*/ void 0, transformAsynchronousModuleBody(node)) ])) ]), /*location*/ node.statements)); return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; } /** * Collect the additional asynchronous dependencies for the module. * * @param node The source file. * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. */ function collectAsynchronousDependencies(node, includeNonAmdDependencies) { // Fill in amd-dependency tags for(var aliasedModuleNames = [], unaliasedModuleNames = [], importAliasNames = [], _i = 0, _a = node.amdDependencies; _i < _a.length; _i++){ var amdDependency = _a[_i]; amdDependency.name ? (aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)), importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, amdDependency.name))) : unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); } for(var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++){ var importNode = _c[_b], externalModuleName = ts1.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), importAliasName = ts1.getLocalNameForExternalImport(factory, importNode, currentSourceFile); // It is possible that externalModuleName is undefined if it is not string literal. // This can happen in the invalid import syntax. // E.g : "import * from alias from 'someLib';" externalModuleName && (includeNonAmdDependencies && importAliasName ? (// Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier ts1.setEmitFlags(importAliasName, 4 /* NoSubstitution */ ), aliasedModuleNames.push(externalModuleName), importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, importAliasName))) : unaliasedModuleNames.push(externalModuleName)); } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } function getAMDImportExpressionForImport(node) { if (!(ts1.isImportEqualsDeclaration(node) || ts1.isExportDeclaration(node)) && ts1.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) { var name = ts1.getLocalNameForExternalImport(factory, node, currentSourceFile), expr = getHelperExpressionForImport(node, name); // TODO: GH#18217 if (expr !== name) return factory.createExpressionStatement(factory.createAssignment(name, expr)); } } /** * Transforms a SourceFile into an AMD or UMD module body. * * @param node The SourceFile node. */ function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = [], statementOffset = factory.copyPrologue(node.statements, statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, topLevelVisitor); shouldEmitUnderscoreUnderscoreESModule() && ts1.append(statements, createUnderscoreUnderscoreESModule()), ts1.length(currentModuleInfo.exportedNames) && ts1.append(statements, factory.createExpressionStatement(ts1.reduceLeft(currentModuleInfo.exportedNames, function(prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts1.idText(nextId))), prev); }, factory.createVoidZero()))), // Visit each statement of the module body. ts1.append(statements, ts1.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts1.isStatement)), moduleKind === ts1.ModuleKind.AMD && ts1.addRange(statements, ts1.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)), ts1.addRange(statements, ts1.visitNodes(node.statements, topLevelVisitor, ts1.isStatement, statementOffset)), // Append the 'export =' statement if provided. addExportEqualsIfNeeded(statements, /*emitAsReturn*/ !0), // End the lexical environment for the module body // and merge any new lexical declarations. ts1.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var body = factory.createBlock(statements, /*multiLine*/ !0); return needUMDDynamicImportHelper && ts1.addEmitHelper(body, dynamicImportUMDHelper), body; } /** * Adds the down-level representation of `export=` to the statement list if one exists * in the source file. * * @param statements The Statement list to modify. * @param emitAsReturn A value indicating whether to emit the `export=` statement as a * return statement. */ function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { var expressionResult = ts1.visitNode(currentModuleInfo.exportEquals.expression, visitor); if (expressionResult) { if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts1.setTextRange(statement, currentModuleInfo.exportEquals), ts1.setEmitFlags(statement, 1920 /* NoComments */ ), statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts1.setTextRange(statement, currentModuleInfo.exportEquals), ts1.setEmitFlags(statement, 1536 /* NoComments */ ), statements.push(statement); } } } } // // Top-Level Source Element Visitors // /** * Visits a node at the top level of the source file. * * @param node The node to visit. */ function topLevelVisitor(node) { switch(node.kind){ case 265 /* ImportDeclaration */ : return(/** * Visits an ImportDeclaration node. * * @param node The node to visit. */ function(node) { var statements, namespaceDeclaration = ts1.getNamespaceDeclarationNode(node); if (moduleKind !== ts1.ModuleKind.AMD) { if (!node.importClause) // import "mod"; return ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node); var variables = []; namespaceDeclaration && !ts1.isDefaultImport(node) ? // import * as n from "mod"; variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ void 0, /*type*/ void 0, getHelperExpressionForImport(node, createRequireCall(node)))) : (// import d from "mod"; // import { x, y } from "mod"; // import d, { x, y } from "mod"; // import d, * as n from "mod"; variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), /*exclamationToken*/ void 0, /*type*/ void 0, getHelperExpressionForImport(node, createRequireCall(node)))), namespaceDeclaration && ts1.isDefaultImport(node) && variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ void 0, /*type*/ void 0, factory.getGeneratedNameForNode(node)))), statements = ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(/*modifiers*/ void 0, factory.createVariableDeclarationList(variables, 2 /* Const */ * (languageVersion >= 2 /* ES2015 */ ) /* None */ )), /*location*/ node), /*original*/ node)); } else namespaceDeclaration && ts1.isDefaultImport(node) && // import d, * as n from "mod"; (statements = ts1.append(statements, factory.createVariableStatement(/*modifiers*/ void 0, factory.createVariableDeclarationList([ ts1.setOriginalNode(ts1.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), /*exclamationToken*/ void 0, /*type*/ void 0, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) ], 2 /* Const */ * (languageVersion >= 2 /* ES2015 */ ) /* None */ )))); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else statements = appendExportsOfImportDeclaration(statements, node); return ts1.singleOrMany(statements); }(node)); case 264 /* ImportEqualsDeclaration */ : return(/** * Visits an ImportEqualsDeclaration node. * * @param node The node to visit. */ function(node) { if (ts1.Debug.assert(ts1.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."), moduleKind !== ts1.ModuleKind.AMD ? statements = ts1.hasSyntacticModifier(node, 1 /* Export */ ) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)) : ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(/*modifiers*/ void 0, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.cloneNode(node.name), /*exclamationToken*/ void 0, /*type*/ void 0, createRequireCall(node)) ], /*flags*/ 2 /* Const */ * (languageVersion >= 2 /* ES2015 */ ) /* None */ )), node), node)) : ts1.hasSyntacticModifier(node, 1 /* Export */ ) && (statements = ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node))), hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var statements, id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); } else statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts1.singleOrMany(statements); }(node)); case 271 /* ExportDeclaration */ : return(/** * Visits an ExportDeclaration node. * * @param The node to visit. */ function(node) { if (node.moduleSpecifier) { var innerExpr, generatedName = factory.getGeneratedNameForNode(node); if (node.exportClause && ts1.isNamedExports(node.exportClause)) { var statements = []; // export { x, y } from "mod"; moduleKind !== ts1.ModuleKind.AMD && statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(/*modifiers*/ void 0, factory.createVariableDeclarationList([ factory.createVariableDeclaration(generatedName, /*exclamationToken*/ void 0, /*type*/ void 0, createRequireCall(node)) ])), /*location*/ node), /* original */ node)); for(var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++){ var specifier = _a[_i]; if (0 /* ES3 */ === languageVersion) statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : void 0)), specifier), specifier)); else { var exportNeedsImportDefault = !!ts1.getESModuleInterop(compilerOptions) && !(67108864 /* NeverApplyImportHelper */ & ts1.getEmitFlags(node)) && "default" === ts1.idText(specifier.propertyName || specifier.name), exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ void 0, /* liveBinding */ !0)), specifier), specifier)); } } return ts1.singleOrMany(statements); } if (!node.exportClause) // export * from "mod"; return ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts1.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node); var statements = []; return(// export * as ns from "mod"; // export * as default from "mod"; statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), (innerExpr = moduleKind !== ts1.ModuleKind.AMD ? createRequireCall(node) : ts1.isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory.createIdentifier(ts1.idText(node.exportClause.name)), !ts1.getESModuleInterop(compilerOptions) || 67108864 /* NeverApplyImportHelper */ & ts1.getEmitFlags(node) ? innerExpr : ts1.getExportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : innerExpr))), node), node)), ts1.singleOrMany(statements)); } }(node)); case 270 /* ExportAssignment */ : return(/** * Visits an ExportAssignment node. * * @param node The node to visit. */ function(node) { if (!node.isExportEquals) { var statements, original = node.original; if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts1.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ !0); } else statements = appendExportStatement(statements, factory.createIdentifier("default"), ts1.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ !0); return ts1.singleOrMany(statements); } }(node)); case 236 /* VariableStatement */ : return(/** * Visits a VariableStatement node. * * @param node The node to visit. */ function(node) { if (ts1.hasSyntacticModifier(node, 1 /* Export */ )) { // If we're exporting these variables, then these just become assignments to 'exports.x'. for(var statements, variables, expressions, modifiers = void 0, removeCommentsOnExpressions = !1, _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++){ var variable = _a[_i]; if (ts1.isIdentifier(variable.name) && ts1.isLocalName(variable.name)) modifiers || (modifiers = ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier)), variables = ts1.append(variables, variable); else if (variable.initializer) { if (!ts1.isBindingPattern(variable.name) && (ts1.isArrowFunction(variable.initializer) || ts1.isFunctionExpression(variable.initializer) || ts1.isClassExpression(variable.initializer))) { var expression = factory.createAssignment(ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), /*location*/ variable.name), factory.createIdentifier(ts1.getTextOfIdentifierOrLiteral(variable.name))), updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts1.visitNode(variable.initializer, visitor)); variables = ts1.append(variables, updatedVariable), expressions = ts1.append(expressions, expression), removeCommentsOnExpressions = !0; } else expressions = ts1.append(expressions, ts1.isBindingPattern(variable.name) ? ts1.flattenDestructuringAssignment(ts1.visitNode(variable, visitor), /*visitor*/ void 0, context, 0 /* All */ , /*needsValue*/ !1, createAllExportExpressions) : factory.createAssignment(ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), /*location*/ variable.name), variable.initializer ? ts1.visitNode(variable.initializer, visitor) : factory.createVoidZero())); } } if (variables && (statements = ts1.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)))), expressions) { var statement = ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node); removeCommentsOnExpressions && ts1.removeAllComments(statement), statements = ts1.append(statements, statement); } } else statements = ts1.append(statements, ts1.visitEachChild(node, visitor, context)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); } else statements = appendExportsOfVariableStatement(statements, node); return ts1.singleOrMany(statements); }(node)); case 255 /* FunctionDeclaration */ : return(/** * Visits a FunctionDeclaration node. * * @param node The node to visit. */ function(node) { var statements; if (statements = ts1.hasSyntacticModifier(node, 1 /* Export */ ) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createFunctionDeclaration(/*decorators*/ void 0, ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ !0, /*allowSourceMaps*/ !0), /*typeParameters*/ void 0, ts1.visitNodes(node.parameters, visitor), /*type*/ void 0, ts1.visitEachChild(node.body, visitor, context)), /*location*/ node), /*original*/ node)) : ts1.append(statements, ts1.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else statements = appendExportsOfHoistedDeclaration(statements, node); return ts1.singleOrMany(statements); }(node)); case 256 /* ClassDeclaration */ : return(/** * Visits a ClassDeclaration node. * * @param node The node to visit. */ function(node) { var statements; if (statements = ts1.hasSyntacticModifier(node, 1 /* Export */ ) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createClassDeclaration(/*decorators*/ void 0, ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier), factory.getDeclarationName(node, /*allowComments*/ !0, /*allowSourceMaps*/ !0), /*typeParameters*/ void 0, ts1.visitNodes(node.heritageClauses, visitor), ts1.visitNodes(node.members, visitor)), node), node)) : ts1.append(statements, ts1.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else statements = appendExportsOfHoistedDeclaration(statements, node); return ts1.singleOrMany(statements); }(node)); case 350 /* MergeDeclarationMarker */ : return(/** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged * and transformed declaration. * * @param node The node to visit. */ function(node) { // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding // declaration we do not emit a leading variable declaration. To preserve the // begin/end semantics of the declararation and to properly handle exports // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. // // To balance the declaration, add the exports of the elided variable // statement. if (hasAssociatedEndOfDeclarationMarker(node) && 236 /* VariableStatement */ === node.original.kind) { var id = ts1.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; }(node)); case 351 /* EndOfDeclarationMarker */ : var id, statements; return (statements = deferredExports[id = ts1.getOriginalNodeId(node)]) ? (delete deferredExports[id], ts1.append(statements, node)) : node; default: return visitor(node); } } function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. if (!(71307264 /* ContainsUpdateExpressionForIdentifier */ & node.transformFlags)) return node; switch(node.kind){ case 241 /* ForStatement */ : return factory.updateForStatement(node, ts1.visitNode(node.initializer, discardedValueVisitor, ts1.isForInitializer), ts1.visitNode(node.condition, visitor, ts1.isExpression), ts1.visitNode(node.incrementor, discardedValueVisitor, ts1.isExpression), ts1.visitIterationBody(node.statement, visitor, context)); case 237 /* ExpressionStatement */ : return factory.updateExpressionStatement(node, ts1.visitNode(node.expression, discardedValueVisitor, ts1.isExpression)); case 211 /* ParenthesizedExpression */ : return factory.updateParenthesizedExpression(node, ts1.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts1.isExpression)); case 348 /* PartiallyEmittedExpression */ : return factory.updatePartiallyEmittedExpression(node, ts1.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts1.isExpression)); case 207 /* CallExpression */ : if (ts1.isImportCall(node) && void 0 === currentSourceFile.impliedNodeFormat) return function(node) { var externalModuleName = ts1.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions), firstArgument = ts1.visitNode(ts1.firstOrUndefined(node.arguments), visitor), argument = !externalModuleName || firstArgument && ts1.isStringLiteral(firstArgument) && firstArgument.text === externalModuleName.text ? firstArgument : externalModuleName, containsLexicalThis = !!(8192 /* ContainsLexicalThis */ & node.transformFlags); switch(compilerOptions.module){ case ts1.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); case ts1.ModuleKind.UMD: return function(arg, containsLexicalThis) { if (// (function (factory) { // ... (regular UMD) // } // })(function (require, exports, useSyncRequire) { // "use strict"; // Object.defineProperty(exports, "__esModule", { value: true }); // var __syncRequire = typeof module === "object" && typeof module.exports === "object"; // var __resolved = new Promise(function (resolve) { resolve(); }); // ..... // __syncRequire // ? __resolved.then(function () { return require(x); }) /*CommonJs Require*/ // : new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ // }); needUMDDynamicImportHelper = !0, ts1.isSimpleCopiableExpression(arg)) { var argClone = ts1.isGeneratedIdentifier(arg) ? arg : ts1.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts1.setEmitFlags(ts1.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */ ); return factory.createConditionalExpression(/*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ void 0, /*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis), /*colonToken*/ void 0, /*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis)); } var temp = factory.createTempVariable(hoistVariableDeclaration); return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(/*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ void 0, /*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis), /*colonToken*/ void 0, /*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis))); }(null != argument ? argument : factory.createVoidZero(), containsLexicalThis); case ts1.ModuleKind.CommonJS: default: return createImportCallExpressionCommonJS(argument, containsLexicalThis); } }(node); break; case 220 /* BinaryExpression */ : if (ts1.isDestructuringAssignment(node)) return !function destructuringNeedsFlattening(node) { if (ts1.isObjectLiteralExpression(node)) for(var _i = 0, _a = node.properties; _i < _a.length; _i++){ var elem = _a[_i]; switch(elem.kind){ case 294 /* PropertyAssignment */ : if (destructuringNeedsFlattening(elem.initializer)) return !0; break; case 295 /* ShorthandPropertyAssignment */ : if (destructuringNeedsFlattening(elem.name)) return !0; break; case 296 /* SpreadAssignment */ : if (destructuringNeedsFlattening(elem.expression)) return !0; break; case 168 /* MethodDeclaration */ : case 171 /* GetAccessor */ : case 172 /* SetAccessor */ : return !1; default: ts1.Debug.assertNever(elem, "Unhandled object member kind"); } } else if (ts1.isArrayLiteralExpression(node)) for(var _b = 0, _c = node.elements; _b < _c.length; _b++){ var elem = _c[_b]; if (ts1.isSpreadElement(elem)) { if (destructuringNeedsFlattening(elem.expression)) return !0; } else if (destructuringNeedsFlattening(elem)) return !0; } else if (ts1.isIdentifier(node)) return ts1.length(getExports(node)) > +!!ts1.isExportName(node); return !1; }(node.left) ? ts1.visitEachChild(node, visitor, context) : ts1.flattenDestructuringAssignment(node, visitor, context, 0 /* All */ , !valueIsDiscarded, createAllExportExpressions); break; case 218 /* PrefixUnaryExpression */ : case 219 /* PostfixUnaryExpression */ : return function(node, valueIsDiscarded) { // When we see a prefix or postfix increment expression whose operand is an exported // symbol, we should ensure all exports of that symbol are updated with the correct // value. // // - We do not transform generated identifiers for any reason. // - We do not transform identifiers tagged with the LocalName flag. // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. if ((45 /* PlusPlusToken */ === node.operator || 46 /* MinusMinusToken */ === node.operator) && ts1.isIdentifier(node.operand) && !ts1.isGeneratedIdentifier(node.operand) && !ts1.isLocalName(node.operand) && !ts1.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { var temp = void 0, expression = ts1.visitNode(node.operand, visitor, ts1.isExpression); ts1.isPrefixUnaryExpression(node) ? expression = factory.updatePrefixUnaryExpression(node, expression) : (expression = factory.updatePostfixUnaryExpression(node, expression), valueIsDiscarded || (temp = factory.createTempVariable(hoistVariableDeclaration), expression = factory.createAssignment(temp, expression), ts1.setTextRange(expression, node)), expression = factory.createComma(expression, factory.cloneNode(node.operand)), ts1.setTextRange(expression, node)); for(var _i = 0; _i < exportedNames.length; _i++){ var exportName = exportedNames[_i]; noSubstitution[ts1.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression), ts1.setTextRange(expression, node); } return temp && (noSubstitution[ts1.getNodeId(expression)] = !0, expression = factory.createComma(expression, temp), ts1.setTextRange(expression, node)), expression; } } return ts1.visitEachChild(node, visitor, context); }(node, valueIsDiscarded); } return ts1.visitEachChild(node, visitor, context); } function visitor(node) { return visitorWorker(node, /*valueIsDiscarded*/ !1); } function discardedValueVisitor(node) { return visitorWorker(node, /*valueIsDiscarded*/ !0); } function createImportCallExpressionAMD(arg, containsLexicalThis) { // improt("./blah") // emit as // define(["require", "exports", "blah"], function (require, exports) { // ... // new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ // }); var func, resolve = factory.createUniqueName("resolve"), reject = factory.createUniqueName("reject"), parameters = [ factory.createParameterDeclaration(/*decorator*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, /*name*/ resolve), factory.createParameterDeclaration(/*decorator*/ void 0, /*modifiers*/ void 0, /*dotDotDotToken*/ void 0, /*name*/ reject) ], body = factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ void 0, [ factory.createArrayLiteralExpression([ arg || factory.createOmittedExpression() ]), resolve, reject ])) ]); languageVersion >= 2 /* ES2015 */ ? func = factory.createArrowFunction(/*modifiers*/ void 0, /*typeParameters*/ void 0, parameters, /*type*/ void 0, /*equalsGreaterThanToken*/ void 0, body) : (func = factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, parameters, /*type*/ void 0, body), containsLexicalThis && ts1.setEmitFlags(func, 8 /* CapturesThis */ )); var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ void 0, [ func ]); return ts1.getESModuleInterop(compilerOptions) ? factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ void 0, [ emitHelpers().createImportStarCallbackHelper() ]) : promise; } function createImportCallExpressionCommonJS(arg, containsLexicalThis) { // import("./blah") // emit as // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/ // We have to wrap require in then callback so that require is done in asynchronously // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately var func, promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ void 0, /*argumentsArray*/ []), requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ void 0, arg ? [ arg ] : []); return ts1.getESModuleInterop(compilerOptions) && (requireCall = emitHelpers().createImportStarHelper(requireCall)), languageVersion >= 2 /* ES2015 */ ? func = factory.createArrowFunction(/*modifiers*/ void 0, /*typeParameters*/ void 0, /*parameters*/ [], /*type*/ void 0, /*equalsGreaterThanToken*/ void 0, requireCall) : (func = factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, /*parameters*/ [], /*type*/ void 0, factory.createBlock([ factory.createReturnStatement(requireCall) ])), containsLexicalThis && ts1.setEmitFlags(func, 8 /* CapturesThis */ )), factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ void 0, [ func ]); } function getHelperExpressionForImport(node, innerExpr) { return !ts1.getESModuleInterop(compilerOptions) || 67108864 /* NeverApplyImportHelper */ & ts1.getEmitFlags(node) ? innerExpr : ts1.getImportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : ts1.getImportNeedsImportDefaultHelper(node) ? emitHelpers().createImportDefaultHelper(innerExpr) : innerExpr; } /** * Creates a `require()` call to import an external module. * * @param importNode The declararation to import. */ function createRequireCall(importNode) { var moduleName = ts1.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), args = []; return moduleName && args.push(moduleName), factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ void 0, args); } function createAllExportExpressions(name, value, location) { var exportedNames = getExports(name); if (exportedNames) { for(var expression = ts1.isExportName(name) ? value : factory.createAssignment(name, value), _i = 0; _i < exportedNames.length; _i++){ var exportName = exportedNames[_i]; // Mark the node to prevent triggering substitution. ts1.setEmitFlags(expression, 4 /* NoSubstitution */ ), expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; } return factory.createAssignment(name, value); } /** * Determines whether a node has an associated EndOfDeclarationMarker. * * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { return (4194304 /* HasEndOfDeclarationMarker */ & ts1.getEmitFlags(node)) != 0; } /** * Appends the exports of an ImportDeclaration to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfImportDeclaration(statements, decl) { if (currentModuleInfo.exportEquals) return statements; var importClause = decl.importClause; if (!importClause) return statements; importClause.name && (statements = appendExportsOfDeclaration(statements, importClause)); var namedBindings = importClause.namedBindings; if (namedBindings) switch(namedBindings.kind){ case 267 /* NamespaceImport */ : statements = appendExportsOfDeclaration(statements, namedBindings); break; case 268 /* NamedImports */ : for(var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++)statements = appendExportsOfDeclaration(statements, _a[_i], /* liveBinding */ !0); } return statements; } /** * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfImportEqualsDeclaration(statements, decl) { return currentModuleInfo.exportEquals ? statements : appendExportsOfDeclaration(statements, decl); } /** * Appends the exports of a VariableStatement to a statement list, returning the statement * list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param node The VariableStatement whose exports are to be recorded. */ function appendExportsOfVariableStatement(statements, node) { if (currentModuleInfo.exportEquals) return statements; for(var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++)statements = /** * Appends the exports of a VariableDeclaration or BindingElement to a statement list, * returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfBindingElement(statements, decl) { if (currentModuleInfo.exportEquals) return statements; if (ts1.isBindingPattern(decl.name)) for(var _i = 0, _a = decl.name.elements; _i < _a.length; _i++){ var element = _a[_i]; ts1.isOmittedExpression(element) || (statements = appendExportsOfBindingElement(statements, element)); } else ts1.isGeneratedIdentifier(decl.name) || (statements = appendExportsOfDeclaration(statements, decl)); return statements; }(statements, _a[_i]); return statements; } /** * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, * returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration whose exports are to be recorded. */ function appendExportsOfHoistedDeclaration(statements, decl) { return currentModuleInfo.exportEquals || (ts1.hasSyntacticModifier(decl, 1 /* Export */ ) && (statements = appendExportStatement(statements, ts1.hasSyntacticModifier(decl, 512 /* Default */ ) ? factory.createIdentifier("default") : factory.getDeclarationName(decl), factory.getLocalName(decl), /*location*/ decl)), decl.name && (statements = appendExportsOfDeclaration(statements, decl))), statements; } /** * Appends the exports of a declaration to a statement list, returning the statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param decl The declaration to export. */ function appendExportsOfDeclaration(statements, decl, liveBinding) { var name = factory.getDeclarationName(decl), exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts1.idText(name)); if (exportSpecifiers) for(var _i = 0; _i < exportSpecifiers.length; _i++){ var exportSpecifier = exportSpecifiers[_i]; statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ void 0, liveBinding); } return statements; } /** * Appends the down-level representation of an export to a statement list, returning the * statement list. * * @param statements A statement list to which the down-level export statements are to be * appended. If `statements` is `undefined`, a new array is allocated if statements are * appended. * @param exportName The name of the export. * @param expression The expression to export. * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) { var statement; return statements = ts1.append(statements, (statement = ts1.setTextRange(factory.createExpressionStatement(createExportExpression(exportName, expression, /* location */ void 0, liveBinding)), location), ts1.startOnNewLine(statement), allowComments || ts1.setEmitFlags(statement, 1536 /* NoComments */ ), statement)); } function createUnderscoreUnderscoreESModule() { var statement; return statement = 0 /* ES3 */ === languageVersion ? factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())) : factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ void 0, [ factory.createIdentifier("exports"), factory.createStringLiteral("__esModule"), factory.createObjectLiteralExpression([ factory.createPropertyAssignment("value", factory.createTrue()) ]) ])), ts1.setEmitFlags(statement, 1048576 /* CustomPrologue */ ), statement; } /** * Creates a call to the current file's export function to export a value. * * @param name The bound name of the export. * @param value The exported value. * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { return ts1.setTextRange(liveBinding && 0 /* ES3 */ !== languageVersion ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ void 0, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), factory.createObjectLiteralExpression([ factory.createPropertyAssignment("enumerable", factory.createTrue()), factory.createPropertyAssignment("get", factory.createFunctionExpression(/*modifiers*/ void 0, /*asteriskToken*/ void 0, /*name*/ void 0, /*typeParameters*/ void 0, /*parameters*/ [], /*type*/ void 0, factory.createBlock([ factory.createReturnStatement(value) ]))) ]) ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location); } // // Modifier Visitors // /** * Visit nodes to elide module-specific modifiers. * * @param node The node to visit. */ function modifierVisitor(node) { // Elide module-specific modifiers. switch(node.kind){ case 93 /* ExportKeyword */ : case 88 /* DefaultKeyword */ : return; } return node; } /** * Substitution for an Identifier expression that may contain an imported or exported * symbol. * * @param node The node to substitute. */ function substituteExpressionIdentifier(node) { var _a, _b; if (4096 /* HelperName */ & ts1.getEmitFlags(node)) { var externalHelpersModuleName = ts1.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } else if (!(ts1.isGeneratedIdentifier(node) && !(64 /* AllowNameSubstitution */ & node.autoGenerateFlags)) && !ts1.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts1.isExportName(node)); if (exportContainer && 303 /* SourceFile */ === exportContainer.kind) return ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts1.isImportClause(importDeclaration)) return ts1.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), /*location*/ node); if (ts1.isImportSpecifier(importDeclaration)) { var name = importDeclaration.propertyName || importDeclaration.name; return ts1.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode((null === (_b = null === (_a = importDeclaration.parent) || void 0 === _a ? void 0 : _a.parent) || void 0 === _b ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(name)), /*location*/ node); } } } return node; } /** * Gets the additional exports of a name. * * @param name The name. */ function getExports(name) { if (!ts1.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) return currentModuleInfo && currentModuleInfo.exportedBindings[ts1.getOriginalNodeId(valueDeclaration)]; } } }, dynamicImportUMDHelper = { name: "typescript:dynamicimport-sync-require", scoped: !0, text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/001/input.js
JavaScript
const re = new RegExp("^/(?!_next).*$");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/001/output.js
JavaScript
RegExp("^/(?!_next).*$");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/002/input.js
JavaScript
const globalStyles = new String(":root {--a-b:4px}"); globalStyles.__hash = "34c3f159e306f9e9"; export default globalStyles;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/002/output.js
JavaScript
const globalStyles = new String(":root {--a-b:4px}"); globalStyles.__hash = "34c3f159e306f9e9"; export default globalStyles;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/003/input.js
JavaScript
import { a, b } from "./utils"; if (typeof window !== "undefined") { require("intersection-observer"); } const manager = (function makeManager() { const c = new Map(); function d(e) { return f(e) || new IntersectionObserver(g, e); } function f(g = {}) { const h = b(g); for (const i of c.keys()) { if (a(i, h)) { return i; } } return null; } function j(k) { return !c.has(k) ? c.set(k, new Map()).get(k) : c.get(k); } function l(m, n, o) { const p = j(m); p.set(n, o); m.observe(n); } function q(r, s) { const t = j(r); t.delete(s); r.unobserve(s); } function g(u, v) { for (let w of u) { const x = j(v); const y = x.get(w.target); if (y) { y(w); } } } return { d, l, q, }; })(); export default manager; export const { d } = manager; export const { l } = manager; export const { q } = manager;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/003/output.js
JavaScript
import { a, b } from "./utils"; "undefined" != typeof window && require("intersection-observer"); const manager = function() { const c = new Map(); function j(k) { return c.has(k) ? c.get(k) : c.set(k, new Map()).get(k); } function g(u, v) { for (let w of u){ const y = j(v).get(w.target); y && y(w); } } return { d: function(e) { return function(g = {}) { const h = b(g); for (const i of c.keys())if (a(i, h)) return i; return null; }(e) || new IntersectionObserver(g, e); }, l: function(m, n, o) { j(m).set(n, o), m.observe(n); }, q: function(r, s) { j(r).delete(s), r.unobserve(s); } }; }(); export default manager; export const { d } = manager; export const { l } = manager; export const { q } = manager;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/004/input.js
JavaScript
export function ItemsList() { var _ref; var _temp, _this, _ret; _classCallCheck(this, ItemsList); for ( var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++ ) { args[_key] = arguments[_key]; } return ( (_ret = ((_temp = ((_this = _possibleConstructorReturn( this, (_ref = ItemsList.__proto__ || Object.getPrototypeOf(ItemsList)).call.apply( _ref, [this].concat(args) ) )), _this)), (_this.storeHighlightedItemReference = function (highlightedItem) { _this.props.onHighlightedItemChange( highlightedItem === null ? null : highlightedItem.item ); }), _temp)), _possibleConstructorReturn(_this, _ret) ); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/004/output.js
JavaScript
export function ItemsList() { _classCallCheck(this, ItemsList); for(var _ref, _temp, _this, _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; return _temp = _this = _possibleConstructorReturn(this, (_ref = ItemsList.__proto__ || Object.getPrototypeOf(ItemsList)).call.apply(_ref, [ this ].concat(args))), _this.storeHighlightedItemReference = function(highlightedItem) { _this.props.onHighlightedItemChange(null === highlightedItem ? null : highlightedItem.item); }, _possibleConstructorReturn(_this, _temp); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/005/input.js
JavaScript
const s = 1000; const m = s * 60; const h = m * 60; const d = h * 24; const w = d * 7; const y = d * 365.25; function ms(value, options) { try { if (typeof value === "string" && value.length > 0) { return parse(value); } else if (typeof value === "number" && isFinite(value)) { return options?.long ? fmtLong(value) : fmtShort(value); } throw new Error("Value is not a string or number."); } catch (error) { const message = isError(error) ? `${error.message}. value=${JSON.stringify(value)}` : "An unknown error has occured."; throw new Error(message); } } function parse(str) { str = String(str); if (str.length > 100) { throw new Error("Value exceeds the maximum length of 100 characters."); } const match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( str ); if (!match) { return NaN; } const n = parseFloat(match[1]); const type = (match[2] || "ms").toLowerCase(); switch (type) { case "years": case "year": case "yrs": case "yr": case "y": return n * y; case "weeks": case "week": case "w": return n * w; case "days": case "day": case "d": return n * d; case "hours": case "hour": case "hrs": case "hr": case "h": return n * h; case "minutes": case "minute": case "mins": case "min": case "m": return n * m; case "seconds": case "second": case "secs": case "sec": case "s": return n * s; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return n; default: throw new Error( `The unit ${type} was matched, but no matching case exists.` ); } } export default ms; function fmtShort(ms) { const msAbs = Math.abs(ms); if (msAbs >= d) { return `${Math.round(ms / d)}d`; } if (msAbs >= h) { return `${Math.round(ms / h)}h`; } if (msAbs >= m) { return `${Math.round(ms / m)}m`; } if (msAbs >= s) { return `${Math.round(ms / s)}s`; } return `${ms}ms`; } function fmtLong(ms) { const msAbs = Math.abs(ms); if (msAbs >= d) { return plural(ms, msAbs, d, "day"); } if (msAbs >= h) { return plural(ms, msAbs, h, "hour"); } if (msAbs >= m) { return plural(ms, msAbs, m, "minute"); } if (msAbs >= s) { return plural(ms, msAbs, s, "second"); } return `${ms} ms`; } function plural(ms, msAbs, n, name) { const isPlural = msAbs >= n * 1.5; return `${Math.round(ms / n)} ${name}${isPlural ? "s" : ""}`; } function isError(error) { return typeof error === "object" && error !== null && "message" in error; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/005/output.js
JavaScript
export default function(value, options) { try { if ("string" == typeof value && value.length > 0) return function(str) { if ((str = String(str)).length > 100) throw Error("Value exceeds the maximum length of 100 characters."); const match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); if (!match) return NaN; const n = parseFloat(match[1]), type = (match[2] || "ms").toLowerCase(); switch(type){ case "years": case "year": case "yrs": case "yr": case "y": return 31557600000 * n; case "weeks": case "week": case "w": return 604800000 * n; case "days": case "day": case "d": return 86400000 * n; case "hours": case "hour": case "hrs": case "hr": case "h": return 3600000 * n; case "minutes": case "minute": case "mins": case "min": case "m": return 60000 * n; case "seconds": case "second": case "secs": case "sec": case "s": return 1000 * n; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return n; default: throw Error(`The unit ${type} was matched, but no matching case exists.`); } }(value); if ("number" == typeof value && isFinite(value)) return options?.long ? function(ms) { const msAbs = Math.abs(ms); return msAbs >= 86400000 ? plural(ms, msAbs, 86400000, "day") : msAbs >= 3600000 ? plural(ms, msAbs, 3600000, "hour") : msAbs >= 60000 ? plural(ms, msAbs, 60000, "minute") : msAbs >= 1000 ? plural(ms, msAbs, 1000, "second") : `${ms} ms`; }(value) : function(ms) { const msAbs = Math.abs(ms); return msAbs >= 86400000 ? `${Math.round(ms / 86400000)}d` : msAbs >= 3600000 ? `${Math.round(ms / 3600000)}h` : msAbs >= 60000 ? `${Math.round(ms / 60000)}m` : msAbs >= 1000 ? `${Math.round(ms / 1000)}s` : `${ms}ms`; }(value); throw Error("Value is not a string or number."); } catch (error) { throw Error("object" == typeof error && null !== error && "message" in error ? `${error.message}. value=${JSON.stringify(value)}` : "An unknown error has occured."); } } function plural(ms, msAbs, n, name) { return `${Math.round(ms / n)} ${name}${msAbs >= 1.5 * n ? "s" : ""}`; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/006/input.js
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment, } from "react/jsx-runtime"; import * as React from "react"; import invariant from "invariant"; import { injectScript } from "./utils/injectscript"; import { preventGoogleFonts } from "./utils/prevent-google-fonts"; import { isBrowser } from "./utils/isbrowser"; import { makeLoadScriptUrl } from "./utils/make-load-script-url"; let cleaningUp = false; export function DefaultLoadingElement() { return /*#__PURE__*/ _jsx("div", { children: `Loading...`, }); } export const defaultLoadScriptProps = { id: "script-loader", version: "weekly", }; class LoadScript extends React.PureComponent { componentDidMount() { if (isBrowser) { if (window.google && window.google.maps && !cleaningUp) { console.error("google api is already presented"); return; } this.isCleaningUp() .then(this.injectScript) .catch(function error(err) { console.error( "Error at injecting script after cleaning up: ", err ); }); } } componentDidUpdate(prevProps) { if (this.props.libraries !== prevProps.libraries) { console.warn( "Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables" ); } if (isBrowser && prevProps.language !== this.props.language) { this.cleanup(); // TODO: refactor to use gDSFP maybe... wait for hooks refactoring. // eslint-disable-next-line react/no-did-update-set-state this.setState(function setLoaded() { return { loaded: false, }; }, this.cleanupCallback); } } componentWillUnmount() { if (isBrowser) { this.cleanup(); const timeoutCallback = () => { if (!this.check.current) { // @ts-ignore delete window.google; cleaningUp = false; } }; window.setTimeout(timeoutCallback, 1); if (this.props.onUnmount) { this.props.onUnmount(); } } } render() { return /*#__PURE__*/ _jsxs(_Fragment, { children: [ /*#__PURE__*/ _jsx("div", { ref: this.check, }), this.state.loaded ? this.props.children : this.props.loadingElement || /*#__PURE__*/ _jsx(DefaultLoadingElement, {}), ], }); } constructor(...args) { super(...args); this.check = /*#__PURE__*/ React.createRef(); this.state = { loaded: false, }; this.cleanupCallback = () => { // @ts-ignore delete window.google.maps; this.injectScript(); }; this.isCleaningUp = async () => { function promiseCallback(resolve) { if (!cleaningUp) { resolve(); } else { if (isBrowser) { const timer = window.setInterval(function interval() { if (!cleaningUp) { window.clearInterval(timer); resolve(); } }, 1); } } return; } return new Promise(promiseCallback); }; this.cleanup = () => { cleaningUp = true; const script1 = document.getElementById(this.props.id); if (script1 && script1.parentNode) { script1.parentNode.removeChild(script1); } Array.prototype.slice .call(document.getElementsByTagName("script")) .filter(function filter(script) { return ( typeof script.src === "string" && script.src.includes("maps.googleapis") ); }) .forEach(function forEach(script) { if (script.parentNode) { script.parentNode.removeChild(script); } }); Array.prototype.slice .call(document.getElementsByTagName("link")) .filter(function filter(link) { return ( link.href === "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans" ); }) .forEach(function forEach(link) { if (link.parentNode) { link.parentNode.removeChild(link); } }); Array.prototype.slice .call(document.getElementsByTagName("style")) .filter(function filter(style) { return ( style.innerText !== undefined && style.innerText.length > 0 && style.innerText.includes(".gm-") ); }) .forEach(function forEach(style) { if (style.parentNode) { style.parentNode.removeChild(style); } }); }; this.injectScript = () => { if (this.props.preventGoogleFontsLoading) { preventGoogleFonts(); } invariant( !!this.props.id, 'LoadScript requires "id" prop to be a string: %s', this.props.id ); const injectScriptOptions = { id: this.props.id, nonce: this.props.nonce, url: makeLoadScriptUrl(this.props), }; injectScript(injectScriptOptions) .then(() => { if (this.props.onLoad) { this.props.onLoad(); } this.setState(function setLoaded() { return { loaded: true, }; }); return; }) .catch((err) => { if (this.props.onError) { this.props.onError(err); } console.error(` There has been an Error with loading Google Maps API script, please check that you provided correct google API key (${ this.props.googleMapsApiKey || "-" }) or Client ID (${ this.props.googleMapsClientId || "-" }) to <LoadScript /> Otherwise it is a Network issue. `); }); }; } } LoadScript.defaultProps = defaultLoadScriptProps; export default LoadScript;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/006/output.js
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import * as React from "react"; import invariant from "invariant"; import { injectScript } from "./utils/injectscript"; import { preventGoogleFonts } from "./utils/prevent-google-fonts"; import { isBrowser } from "./utils/isbrowser"; import { makeLoadScriptUrl } from "./utils/make-load-script-url"; let cleaningUp = !1; export function DefaultLoadingElement() { return /*#__PURE__*/ _jsx("div", { children: "Loading..." }); } export const defaultLoadScriptProps = { id: "script-loader", version: "weekly" }; class LoadScript extends React.PureComponent { componentDidMount() { if (isBrowser) { if (window.google && window.google.maps && !cleaningUp) { console.error("google api is already presented"); return; } this.isCleaningUp().then(this.injectScript).catch(function(err) { console.error("Error at injecting script after cleaning up: ", err); }); } } componentDidUpdate(prevProps) { this.props.libraries !== prevProps.libraries && console.warn("Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables"), isBrowser && prevProps.language !== this.props.language && (this.cleanup(), // TODO: refactor to use gDSFP maybe... wait for hooks refactoring. // eslint-disable-next-line react/no-did-update-set-state this.setState(function() { return { loaded: !1 }; }, this.cleanupCallback)); } componentWillUnmount() { isBrowser && (this.cleanup(), window.setTimeout(()=>{ this.check.current || (// @ts-ignore delete window.google, cleaningUp = !1); }, 1), this.props.onUnmount && this.props.onUnmount()); } render() { return /*#__PURE__*/ _jsxs(_Fragment, { children: [ /*#__PURE__*/ _jsx("div", { ref: this.check }), this.state.loaded ? this.props.children : this.props.loadingElement || /*#__PURE__*/ _jsx(DefaultLoadingElement, {}) ] }); } constructor(...args){ super(...args), this.check = /*#__PURE__*/ React.createRef(), this.state = { loaded: !1 }, this.cleanupCallback = ()=>{ // @ts-ignore delete window.google.maps, this.injectScript(); }, this.isCleaningUp = async ()=>new Promise(function(resolve) { if (cleaningUp) { if (isBrowser) { const timer = window.setInterval(function() { cleaningUp || (window.clearInterval(timer), resolve()); }, 1); } } else resolve(); }), this.cleanup = ()=>{ cleaningUp = !0; const script1 = document.getElementById(this.props.id); script1 && script1.parentNode && script1.parentNode.removeChild(script1), Array.prototype.slice.call(document.getElementsByTagName("script")).filter(function(script) { return "string" == typeof script.src && script.src.includes("maps.googleapis"); }).forEach(function(script) { script.parentNode && script.parentNode.removeChild(script); }), Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(link) { return "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans" === link.href; }).forEach(function(link) { link.parentNode && link.parentNode.removeChild(link); }), Array.prototype.slice.call(document.getElementsByTagName("style")).filter(function(style) { return void 0 !== style.innerText && style.innerText.length > 0 && style.innerText.includes(".gm-"); }).forEach(function(style) { style.parentNode && style.parentNode.removeChild(style); }); }, this.injectScript = ()=>{ this.props.preventGoogleFontsLoading && preventGoogleFonts(), invariant(!!this.props.id, 'LoadScript requires "id" prop to be a string: %s', this.props.id), injectScript({ id: this.props.id, nonce: this.props.nonce, url: makeLoadScriptUrl(this.props) }).then(()=>{ this.props.onLoad && this.props.onLoad(), this.setState(function() { return { loaded: !0 }; }); }).catch((err)=>{ this.props.onError && this.props.onError(err), console.error(` There has been an Error with loading Google Maps API script, please check that you provided correct google API key (${this.props.googleMapsApiKey || "-"}) or Client ID (${this.props.googleMapsClientId || "-"}) to <LoadScript /> Otherwise it is a Network issue. `); }); }; } } LoadScript.defaultProps = defaultLoadScriptProps; export default LoadScript;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/007/input.js
JavaScript
import _JSXStyle from "styled-jsx/style"; const WithSidebar = ({ right = false, top = false, sidebar, sidebarWidth = 230, hideOnMobile = false, breakpoint = 730, children, }) => /*#__PURE__*/ React.createElement( "main", { className: _JSXStyle.dynamic([ [ "4507deac72c40d6c", [ right ? "row-reverse" : "row", sidebarWidth, breakpoint, top ? "column" : "column-reverse", ], ], ]), }, /*#__PURE__*/ React.createElement( Sidebar, { width: sidebarWidth, right: right, hide: hideOnMobile, breakpoint: breakpoint, }, sidebar ), /*#__PURE__*/ React.createElement( "div", { className: _JSXStyle.dynamic([ [ "4507deac72c40d6c", [ right ? "row-reverse" : "row", sidebarWidth, breakpoint, top ? "column" : "column-reverse", ], ], ]), }, children ), /*#__PURE__*/ React.createElement( _JSXStyle, { id: "4507deac72c40d6c", dynamic: [ right ? "row-reverse" : "row", sidebarWidth, breakpoint, top ? "column" : "column-reverse", ], }, `main.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-flex-direction:${ right ? "row-reverse" : "row" };-ms-flex-direction:${ right ? "row-reverse" : "row" };flex-direction:${ right ? "row-reverse" : "row" };-webkit-box-pack:justify;-webkit-justify-content:space-between;-moz-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;margin-bottom:var(--geist-gap-double)}div.__jsx-style-dynamic-selector{width:100%;max-width:-webkit-calc(100% - ${sidebarWidth}px - var(--geist-gap-double));max-width:-moz-calc(100% - ${sidebarWidth}px - var(--geist-gap-double));max-width:calc(100% - ${sidebarWidth}px - var(--geist-gap-double))}@media(max-width:${breakpoint}px){main.__jsx-style-dynamic-selector{-webkit-flex-direction:${ top ? "column" : "column-reverse" };-ms-flex-direction:${ top ? "column" : "column-reverse" };flex-direction:${ top ? "column" : "column-reverse" }}div.__jsx-style-dynamic-selector{max-width:unset}}` ) ); WithSidebar({});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/issues/vercel/007/output.js
JavaScript
import _JSXStyle from "styled-jsx/style"; (({ right = !1, top = !1, sidebar, sidebarWidth = 230, hideOnMobile = !1, breakpoint = 730, children })=>(_JSXStyle.dynamic([ [ "4507deac72c40d6c", [ right ? "row-reverse" : "row", sidebarWidth, breakpoint, top ? "column" : "column-reverse" ] ] ]), /*#__PURE__*/ Sidebar, /*#__PURE__*/ _JSXStyle.dynamic([ [ "4507deac72c40d6c", [ right ? "row-reverse" : "row", sidebarWidth, breakpoint, top ? "column" : "column-reverse" ] ] ]), /*#__PURE__*/ top ? "column" : "column-reverse"))({});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/array/input.js
JavaScript
// Invalid f([][0]); f([][1]); f([][-1]); f([].invalid); f([]["invalid"]); f([][[]]); f([][0+[]]); // Object symbols [].constructor; [].__proto__; [].__defineGetter__; [].__defineSetter__; [].__lookupGetter__; [].__lookupSetter__; [].hasOwnProperty; [].isPrototypeOf; [].propertyIsEnumerable; [].toLocaleString; [].toString; [].valueOf; // Array symbols [].length; [].at; [].concat; [].copyWithin; [].entries; [].every; [].fill; [].filter; [].find; [].findIndex; [].findLast; [].findLastIndex; [].flat; [].flatMap; [].forEach; [].includes; [].indexOf; [].join; [].keys; [].lastIndexOf; [].map; [].pop; [].push; [].reduce; [].reduceRight; [].reverse; [].shift; [].slice; [].some; [].sort; [].splice; [].toReversed; [].toSorted; [].toSpliced; [].unshift; [].values; [].with;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/array/output.js
JavaScript
// Invalid f(void 0), f(void 0), f(void 0), f(void 0), f(void 0), f(void 0), f(void 0), // Object symbols [].constructor, [].__proto__, [].__defineGetter__, [].__defineSetter__, [].__lookupGetter__, [].__lookupSetter__, [].hasOwnProperty, [].isPrototypeOf, [].propertyIsEnumerable, [].toLocaleString, [].toString, [].valueOf, [].at, [].concat, [].copyWithin, [].entries, [].every, [].fill, [].filter, [].find, [].findIndex, [].findLast, [].findLastIndex, [].flat, [].flatMap, [].forEach, [].includes, [].indexOf, [].join, [].keys, [].lastIndexOf, [].map, [].pop, [].push, [].reduce, [].reduceRight, [].reverse, [].shift, [].slice, [].some, [].sort, [].splice, [].toReversed, [].toSorted, [].toSpliced, [].unshift, [].values, [].with;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/array_side_effects/input.js
JavaScript
// Out of bounds f([][-1]); f([][1]); f([][[]]); f([][0+[]]); f([x(), 2, 'a', 1+1, y()][-1]); f([x(), 2, 'a', 1+1, y()][10]); // Invalid property f([].invalid); f([]["invalid"]); f([x(), 2, 'a', 1+1, y()].invalid); f([x(), 2, 'a', 1+1, y()]["invalid"]); // Valid property f([].push); f([]["push"]); f([x(), 2, 'a', 1+1, y()].push); f([x(), 2, 'a', 1+1, y()]["push"]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/array_side_effects/output.js
JavaScript
// Out of bounds f(void 0), f(void 0), f(void 0), f(void 0), f((x(), void y())), f((x(), void y())), // Invalid property f(void 0), f(void 0), f((x(), void y())), f((x(), void y())), // Valid property f([].push), f([].push), f([ x(), y() ].push), f([ x(), y() ].push);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/assignment/input.js
JavaScript
f({}.x = 5);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/assignment/output.js
JavaScript
f({}.x = 5);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/callee/input.js
JavaScript
try { const foo = {}; foo?.bar.baz?.(); } catch (e) { console.log('PASS'); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/callee/output.js
JavaScript
try { ({}).bar.baz?.(); } catch (e) { console.log('PASS'); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/object/input.js
JavaScript
// Invalid ({}[0]); ({}.invalid); ({}["invalid"]); ({}[[]]); ({}[0+[]]); // Object symbols ({}.constructor); ({}.__proto__); ({}.__defineGetter__); ({}.__defineSetter__); ({}.__lookupGetter__); ({}.__lookupSetter__); ({}.hasOwnProperty); ({}.isPrototypeOf); ({}.propertyIsEnumerable); ({}.toLocaleString); ({}.toString); ({}.valueOf);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/object/output.js
JavaScript
// Object symbols ({}).constructor, ({}).__proto__, ({}).__defineGetter__, ({}).__defineSetter__, ({}).__lookupGetter__, ({}).__lookupSetter__, ({}).hasOwnProperty, ({}).isPrototypeOf, ({}).propertyIsEnumerable, ({}).toLocaleString, ({}).toString, ({}).valueOf;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/object_side_effects/input.js
JavaScript
// foo(), {}.__proto__ f({a: foo(), b: 5}.__proto__); // foo(), bar(), undefined f({a: foo(), b: bar()}.invalid); // foo1(), bar(), baz(), foo2(), undefined f({ a: foo1(), b: { a: bar(), b: { a: baz() }, c: foo2() } }.invalid);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/object_side_effects/output.js
JavaScript
// foo(), {}.__proto__ f((foo(), ({}).__proto__)), // foo(), bar(), undefined f((foo(), void bar())), // foo1(), bar(), baz(), foo2(), undefined f((foo1(), bar(), baz(), void foo2()));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/seq/input.js
JavaScript
console.log((f(), [2, 4])[5]); console.log((f(), {b: 2}).a);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/seq/output.js
JavaScript
console.log(void f()), console.log(void f());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/string/input.js
JavaScript
// Invalid ''[0]; ''[1]; ''[-1]; ''.invalid; ''["invalid"]; ''[[]]; ''[0+[]]; // Object symbols ''.constructor; ''.__proto__; ''.__defineGetter__; ''.__defineSetter__; ''.__lookupGetter__; ''.__lookupSetter__; ''.hasOwnProperty; ''.isPrototypeOf; ''.propertyIsEnumerable; ''.toLocaleString; ''.toString; ''.valueOf; // String symbols ''.length; ''.anchor; ''.at; ''.big; ''.blink; ''.bold; ''.charAt; ''.charCodeAt; ''.codePointAt; ''.concat; ''.endsWith; ''.fixed; ''.fontcolor; ''.fontsize; ''.includes; ''.indexOf; ''.isWellFormed; ''.italics; ''.lastIndexOf; ''.link; ''.localeCompare; ''.match; ''.matchAll; ''.normalize; ''.padEnd; ''.padStart; ''.repeat; ''.replace; ''.replaceAll; ''.search; ''.slice; ''.small; ''.split; ''.startsWith; ''.strike; ''.sub; ''.substr; ''.substring; ''.sup; ''.toLocaleLowerCase; ''.toLocaleUpperCase; ''.toLowerCase; ''.toUpperCase; ''.toWellFormed; ''.trim; ''.trimEnd; ''.trimStart;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/string/output.js
JavaScript
// Invalid // Object symbols ''.constructor, ''.__proto__, ''.__defineGetter__, ''.__defineSetter__, ''.__lookupGetter__, ''.__lookupSetter__, ''.hasOwnProperty, ''.isPrototypeOf, ''.propertyIsEnumerable, ''.toLocaleString, ''.toString, ''.valueOf, ''.anchor, ''.at, ''.big, ''.blink, ''.bold, ''.charAt, ''.charCodeAt, ''.codePointAt, ''.concat, ''.endsWith, ''.fixed, ''.fontcolor, ''.fontsize, ''.includes, ''.indexOf, ''.isWellFormed, ''.italics, ''.lastIndexOf, ''.link, ''.localeCompare, ''.match, ''.matchAll, ''.normalize, ''.padEnd, ''.padStart, ''.repeat, ''.replace, ''.replaceAll, ''.search, ''.slice, ''.small, ''.split, ''.startsWith, ''.strike, ''.sub, ''.substr, ''.substring, ''.sup, ''.toLocaleLowerCase, ''.toLocaleUpperCase, ''.toLowerCase, ''.toUpperCase, ''.toWellFormed, ''.trim, ''.trimEnd, ''.trimStart;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/undetermined_prop/input.js
JavaScript
({ a: 1, })[undetermined()];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/member_expr/undetermined_prop/output.js
JavaScript
undetermined();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/30498/1/input.js
JavaScript
export function string_create() { return new StringSchema(); } export class StringSchema extends BaseSchema { matches(regex, options) { let excludeEmptyString = false; let message; let name; if (options) { if (typeof options === "object") { ({ excludeEmptyString = false, message, name } = options); } else { message = options; } } return this.test({ name: name || "matches", message: message || string.matches, params: { regex, }, test: (value) => isAbsent(value) || (value === "" && excludeEmptyString) || value.search(regex) !== -1, }); } } string_create.prototype = StringSchema.prototype;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/30498/1/output.js
JavaScript
export function string_create() { return new StringSchema(); } export class StringSchema extends BaseSchema { matches(regex, options) { let message, name, excludeEmptyString = !1; return options && ("object" == typeof options ? { excludeEmptyString = !1, message, name } = options : message = options), this.test({ name: name || "matches", message: message || string.matches, params: { regex }, test: (value)=>isAbsent(value) || "" === value && excludeEmptyString || -1 !== value.search(regex) }); } } string_create.prototype = StringSchema.prototype;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/input.js
JavaScript
"use strict"; (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [453], { /***/ 8780: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Decoration: function () { return /* binding */ Decoration; }, /* harmony export */ DecorationSet: function () { return /* binding */ DecorationSet; }, /* harmony export */ EditorView: function () { return /* binding */ EditorView; }, /* harmony export */ __endComposition: function () { return /* binding */ endComposition; }, /* harmony export */ __parseFromClipboard: function () { return /* binding */ parseFromClipboard; }, /* harmony export */ __serializeForClipboard: function () { return /* binding */ serializeForClipboard; }, /* harmony export */ }); /* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6922); /* harmony import */ var prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2230); /* harmony import */ var prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1081); var result = {}; if ( typeof navigator != "undefined" && typeof document != "undefined" ) { var ie_edge = /Edge\/(\d+)/.exec(navigator.userAgent); var ie_upto10 = /MSIE \d/.test(navigator.userAgent); var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec( navigator.userAgent ); var ie = (result.ie = !!(ie_upto10 || ie_11up || ie_edge)); result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null; result.gecko = !ie && /gecko\/(\d+)/i.test(navigator.userAgent); result.gecko_version = result.gecko && +(/Firefox\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1]; var chrome = !ie && /Chrome\/(\d+)/.exec(navigator.userAgent); result.chrome = !!chrome; result.chrome_version = chrome && +chrome[1]; // Is true for both iOS and iPadOS for convenience result.safari = !ie && /Apple Computer/.test(navigator.vendor); result.ios = result.safari && (/Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2); result.mac = result.ios || /Mac/.test(navigator.platform); result.android = /Android \d/.test(navigator.userAgent); result.webkit = "webkitFontSmoothing" in document.documentElement.style; result.webkit_version = result.webkit && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [ 0, 0, ])[1]; } var domIndex = function (node) { for (var index = 0; ; index++) { node = node.previousSibling; if (!node) { return index; } } }; var parentNode = function (node) { var parent = node.assignedSlot || node.parentNode; return parent && parent.nodeType == 11 ? parent.host : parent; }; var reusedRange = null; // Note that this will always return the same range, because DOM range // objects are every expensive, and keep slowing down subsequent DOM // updates, for some reason. var textRange = function (node, from, to) { var range = reusedRange || (reusedRange = document.createRange()); range.setEnd(node, to == null ? node.nodeValue.length : to); range.setStart(node, from || 0); return range; }; // Scans forward and backward through DOM positions equivalent to the // given one to see if the two are in the same place (i.e. after a // text node vs at the end of that text node) var isEquivalentPosition = function ( node, off, targetNode, targetOff ) { return ( targetNode && (scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1)) ); }; var atomElements = /^(img|br|input|textarea|hr)$/i; function scanFor(node, off, targetNode, targetOff, dir) { for (;;) { if (node == targetNode && off == targetOff) { return true; } if (off == (dir < 0 ? 0 : nodeSize(node))) { var parent = node.parentNode; if ( parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false" ) { return false; } off = domIndex(node) + (dir < 0 ? 0 : 1); node = parent; } else if (node.nodeType == 1) { node = node.childNodes[off + (dir < 0 ? -1 : 0)]; if (node.contentEditable == "false") { return false; } off = dir < 0 ? nodeSize(node) : 0; } else { return false; } } } function nodeSize(node) { return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length; } function isOnEdge(node, offset, parent) { for ( var atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd; ) { if (node == parent) { return true; } var index = domIndex(node); node = node.parentNode; if (!node) { return false; } atStart = atStart && index == 0; atEnd = atEnd && index == nodeSize(node); } } function hasBlockDesc(dom) { var desc; for (var cur = dom; cur; cur = cur.parentNode) { if ((desc = cur.pmViewDesc)) { break; } } return ( desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom) ); } // Work around Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=447523 // (isCollapsed inappropriately returns true in shadow dom) var selectionCollapsed = function (domSel) { var collapsed = domSel.isCollapsed; if ( collapsed && result.chrome && domSel.rangeCount && !domSel.getRangeAt(0).collapsed ) { collapsed = false; } return collapsed; }; function keyEvent(keyCode, key) { var event = document.createEvent("Event"); event.initEvent("keydown", true, true); event.keyCode = keyCode; event.key = event.code = key; return event; } function windowRect(doc) { return { left: 0, right: doc.documentElement.clientWidth, top: 0, bottom: doc.documentElement.clientHeight, }; } function getSide(value, side) { return typeof value == "number" ? value : value[side]; } function clientRect(node) { var rect = node.getBoundingClientRect(); // Adjust for elements with style "transform: scale()" var scaleX = rect.width / node.offsetWidth || 1; var scaleY = rect.height / node.offsetHeight || 1; // Make sure scrollbar width isn't included in the rectangle return { left: rect.left, right: rect.left + node.clientWidth * scaleX, top: rect.top, bottom: rect.top + node.clientHeight * scaleY, }; } function scrollRectIntoView(view, rect, startDOM) { var scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5; var doc = view.dom.ownerDocument; for ( var parent = startDOM || view.dom; ; parent = parentNode(parent) ) { if (!parent) { break; } if (parent.nodeType != 1) { continue; } var atTop = parent == doc.body || parent.nodeType != 1; var bounding = atTop ? windowRect(doc) : clientRect(parent); var moveX = 0, moveY = 0; if ( rect.top < bounding.top + getSide(scrollThreshold, "top") ) { moveY = -( bounding.top - rect.top + getSide(scrollMargin, "top") ); } else if ( rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom") ) { moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom"); } if ( rect.left < bounding.left + getSide(scrollThreshold, "left") ) { moveX = -( bounding.left - rect.left + getSide(scrollMargin, "left") ); } else if ( rect.right > bounding.right - getSide(scrollThreshold, "right") ) { moveX = rect.right - bounding.right + getSide(scrollMargin, "right"); } if (moveX || moveY) { if (atTop) { doc.defaultView.scrollBy(moveX, moveY); } else { var startX = parent.scrollLeft, startY = parent.scrollTop; if (moveY) { parent.scrollTop += moveY; } if (moveX) { parent.scrollLeft += moveX; } var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY; rect = { left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY, }; } } if (atTop) { break; } } } // Store the scroll position of the editor's parent nodes, along with // the top position of an element near the top of the editor, which // will be used to make sure the visible viewport remains stable even // when the size of the content above changes. function storeScrollPos(view) { var rect = view.dom.getBoundingClientRect(), startY = Math.max(0, rect.top); var refDOM, refTop; for ( var x = (rect.left + rect.right) / 2, y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5 ) { var dom = view.root.elementFromPoint(x, y); if (dom == view.dom || !view.dom.contains(dom)) { continue; } var localRect = dom.getBoundingClientRect(); if (localRect.top >= startY - 20) { refDOM = dom; refTop = localRect.top; break; } } return { refDOM: refDOM, refTop: refTop, stack: scrollStack(view.dom), }; } function scrollStack(dom) { var stack = [], doc = dom.ownerDocument; for (; dom; dom = parentNode(dom)) { stack.push({ dom: dom, top: dom.scrollTop, left: dom.scrollLeft, }); if (dom == doc) { break; } } return stack; } // Reset the scroll position of the editor's parent nodes to that what // it was before, when storeScrollPos was called. function resetScrollPos(ref) { var refDOM = ref.refDOM; var refTop = ref.refTop; var stack = ref.stack; var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0; restoreScrollStack( stack, newRefTop == 0 ? 0 : newRefTop - refTop ); } function restoreScrollStack(stack, dTop) { for (var i = 0; i < stack.length; i++) { var ref = stack[i]; var dom = ref.dom; var top = ref.top; var left = ref.left; if (dom.scrollTop != top + dTop) { dom.scrollTop = top + dTop; } if (dom.scrollLeft != left) { dom.scrollLeft = left; } } } var preventScrollSupported = null; // Feature-detects support for .focus({preventScroll: true}), and uses // a fallback kludge when not supported. function focusPreventScroll(dom) { if (dom.setActive) { return dom.setActive(); } // in IE if (preventScrollSupported) { return dom.focus(preventScrollSupported); } var stored = scrollStack(dom); dom.focus( preventScrollSupported == null ? { get preventScroll() { preventScrollSupported = { preventScroll: true, }; return true; }, } : undefined ); if (!preventScrollSupported) { preventScrollSupported = false; restoreScrollStack(stored, 0); } } function findOffsetInNode(node, coords) { var closest, dxClosest = 2e8, coordsClosest, offset = 0; var rowBot = coords.top, rowTop = coords.top; for ( var child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++ ) { var rects = void 0; if (child.nodeType == 1) { rects = child.getClientRects(); } else if (child.nodeType == 3) { rects = textRange(child).getClientRects(); } else { continue; } for (var i = 0; i < rects.length; i++) { var rect = rects[i]; if (rect.top <= rowBot && rect.bottom >= rowTop) { rowBot = Math.max(rect.bottom, rowBot); rowTop = Math.min(rect.top, rowTop); var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0; if (dx < dxClosest) { closest = child; dxClosest = dx; coordsClosest = dx && closest.nodeType == 3 ? { left: rect.right < coords.left ? rect.right : rect.left, top: coords.top, } : coords; if (child.nodeType == 1 && dx) { offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0); } continue; } } if ( !closest && ((coords.left >= rect.right && coords.top >= rect.top) || (coords.left >= rect.left && coords.top >= rect.bottom)) ) { offset = childIndex + 1; } } } if (closest && closest.nodeType == 3) { return findOffsetInText(closest, coordsClosest); } if (!closest || (dxClosest && closest.nodeType == 1)) { return { node: node, offset: offset }; } return findOffsetInNode(closest, coordsClosest); } function findOffsetInText(node, coords) { var len = node.nodeValue.length; var range = document.createRange(); for (var i = 0; i < len; i++) { range.setEnd(node, i + 1); range.setStart(node, i); var rect = singleRect(range, 1); if (rect.top == rect.bottom) { continue; } if (inRect(coords, rect)) { return { node: node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0), }; } } return { node: node, offset: 0 }; } function inRect(coords, rect) { return ( coords.left >= rect.left - 1 && coords.left <= rect.right + 1 && coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1 ); } function targetKludge(dom, coords) { var parent = dom.parentNode; if ( parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left ) { return parent; } return dom; } function posFromElement(view, elt, coords) { var ref = findOffsetInNode(elt, coords); var node = ref.node; var offset = ref.offset; var bias = -1; if (node.nodeType == 1 && !node.firstChild) { var rect = node.getBoundingClientRect(); bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1; } return view.docView.posFromDOM(node, offset, bias); } function posFromCaret(view, node, offset, coords) { // Browser (in caretPosition/RangeFromPoint) will agressively // normalize towards nearby inline nodes. Since we are interested in // positions between block nodes too, we first walk up the hierarchy // of nodes to see if there are block nodes that the coordinates // fall outside of. If so, we take the position before/after that // block. If not, we call `posFromDOM` on the raw node/offset. var outside = -1; for (var cur = node; ; ) { if (cur == view.dom) { break; } var desc = view.docView.nearestDesc(cur, true); if (!desc) { return null; } if (desc.node.isBlock && desc.parent) { var rect = desc.dom.getBoundingClientRect(); if (rect.left > coords.left || rect.top > coords.top) { outside = desc.posBefore; } else if ( rect.right < coords.left || rect.bottom < coords.top ) { outside = desc.posAfter; } else { break; } } cur = desc.dom.parentNode; } return outside > -1 ? outside : view.docView.posFromDOM(node, offset); } function elementFromPoint(element, coords, box) { var len = element.childNodes.length; if (len && box.top < box.bottom) { for ( var startI = Math.max( 0, Math.min( len - 1, Math.floor( (len * (coords.top - box.top)) / (box.bottom - box.top) ) - 2 ) ), i = startI; ; ) { var child = element.childNodes[i]; if (child.nodeType == 1) { var rects = child.getClientRects(); for (var j = 0; j < rects.length; j++) { var rect = rects[j]; if (inRect(coords, rect)) { return elementFromPoint( child, coords, rect ); } } } if ((i = (i + 1) % len) == startI) { break; } } } return element; } // Given an x,y position on the editor, get the position in the document. function posAtCoords(view, coords) { var assign, assign$1; var doc = view.dom.ownerDocument, node, offset; if (doc.caretPositionFromPoint) { try { // Firefox throws for this call in hard-to-predict circumstances (#994) var pos$1 = doc.caretPositionFromPoint( coords.left, coords.top ); if (pos$1) { (assign = pos$1), (node = assign.offsetNode), (offset = assign.offset); } } catch (_) {} } if (!node && doc.caretRangeFromPoint) { var range = doc.caretRangeFromPoint( coords.left, coords.top ); if (range) { (assign$1 = range), (node = assign$1.startContainer), (offset = assign$1.startOffset); } } var elt = ( view.root.elementFromPoint ? view.root : doc ).elementFromPoint(coords.left, coords.top + 1), pos; if ( !elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt) ) { var box = view.dom.getBoundingClientRect(); if (!inRect(coords, box)) { return null; } elt = elementFromPoint(view.dom, coords, box); if (!elt) { return null; } } // Safari's caretRangeFromPoint returns nonsense when on a draggable element if (result.safari) { for (var p = elt; node && p; p = parentNode(p)) { if (p.draggable) { node = offset = null; } } } elt = targetKludge(elt, coords); if (node) { if (result.gecko && node.nodeType == 1) { // Firefox will sometimes return offsets into <input> nodes, which // have no actual children, from caretPositionFromPoint (#953) offset = Math.min(offset, node.childNodes.length); // It'll also move the returned position before image nodes, // even if those are behind it. if (offset < node.childNodes.length) { var next = node.childNodes[offset], box$1; if ( next.nodeName == "IMG" && (box$1 = next.getBoundingClientRect()).right <= coords.left && box$1.bottom > coords.top ) { offset++; } } } // Suspiciously specific kludge to work around caret*FromPoint // never returning a position at the end of the document if ( node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom ) { pos = view.state.doc.content.size; } // Ignore positions directly after a BR, since caret*FromPoint // 'round up' positions that would be more accurately placed // before the BR node. else if ( offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != "BR" ) { pos = posFromCaret(view, node, offset, coords); } } if (pos == null) { pos = posFromElement(view, elt, coords); } var desc = view.docView.nearestDesc(elt, true); return { pos: pos, inside: desc ? desc.posAtStart - desc.border : -1, }; } function singleRect(object, bias) { var rects = object.getClientRects(); return !rects.length ? object.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1]; } var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; // : (EditorView, number, number) → {left: number, top: number, right: number, bottom: number} // Given a position in the document model, get a bounding box of the // character at that position, relative to the window. function coordsAtPos(view, pos, side) { var ref = view.docView.domFromPos(pos, side < 0 ? -1 : 1); var node = ref.node; var offset = ref.offset; var supportEmptyRange = result.webkit || result.gecko; if (node.nodeType == 3) { // These browsers support querying empty text ranges. Prefer that in // bidi context or when at the end of a node. if ( supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length)) ) { var rect = singleRect( textRange(node, offset, offset), side ); // Firefox returns bad results (the position before the space) // when querying a position directly after line-broken // whitespace. Detect this situation and and kludge around it if ( result.gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length ) { var rectBefore = singleRect( textRange(node, offset - 1, offset - 1), -1 ); if (rectBefore.top == rect.top) { var rectAfter = singleRect( textRange(node, offset, offset + 1), -1 ); if (rectAfter.top != rect.top) { return flattenV( rectAfter, rectAfter.left < rectBefore.left ); } } } return rect; } else { var from = offset, to = offset, takeSide = side < 0 ? 1 : -1; if (side < 0 && !offset) { to++; takeSide = -1; } else if ( side >= 0 && offset == node.nodeValue.length ) { from--; takeSide = 1; } else if (side < 0) { from--; } else { to++; } return flattenV( singleRect(textRange(node, from, to), takeSide), takeSide < 0 ); } } // Return a horizontal line in block context if (!view.state.doc.resolve(pos).parent.inlineContent) { if (offset && (side < 0 || offset == nodeSize(node))) { var before = node.childNodes[offset - 1]; if (before.nodeType == 1) { return flattenH( before.getBoundingClientRect(), false ); } } if (offset < nodeSize(node)) { var after = node.childNodes[offset]; if (after.nodeType == 1) { return flattenH( after.getBoundingClientRect(), true ); } } return flattenH(node.getBoundingClientRect(), side >= 0); } // Inline, not in text node (this is not Bidi-safe) if (offset && (side < 0 || offset == nodeSize(node))) { var before$1 = node.childNodes[offset - 1]; var target = before$1.nodeType == 3 ? textRange( before$1, nodeSize(before$1) - (supportEmptyRange ? 0 : 1) ) : // BR nodes tend to only return the rectangle before them. // Only use them if they are the last element in their parent before$1.nodeType == 1 && (before$1.nodeName != "BR" || !before$1.nextSibling) ? before$1 : null; if (target) { return flattenV(singleRect(target, 1), false); } } if (offset < nodeSize(node)) { var after$1 = node.childNodes[offset]; while ( after$1.pmViewDesc && after$1.pmViewDesc.ignoreForCoords ) { after$1 = after$1.nextSibling; } var target$1 = !after$1 ? null : after$1.nodeType == 3 ? textRange(after$1, 0, supportEmptyRange ? 0 : 1) : after$1.nodeType == 1 ? after$1 : null; if (target$1) { return flattenV(singleRect(target$1, -1), true); } } // All else failed, just try to get a rectangle for the target node return flattenV( singleRect( node.nodeType == 3 ? textRange(node) : node, -side ), side >= 0 ); } function flattenV(rect, left) { if (rect.width == 0) { return rect; } var x = left ? rect.left : rect.right; return { top: rect.top, bottom: rect.bottom, left: x, right: x, }; } function flattenH(rect, top) { if (rect.height == 0) { return rect; } var y = top ? rect.top : rect.bottom; return { top: y, bottom: y, left: rect.left, right: rect.right, }; } function withFlushedState(view, state, f) { var viewState = view.state, active = view.root.activeElement; if (viewState != state) { view.updateState(state); } if (active != view.dom) { view.focus(); } try { return f(); } finally { if (viewState != state) { view.updateState(viewState); } if (active != view.dom && active) { active.focus(); } } } // : (EditorView, number, number) // Whether vertical position motion in a given direction // from a position would leave a text block. function endOfTextblockVertical(view, state, dir) { var sel = state.selection; var $pos = dir == "up" ? sel.$from : sel.$to; return withFlushedState(view, state, function () { var ref = view.docView.domFromPos( $pos.pos, dir == "up" ? -1 : 1 ); var dom = ref.node; for (;;) { var nearest = view.docView.nearestDesc(dom, true); if (!nearest) { break; } if (nearest.node.isBlock) { dom = nearest.dom; break; } dom = nearest.dom.parentNode; } var coords = coordsAtPos(view, $pos.pos, 1); for ( var child = dom.firstChild; child; child = child.nextSibling ) { var boxes = void 0; if (child.nodeType == 1) { boxes = child.getClientRects(); } else if (child.nodeType == 3) { boxes = textRange( child, 0, child.nodeValue.length ).getClientRects(); } else { continue; } for (var i = 0; i < boxes.length; i++) { var box = boxes[i]; if ( box.bottom > box.top + 1 && (dir == "up" ? coords.top - box.top > (box.bottom - coords.top) * 2 : box.bottom - coords.bottom > (coords.bottom - box.top) * 2) ) { return false; } } } return true; }); } var maybeRTL = /[\u0590-\u08ac]/; function endOfTextblockHorizontal(view, state, dir) { var ref = state.selection; var $head = ref.$head; if (!$head.parent.isTextblock) { return false; } var offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size; var sel = view.root.getSelection(); // If the textblock is all LTR, or the browser doesn't support // Selection.modify (Edge), fall back to a primitive approach if (!maybeRTL.test($head.parent.textContent) || !sel.modify) { return dir == "left" || dir == "backward" ? atStart : atEnd; } return withFlushedState(view, state, function () { // This is a huge hack, but appears to be the best we can // currently do: use `Selection.modify` to move the selection by // one character, and see if that moves the cursor out of the // textblock (or doesn't move it at all, when at the start/end of // the document). var oldRange = sel.getRangeAt(0), oldNode = sel.focusNode, oldOff = sel.focusOffset; var oldBidiLevel = sel.caretBidiLevel; // Only for Firefox sel.modify("move", dir, "character"); var parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom; var result = !parentDOM.contains( sel.focusNode.nodeType == 1 ? sel.focusNode : sel.focusNode.parentNode ) || (oldNode == sel.focusNode && oldOff == sel.focusOffset); // Restore the previous selection sel.removeAllRanges(); sel.addRange(oldRange); if (oldBidiLevel != null) { sel.caretBidiLevel = oldBidiLevel; } return result; }); } var cachedState = null, cachedDir = null, cachedResult = false; function endOfTextblock(view, state, dir) { if (cachedState == state && cachedDir == dir) { return cachedResult; } cachedState = state; cachedDir = dir; return (cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir)); } // NodeView:: interface // // By default, document nodes are rendered using the result of the // [`toDOM`](#model.NodeSpec.toDOM) method of their spec, and managed // entirely by the editor. For some use cases, such as embedded // node-specific editing interfaces, you want more control over // the behavior of a node's in-editor representation, and need to // [define](#view.EditorProps.nodeViews) a custom node view. // // Mark views only support `dom` and `contentDOM`, and don't support // any of the node view methods. // // Objects returned as node views must conform to this interface. // // dom:: ?dom.Node // The outer DOM node that represents the document node. When not // given, the default strategy is used to create a DOM node. // // contentDOM:: ?dom.Node // The DOM node that should hold the node's content. Only meaningful // if the node view also defines a `dom` property and if its node // type is not a leaf node type. When this is present, ProseMirror // will take care of rendering the node's children into it. When it // is not present, the node view itself is responsible for rendering // (or deciding not to render) its child nodes. // // update:: ?(node: Node, decorations: [Decoration], innerDecorations: DecorationSource) → bool // When given, this will be called when the view is updating itself. // It will be given a node (possibly of a different type), an array // of active decorations around the node (which are automatically // drawn, and the node view may ignore if it isn't interested in // them), and a [decoration source](#view.DecorationSource) that // represents any decorations that apply to the content of the node // (which again may be ignored). It should return true if it was // able to update to that node, and false otherwise. If the node // view has a `contentDOM` property (or no `dom` property), updating // its child nodes will be handled by ProseMirror. // // selectNode:: ?() // Can be used to override the way the node's selected status (as a // node selection) is displayed. // // deselectNode:: ?() // When defining a `selectNode` method, you should also provide a // `deselectNode` method to remove the effect again. // // setSelection:: ?(anchor: number, head: number, root: dom.Document) // This will be called to handle setting the selection inside the // node. The `anchor` and `head` positions are relative to the start // of the node. By default, a DOM selection will be created between // the DOM positions corresponding to those positions, but if you // override it you can do something else. // // stopEvent:: ?(event: dom.Event) → bool // Can be used to prevent the editor view from trying to handle some // or all DOM events that bubble up from the node view. Events for // which this returns true are not handled by the editor. // // ignoreMutation:: ?(dom.MutationRecord) → bool // Called when a DOM // [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) // or a selection change happens within the view. When the change is // a selection change, the record will have a `type` property of // `"selection"` (which doesn't occur for native mutation records). // Return false if the editor should re-read the selection or // re-parse the range around the mutation, true if it can safely be // ignored. // // destroy:: ?() // Called when the node view is removed from the editor or the whole // editor is destroyed. (Not available for marks.) // View descriptions are data structures that describe the DOM that is // used to represent the editor's content. They are used for: // // - Incremental redrawing when the document changes // // - Figuring out what part of the document a given DOM position // corresponds to // // - Wiring in custom implementations of the editing interface for a // given node // // They form a doubly-linked mutable tree, starting at `view.docView`. var NOT_DIRTY = 0, CHILD_DIRTY = 1, CONTENT_DIRTY = 2, NODE_DIRTY = 3; // Superclass for the various kinds of descriptions. Defines their // basic structure and shared methods. var ViewDesc = function ViewDesc( parent, children, dom, contentDOM ) { this.parent = parent; this.children = children; this.dom = dom; // An expando property on the DOM node provides a link back to its // description. dom.pmViewDesc = this; // This is the node that holds the child views. It may be null for // descs that don't have children. this.contentDOM = contentDOM; this.dirty = NOT_DIRTY; }; var prototypeAccessors = { size: { configurable: true }, border: { configurable: true }, posBefore: { configurable: true }, posAtStart: { configurable: true }, posAfter: { configurable: true }, posAtEnd: { configurable: true }, contentLost: { configurable: true }, domAtom: { configurable: true }, ignoreForCoords: { configurable: true }, }; // Used to check whether a given description corresponds to a // widget/mark/node. ViewDesc.prototype.matchesWidget = function matchesWidget() { return false; }; ViewDesc.prototype.matchesMark = function matchesMark() { return false; }; ViewDesc.prototype.matchesNode = function matchesNode() { return false; }; ViewDesc.prototype.matchesHack = function matchesHack(_nodeName) { return false; }; // : () → ?ParseRule // When parsing in-editor content (in domchange.js), we allow // descriptions to determine the parse rules that should be used to // parse them. ViewDesc.prototype.parseRule = function parseRule() { return null; }; // : (dom.Event) → bool // Used by the editor's event handler to ignore events that come // from certain descs. ViewDesc.prototype.stopEvent = function stopEvent() { return false; }; // The size of the content represented by this desc. prototypeAccessors.size.get = function () { var size = 0; for (var i = 0; i < this.children.length; i++) { size += this.children[i].size; } return size; }; // For block nodes, this represents the space taken up by their // start/end tokens. prototypeAccessors.border.get = function () { return 0; }; ViewDesc.prototype.destroy = function destroy() { this.parent = null; if (this.dom.pmViewDesc == this) { this.dom.pmViewDesc = null; } for (var i = 0; i < this.children.length; i++) { this.children[i].destroy(); } }; ViewDesc.prototype.posBeforeChild = function posBeforeChild(child) { for ( var i = 0, pos = this.posAtStart; i < this.children.length; i++ ) { var cur = this.children[i]; if (cur == child) { return pos; } pos += cur.size; } }; prototypeAccessors.posBefore.get = function () { return this.parent.posBeforeChild(this); }; prototypeAccessors.posAtStart.get = function () { return this.parent ? this.parent.posBeforeChild(this) + this.border : 0; }; prototypeAccessors.posAfter.get = function () { return this.posBefore + this.size; }; prototypeAccessors.posAtEnd.get = function () { return this.posAtStart + this.size - 2 * this.border; }; // : (dom.Node, number, ?number) → number ViewDesc.prototype.localPosFromDOM = function localPosFromDOM( dom, offset, bias ) { // If the DOM position is in the content, use the child desc after // it to figure out a position. if ( this.contentDOM && this.contentDOM.contains( dom.nodeType == 1 ? dom : dom.parentNode ) ) { if (bias < 0) { var domBefore, desc; if (dom == this.contentDOM) { domBefore = dom.childNodes[offset - 1]; } else { while (dom.parentNode != this.contentDOM) { dom = dom.parentNode; } domBefore = dom.previousSibling; } while ( domBefore && !( (desc = domBefore.pmViewDesc) && desc.parent == this ) ) { domBefore = domBefore.previousSibling; } return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart; } else { var domAfter, desc$1; if (dom == this.contentDOM) { domAfter = dom.childNodes[offset]; } else { while (dom.parentNode != this.contentDOM) { dom = dom.parentNode; } domAfter = dom.nextSibling; } while ( domAfter && !( (desc$1 = domAfter.pmViewDesc) && desc$1.parent == this ) ) { domAfter = domAfter.nextSibling; } return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd; } } // Otherwise, use various heuristics, falling back on the bias // parameter, to determine whether to return the position at the // start or at the end of this view desc. var atEnd; if (dom == this.dom && this.contentDOM) { atEnd = offset > domIndex(this.contentDOM); } else if ( this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM) ) { atEnd = dom.compareDocumentPosition(this.contentDOM) & 2; } else if (this.dom.firstChild) { if (offset == 0) { for (var search = dom; ; search = search.parentNode) { if (search == this.dom) { atEnd = false; break; } if (search.parentNode.firstChild != search) { break; } } } if (atEnd == null && offset == dom.childNodes.length) { for ( var search$1 = dom; ; search$1 = search$1.parentNode ) { if (search$1 == this.dom) { atEnd = true; break; } if (search$1.parentNode.lastChild != search$1) { break; } } } } return (atEnd == null ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart; }; // Scan up the dom finding the first desc that is a descendant of // this one. ViewDesc.prototype.nearestDesc = function nearestDesc( dom, onlyNodes ) { for (var first = true, cur = dom; cur; cur = cur.parentNode) { var desc = this.getDesc(cur); if (desc && (!onlyNodes || desc.node)) { // If dom is outside of this desc's nodeDOM, don't count it. if ( first && desc.nodeDOM && !(desc.nodeDOM.nodeType == 1 ? desc.nodeDOM.contains( dom.nodeType == 1 ? dom : dom.parentNode ) : desc.nodeDOM == dom) ) { first = false; } else { return desc; } } } }; ViewDesc.prototype.getDesc = function getDesc(dom) { var desc = dom.pmViewDesc; for (var cur = desc; cur; cur = cur.parent) { if (cur == this) { return desc; } } }; ViewDesc.prototype.posFromDOM = function posFromDOM( dom, offset, bias ) { for (var scan = dom; scan; scan = scan.parentNode) { var desc = this.getDesc(scan); if (desc) { return desc.localPosFromDOM(dom, offset, bias); } } return -1; }; // : (number) → ?NodeViewDesc // Find the desc for the node after the given pos, if any. (When a // parent node overrode rendering, there might not be one.) ViewDesc.prototype.descAt = function descAt(pos) { for (var i = 0, offset = 0; i < this.children.length; i++) { var child = this.children[i], end = offset + child.size; if (offset == pos && end != offset) { while (!child.border && child.children.length) { child = child.children[0]; } return child; } if (pos < end) { return child.descAt(pos - offset - child.border); } offset = end; } }; // : (number, number) → {node: dom.Node, offset: number} ViewDesc.prototype.domFromPos = function domFromPos(pos, side) { if (!this.contentDOM) { return { node: this.dom, offset: 0 }; } // First find the position in the child array var i = 0, offset = 0; for (var curPos = 0; i < this.children.length; i++) { var child = this.children[i], end = curPos + child.size; if (end > pos || child instanceof TrailingHackViewDesc) { offset = pos - curPos; break; } curPos = end; } // If this points into the middle of a child, call through if (offset) { return this.children[i].domFromPos( offset - this.children[i].border, side ); } // Go back if there were any zero-length widgets with side >= 0 before this point for ( var prev = void 0; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.widget.type.side >= 0; i-- ) {} // Scan towards the first useable node if (side <= 0) { var prev$1, enter = true; for (; ; i--, enter = false) { prev$1 = i ? this.children[i - 1] : null; if ( !prev$1 || prev$1.dom.parentNode == this.contentDOM ) { break; } } if ( prev$1 && side && enter && !prev$1.border && !prev$1.domAtom ) { return prev$1.domFromPos(prev$1.size, side); } return { node: this.contentDOM, offset: prev$1 ? domIndex(prev$1.dom) + 1 : 0, }; } else { var next, enter$1 = true; for (; ; i++, enter$1 = false) { next = i < this.children.length ? this.children[i] : null; if (!next || next.dom.parentNode == this.contentDOM) { break; } } if (next && enter$1 && !next.border && !next.domAtom) { return next.domFromPos(0, side); } return { node: this.contentDOM, offset: next ? domIndex(next.dom) : this.contentDOM.childNodes.length, }; } }; // Used to find a DOM range in a single parent for a given changed // range. ViewDesc.prototype.parseRange = function parseRange( from, to, base ) { if (base === void 0) base = 0; if (this.children.length == 0) { return { node: this.contentDOM, from: from, to: to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length, }; } var fromOffset = -1, toOffset = -1; for (var offset = base, i = 0; ; i++) { var child = this.children[i], end = offset + child.size; if (fromOffset == -1 && from <= end) { var childBase = offset + child.border; // FIXME maybe descend mark views to parse a narrower range? if ( from >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM) ) { return child.parseRange(from, to, childBase); } from = offset; for (var j = i; j > 0; j--) { var prev = this.children[j - 1]; if ( prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1) ) { fromOffset = domIndex(prev.dom) + 1; break; } from -= prev.size; } if (fromOffset == -1) { fromOffset = 0; } } if ( fromOffset > -1 && (end > to || i == this.children.length - 1) ) { to = end; for ( var j$1 = i + 1; j$1 < this.children.length; j$1++ ) { var next = this.children[j$1]; if ( next.size && next.dom.parentNode == this.contentDOM && !next.emptyChildAt(-1) ) { toOffset = domIndex(next.dom); break; } to += next.size; } if (toOffset == -1) { toOffset = this.contentDOM.childNodes.length; } break; } offset = end; } return { node: this.contentDOM, from: from, to: to, fromOffset: fromOffset, toOffset: toOffset, }; }; ViewDesc.prototype.emptyChildAt = function emptyChildAt(side) { if (this.border || !this.contentDOM || !this.children.length) { return false; } var child = this.children[side < 0 ? 0 : this.children.length - 1]; return child.size == 0 || child.emptyChildAt(side); }; // : (number) → dom.Node ViewDesc.prototype.domAfterPos = function domAfterPos(pos) { var ref = this.domFromPos(pos, 0); var node = ref.node; var offset = ref.offset; if (node.nodeType != 1 || offset == node.childNodes.length) { throw new RangeError("No node after pos " + pos); } return node.childNodes[offset]; }; // : (number, number, dom.Document) // View descs are responsible for setting any selection that falls // entirely inside of them, so that custom implementations can do // custom things with the selection. Note that this falls apart when // a selection starts in such a node and ends in another, in which // case we just use whatever domFromPos produces as a best effort. ViewDesc.prototype.setSelection = function setSelection( anchor, head, root, force ) { // If the selection falls entirely in a child, give it to that child var from = Math.min(anchor, head), to = Math.max(anchor, head); for (var i = 0, offset = 0; i < this.children.length; i++) { var child = this.children[i], end = offset + child.size; if (from > offset && to < end) { return child.setSelection( anchor - offset - child.border, head - offset - child.border, root, force ); } offset = end; } var anchorDOM = this.domFromPos(anchor, anchor ? -1 : 1); var headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1); var domSel = root.getSelection(); var brKludge = false; // On Firefox, using Selection.collapse to put the cursor after a // BR node for some reason doesn't always work (#1073). On Safari, // the cursor sometimes inexplicable visually lags behind its // reported position in such situations (#1092). if ((result.gecko || result.safari) && anchor == head) { var node = anchorDOM.node; var offset$1 = anchorDOM.offset; if (node.nodeType == 3) { brKludge = offset$1 && node.nodeValue[offset$1 - 1] == "\n"; // Issue #1128 if (brKludge && offset$1 == node.nodeValue.length) { for ( var scan = node, after = void 0; scan; scan = scan.parentNode ) { if ((after = scan.nextSibling)) { if (after.nodeName == "BR") { anchorDOM = headDOM = { node: after.parentNode, offset: domIndex(after) + 1, }; } break; } var desc = scan.pmViewDesc; if (desc && desc.node && desc.node.isBlock) { break; } } } } else { var prev = node.childNodes[offset$1 - 1]; brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false"); } } // Firefox can act strangely when the selection is in front of an // uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536 if ( result.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1 ) { var after$1 = domSel.focusNode.childNodes[domSel.focusOffset]; if (after$1 && after$1.contentEditable == "false") { force = true; } } if ( !(force || (brKludge && result.safari)) && isEquivalentPosition( anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset ) && isEquivalentPosition( headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset ) ) { return; } // Selection.extend can be used to create an 'inverted' selection // (one where the focus is before the anchor), but not all // browsers support it yet. var domSelExtended = false; if ((domSel.extend || anchor == head) && !brKludge) { domSel.collapse(anchorDOM.node, anchorDOM.offset); try { if (anchor != head) { domSel.extend(headDOM.node, headDOM.offset); } domSelExtended = true; } catch (err) { // In some cases with Chrome the selection is empty after calling // collapse, even when it should be valid. This appears to be a bug, but // it is difficult to isolate. If this happens fallback to the old path // without using extend. if (!(err instanceof DOMException)) { throw err; } // declare global: DOMException } } if (!domSelExtended) { if (anchor > head) { var tmp = anchorDOM; anchorDOM = headDOM; headDOM = tmp; } var range = document.createRange(); range.setEnd(headDOM.node, headDOM.offset); range.setStart(anchorDOM.node, anchorDOM.offset); domSel.removeAllRanges(); domSel.addRange(range); } }; // : (dom.MutationRecord) → bool ViewDesc.prototype.ignoreMutation = function ignoreMutation( mutation ) { return !this.contentDOM && mutation.type != "selection"; }; prototypeAccessors.contentLost.get = function () { return ( this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM) ); }; // Remove a subtree of the element tree that has been touched // by a DOM change, so that the next update will redraw it. ViewDesc.prototype.markDirty = function markDirty(from, to) { for (var offset = 0, i = 0; i < this.children.length; i++) { var child = this.children[i], end = offset + child.size; if ( offset == end ? from <= end && to >= offset : from < end && to > offset ) { var startInside = offset + child.border, endInside = end - child.border; if (from >= startInside && to <= endInside) { this.dirty = from == offset || to == end ? CONTENT_DIRTY : CHILD_DIRTY; if ( from == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM) ) { child.dirty = NODE_DIRTY; } else { child.markDirty( from - startInside, to - startInside ); } return; } else { child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? CONTENT_DIRTY : NODE_DIRTY; } } offset = end; } this.dirty = CONTENT_DIRTY; }; ViewDesc.prototype.markParentsDirty = function markParentsDirty() { var level = 1; for ( var node = this.parent; node; node = node.parent, level++ ) { var dirty = level == 1 ? CONTENT_DIRTY : CHILD_DIRTY; if (node.dirty < dirty) { node.dirty = dirty; } } }; prototypeAccessors.domAtom.get = function () { return false; }; prototypeAccessors.ignoreForCoords.get = function () { return false; }; Object.defineProperties(ViewDesc.prototype, prototypeAccessors); // Reused array to avoid allocating fresh arrays for things that will // stay empty anyway. var nothing = []; // A widget desc represents a widget decoration, which is a DOM node // drawn between the document nodes. var WidgetViewDesc = /*@__PURE__*/ (function (ViewDesc) { function WidgetViewDesc(parent, widget, view, pos) { var self, dom = widget.type.toDOM; if (typeof dom == "function") { dom = dom(view, function () { if (!self) { return pos; } if (self.parent) { return self.parent.posBeforeChild(self); } }); } if (!widget.type.spec.raw) { if (dom.nodeType != 1) { var wrap = document.createElement("span"); wrap.appendChild(dom); dom = wrap; } dom.contentEditable = false; dom.classList.add("ProseMirror-widget"); } ViewDesc.call(this, parent, nothing, dom, null); this.widget = widget; self = this; } if (ViewDesc) WidgetViewDesc.__proto__ = ViewDesc; WidgetViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype ); WidgetViewDesc.prototype.constructor = WidgetViewDesc; var prototypeAccessors$1 = { domAtom: { configurable: true } }; WidgetViewDesc.prototype.matchesWidget = function matchesWidget( widget ) { return ( this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type) ); }; WidgetViewDesc.prototype.parseRule = function parseRule() { return { ignore: true }; }; WidgetViewDesc.prototype.stopEvent = function stopEvent(event) { var stop = this.widget.spec.stopEvent; return stop ? stop(event) : false; }; WidgetViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) { return ( mutation.type != "selection" || this.widget.spec.ignoreSelection ); }; prototypeAccessors$1.domAtom.get = function () { return true; }; Object.defineProperties( WidgetViewDesc.prototype, prototypeAccessors$1 ); return WidgetViewDesc; })(ViewDesc); var CompositionViewDesc = /*@__PURE__*/ (function (ViewDesc) { function CompositionViewDesc(parent, dom, textDOM, text) { ViewDesc.call(this, parent, nothing, dom, null); this.textDOM = textDOM; this.text = text; } if (ViewDesc) CompositionViewDesc.__proto__ = ViewDesc; CompositionViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype ); CompositionViewDesc.prototype.constructor = CompositionViewDesc; var prototypeAccessors$2 = { size: { configurable: true } }; prototypeAccessors$2.size.get = function () { return this.text.length; }; CompositionViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset) { if (dom != this.textDOM) { return this.posAtStart + (offset ? this.size : 0); } return this.posAtStart + offset; }; CompositionViewDesc.prototype.domFromPos = function domFromPos( pos ) { return { node: this.textDOM, offset: pos }; }; CompositionViewDesc.prototype.ignoreMutation = function ignoreMutation(mut) { return ( mut.type === "characterData" && mut.target.nodeValue == mut.oldValue ); }; Object.defineProperties( CompositionViewDesc.prototype, prototypeAccessors$2 ); return CompositionViewDesc; })(ViewDesc); // A mark desc represents a mark. May have multiple children, // depending on how the mark is split. Note that marks are drawn using // a fixed nesting order, for simplicity and predictability, so in // some cases they will be split more often than would appear // necessary. var MarkViewDesc = /*@__PURE__*/ (function (ViewDesc) { function MarkViewDesc(parent, mark, dom, contentDOM) { ViewDesc.call(this, parent, [], dom, contentDOM); this.mark = mark; } if (ViewDesc) MarkViewDesc.__proto__ = ViewDesc; MarkViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype ); MarkViewDesc.prototype.constructor = MarkViewDesc; MarkViewDesc.create = function create( parent, mark, inline, view ) { var custom = view.nodeViews[mark.type.name]; var spec = custom && custom(mark, view, inline); if (!spec || !spec.dom) { spec = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.renderSpec( document, mark.type.spec.toDOM(mark, inline) ); } return new MarkViewDesc( parent, mark, spec.dom, spec.contentDOM || spec.dom ); }; MarkViewDesc.prototype.parseRule = function parseRule() { return { mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM, }; }; MarkViewDesc.prototype.matchesMark = function matchesMark( mark ) { return this.dirty != NODE_DIRTY && this.mark.eq(mark); }; MarkViewDesc.prototype.markDirty = function markDirty( from, to ) { ViewDesc.prototype.markDirty.call(this, from, to); // Move dirty info to nearest node view if (this.dirty != NOT_DIRTY) { var parent = this.parent; while (!parent.node) { parent = parent.parent; } if (parent.dirty < this.dirty) { parent.dirty = this.dirty; } this.dirty = NOT_DIRTY; } }; MarkViewDesc.prototype.slice = function slice(from, to, view) { var copy = MarkViewDesc.create( this.parent, this.mark, true, view ); var nodes = this.children, size = this.size; if (to < size) { nodes = replaceNodes(nodes, to, size, view); } if (from > 0) { nodes = replaceNodes(nodes, 0, from, view); } for (var i = 0; i < nodes.length; i++) { nodes[i].parent = copy; } copy.children = nodes; return copy; }; return MarkViewDesc; })(ViewDesc); // Node view descs are the main, most common type of view desc, and // correspond to an actual node in the document. Unlike mark descs, // they populate their child array themselves. var NodeViewDesc = /*@__PURE__*/ (function (ViewDesc) { function NodeViewDesc( parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos ) { ViewDesc.call( this, parent, node.isLeaf ? nothing : [], dom, contentDOM ); this.nodeDOM = nodeDOM; this.node = node; this.outerDeco = outerDeco; this.innerDeco = innerDeco; if (contentDOM) { this.updateChildren(view, pos); } } if (ViewDesc) NodeViewDesc.__proto__ = ViewDesc; NodeViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype ); NodeViewDesc.prototype.constructor = NodeViewDesc; var prototypeAccessors$3 = { size: { configurable: true }, border: { configurable: true }, domAtom: { configurable: true }, }; // By default, a node is rendered using the `toDOM` method from the // node type spec. But client code can use the `nodeViews` spec to // supply a custom node view, which can influence various aspects of // the way the node works. // // (Using subclassing for this was intentionally decided against, // since it'd require exposing a whole slew of finicky // implementation details to the user code that they probably will // never need.) NodeViewDesc.create = function create( parent, node, outerDeco, innerDeco, view, pos ) { var assign; var custom = view.nodeViews[node.type.name], descObj; var spec = custom && custom( node, view, function () { // (This is a function that allows the custom view to find its // own position) if (!descObj) { return pos; } if (descObj.parent) { return descObj.parent.posBeforeChild( descObj ); } }, outerDeco, innerDeco ); var dom = spec && spec.dom, contentDOM = spec && spec.contentDOM; if (node.isText) { if (!dom) { dom = document.createTextNode(node.text); } else if (dom.nodeType != 3) { throw new RangeError( "Text must be rendered as a DOM text node" ); } } else if (!dom) { (assign = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.renderSpec( document, node.type.spec.toDOM(node) )), (dom = assign.dom), (contentDOM = assign.contentDOM); } if (!contentDOM && !node.isText && dom.nodeName != "BR") { // Chrome gets confused by <br contenteditable=false> if (!dom.hasAttribute("contenteditable")) { dom.contentEditable = false; } if (node.type.spec.draggable) { dom.draggable = true; } } var nodeDOM = dom; dom = applyOuterDeco(dom, outerDeco, node); if (spec) { return (descObj = new CustomNodeViewDesc( parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos + 1 )); } else if (node.isText) { return new TextViewDesc( parent, node, outerDeco, innerDeco, dom, nodeDOM, view ); } else { return new NodeViewDesc( parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos + 1 ); } }; NodeViewDesc.prototype.parseRule = function parseRule() { var this$1 = this; // Experimental kludge to allow opt-in re-parsing of nodes if (this.node.type.spec.reparseInView) { return null; } // FIXME the assumption that this can always return the current // attrs means that if the user somehow manages to change the // attrs in the dom, that won't be picked up. Not entirely sure // whether this is a problem var rule = { node: this.node.type.name, attrs: this.node.attrs, }; if (this.node.type.spec.code) { rule.preserveWhitespace = "full"; } if (this.contentDOM && !this.contentLost) { rule.contentElement = this.contentDOM; } else { rule.getContent = function () { return this$1.contentDOM ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Fragment.empty : this$1.node.content; }; } return rule; }; NodeViewDesc.prototype.matchesNode = function matchesNode( node, outerDeco, innerDeco ) { return ( this.dirty == NOT_DIRTY && node.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco) ); }; prototypeAccessors$3.size.get = function () { return this.node.nodeSize; }; prototypeAccessors$3.border.get = function () { return this.node.isLeaf ? 0 : 1; }; // Syncs `this.children` to match `this.node.content` and the local // decorations, possibly introducing nesting for marks. Then, in a // separate step, syncs the DOM inside `this.contentDOM` to // `this.children`. NodeViewDesc.prototype.updateChildren = function updateChildren( view, pos ) { var this$1 = this; var inline = this.node.inlineContent, off = pos; var composition = view.composing && this.localCompositionInfo(view, pos); var localComposition = composition && composition.pos > -1 ? composition : null; var compositionInChild = composition && composition.pos < 0; var updater = new ViewTreeUpdater( this, localComposition && localComposition.node ); iterDeco( this.node, this.innerDeco, function (widget, i, insideNode) { if (widget.spec.marks) { updater.syncToMarks( widget.spec.marks, inline, view ); } else if (widget.type.side >= 0 && !insideNode) { updater.syncToMarks( i == this$1.node.childCount ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Mark.none : this$1.node.child(i).marks, inline, view ); } // If the next node is a desc matching this widget, reuse it, // otherwise insert the widget as a new view desc. updater.placeWidget(widget, view, off); }, function (child, outerDeco, innerDeco, i) { // Make sure the wrapping mark descs match the node's marks. updater.syncToMarks(child.marks, inline, view); // Try several strategies for drawing this node var compIndex; if ( updater.findNodeMatch( child, outerDeco, innerDeco, i ) ); else if ( compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild( composition.node )) > -1 && updater.updateNodeAt( child, outerDeco, innerDeco, compIndex, view ) ); else if ( updater.updateNextNode( child, outerDeco, innerDeco, view, i ) ); else { // Add it as a new view updater.addNode( child, outerDeco, innerDeco, view, off ); } off += child.nodeSize; } ); // Drop all remaining descs after the current position. updater.syncToMarks(nothing, inline, view); if (this.node.isTextblock) { updater.addTextblockHacks(); } updater.destroyRest(); // Sync the DOM if anything changed if (updater.changed || this.dirty == CONTENT_DIRTY) { // May have to protect focused DOM from being changed if a composition is active if (localComposition) { this.protectLocalComposition( view, localComposition ); } renderDescs(this.contentDOM, this.children, view); if (result.ios) { iosHacks(this.dom); } } }; NodeViewDesc.prototype.localCompositionInfo = function localCompositionInfo(view, pos) { // Only do something if both the selection and a focused text node // are inside of this node var ref = view.state.selection; var from = ref.from; var to = ref.to; if ( !( view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) || from < pos || to > pos + this.node.content.size ) { return; } var sel = view.root.getSelection(); var textNode = nearbyTextNode( sel.focusNode, sel.focusOffset ); if ( !textNode || !this.dom.contains(textNode.parentNode) ) { return; } if (this.node.inlineContent) { // Find the text in the focused node in the node, stop if it's not // there (may have been modified through other means, in which // case it should overwritten) var text = textNode.nodeValue; var textPos = findTextInFragment( this.node.content, text, from - pos, to - pos ); return textPos < 0 ? null : { node: textNode, pos: textPos, text: text }; } else { return { node: textNode, pos: -1 }; } }; NodeViewDesc.prototype.protectLocalComposition = function protectLocalComposition(view, ref) { var node = ref.node; var pos = ref.pos; var text = ref.text; // The node is already part of a local view desc, leave it there if (this.getDesc(node)) { return; } // Create a composition view for the orphaned nodes var topNode = node; for (; ; topNode = topNode.parentNode) { if (topNode.parentNode == this.contentDOM) { break; } while (topNode.previousSibling) { topNode.parentNode.removeChild( topNode.previousSibling ); } while (topNode.nextSibling) { topNode.parentNode.removeChild( topNode.nextSibling ); } if (topNode.pmViewDesc) { topNode.pmViewDesc = null; } } var desc = new CompositionViewDesc( this, topNode, node, text ); view.compositionNodes.push(desc); // Patch up this.children to contain the composition view this.children = replaceNodes( this.children, pos, pos + text.length, view, desc ); }; // : (Node, [Decoration], DecorationSource, EditorView) → bool // If this desc be updated to match the given node decoration, // do so and return true. NodeViewDesc.prototype.update = function update( node, outerDeco, innerDeco, view ) { if ( this.dirty == NODE_DIRTY || !node.sameMarkup(this.node) ) { return false; } this.updateInner(node, outerDeco, innerDeco, view); return true; }; NodeViewDesc.prototype.updateInner = function updateInner( node, outerDeco, innerDeco, view ) { this.updateOuterDeco(outerDeco); this.node = node; this.innerDeco = innerDeco; if (this.contentDOM) { this.updateChildren(view, this.posAtStart); } this.dirty = NOT_DIRTY; }; NodeViewDesc.prototype.updateOuterDeco = function updateOuterDeco(outerDeco) { if (sameOuterDeco(outerDeco, this.outerDeco)) { return; } var needsWrap = this.nodeDOM.nodeType != 1; var oldDOM = this.dom; this.dom = patchOuterDeco( this.dom, this.nodeDOM, computeOuterDeco( this.outerDeco, this.node, needsWrap ), computeOuterDeco(outerDeco, this.node, needsWrap) ); if (this.dom != oldDOM) { oldDOM.pmViewDesc = null; this.dom.pmViewDesc = this; } this.outerDeco = outerDeco; }; // Mark this node as being the selected node. NodeViewDesc.prototype.selectNode = function selectNode() { this.nodeDOM.classList.add("ProseMirror-selectednode"); if (this.contentDOM || !this.node.type.spec.draggable) { this.dom.draggable = true; } }; // Remove selected node marking from this node. NodeViewDesc.prototype.deselectNode = function deselectNode() { this.nodeDOM.classList.remove("ProseMirror-selectednode"); if (this.contentDOM || !this.node.type.spec.draggable) { this.dom.removeAttribute("draggable"); } }; prototypeAccessors$3.domAtom.get = function () { return this.node.isAtom; }; Object.defineProperties( NodeViewDesc.prototype, prototypeAccessors$3 ); return NodeViewDesc; })(ViewDesc); // Create a view desc for the top-level document node, to be exported // and used by the view class. function docViewDesc(doc, outerDeco, innerDeco, dom, view) { applyOuterDeco(dom, outerDeco, doc); return new NodeViewDesc( null, doc, outerDeco, innerDeco, dom, dom, dom, view, 0 ); } var TextViewDesc = /*@__PURE__*/ (function (NodeViewDesc) { function TextViewDesc( parent, node, outerDeco, innerDeco, dom, nodeDOM, view ) { NodeViewDesc.call( this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM, view ); } if (NodeViewDesc) TextViewDesc.__proto__ = NodeViewDesc; TextViewDesc.prototype = Object.create( NodeViewDesc && NodeViewDesc.prototype ); TextViewDesc.prototype.constructor = TextViewDesc; var prototypeAccessors$4 = { domAtom: { configurable: true } }; TextViewDesc.prototype.parseRule = function parseRule() { var skip = this.nodeDOM.parentNode; while (skip && skip != this.dom && !skip.pmIsDeco) { skip = skip.parentNode; } return { skip: skip || true }; }; TextViewDesc.prototype.update = function update( node, outerDeco, _, view ) { if ( this.dirty == NODE_DIRTY || (this.dirty != NOT_DIRTY && !this.inParent()) || !node.sameMarkup(this.node) ) { return false; } this.updateOuterDeco(outerDeco); if ( (this.dirty != NOT_DIRTY || node.text != this.node.text) && node.text != this.nodeDOM.nodeValue ) { this.nodeDOM.nodeValue = node.text; if (view.trackWrites == this.nodeDOM) { view.trackWrites = null; } } this.node = node; this.dirty = NOT_DIRTY; return true; }; TextViewDesc.prototype.inParent = function inParent() { var parentDOM = this.parent.contentDOM; for (var n = this.nodeDOM; n; n = n.parentNode) { if (n == parentDOM) { return true; } } return false; }; TextViewDesc.prototype.domFromPos = function domFromPos(pos) { return { node: this.nodeDOM, offset: pos }; }; TextViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset, bias) { if (dom == this.nodeDOM) { return ( this.posAtStart + Math.min(offset, this.node.text.length) ); } return NodeViewDesc.prototype.localPosFromDOM.call( this, dom, offset, bias ); }; TextViewDesc.prototype.ignoreMutation = function ignoreMutation( mutation ) { return ( mutation.type != "characterData" && mutation.type != "selection" ); }; TextViewDesc.prototype.slice = function slice(from, to, view) { var node = this.node.cut(from, to), dom = document.createTextNode(node.text); return new TextViewDesc( this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view ); }; TextViewDesc.prototype.markDirty = function markDirty( from, to ) { NodeViewDesc.prototype.markDirty.call(this, from, to); if ( this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length) ) { this.dirty = NODE_DIRTY; } }; prototypeAccessors$4.domAtom.get = function () { return false; }; Object.defineProperties( TextViewDesc.prototype, prototypeAccessors$4 ); return TextViewDesc; })(NodeViewDesc); // A dummy desc used to tag trailing BR or IMG nodes created to work // around contentEditable terribleness. var TrailingHackViewDesc = /*@__PURE__*/ (function (ViewDesc) { function TrailingHackViewDesc() { ViewDesc.apply(this, arguments); } if (ViewDesc) TrailingHackViewDesc.__proto__ = ViewDesc; TrailingHackViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype ); TrailingHackViewDesc.prototype.constructor = TrailingHackViewDesc; var prototypeAccessors$5 = { domAtom: { configurable: true }, ignoreForCoords: { configurable: true }, }; TrailingHackViewDesc.prototype.parseRule = function parseRule() { return { ignore: true }; }; TrailingHackViewDesc.prototype.matchesHack = function matchesHack(nodeName) { return ( this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName ); }; prototypeAccessors$5.domAtom.get = function () { return true; }; prototypeAccessors$5.ignoreForCoords.get = function () { return this.dom.nodeName == "IMG"; }; Object.defineProperties( TrailingHackViewDesc.prototype, prototypeAccessors$5 ); return TrailingHackViewDesc; })(ViewDesc); // A separate subclass is used for customized node views, so that the // extra checks only have to be made for nodes that are actually // customized. var CustomNodeViewDesc = /*@__PURE__*/ (function (NodeViewDesc) { function CustomNodeViewDesc( parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos ) { NodeViewDesc.call( this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos ); this.spec = spec; } if (NodeViewDesc) CustomNodeViewDesc.__proto__ = NodeViewDesc; CustomNodeViewDesc.prototype = Object.create( NodeViewDesc && NodeViewDesc.prototype ); CustomNodeViewDesc.prototype.constructor = CustomNodeViewDesc; // A custom `update` method gets to decide whether the update goes // through. If it does, and there's a `contentDOM` node, our logic // updates the children. CustomNodeViewDesc.prototype.update = function update( node, outerDeco, innerDeco, view ) { if (this.dirty == NODE_DIRTY) { return false; } if (this.spec.update) { var result = this.spec.update( node, outerDeco, innerDeco ); if (result) { this.updateInner(node, outerDeco, innerDeco, view); } return result; } else if (!this.contentDOM && !node.isLeaf) { return false; } else { return NodeViewDesc.prototype.update.call( this, node, outerDeco, innerDeco, view ); } }; CustomNodeViewDesc.prototype.selectNode = function selectNode() { this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc.prototype.selectNode.call(this); }; CustomNodeViewDesc.prototype.deselectNode = function deselectNode() { this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc.prototype.deselectNode.call(this); }; CustomNodeViewDesc.prototype.setSelection = function setSelection(anchor, head, root, force) { this.spec.setSelection ? this.spec.setSelection(anchor, head, root) : NodeViewDesc.prototype.setSelection.call( this, anchor, head, root, force ); }; CustomNodeViewDesc.prototype.destroy = function destroy() { if (this.spec.destroy) { this.spec.destroy(); } NodeViewDesc.prototype.destroy.call(this); }; CustomNodeViewDesc.prototype.stopEvent = function stopEvent( event ) { return this.spec.stopEvent ? this.spec.stopEvent(event) : false; }; CustomNodeViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) { return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc.prototype.ignoreMutation.call( this, mutation ); }; return CustomNodeViewDesc; })(NodeViewDesc); // : (dom.Node, [ViewDesc]) // Sync the content of the given DOM node with the nodes associated // with the given array of view descs, recursing into mark descs // because this should sync the subtree for a whole node at a time. function renderDescs(parentDOM, descs, view) { var dom = parentDOM.firstChild, written = false; for (var i = 0; i < descs.length; i++) { var desc = descs[i], childDOM = desc.dom; if (childDOM.parentNode == parentDOM) { while (childDOM != dom) { dom = rm(dom); written = true; } dom = dom.nextSibling; } else { written = true; parentDOM.insertBefore(childDOM, dom); } if (desc instanceof MarkViewDesc) { var pos = dom ? dom.previousSibling : parentDOM.lastChild; renderDescs(desc.contentDOM, desc.children, view); dom = pos ? pos.nextSibling : parentDOM.firstChild; } } while (dom) { dom = rm(dom); written = true; } if (written && view.trackWrites == parentDOM) { view.trackWrites = null; } } function OuterDecoLevel(nodeName) { if (nodeName) { this.nodeName = nodeName; } } OuterDecoLevel.prototype = Object.create(null); var noDeco = [new OuterDecoLevel()]; function computeOuterDeco(outerDeco, node, needsWrap) { if (outerDeco.length == 0) { return noDeco; } var top = needsWrap ? noDeco[0] : new OuterDecoLevel(), result = [top]; for (var i = 0; i < outerDeco.length; i++) { var attrs = outerDeco[i].type.attrs; if (!attrs) { continue; } if (attrs.nodeName) { result.push((top = new OuterDecoLevel(attrs.nodeName))); } for (var name in attrs) { var val = attrs[name]; if (val == null) { continue; } if (needsWrap && result.length == 1) { result.push( (top = new OuterDecoLevel( node.isInline ? "span" : "div" )) ); } if (name == "class") { top.class = (top.class ? top.class + " " : "") + val; } else if (name == "style") { top.style = (top.style ? top.style + ";" : "") + val; } else if (name != "nodeName") { top[name] = val; } } } return result; } function patchOuterDeco( outerDOM, nodeDOM, prevComputed, curComputed ) { // Shortcut for trivial case if (prevComputed == noDeco && curComputed == noDeco) { return nodeDOM; } var curDOM = nodeDOM; for (var i = 0; i < curComputed.length; i++) { var deco = curComputed[i], prev = prevComputed[i]; if (i) { var parent = void 0; if ( prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = curDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName ) { curDOM = parent; } else { parent = document.createElement(deco.nodeName); parent.pmIsDeco = true; parent.appendChild(curDOM); prev = noDeco[0]; curDOM = parent; } } patchAttributes(curDOM, prev || noDeco[0], deco); } return curDOM; } function patchAttributes(dom, prev, cur) { for (var name in prev) { if ( name != "class" && name != "style" && name != "nodeName" && !(name in cur) ) { dom.removeAttribute(name); } } for (var name$1 in cur) { if ( name$1 != "class" && name$1 != "style" && name$1 != "nodeName" && cur[name$1] != prev[name$1] ) { dom.setAttribute(name$1, cur[name$1]); } } if (prev.class != cur.class) { var prevList = prev.class ? prev.class.split(" ").filter(Boolean) : nothing; var curList = cur.class ? cur.class.split(" ").filter(Boolean) : nothing; for (var i = 0; i < prevList.length; i++) { if (curList.indexOf(prevList[i]) == -1) { dom.classList.remove(prevList[i]); } } for (var i$1 = 0; i$1 < curList.length; i$1++) { if (prevList.indexOf(curList[i$1]) == -1) { dom.classList.add(curList[i$1]); } } } if (prev.style != cur.style) { if (prev.style) { var prop = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, m; while ((m = prop.exec(prev.style))) { dom.style.removeProperty(m[1]); } } if (cur.style) { dom.style.cssText += cur.style; } } } function applyOuterDeco(dom, deco, node) { return patchOuterDeco( dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1) ); } // : ([Decoration], [Decoration]) → bool function sameOuterDeco(a, b) { if (a.length != b.length) { return false; } for (var i = 0; i < a.length; i++) { if (!a[i].type.eq(b[i].type)) { return false; } } return true; } // Remove a DOM node and return its next sibling. function rm(dom) { var next = dom.nextSibling; dom.parentNode.removeChild(dom); return next; } // Helper class for incrementally updating a tree of mark descs and // the widget and node descs inside of them. var ViewTreeUpdater = function ViewTreeUpdater(top, lockedNode) { this.top = top; this.lock = lockedNode; // Index into `this.top`'s child array, represents the current // update position. this.index = 0; // When entering a mark, the current top and index are pushed // onto this. this.stack = []; // Tracks whether anything was changed this.changed = false; this.preMatch = preMatch(top.node.content, top.children); }; // Destroy and remove the children between the given indices in // `this.top`. ViewTreeUpdater.prototype.destroyBetween = function destroyBetween( start, end ) { if (start == end) { return; } for (var i = start; i < end; i++) { this.top.children[i].destroy(); } this.top.children.splice(start, end - start); this.changed = true; }; // Destroy all remaining children in `this.top`. ViewTreeUpdater.prototype.destroyRest = function destroyRest() { this.destroyBetween(this.index, this.top.children.length); }; // : ([Mark], EditorView) // Sync the current stack of mark descs with the given array of // marks, reusing existing mark descs when possible. ViewTreeUpdater.prototype.syncToMarks = function syncToMarks( marks, inline, view ) { var keep = 0, depth = this.stack.length >> 1; var maxKeep = Math.min(depth, marks.length); while ( keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[(keep + 1) << 1] ).matchesMark(marks[keep]) && marks[keep].type.spec.spanning !== false ) { keep++; } while (keep < depth) { this.destroyRest(); this.top.dirty = NOT_DIRTY; this.index = this.stack.pop(); this.top = this.stack.pop(); depth--; } while (depth < marks.length) { this.stack.push(this.top, this.index + 1); var found = -1; for ( var i = this.index; i < Math.min(this.index + 3, this.top.children.length); i++ ) { if (this.top.children[i].matchesMark(marks[depth])) { found = i; break; } } if (found > -1) { if (found > this.index) { this.changed = true; this.destroyBetween(this.index, found); } this.top = this.top.children[this.index]; } else { var markDesc = MarkViewDesc.create( this.top, marks[depth], inline, view ); this.top.children.splice(this.index, 0, markDesc); this.top = markDesc; this.changed = true; } this.index = 0; depth++; } }; // : (Node, [Decoration], DecorationSource) → bool // Try to find a node desc matching the given data. Skip over it and // return true when successful. ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch( node, outerDeco, innerDeco, index ) { var children = this.top.children, found = -1; if (index >= this.preMatch.index) { for (var i = this.index; i < children.length; i++) { if ( children[i].matchesNode(node, outerDeco, innerDeco) ) { found = i; break; } } } else { for ( var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++ ) { var child = children[i$1]; if ( child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child) ) { found = i$1; break; } } } if (found < 0) { return false; } this.destroyBetween(this.index, found); this.index++; return true; }; ViewTreeUpdater.prototype.updateNodeAt = function updateNodeAt( node, outerDeco, innerDeco, index, view ) { var child = this.top.children[index]; if (!child.update(node, outerDeco, innerDeco, view)) { return false; } this.destroyBetween(this.index, index); this.index = index + 1; return true; }; ViewTreeUpdater.prototype.findIndexWithChild = function findIndexWithChild(domNode) { for (;;) { var parent = domNode.parentNode; if (!parent) { return -1; } if (parent == this.top.contentDOM) { var desc = domNode.pmViewDesc; if (desc) { for ( var i = this.index; i < this.top.children.length; i++ ) { if (this.top.children[i] == desc) { return i; } } } return -1; } domNode = parent; } }; // : (Node, [Decoration], DecorationSource, EditorView, Fragment, number) → bool // Try to update the next node, if any, to the given data. Checks // pre-matches to avoid overwriting nodes that could still be used. ViewTreeUpdater.prototype.updateNextNode = function updateNextNode( node, outerDeco, innerDeco, view, index ) { for (var i = this.index; i < this.top.children.length; i++) { var next = this.top.children[i]; if (next instanceof NodeViewDesc) { var preMatch = this.preMatch.matched.get(next); if (preMatch != null && preMatch != index) { return false; } var nextDOM = next.dom; // Can't update if nextDOM is or contains this.lock, except if // it's a text node whose content already matches the new text // and whose decorations match the new ones. var locked = this.lock && (nextDOM == this.lock || (nextDOM.nodeType == 1 && nextDOM.contains(this.lock.parentNode))) && !( node.isText && next.node && next.node.isText && next.nodeDOM.nodeValue == node.text && next.dirty != NODE_DIRTY && sameOuterDeco(outerDeco, next.outerDeco) ); if ( !locked && next.update(node, outerDeco, innerDeco, view) ) { this.destroyBetween(this.index, i); if (next.dom != nextDOM) { this.changed = true; } this.index++; return true; } break; } } return false; }; // : (Node, [Decoration], DecorationSource, EditorView) // Insert the node as a newly created node desc. ViewTreeUpdater.prototype.addNode = function addNode( node, outerDeco, innerDeco, view, pos ) { this.top.children.splice( this.index++, 0, NodeViewDesc.create( this.top, node, outerDeco, innerDeco, view, pos ) ); this.changed = true; }; ViewTreeUpdater.prototype.placeWidget = function placeWidget( widget, view, pos ) { var next = this.index < this.top.children.length ? this.top.children[this.index] : null; if ( next && next.matchesWidget(widget) && (widget == next.widget || !next.widget.type.toDOM.parentNode) ) { this.index++; } else { var desc = new WidgetViewDesc(this.top, widget, view, pos); this.top.children.splice(this.index++, 0, desc); this.changed = true; } }; // Make sure a textblock looks and behaves correctly in // contentEditable. ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks() { var lastChild = this.top.children[this.index - 1]; while (lastChild instanceof MarkViewDesc) { lastChild = lastChild.children[lastChild.children.length - 1]; } if ( !lastChild || // Empty textblock !(lastChild instanceof TextViewDesc) || /\n$/.test(lastChild.node.text) ) { // Avoid bugs in Safari's cursor drawing (#1165) and Chrome's mouse selection (#1152) if ( (result.safari || result.chrome) && lastChild && lastChild.dom.contentEditable == "false" ) { this.addHackNode("IMG"); } this.addHackNode("BR"); } }; ViewTreeUpdater.prototype.addHackNode = function addHackNode( nodeName ) { if ( this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName) ) { this.index++; } else { var dom = document.createElement(nodeName); if (nodeName == "IMG") { dom.className = "ProseMirror-separator"; } if (nodeName == "BR") { dom.className = "ProseMirror-trailingBreak"; } this.top.children.splice( this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null) ); this.changed = true; } }; // : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>} // Iterate from the end of the fragment and array of descs to find // directly matching ones, in order to avoid overeagerly reusing those // for other nodes. Returns the fragment index of the first node that // is part of the sequence of matched nodes at the end of the // fragment. function preMatch(frag, descs) { var fI = frag.childCount, dI = descs.length, matched = new Map(); for (; fI > 0 && dI > 0; dI--) { var desc = descs[dI - 1], node = desc.node; if (!node) { continue; } if (node != frag.child(fI - 1)) { break; } --fI; matched.set(desc, fI); } return { index: fI, matched: matched }; } function compareSide(a, b) { return a.type.side - b.type.side; } // : (ViewDesc, DecorationSource, (Decoration, number), (Node, [Decoration], DecorationSource, number)) // This function abstracts iterating over the nodes and decorations in // a fragment. Calls `onNode` for each node, with its local and child // decorations. Splits text nodes when there is a decoration starting // or ending inside of them. Calls `onWidget` for each widget. function iterDeco(parent, deco, onWidget, onNode) { var locals = deco.locals(parent), offset = 0; // Simple, cheap variant for when there are no local decorations if (locals.length == 0) { for (var i = 0; i < parent.childCount; i++) { var child = parent.child(i); onNode(child, locals, deco.forChild(offset, child), i); offset += child.nodeSize; } return; } var decoIndex = 0, active = [], restNode = null; for (var parentIndex = 0; ; ) { if ( decoIndex < locals.length && locals[decoIndex].to == offset ) { var widget = locals[decoIndex++], widgets = void 0; while ( decoIndex < locals.length && locals[decoIndex].to == offset ) { (widgets || (widgets = [widget])).push( locals[decoIndex++] ); } if (widgets) { widgets.sort(compareSide); for (var i$1 = 0; i$1 < widgets.length; i$1++) { onWidget(widgets[i$1], parentIndex, !!restNode); } } else { onWidget(widget, parentIndex, !!restNode); } } var child$1 = void 0, index = void 0; if (restNode) { index = -1; child$1 = restNode; restNode = null; } else if (parentIndex < parent.childCount) { index = parentIndex; child$1 = parent.child(parentIndex++); } else { break; } for (var i$2 = 0; i$2 < active.length; i$2++) { if (active[i$2].to <= offset) { active.splice(i$2--, 1); } } while ( decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset ) { active.push(locals[decoIndex++]); } var end = offset + child$1.nodeSize; if (child$1.isText) { var cutAt = end; if ( decoIndex < locals.length && locals[decoIndex].from < cutAt ) { cutAt = locals[decoIndex].from; } for (var i$3 = 0; i$3 < active.length; i$3++) { if (active[i$3].to < cutAt) { cutAt = active[i$3].to; } } if (cutAt < end) { restNode = child$1.cut(cutAt - offset); child$1 = child$1.cut(0, cutAt - offset); end = cutAt; index = -1; } } var outerDeco = !active.length ? nothing : child$1.isInline && !child$1.isLeaf ? active.filter(function (d) { return !d.inline; }) : active.slice(); onNode( child$1, outerDeco, deco.forChild(offset, child$1), index ); offset = end; } } // List markers in Mobile Safari will mysteriously disappear // sometimes. This works around that. function iosHacks(dom) { if (dom.nodeName == "UL" || dom.nodeName == "OL") { var oldCSS = dom.style.cssText; dom.style.cssText = oldCSS + "; list-style: square !important"; window.getComputedStyle(dom).listStyle; dom.style.cssText = oldCSS; } } function nearbyTextNode(node, offset) { for (;;) { if (node.nodeType == 3) { return node; } if (node.nodeType == 1 && offset > 0) { if ( node.childNodes.length > offset && node.childNodes[offset].nodeType == 3 ) { return node.childNodes[offset]; } node = node.childNodes[offset - 1]; offset = nodeSize(node); } else if ( node.nodeType == 1 && offset < node.childNodes.length ) { node = node.childNodes[offset]; offset = 0; } else { return null; } } } // Find a piece of text in an inline fragment, overlapping from-to function findTextInFragment(frag, text, from, to) { for (var i = 0, pos = 0; i < frag.childCount && pos <= to; ) { var child = frag.child(i++), childStart = pos; pos += child.nodeSize; if (!child.isText) { continue; } var str = child.text; while (i < frag.childCount) { var next = frag.child(i++); pos += next.nodeSize; if (!next.isText) { break; } str += next.text; } if (pos >= from) { var found = str.lastIndexOf(text, to - childStart); if ( found >= 0 && found + text.length + childStart >= from ) { return childStart + found; } } } return -1; } // Replace range from-to in an array of view descs with replacement // (may be null to just delete). This goes very much against the grain // of the rest of this code, which tends to create nodes with the // right shape in one go, rather than messing with them after // creation, but is necessary in the composition hack. function replaceNodes(nodes, from, to, view, replacement) { var result = []; for (var i = 0, off = 0; i < nodes.length; i++) { var child = nodes[i], start = off, end = (off += child.size); if (start >= to || end <= from) { result.push(child); } else { if (start < from) { result.push(child.slice(0, from - start, view)); } if (replacement) { result.push(replacement); replacement = null; } if (end > to) { result.push( child.slice(to - start, child.size, view) ); } } } return result; } function selectionFromDOM(view, origin) { var domSel = view.root.getSelection(), doc = view.state.doc; if (!domSel.focusNode) { return null; } var nearestDesc = view.docView.nearestDesc(domSel.focusNode), inWidget = nearestDesc && nearestDesc.size == 0; var head = view.docView.posFromDOM( domSel.focusNode, domSel.focusOffset ); if (head < 0) { return null; } var $head = doc.resolve(head), $anchor, selection; if (selectionCollapsed(domSel)) { $anchor = $head; while (nearestDesc && !nearestDesc.node) { nearestDesc = nearestDesc.parent; } if ( nearestDesc && nearestDesc.node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( nearestDesc.node ) && nearestDesc.parent && !( nearestDesc.node.isInline && isOnEdge( domSel.focusNode, domSel.focusOffset, nearestDesc.dom ) ) ) { var pos = nearestDesc.posBefore; selection = new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection( head == pos ? $head : doc.resolve(pos) ); } } else { var anchor = view.docView.posFromDOM( domSel.anchorNode, domSel.anchorOffset ); if (anchor < 0) { return null; } $anchor = doc.resolve(anchor); } if (!selection) { var bias = origin == "pointer" || (view.state.selection.head < $head.pos && !inWidget) ? 1 : -1; selection = selectionBetween(view, $anchor, $head, bias); } return selection; } function editorOwnsSelection(view) { return view.editable ? view.hasFocus() : hasSelection(view) && document.activeElement && document.activeElement.contains(view.dom); } function selectionToDOM(view, force) { var sel = view.state.selection; syncNodeSelection(view, sel); if (!editorOwnsSelection(view)) { return; } if (!force && view.mouseDown && view.mouseDown.allowDefault) { view.mouseDown.delayedSelectionSync = true; view.domObserver.setCurSelection(); return; } view.domObserver.disconnectSelection(); if (view.cursorWrapper) { selectCursorWrapper(view); } else { var anchor = sel.anchor; var head = sel.head; var resetEditableFrom, resetEditableTo; if ( brokenSelectBetweenUneditable && !( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) ) { if (!sel.$from.parent.inlineContent) { resetEditableFrom = temporarilyEditableNear( view, sel.from ); } if (!sel.empty && !sel.$from.parent.inlineContent) { resetEditableTo = temporarilyEditableNear( view, sel.to ); } } view.docView.setSelection(anchor, head, view.root, force); if (brokenSelectBetweenUneditable) { if (resetEditableFrom) { resetEditable(resetEditableFrom); } if (resetEditableTo) { resetEditable(resetEditableTo); } } if (sel.visible) { view.dom.classList.remove("ProseMirror-hideselection"); } else { view.dom.classList.add("ProseMirror-hideselection"); if ("onselectionchange" in document) { removeClassOnSelectionChange(view); } } } view.domObserver.setCurSelection(); view.domObserver.connectSelection(); } // Kludge to work around Webkit not allowing a selection to start/end // between non-editable block nodes. We briefly make something // editable, set the selection, then set it uneditable again. var brokenSelectBetweenUneditable = result.safari || (result.chrome && result.chrome_version < 63); function temporarilyEditableNear(view, pos) { var ref = view.docView.domFromPos(pos, 0); var node = ref.node; var offset = ref.offset; var after = offset < node.childNodes.length ? node.childNodes[offset] : null; var before = offset ? node.childNodes[offset - 1] : null; if ( result.safari && after && after.contentEditable == "false" ) { return setEditable(after); } if ( (!after || after.contentEditable == "false") && (!before || before.contentEditable == "false") ) { if (after) { return setEditable(after); } else if (before) { return setEditable(before); } } } function setEditable(element) { element.contentEditable = "true"; if (result.safari && element.draggable) { element.draggable = false; element.wasDraggable = true; } return element; } function resetEditable(element) { element.contentEditable = "false"; if (element.wasDraggable) { element.draggable = true; element.wasDraggable = null; } } function removeClassOnSelectionChange(view) { var doc = view.dom.ownerDocument; doc.removeEventListener( "selectionchange", view.hideSelectionGuard ); var domSel = view.root.getSelection(); var node = domSel.anchorNode, offset = domSel.anchorOffset; doc.addEventListener( "selectionchange", (view.hideSelectionGuard = function () { if ( domSel.anchorNode != node || domSel.anchorOffset != offset ) { doc.removeEventListener( "selectionchange", view.hideSelectionGuard ); setTimeout(function () { if ( !editorOwnsSelection(view) || view.state.selection.visible ) { view.dom.classList.remove( "ProseMirror-hideselection" ); } }, 20); } }) ); } function selectCursorWrapper(view) { var domSel = view.root.getSelection(), range = document.createRange(); var node = view.cursorWrapper.dom, img = node.nodeName == "IMG"; if (img) { range.setEnd(node.parentNode, domIndex(node) + 1); } else { range.setEnd(node, 0); } range.collapse(false); domSel.removeAllRanges(); domSel.addRange(range); // Kludge to kill 'control selection' in IE11 when selecting an // invisible cursor wrapper, since that would result in those weird // resize handles and a selection that considers the absolutely // positioned wrapper, rather than the root editable node, the // focused element. if ( !img && !view.state.selection.visible && result.ie && result.ie_version <= 11 ) { node.disabled = true; node.disabled = false; } } function syncNodeSelection(view, sel) { if ( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ) { var desc = view.docView.descAt(sel.from); if (desc != view.lastSelectedViewDesc) { clearNodeSelection(view); if (desc) { desc.selectNode(); } view.lastSelectedViewDesc = desc; } } else { clearNodeSelection(view); } } // Clear all DOM statefulness of the last node selection. function clearNodeSelection(view) { if (view.lastSelectedViewDesc) { if (view.lastSelectedViewDesc.parent) { view.lastSelectedViewDesc.deselectNode(); } view.lastSelectedViewDesc = null; } } function selectionBetween(view, $anchor, $head, bias) { return ( view.someProp("createSelectionBetween", function (f) { return f(view, $anchor, $head); }) || prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.between( $anchor, $head, bias ) ); } function hasFocusAndSelection(view) { if (view.editable && view.root.activeElement != view.dom) { return false; } return hasSelection(view); } function hasSelection(view) { var sel = view.root.getSelection(); if (!sel.anchorNode) { return false; } try { // Firefox will raise 'permission denied' errors when accessing // properties of `sel.anchorNode` when it's in a generated CSS // element. return ( view.dom.contains( sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode ) && (view.editable || view.dom.contains( sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode )) ); } catch (_) { return false; } } function anchorInRightPlace(view) { var anchorDOM = view.docView.domFromPos( view.state.selection.anchor, 0 ); var domSel = view.root.getSelection(); return isEquivalentPosition( anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset ); } function moveSelectionBlock(state, dir) { var ref = state.selection; var $anchor = ref.$anchor; var $head = ref.$head; var $side = dir > 0 ? $anchor.max($head) : $anchor.min($head); var $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve( dir > 0 ? $side.after() : $side.before() ) : null; return ( $start && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom( $start, dir ) ); } function apply(view, sel) { view.dispatch(view.state.tr.setSelection(sel).scrollIntoView()); return true; } function selectHorizontally(view, dir, mods) { var sel = view.state.selection; if ( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) { if (!sel.empty || mods.indexOf("s") > -1) { return false; } else if ( view.endOfTextblock(dir > 0 ? "right" : "left") ) { var next = moveSelectionBlock(view.state, dir); if ( next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ) { return apply(view, next); } return false; } else if (!(result.mac && mods.indexOf("m") > -1)) { var $head = sel.$head, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter, desc; if (!node || node.isText) { return false; } var nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos; if ( !( node.isAtom || ((desc = view.docView.descAt(nodePos)) && !desc.contentDOM) ) ) { return false; } if ( prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( node ) ) { return apply( view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection( dir < 0 ? view.state.doc.resolve( $head.pos - node.nodeSize ) : $head ) ); } else if (result.webkit) { // Chrome and Safari will introduce extra pointless cursor // positions around inline uneditable nodes, so we have to // take over and move the cursor past them (#937) return apply( view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection( view.state.doc.resolve( dir < 0 ? nodePos : nodePos + node.nodeSize ) ) ); } else { return false; } } } else if ( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && sel.node.isInline ) { return apply( view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection( dir > 0 ? sel.$to : sel.$from ) ); } else { var next$1 = moveSelectionBlock(view.state, dir); if (next$1) { return apply(view, next$1); } return false; } } function nodeLen(node) { return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length; } function isIgnorable(dom) { var desc = dom.pmViewDesc; return ( desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != "BR") ); } // Make sure the cursor isn't directly after one or more ignored // nodes, which will confuse the browser's cursor motion logic. function skipIgnoredNodesLeft(view) { var sel = view.root.getSelection(); var node = sel.focusNode, offset = sel.focusOffset; if (!node) { return; } var moveNode, moveOffset, force = false; // Gecko will do odd things when the selection is directly in front // of a non-editable node, so in that case, move it into the next // node if possible. Issue prosemirror/prosemirror#832. if ( result.gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset]) ) { force = true; } for (;;) { if (offset > 0) { if (node.nodeType != 1) { break; } else { var before = node.childNodes[offset - 1]; if (isIgnorable(before)) { moveNode = node; moveOffset = --offset; } else if (before.nodeType == 3) { node = before; offset = node.nodeValue.length; } else { break; } } } else if (isBlockNode(node)) { break; } else { var prev = node.previousSibling; while (prev && isIgnorable(prev)) { moveNode = node.parentNode; moveOffset = domIndex(prev); prev = prev.previousSibling; } if (!prev) { node = node.parentNode; if (node == view.dom) { break; } offset = 0; } else { node = prev; offset = nodeLen(node); } } } if (force) { setSelFocus(view, sel, node, offset); } else if (moveNode) { setSelFocus(view, sel, moveNode, moveOffset); } } // Make sure the cursor isn't directly before one or more ignored // nodes. function skipIgnoredNodesRight(view) { var sel = view.root.getSelection(); var node = sel.focusNode, offset = sel.focusOffset; if (!node) { return; } var len = nodeLen(node); var moveNode, moveOffset; for (;;) { if (offset < len) { if (node.nodeType != 1) { break; } var after = node.childNodes[offset]; if (isIgnorable(after)) { moveNode = node; moveOffset = ++offset; } else { break; } } else if (isBlockNode(node)) { break; } else { var next = node.nextSibling; while (next && isIgnorable(next)) { moveNode = next.parentNode; moveOffset = domIndex(next) + 1; next = next.nextSibling; } if (!next) { node = node.parentNode; if (node == view.dom) { break; } offset = len = 0; } else { node = next; offset = 0; len = nodeLen(node); } } } if (moveNode) { setSelFocus(view, sel, moveNode, moveOffset); } } function isBlockNode(dom) { var desc = dom.pmViewDesc; return desc && desc.node && desc.node.isBlock; } function setSelFocus(view, sel, node, offset) { if (selectionCollapsed(sel)) { var range = document.createRange(); range.setEnd(node, offset); range.setStart(node, offset); sel.removeAllRanges(); sel.addRange(range); } else if (sel.extend) { sel.extend(node, offset); } view.domObserver.setCurSelection(); var state = view.state; // If no state update ends up happening, reset the selection. setTimeout(function () { if (view.state == state) { selectionToDOM(view); } }, 50); } // : (EditorState, number) // Check whether vertical selection motion would involve node // selections. If so, apply it (if not, the result is left to the // browser) function selectVertically(view, dir, mods) { var sel = view.state.selection; if ( (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty) || mods.indexOf("s") > -1 ) { return false; } if (result.mac && mods.indexOf("m") > -1) { return false; } var $from = sel.$from; var $to = sel.$to; if ( !$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? "up" : "down") ) { var next = moveSelectionBlock(view.state, dir); if ( next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ) { return apply(view, next); } } if (!$from.parent.inlineContent) { var side = dir < 0 ? $from : $to; var beyond = sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.AllSelection ? prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.near( side, dir ) : prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom( side, dir ); return beyond ? apply(view, beyond) : false; } return false; } function stopNativeHorizontalDelete(view, dir) { if ( !( view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) ) { return true; } var ref = view.state.selection; var $head = ref.$head; var $anchor = ref.$anchor; var empty = ref.empty; if (!$head.sameParent($anchor)) { return true; } if (!empty) { return false; } if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) { return true; } var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter); if (nextNode && !nextNode.isText) { var tr = view.state.tr; if (dir < 0) { tr.delete($head.pos - nextNode.nodeSize, $head.pos); } else { tr.delete($head.pos, $head.pos + nextNode.nodeSize); } view.dispatch(tr); return true; } return false; } function switchEditable(view, node, state) { view.domObserver.stop(); node.contentEditable = state; view.domObserver.start(); } // Issue #867 / #1090 / https://bugs.chromium.org/p/chromium/issues/detail?id=903821 // In which Safari (and at some point in the past, Chrome) does really // wrong things when the down arrow is pressed when the cursor is // directly at the start of a textblock and has an uneditable node // after it function safariDownArrowBug(view) { if ( !result.safari || view.state.selection.$head.parentOffset > 0 ) { return; } var ref = view.root.getSelection(); var focusNode = ref.focusNode; var focusOffset = ref.focusOffset; if ( focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == "false" ) { var child = focusNode.firstChild; switchEditable(view, child, true); setTimeout(function () { return switchEditable(view, child, false); }, 20); } } // A backdrop key mapping used to make sure we always suppress keys // that have a dangerous default effect, even if the commands they are // bound to return false, and to make sure that cursor-motion keys // find a cursor (as opposed to a node selection) when pressed. For // cursor-motion keys, the code in the handlers also takes care of // block selections. function getMods(event) { var result = ""; if (event.ctrlKey) { result += "c"; } if (event.metaKey) { result += "m"; } if (event.altKey) { result += "a"; } if (event.shiftKey) { result += "s"; } return result; } function captureKeyDown(view, event) { var code = event.keyCode, mods = getMods(event); if (code == 8 || (result.mac && code == 72 && mods == "c")) { // Backspace, Ctrl-h on Mac return ( stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view) ); } else if ( code == 46 || (result.mac && code == 68 && mods == "c") ) { // Delete, Ctrl-d on Mac return ( stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view) ); } else if (code == 13 || code == 27) { // Enter, Esc return true; } else if (code == 37) { // Left arrow return ( selectHorizontally(view, -1, mods) || skipIgnoredNodesLeft(view) ); } else if (code == 39) { // Right arrow return ( selectHorizontally(view, 1, mods) || skipIgnoredNodesRight(view) ); } else if (code == 38) { // Up arrow return ( selectVertically(view, -1, mods) || skipIgnoredNodesLeft(view) ); } else if (code == 40) { // Down arrow return ( safariDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodesRight(view) ); } else if ( mods == (result.mac ? "m" : "c") && (code == 66 || code == 73 || code == 89 || code == 90) ) { // Mod-[biyz] return true; } return false; } // Note that all referencing and parsing is done with the // start-of-operation selection and document, since that's the one // that the DOM represents. If any changes came in in the meantime, // the modification is mapped over those before it is applied, in // readDOMChange. function parseBetween(view, from_, to_) { var ref = view.docView.parseRange(from_, to_); var parent = ref.node; var fromOffset = ref.fromOffset; var toOffset = ref.toOffset; var from = ref.from; var to = ref.to; var domSel = view.root.getSelection(), find = null, anchor = domSel.anchorNode; if ( anchor && view.dom.contains( anchor.nodeType == 1 ? anchor : anchor.parentNode ) ) { find = [{ node: anchor, offset: domSel.anchorOffset }]; if (!selectionCollapsed(domSel)) { find.push({ node: domSel.focusNode, offset: domSel.focusOffset, }); } } // Work around issue in Chrome where backspacing sometimes replaces // the deleted content with a random BR node (issues #799, #831) if (result.chrome && view.lastKeyCode === 8) { for (var off = toOffset; off > fromOffset; off--) { var node = parent.childNodes[off - 1], desc = node.pmViewDesc; if (node.nodeName == "BR" && !desc) { toOffset = off; break; } if (!desc || desc.size) { break; } } } var startDoc = view.state.doc; var parser = view.someProp("domParser") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMParser.fromSchema( view.state.schema ); var $from = startDoc.resolve(from); var sel = null, doc = parser.parse(parent, { topNode: $from.parent, topMatch: $from.parent.contentMatchAt($from.index()), topOpen: true, from: fromOffset, to: toOffset, preserveWhitespace: $from.parent.type.spec.code ? "full" : true, editableContent: true, findPositions: find, ruleFromNode: ruleFromNode, context: $from, }); if (find && find[0].pos != null) { var anchor$1 = find[0].pos, head = find[1] && find[1].pos; if (head == null) { head = anchor$1; } sel = { anchor: anchor$1 + from, head: head + from }; } return { doc: doc, sel: sel, from: from, to: to }; } function ruleFromNode(dom) { var desc = dom.pmViewDesc; if (desc) { return desc.parseRule(); } else if (dom.nodeName == "BR" && dom.parentNode) { // Safari replaces the list item or table cell with a BR // directly in the list node (?!) if you delete the last // character in a list item or table cell (#708, #862) if ( result.safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName) ) { var skip = document.createElement("div"); skip.appendChild(document.createElement("li")); return { skip: skip }; } else if ( dom.parentNode.lastChild == dom || (result.safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) ) { return { ignore: true }; } } else if ( dom.nodeName == "IMG" && dom.getAttribute("mark-placeholder") ) { return { ignore: true }; } } function readDOMChange(view, from, to, typeOver, addedNodes) { if (from < 0) { var origin = view.lastSelectionTime > Date.now() - 50 ? view.lastSelectionOrigin : null; var newSel = selectionFromDOM(view, origin); if (newSel && !view.state.selection.eq(newSel)) { var tr$1 = view.state.tr.setSelection(newSel); if (origin == "pointer") { tr$1.setMeta("pointer", true); } else if (origin == "key") { tr$1.scrollIntoView(); } view.dispatch(tr$1); } return; } var $before = view.state.doc.resolve(from); var shared = $before.sharedDepth(to); from = $before.before(shared + 1); to = view.state.doc.resolve(to).after(shared + 1); var sel = view.state.selection; var parse = parseBetween(view, from, to); // Chrome sometimes leaves the cursor before the inserted text when // composing after a cursor wrapper. This moves it forward. if ( result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from ) { var text = view.cursorWrapper.deco.type.toDOM.nextSibling; var size = text && text.nodeValue ? text.nodeValue.length : 1; parse.sel = { anchor: parse.sel.anchor + size, head: parse.sel.anchor + size, }; } var doc = view.state.doc, compare = doc.slice(parse.from, parse.to); var preferredPos, preferredSide; // Prefer anchoring to end when Backspace is pressed if ( view.lastKeyCode === 8 && Date.now() - 100 < view.lastKeyCodeTime ) { preferredPos = view.state.selection.to; preferredSide = "end"; } else { preferredPos = view.state.selection.from; preferredSide = "start"; } view.lastKeyCode = null; var change = findDiff( compare.content, parse.doc.content, parse.from, preferredPos, preferredSide ); if (!change) { if ( typeOver && sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head) ) { change = { start: sel.from, endA: sel.to, endB: sel.to, }; } else if ( ((result.ios && view.lastIOSEnter > Date.now() - 225) || result.android) && addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }) && view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); }) ) { view.lastIOSEnter = 0; return; } else { if (parse.sel) { var sel$1 = resolveSelection( view, view.state.doc, parse.sel ); if (sel$1 && !sel$1.eq(view.state.selection)) { view.dispatch( view.state.tr.setSelection(sel$1) ); } } return; } } view.domChangeCount++; // Handle the case where overwriting a selection by typing matches // the start or end of the selected content, creating a change // that's smaller than what was actually overwritten. if ( view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) { if ( change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 ) { change.start = view.state.selection.from; } else if ( change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 ) { change.endB += view.state.selection.to - change.endA; change.endA = view.state.selection.to; } } // IE11 will insert a non-breaking space _ahead_ of the space after // the cursor space when adding a space before another space. When // that happened, adjust the change to cover the space instead. if ( result.ie && result.ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse.from && parse.doc.textBetween( change.start - parse.from - 1, change.start - parse.from + 1 ) == " \u00a0" ) { change.start--; change.endA--; change.endB--; } var $from = parse.doc.resolveNoCache(change.start - parse.from); var $to = parse.doc.resolveNoCache(change.endB - parse.from); var inlineChange = $from.sameParent($to) && $from.parent.inlineContent; var nextSel; // If this looks like the effect of pressing Enter (or was recorded // as being an iOS enter press), just dispatch an Enter key instead. if ( ((result.ios && view.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }))) || (!inlineChange && $from.pos < parse.doc.content.size && (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom( parse.doc.resolve($from.pos + 1), 1, true )) && nextSel.head == $to.pos)) && view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); }) ) { view.lastIOSEnter = 0; return; } // Same for backspace if ( view.state.selection.anchor > change.start && looksLikeJoin(doc, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(8, "Backspace")); }) ) { if (result.android && result.chrome) { view.domObserver.suppressSelectionUpdates(); } // #820 return; } // Chrome Android will occasionally, during composition, delete the // entire composition and then immediately insert it again. This is // used to detect that situation. if ( result.chrome && result.android && change.toB == change.from ) { view.lastAndroidDelete = Date.now(); } // This tries to detect Android virtual keyboard // enter-and-pick-suggestion action. That sometimes (see issue // #1059) first fires a DOM mutation, before moving the selection to // the newly created block. And then, because ProseMirror cleans up // the DOM selection, it gives up moving the selection entirely, // leaving the cursor in the wrong place. When that happens, we drop // the new paragraph from the initial change, and fire a simulated // enter key afterwards. if ( result.android && !inlineChange && $from.start() != $to.start() && $to.parentOffset == 0 && $from.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA ) { change.endB -= 2; $to = parse.doc.resolveNoCache(change.endB - parse.from); setTimeout(function () { view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); }); }, 20); } var chFrom = change.start, chTo = change.endA; var tr, storedMarks, markChange, $from1; if (inlineChange) { if ($from.pos == $to.pos) { // Deletion // IE11 sometimes weirdly moves the DOM selection around after // backspacing out the first element in a textblock if ( result.ie && result.ie_version <= 11 && $from.parentOffset == 0 ) { view.domObserver.suppressSelectionUpdates(); setTimeout(function () { return selectionToDOM(view); }, 20); } tr = view.state.tr.delete(chFrom, chTo); storedMarks = doc .resolve(change.start) .marksAcross(doc.resolve(change.endA)); } else if ( // Adding or removing a mark change.endA == change.endB && ($from1 = doc.resolve(change.start)) && (markChange = isMarkChange( $from.parent.content.cut( $from.parentOffset, $to.parentOffset ), $from1.parent.content.cut( $from1.parentOffset, change.endA - $from1.start() ) )) ) { tr = view.state.tr; if (markChange.type == "add") { tr.addMark(chFrom, chTo, markChange.mark); } else { tr.removeMark(chFrom, chTo, markChange.mark); } } else if ( $from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1) ) { // Both positions in the same text node -- simply insert text var text$1 = $from.parent.textBetween( $from.parentOffset, $to.parentOffset ); if ( view.someProp("handleTextInput", function (f) { return f(view, chFrom, chTo, text$1); }) ) { return; } tr = view.state.tr.insertText(text$1, chFrom, chTo); } } if (!tr) { tr = view.state.tr.replace( chFrom, chTo, parse.doc.slice( change.start - parse.from, change.endB - parse.from ) ); } if (parse.sel) { var sel$2 = resolveSelection(view, tr.doc, parse.sel); // Chrome Android will sometimes, during composition, report the // selection in the wrong place. If it looks like that is // happening, don't update the selection. // Edge just doesn't move the cursor forward when you start typing // in an empty block or between br nodes. if ( sel$2 && !( (result.chrome && result.android && view.composing && sel$2.empty && (change.start != change.endB || view.lastAndroidDelete < Date.now() - 100) && (sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1)) || (result.ie && sel$2.empty && sel$2.head == chFrom) ) ) { tr.setSelection(sel$2); } } if (storedMarks) { tr.ensureMarks(storedMarks); } view.dispatch(tr.scrollIntoView()); } function resolveSelection(view, doc, parsedSel) { if ( Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size ) { return null; } return selectionBetween( view, doc.resolve(parsedSel.anchor), doc.resolve(parsedSel.head) ); } // : (Fragment, Fragment) → ?{mark: Mark, type: string} // Given two same-length, non-empty fragments of inline content, // determine whether the first could be created from the second by // removing or adding a single mark type. function isMarkChange(cur, prev) { var curMarks = cur.firstChild.marks, prevMarks = prev.firstChild.marks; var added = curMarks, removed = prevMarks, type, mark, update; for (var i = 0; i < prevMarks.length; i++) { added = prevMarks[i].removeFromSet(added); } for (var i$1 = 0; i$1 < curMarks.length; i$1++) { removed = curMarks[i$1].removeFromSet(removed); } if (added.length == 1 && removed.length == 0) { mark = added[0]; type = "add"; update = function (node) { return node.mark(mark.addToSet(node.marks)); }; } else if (added.length == 0 && removed.length == 1) { mark = removed[0]; type = "remove"; update = function (node) { return node.mark(mark.removeFromSet(node.marks)); }; } else { return null; } var updated = []; for (var i$2 = 0; i$2 < prev.childCount; i$2++) { updated.push(update(prev.child(i$2))); } if ( prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( updated ).eq(cur) ) { return { mark: mark, type: type }; } } function looksLikeJoin(old, start, end, $newStart, $newEnd) { if ( !$newStart.parent.isTextblock || // The content must have shrunk end - start <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into skipClosingAndOpening($newStart, true, false) < $newEnd.pos ) { return false; } var $start = old.resolve(start); // Start must be at the end of a block if ( $start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock ) { return false; } var $next = old.resolve( skipClosingAndOpening($start, true, true) ); // The next textblock must start before end and end near it if ( !$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end ) { return false; } // The fragments after the join point must match return $newStart.parent.content .cut($newStart.parentOffset) .eq($next.parent.content); } function skipClosingAndOpening($pos, fromEnd, mayOpen) { var depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos; while ( depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount) ) { depth--; end++; fromEnd = false; } if (mayOpen) { var next = $pos .node(depth) .maybeChild($pos.indexAfter(depth)); while (next && !next.isLeaf) { next = next.firstChild; end++; } } return end; } function findDiff(a, b, pos, preferredPos, preferredSide) { var start = a.findDiffStart(b, pos); if (start == null) { return null; } var ref = a.findDiffEnd(b, pos + a.size, pos + b.size); var endA = ref.a; var endB = ref.b; if (preferredSide == "end") { var adjust = Math.max(0, start - Math.min(endA, endB)); preferredPos -= endA + adjust - start; } if (endA < start && a.size < b.size) { var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0; start -= move; endB = start + (endB - endA); endA = start; } else if (endB < start) { var move$1 = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0; start -= move$1; endA = start + (endA - endB); endB = start; } return { start: start, endA: endA, endB: endB }; } function serializeForClipboard(view, slice) { var context = []; var content = slice.content; var openStart = slice.openStart; var openEnd = slice.openEnd; while ( openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1 ) { openStart--; openEnd--; var node = content.firstChild; context.push( node.type.name, node.attrs != node.type.defaultAttrs ? node.attrs : null ); content = node.content; } var serializer = view.someProp("clipboardSerializer") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.fromSchema( view.state.schema ); var doc = detachedDoc(), wrap = doc.createElement("div"); wrap.appendChild( serializer.serializeFragment(content, { document: doc }) ); var firstChild = wrap.firstChild, needsWrap; while ( firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()]) ) { for (var i = needsWrap.length - 1; i >= 0; i--) { var wrapper = doc.createElement(needsWrap[i]); while (wrap.firstChild) { wrapper.appendChild(wrap.firstChild); } wrap.appendChild(wrapper); if (needsWrap[i] != "tbody") { openStart++; openEnd++; } } firstChild = wrap.firstChild; } if (firstChild && firstChild.nodeType == 1) { firstChild.setAttribute( "data-pm-slice", openStart + " " + openEnd + " " + JSON.stringify(context) ); } var text = view.someProp("clipboardTextSerializer", function (f) { return f(slice); }) || slice.content.textBetween(0, slice.content.size, "\n\n"); return { dom: wrap, text: text }; } // : (EditorView, string, string, ?bool, ResolvedPos) → ?Slice // Read a slice of content from the clipboard (or drop data). function parseFromClipboard(view, text, html, plainText, $context) { var dom, inCode = $context.parent.type.spec.code, slice; if (!html && !text) { return null; } var asText = text && (plainText || inCode || !html); if (asText) { view.someProp("transformPastedText", function (f) { text = f(text, inCode || plainText); }); if (inCode) { return text ? new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice( prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( view.state.schema.text( text.replace(/\r\n?/g, "\n") ) ), 0, 0 ) : prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Slice.empty; } var parsed = view.someProp( "clipboardTextParser", function (f) { return f(text, $context, plainText); } ); if (parsed) { slice = parsed; } else { var marks = $context.marks(); var ref = view.state; var schema = ref.schema; var serializer = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.fromSchema( schema ); dom = document.createElement("div"); text.split(/(?:\r\n?|\n)+/).forEach(function (block) { var p = dom.appendChild( document.createElement("p") ); if (block) { p.appendChild( serializer.serializeNode( schema.text(block, marks) ) ); } }); } } else { view.someProp("transformPastedHTML", function (f) { html = f(html); }); dom = readHTML(html); if (result.webkit) { restoreReplacedSpaces(dom); } } var contextNode = dom && dom.querySelector("[data-pm-slice]"); var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec( contextNode.getAttribute("data-pm-slice") ); if (!slice) { var parser = view.someProp("clipboardParser") || view.someProp("domParser") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMParser.fromSchema( view.state.schema ); slice = parser.parseSlice(dom, { preserveWhitespace: !!(asText || sliceData), context: $context, }); } if (sliceData) { slice = addContext( closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3] ); } else { // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice.maxOpen( normalizeSiblings(slice.content, $context), true ); if (slice.openStart || slice.openEnd) { var openStart = 0, openEnd = 0; for ( var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating; openStart++, node = node.firstChild ) {} for ( var node$1 = slice.content.lastChild; openEnd < slice.openEnd && !node$1.type.spec.isolating; openEnd++, node$1 = node$1.lastChild ) {} slice = closeSlice(slice, openStart, openEnd); } } view.someProp("transformPasted", function (f) { slice = f(slice); }); return slice; } // Takes a slice parsed with parseSlice, which means there hasn't been // any content-expression checking done on the top nodes, tries to // find a parent node in the current context that might fit the nodes, // and if successful, rebuilds the slice so that it fits into that parent. // // This addresses the problem that Transform.replace expects a // coherent slice, and will fail to place a set of siblings that don't // fit anywhere in the schema. function normalizeSiblings(fragment, $context) { if (fragment.childCount < 2) { return fragment; } var loop = function (d) { var parent = $context.node(d); var match = parent.contentMatchAt($context.index(d)); var lastWrap = void 0, result = []; fragment.forEach(function (node) { if (!result) { return; } var wrap = match.findWrapping(node.type), inLast; if (!wrap) { return (result = null); } if ( (inLast = result.length && lastWrap.length && addToSibling( wrap, lastWrap, node, result[result.length - 1], 0 )) ) { result[result.length - 1] = inLast; } else { if (result.length) { result[result.length - 1] = closeRight( result[result.length - 1], lastWrap.length ); } var wrapped = withWrappers(node, wrap); result.push(wrapped); match = match.matchType( wrapped.type, wrapped.attrs ); lastWrap = wrap; } }); if (result) { return { v: prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( result ), }; } }; for (var d = $context.depth; d >= 0; d--) { var returned = loop(d); if (returned) return returned.v; } return fragment; } function withWrappers(node, wrap, from) { if (from === void 0) from = 0; for (var i = wrap.length - 1; i >= from; i--) { node = wrap[i].create( null, prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( node ) ); } return node; } // Used to group adjacent nodes wrapped in similar parents by // normalizeSiblings into the same parent node function addToSibling(wrap, lastWrap, node, sibling, depth) { if ( depth < wrap.length && depth < lastWrap.length && wrap[depth] == lastWrap[depth] ) { var inner = addToSibling( wrap, lastWrap, node, sibling.lastChild, depth + 1 ); if (inner) { return sibling.copy( sibling.content.replaceChild( sibling.childCount - 1, inner ) ); } var match = sibling.contentMatchAt(sibling.childCount); if ( match.matchType( depth == wrap.length - 1 ? node.type : wrap[depth + 1] ) ) { return sibling.copy( sibling.content.append( prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( withWrappers(node, wrap, depth + 1) ) ) ); } } } function closeRight(node, depth) { if (depth == 0) { return node; } var fragment = node.content.replaceChild( node.childCount - 1, closeRight(node.lastChild, depth - 1) ); var fill = node .contentMatchAt(node.childCount) .fillBefore( prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment .empty, true ); return node.copy(fragment.append(fill)); } function closeRange(fragment, side, from, to, depth, openEnd) { var node = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node.content; if (depth < to - 1) { inner = closeRange( inner, side, from, to, depth + 1, openEnd ); } if (depth >= from) { inner = side < 0 ? node .contentMatchAt(0) .fillBefore( inner, fragment.childCount > 1 || openEnd <= depth ) .append(inner) : inner.append( node .contentMatchAt(node.childCount) .fillBefore( prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Fragment.empty, true ) ); } return fragment.replaceChild( side < 0 ? 0 : fragment.childCount - 1, node.copy(inner) ); } function closeSlice(slice, openStart, openEnd) { if (openStart < slice.openStart) { slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice( closeRange( slice.content, -1, openStart, slice.openStart, 0, slice.openEnd ), openStart, slice.openEnd ); } if (openEnd < slice.openEnd) { slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice( closeRange( slice.content, 1, openEnd, slice.openEnd, 0, 0 ), slice.openStart, openEnd ); } return slice; } // Trick from jQuery -- some elements must be wrapped in other // elements for innerHTML to work. I.e. if you do `div.innerHTML = // "<td>..</td>"` the table cells are ignored. var wrapMap = { thead: ["table"], tbody: ["table"], tfoot: ["table"], caption: ["table"], colgroup: ["table"], col: ["table", "colgroup"], tr: ["table", "tbody"], td: ["table", "tbody", "tr"], th: ["table", "tbody", "tr"], }; var _detachedDoc = null; function detachedDoc() { return ( _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title")) ); } function readHTML(html) { var metas = /^(\s*<meta [^>]*>)*/.exec(html); if (metas) { html = html.slice(metas[0].length); } var elt = detachedDoc().createElement("div"); var firstTag = /<([a-z][^>\s]+)/i.exec(html), wrap; if ((wrap = firstTag && wrapMap[firstTag[1].toLowerCase()])) { html = wrap .map(function (n) { return "<" + n + ">"; }) .join("") + html + wrap .map(function (n) { return "</" + n + ">"; }) .reverse() .join(""); } elt.innerHTML = html; if (wrap) { for (var i = 0; i < wrap.length; i++) { elt = elt.querySelector(wrap[i]) || elt; } } return elt; } // Webkit browsers do some hard-to-predict replacement of regular // spaces with non-breaking spaces when putting content on the // clipboard. This tries to convert such non-breaking spaces (which // will be wrapped in a plain span on Chrome, a span with class // Apple-converted-space on Safari) back to regular spaces. function restoreReplacedSpaces(dom) { var nodes = dom.querySelectorAll( result.chrome ? "span:not([class]):not([style])" : "span.Apple-converted-space" ); for (var i = 0; i < nodes.length; i++) { var node = nodes[i]; if ( node.childNodes.length == 1 && node.textContent == "\u00a0" && node.parentNode ) { node.parentNode.replaceChild( dom.ownerDocument.createTextNode(" "), node ); } } } function addContext(slice, context) { if (!slice.size) { return slice; } var schema = slice.content.firstChild.type.schema, array; try { array = JSON.parse(context); } catch (e) { return slice; } var content = slice.content; var openStart = slice.openStart; var openEnd = slice.openEnd; for (var i = array.length - 2; i >= 0; i -= 2) { var type = schema.nodes[array[i]]; if (!type || type.hasRequiredAttrs()) { break; } content = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from( type.create(array[i + 1], content) ); openStart++; openEnd++; } return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice( content, openStart, openEnd ); } var observeOptions = { childList: true, characterData: true, characterDataOldValue: true, attributes: true, attributeOldValue: true, subtree: true, }; // IE11 has very broken mutation observers, so we also listen to DOMCharacterDataModified var useCharData = result.ie && result.ie_version <= 11; var SelectionState = function SelectionState() { this.anchorNode = this.anchorOffset = this.focusNode = this.focusOffset = null; }; SelectionState.prototype.set = function set(sel) { this.anchorNode = sel.anchorNode; this.anchorOffset = sel.anchorOffset; this.focusNode = sel.focusNode; this.focusOffset = sel.focusOffset; }; SelectionState.prototype.eq = function eq(sel) { return ( sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset && sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset ); }; var DOMObserver = function DOMObserver(view, handleDOMChange) { var this$1 = this; this.view = view; this.handleDOMChange = handleDOMChange; this.queue = []; this.flushingSoon = -1; this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) { for (var i = 0; i < mutations.length; i++) { this$1.queue.push(mutations[i]); } // IE11 will sometimes (on backspacing out a single character // text node after a BR node) call the observer callback // before actually updating the DOM, which will cause // ProseMirror to miss the change (see #930) if ( result.ie && result.ie_version <= 11 && mutations.some(function (m) { return ( (m.type == "childList" && m.removedNodes.length) || (m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length) ); }) ) { this$1.flushSoon(); } else { this$1.flush(); } }); this.currentSelection = new SelectionState(); if (useCharData) { this.onCharData = function (e) { this$1.queue.push({ target: e.target, type: "characterData", oldValue: e.prevValue, }); this$1.flushSoon(); }; } this.onSelectionChange = this.onSelectionChange.bind(this); this.suppressingSelectionUpdates = false; }; DOMObserver.prototype.flushSoon = function flushSoon() { var this$1 = this; if (this.flushingSoon < 0) { this.flushingSoon = window.setTimeout(function () { this$1.flushingSoon = -1; this$1.flush(); }, 20); } }; DOMObserver.prototype.forceFlush = function forceFlush() { if (this.flushingSoon > -1) { window.clearTimeout(this.flushingSoon); this.flushingSoon = -1; this.flush(); } }; DOMObserver.prototype.start = function start() { if (this.observer) { this.observer.observe(this.view.dom, observeOptions); } if (useCharData) { this.view.dom.addEventListener( "DOMCharacterDataModified", this.onCharData ); } this.connectSelection(); }; DOMObserver.prototype.stop = function stop() { var this$1 = this; if (this.observer) { var take = this.observer.takeRecords(); if (take.length) { for (var i = 0; i < take.length; i++) { this.queue.push(take[i]); } window.setTimeout(function () { return this$1.flush(); }, 20); } this.observer.disconnect(); } if (useCharData) { this.view.dom.removeEventListener( "DOMCharacterDataModified", this.onCharData ); } this.disconnectSelection(); }; DOMObserver.prototype.connectSelection = function connectSelection() { this.view.dom.ownerDocument.addEventListener( "selectionchange", this.onSelectionChange ); }; DOMObserver.prototype.disconnectSelection = function disconnectSelection() { this.view.dom.ownerDocument.removeEventListener( "selectionchange", this.onSelectionChange ); }; DOMObserver.prototype.suppressSelectionUpdates = function suppressSelectionUpdates() { var this$1 = this; this.suppressingSelectionUpdates = true; setTimeout(function () { return (this$1.suppressingSelectionUpdates = false); }, 50); }; DOMObserver.prototype.onSelectionChange = function onSelectionChange() { if (!hasFocusAndSelection(this.view)) { return; } if (this.suppressingSelectionUpdates) { return selectionToDOM(this.view); } // Deletions on IE11 fire their events in the wrong order, giving // us a selection change event before the DOM changes are // reported. if ( result.ie && result.ie_version <= 11 && !this.view.state.selection.empty ) { var sel = this.view.root.getSelection(); // Selection.isCollapsed isn't reliable on IE if ( sel.focusNode && isEquivalentPosition( sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset ) ) { return this.flushSoon(); } } this.flush(); }; DOMObserver.prototype.setCurSelection = function setCurSelection() { this.currentSelection.set(this.view.root.getSelection()); }; DOMObserver.prototype.ignoreSelectionChange = function ignoreSelectionChange(sel) { if (sel.rangeCount == 0) { return true; } var container = sel.getRangeAt(0).commonAncestorContainer; var desc = this.view.docView.nearestDesc(container); if ( desc && desc.ignoreMutation({ type: "selection", target: container.nodeType == 3 ? container.parentNode : container, }) ) { this.setCurSelection(); return true; } }; DOMObserver.prototype.flush = function flush() { if (!this.view.docView || this.flushingSoon > -1) { return; } var mutations = this.observer ? this.observer.takeRecords() : []; if (this.queue.length) { mutations = this.queue.concat(mutations); this.queue.length = 0; } var sel = this.view.root.getSelection(); var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel); var from = -1, to = -1, typeOver = false, added = []; if (this.view.editable) { for (var i = 0; i < mutations.length; i++) { var result$1 = this.registerMutation( mutations[i], added ); if (result$1) { from = from < 0 ? result$1.from : Math.min(result$1.from, from); to = to < 0 ? result$1.to : Math.max(result$1.to, to); if (result$1.typeOver) { typeOver = true; } } } } if (result.gecko && added.length > 1) { var brs = added.filter(function (n) { return n.nodeName == "BR"; }); if (brs.length == 2) { var a = brs[0]; var b = brs[1]; if ( a.parentNode && a.parentNode.parentNode == b.parentNode ) { b.remove(); } else { a.remove(); } } } if (from > -1 || newSel) { if (from > -1) { this.view.docView.markDirty(from, to); checkCSS(this.view); } this.handleDOMChange(from, to, typeOver, added); if (this.view.docView.dirty) { this.view.updateState(this.view.state); } else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); } this.currentSelection.set(sel); } }; DOMObserver.prototype.registerMutation = function registerMutation( mut, added ) { // Ignore mutations inside nodes that were already noted as inserted if (added.indexOf(mut.target) > -1) { return null; } var desc = this.view.docView.nearestDesc(mut.target); if ( mut.type == "attributes" && (desc == this.view.docView || mut.attributeName == "contenteditable" || // Firefox sometimes fires spurious events for null/empty styles (mut.attributeName == "style" && !mut.oldValue && !mut.target.getAttribute("style"))) ) { return null; } if (!desc || desc.ignoreMutation(mut)) { return null; } if (mut.type == "childList") { for (var i = 0; i < mut.addedNodes.length; i++) { added.push(mut.addedNodes[i]); } if ( desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target) ) { return { from: desc.posBefore, to: desc.posAfter }; } var prev = mut.previousSibling, next = mut.nextSibling; if ( result.ie && result.ie_version <= 11 && mut.addedNodes.length ) { // IE11 gives us incorrect next/prev siblings for some // insertions, so if there are added nodes, recompute those for (var i$1 = 0; i$1 < mut.addedNodes.length; i$1++) { var ref = mut.addedNodes[i$1]; var previousSibling = ref.previousSibling; var nextSibling = ref.nextSibling; if ( !previousSibling || Array.prototype.indexOf.call( mut.addedNodes, previousSibling ) < 0 ) { prev = previousSibling; } if ( !nextSibling || Array.prototype.indexOf.call( mut.addedNodes, nextSibling ) < 0 ) { next = nextSibling; } } } var fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0; var from = desc.localPosFromDOM(mut.target, fromOffset, -1); var toOffset = next && next.parentNode == mut.target ? domIndex(next) : mut.target.childNodes.length; var to = desc.localPosFromDOM(mut.target, toOffset, 1); return { from: from, to: to }; } else if (mut.type == "attributes") { return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border, }; } else { // "characterData" return { from: desc.posAtStart, to: desc.posAtEnd, // An event was generated for a text change that didn't change // any text. Mark the dom change to fall back to assuming the // selection was typed over with an identical value if it can't // find another change. typeOver: mut.target.nodeValue == mut.oldValue, }; } }; var cssChecked = false; function checkCSS(view) { if (cssChecked) { return; } cssChecked = true; if (getComputedStyle(view.dom).whiteSpace == "normal") { console["warn"]( "ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package." ); } } // A collection of DOM events that occur within the editor, and callback functions // to invoke when the event fires. var handlers = {}, editHandlers = {}; function initInput(view) { view.shiftKey = false; view.mouseDown = null; view.lastKeyCode = null; view.lastKeyCodeTime = 0; view.lastClick = { time: 0, x: 0, y: 0, type: "" }; view.lastSelectionOrigin = null; view.lastSelectionTime = 0; view.lastIOSEnter = 0; view.lastIOSEnterFallbackTimeout = null; view.lastAndroidDelete = 0; view.composing = false; view.composingTimeout = null; view.compositionNodes = []; view.compositionEndedAt = -2e8; view.domObserver = new DOMObserver(view, function ( from, to, typeOver, added ) { return readDOMChange(view, from, to, typeOver, added); }); view.domObserver.start(); // Used by hacks like the beforeinput handler to check whether anything happened in the DOM view.domChangeCount = 0; view.eventHandlers = Object.create(null); var loop = function (event) { var handler = handlers[event]; view.dom.addEventListener( event, (view.eventHandlers[event] = function (event) { if ( eventBelongsToView(view, event) && !runCustomHandler(view, event) && (view.editable || !(event.type in editHandlers)) ) { handler(view, event); } }) ); }; for (var event in handlers) loop(event); // On Safari, for reasons beyond my understanding, adding an input // event handler makes an issue where the composition vanishes when // you press enter go away. if (result.safari) { view.dom.addEventListener("input", function () { return null; }); } ensureListeners(view); } function setSelectionOrigin(view, origin) { view.lastSelectionOrigin = origin; view.lastSelectionTime = Date.now(); } function destroyInput(view) { view.domObserver.stop(); for (var type in view.eventHandlers) { view.dom.removeEventListener( type, view.eventHandlers[type] ); } clearTimeout(view.composingTimeout); clearTimeout(view.lastIOSEnterFallbackTimeout); } function ensureListeners(view) { view.someProp("handleDOMEvents", function (currentHandlers) { for (var type in currentHandlers) { if (!view.eventHandlers[type]) { view.dom.addEventListener( type, (view.eventHandlers[type] = function (event) { return runCustomHandler(view, event); }) ); } } }); } function runCustomHandler(view, event) { return view.someProp("handleDOMEvents", function (handlers) { var handler = handlers[event.type]; return handler ? handler(view, event) || event.defaultPrevented : false; }); } function eventBelongsToView(view, event) { if (!event.bubbles) { return true; } if (event.defaultPrevented) { return false; } for ( var node = event.target; node != view.dom; node = node.parentNode ) { if ( !node || node.nodeType == 11 || (node.pmViewDesc && node.pmViewDesc.stopEvent(event)) ) { return false; } } return true; } function dispatchEvent(view, event) { if ( !runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers)) ) { handlers[event.type](view, event); } } editHandlers.keydown = function (view, event) { view.shiftKey = event.keyCode == 16 || event.shiftKey; if (inOrNearComposition(view, event)) { return; } if (event.keyCode != 229) { view.domObserver.forceFlush(); } view.lastKeyCode = event.keyCode; view.lastKeyCodeTime = Date.now(); // On iOS, if we preventDefault enter key presses, the virtual // keyboard gets confused. So the hack here is to set a flag that // makes the DOM change code recognize that what just happens should // be replaced by whatever the Enter key handlers do. if ( result.ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey ) { var now = Date.now(); view.lastIOSEnter = now; view.lastIOSEnterFallbackTimeout = setTimeout(function () { if (view.lastIOSEnter == now) { view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); }); view.lastIOSEnter = 0; } }, 200); } else if ( view.someProp("handleKeyDown", function (f) { return f(view, event); }) || captureKeyDown(view, event) ) { event.preventDefault(); } else { setSelectionOrigin(view, "key"); } }; editHandlers.keyup = function (view, e) { if (e.keyCode == 16) { view.shiftKey = false; } }; editHandlers.keypress = function (view, event) { if ( inOrNearComposition(view, event) || !event.charCode || (event.ctrlKey && !event.altKey) || (result.mac && event.metaKey) ) { return; } if ( view.someProp("handleKeyPress", function (f) { return f(view, event); }) ) { event.preventDefault(); return; } var sel = view.state.selection; if ( !( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) || !sel.$from.sameParent(sel.$to) ) { var text = String.fromCharCode(event.charCode); if ( !view.someProp("handleTextInput", function (f) { return f(view, sel.$from.pos, sel.$to.pos, text); }) ) { view.dispatch( view.state.tr.insertText(text).scrollIntoView() ); } event.preventDefault(); } }; function eventCoords(event) { return { left: event.clientX, top: event.clientY }; } function isNear(event, click) { var dx = click.x - event.clientX, dy = click.y - event.clientY; return dx * dx + dy * dy < 100; } function runHandlerOnContext(view, propName, pos, inside, event) { if (inside == -1) { return false; } var $pos = view.state.doc.resolve(inside); var loop = function (i) { if ( view.someProp(propName, function (f) { return i > $pos.depth ? f( view, pos, $pos.nodeAfter, $pos.before(i), event, true ) : f( view, pos, $pos.node(i), $pos.before(i), event, false ); }) ) { return { v: true }; } }; for (var i = $pos.depth + 1; i > 0; i--) { var returned = loop(i); if (returned) return returned.v; } return false; } function updateSelection(view, selection, origin) { if (!view.focused) { view.focus(); } var tr = view.state.tr.setSelection(selection); if (origin == "pointer") { tr.setMeta("pointer", true); } view.dispatch(tr); } function selectClickedLeaf(view, inside) { if (inside == -1) { return false; } var $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter; if ( node && node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( node ) ) { updateSelection( view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection( $pos ), "pointer" ); return true; } return false; } function selectClickedNode(view, inside) { if (inside == -1) { return false; } var sel = view.state.selection, selectedNode, selectAt; if ( sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ) { selectedNode = sel.node; } var $pos = view.state.doc.resolve(inside); for (var i = $pos.depth + 1; i > 0; i--) { var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i); if ( prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( node ) ) { if ( selectedNode && sel.$from.depth > 0 && i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos ) { selectAt = $pos.before(sel.$from.depth); } else { selectAt = $pos.before(i); } break; } } if (selectAt != null) { updateSelection( view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create( view.state.doc, selectAt ), "pointer" ); return true; } else { return false; } } function handleSingleClick(view, pos, inside, event, selectNode) { return ( runHandlerOnContext( view, "handleClickOn", pos, inside, event ) || view.someProp("handleClick", function (f) { return f(view, pos, event); }) || (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside)) ); } function handleDoubleClick(view, pos, inside, event) { return ( runHandlerOnContext( view, "handleDoubleClickOn", pos, inside, event ) || view.someProp("handleDoubleClick", function (f) { return f(view, pos, event); }) ); } function handleTripleClick(view, pos, inside, event) { return ( runHandlerOnContext( view, "handleTripleClickOn", pos, inside, event ) || view.someProp("handleTripleClick", function (f) { return f(view, pos, event); }) || defaultTripleClick(view, inside, event) ); } function defaultTripleClick(view, inside, event) { if (event.button != 0) { return false; } var doc = view.state.doc; if (inside == -1) { if (doc.inlineContent) { updateSelection( view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.create( doc, 0, doc.content.size ), "pointer" ); return true; } return false; } var $pos = doc.resolve(inside); for (var i = $pos.depth + 1; i > 0; i--) { var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i); var nodePos = $pos.before(i); if (node.inlineContent) { updateSelection( view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.create( doc, nodePos + 1, nodePos + 1 + node.content.size ), "pointer" ); } else if ( prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( node ) ) { updateSelection( view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create( doc, nodePos ), "pointer" ); } else { continue; } return true; } } function forceDOMFlush(view) { return endComposition(view); } var selectNodeModifier = result.mac ? "metaKey" : "ctrlKey"; handlers.mousedown = function (view, event) { view.shiftKey = event.shiftKey; var flushed = forceDOMFlush(view); var now = Date.now(), type = "singleClick"; if ( now - view.lastClick.time < 500 && isNear(event, view.lastClick) && !event[selectNodeModifier] ) { if (view.lastClick.type == "singleClick") { type = "doubleClick"; } else if (view.lastClick.type == "doubleClick") { type = "tripleClick"; } } view.lastClick = { time: now, x: event.clientX, y: event.clientY, type: type, }; var pos = view.posAtCoords(eventCoords(event)); if (!pos) { return; } if (type == "singleClick") { if (view.mouseDown) { view.mouseDown.done(); } view.mouseDown = new MouseDown(view, pos, event, flushed); } else if ( (type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event) ) { event.preventDefault(); } else { setSelectionOrigin(view, "pointer"); } }; var MouseDown = function MouseDown(view, pos, event, flushed) { var this$1 = this; this.view = view; this.startDoc = view.state.doc; this.pos = pos; this.event = event; this.flushed = flushed; this.selectNode = event[selectNodeModifier]; this.allowDefault = event.shiftKey; this.delayedSelectionSync = false; var targetNode, targetPos; if (pos.inside > -1) { targetNode = view.state.doc.nodeAt(pos.inside); targetPos = pos.inside; } else { var $pos = view.state.doc.resolve(pos.pos); targetNode = $pos.parent; targetPos = $pos.depth ? $pos.before() : 0; } this.mightDrag = null; var target = flushed ? null : event.target; var targetDesc = target ? view.docView.nearestDesc(target, true) : null; this.target = targetDesc ? targetDesc.dom : null; var ref = view.state; var selection = ref.selection; if ( (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false) || (selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && selection.from <= targetPos && selection.to > targetPos) ) { this.mightDrag = { node: targetNode, pos: targetPos, addAttr: this.target && !this.target.draggable, setUneditable: this.target && result.gecko && !this.target.hasAttribute("contentEditable"), }; } if ( this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) ) { this.view.domObserver.stop(); if (this.mightDrag.addAttr) { this.target.draggable = true; } if (this.mightDrag.setUneditable) { setTimeout(function () { if (this$1.view.mouseDown == this$1) { this$1.target.setAttribute( "contentEditable", "false" ); } }, 20); } this.view.domObserver.start(); } view.root.addEventListener( "mouseup", (this.up = this.up.bind(this)) ); view.root.addEventListener( "mousemove", (this.move = this.move.bind(this)) ); setSelectionOrigin(view, "pointer"); }; MouseDown.prototype.done = function done() { var this$1 = this; this.view.root.removeEventListener("mouseup", this.up); this.view.root.removeEventListener("mousemove", this.move); if (this.mightDrag && this.target) { this.view.domObserver.stop(); if (this.mightDrag.addAttr) { this.target.removeAttribute("draggable"); } if (this.mightDrag.setUneditable) { this.target.removeAttribute("contentEditable"); } this.view.domObserver.start(); } if (this.delayedSelectionSync) { setTimeout(function () { return selectionToDOM(this$1.view); }); } this.view.mouseDown = null; }; MouseDown.prototype.up = function up(event) { this.done(); if ( !this.view.dom.contains( event.target.nodeType == 3 ? event.target.parentNode : event.target ) ) { return; } var pos = this.pos; if (this.view.state.doc != this.startDoc) { pos = this.view.posAtCoords(eventCoords(event)); } if (this.allowDefault || !pos) { setSelectionOrigin(this.view, "pointer"); } else if ( handleSingleClick( this.view, pos.pos, pos.inside, event, this.selectNode ) ) { event.preventDefault(); } else if ( event.button == 0 && (this.flushed || // Safari ignores clicks on draggable elements (result.safari && this.mightDrag && !this.mightDrag.node.isAtom) || // Chrome will sometimes treat a node selection as a // cursor, but still report that the node is selected // when asked through getSelection. You'll then get a // situation where clicking at the point where that // (hidden) cursor is doesn't change the selection, and // thus doesn't get a reaction from ProseMirror. This // works around that. (result.chrome && !( this.view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection ) && Math.min( Math.abs( pos.pos - this.view.state.selection.from ), Math.abs(pos.pos - this.view.state.selection.to) ) <= 2)) ) { updateSelection( this.view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.near( this.view.state.doc.resolve(pos.pos) ), "pointer" ); event.preventDefault(); } else { setSelectionOrigin(this.view, "pointer"); } }; MouseDown.prototype.move = function move(event) { if ( !this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4) ) { this.allowDefault = true; } setSelectionOrigin(this.view, "pointer"); if (event.buttons == 0) { this.done(); } }; handlers.touchdown = function (view) { forceDOMFlush(view); setSelectionOrigin(view, "pointer"); }; handlers.contextmenu = function (view) { return forceDOMFlush(view); }; function inOrNearComposition(view, event) { if (view.composing) { return true; } // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/. // On Japanese input method editors (IMEs), the Enter key is used to confirm character // selection. On Safari, when Enter is pressed, compositionend and keydown events are // emitted. The keydown event triggers newline insertion, which we don't want. // This method returns true if the keydown event should be ignored. // We only ignore it once, as pressing Enter a second time *should* insert a newline. // Furthermore, the keydown event timestamp must be close to the compositionEndedAt timestamp. // This guards against the case where compositionend is triggered without the keyboard // (e.g. character confirmation may be done with the mouse), and keydown is triggered // afterwards- we wouldn't want to ignore the keydown event in this case. if ( result.safari && Math.abs(event.timeStamp - view.compositionEndedAt) < 500 ) { view.compositionEndedAt = -2e8; return true; } return false; } // Drop active composition after 5 seconds of inactivity on Android var timeoutComposition = result.android ? 5000 : -1; editHandlers.compositionstart = editHandlers.compositionupdate = function (view) { if (!view.composing) { view.domObserver.flush(); var state = view.state; var $pos = state.selection.$from; if ( state.selection.empty && (state.storedMarks || (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function (m) { return m.type.spec.inclusive === false; }))) ) { // Need to wrap the cursor in mark nodes different from the ones in the DOM context view.markCursor = view.state.storedMarks || $pos.marks(); endComposition(view, true); view.markCursor = null; } else { endComposition(view); // In firefox, if the cursor is after but outside a marked node, // the inserted text won't inherit the marks. So this moves it // inside if necessary. if ( result.gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length ) { var sel = view.root.getSelection(); for ( var node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0; ) { var before = offset < 0 ? node.lastChild : node.childNodes[offset - 1]; if (!before) { break; } if (before.nodeType == 3) { sel.collapse( before, before.nodeValue.length ); break; } else { node = before; offset = -1; } } } } view.composing = true; } scheduleComposeEnd(view, timeoutComposition); }; editHandlers.compositionend = function (view, event) { if (view.composing) { view.composing = false; view.compositionEndedAt = event.timeStamp; scheduleComposeEnd(view, 20); } }; function scheduleComposeEnd(view, delay) { clearTimeout(view.composingTimeout); if (delay > -1) { view.composingTimeout = setTimeout(function () { return endComposition(view); }, delay); } } function clearComposition(view) { if (view.composing) { view.composing = false; view.compositionEndedAt = timestampFromCustomEvent(); } while (view.compositionNodes.length > 0) { view.compositionNodes.pop().markParentsDirty(); } } function timestampFromCustomEvent() { var event = document.createEvent("Event"); event.initEvent("event", true, true); return event.timeStamp; } function endComposition(view, forceUpdate) { view.domObserver.forceFlush(); clearComposition(view); if (forceUpdate || view.docView.dirty) { var sel = selectionFromDOM(view); if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); } else { view.updateState(view.state); } return true; } return false; } function captureCopy(view, dom) { // The extra wrapper is somehow necessary on IE/Edge to prevent the // content from being mangled when it is put onto the clipboard if (!view.dom.parentNode) { return; } var wrap = view.dom.parentNode.appendChild( document.createElement("div") ); wrap.appendChild(dom); wrap.style.cssText = "position: fixed; left: -10000px; top: 10px"; var sel = getSelection(), range = document.createRange(); range.selectNodeContents(dom); // Done because IE will fire a selectionchange moving the selection // to its start when removeAllRanges is called and the editor still // has focus (which will mess up the editor's selection state). view.dom.blur(); sel.removeAllRanges(); sel.addRange(range); setTimeout(function () { if (wrap.parentNode) { wrap.parentNode.removeChild(wrap); } view.focus(); }, 50); } // This is very crude, but unfortunately both these browsers _pretend_ // that they have a clipboard API—all the objects and methods are // there, they just don't work, and they are hard to test. var brokenClipboardAPI = (result.ie && result.ie_version < 15) || (result.ios && result.webkit_version < 604); handlers.copy = editHandlers.cut = function (view, e) { var sel = view.state.selection, cut = e.type == "cut"; if (sel.empty) { return; } // IE and Edge's clipboard interface is completely broken var data = brokenClipboardAPI ? null : e.clipboardData; var slice = sel.content(); var ref = serializeForClipboard(view, slice); var dom = ref.dom; var text = ref.text; if (data) { e.preventDefault(); data.clearData(); data.setData("text/html", dom.innerHTML); data.setData("text/plain", text); } else { captureCopy(view, dom); } if (cut) { view.dispatch( view.state.tr .deleteSelection() .scrollIntoView() .setMeta("uiEvent", "cut") ); } }; function sliceSingleNode(slice) { return slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null; } function capturePaste(view, e) { if (!view.dom.parentNode) { return; } var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code; var target = view.dom.parentNode.appendChild( document.createElement(plainText ? "textarea" : "div") ); if (!plainText) { target.contentEditable = "true"; } target.style.cssText = "position: fixed; left: -10000px; top: 10px"; target.focus(); setTimeout(function () { view.focus(); if (target.parentNode) { target.parentNode.removeChild(target); } if (plainText) { doPaste(view, target.value, null, e); } else { doPaste(view, target.textContent, target.innerHTML, e); } }, 50); } function doPaste(view, text, html, e) { var slice = parseFromClipboard( view, text, html, view.shiftKey, view.state.selection.$from ); if ( view.someProp("handlePaste", function (f) { return f( view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Slice.empty ); }) ) { return true; } if (!slice) { return false; } var singleNode = sliceSingleNode(slice); var tr = singleNode ? view.state.tr.replaceSelectionWith( singleNode, view.shiftKey ) : view.state.tr.replaceSelection(slice); view.dispatch( tr .scrollIntoView() .setMeta("paste", true) .setMeta("uiEvent", "paste") ); return true; } editHandlers.paste = function (view, e) { var data = brokenClipboardAPI ? null : e.clipboardData; if ( data && doPaste( view, data.getData("text/plain"), data.getData("text/html"), e ) ) { e.preventDefault(); } else { capturePaste(view, e); } }; var Dragging = function Dragging(slice, move) { this.slice = slice; this.move = move; }; var dragCopyModifier = result.mac ? "altKey" : "ctrlKey"; handlers.dragstart = function (view, e) { var mouseDown = view.mouseDown; if (mouseDown) { mouseDown.done(); } if (!e.dataTransfer) { return; } var sel = view.state.selection; var pos = sel.empty ? null : view.posAtCoords(eventCoords(e)); if ( pos && pos.pos >= sel.from && pos.pos <= (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ? sel.to - 1 : sel.to) ); else if (mouseDown && mouseDown.mightDrag) { view.dispatch( view.state.tr.setSelection( prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create( view.state.doc, mouseDown.mightDrag.pos ) ) ); } else if (e.target && e.target.nodeType == 1) { var desc = view.docView.nearestDesc(e.target, true); if ( desc && desc.node.type.spec.draggable && desc != view.docView ) { view.dispatch( view.state.tr.setSelection( prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create( view.state.doc, desc.posBefore ) ) ); } } var slice = view.state.selection.content(); var ref = serializeForClipboard(view, slice); var dom = ref.dom; var text = ref.text; e.dataTransfer.clearData(); e.dataTransfer.setData( brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML ); // See https://github.com/ProseMirror/prosemirror/issues/1156 e.dataTransfer.effectAllowed = "copyMove"; if (!brokenClipboardAPI) { e.dataTransfer.setData("text/plain", text); } view.dragging = new Dragging(slice, !e[dragCopyModifier]); }; handlers.dragend = function (view) { var dragging = view.dragging; window.setTimeout(function () { if (view.dragging == dragging) { view.dragging = null; } }, 50); }; editHandlers.dragover = editHandlers.dragenter = function (_, e) { return e.preventDefault(); }; editHandlers.drop = function (view, e) { var dragging = view.dragging; view.dragging = null; if (!e.dataTransfer) { return; } var eventPos = view.posAtCoords(eventCoords(e)); if (!eventPos) { return; } var $mouse = view.state.doc.resolve(eventPos.pos); if (!$mouse) { return; } var slice = dragging && dragging.slice; if (slice) { view.someProp("transformPasted", function (f) { slice = f(slice); }); } else { slice = parseFromClipboard( view, e.dataTransfer.getData( brokenClipboardAPI ? "Text" : "text/plain" ), brokenClipboardAPI ? null : e.dataTransfer.getData("text/html"), false, $mouse ); } var move = dragging && !e[dragCopyModifier]; if ( view.someProp("handleDrop", function (f) { return f( view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ .Slice.empty, move ); }) ) { e.preventDefault(); return; } if (!slice) { return; } e.preventDefault(); var insertPos = slice ? (0, prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ /* .dropPoint */.nj)( view.state.doc, $mouse.pos, slice ) : $mouse.pos; if (insertPos == null) { insertPos = $mouse.pos; } var tr = view.state.tr; if (move) { tr.deleteSelection(); } var pos = tr.mapping.map(insertPos); var isNode = slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1; var beforeInsert = tr.doc; if (isNode) { tr.replaceRangeWith(pos, pos, slice.content.firstChild); } else { tr.replaceRange(pos, pos, slice); } if (tr.doc.eq(beforeInsert)) { return; } var $pos = tr.doc.resolve(pos); if ( isNode && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable( slice.content.firstChild ) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild) ) { tr.setSelection( new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection( $pos ) ); } else { var end = tr.mapping.map(insertPos); tr.mapping.maps[tr.mapping.maps.length - 1].forEach( function (_from, _to, _newFrom, newTo) { return (end = newTo); } ); tr.setSelection( selectionBetween(view, $pos, tr.doc.resolve(end)) ); } view.focus(); view.dispatch(tr.setMeta("uiEvent", "drop")); }; handlers.focus = function (view) { if (!view.focused) { view.domObserver.stop(); view.dom.classList.add("ProseMirror-focused"); view.domObserver.start(); view.focused = true; setTimeout(function () { if ( view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq( view.root.getSelection() ) ) { selectionToDOM(view); } }, 20); } }; handlers.blur = function (view, e) { if (view.focused) { view.domObserver.stop(); view.dom.classList.remove("ProseMirror-focused"); view.domObserver.start(); if (e.relatedTarget && view.dom.contains(e.relatedTarget)) { view.domObserver.currentSelection.set({}); } view.focused = false; } }; handlers.beforeinput = function (view, event) { // We should probably do more with beforeinput events, but support // is so spotty that I'm still waiting to see where they are going. // Very specific hack to deal with backspace sometimes failing on // Chrome Android when after an uneditable node. if ( result.chrome && result.android && event.inputType == "deleteContentBackward" ) { var domChangeCount = view.domChangeCount; setTimeout(function () { if (view.domChangeCount != domChangeCount) { return; } // Event already had some effect // This bug tends to close the virtual keyboard, so we refocus view.dom.blur(); view.focus(); if ( view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(8, "Backspace")); }) ) { return; } var ref = view.state.selection; var $cursor = ref.$cursor; // Crude approximation of backspace behavior when no command handled it if ($cursor && $cursor.pos > 0) { view.dispatch( view.state.tr .delete($cursor.pos - 1, $cursor.pos) .scrollIntoView() ); } }, 50); } }; // Make sure all handlers get registered for (var prop in editHandlers) { handlers[prop] = editHandlers[prop]; } function compareObjs(a, b) { if (a == b) { return true; } for (var p in a) { if (a[p] !== b[p]) { return false; } } for (var p$1 in b) { if (!(p$1 in a)) { return false; } } return true; } var WidgetType = function WidgetType(toDOM, spec) { this.spec = spec || noSpec; this.side = this.spec.side || 0; this.toDOM = toDOM; }; WidgetType.prototype.map = function map( mapping, span, offset, oldOffset ) { var ref = mapping.mapResult( span.from + oldOffset, this.side < 0 ? -1 : 1 ); var pos = ref.pos; var deleted = ref.deleted; return deleted ? null : new Decoration(pos - offset, pos - offset, this); }; WidgetType.prototype.valid = function valid() { return true; }; WidgetType.prototype.eq = function eq(other) { return ( this == other || (other instanceof WidgetType && ((this.spec.key && this.spec.key == other.spec.key) || (this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))) ); }; var InlineType = function InlineType(attrs, spec) { this.spec = spec || noSpec; this.attrs = attrs; }; InlineType.prototype.map = function map( mapping, span, offset, oldOffset ) { var from = mapping.map( span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1 ) - offset; var to = mapping.map( span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1 ) - offset; return from >= to ? null : new Decoration(from, to, this); }; InlineType.prototype.valid = function valid(_, span) { return span.from < span.to; }; InlineType.prototype.eq = function eq(other) { return ( this == other || (other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec)) ); }; InlineType.is = function is(span) { return span.type instanceof InlineType; }; var NodeType = function NodeType(attrs, spec) { this.spec = spec || noSpec; this.attrs = attrs; }; NodeType.prototype.map = function map( mapping, span, offset, oldOffset ) { var from = mapping.mapResult(span.from + oldOffset, 1); if (from.deleted) { return null; } var to = mapping.mapResult(span.to + oldOffset, -1); if (to.deleted || to.pos <= from.pos) { return null; } return new Decoration(from.pos - offset, to.pos - offset, this); }; NodeType.prototype.valid = function valid(node, span) { var ref = node.content.findIndex(span.from); var index = ref.index; var offset = ref.offset; var child; return ( offset == span.from && !(child = node.child(index)).isText && offset + child.nodeSize == span.to ); }; NodeType.prototype.eq = function eq(other) { return ( this == other || (other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec)) ); }; // ::- Decoration objects can be provided to the view through the // [`decorations` prop](#view.EditorProps.decorations). They come in // several variants—see the static members of this class for details. var Decoration = function Decoration(from, to, type) { // :: number // The start position of the decoration. this.from = from; // :: number // The end position. Will be the same as `from` for [widget // decorations](#view.Decoration^widget). this.to = to; this.type = type; }; var prototypeAccessors$1 = { spec: { configurable: true }, inline: { configurable: true }, }; Decoration.prototype.copy = function copy(from, to) { return new Decoration(from, to, this.type); }; Decoration.prototype.eq = function eq(other, offset) { if (offset === void 0) offset = 0; return ( this.type.eq(other.type) && this.from + offset == other.from && this.to + offset == other.to ); }; Decoration.prototype.map = function map( mapping, offset, oldOffset ) { return this.type.map(mapping, this, offset, oldOffset); }; // :: (number, union<(view: EditorView, getPos: () → number) → dom.Node, dom.Node>, ?Object) → Decoration // Creates a widget decoration, which is a DOM node that's shown in // the document at the given position. It is recommended that you // delay rendering the widget by passing a function that will be // called when the widget is actually drawn in a view, but you can // also directly pass a DOM node. `getPos` can be used to find the // widget's current document position. // // spec::- These options are supported: // // side:: ?number // Controls which side of the document position this widget is // associated with. When negative, it is drawn before a cursor // at its position, and content inserted at that position ends // up after the widget. When zero (the default) or positive, the // widget is drawn after the cursor and content inserted there // ends up before the widget. // // When there are multiple widgets at a given position, their // `side` values determine the order in which they appear. Those // with lower values appear first. The ordering of widgets with // the same `side` value is unspecified. // // When `marks` is null, `side` also determines the marks that // the widget is wrapped in—those of the node before when // negative, those of the node after when positive. // // marks:: ?[Mark] // The precise set of marks to draw around the widget. // // stopEvent:: ?(event: dom.Event) → bool // Can be used to control which DOM events, when they bubble out // of this widget, the editor view should ignore. // // ignoreSelection:: ?bool // When set (defaults to false), selection changes inside the // widget are ignored, and don't cause ProseMirror to try and // re-sync the selection with its selection state. // // key:: ?string // When comparing decorations of this type (in order to decide // whether it needs to be redrawn), ProseMirror will by default // compare the widget DOM node by identity. If you pass a key, // that key will be compared instead, which can be useful when // you generate decorations on the fly and don't want to store // and reuse DOM nodes. Make sure that any widgets with the same // key are interchangeable—if widgets differ in, for example, // the behavior of some event handler, they should get // different keys. Decoration.widget = function widget(pos, toDOM, spec) { return new Decoration(pos, pos, new WidgetType(toDOM, spec)); }; // :: (number, number, DecorationAttrs, ?Object) → Decoration // Creates an inline decoration, which adds the given attributes to // each inline node between `from` and `to`. // // spec::- These options are recognized: // // inclusiveStart:: ?bool // Determines how the left side of the decoration is // [mapped](#transform.Position_Mapping) when content is // inserted directly at that position. By default, the decoration // won't include the new content, but you can set this to `true` // to make it inclusive. // // inclusiveEnd:: ?bool // Determines how the right side of the decoration is mapped. // See // [`inclusiveStart`](#view.Decoration^inline^spec.inclusiveStart). Decoration.inline = function inline(from, to, attrs, spec) { return new Decoration(from, to, new InlineType(attrs, spec)); }; // :: (number, number, DecorationAttrs, ?Object) → Decoration // Creates a node decoration. `from` and `to` should point precisely // before and after a node in the document. That node, and only that // node, will receive the given attributes. // // spec::- // // Optional information to store with the decoration. It // is also used when comparing decorators for equality. Decoration.node = function node(from, to, attrs, spec) { return new Decoration(from, to, new NodeType(attrs, spec)); }; // :: Object // The spec provided when creating this decoration. Can be useful // if you've stored extra information in that object. prototypeAccessors$1.spec.get = function () { return this.type.spec; }; prototypeAccessors$1.inline.get = function () { return this.type instanceof InlineType; }; Object.defineProperties(Decoration.prototype, prototypeAccessors$1); // DecorationAttrs:: interface // A set of attributes to add to a decorated node. Most properties // simply directly correspond to DOM attributes of the same name, // which will be set to the property's value. These are exceptions: // // class:: ?string // A CSS class name or a space-separated set of class names to be // _added_ to the classes that the node already had. // // style:: ?string // A string of CSS to be _added_ to the node's existing `style` property. // // nodeName:: ?string // When non-null, the target node is wrapped in a DOM element of // this type (and the other attributes are applied to this element). var none = [], noSpec = {}; // :: class extends DecorationSource // A collection of [decorations](#view.Decoration), organized in // such a way that the drawing algorithm can efficiently use and // compare them. This is a persistent data structure—it is not // modified, updates create a new value. var DecorationSet = function DecorationSet(local, children) { this.local = local && local.length ? local : none; this.children = children && children.length ? children : none; }; // :: (Node, [Decoration]) → DecorationSet // Create a set of decorations, using the structure of the given // document. DecorationSet.create = function create(doc, decorations) { return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty; }; // :: (?number, ?number, ?(spec: Object) → bool) → [Decoration] // Find all decorations in this set which touch the given range // (including decorations that start or end directly at the // boundaries) and match the given predicate on their spec. When // `start` and `end` are omitted, all decorations in the set are // considered. When `predicate` isn't given, all decorations are // assumed to match. DecorationSet.prototype.find = function find( start, end, predicate ) { var result = []; this.findInner( start == null ? 0 : start, end == null ? 1e9 : end, result, 0, predicate ); return result; }; DecorationSet.prototype.findInner = function findInner( start, end, result, offset, predicate ) { for (var i = 0; i < this.local.length; i++) { var span = this.local[i]; if ( span.from <= end && span.to >= start && (!predicate || predicate(span.spec)) ) { result.push( span.copy(span.from + offset, span.to + offset) ); } } for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) { if ( this.children[i$1] < end && this.children[i$1 + 1] > start ) { var childOff = this.children[i$1] + 1; this.children[i$1 + 2].findInner( start - childOff, end - childOff, result, offset + childOff, predicate ); } } }; // :: (Mapping, Node, ?Object) → DecorationSet // Map the set of decorations in response to a change in the // document. // // options::- An optional set of options. // // onRemove:: ?(decorationSpec: Object) // When given, this function will be called for each decoration // that gets dropped as a result of the mapping, passing the // spec of that decoration. DecorationSet.prototype.map = function map(mapping, doc, options) { if (this == empty || mapping.maps.length == 0) { return this; } return this.mapInner(mapping, doc, 0, 0, options || noSpec); }; DecorationSet.prototype.mapInner = function mapInner( mapping, node, offset, oldOffset, options ) { var newLocal; for (var i = 0; i < this.local.length; i++) { var mapped = this.local[i].map(mapping, offset, oldOffset); if (mapped && mapped.type.valid(node, mapped)) { (newLocal || (newLocal = [])).push(mapped); } else if (options.onRemove) { options.onRemove(this.local[i].spec); } } if (this.children.length) { return mapChildren( this.children, newLocal, mapping, node, offset, oldOffset, options ); } else { return newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty; } }; // :: (Node, [Decoration]) → DecorationSet // Add the given array of decorations to the ones in the set, // producing a new set. Needs access to the current document to // create the appropriate tree structure. DecorationSet.prototype.add = function add(doc, decorations) { if (!decorations.length) { return this; } if (this == empty) { return DecorationSet.create(doc, decorations); } return this.addInner(doc, decorations, 0); }; DecorationSet.prototype.addInner = function addInner( doc, decorations, offset ) { var this$1 = this; var children, childIndex = 0; doc.forEach(function (childNode, childOffset) { var baseOffset = childOffset + offset, found; if ( !(found = takeSpansForNode( decorations, childNode, baseOffset )) ) { return; } if (!children) { children = this$1.children.slice(); } while ( childIndex < children.length && children[childIndex] < childOffset ) { childIndex += 3; } if (children[childIndex] == childOffset) { children[childIndex + 2] = children[ childIndex + 2 ].addInner(childNode, found, baseOffset + 1); } else { children.splice( childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec) ); } childIndex += 3; }); var local = moveSpans( childIndex ? withoutNulls(decorations) : decorations, -offset ); for (var i = 0; i < local.length; i++) { if (!local[i].type.valid(doc, local[i])) { local.splice(i--, 1); } } return new DecorationSet( local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children ); }; // :: ([Decoration]) → DecorationSet // Create a new set that contains the decorations in this set, minus // the ones in the given array. DecorationSet.prototype.remove = function remove(decorations) { if (decorations.length == 0 || this == empty) { return this; } return this.removeInner(decorations, 0); }; DecorationSet.prototype.removeInner = function removeInner( decorations, offset ) { var children = this.children, local = this.local; for (var i = 0; i < children.length; i += 3) { var found = void 0, from = children[i] + offset, to = children[i + 1] + offset; for ( var j = 0, span = void 0; j < decorations.length; j++ ) { if ((span = decorations[j])) { if (span.from > from && span.to < to) { decorations[j] = null; (found || (found = [])).push(span); } } } if (!found) { continue; } if (children == this.children) { children = this.children.slice(); } var removed = children[i + 2].removeInner(found, from + 1); if (removed != empty) { children[i + 2] = removed; } else { children.splice(i, 3); i -= 3; } } if (local.length) { for ( var i$1 = 0, span$1 = void 0; i$1 < decorations.length; i$1++ ) { if ((span$1 = decorations[i$1])) { for (var j$1 = 0; j$1 < local.length; j$1++) { if (local[j$1].eq(span$1, offset)) { if (local == this.local) { local = this.local.slice(); } local.splice(j$1--, 1); } } } } } if (children == this.children && local == this.local) { return this; } return local.length || children.length ? new DecorationSet(local, children) : empty; }; DecorationSet.prototype.forChild = function forChild(offset, node) { if (this == empty) { return this; } if (node.isLeaf) { return DecorationSet.empty; } var child, local; for (var i = 0; i < this.children.length; i += 3) { if (this.children[i] >= offset) { if (this.children[i] == offset) { child = this.children[i + 2]; } break; } } var start = offset + 1, end = start + node.content.size; for (var i$1 = 0; i$1 < this.local.length; i$1++) { var dec = this.local[i$1]; if ( dec.from < end && dec.to > start && dec.type instanceof InlineType ) { var from = Math.max(start, dec.from) - start, to = Math.min(end, dec.to) - start; if (from < to) { (local || (local = [])).push(dec.copy(from, to)); } } } if (local) { var localSet = new DecorationSet(local.sort(byPos)); return child ? new DecorationGroup([localSet, child]) : localSet; } return child || empty; }; DecorationSet.prototype.eq = function eq(other) { if (this == other) { return true; } if ( !(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length ) { return false; } for (var i = 0; i < this.local.length; i++) { if (!this.local[i].eq(other.local[i])) { return false; } } for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) { if ( this.children[i$1] != other.children[i$1] || this.children[i$1 + 1] != other.children[i$1 + 1] || !this.children[i$1 + 2].eq(other.children[i$1 + 2]) ) { return false; } } return true; }; DecorationSet.prototype.locals = function locals(node) { return removeOverlap(this.localsInner(node)); }; DecorationSet.prototype.localsInner = function localsInner(node) { if (this == empty) { return none; } if (node.inlineContent || !this.local.some(InlineType.is)) { return this.local; } var result = []; for (var i = 0; i < this.local.length; i++) { if (!(this.local[i].type instanceof InlineType)) { result.push(this.local[i]); } } return result; }; // DecorationSource:: interface // An object that can [provide](#view.EditorProps.decorations) // decorations. Implemented by [`DecorationSet`](#view.DecorationSet), // and passed to [node views](#view.EditorProps.nodeViews). // // map:: (Mapping, Node) → DecorationSource // Map the set of decorations in response to a change in the // document. var empty = new DecorationSet(); // :: DecorationSet // The empty set of decorations. DecorationSet.empty = empty; DecorationSet.removeOverlap = removeOverlap; // :- An abstraction that allows the code dealing with decorations to // treat multiple DecorationSet objects as if it were a single object // with (a subset of) the same interface. var DecorationGroup = function DecorationGroup(members) { this.members = members; }; DecorationGroup.prototype.map = function map(mapping, doc) { var mappedDecos = this.members.map(function (member) { return member.map(mapping, doc, noSpec); }); return DecorationGroup.from(mappedDecos); }; DecorationGroup.prototype.forChild = function forChild( offset, child ) { if (child.isLeaf) { return DecorationSet.empty; } var found = []; for (var i = 0; i < this.members.length; i++) { var result = this.members[i].forChild(offset, child); if (result == empty) { continue; } if (result instanceof DecorationGroup) { found = found.concat(result.members); } else { found.push(result); } } return DecorationGroup.from(found); }; DecorationGroup.prototype.eq = function eq(other) { if ( !(other instanceof DecorationGroup) || other.members.length != this.members.length ) { return false; } for (var i = 0; i < this.members.length; i++) { if (!this.members[i].eq(other.members[i])) { return false; } } return true; }; DecorationGroup.prototype.locals = function locals(node) { var result, sorted = true; for (var i = 0; i < this.members.length; i++) { var locals = this.members[i].localsInner(node); if (!locals.length) { continue; } if (!result) { result = locals; } else { if (sorted) { result = result.slice(); sorted = false; } for (var j = 0; j < locals.length; j++) { result.push(locals[j]); } } } return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none; }; // : ([DecorationSet]) → union<DecorationSet, DecorationGroup> // Create a group for the given array of decoration sets, or return // a single set when possible. DecorationGroup.from = function from(members) { switch (members.length) { case 0: return empty; case 1: return members[0]; default: return new DecorationGroup(members); } }; function mapChildren( oldChildren, newLocal, mapping, node, offset, oldOffset, options ) { var children = oldChildren.slice(); // Mark the children that are directly touched by changes, and // move those that are after the changes. var shift = function (oldStart, oldEnd, newStart, newEnd) { for (var i = 0; i < children.length; i += 3) { var end = children[i + 1], dSize = void 0; if (end == -1 || oldStart > end + oldOffset) { continue; } if (oldEnd >= children[i] + oldOffset) { children[i + 1] = -1; } else if ( newStart >= offset && (dSize = newEnd - newStart - (oldEnd - oldStart)) ) { children[i] += dSize; children[i + 1] += dSize; } } }; for (var i = 0; i < mapping.maps.length; i++) { mapping.maps[i].forEach(shift); } // Find the child nodes that still correspond to a single node, // recursively call mapInner on them and update their positions. var mustRebuild = false; for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] == -1) { // Touched nodes var from = mapping.map(oldChildren[i$1] + oldOffset), fromLocal = from - offset; if (fromLocal < 0 || fromLocal >= node.content.size) { mustRebuild = true; continue; } // Must read oldChildren because children was tagged with -1 var to = mapping.map( oldChildren[i$1 + 1] + oldOffset, -1 ), toLocal = to - offset; var ref = node.content.findIndex(fromLocal); var index = ref.index; var childOffset = ref.offset; var childNode = node.maybeChild(index); if ( childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal ) { var mapped = children[i$1 + 2].mapInner( mapping, childNode, from + 1, oldChildren[i$1] + oldOffset + 1, options ); if (mapped != empty) { children[i$1] = fromLocal; children[i$1 + 1] = toLocal; children[i$1 + 2] = mapped; } else { children[i$1 + 1] = -2; mustRebuild = true; } } else { mustRebuild = true; } } } // Remaining children must be collected and rebuilt into the appropriate structure if (mustRebuild) { var decorations = mapAndGatherRemainingDecorations( children, oldChildren, newLocal || [], mapping, offset, oldOffset, options ); var built = buildTree(decorations, node, 0, options); newLocal = built.local; for (var i$2 = 0; i$2 < children.length; i$2 += 3) { if (children[i$2 + 1] < 0) { children.splice(i$2, 3); i$2 -= 3; } } for ( var i$3 = 0, j = 0; i$3 < built.children.length; i$3 += 3 ) { var from$1 = built.children[i$3]; while (j < children.length && children[j] < from$1) { j += 3; } children.splice( j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2] ); } } return new DecorationSet( newLocal && newLocal.sort(byPos), children ); } function moveSpans(spans, offset) { if (!offset || !spans.length) { return spans; } var result = []; for (var i = 0; i < spans.length; i++) { var span = spans[i]; result.push( new Decoration( span.from + offset, span.to + offset, span.type ) ); } return result; } function mapAndGatherRemainingDecorations( children, oldChildren, decorations, mapping, offset, oldOffset, options ) { // Gather all decorations from the remaining marked children function gather(set, oldOffset) { for (var i = 0; i < set.local.length; i++) { var mapped = set.local[i].map( mapping, offset, oldOffset ); if (mapped) { decorations.push(mapped); } else if (options.onRemove) { options.onRemove(set.local[i].spec); } } for (var i$1 = 0; i$1 < set.children.length; i$1 += 3) { gather( set.children[i$1 + 2], set.children[i$1] + oldOffset + 1 ); } } for (var i = 0; i < children.length; i += 3) { if (children[i + 1] == -1) { gather(children[i + 2], oldChildren[i] + oldOffset + 1); } } return decorations; } function takeSpansForNode(spans, node, offset) { if (node.isLeaf) { return null; } var end = offset + node.nodeSize, found = null; for (var i = 0, span = void 0; i < spans.length; i++) { if ( (span = spans[i]) && span.from > offset && span.to < end ) { (found || (found = [])).push(span); spans[i] = null; } } return found; } function withoutNulls(array) { var result = []; for (var i = 0; i < array.length; i++) { if (array[i] != null) { result.push(array[i]); } } return result; } // : ([Decoration], Node, number) → DecorationSet // Build up a tree that corresponds to a set of decorations. `offset` // is a base offset that should be subtracted from the `from` and `to` // positions in the spans (so that we don't have to allocate new spans // for recursive calls). function buildTree(spans, node, offset, options) { var children = [], hasNulls = false; node.forEach(function (childNode, localStart) { var found = takeSpansForNode( spans, childNode, localStart + offset ); if (found) { hasNulls = true; var subtree = buildTree( found, childNode, offset + localStart + 1, options ); if (subtree != empty) { children.push( localStart, localStart + childNode.nodeSize, subtree ); } } }); var locals = moveSpans( hasNulls ? withoutNulls(spans) : spans, -offset ).sort(byPos); for (var i = 0; i < locals.length; i++) { if (!locals[i].type.valid(node, locals[i])) { if (options.onRemove) { options.onRemove(locals[i].spec); } locals.splice(i--, 1); } } return locals.length || children.length ? new DecorationSet(locals, children) : empty; } // : (Decoration, Decoration) → number // Used to sort decorations so that ones with a low start position // come first, and within a set with the same start position, those // with an smaller end position come first. function byPos(a, b) { return a.from - b.from || a.to - b.to; } // : ([Decoration]) → [Decoration] // Scan a sorted array of decorations for partially overlapping spans, // and split those so that only fully overlapping spans are left (to // make subsequent rendering easier). Will return the input array if // no partially overlapping spans are found (the common case). function removeOverlap(spans) { var working = spans; for (var i = 0; i < working.length - 1; i++) { var span = working[i]; if (span.from != span.to) { for (var j = i + 1; j < working.length; j++) { var next = working[j]; if (next.from == span.from) { if (next.to != span.to) { if (working == spans) { working = spans.slice(); } // Followed by a partially overlapping larger span. Split that // span. working[j] = next.copy(next.from, span.to); insertAhead( working, j + 1, next.copy(span.to, next.to) ); } continue; } else { if (next.from < span.to) { if (working == spans) { working = spans.slice(); } // The end of this one overlaps with a subsequent span. Split // this one. working[i] = span.copy( span.from, next.from ); insertAhead( working, j, span.copy(next.from, span.to) ); } break; } } } } return working; } function insertAhead(array, i, deco) { while (i < array.length && byPos(deco, array[i]) > 0) { i++; } array.splice(i, 0, deco); } // : (EditorView) → union<DecorationSet, DecorationGroup> // Get the decorations associated with the current props of a view. function viewDecorations(view) { var found = []; view.someProp("decorations", function (f) { var result = f(view.state); if (result && result != empty) { found.push(result); } }); if (view.cursorWrapper) { found.push( DecorationSet.create(view.state.doc, [ view.cursorWrapper.deco, ]) ); } return DecorationGroup.from(found); } // ::- An editor view manages the DOM structure that represents an // editable document. Its state and behavior are determined by its // [props](#view.DirectEditorProps). var EditorView = function EditorView(place, props) { this._props = props; // :: EditorState // The view's current [state](#state.EditorState). this.state = props.state; this.directPlugins = props.plugins || []; this.directPlugins.forEach(checkStateComponent); this.dispatch = this.dispatch.bind(this); this._root = null; this.focused = false; // Kludge used to work around a Chrome bug this.trackWrites = null; // :: dom.Element // An editable DOM node containing the document. (You probably // should not directly interfere with its content.) this.dom = (place && place.mount) || document.createElement("div"); if (place) { if (place.appendChild) { place.appendChild(this.dom); } else if (place.apply) { place(this.dom); } else if (place.mount) { this.mounted = true; } } // :: bool // Indicates whether the editor is currently [editable](#view.EditorProps.editable). this.editable = getEditable(this); this.markCursor = null; this.cursorWrapper = null; updateCursorWrapper(this); this.nodeViews = buildNodeViews(this); this.docView = docViewDesc( this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this ); this.lastSelectedViewDesc = null; // :: ?{slice: Slice, move: bool} // When editor content is being dragged, this object contains // information about the dragged slice and whether it is being // copied or moved. At any other time, it is null. this.dragging = null; initInput(this); this.prevDirectPlugins = []; this.pluginViews = []; this.updatePluginViews(); }; var prototypeAccessors$2 = { props: { configurable: true }, root: { configurable: true }, }; // composing:: boolean // Holds `true` when a // [composition](https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide) // is active. // :: DirectEditorProps // The view's current [props](#view.EditorProps). prototypeAccessors$2.props.get = function () { if (this._props.state != this.state) { var prev = this._props; this._props = {}; for (var name in prev) { this._props[name] = prev[name]; } this._props.state = this.state; } return this._props; }; // :: (DirectEditorProps) // Update the view's props. Will immediately cause an update to // the DOM. EditorView.prototype.update = function update(props) { if (props.handleDOMEvents != this._props.handleDOMEvents) { ensureListeners(this); } this._props = props; if (props.plugins) { props.plugins.forEach(checkStateComponent); this.directPlugins = props.plugins; } this.updateStateInner(props.state, true); }; // :: (DirectEditorProps) // Update the view by updating existing props object with the object // given as argument. Equivalent to `view.update(Object.assign({}, // view.props, props))`. EditorView.prototype.setProps = function setProps(props) { var updated = {}; for (var name in this._props) { updated[name] = this._props[name]; } updated.state = this.state; for (var name$1 in props) { updated[name$1] = props[name$1]; } this.update(updated); }; // :: (EditorState) // Update the editor's `state` prop, without touching any of the // other props. EditorView.prototype.updateState = function updateState(state) { this.updateStateInner( state, this.state.plugins != state.plugins ); }; EditorView.prototype.updateStateInner = function updateStateInner( state, reconfigured ) { var this$1 = this; var prev = this.state, redraw = false, updateSel = false; // When stored marks are added, stop composition, so that they can // be displayed. if (state.storedMarks && this.composing) { clearComposition(this); updateSel = true; } this.state = state; if (reconfigured) { var nodeViews = buildNodeViews(this); if (changedNodeViews(nodeViews, this.nodeViews)) { this.nodeViews = nodeViews; redraw = true; } ensureListeners(this); } this.editable = getEditable(this); updateCursorWrapper(this); var innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this); var scroll = reconfigured ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve"; var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco); if (updateDoc || !state.selection.eq(prev.selection)) { updateSel = true; } var oldScrollPos = scroll == "preserve" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this); if (updateSel) { this.domObserver.stop(); // Work around an issue in Chrome, IE, and Edge where changing // the DOM around an active selection puts it into a broken // state where the thing the user sees differs from the // selection reported by the Selection object (#710, #973, // #1011, #1013, #1035). var forceSelUpdate = updateDoc && (result.ie || result.chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && selectionContextChanged( prev.selection, state.selection ); if (updateDoc) { // If the node that the selection points into is written to, // Chrome sometimes starts misreporting the selection, so this // tracks that and forces a selection reset when our update // did write to the node. var chromeKludge = result.chrome ? (this.trackWrites = this.root.getSelection().focusNode) : null; if ( redraw || !this.docView.update( state.doc, outerDeco, innerDeco, this ) ) { this.docView.updateOuterDeco([]); this.docView.destroy(); this.docView = docViewDesc( state.doc, outerDeco, innerDeco, this.dom, this ); } if (chromeKludge && !this.trackWrites) { forceSelUpdate = true; } } // Work around for an issue where an update arriving right between // a DOM selection change and the "selectionchange" event for it // can cause a spurious DOM selection update, disrupting mouse // drag selection. if ( forceSelUpdate || !( this.mouseDown && this.domObserver.currentSelection.eq( this.root.getSelection() ) && anchorInRightPlace(this) ) ) { selectionToDOM(this, forceSelUpdate); } else { syncNodeSelection(this, state.selection); this.domObserver.setCurSelection(); } this.domObserver.start(); } this.updatePluginViews(prev); if (scroll == "reset") { this.dom.scrollTop = 0; } else if (scroll == "to selection") { var startDOM = this.root.getSelection().focusNode; if ( this.someProp("handleScrollToSelection", function (f) { return f(this$1); }) ); else if ( state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ) { // Handled scrollRectIntoView( this, this.docView .domAfterPos(state.selection.from) .getBoundingClientRect(), startDOM ); } else { scrollRectIntoView( this, this.coordsAtPos(state.selection.head, 1), startDOM ); } } else if (oldScrollPos) { resetScrollPos(oldScrollPos); } }; EditorView.prototype.destroyPluginViews = function destroyPluginViews() { var view; while ((view = this.pluginViews.pop())) { if (view.destroy) { view.destroy(); } } }; EditorView.prototype.updatePluginViews = function updatePluginViews( prevState ) { if ( !prevState || prevState.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins ) { this.prevDirectPlugins = this.directPlugins; this.destroyPluginViews(); for (var i = 0; i < this.directPlugins.length; i++) { var plugin = this.directPlugins[i]; if (plugin.spec.view) { this.pluginViews.push(plugin.spec.view(this)); } } for (var i$1 = 0; i$1 < this.state.plugins.length; i$1++) { var plugin$1 = this.state.plugins[i$1]; if (plugin$1.spec.view) { this.pluginViews.push(plugin$1.spec.view(this)); } } } else { for (var i$2 = 0; i$2 < this.pluginViews.length; i$2++) { var pluginView = this.pluginViews[i$2]; if (pluginView.update) { pluginView.update(this, prevState); } } } }; // :: (string, ?(prop: *) → *) → * // Goes over the values of a prop, first those provided directly, // then those from plugins given to the view, then from plugins in // the state (in order), and calls `f` every time a non-undefined // value is found. When `f` returns a truthy value, that is // immediately returned. When `f` isn't provided, it is treated as // the identity function (the prop value is returned directly). EditorView.prototype.someProp = function someProp(propName, f) { var prop = this._props && this._props[propName], value; if (prop != null && (value = f ? f(prop) : prop)) { return value; } for (var i = 0; i < this.directPlugins.length; i++) { var prop$1 = this.directPlugins[i].props[propName]; if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) { return value; } } var plugins = this.state.plugins; if (plugins) { for (var i$1 = 0; i$1 < plugins.length; i$1++) { var prop$2 = plugins[i$1].props[propName]; if ( prop$2 != null && (value = f ? f(prop$2) : prop$2) ) { return value; } } } }; // :: () → bool // Query whether the view has focus. EditorView.prototype.hasFocus = function hasFocus() { return this.root.activeElement == this.dom; }; // :: () // Focus the editor. EditorView.prototype.focus = function focus() { this.domObserver.stop(); if (this.editable) { focusPreventScroll(this.dom); } selectionToDOM(this); this.domObserver.start(); }; // :: union<dom.Document, dom.DocumentFragment> // Get the document root in which the editor exists. This will // usually be the top-level `document`, but might be a [shadow // DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM) // root if the editor is inside one. prototypeAccessors$2.root.get = function () { var cached = this._root; if (cached == null) { for ( var search = this.dom.parentNode; search; search = search.parentNode ) { if ( search.nodeType == 9 || (search.nodeType == 11 && search.host) ) { if (!search.getSelection) { Object.getPrototypeOf(search).getSelection = function () { return document.getSelection(); }; } return (this._root = search); } } } return cached || document; }; // :: ({left: number, top: number}) → ?{pos: number, inside: number} // Given a pair of viewport coordinates, return the document // position that corresponds to them. May return null if the given // coordinates aren't inside of the editor. When an object is // returned, its `pos` property is the position nearest to the // coordinates, and its `inside` property holds the position of the // inner node that the position falls inside of, or -1 if it is at // the top level, not in any node. EditorView.prototype.posAtCoords = function posAtCoords$1(coords) { return posAtCoords(this, coords); }; // :: (number, number) → {left: number, right: number, top: number, bottom: number} // Returns the viewport rectangle at a given document position. // `left` and `right` will be the same number, as this returns a // flat cursor-ish rectangle. If the position is between two things // that aren't directly adjacent, `side` determines which element is // used. When < 0, the element before the position is used, // otherwise the element after. EditorView.prototype.coordsAtPos = function coordsAtPos$1( pos, side ) { if (side === void 0) side = 1; return coordsAtPos(this, pos, side); }; // :: (number, number) → {node: dom.Node, offset: number} // Find the DOM position that corresponds to the given document // position. When `side` is negative, find the position as close as // possible to the content before the position. When positive, // prefer positions close to the content after the position. When // zero, prefer as shallow a position as possible. // // Note that you should **not** mutate the editor's internal DOM, // only inspect it (and even that is usually not necessary). EditorView.prototype.domAtPos = function domAtPos(pos, side) { if (side === void 0) side = 0; return this.docView.domFromPos(pos, side); }; // :: (number) → ?dom.Node // Find the DOM node that represents the document node after the // given position. May return `null` when the position doesn't point // in front of a node or if the node is inside an opaque node view. // // This is intended to be able to call things like // `getBoundingClientRect` on that DOM node. Do **not** mutate the // editor DOM directly, or add styling this way, since that will be // immediately overriden by the editor as it redraws the node. EditorView.prototype.nodeDOM = function nodeDOM(pos) { var desc = this.docView.descAt(pos); return desc ? desc.nodeDOM : null; }; // :: (dom.Node, number, ?number) → number // Find the document position that corresponds to a given DOM // position. (Whenever possible, it is preferable to inspect the // document structure directly, rather than poking around in the // DOM, but sometimes—for example when interpreting an event // target—you don't have a choice.) // // The `bias` parameter can be used to influence which side of a DOM // node to use when the position is inside a leaf node. EditorView.prototype.posAtDOM = function posAtDOM( node, offset, bias ) { if (bias === void 0) bias = -1; var pos = this.docView.posFromDOM(node, offset, bias); if (pos == null) { throw new RangeError("DOM position not inside the editor"); } return pos; }; // :: (union<"up", "down", "left", "right", "forward", "backward">, ?EditorState) → bool // Find out whether the selection is at the end of a textblock when // moving in a given direction. When, for example, given `"left"`, // it will return true if moving left from the current cursor // position would leave that position's parent textblock. Will apply // to the view's current state by default, but it is possible to // pass a different state. EditorView.prototype.endOfTextblock = function endOfTextblock$1( dir, state ) { return endOfTextblock(this, state || this.state, dir); }; // :: () // Removes the editor from the DOM and destroys all [node // views](#view.NodeView). EditorView.prototype.destroy = function destroy() { if (!this.docView) { return; } destroyInput(this); this.destroyPluginViews(); if (this.mounted) { this.docView.update( this.state.doc, [], viewDecorations(this), this ); this.dom.textContent = ""; } else if (this.dom.parentNode) { this.dom.parentNode.removeChild(this.dom); } this.docView.destroy(); this.docView = null; }; // Used for testing. EditorView.prototype.dispatchEvent = function dispatchEvent$1( event ) { return dispatchEvent(this, event); }; // :: (Transaction) // Dispatch a transaction. Will call // [`dispatchTransaction`](#view.DirectEditorProps.dispatchTransaction) // when given, and otherwise defaults to applying the transaction to // the current state and calling // [`updateState`](#view.EditorView.updateState) with the result. // This method is bound to the view instance, so that it can be // easily passed around. EditorView.prototype.dispatch = function dispatch(tr) { var dispatchTransaction = this._props.dispatchTransaction; if (dispatchTransaction) { dispatchTransaction.call(this, tr); } else { this.updateState(this.state.apply(tr)); } }; Object.defineProperties(EditorView.prototype, prototypeAccessors$2); function computeDocDeco(view) { var attrs = Object.create(null); attrs.class = "ProseMirror"; attrs.contenteditable = String(view.editable); attrs.translate = "no"; view.someProp("attributes", function (value) { if (typeof value == "function") { value = value(view.state); } if (value) { for (var attr in value) { if (attr == "class") { attrs.class += " " + value[attr]; } if (attr == "style") { attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr]; } else if ( !attrs[attr] && attr != "contenteditable" && attr != "nodeName" ) { attrs[attr] = String(value[attr]); } } } }); return [Decoration.node(0, view.state.doc.content.size, attrs)]; } function updateCursorWrapper(view) { if (view.markCursor) { var dom = document.createElement("img"); dom.className = "ProseMirror-separator"; dom.setAttribute("mark-placeholder", "true"); view.cursorWrapper = { dom: dom, deco: Decoration.widget( view.state.selection.head, dom, { raw: true, marks: view.markCursor } ), }; } else { view.cursorWrapper = null; } } function getEditable(view) { return !view.someProp("editable", function (value) { return value(view.state) === false; }); } function selectionContextChanged(sel1, sel2) { var depth = Math.min( sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head) ); return sel1.$anchor.start(depth) != sel2.$anchor.start(depth); } function buildNodeViews(view) { var result = {}; view.someProp("nodeViews", function (obj) { for (var prop in obj) { if ( !Object.prototype.hasOwnProperty.call(result, prop) ) { result[prop] = obj[prop]; } } }); return result; } function changedNodeViews(a, b) { var nA = 0, nB = 0; for (var prop in a) { if (a[prop] != b[prop]) { return true; } nA++; } for (var _ in b) { nB++; } return nA != nB; } function checkStateComponent(plugin) { if ( plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction ) { throw new RangeError( "Plugins passed directly to the view must not have a state component" ); } } // EditorProps:: interface // // Props are configuration values that can be passed to an editor view // or included in a plugin. This interface lists the supported props. // // The various event-handling functions may all return `true` to // indicate that they handled the given event. The view will then take // care to call `preventDefault` on the event, except with // `handleDOMEvents`, where the handler itself is responsible for that. // // How a prop is resolved depends on the prop. Handler functions are // called one at a time, starting with the base props and then // searching through the plugins (in order of appearance) until one of // them returns true. For some props, the first plugin that yields a // value gets precedence. // // handleDOMEvents:: ?Object<(view: EditorView, event: dom.Event) → bool> // Can be an object mapping DOM event type names to functions that // handle them. Such functions will be called before any handling // ProseMirror does of events fired on the editable DOM element. // Contrary to the other event handling props, when returning true // from such a function, you are responsible for calling // `preventDefault` yourself (or not, if you want to allow the // default behavior). // // handleKeyDown:: ?(view: EditorView, event: dom.KeyboardEvent) → bool // Called when the editor receives a `keydown` event. // // handleKeyPress:: ?(view: EditorView, event: dom.KeyboardEvent) → bool // Handler for `keypress` events. // // handleTextInput:: ?(view: EditorView, from: number, to: number, text: string) → bool // Whenever the user directly input text, this handler is called // before the input is applied. If it returns `true`, the default // behavior of actually inserting the text is suppressed. // // handleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a click, from the inside out. The // `direct` flag will be true for the inner node. // // handleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is clicked, after `handleClickOn` handlers // have been called. // // handleDoubleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a double click. // // handleDoubleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is double-clicked, after `handleDoubleClickOn`. // // handleTripleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a triple click. // // handleTripleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is triple-clicked, after `handleTripleClickOn`. // // handlePaste:: ?(view: EditorView, event: dom.ClipboardEvent, slice: Slice) → bool // Can be used to override the behavior of pasting. `slice` is the // pasted content parsed by the editor, but you can directly access // the event to get at the raw content. // // handleDrop:: ?(view: EditorView, event: dom.Event, slice: Slice, moved: bool) → bool // Called when something is dropped on the editor. `moved` will be // true if this drop moves from the current selection (which should // thus be deleted). // // handleScrollToSelection:: ?(view: EditorView) → bool // Called when the view, after updating its state, tries to scroll // the selection into view. A handler function may return false to // indicate that it did not handle the scrolling and further // handlers or the default behavior should be tried. // // createSelectionBetween:: ?(view: EditorView, anchor: ResolvedPos, head: ResolvedPos) → ?Selection // Can be used to override the way a selection is created when // reading a DOM selection between the given anchor and head. // // domParser:: ?DOMParser // The [parser](#model.DOMParser) to use when reading editor changes // from the DOM. Defaults to calling // [`DOMParser.fromSchema`](#model.DOMParser^fromSchema) on the // editor's schema. // // transformPastedHTML:: ?(html: string) → string // Can be used to transform pasted HTML text, _before_ it is parsed, // for example to clean it up. // // clipboardParser:: ?DOMParser // The [parser](#model.DOMParser) to use when reading content from // the clipboard. When not given, the value of the // [`domParser`](#view.EditorProps.domParser) prop is used. // // transformPastedText:: ?(text: string, plain: bool) → string // Transform pasted plain text. The `plain` flag will be true when // the text is pasted as plain text. // // clipboardTextParser:: ?(text: string, $context: ResolvedPos, plain: bool) → Slice // A function to parse text from the clipboard into a document // slice. Called after // [`transformPastedText`](#view.EditorProps.transformPastedText). // The default behavior is to split the text into lines, wrap them // in `<p>` tags, and call // [`clipboardParser`](#view.EditorProps.clipboardParser) on it. // The `plain` flag will be true when the text is pasted as plain text. // // transformPasted:: ?(Slice) → Slice // Can be used to transform pasted content before it is applied to // the document. // // nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration], innerDecorations: DecorationSource) → NodeView> // Allows you to pass custom rendering and behavior logic for nodes // and marks. Should map node and mark names to constructor // functions that produce a [`NodeView`](#view.NodeView) object // implementing the node's display behavior. For nodes, the third // argument `getPos` is a function that can be called to get the // node's current position, which can be useful when creating // transactions to update it. For marks, the third argument is a // boolean that indicates whether the mark's content is inline. // // `decorations` is an array of node or inline decorations that are // active around the node. They are automatically drawn in the // normal way, and you will usually just want to ignore this, but // they can also be used as a way to provide context information to // the node view without adding it to the document itself. // // `innerDecorations` holds the decorations for the node's content. // You can safely ignore this if your view has no content or a // `contentDOM` property, since the editor will draw the decorations // on the content. But if you, for example, want to create a nested // editor with the content, it may make sense to provide it with the // inner decorations. // // clipboardSerializer:: ?DOMSerializer // The DOM serializer to use when putting content onto the // clipboard. If not given, the result of // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema) // will be used. // // clipboardTextSerializer:: ?(Slice) → string // A function that will be called to get the text for the current // selection when copying text to the clipboard. By default, the // editor will use [`textBetween`](#model.Node.textBetween) on the // selected range. // // decorations:: ?(state: EditorState) → ?DecorationSource // A set of [document decorations](#view.Decoration) to show in the // view. // // editable:: ?(state: EditorState) → bool // When this returns false, the content of the view is not directly // editable. // // attributes:: ?union<Object<string>, (EditorState) → ?Object<string>> // Control the DOM attributes of the editable element. May be either // an object or a function going from an editor state to an object. // By default, the element will get a class `"ProseMirror"`, and // will have its `contentEditable` attribute determined by the // [`editable` prop](#view.EditorProps.editable). Additional classes // provided here will be added to the class. For other attributes, // the value provided first (as in // [`someProp`](#view.EditorView.someProp)) will be used. // // scrollThreshold:: ?union<number, {top: number, right: number, bottom: number, left: number}> // Determines the distance (in pixels) between the cursor and the // end of the visible viewport at which point, when scrolling the // cursor into view, scrolling takes place. Defaults to 0. // // scrollMargin:: ?union<number, {top: number, right: number, bottom: number, left: number}> // Determines the extra space (in pixels) that is left above or // below the cursor when it is scrolled into view. Defaults to 5. // DirectEditorProps:: interface extends EditorProps // // The props object given directly to the editor view supports two // fields that can't be used in plugins: // // state:: EditorState // The current state of the editor. // // plugins:: [Plugin] // A set of plugins to use in the view, applying their [plugin // view](#state.PluginSpec.view) and // [props](#state.PluginSpec.props). Passing plugins with a state // component (a [state field](#state.PluginSpec.state) field or a // [transaction)[#state.PluginSpec.filterTransaction] filter or // appender) will result in an error, since such plugins must be // present in the state to work. // // dispatchTransaction:: ?(tr: Transaction) // The callback over which to send transactions (state updates) // produced by the view. If you specify this, you probably want to // make sure this ends up calling the view's // [`updateState`](#view.EditorView.updateState) method with a new // state that has the transaction // [applied](#state.EditorState.apply). The callback will be bound to have // the view instance as its `this` binding. //# sourceMappingURL=index.es.js.map /***/ }, }, ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js
JavaScript
"use strict"; (self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 453 ], { /***/ 8780: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__), /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Decoration: function() { return /* binding */ Decoration; }, /* harmony export */ DecorationSet: function() { return /* binding */ DecorationSet; }, /* harmony export */ EditorView: function() { return /* binding */ EditorView; }, /* harmony export */ __endComposition: function() { return /* binding */ endComposition; }, /* harmony export */ __parseFromClipboard: function() { return /* binding */ parseFromClipboard; }, /* harmony export */ __serializeForClipboard: function() { return /* binding */ serializeForClipboard; } }); /* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6922), prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2230), prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1081), result = {}; if ("undefined" != typeof navigator && "undefined" != typeof document) { var ie_edge = /Edge\/(\d+)/.exec(navigator.userAgent), ie_upto10 = /MSIE \d/.test(navigator.userAgent), ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent), ie = result.ie = !!(ie_upto10 || ie_11up || ie_edge); result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null, result.gecko = !ie && /gecko\/(\d+)/i.test(navigator.userAgent), result.gecko_version = result.gecko && +(/Firefox\/(\d+)/.exec(navigator.userAgent) || [ 0, 0 ])[1]; var chrome = !ie && /Chrome\/(\d+)/.exec(navigator.userAgent); result.chrome = !!chrome, result.chrome_version = chrome && +chrome[1], // Is true for both iOS and iPadOS for convenience result.safari = !ie && /Apple Computer/.test(navigator.vendor), result.ios = result.safari && (/Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2), result.mac = result.ios || /Mac/.test(navigator.platform), result.android = /Android \d/.test(navigator.userAgent), result.webkit = "webkitFontSmoothing" in document.documentElement.style, result.webkit_version = result.webkit && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [ 0, 0 ])[1]; } var domIndex = function(node) { for(var index = 0;; index++)if (!(node = node.previousSibling)) return index; }, parentNode = function(node) { var parent = node.assignedSlot || node.parentNode; return parent && 11 == parent.nodeType ? parent.host : parent; }, reusedRange = null, textRange = function(node, from, to) { var range = reusedRange || (reusedRange = document.createRange()); return range.setEnd(node, null == to ? node.nodeValue.length : to), range.setStart(node, from || 0), range; }, isEquivalentPosition = function(node, off, targetNode, targetOff) { return targetNode && (scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1)); }, atomElements = /^(img|br|input|textarea|hr)$/i; function scanFor(node, off, targetNode, targetOff, dir) { for(;;){ if (node == targetNode && off == targetOff) return !0; if (off == (dir < 0 ? 0 : nodeSize(node))) { var parent = node.parentNode; if (1 != parent.nodeType || function(dom) { for(var desc, cur = dom; cur && !(desc = cur.pmViewDesc); cur = cur.parentNode); return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom); }(node) || atomElements.test(node.nodeName) || "false" == node.contentEditable) return !1; off = domIndex(node) + (dir < 0 ? 0 : 1), node = parent; } else { if (1 != node.nodeType || "false" == (node = node.childNodes[off + (dir < 0 ? -1 : 0)]).contentEditable) return !1; off = dir < 0 ? nodeSize(node) : 0; } } } function nodeSize(node) { return 3 == node.nodeType ? node.nodeValue.length : node.childNodes.length; } // Work around Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=447523 // (isCollapsed inappropriately returns true in shadow dom) var selectionCollapsed = function(domSel) { var collapsed = domSel.isCollapsed; return collapsed && result.chrome && domSel.rangeCount && !domSel.getRangeAt(0).collapsed && (collapsed = !1), collapsed; }; function keyEvent(keyCode, key) { var event = document.createEvent("Event"); return event.initEvent("keydown", !0, !0), event.keyCode = keyCode, event.key = event.code = key, event; } function getSide(value, side) { return "number" == typeof value ? value : value[side]; } function scrollRectIntoView(view, rect, startDOM) { for(var scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5, doc = view.dom.ownerDocument, parent = startDOM || view.dom; parent; parent = parentNode(parent))if (1 == parent.nodeType) { var atTop = parent == doc.body || 1 != parent.nodeType, bounding = atTop ? { left: 0, right: doc.documentElement.clientWidth, top: 0, bottom: doc.documentElement.clientHeight } : function(node) { var rect = node.getBoundingClientRect(), scaleX = rect.width / node.offsetWidth || 1, scaleY = rect.height / node.offsetHeight || 1; // Make sure scrollbar width isn't included in the rectangle return { left: rect.left, right: rect.left + node.clientWidth * scaleX, top: rect.top, bottom: rect.top + node.clientHeight * scaleY }; }(parent), moveX = 0, moveY = 0; if (rect.top < bounding.top + getSide(scrollThreshold, "top") ? moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top")) : rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom") && (moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom")), rect.left < bounding.left + getSide(scrollThreshold, "left") ? moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left")) : rect.right > bounding.right - getSide(scrollThreshold, "right") && (moveX = rect.right - bounding.right + getSide(scrollMargin, "right")), moveX || moveY) { if (atTop) doc.defaultView.scrollBy(moveX, moveY); else { var startX = parent.scrollLeft, startY = parent.scrollTop; moveY && (parent.scrollTop += moveY), moveX && (parent.scrollLeft += moveX); var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY; rect = { left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY }; } } if (atTop) break; } } function scrollStack(dom) { for(var stack = [], doc = dom.ownerDocument; dom && (stack.push({ dom: dom, top: dom.scrollTop, left: dom.scrollLeft }), dom != doc); dom = parentNode(dom)); return stack; } function restoreScrollStack(stack, dTop) { for(var i = 0; i < stack.length; i++){ var ref = stack[i], dom = ref.dom, top = ref.top, left = ref.left; dom.scrollTop != top + dTop && (dom.scrollTop = top + dTop), dom.scrollLeft != left && (dom.scrollLeft = left); } } var preventScrollSupported = null; function inRect(coords, rect) { return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 && coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1; } function singleRect(object, bias) { var rects = object.getClientRects(); return rects.length ? rects[bias < 0 ? 0 : rects.length - 1] : object.getBoundingClientRect(); } var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; // : (EditorView, number, number) → {left: number, top: number, right: number, bottom: number} // Given a position in the document model, get a bounding box of the // character at that position, relative to the window. function coordsAtPos(view, pos, side) { var ref = view.docView.domFromPos(pos, side < 0 ? -1 : 1), node = ref.node, offset = ref.offset, supportEmptyRange = result.webkit || result.gecko; if (3 == node.nodeType) { // These browsers support querying empty text ranges. Prefer that in // bidi context or when at the end of a node. if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) { var rect = singleRect(textRange(node, offset, offset), side); // Firefox returns bad results (the position before the space) // when querying a position directly after line-broken // whitespace. Detect this situation and and kludge around it if (result.gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) { var rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1); if (rectBefore.top == rect.top) { var rectAfter = singleRect(textRange(node, offset, offset + 1), -1); if (rectAfter.top != rect.top) return flattenV(rectAfter, rectAfter.left < rectBefore.left); } } return rect; } var from = offset, to = offset, takeSide = side < 0 ? 1 : -1; return side < 0 && !offset ? (to++, takeSide = -1) : side >= 0 && offset == node.nodeValue.length ? (from--, takeSide = 1) : side < 0 ? from-- : to++, flattenV(singleRect(textRange(node, from, to), takeSide), takeSide < 0); } // Return a horizontal line in block context if (!view.state.doc.resolve(pos).parent.inlineContent) { if (offset && (side < 0 || offset == nodeSize(node))) { var before = node.childNodes[offset - 1]; if (1 == before.nodeType) return flattenH(before.getBoundingClientRect(), !1); } if (offset < nodeSize(node)) { var after = node.childNodes[offset]; if (1 == after.nodeType) return flattenH(after.getBoundingClientRect(), !0); } return flattenH(node.getBoundingClientRect(), side >= 0); } // Inline, not in text node (this is not Bidi-safe) if (offset && (side < 0 || offset == nodeSize(node))) { var before$1 = node.childNodes[offset - 1], target = 3 == before$1.nodeType ? textRange(before$1, nodeSize(before$1) - +!supportEmptyRange) : // Only use them if they are the last element in their parent 1 != before$1.nodeType || "BR" == before$1.nodeName && before$1.nextSibling ? null : before$1; if (target) return flattenV(singleRect(target, 1), !1); } if (offset < nodeSize(node)) { for(var after$1 = node.childNodes[offset]; after$1.pmViewDesc && after$1.pmViewDesc.ignoreForCoords;)after$1 = after$1.nextSibling; var target$1 = after$1 ? 3 == after$1.nodeType ? textRange(after$1, 0, +!supportEmptyRange) : 1 == after$1.nodeType ? after$1 : null : null; if (target$1) return flattenV(singleRect(target$1, -1), !0); } // All else failed, just try to get a rectangle for the target node return flattenV(singleRect(3 == node.nodeType ? textRange(node) : node, -side), side >= 0); } function flattenV(rect, left) { if (0 == rect.width) return rect; var x = left ? rect.left : rect.right; return { top: rect.top, bottom: rect.bottom, left: x, right: x }; } function flattenH(rect, top) { if (0 == rect.height) return rect; var y = top ? rect.top : rect.bottom; return { top: y, bottom: y, left: rect.left, right: rect.right }; } function withFlushedState(view, state, f) { var viewState = view.state, active = view.root.activeElement; viewState != state && view.updateState(state), active != view.dom && view.focus(); try { return f(); } finally{ viewState != state && view.updateState(viewState), active != view.dom && active && active.focus(); } } var maybeRTL = /[\u0590-\u08ac]/, cachedState = null, cachedDir = null, cachedResult = !1, ViewDesc = function(parent, children, dom, contentDOM) { this.parent = parent, this.children = children, this.dom = dom, // An expando property on the DOM node provides a link back to its // description. dom.pmViewDesc = this, // This is the node that holds the child views. It may be null for // descs that don't have children. this.contentDOM = contentDOM, this.dirty = 0; }, prototypeAccessors = { size: { configurable: !0 }, border: { configurable: !0 }, posBefore: { configurable: !0 }, posAtStart: { configurable: !0 }, posAfter: { configurable: !0 }, posAtEnd: { configurable: !0 }, contentLost: { configurable: !0 }, domAtom: { configurable: !0 }, ignoreForCoords: { configurable: !0 } }; // Used to check whether a given description corresponds to a // widget/mark/node. ViewDesc.prototype.matchesWidget = function() { return !1; }, ViewDesc.prototype.matchesMark = function() { return !1; }, ViewDesc.prototype.matchesNode = function() { return !1; }, ViewDesc.prototype.matchesHack = function(_nodeName) { return !1; }, // : () → ?ParseRule // When parsing in-editor content (in domchange.js), we allow // descriptions to determine the parse rules that should be used to // parse them. ViewDesc.prototype.parseRule = function() { return null; }, // : (dom.Event) → bool // Used by the editor's event handler to ignore events that come // from certain descs. ViewDesc.prototype.stopEvent = function() { return !1; }, // The size of the content represented by this desc. prototypeAccessors.size.get = function() { for(var size = 0, i = 0; i < this.children.length; i++)size += this.children[i].size; return size; }, // For block nodes, this represents the space taken up by their // start/end tokens. prototypeAccessors.border.get = function() { return 0; }, ViewDesc.prototype.destroy = function() { this.parent = null, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = null); for(var i = 0; i < this.children.length; i++)this.children[i].destroy(); }, ViewDesc.prototype.posBeforeChild = function(child) { for(var i = 0, pos = this.posAtStart; i < this.children.length; i++){ var cur = this.children[i]; if (cur == child) return pos; pos += cur.size; } }, prototypeAccessors.posBefore.get = function() { return this.parent.posBeforeChild(this); }, prototypeAccessors.posAtStart.get = function() { return this.parent ? this.parent.posBeforeChild(this) + this.border : 0; }, prototypeAccessors.posAfter.get = function() { return this.posBefore + this.size; }, prototypeAccessors.posAtEnd.get = function() { return this.posAtStart + this.size - 2 * this.border; }, // : (dom.Node, number, ?number) → number ViewDesc.prototype.localPosFromDOM = function(dom, offset, bias) { // If the DOM position is in the content, use the child desc after // it to figure out a position. if (this.contentDOM && this.contentDOM.contains(1 == dom.nodeType ? dom : dom.parentNode)) { if (bias < 0) { if (dom == this.contentDOM) domBefore = dom.childNodes[offset - 1]; else { for(; dom.parentNode != this.contentDOM;)dom = dom.parentNode; domBefore = dom.previousSibling; } for(; domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this);)domBefore = domBefore.previousSibling; return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart; } if (dom == this.contentDOM) domAfter = dom.childNodes[offset]; else { for(; dom.parentNode != this.contentDOM;)dom = dom.parentNode; domAfter = dom.nextSibling; } for(; domAfter && !((desc$1 = domAfter.pmViewDesc) && desc$1.parent == this);)domAfter = domAfter.nextSibling; return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd; } if (dom == this.dom && this.contentDOM) atEnd = offset > domIndex(this.contentDOM); else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = 2 & dom.compareDocumentPosition(this.contentDOM); else if (this.dom.firstChild) { if (0 == offset) for(var domBefore, desc, domAfter, desc$1, atEnd, search = dom;; search = search.parentNode){ if (search == this.dom) { atEnd = !1; break; } if (search.parentNode.firstChild != search) break; } if (null == atEnd && offset == dom.childNodes.length) for(var search$1 = dom;; search$1 = search$1.parentNode){ if (search$1 == this.dom) { atEnd = !0; break; } if (search$1.parentNode.lastChild != search$1) break; } } return (null == atEnd ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart; }, // Scan up the dom finding the first desc that is a descendant of // this one. ViewDesc.prototype.nearestDesc = function(dom, onlyNodes) { for(var first = !0, cur = dom; cur; cur = cur.parentNode){ var desc = this.getDesc(cur); if (desc && (!onlyNodes || desc.node)) { // If dom is outside of this desc's nodeDOM, don't count it. if (!first || !desc.nodeDOM || (1 == desc.nodeDOM.nodeType ? desc.nodeDOM.contains(1 == dom.nodeType ? dom : dom.parentNode) : desc.nodeDOM == dom)) return desc; first = !1; } } }, ViewDesc.prototype.getDesc = function(dom) { for(var desc = dom.pmViewDesc, cur = desc; cur; cur = cur.parent)if (cur == this) return desc; }, ViewDesc.prototype.posFromDOM = function(dom, offset, bias) { for(var scan = dom; scan; scan = scan.parentNode){ var desc = this.getDesc(scan); if (desc) return desc.localPosFromDOM(dom, offset, bias); } return -1; }, // : (number) → ?NodeViewDesc // Find the desc for the node after the given pos, if any. (When a // parent node overrode rendering, there might not be one.) ViewDesc.prototype.descAt = function(pos) { for(var i = 0, offset = 0; i < this.children.length; i++){ var child = this.children[i], end = offset + child.size; if (offset == pos && end != offset) { for(; !child.border && child.children.length;)child = child.children[0]; return child; } if (pos < end) return child.descAt(pos - offset - child.border); offset = end; } }, // : (number, number) → {node: dom.Node, offset: number} ViewDesc.prototype.domFromPos = function(pos, side) { if (!this.contentDOM) return { node: this.dom, offset: 0 }; for(var i = 0, offset = 0, curPos = 0; i < this.children.length; i++){ var child = this.children[i], end = curPos + child.size; if (end > pos || child instanceof TrailingHackViewDesc) { offset = pos - curPos; break; } curPos = end; } // If this points into the middle of a child, call through if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side); // Go back if there were any zero-length widgets with side >= 0 before this point for(var prev = void 0; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.widget.type.side >= 0; i--); // Scan towards the first useable node if (side <= 0) { for(var prev$1, enter = !0; (prev$1 = i ? this.children[i - 1] : null) && prev$1.dom.parentNode != this.contentDOM; i--, enter = !1); return prev$1 && side && enter && !prev$1.border && !prev$1.domAtom ? prev$1.domFromPos(prev$1.size, side) : { node: this.contentDOM, offset: prev$1 ? domIndex(prev$1.dom) + 1 : 0 }; } for(var next, enter$1 = !0; (next = i < this.children.length ? this.children[i] : null) && next.dom.parentNode != this.contentDOM; i++, enter$1 = !1); return next && enter$1 && !next.border && !next.domAtom ? next.domFromPos(0, side) : { node: this.contentDOM, offset: next ? domIndex(next.dom) : this.contentDOM.childNodes.length }; }, // Used to find a DOM range in a single parent for a given changed // range. ViewDesc.prototype.parseRange = function(from, to, base) { if (void 0 === base && (base = 0), 0 == this.children.length) return { node: this.contentDOM, from: from, to: to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length }; for(var fromOffset = -1, toOffset = -1, offset = base, i = 0;; i++){ var child = this.children[i], end = offset + child.size; if (-1 == fromOffset && from <= end) { var childBase = offset + child.border; // FIXME maybe descend mark views to parse a narrower range? if (from >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM)) return child.parseRange(from, to, childBase); from = offset; for(var j = i; j > 0; j--){ var prev = this.children[j - 1]; if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) { fromOffset = domIndex(prev.dom) + 1; break; } from -= prev.size; } -1 == fromOffset && (fromOffset = 0); } if (fromOffset > -1 && (end > to || i == this.children.length - 1)) { to = end; for(var j$1 = i + 1; j$1 < this.children.length; j$1++){ var next = this.children[j$1]; if (next.size && next.dom.parentNode == this.contentDOM && !next.emptyChildAt(-1)) { toOffset = domIndex(next.dom); break; } to += next.size; } -1 == toOffset && (toOffset = this.contentDOM.childNodes.length); break; } offset = end; } return { node: this.contentDOM, from: from, to: to, fromOffset: fromOffset, toOffset: toOffset }; }, ViewDesc.prototype.emptyChildAt = function(side) { if (this.border || !this.contentDOM || !this.children.length) return !1; var child = this.children[side < 0 ? 0 : this.children.length - 1]; return 0 == child.size || child.emptyChildAt(side); }, // : (number) → dom.Node ViewDesc.prototype.domAfterPos = function(pos) { var ref = this.domFromPos(pos, 0), node = ref.node, offset = ref.offset; if (1 != node.nodeType || offset == node.childNodes.length) throw RangeError("No node after pos " + pos); return node.childNodes[offset]; }, // : (number, number, dom.Document) // View descs are responsible for setting any selection that falls // entirely inside of them, so that custom implementations can do // custom things with the selection. Note that this falls apart when // a selection starts in such a node and ends in another, in which // case we just use whatever domFromPos produces as a best effort. ViewDesc.prototype.setSelection = function(anchor, head, root, force) { for(var from = Math.min(anchor, head), to = Math.max(anchor, head), i = 0, offset = 0; i < this.children.length; i++){ var child = this.children[i], end = offset + child.size; if (from > offset && to < end) return child.setSelection(anchor - offset - child.border, head - offset - child.border, root, force); offset = end; } // If the selection falls entirely in a child, give it to that child var anchorDOM = this.domFromPos(anchor, anchor ? -1 : 1), headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1), domSel = root.getSelection(), brKludge = !1; // On Firefox, using Selection.collapse to put the cursor after a // BR node for some reason doesn't always work (#1073). On Safari, // the cursor sometimes inexplicable visually lags behind its // reported position in such situations (#1092). if ((result.gecko || result.safari) && anchor == head) { var node = anchorDOM.node, offset$1 = anchorDOM.offset; if (3 == node.nodeType) // Issue #1128 { if ((brKludge = offset$1 && "\n" == node.nodeValue[offset$1 - 1]) && offset$1 == node.nodeValue.length) for(var scan = node, after = void 0; scan; scan = scan.parentNode){ if (after = scan.nextSibling) { "BR" == after.nodeName && (anchorDOM = headDOM = { node: after.parentNode, offset: domIndex(after) + 1 }); break; } var desc = scan.pmViewDesc; if (desc && desc.node && desc.node.isBlock) break; } } else { var prev = node.childNodes[offset$1 - 1]; brKludge = prev && ("BR" == prev.nodeName || "false" == prev.contentEditable); } } // Firefox can act strangely when the selection is in front of an // uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536 if (result.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && 1 == domSel.focusNode.nodeType) { var after$1 = domSel.focusNode.childNodes[domSel.focusOffset]; after$1 && "false" == after$1.contentEditable && (force = !0); } if (!(!(force || brKludge && result.safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset))) { // Selection.extend can be used to create an 'inverted' selection // (one where the focus is before the anchor), but not all // browsers support it yet. var domSelExtended = !1; if ((domSel.extend || anchor == head) && !brKludge) { domSel.collapse(anchorDOM.node, anchorDOM.offset); try { anchor != head && domSel.extend(headDOM.node, headDOM.offset), domSelExtended = !0; } catch (err) { // In some cases with Chrome the selection is empty after calling // collapse, even when it should be valid. This appears to be a bug, but // it is difficult to isolate. If this happens fallback to the old path // without using extend. if (!(err instanceof DOMException)) throw err; // declare global: DOMException } } if (!domSelExtended) { if (anchor > head) { var tmp = anchorDOM; anchorDOM = headDOM, headDOM = tmp; } var range = document.createRange(); range.setEnd(headDOM.node, headDOM.offset), range.setStart(anchorDOM.node, anchorDOM.offset), domSel.removeAllRanges(), domSel.addRange(range); } } }, // : (dom.MutationRecord) → bool ViewDesc.prototype.ignoreMutation = function(mutation) { return !this.contentDOM && "selection" != mutation.type; }, prototypeAccessors.contentLost.get = function() { return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM); }, // Remove a subtree of the element tree that has been touched // by a DOM change, so that the next update will redraw it. ViewDesc.prototype.markDirty = function(from, to) { for(var offset = 0, i = 0; i < this.children.length; i++){ var child = this.children[i], end = offset + child.size; if (offset == end ? from <= end && to >= offset : from < end && to > offset) { var startInside = offset + child.border, endInside = end - child.border; if (from >= startInside && to <= endInside) { this.dirty = from == offset || to == end ? 2 : 1, from == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM) ? child.dirty = 3 : child.markDirty(from - startInside, to - startInside); return; } child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? 2 : 3; } offset = end; } this.dirty = 2; }, ViewDesc.prototype.markParentsDirty = function() { for(var level = 1, node = this.parent; node; node = node.parent, level++){ var dirty = 1 == level ? 2 : 1; node.dirty < dirty && (node.dirty = dirty); } }, prototypeAccessors.domAtom.get = function() { return !1; }, prototypeAccessors.ignoreForCoords.get = function() { return !1; }, Object.defineProperties(ViewDesc.prototype, prototypeAccessors); // Reused array to avoid allocating fresh arrays for things that will // stay empty anyway. var nothing = [], WidgetViewDesc = /*@__PURE__*/ function(ViewDesc) { function WidgetViewDesc(parent, widget, view, pos) { var self1, dom = widget.type.toDOM; if ("function" == typeof dom && (dom = dom(view, function() { return self1 ? self1.parent ? self1.parent.posBeforeChild(self1) : void 0 : pos; })), !widget.type.spec.raw) { if (1 != dom.nodeType) { var wrap = document.createElement("span"); wrap.appendChild(dom), dom = wrap; } dom.contentEditable = !1, dom.classList.add("ProseMirror-widget"); } ViewDesc.call(this, parent, nothing, dom, null), this.widget = widget, self1 = this; } ViewDesc && (WidgetViewDesc.__proto__ = ViewDesc), WidgetViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype), WidgetViewDesc.prototype.constructor = WidgetViewDesc; var prototypeAccessors$1 = { domAtom: { configurable: !0 } }; return WidgetViewDesc.prototype.matchesWidget = function(widget) { return 0 == this.dirty && widget.type.eq(this.widget.type); }, WidgetViewDesc.prototype.parseRule = function() { return { ignore: !0 }; }, WidgetViewDesc.prototype.stopEvent = function(event) { var stop = this.widget.spec.stopEvent; return !!stop && stop(event); }, WidgetViewDesc.prototype.ignoreMutation = function(mutation) { return "selection" != mutation.type || this.widget.spec.ignoreSelection; }, prototypeAccessors$1.domAtom.get = function() { return !0; }, Object.defineProperties(WidgetViewDesc.prototype, prototypeAccessors$1), WidgetViewDesc; }(ViewDesc), CompositionViewDesc = /*@__PURE__*/ function(ViewDesc) { function CompositionViewDesc(parent, dom, textDOM, text) { ViewDesc.call(this, parent, nothing, dom, null), this.textDOM = textDOM, this.text = text; } ViewDesc && (CompositionViewDesc.__proto__ = ViewDesc), CompositionViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype), CompositionViewDesc.prototype.constructor = CompositionViewDesc; var prototypeAccessors$2 = { size: { configurable: !0 } }; return prototypeAccessors$2.size.get = function() { return this.text.length; }, CompositionViewDesc.prototype.localPosFromDOM = function(dom, offset) { return dom != this.textDOM ? this.posAtStart + (offset ? this.size : 0) : this.posAtStart + offset; }, CompositionViewDesc.prototype.domFromPos = function(pos) { return { node: this.textDOM, offset: pos }; }, CompositionViewDesc.prototype.ignoreMutation = function(mut) { return "characterData" === mut.type && mut.target.nodeValue == mut.oldValue; }, Object.defineProperties(CompositionViewDesc.prototype, prototypeAccessors$2), CompositionViewDesc; }(ViewDesc), MarkViewDesc = /*@__PURE__*/ function(ViewDesc) { function MarkViewDesc(parent, mark, dom, contentDOM) { ViewDesc.call(this, parent, [], dom, contentDOM), this.mark = mark; } return ViewDesc && (MarkViewDesc.__proto__ = ViewDesc), MarkViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype), MarkViewDesc.prototype.constructor = MarkViewDesc, MarkViewDesc.create = function(parent, mark, inline, view) { var custom = view.nodeViews[mark.type.name], spec = custom && custom(mark, view, inline); return spec && spec.dom || (spec = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline))), new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom); }, MarkViewDesc.prototype.parseRule = function() { return { mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM }; }, MarkViewDesc.prototype.matchesMark = function(mark) { return 3 != this.dirty && this.mark.eq(mark); }, MarkViewDesc.prototype.markDirty = function(from, to) { // Move dirty info to nearest node view if (ViewDesc.prototype.markDirty.call(this, from, to), 0 != this.dirty) { for(var parent = this.parent; !parent.node;)parent = parent.parent; parent.dirty < this.dirty && (parent.dirty = this.dirty), this.dirty = 0; } }, MarkViewDesc.prototype.slice = function(from, to, view) { var copy = MarkViewDesc.create(this.parent, this.mark, !0, view), nodes = this.children, size = this.size; to < size && (nodes = replaceNodes(nodes, to, size, view)), from > 0 && (nodes = replaceNodes(nodes, 0, from, view)); for(var i = 0; i < nodes.length; i++)nodes[i].parent = copy; return copy.children = nodes, copy; }, MarkViewDesc; }(ViewDesc), NodeViewDesc = /*@__PURE__*/ function(ViewDesc) { function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos) { ViewDesc.call(this, parent, node.isLeaf ? nothing : [], dom, contentDOM), this.nodeDOM = nodeDOM, this.node = node, this.outerDeco = outerDeco, this.innerDeco = innerDeco, contentDOM && this.updateChildren(view, pos); } ViewDesc && (NodeViewDesc.__proto__ = ViewDesc), NodeViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype), NodeViewDesc.prototype.constructor = NodeViewDesc; var prototypeAccessors$3 = { size: { configurable: !0 }, border: { configurable: !0 }, domAtom: { configurable: !0 } }; return(// By default, a node is rendered using the `toDOM` method from the // node type spec. But client code can use the `nodeViews` spec to // supply a custom node view, which can influence various aspects of // the way the node works. // // (Using subclassing for this was intentionally decided against, // since it'd require exposing a whole slew of finicky // implementation details to the user code that they probably will // never need.) NodeViewDesc.create = function(parent, node, outerDeco, innerDeco, view, pos) { var assign, descObj, custom = view.nodeViews[node.type.name], spec = custom && custom(node, view, function() { return(// (This is a function that allows the custom view to find its // own position) descObj ? descObj.parent ? descObj.parent.posBeforeChild(descObj) : void 0 : pos); }, outerDeco, innerDeco), dom = spec && spec.dom, contentDOM = spec && spec.contentDOM; if (node.isText) { if (dom) { if (3 != dom.nodeType) throw RangeError("Text must be rendered as a DOM text node"); } else dom = document.createTextNode(node.text); } else dom || (dom = (assign = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node))).dom, contentDOM = assign.contentDOM); contentDOM || node.isText || "BR" == dom.nodeName || (dom.hasAttribute("contenteditable") || (dom.contentEditable = !1), node.type.spec.draggable && (dom.draggable = !0)); var nodeDOM = dom; return (dom = applyOuterDeco(dom, outerDeco, node), spec) ? descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos + 1) : node.isText ? new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) : new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos + 1); }, NodeViewDesc.prototype.parseRule = function() { var this$1 = this; // Experimental kludge to allow opt-in re-parsing of nodes if (this.node.type.spec.reparseInView) return null; // FIXME the assumption that this can always return the current // attrs means that if the user somehow manages to change the // attrs in the dom, that won't be picked up. Not entirely sure // whether this is a problem var rule = { node: this.node.type.name, attrs: this.node.attrs }; return this.node.type.spec.code && (rule.preserveWhitespace = "full"), this.contentDOM && !this.contentLost ? rule.contentElement = this.contentDOM : rule.getContent = function() { return this$1.contentDOM ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.empty : this$1.node.content; }, rule; }, NodeViewDesc.prototype.matchesNode = function(node, outerDeco, innerDeco) { return 0 == this.dirty && node.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco); }, prototypeAccessors$3.size.get = function() { return this.node.nodeSize; }, prototypeAccessors$3.border.get = function() { return +!this.node.isLeaf; }, // Syncs `this.children` to match `this.node.content` and the local // decorations, possibly introducing nesting for marks. Then, in a // separate step, syncs the DOM inside `this.contentDOM` to // `this.children`. NodeViewDesc.prototype.updateChildren = function(view, pos) { var this$1 = this, inline = this.node.inlineContent, off = pos, composition = view.composing && this.localCompositionInfo(view, pos), localComposition = composition && composition.pos > -1 ? composition : null, compositionInChild = composition && composition.pos < 0, updater = new ViewTreeUpdater(this, localComposition && localComposition.node); // : (ViewDesc, DecorationSource, (Decoration, number), (Node, [Decoration], DecorationSource, number)) // This function abstracts iterating over the nodes and decorations in // a fragment. Calls `onNode` for each node, with its local and child // decorations. Splits text nodes when there is a decoration starting // or ending inside of them. Calls `onWidget` for each widget. (function(parent, deco, onWidget, onNode) { var locals = deco.locals(parent), offset = 0; // Simple, cheap variant for when there are no local decorations if (0 == locals.length) { for(var i = 0; i < parent.childCount; i++){ var child = parent.child(i); onNode(child, locals, deco.forChild(offset, child), i), offset += child.nodeSize; } return; } for(var decoIndex = 0, active = [], restNode = null, parentIndex = 0;;){ if (decoIndex < locals.length && locals[decoIndex].to == offset) { for(var widget = locals[decoIndex++], widgets = void 0; decoIndex < locals.length && locals[decoIndex].to == offset;)(widgets || (widgets = [ widget ])).push(locals[decoIndex++]); if (widgets) { widgets.sort(compareSide); for(var i$1 = 0; i$1 < widgets.length; i$1++)onWidget(widgets[i$1], parentIndex, !!restNode); } else onWidget(widget, parentIndex, !!restNode); } var child$1 = void 0, index = void 0; if (restNode) index = -1, child$1 = restNode, restNode = null; else if (parentIndex < parent.childCount) index = parentIndex, child$1 = parent.child(parentIndex++); else break; for(var i$2 = 0; i$2 < active.length; i$2++)active[i$2].to <= offset && active.splice(i$2--, 1); for(; decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset;)active.push(locals[decoIndex++]); var end = offset + child$1.nodeSize; if (child$1.isText) { var cutAt = end; decoIndex < locals.length && locals[decoIndex].from < cutAt && (cutAt = locals[decoIndex].from); for(var i$3 = 0; i$3 < active.length; i$3++)active[i$3].to < cutAt && (cutAt = active[i$3].to); cutAt < end && (restNode = child$1.cut(cutAt - offset), child$1 = child$1.cut(0, cutAt - offset), end = cutAt, index = -1); } var outerDeco = active.length ? child$1.isInline && !child$1.isLeaf ? active.filter(function(d) { return !d.inline; }) : active.slice() : nothing; onNode(child$1, outerDeco, deco.forChild(offset, child$1), index), offset = end; } })(this.node, this.innerDeco, function(widget, i, insideNode) { widget.spec.marks ? updater.syncToMarks(widget.spec.marks, inline, view) : widget.type.side >= 0 && !insideNode && updater.syncToMarks(i == this$1.node.childCount ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Mark.none : this$1.node.child(i).marks, inline, view), // If the next node is a desc matching this widget, reuse it, // otherwise insert the widget as a new view desc. updater.placeWidget(widget, view, off); }, function(child, outerDeco, innerDeco, i) { var compIndex; // Make sure the wrapping mark descs match the node's marks. updater.syncToMarks(child.marks, inline, view), updater.findNodeMatch(child, outerDeco, innerDeco, i) || compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view) || updater.updateNextNode(child, outerDeco, innerDeco, view, i) || // Add it as a new view updater.addNode(child, outerDeco, innerDeco, view, off), off += child.nodeSize; }), // Drop all remaining descs after the current position. updater.syncToMarks(nothing, inline, view), this.node.isTextblock && updater.addTextblockHacks(), updater.destroyRest(), (updater.changed || 2 == this.dirty) && (localComposition && this.protectLocalComposition(view, localComposition), // : (dom.Node, [ViewDesc]) // Sync the content of the given DOM node with the nodes associated // with the given array of view descs, recursing into mark descs // because this should sync the subtree for a whole node at a time. function renderDescs(parentDOM, descs, view) { for(var dom = parentDOM.firstChild, written = !1, i = 0; i < descs.length; i++){ var desc = descs[i], childDOM = desc.dom; if (childDOM.parentNode == parentDOM) { for(; childDOM != dom;)dom = rm(dom), written = !0; dom = dom.nextSibling; } else written = !0, parentDOM.insertBefore(childDOM, dom); if (desc instanceof MarkViewDesc) { var pos = dom ? dom.previousSibling : parentDOM.lastChild; renderDescs(desc.contentDOM, desc.children, view), dom = pos ? pos.nextSibling : parentDOM.firstChild; } } for(; dom;)dom = rm(dom), written = !0; written && view.trackWrites == parentDOM && (view.trackWrites = null); }(this.contentDOM, this.children, view), result.ios && // List markers in Mobile Safari will mysteriously disappear // sometimes. This works around that. function(dom) { if ("UL" == dom.nodeName || "OL" == dom.nodeName) { var oldCSS = dom.style.cssText; dom.style.cssText = oldCSS + "; list-style: square !important", window.getComputedStyle(dom).listStyle, dom.style.cssText = oldCSS; } }(this.dom)); }, NodeViewDesc.prototype.localCompositionInfo = function(view, pos) { // Only do something if both the selection and a focused text node // are inside of this node var ref = view.state.selection, from = ref.from, to = ref.to; if (view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !(from < pos) && !(to > pos + this.node.content.size)) { var sel = view.root.getSelection(), textNode = function(node, offset) { for(;;){ if (3 == node.nodeType) return node; if (1 == node.nodeType && offset > 0) { if (node.childNodes.length > offset && 3 == node.childNodes[offset].nodeType) return node.childNodes[offset]; offset = nodeSize(node = node.childNodes[offset - 1]); } else { if (1 != node.nodeType || !(offset < node.childNodes.length)) return null; node = node.childNodes[offset], offset = 0; } } }(sel.focusNode, sel.focusOffset); if (textNode && this.dom.contains(textNode.parentNode)) { if (!this.node.inlineContent) return { node: textNode, pos: -1 }; // Find the text in the focused node in the node, stop if it's not // there (may have been modified through other means, in which // case it should overwritten) var text = textNode.nodeValue, textPos = // Find a piece of text in an inline fragment, overlapping from-to function(frag, text, from, to) { for(var i = 0, pos = 0; i < frag.childCount && pos <= to;){ var child = frag.child(i++), childStart = pos; if (pos += child.nodeSize, child.isText) { for(var str = child.text; i < frag.childCount;){ var next = frag.child(i++); if (pos += next.nodeSize, !next.isText) break; str += next.text; } if (pos >= from) { var found = str.lastIndexOf(text, to - childStart); if (found >= 0 && found + text.length + childStart >= from) return childStart + found; } } } return -1; }(this.node.content, text, from - pos, to - pos); return textPos < 0 ? null : { node: textNode, pos: textPos, text: text }; } } }, NodeViewDesc.prototype.protectLocalComposition = function(view, ref) { var node = ref.node, pos = ref.pos, text = ref.text; // The node is already part of a local view desc, leave it there if (!this.getDesc(node)) { for(// Create a composition view for the orphaned nodes var topNode = node; topNode.parentNode != this.contentDOM; topNode = topNode.parentNode){ for(; topNode.previousSibling;)topNode.parentNode.removeChild(topNode.previousSibling); for(; topNode.nextSibling;)topNode.parentNode.removeChild(topNode.nextSibling); topNode.pmViewDesc && (topNode.pmViewDesc = null); } var desc = new CompositionViewDesc(this, topNode, node, text); view.compositionNodes.push(desc), // Patch up this.children to contain the composition view this.children = replaceNodes(this.children, pos, pos + text.length, view, desc); } }, // : (Node, [Decoration], DecorationSource, EditorView) → bool // If this desc be updated to match the given node decoration, // do so and return true. NodeViewDesc.prototype.update = function(node, outerDeco, innerDeco, view) { return !!(3 != this.dirty && node.sameMarkup(this.node)) && (this.updateInner(node, outerDeco, innerDeco, view), !0); }, NodeViewDesc.prototype.updateInner = function(node, outerDeco, innerDeco, view) { this.updateOuterDeco(outerDeco), this.node = node, this.innerDeco = innerDeco, this.contentDOM && this.updateChildren(view, this.posAtStart), this.dirty = 0; }, NodeViewDesc.prototype.updateOuterDeco = function(outerDeco) { if (!sameOuterDeco(outerDeco, this.outerDeco)) { var needsWrap = 1 != this.nodeDOM.nodeType, oldDOM = this.dom; this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap)), this.dom != oldDOM && (oldDOM.pmViewDesc = null, this.dom.pmViewDesc = this), this.outerDeco = outerDeco; } }, // Mark this node as being the selected node. NodeViewDesc.prototype.selectNode = function() { this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.dom.draggable = !0); }, // Remove selected node marking from this node. NodeViewDesc.prototype.deselectNode = function() { this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.dom.removeAttribute("draggable"); }, prototypeAccessors$3.domAtom.get = function() { return this.node.isAtom; }, Object.defineProperties(NodeViewDesc.prototype, prototypeAccessors$3), NodeViewDesc); }(ViewDesc); // Create a view desc for the top-level document node, to be exported // and used by the view class. function docViewDesc(doc, outerDeco, innerDeco, dom, view) { return applyOuterDeco(dom, outerDeco, doc), new NodeViewDesc(null, doc, outerDeco, innerDeco, dom, dom, dom, view, 0); } var TextViewDesc = /*@__PURE__*/ function(NodeViewDesc) { function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) { NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM, view); } NodeViewDesc && (TextViewDesc.__proto__ = NodeViewDesc), TextViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype), TextViewDesc.prototype.constructor = TextViewDesc; var prototypeAccessors$4 = { domAtom: { configurable: !0 } }; return TextViewDesc.prototype.parseRule = function() { for(var skip = this.nodeDOM.parentNode; skip && skip != this.dom && !skip.pmIsDeco;)skip = skip.parentNode; return { skip: skip || !0 }; }, TextViewDesc.prototype.update = function(node, outerDeco, _, view) { return !!(3 != this.dirty && (0 == this.dirty || this.inParent()) && node.sameMarkup(this.node)) && (this.updateOuterDeco(outerDeco), (0 != this.dirty || node.text != this.node.text) && node.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = node.text, view.trackWrites == this.nodeDOM && (view.trackWrites = null)), this.node = node, this.dirty = 0, !0); }, TextViewDesc.prototype.inParent = function() { for(var parentDOM = this.parent.contentDOM, n = this.nodeDOM; n; n = n.parentNode)if (n == parentDOM) return !0; return !1; }, TextViewDesc.prototype.domFromPos = function(pos) { return { node: this.nodeDOM, offset: pos }; }, TextViewDesc.prototype.localPosFromDOM = function(dom, offset, bias) { return dom == this.nodeDOM ? this.posAtStart + Math.min(offset, this.node.text.length) : NodeViewDesc.prototype.localPosFromDOM.call(this, dom, offset, bias); }, TextViewDesc.prototype.ignoreMutation = function(mutation) { return "characterData" != mutation.type && "selection" != mutation.type; }, TextViewDesc.prototype.slice = function(from, to, view) { var node = this.node.cut(from, to), dom = document.createTextNode(node.text); return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view); }, TextViewDesc.prototype.markDirty = function(from, to) { NodeViewDesc.prototype.markDirty.call(this, from, to), this.dom != this.nodeDOM && (0 == from || to == this.nodeDOM.nodeValue.length) && (this.dirty = 3); }, prototypeAccessors$4.domAtom.get = function() { return !1; }, Object.defineProperties(TextViewDesc.prototype, prototypeAccessors$4), TextViewDesc; }(NodeViewDesc), TrailingHackViewDesc = /*@__PURE__*/ function(ViewDesc) { function TrailingHackViewDesc() { ViewDesc.apply(this, arguments); } ViewDesc && (TrailingHackViewDesc.__proto__ = ViewDesc), TrailingHackViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype), TrailingHackViewDesc.prototype.constructor = TrailingHackViewDesc; var prototypeAccessors$5 = { domAtom: { configurable: !0 }, ignoreForCoords: { configurable: !0 } }; return TrailingHackViewDesc.prototype.parseRule = function() { return { ignore: !0 }; }, TrailingHackViewDesc.prototype.matchesHack = function(nodeName) { return 0 == this.dirty && this.dom.nodeName == nodeName; }, prototypeAccessors$5.domAtom.get = function() { return !0; }, prototypeAccessors$5.ignoreForCoords.get = function() { return "IMG" == this.dom.nodeName; }, Object.defineProperties(TrailingHackViewDesc.prototype, prototypeAccessors$5), TrailingHackViewDesc; }(ViewDesc), CustomNodeViewDesc = /*@__PURE__*/ function(NodeViewDesc) { function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos) { NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos), this.spec = spec; } return NodeViewDesc && (CustomNodeViewDesc.__proto__ = NodeViewDesc), CustomNodeViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype), CustomNodeViewDesc.prototype.constructor = CustomNodeViewDesc, // A custom `update` method gets to decide whether the update goes // through. If it does, and there's a `contentDOM` node, our logic // updates the children. CustomNodeViewDesc.prototype.update = function(node, outerDeco, innerDeco, view) { if (3 == this.dirty) return !1; if (this.spec.update) { var result = this.spec.update(node, outerDeco, innerDeco); return result && this.updateInner(node, outerDeco, innerDeco, view), result; } return (!!this.contentDOM || !!node.isLeaf) && NodeViewDesc.prototype.update.call(this, node, outerDeco, innerDeco, view); }, CustomNodeViewDesc.prototype.selectNode = function() { this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc.prototype.selectNode.call(this); }, CustomNodeViewDesc.prototype.deselectNode = function() { this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc.prototype.deselectNode.call(this); }, CustomNodeViewDesc.prototype.setSelection = function(anchor, head, root, force) { this.spec.setSelection ? this.spec.setSelection(anchor, head, root) : NodeViewDesc.prototype.setSelection.call(this, anchor, head, root, force); }, CustomNodeViewDesc.prototype.destroy = function() { this.spec.destroy && this.spec.destroy(), NodeViewDesc.prototype.destroy.call(this); }, CustomNodeViewDesc.prototype.stopEvent = function(event) { return !!this.spec.stopEvent && this.spec.stopEvent(event); }, CustomNodeViewDesc.prototype.ignoreMutation = function(mutation) { return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc.prototype.ignoreMutation.call(this, mutation); }, CustomNodeViewDesc; }(NodeViewDesc); function OuterDecoLevel(nodeName) { nodeName && (this.nodeName = nodeName); } OuterDecoLevel.prototype = Object.create(null); var noDeco = [ new OuterDecoLevel() ]; function computeOuterDeco(outerDeco, node, needsWrap) { if (0 == outerDeco.length) return noDeco; for(var top = needsWrap ? noDeco[0] : new OuterDecoLevel(), result = [ top ], i = 0; i < outerDeco.length; i++){ var attrs = outerDeco[i].type.attrs; if (attrs) for(var name in attrs.nodeName && result.push(top = new OuterDecoLevel(attrs.nodeName)), attrs){ var val = attrs[name]; null != val && (needsWrap && 1 == result.length && result.push(top = new OuterDecoLevel(node.isInline ? "span" : "div")), "class" == name ? top.class = (top.class ? top.class + " " : "") + val : "style" == name ? top.style = (top.style ? top.style + ";" : "") + val : "nodeName" != name && (top[name] = val)); } } return result; } function patchOuterDeco(outerDOM, nodeDOM, prevComputed, curComputed) { // Shortcut for trivial case if (prevComputed == noDeco && curComputed == noDeco) return nodeDOM; for(var curDOM = nodeDOM, i = 0; i < curComputed.length; i++){ var deco = curComputed[i], prev = prevComputed[i]; if (i) { var parent = void 0; prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = curDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName || ((parent = document.createElement(deco.nodeName)).pmIsDeco = !0, parent.appendChild(curDOM), prev = noDeco[0]), curDOM = parent; } !function(dom, prev, cur) { for(var name in prev)"class" == name || "style" == name || "nodeName" == name || name in cur || dom.removeAttribute(name); for(var name$1 in cur)"class" != name$1 && "style" != name$1 && "nodeName" != name$1 && cur[name$1] != prev[name$1] && dom.setAttribute(name$1, cur[name$1]); if (prev.class != cur.class) { for(var prevList = prev.class ? prev.class.split(" ").filter(Boolean) : nothing, curList = cur.class ? cur.class.split(" ").filter(Boolean) : nothing, i = 0; i < prevList.length; i++)-1 == curList.indexOf(prevList[i]) && dom.classList.remove(prevList[i]); for(var i$1 = 0; i$1 < curList.length; i$1++)-1 == prevList.indexOf(curList[i$1]) && dom.classList.add(curList[i$1]); } if (prev.style != cur.style) { if (prev.style) for(var m, prop = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g; m = prop.exec(prev.style);)dom.style.removeProperty(m[1]); cur.style && (dom.style.cssText += cur.style); } }(curDOM, prev || noDeco[0], deco); } return curDOM; } function applyOuterDeco(dom, deco, node) { return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, 1 != dom.nodeType)); } // : ([Decoration], [Decoration]) → bool function sameOuterDeco(a, b) { if (a.length != b.length) return !1; for(var i = 0; i < a.length; i++)if (!a[i].type.eq(b[i].type)) return !1; return !0; } // Remove a DOM node and return its next sibling. function rm(dom) { var next = dom.nextSibling; return dom.parentNode.removeChild(dom), next; } // Helper class for incrementally updating a tree of mark descs and // the widget and node descs inside of them. var ViewTreeUpdater = function(top, lockedNode) { this.top = top, this.lock = lockedNode, // Index into `this.top`'s child array, represents the current // update position. this.index = 0, // When entering a mark, the current top and index are pushed // onto this. this.stack = [], // Tracks whether anything was changed this.changed = !1, this.preMatch = // : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>} // Iterate from the end of the fragment and array of descs to find // directly matching ones, in order to avoid overeagerly reusing those // for other nodes. Returns the fragment index of the first node that // is part of the sequence of matched nodes at the end of the // fragment. function(frag, descs) { for(var fI = frag.childCount, dI = descs.length, matched = new Map(); fI > 0 && dI > 0; dI--){ var desc = descs[dI - 1], node = desc.node; if (node) { if (node != frag.child(fI - 1)) break; --fI, matched.set(desc, fI); } } return { index: fI, matched: matched }; }(top.node.content, top.children); }; function compareSide(a, b) { return a.type.side - b.type.side; } // Replace range from-to in an array of view descs with replacement // (may be null to just delete). This goes very much against the grain // of the rest of this code, which tends to create nodes with the // right shape in one go, rather than messing with them after // creation, but is necessary in the composition hack. function replaceNodes(nodes, from, to, view, replacement) { for(var result = [], i = 0, off = 0; i < nodes.length; i++){ var child = nodes[i], start = off, end = off += child.size; start >= to || end <= from ? result.push(child) : (start < from && result.push(child.slice(0, from - start, view)), replacement && (result.push(replacement), replacement = null), end > to && result.push(child.slice(to - start, child.size, view))); } return result; } function selectionFromDOM(view, origin) { var domSel = view.root.getSelection(), doc = view.state.doc; if (!domSel.focusNode) return null; var nearestDesc = view.docView.nearestDesc(domSel.focusNode), inWidget = nearestDesc && 0 == nearestDesc.size, head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset); if (head < 0) return null; var $anchor, selection, $head = doc.resolve(head); if (selectionCollapsed(domSel)) { for($anchor = $head; nearestDesc && !nearestDesc.node;)nearestDesc = nearestDesc.parent; if (nearestDesc && nearestDesc.node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && function(node, offset, parent) { for(var atStart = 0 == offset, atEnd = offset == nodeSize(node); atStart || atEnd;){ if (node == parent) return !0; var index = domIndex(node); if (!(node = node.parentNode)) return !1; atStart = atStart && 0 == index, atEnd = atEnd && index == nodeSize(node); } }(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) { var pos = nearestDesc.posBefore; selection = new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection(head == pos ? $head : doc.resolve(pos)); } } else { var anchor = view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset); if (anchor < 0) return null; $anchor = doc.resolve(anchor); } if (!selection) { var bias = "pointer" == origin || view.state.selection.head < $head.pos && !inWidget ? 1 : -1; selection = selectionBetween(view, $anchor, $head, bias); } return selection; } function editorOwnsSelection(view) { return view.editable ? view.hasFocus() : hasSelection(view) && document.activeElement && document.activeElement.contains(view.dom); } function selectionToDOM(view, force) { var sel = view.state.selection; if (syncNodeSelection(view, sel), editorOwnsSelection(view)) { if (!force && view.mouseDown && view.mouseDown.allowDefault) { view.mouseDown.delayedSelectionSync = !0, view.domObserver.setCurSelection(); return; } if (view.domObserver.disconnectSelection(), view.cursorWrapper) domSel = view.root.getSelection(), range = document.createRange(), (img = "IMG" == (node = view.cursorWrapper.dom).nodeName) ? range.setEnd(node.parentNode, domIndex(node) + 1) : range.setEnd(node, 0), range.collapse(!1), domSel.removeAllRanges(), domSel.addRange(range), !img && !view.state.selection.visible && result.ie && result.ie_version <= 11 && (node.disabled = !0, node.disabled = !1); else { var domSel, range, node, img, doc, domSel1, node1, offset, resetEditableFrom, resetEditableTo, anchor = sel.anchor, head = sel.head; !brokenSelectBetweenUneditable || sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection || (sel.$from.parent.inlineContent || (resetEditableFrom = temporarilyEditableNear(view, sel.from)), sel.empty || sel.$from.parent.inlineContent || (resetEditableTo = temporarilyEditableNear(view, sel.to))), view.docView.setSelection(anchor, head, view.root, force), brokenSelectBetweenUneditable && (resetEditableFrom && resetEditable(resetEditableFrom), resetEditableTo && resetEditable(resetEditableTo)), sel.visible ? view.dom.classList.remove("ProseMirror-hideselection") : (view.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && ((doc = view.dom.ownerDocument).removeEventListener("selectionchange", view.hideSelectionGuard), node1 = (domSel1 = view.root.getSelection()).anchorNode, offset = domSel1.anchorOffset, doc.addEventListener("selectionchange", view.hideSelectionGuard = function() { (domSel1.anchorNode != node1 || domSel1.anchorOffset != offset) && (doc.removeEventListener("selectionchange", view.hideSelectionGuard), setTimeout(function() { (!editorOwnsSelection(view) || view.state.selection.visible) && view.dom.classList.remove("ProseMirror-hideselection"); }, 20)); }))); } view.domObserver.setCurSelection(), view.domObserver.connectSelection(); } } // Destroy and remove the children between the given indices in // `this.top`. ViewTreeUpdater.prototype.destroyBetween = function(start, end) { if (start != end) { for(var i = start; i < end; i++)this.top.children[i].destroy(); this.top.children.splice(start, end - start), this.changed = !0; } }, // Destroy all remaining children in `this.top`. ViewTreeUpdater.prototype.destroyRest = function() { this.destroyBetween(this.index, this.top.children.length); }, // : ([Mark], EditorView) // Sync the current stack of mark descs with the given array of // marks, reusing existing mark descs when possible. ViewTreeUpdater.prototype.syncToMarks = function(marks, inline, view) { for(var keep = 0, depth = this.stack.length >> 1, maxKeep = Math.min(depth, marks.length); keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[keep + 1 << 1]).matchesMark(marks[keep]) && !1 !== marks[keep].type.spec.spanning;)keep++; for(; keep < depth;)this.destroyRest(), this.top.dirty = 0, this.index = this.stack.pop(), this.top = this.stack.pop(), depth--; for(; depth < marks.length;){ this.stack.push(this.top, this.index + 1); for(var found = -1, i = this.index; i < Math.min(this.index + 3, this.top.children.length); i++)if (this.top.children[i].matchesMark(marks[depth])) { found = i; break; } if (found > -1) found > this.index && (this.changed = !0, this.destroyBetween(this.index, found)), this.top = this.top.children[this.index]; else { var markDesc = MarkViewDesc.create(this.top, marks[depth], inline, view); this.top.children.splice(this.index, 0, markDesc), this.top = markDesc, this.changed = !0; } this.index = 0, depth++; } }, // : (Node, [Decoration], DecorationSource) → bool // Try to find a node desc matching the given data. Skip over it and // return true when successful. ViewTreeUpdater.prototype.findNodeMatch = function(node, outerDeco, innerDeco, index) { var children = this.top.children, found = -1; if (index >= this.preMatch.index) { for(var i = this.index; i < children.length; i++)if (children[i].matchesNode(node, outerDeco, innerDeco)) { found = i; break; } } else for(var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++){ var child = children[i$1]; if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) { found = i$1; break; } } return !(found < 0) && (this.destroyBetween(this.index, found), this.index++, !0); }, ViewTreeUpdater.prototype.updateNodeAt = function(node, outerDeco, innerDeco, index, view) { return !!this.top.children[index].update(node, outerDeco, innerDeco, view) && (this.destroyBetween(this.index, index), this.index = index + 1, !0); }, ViewTreeUpdater.prototype.findIndexWithChild = function(domNode) { for(;;){ var parent = domNode.parentNode; if (!parent) return -1; if (parent == this.top.contentDOM) { var desc = domNode.pmViewDesc; if (desc) { for(var i = this.index; i < this.top.children.length; i++)if (this.top.children[i] == desc) return i; } return -1; } domNode = parent; } }, // : (Node, [Decoration], DecorationSource, EditorView, Fragment, number) → bool // Try to update the next node, if any, to the given data. Checks // pre-matches to avoid overwriting nodes that could still be used. ViewTreeUpdater.prototype.updateNextNode = function(node, outerDeco, innerDeco, view, index) { for(var i = this.index; i < this.top.children.length; i++){ var next = this.top.children[i]; if (next instanceof NodeViewDesc) { var preMatch = this.preMatch.matched.get(next); if (null != preMatch && preMatch != index) return !1; var nextDOM = next.dom; if (!(this.lock && (nextDOM == this.lock || 1 == nextDOM.nodeType && nextDOM.contains(this.lock.parentNode)) && !(node.isText && next.node && next.node.isText && next.nodeDOM.nodeValue == node.text && 3 != next.dirty && sameOuterDeco(outerDeco, next.outerDeco))) && next.update(node, outerDeco, innerDeco, view)) return this.destroyBetween(this.index, i), next.dom != nextDOM && (this.changed = !0), this.index++, !0; break; } } return !1; }, // : (Node, [Decoration], DecorationSource, EditorView) // Insert the node as a newly created node desc. ViewTreeUpdater.prototype.addNode = function(node, outerDeco, innerDeco, view, pos) { this.top.children.splice(this.index++, 0, NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos)), this.changed = !0; }, ViewTreeUpdater.prototype.placeWidget = function(widget, view, pos) { var next = this.index < this.top.children.length ? this.top.children[this.index] : null; if (next && next.matchesWidget(widget) && (widget == next.widget || !next.widget.type.toDOM.parentNode)) this.index++; else { var desc = new WidgetViewDesc(this.top, widget, view, pos); this.top.children.splice(this.index++, 0, desc), this.changed = !0; } }, // Make sure a textblock looks and behaves correctly in // contentEditable. ViewTreeUpdater.prototype.addTextblockHacks = function() { for(var lastChild = this.top.children[this.index - 1]; lastChild instanceof MarkViewDesc;)lastChild = lastChild.children[lastChild.children.length - 1]; !(!lastChild || // Empty textblock !(lastChild instanceof TextViewDesc) || /\n$/.test(lastChild.node.text)) || ((result.safari || result.chrome) && lastChild && "false" == lastChild.dom.contentEditable && this.addHackNode("IMG"), this.addHackNode("BR")); }, ViewTreeUpdater.prototype.addHackNode = function(nodeName) { if (this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName)) this.index++; else { var dom = document.createElement(nodeName); "IMG" == nodeName && (dom.className = "ProseMirror-separator"), "BR" == nodeName && (dom.className = "ProseMirror-trailingBreak"), this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null)), this.changed = !0; } }; // Kludge to work around Webkit not allowing a selection to start/end // between non-editable block nodes. We briefly make something // editable, set the selection, then set it uneditable again. var brokenSelectBetweenUneditable = result.safari || result.chrome && result.chrome_version < 63; function temporarilyEditableNear(view, pos) { var ref = view.docView.domFromPos(pos, 0), node = ref.node, offset = ref.offset, after = offset < node.childNodes.length ? node.childNodes[offset] : null, before = offset ? node.childNodes[offset - 1] : null; if (result.safari && after && "false" == after.contentEditable) return setEditable(after); if ((!after || "false" == after.contentEditable) && (!before || "false" == before.contentEditable)) { if (after) return setEditable(after); if (before) return setEditable(before); } } function setEditable(element) { return element.contentEditable = "true", result.safari && element.draggable && (element.draggable = !1, element.wasDraggable = !0), element; } function resetEditable(element) { element.contentEditable = "false", element.wasDraggable && (element.draggable = !0, element.wasDraggable = null); } function syncNodeSelection(view, sel) { if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection) { var desc = view.docView.descAt(sel.from); desc != view.lastSelectedViewDesc && (clearNodeSelection(view), desc && desc.selectNode(), view.lastSelectedViewDesc = desc); } else clearNodeSelection(view); } // Clear all DOM statefulness of the last node selection. function clearNodeSelection(view) { view.lastSelectedViewDesc && (view.lastSelectedViewDesc.parent && view.lastSelectedViewDesc.deselectNode(), view.lastSelectedViewDesc = null); } function selectionBetween(view, $anchor, $head, bias) { return view.someProp("createSelectionBetween", function(f) { return f(view, $anchor, $head); }) || prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.between($anchor, $head, bias); } function hasSelection(view) { var sel = view.root.getSelection(); if (!sel.anchorNode) return !1; try { // Firefox will raise 'permission denied' errors when accessing // properties of `sel.anchorNode` when it's in a generated CSS // element. return view.dom.contains(3 == sel.anchorNode.nodeType ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(3 == sel.focusNode.nodeType ? sel.focusNode.parentNode : sel.focusNode)); } catch (_) { return !1; } } function moveSelectionBlock(state, dir) { var ref = state.selection, $anchor = ref.$anchor, $head = ref.$head, $side = dir > 0 ? $anchor.max($head) : $anchor.min($head), $start = $side.parent.inlineContent ? $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null : $side; return $start && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom($start, dir); } function apply(view, sel) { return view.dispatch(view.state.tr.setSelection(sel).scrollIntoView()), !0; } function selectHorizontally(view, dir, mods) { var sel = view.state.selection; if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection) { if (!sel.empty || mods.indexOf("s") > -1) return !1; if (view.endOfTextblock(dir > 0 ? "right" : "left")) { var next = moveSelectionBlock(view.state, dir); return !!next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && apply(view, next); } if (!(result.mac && mods.indexOf("m") > -1)) { var desc, $head = sel.$head, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter; if (!node || node.isText) return !1; var nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos; return !!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM) && (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(node) ? apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head)) : !!result.webkit && apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)))); } } else { if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && sel.node.isInline) return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection(dir > 0 ? sel.$to : sel.$from)); var next$1 = moveSelectionBlock(view.state, dir); return !!next$1 && apply(view, next$1); } } function nodeLen(node) { return 3 == node.nodeType ? node.nodeValue.length : node.childNodes.length; } function isIgnorable(dom) { var desc = dom.pmViewDesc; return desc && 0 == desc.size && (dom.nextSibling || "BR" != dom.nodeName); } // Make sure the cursor isn't directly after one or more ignored // nodes, which will confuse the browser's cursor motion logic. function skipIgnoredNodesLeft(view) { var sel = view.root.getSelection(), node = sel.focusNode, offset = sel.focusOffset; if (node) { var moveNode, moveOffset, force = !1; for(result.gecko && 1 == node.nodeType && offset < nodeLen(node) && isIgnorable(node.childNodes[offset]) && (force = !0);;)if (offset > 0) { if (1 != node.nodeType) break; var before = node.childNodes[offset - 1]; if (isIgnorable(before)) moveNode = node, moveOffset = --offset; else if (3 == before.nodeType) offset = (node = before).nodeValue.length; else break; } else if (isBlockNode(node)) break; else { for(var prev = node.previousSibling; prev && isIgnorable(prev);)moveNode = node.parentNode, moveOffset = domIndex(prev), prev = prev.previousSibling; if (prev) offset = nodeLen(node = prev); else { if ((node = node.parentNode) == view.dom) break; offset = 0; } } force ? setSelFocus(view, sel, node, offset) : moveNode && setSelFocus(view, sel, moveNode, moveOffset); } } // Make sure the cursor isn't directly before one or more ignored // nodes. function skipIgnoredNodesRight(view) { var moveNode, moveOffset, sel = view.root.getSelection(), node = sel.focusNode, offset = sel.focusOffset; if (node) { for(var len = nodeLen(node);;)if (offset < len) { if (1 != node.nodeType) break; if (isIgnorable(node.childNodes[offset])) moveNode = node, moveOffset = ++offset; else break; } else if (isBlockNode(node)) break; else { for(var next = node.nextSibling; next && isIgnorable(next);)moveNode = next.parentNode, moveOffset = domIndex(next) + 1, next = next.nextSibling; if (next) offset = 0, len = nodeLen(node = next); else { if ((node = node.parentNode) == view.dom) break; offset = len = 0; } } moveNode && setSelFocus(view, sel, moveNode, moveOffset); } } function isBlockNode(dom) { var desc = dom.pmViewDesc; return desc && desc.node && desc.node.isBlock; } function setSelFocus(view, sel, node, offset) { if (selectionCollapsed(sel)) { var range = document.createRange(); range.setEnd(node, offset), range.setStart(node, offset), sel.removeAllRanges(), sel.addRange(range); } else sel.extend && sel.extend(node, offset); view.domObserver.setCurSelection(); var state = view.state; // If no state update ends up happening, reset the selection. setTimeout(function() { view.state == state && selectionToDOM(view); }, 50); } // : (EditorState, number) // Check whether vertical selection motion would involve node // selections. If so, apply it (if not, the result is left to the // browser) function selectVertically(view, dir, mods) { var sel = view.state.selection; if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty || mods.indexOf("s") > -1 || result.mac && mods.indexOf("m") > -1) return !1; var $from = sel.$from, $to = sel.$to; if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? "up" : "down")) { var next = moveSelectionBlock(view.state, dir); if (next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection) return apply(view, next); } if (!$from.parent.inlineContent) { var side = dir < 0 ? $from : $to, beyond = sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.AllSelection ? prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.near(side, dir) : prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom(side, dir); return !!beyond && apply(view, beyond); } return !1; } function stopNativeHorizontalDelete(view, dir) { if (!(view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection)) return !0; var ref = view.state.selection, $head = ref.$head, $anchor = ref.$anchor, empty = ref.empty; if (!$head.sameParent($anchor)) return !0; if (!empty) return !1; if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) return !0; var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter); if (nextNode && !nextNode.isText) { var tr = view.state.tr; return dir < 0 ? tr.delete($head.pos - nextNode.nodeSize, $head.pos) : tr.delete($head.pos, $head.pos + nextNode.nodeSize), view.dispatch(tr), !0; } return !1; } function switchEditable(view, node, state) { view.domObserver.stop(), node.contentEditable = state, view.domObserver.start(); } function ruleFromNode(dom) { var desc = dom.pmViewDesc; if (desc) return desc.parseRule(); if ("BR" == dom.nodeName && dom.parentNode) { // Safari replaces the list item or table cell with a BR // directly in the list node (?!) if you delete the last // character in a list item or table cell (#708, #862) if (result.safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName)) { var skip = document.createElement("div"); return skip.appendChild(document.createElement("li")), { skip: skip }; } if (dom.parentNode.lastChild == dom || result.safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) return { ignore: !0 }; } else if ("IMG" == dom.nodeName && dom.getAttribute("mark-placeholder")) return { ignore: !0 }; } function resolveSelection(view, doc, parsedSel) { return Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size ? null : selectionBetween(view, doc.resolve(parsedSel.anchor), doc.resolve(parsedSel.head)); } function skipClosingAndOpening($pos, fromEnd, mayOpen) { for(var depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos; depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount);)depth--, end++, fromEnd = !1; if (mayOpen) for(var next = $pos.node(depth).maybeChild($pos.indexAfter(depth)); next && !next.isLeaf;)next = next.firstChild, end++; return end; } function serializeForClipboard(view, slice) { for(var context = [], content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd; openStart > 1 && openEnd > 1 && 1 == content.childCount && 1 == content.firstChild.childCount;){ openStart--, openEnd--; var node = content.firstChild; context.push(node.type.name, node.attrs != node.type.defaultAttrs ? node.attrs : null), content = node.content; } var serializer = view.someProp("clipboardSerializer") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.fromSchema(view.state.schema), doc = detachedDoc(), wrap = doc.createElement("div"); wrap.appendChild(serializer.serializeFragment(content, { document: doc })); for(var needsWrap, firstChild = wrap.firstChild; firstChild && 1 == firstChild.nodeType && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()]);){ for(var i = needsWrap.length - 1; i >= 0; i--){ for(var wrapper = doc.createElement(needsWrap[i]); wrap.firstChild;)wrapper.appendChild(wrap.firstChild); wrap.appendChild(wrapper), "tbody" != needsWrap[i] && (openStart++, openEnd++); } firstChild = wrap.firstChild; } return firstChild && 1 == firstChild.nodeType && firstChild.setAttribute("data-pm-slice", openStart + " " + openEnd + " " + JSON.stringify(context)), { dom: wrap, text: view.someProp("clipboardTextSerializer", function(f) { return f(slice); }) || slice.content.textBetween(0, slice.content.size, "\n\n") }; } // : (EditorView, string, string, ?bool, ResolvedPos) → ?Slice // Read a slice of content from the clipboard (or drop data). function parseFromClipboard(view, text, html, plainText, $context) { var dom, slice, inCode = $context.parent.type.spec.code; if (!html && !text) return null; var asText = text && (plainText || inCode || !html); if (asText) { if (view.someProp("transformPastedText", function(f) { text = f(text, inCode || plainText); }), inCode) return text ? new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0) : prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice.empty; var parsed = view.someProp("clipboardTextParser", function(f) { return f(text, $context, plainText); }); if (parsed) slice = parsed; else { var marks = $context.marks(), schema = view.state.schema, serializer = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMSerializer.fromSchema(schema); dom = document.createElement("div"), text.split(/(?:\r\n?|\n)+/).forEach(function(block) { var p = dom.appendChild(document.createElement("p")); block && p.appendChild(serializer.serializeNode(schema.text(block, marks))); }); } } else view.someProp("transformPastedHTML", function(f) { html = f(html); }), dom = function(html) { var metas = /^(\s*<meta [^>]*>)*/.exec(html); metas && (html = html.slice(metas[0].length)); var wrap, elt = detachedDoc().createElement("div"), firstTag = /<([a-z][^>\s]+)/i.exec(html); if ((wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) && (html = wrap.map(function(n) { return "<" + n + ">"; }).join("") + html + wrap.map(function(n) { return "</" + n + ">"; }).reverse().join("")), elt.innerHTML = html, wrap) for(var i = 0; i < wrap.length; i++)elt = elt.querySelector(wrap[i]) || elt; return elt; }(html), result.webkit && // Webkit browsers do some hard-to-predict replacement of regular // spaces with non-breaking spaces when putting content on the // clipboard. This tries to convert such non-breaking spaces (which // will be wrapped in a plain span on Chrome, a span with class // Apple-converted-space on Safari) back to regular spaces. function(dom) { for(var nodes = dom.querySelectorAll(result.chrome ? "span:not([class]):not([style])" : "span.Apple-converted-space"), i = 0; i < nodes.length; i++){ var node = nodes[i]; 1 == node.childNodes.length && "\u00a0" == node.textContent && node.parentNode && node.parentNode.replaceChild(dom.ownerDocument.createTextNode(" "), node); } }(dom); var contextNode = dom && dom.querySelector("[data-pm-slice]"), sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice")); if (slice || (slice = (view.someProp("clipboardParser") || view.someProp("domParser") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMParser.fromSchema(view.state.schema)).parseSlice(dom, { preserveWhitespace: !!(asText || sliceData), context: $context })), sliceData) slice = function(slice, context) { if (!slice.size) return slice; var array, schema = slice.content.firstChild.type.schema; try { array = JSON.parse(context); } catch (e) { return slice; } for(var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd, i = array.length - 2; i >= 0; i -= 2){ var type = schema.nodes[array[i]]; if (!type || type.hasRequiredAttrs()) break; content = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(type.create(array[i + 1], content)), openStart++, openEnd++; } return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice(content, openStart, openEnd); }(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]); else if (// HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent (slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice.maxOpen(// Takes a slice parsed with parseSlice, which means there hasn't been // any content-expression checking done on the top nodes, tries to // find a parent node in the current context that might fit the nodes, // and if successful, rebuilds the slice so that it fits into that parent. // // This addresses the problem that Transform.replace expects a // coherent slice, and will fail to place a set of siblings that don't // fit anywhere in the schema. function(fragment, $context) { if (fragment.childCount < 2) return fragment; for(var d = $context.depth; d >= 0; d--){ var returned = function(d) { var match = $context.node(d).contentMatchAt($context.index(d)), lastWrap = void 0, result = []; if (fragment.forEach(function(node) { if (result) { var inLast, wrap = match.findWrapping(node.type); if (!wrap) return result = null; if (inLast = result.length && lastWrap.length && // Used to group adjacent nodes wrapped in similar parents by // normalizeSiblings into the same parent node function addToSibling(wrap, lastWrap, node, sibling, depth) { if (depth < wrap.length && depth < lastWrap.length && wrap[depth] == lastWrap[depth]) { var inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1); if (inner) return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner)); if (sibling.contentMatchAt(sibling.childCount).matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1])) return sibling.copy(sibling.content.append(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(withWrappers(node, wrap, depth + 1)))); } }(wrap, lastWrap, node, result[result.length - 1], 0)) result[result.length - 1] = inLast; else { result.length && (result[result.length - 1] = function closeRight(node, depth) { if (0 == depth) return node; var fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1)), fill = node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.empty, !0); return node.copy(fragment.append(fill)); }(result[result.length - 1], lastWrap.length)); var wrapped = withWrappers(node, wrap); result.push(wrapped), match = match.matchType(wrapped.type, wrapped.attrs), lastWrap = wrap; } } }), result) return { v: prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(result) }; }(d); if (returned) return returned.v; } return fragment; }(slice.content, $context), !0)).openStart || slice.openEnd) { for(var openStart = 0, openEnd = 0, node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating; openStart++, node = node.firstChild); for(var node$1 = slice.content.lastChild; openEnd < slice.openEnd && !node$1.type.spec.isolating; openEnd++, node$1 = node$1.lastChild); slice = closeSlice(slice, openStart, openEnd); } return view.someProp("transformPasted", function(f) { slice = f(slice); }), slice; } function withWrappers(node, wrap, from) { void 0 === from && (from = 0); for(var i = wrap.length - 1; i >= from; i--)node = wrap[i].create(null, prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(node)); return node; } function closeRange(fragment, side, from, to, depth, openEnd) { var node = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node.content; return depth < to - 1 && (inner = closeRange(inner, side, from, to, depth + 1, openEnd)), depth >= from && (inner = side < 0 ? node.contentMatchAt(0).fillBefore(inner, fragment.childCount > 1 || openEnd <= depth).append(inner) : inner.append(node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.empty, !0))), fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node.copy(inner)); } function closeSlice(slice, openStart, openEnd) { return openStart < slice.openStart && (slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice(closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd)), openEnd < slice.openEnd && (slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice(closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd)), slice; } // Trick from jQuery -- some elements must be wrapped in other // elements for innerHTML to work. I.e. if you do `div.innerHTML = // "<td>..</td>"` the table cells are ignored. var wrapMap = { thead: [ "table" ], tbody: [ "table" ], tfoot: [ "table" ], caption: [ "table" ], colgroup: [ "table" ], col: [ "table", "colgroup" ], tr: [ "table", "tbody" ], td: [ "table", "tbody", "tr" ], th: [ "table", "tbody", "tr" ] }, _detachedDoc = null; function detachedDoc() { return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title")); } var observeOptions = { childList: !0, characterData: !0, characterDataOldValue: !0, attributes: !0, attributeOldValue: !0, subtree: !0 }, useCharData = result.ie && result.ie_version <= 11, SelectionState = function() { this.anchorNode = this.anchorOffset = this.focusNode = this.focusOffset = null; }; SelectionState.prototype.set = function(sel) { this.anchorNode = sel.anchorNode, this.anchorOffset = sel.anchorOffset, this.focusNode = sel.focusNode, this.focusOffset = sel.focusOffset; }, SelectionState.prototype.eq = function(sel) { return sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset && sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset; }; var DOMObserver = function(view, handleDOMChange) { var this$1 = this; this.view = view, this.handleDOMChange = handleDOMChange, this.queue = [], this.flushingSoon = -1, this.observer = window.MutationObserver && new window.MutationObserver(function(mutations) { for(var i = 0; i < mutations.length; i++)this$1.queue.push(mutations[i]); // IE11 will sometimes (on backspacing out a single character // text node after a BR node) call the observer callback // before actually updating the DOM, which will cause // ProseMirror to miss the change (see #930) result.ie && result.ie_version <= 11 && mutations.some(function(m) { return "childList" == m.type && m.removedNodes.length || "characterData" == m.type && m.oldValue.length > m.target.nodeValue.length; }) ? this$1.flushSoon() : this$1.flush(); }), this.currentSelection = new SelectionState(), useCharData && (this.onCharData = function(e) { this$1.queue.push({ target: e.target, type: "characterData", oldValue: e.prevValue }), this$1.flushSoon(); }), this.onSelectionChange = this.onSelectionChange.bind(this), this.suppressingSelectionUpdates = !1; }; DOMObserver.prototype.flushSoon = function() { var this$1 = this; this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(function() { this$1.flushingSoon = -1, this$1.flush(); }, 20)); }, DOMObserver.prototype.forceFlush = function() { this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush()); }, DOMObserver.prototype.start = function() { this.observer && this.observer.observe(this.view.dom, observeOptions), useCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection(); }, DOMObserver.prototype.stop = function() { var this$1 = this; if (this.observer) { var take = this.observer.takeRecords(); if (take.length) { for(var i = 0; i < take.length; i++)this.queue.push(take[i]); window.setTimeout(function() { return this$1.flush(); }, 20); } this.observer.disconnect(); } useCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection(); }, DOMObserver.prototype.connectSelection = function() { this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange); }, DOMObserver.prototype.disconnectSelection = function() { this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange); }, DOMObserver.prototype.suppressSelectionUpdates = function() { var this$1 = this; this.suppressingSelectionUpdates = !0, setTimeout(function() { return this$1.suppressingSelectionUpdates = !1; }, 50); }, DOMObserver.prototype.onSelectionChange = function() { var view; if ((!(view = this.view).editable || view.root.activeElement == view.dom) && hasSelection(view)) { if (this.suppressingSelectionUpdates) return selectionToDOM(this.view); // Deletions on IE11 fire their events in the wrong order, giving // us a selection change event before the DOM changes are // reported. if (result.ie && result.ie_version <= 11 && !this.view.state.selection.empty) { var sel = this.view.root.getSelection(); // Selection.isCollapsed isn't reliable on IE if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset)) return this.flushSoon(); } this.flush(); } }, DOMObserver.prototype.setCurSelection = function() { this.currentSelection.set(this.view.root.getSelection()); }, DOMObserver.prototype.ignoreSelectionChange = function(sel) { if (0 == sel.rangeCount) return !0; var container = sel.getRangeAt(0).commonAncestorContainer, desc = this.view.docView.nearestDesc(container); if (desc && desc.ignoreMutation({ type: "selection", target: 3 == container.nodeType ? container.parentNode : container })) return this.setCurSelection(), !0; }, DOMObserver.prototype.flush = function() { if (this.view.docView && !(this.flushingSoon > -1)) { var view, mutations = this.observer ? this.observer.takeRecords() : []; this.queue.length && (mutations = this.queue.concat(mutations), this.queue.length = 0); var sel = this.view.root.getSelection(), newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel), from = -1, to = -1, typeOver = !1, added = []; if (this.view.editable) for(var i = 0; i < mutations.length; i++){ var result$1 = this.registerMutation(mutations[i], added); result$1 && (from = from < 0 ? result$1.from : Math.min(result$1.from, from), to = to < 0 ? result$1.to : Math.max(result$1.to, to), result$1.typeOver && (typeOver = !0)); } if (result.gecko && added.length > 1) { var brs = added.filter(function(n) { return "BR" == n.nodeName; }); if (2 == brs.length) { var a = brs[0], b = brs[1]; a.parentNode && a.parentNode.parentNode == b.parentNode ? b.remove() : a.remove(); } } (from > -1 || newSel) && (from > -1 && (this.view.docView.markDirty(from, to), view = this.view, cssChecked || (cssChecked = !0, "normal" == getComputedStyle(view.dom).whiteSpace && console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."))), this.handleDOMChange(from, to, typeOver, added), this.view.docView.dirty ? this.view.updateState(this.view.state) : this.currentSelection.eq(sel) || selectionToDOM(this.view), this.currentSelection.set(sel)); } }, DOMObserver.prototype.registerMutation = function(mut, added) { // Ignore mutations inside nodes that were already noted as inserted if (added.indexOf(mut.target) > -1) return null; var desc = this.view.docView.nearestDesc(mut.target); if ("attributes" == mut.type && (desc == this.view.docView || "contenteditable" == mut.attributeName || // Firefox sometimes fires spurious events for null/empty styles "style" == mut.attributeName && !mut.oldValue && !mut.target.getAttribute("style")) || !desc || desc.ignoreMutation(mut)) return null; if ("childList" == mut.type) { for(var i = 0; i < mut.addedNodes.length; i++)added.push(mut.addedNodes[i]); if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return { from: desc.posBefore, to: desc.posAfter }; var prev = mut.previousSibling, next = mut.nextSibling; if (result.ie && result.ie_version <= 11 && mut.addedNodes.length) // IE11 gives us incorrect next/prev siblings for some // insertions, so if there are added nodes, recompute those for(var i$1 = 0; i$1 < mut.addedNodes.length; i$1++){ var ref = mut.addedNodes[i$1], previousSibling = ref.previousSibling, nextSibling = ref.nextSibling; (!previousSibling || 0 > Array.prototype.indexOf.call(mut.addedNodes, previousSibling)) && (prev = previousSibling), (!nextSibling || 0 > Array.prototype.indexOf.call(mut.addedNodes, nextSibling)) && (next = nextSibling); } var fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0, from = desc.localPosFromDOM(mut.target, fromOffset, -1), toOffset = next && next.parentNode == mut.target ? domIndex(next) : mut.target.childNodes.length; return { from: from, to: desc.localPosFromDOM(mut.target, toOffset, 1) }; } return "attributes" == mut.type ? { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border } : { from: desc.posAtStart, to: desc.posAtEnd, // An event was generated for a text change that didn't change // any text. Mark the dom change to fall back to assuming the // selection was typed over with an identical value if it can't // find another change. typeOver: mut.target.nodeValue == mut.oldValue }; }; var cssChecked = !1, handlers = {}, editHandlers = {}; function setSelectionOrigin(view, origin) { view.lastSelectionOrigin = origin, view.lastSelectionTime = Date.now(); } function ensureListeners(view) { view.someProp("handleDOMEvents", function(currentHandlers) { for(var type in currentHandlers)view.eventHandlers[type] || view.dom.addEventListener(type, view.eventHandlers[type] = function(event) { return runCustomHandler(view, event); }); }); } function runCustomHandler(view, event) { return view.someProp("handleDOMEvents", function(handlers) { var handler = handlers[event.type]; return !!handler && (handler(view, event) || event.defaultPrevented); }); } function eventCoords(event) { return { left: event.clientX, top: event.clientY }; } function runHandlerOnContext(view, propName, pos, inside, event) { if (-1 == inside) return !1; for(var $pos = view.state.doc.resolve(inside), loop = function(i) { if (view.someProp(propName, function(f) { return i > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i), event, !0) : f(view, pos, $pos.node(i), $pos.before(i), event, !1); })) return { v: !0 }; }, i = $pos.depth + 1; i > 0; i--){ var returned = loop(i); if (returned) return returned.v; } return !1; } function updateSelection(view, selection, origin) { view.focused || view.focus(); var tr = view.state.tr.setSelection(selection); "pointer" == origin && tr.setMeta("pointer", !0), view.dispatch(tr); } editHandlers.keydown = function(view, event) { if (view.shiftKey = 16 == event.keyCode || event.shiftKey, !inOrNearComposition(view, event)) { // On iOS, if we preventDefault enter key presses, the virtual // keyboard gets confused. So the hack here is to set a flag that // makes the DOM change code recognize that what just happens should // be replaced by whatever the Enter key handlers do. if (229 != event.keyCode && view.domObserver.forceFlush(), view.lastKeyCode = event.keyCode, view.lastKeyCodeTime = Date.now(), !result.ios || 13 != event.keyCode || event.ctrlKey || event.altKey || event.metaKey) { var result1, code, mods; view.someProp("handleKeyDown", function(f) { return f(view, event); }) || (code = event.keyCode, result1 = "", event.ctrlKey && (result1 += "c"), event.metaKey && (result1 += "m"), event.altKey && (result1 += "a"), event.shiftKey && (result1 += "s"), mods = result1, 8 == code || result.mac && 72 == code && "c" == mods ? stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view) : 46 == code || result.mac && 68 == code && "c" == mods ? stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view) : 13 == code || 27 == code || (37 == code ? selectHorizontally(view, -1, mods) || skipIgnoredNodesLeft(view) : 39 == code ? selectHorizontally(view, 1, mods) || skipIgnoredNodesRight(view) : 38 == code ? selectVertically(view, -1, mods) || skipIgnoredNodesLeft(view) : 40 == code ? // Issue #867 / #1090 / https://bugs.chromium.org/p/chromium/issues/detail?id=903821 // In which Safari (and at some point in the past, Chrome) does really // wrong things when the down arrow is pressed when the cursor is // directly at the start of a textblock and has an uneditable node // after it function(view) { if (result.safari && !(view.state.selection.$head.parentOffset > 0)) { var ref = view.root.getSelection(), focusNode = ref.focusNode, focusOffset = ref.focusOffset; if (focusNode && 1 == focusNode.nodeType && 0 == focusOffset && focusNode.firstChild && "false" == focusNode.firstChild.contentEditable) { var child = focusNode.firstChild; switchEditable(view, child, !0), setTimeout(function() { return switchEditable(view, child, !1); }, 20); } } }(view) || selectVertically(view, 1, mods) || skipIgnoredNodesRight(view) : mods == (result.mac ? "m" : "c") && (66 == code || 73 == code || 89 == code || 90 == code))) ? event.preventDefault() : setSelectionOrigin(view, "key"); } else { var now = Date.now(); view.lastIOSEnter = now, view.lastIOSEnterFallbackTimeout = setTimeout(function() { view.lastIOSEnter == now && (view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(13, "Enter")); }), view.lastIOSEnter = 0); }, 200); } } }, editHandlers.keyup = function(view, e) { 16 == e.keyCode && (view.shiftKey = !1); }, editHandlers.keypress = function(view, event) { if (!inOrNearComposition(view, event) && event.charCode && (!event.ctrlKey || event.altKey) && (!result.mac || !event.metaKey)) { if (view.someProp("handleKeyPress", function(f) { return f(view, event); })) { event.preventDefault(); return; } var sel = view.state.selection; if (!(sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection) || !sel.$from.sameParent(sel.$to)) { var text = String.fromCharCode(event.charCode); view.someProp("handleTextInput", function(f) { return f(view, sel.$from.pos, sel.$to.pos, text); }) || view.dispatch(view.state.tr.insertText(text).scrollIntoView()), event.preventDefault(); } } }; var selectNodeModifier = result.mac ? "metaKey" : "ctrlKey"; handlers.mousedown = function(view, event) { view.shiftKey = event.shiftKey; var click, dx, dy, flushed = endComposition(view), now = Date.now(), type = "singleClick"; now - view.lastClick.time < 500 && (dx = (click = view.lastClick).x - event.clientX) * dx + (dy = click.y - event.clientY) * dy < 100 && !event[selectNodeModifier] && ("singleClick" == view.lastClick.type ? type = "doubleClick" : "doubleClick" == view.lastClick.type && (type = "tripleClick")), view.lastClick = { time: now, x: event.clientX, y: event.clientY, type: type }; var pos = view.posAtCoords(eventCoords(event)); pos && ("singleClick" == type ? (view.mouseDown && view.mouseDown.done(), view.mouseDown = new MouseDown(view, pos, event, flushed)) : ("doubleClick" == type ? function(view, pos, inside, event) { return runHandlerOnContext(view, "handleDoubleClickOn", pos, inside, event) || view.someProp("handleDoubleClick", function(f) { return f(view, pos, event); }); } : function(view, pos, inside, event) { return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) || view.someProp("handleTripleClick", function(f) { return f(view, pos, event); }) || function(view, inside, event) { if (0 != event.button) return !1; var doc = view.state.doc; if (-1 == inside) return !!doc.inlineContent && (updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.create(doc, 0, doc.content.size), "pointer"), !0); for(var $pos = doc.resolve(inside), i = $pos.depth + 1; i > 0; i--){ var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i), nodePos = $pos.before(i); if (node.inlineContent) updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection.create(doc, nodePos + 1, nodePos + 1 + node.content.size), "pointer"); else { if (!prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(node)) continue; updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create(doc, nodePos), "pointer"); } return !0; } }(view, inside, event); })(view, pos.pos, pos.inside, event) ? event.preventDefault() : setSelectionOrigin(view, "pointer")); }; var MouseDown = function(view, pos, event, flushed) { var targetNode, targetPos, this$1 = this; if (this.view = view, this.startDoc = view.state.doc, this.pos = pos, this.event = event, this.flushed = flushed, this.selectNode = event[selectNodeModifier], this.allowDefault = event.shiftKey, this.delayedSelectionSync = !1, pos.inside > -1) targetNode = view.state.doc.nodeAt(pos.inside), targetPos = pos.inside; else { var $pos = view.state.doc.resolve(pos.pos); targetNode = $pos.parent, targetPos = $pos.depth ? $pos.before() : 0; } this.mightDrag = null; var target = flushed ? null : event.target, targetDesc = target ? view.docView.nearestDesc(target, !0) : null; this.target = targetDesc ? targetDesc.dom : null; var selection = view.state.selection; (0 == event.button && targetNode.type.spec.draggable && !1 !== targetNode.type.spec.selectable || selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && selection.from <= targetPos && selection.to > targetPos) && (this.mightDrag = { node: targetNode, pos: targetPos, addAttr: this.target && !this.target.draggable, setUneditable: this.target && result.gecko && !this.target.hasAttribute("contentEditable") }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(function() { this$1.view.mouseDown == this$1 && this$1.target.setAttribute("contentEditable", "false"); }, 20), this.view.domObserver.start()), view.root.addEventListener("mouseup", this.up = this.up.bind(this)), view.root.addEventListener("mousemove", this.move = this.move.bind(this)), setSelectionOrigin(view, "pointer"); }; function inOrNearComposition(view, event) { return !!view.composing || !!(result.safari && 500 > Math.abs(event.timeStamp - view.compositionEndedAt)) && (view.compositionEndedAt = -200000000, !0); } MouseDown.prototype.done = function() { var this$1 = this; this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(function() { return selectionToDOM(this$1.view); }), this.view.mouseDown = null; }, MouseDown.prototype.up = function(event) { if (this.done(), this.view.dom.contains(3 == event.target.nodeType ? event.target.parentNode : event.target)) { var view, pos, inside, selectNode, pos1 = this.pos; (this.view.state.doc != this.startDoc && (pos1 = this.view.posAtCoords(eventCoords(event))), this.allowDefault || !pos1) ? setSelectionOrigin(this.view, "pointer") : (view = this.view, pos = pos1.pos, inside = pos1.inside, selectNode = this.selectNode, runHandlerOnContext(view, "handleClickOn", pos, inside, event) || view.someProp("handleClick", function(f) { return f(view, pos, event); }) || (selectNode ? function(view, inside) { if (-1 == inside) return !1; var selectedNode, selectAt, sel = view.state.selection; sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection && (selectedNode = sel.node); for(var $pos = view.state.doc.resolve(inside), i = $pos.depth + 1; i > 0; i--){ var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i); if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(node)) { selectAt = selectedNode && sel.$from.depth > 0 && i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos ? $pos.before(sel.$from.depth) : $pos.before(i); break; } } return null != selectAt && (updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create(view.state.doc, selectAt), "pointer"), !0); }(view, inside) : function(view, inside) { if (-1 == inside) return !1; var $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter; return !!(node && node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(node)) && (updateSelection(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection($pos), "pointer"), !0); }(view, inside))) ? event.preventDefault() : 0 == event.button && (this.flushed || // Safari ignores clicks on draggable elements result.safari && this.mightDrag && !this.mightDrag.node.isAtom || // Chrome will sometimes treat a node selection as a // cursor, but still report that the node is selected // when asked through getSelection. You'll then get a // situation where clicking at the point where that // (hidden) cursor is doesn't change the selection, and // thus doesn't get a reaction from ProseMirror. This // works around that. result.chrome && !(this.view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection) && 2 >= Math.min(Math.abs(pos1.pos - this.view.state.selection.from), Math.abs(pos1.pos - this.view.state.selection.to))) ? (updateSelection(this.view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.near(this.view.state.doc.resolve(pos1.pos)), "pointer"), event.preventDefault()) : setSelectionOrigin(this.view, "pointer"); } }, MouseDown.prototype.move = function(event) { !this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4) && (this.allowDefault = !0), setSelectionOrigin(this.view, "pointer"), 0 == event.buttons && this.done(); }, handlers.touchdown = function(view) { endComposition(view), setSelectionOrigin(view, "pointer"); }, handlers.contextmenu = function(view) { return endComposition(view); }; // Drop active composition after 5 seconds of inactivity on Android var timeoutComposition = result.android ? 5000 : -1; function scheduleComposeEnd(view, delay) { clearTimeout(view.composingTimeout), delay > -1 && (view.composingTimeout = setTimeout(function() { return endComposition(view); }, delay)); } function clearComposition(view) { var event; for(view.composing && (view.composing = !1, (event = document.createEvent("Event")).initEvent("event", !0, !0), view.compositionEndedAt = event.timeStamp); view.compositionNodes.length > 0;)view.compositionNodes.pop().markParentsDirty(); } function endComposition(view, forceUpdate) { if (view.domObserver.forceFlush(), clearComposition(view), forceUpdate || view.docView.dirty) { var sel = selectionFromDOM(view); return sel && !sel.eq(view.state.selection) ? view.dispatch(view.state.tr.setSelection(sel)) : view.updateState(view.state), !0; } return !1; } editHandlers.compositionstart = editHandlers.compositionupdate = function(view) { if (!view.composing) { view.domObserver.flush(); var state = view.state, $pos = state.selection.$from; if (state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function(m) { return !1 === m.type.spec.inclusive; }))) // Need to wrap the cursor in mark nodes different from the ones in the DOM context view.markCursor = view.state.storedMarks || $pos.marks(), endComposition(view, !0), view.markCursor = null; else // In firefox, if the cursor is after but outside a marked node, // the inserted text won't inherit the marks. So this moves it // inside if necessary. if (endComposition(view), result.gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) for(var sel = view.root.getSelection(), node = sel.focusNode, offset = sel.focusOffset; node && 1 == node.nodeType && 0 != offset;){ var before = offset < 0 ? node.lastChild : node.childNodes[offset - 1]; if (!before) break; if (3 == before.nodeType) { sel.collapse(before, before.nodeValue.length); break; } node = before, offset = -1; } view.composing = !0; } scheduleComposeEnd(view, timeoutComposition); }, editHandlers.compositionend = function(view, event) { view.composing && (view.composing = !1, view.compositionEndedAt = event.timeStamp, scheduleComposeEnd(view, 20)); }; // This is very crude, but unfortunately both these browsers _pretend_ // that they have a clipboard API—all the objects and methods are // there, they just don't work, and they are hard to test. var brokenClipboardAPI = result.ie && result.ie_version < 15 || result.ios && result.webkit_version < 604; function doPaste(view, text, html, e) { var slice = parseFromClipboard(view, text, html, view.shiftKey, view.state.selection.$from); if (view.someProp("handlePaste", function(f) { return f(view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice.empty); })) return !0; if (!slice) return !1; var singleNode = 0 == slice.openStart && 0 == slice.openEnd && 1 == slice.content.childCount ? slice.content.firstChild : null, tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, view.shiftKey) : view.state.tr.replaceSelection(slice); return view.dispatch(tr.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0; } handlers.copy = editHandlers.cut = function(view, e) { var sel = view.state.selection, cut = "cut" == e.type; if (!sel.empty) { // IE and Edge's clipboard interface is completely broken var data = brokenClipboardAPI ? null : e.clipboardData, ref = serializeForClipboard(view, sel.content()), dom = ref.dom, text = ref.text; data ? (e.preventDefault(), data.clearData(), data.setData("text/html", dom.innerHTML), data.setData("text/plain", text)) : function(view, dom) { // The extra wrapper is somehow necessary on IE/Edge to prevent the // content from being mangled when it is put onto the clipboard if (view.dom.parentNode) { var wrap = view.dom.parentNode.appendChild(document.createElement("div")); wrap.appendChild(dom), wrap.style.cssText = "position: fixed; left: -10000px; top: 10px"; var sel = getSelection(), range = document.createRange(); range.selectNodeContents(dom), // Done because IE will fire a selectionchange moving the selection // to its start when removeAllRanges is called and the editor still // has focus (which will mess up the editor's selection state). view.dom.blur(), sel.removeAllRanges(), sel.addRange(range), setTimeout(function() { wrap.parentNode && wrap.parentNode.removeChild(wrap), view.focus(); }, 50); } }(view, dom), cut && view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut")); } }, editHandlers.paste = function(view, e) { var data = brokenClipboardAPI ? null : e.clipboardData; data && doPaste(view, data.getData("text/plain"), data.getData("text/html"), e) ? e.preventDefault() : function(view, e) { if (view.dom.parentNode) { var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code, target = view.dom.parentNode.appendChild(document.createElement(plainText ? "textarea" : "div")); plainText || (target.contentEditable = "true"), target.style.cssText = "position: fixed; left: -10000px; top: 10px", target.focus(), setTimeout(function() { view.focus(), target.parentNode && target.parentNode.removeChild(target), plainText ? doPaste(view, target.value, null, e) : doPaste(view, target.textContent, target.innerHTML, e); }, 50); } }(view, e); }; var Dragging = function(slice, move) { this.slice = slice, this.move = move; }, dragCopyModifier = result.mac ? "altKey" : "ctrlKey"; // Make sure all handlers get registered for(var prop in handlers.dragstart = function(view, e) { var mouseDown = view.mouseDown; if (mouseDown && mouseDown.done(), e.dataTransfer) { var sel = view.state.selection, pos = sel.empty ? null : view.posAtCoords(eventCoords(e)); if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ? sel.to - 1 : sel.to)) ; else if (mouseDown && mouseDown.mightDrag) view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos))); else if (e.target && 1 == e.target.nodeType) { var desc = view.docView.nearestDesc(e.target, !0); desc && desc.node.type.spec.draggable && desc != view.docView && view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.create(view.state.doc, desc.posBefore))); } var slice = view.state.selection.content(), ref = serializeForClipboard(view, slice), dom = ref.dom, text = ref.text; e.dataTransfer.clearData(), e.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML), // See https://github.com/ProseMirror/prosemirror/issues/1156 e.dataTransfer.effectAllowed = "copyMove", brokenClipboardAPI || e.dataTransfer.setData("text/plain", text), view.dragging = new Dragging(slice, !e[dragCopyModifier]); } }, handlers.dragend = function(view) { var dragging = view.dragging; window.setTimeout(function() { view.dragging == dragging && (view.dragging = null); }, 50); }, editHandlers.dragover = editHandlers.dragenter = function(_, e) { return e.preventDefault(); }, editHandlers.drop = function(view, e) { var dragging = view.dragging; if (view.dragging = null, e.dataTransfer) { var eventPos = view.posAtCoords(eventCoords(e)); if (eventPos) { var $mouse = view.state.doc.resolve(eventPos.pos); if ($mouse) { var slice = dragging && dragging.slice; slice ? view.someProp("transformPasted", function(f) { slice = f(slice); }) : slice = parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? "Text" : "text/plain"), brokenClipboardAPI ? null : e.dataTransfer.getData("text/html"), !1, $mouse); var move = dragging && !e[dragCopyModifier]; if (view.someProp("handleDrop", function(f) { return f(view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Slice.empty, move); })) { e.preventDefault(); return; } if (slice) { e.preventDefault(); var insertPos = slice ? (0, prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ /* .dropPoint */ .nj)(view.state.doc, $mouse.pos, slice) : $mouse.pos; null == insertPos && (insertPos = $mouse.pos); var tr = view.state.tr; move && tr.deleteSelection(); var pos = tr.mapping.map(insertPos), isNode = 0 == slice.openStart && 0 == slice.openEnd && 1 == slice.content.childCount, beforeInsert = tr.doc; if (isNode ? tr.replaceRangeWith(pos, pos, slice.content.firstChild) : tr.replaceRange(pos, pos, slice), !tr.doc.eq(beforeInsert)) { var $pos = tr.doc.resolve(pos); if (isNode && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection.isSelectable(slice.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) tr.setSelection(new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection($pos)); else { var end = tr.mapping.map(insertPos); tr.mapping.maps[tr.mapping.maps.length - 1].forEach(function(_from, _to, _newFrom, newTo) { return end = newTo; }), tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end))); } view.focus(), view.dispatch(tr.setMeta("uiEvent", "drop")); } } } } } }, handlers.focus = function(view) { view.focused || (view.domObserver.stop(), view.dom.classList.add("ProseMirror-focused"), view.domObserver.start(), view.focused = !0, setTimeout(function() { view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.root.getSelection()) && selectionToDOM(view); }, 20)); }, handlers.blur = function(view, e) { view.focused && (view.domObserver.stop(), view.dom.classList.remove("ProseMirror-focused"), view.domObserver.start(), e.relatedTarget && view.dom.contains(e.relatedTarget) && view.domObserver.currentSelection.set({}), view.focused = !1); }, handlers.beforeinput = function(view, event) { // We should probably do more with beforeinput events, but support // is so spotty that I'm still waiting to see where they are going. // Very specific hack to deal with backspace sometimes failing on // Chrome Android when after an uneditable node. if (result.chrome && result.android && "deleteContentBackward" == event.inputType) { var domChangeCount = view.domChangeCount; setTimeout(function() { if (view.domChangeCount == domChangeCount && (// This bug tends to close the virtual keyboard, so we refocus view.dom.blur(), view.focus(), !view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(8, "Backspace")); }))) { var $cursor = view.state.selection.$cursor; $cursor && $cursor.pos > 0 && view.dispatch(view.state.tr.delete($cursor.pos - 1, $cursor.pos).scrollIntoView()); } // Event already had some effect }, 50); } }, editHandlers)handlers[prop] = editHandlers[prop]; function compareObjs(a, b) { if (a == b) return !0; for(var p in a)if (a[p] !== b[p]) return !1; for(var p$1 in b)if (!(p$1 in a)) return !1; return !0; } var WidgetType = function(toDOM, spec) { this.spec = spec || noSpec, this.side = this.spec.side || 0, this.toDOM = toDOM; }; WidgetType.prototype.map = function(mapping, span, offset, oldOffset) { var ref = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1), pos = ref.pos; return ref.deleted ? null : new Decoration(pos - offset, pos - offset, this); }, WidgetType.prototype.valid = function() { return !0; }, WidgetType.prototype.eq = function(other) { return this == other || other instanceof WidgetType && (this.spec.key && this.spec.key == other.spec.key || this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)); }; var InlineType = function(attrs, spec) { this.spec = spec || noSpec, this.attrs = attrs; }; InlineType.prototype.map = function(mapping, span, offset, oldOffset) { var from = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset, to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset; return from >= to ? null : new Decoration(from, to, this); }, InlineType.prototype.valid = function(_, span) { return span.from < span.to; }, InlineType.prototype.eq = function(other) { return this == other || other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec); }, InlineType.is = function(span) { return span.type instanceof InlineType; }; var NodeType = function(attrs, spec) { this.spec = spec || noSpec, this.attrs = attrs; }; NodeType.prototype.map = function(mapping, span, offset, oldOffset) { var from = mapping.mapResult(span.from + oldOffset, 1); if (from.deleted) return null; var to = mapping.mapResult(span.to + oldOffset, -1); return to.deleted || to.pos <= from.pos ? null : new Decoration(from.pos - offset, to.pos - offset, this); }, NodeType.prototype.valid = function(node, span) { var child, ref = node.content.findIndex(span.from), index = ref.index, offset = ref.offset; return offset == span.from && !(child = node.child(index)).isText && offset + child.nodeSize == span.to; }, NodeType.prototype.eq = function(other) { return this == other || other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec); }; // ::- Decoration objects can be provided to the view through the // [`decorations` prop](#view.EditorProps.decorations). They come in // several variants—see the static members of this class for details. var Decoration = function(from, to, type) { // :: number // The start position of the decoration. this.from = from, // :: number // The end position. Will be the same as `from` for [widget // decorations](#view.Decoration^widget). this.to = to, this.type = type; }, prototypeAccessors$1 = { spec: { configurable: !0 }, inline: { configurable: !0 } }; Decoration.prototype.copy = function(from, to) { return new Decoration(from, to, this.type); }, Decoration.prototype.eq = function(other, offset) { return void 0 === offset && (offset = 0), this.type.eq(other.type) && this.from + offset == other.from && this.to + offset == other.to; }, Decoration.prototype.map = function(mapping, offset, oldOffset) { return this.type.map(mapping, this, offset, oldOffset); }, // :: (number, union<(view: EditorView, getPos: () → number) → dom.Node, dom.Node>, ?Object) → Decoration // Creates a widget decoration, which is a DOM node that's shown in // the document at the given position. It is recommended that you // delay rendering the widget by passing a function that will be // called when the widget is actually drawn in a view, but you can // also directly pass a DOM node. `getPos` can be used to find the // widget's current document position. // // spec::- These options are supported: // // side:: ?number // Controls which side of the document position this widget is // associated with. When negative, it is drawn before a cursor // at its position, and content inserted at that position ends // up after the widget. When zero (the default) or positive, the // widget is drawn after the cursor and content inserted there // ends up before the widget. // // When there are multiple widgets at a given position, their // `side` values determine the order in which they appear. Those // with lower values appear first. The ordering of widgets with // the same `side` value is unspecified. // // When `marks` is null, `side` also determines the marks that // the widget is wrapped in—those of the node before when // negative, those of the node after when positive. // // marks:: ?[Mark] // The precise set of marks to draw around the widget. // // stopEvent:: ?(event: dom.Event) → bool // Can be used to control which DOM events, when they bubble out // of this widget, the editor view should ignore. // // ignoreSelection:: ?bool // When set (defaults to false), selection changes inside the // widget are ignored, and don't cause ProseMirror to try and // re-sync the selection with its selection state. // // key:: ?string // When comparing decorations of this type (in order to decide // whether it needs to be redrawn), ProseMirror will by default // compare the widget DOM node by identity. If you pass a key, // that key will be compared instead, which can be useful when // you generate decorations on the fly and don't want to store // and reuse DOM nodes. Make sure that any widgets with the same // key are interchangeable—if widgets differ in, for example, // the behavior of some event handler, they should get // different keys. Decoration.widget = function(pos, toDOM, spec) { return new Decoration(pos, pos, new WidgetType(toDOM, spec)); }, // :: (number, number, DecorationAttrs, ?Object) → Decoration // Creates an inline decoration, which adds the given attributes to // each inline node between `from` and `to`. // // spec::- These options are recognized: // // inclusiveStart:: ?bool // Determines how the left side of the decoration is // [mapped](#transform.Position_Mapping) when content is // inserted directly at that position. By default, the decoration // won't include the new content, but you can set this to `true` // to make it inclusive. // // inclusiveEnd:: ?bool // Determines how the right side of the decoration is mapped. // See // [`inclusiveStart`](#view.Decoration^inline^spec.inclusiveStart). Decoration.inline = function(from, to, attrs, spec) { return new Decoration(from, to, new InlineType(attrs, spec)); }, // :: (number, number, DecorationAttrs, ?Object) → Decoration // Creates a node decoration. `from` and `to` should point precisely // before and after a node in the document. That node, and only that // node, will receive the given attributes. // // spec::- // // Optional information to store with the decoration. It // is also used when comparing decorators for equality. Decoration.node = function(from, to, attrs, spec) { return new Decoration(from, to, new NodeType(attrs, spec)); }, // :: Object // The spec provided when creating this decoration. Can be useful // if you've stored extra information in that object. prototypeAccessors$1.spec.get = function() { return this.type.spec; }, prototypeAccessors$1.inline.get = function() { return this.type instanceof InlineType; }, Object.defineProperties(Decoration.prototype, prototypeAccessors$1); // DecorationAttrs:: interface // A set of attributes to add to a decorated node. Most properties // simply directly correspond to DOM attributes of the same name, // which will be set to the property's value. These are exceptions: // // class:: ?string // A CSS class name or a space-separated set of class names to be // _added_ to the classes that the node already had. // // style:: ?string // A string of CSS to be _added_ to the node's existing `style` property. // // nodeName:: ?string // When non-null, the target node is wrapped in a DOM element of // this type (and the other attributes are applied to this element). var none = [], noSpec = {}, DecorationSet = function(local, children) { this.local = local && local.length ? local : none, this.children = children && children.length ? children : none; }; // :: (Node, [Decoration]) → DecorationSet // Create a set of decorations, using the structure of the given // document. DecorationSet.create = function(doc, decorations) { return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty; }, // :: (?number, ?number, ?(spec: Object) → bool) → [Decoration] // Find all decorations in this set which touch the given range // (including decorations that start or end directly at the // boundaries) and match the given predicate on their spec. When // `start` and `end` are omitted, all decorations in the set are // considered. When `predicate` isn't given, all decorations are // assumed to match. DecorationSet.prototype.find = function(start, end, predicate) { var result = []; return this.findInner(null == start ? 0 : start, null == end ? 1e9 : end, result, 0, predicate), result; }, DecorationSet.prototype.findInner = function(start, end, result, offset, predicate) { for(var i = 0; i < this.local.length; i++){ var span = this.local[i]; span.from <= end && span.to >= start && (!predicate || predicate(span.spec)) && result.push(span.copy(span.from + offset, span.to + offset)); } for(var i$1 = 0; i$1 < this.children.length; i$1 += 3)if (this.children[i$1] < end && this.children[i$1 + 1] > start) { var childOff = this.children[i$1] + 1; this.children[i$1 + 2].findInner(start - childOff, end - childOff, result, offset + childOff, predicate); } }, // :: (Mapping, Node, ?Object) → DecorationSet // Map the set of decorations in response to a change in the // document. // // options::- An optional set of options. // // onRemove:: ?(decorationSpec: Object) // When given, this function will be called for each decoration // that gets dropped as a result of the mapping, passing the // spec of that decoration. DecorationSet.prototype.map = function(mapping, doc, options) { return this == empty || 0 == mapping.maps.length ? this : this.mapInner(mapping, doc, 0, 0, options || noSpec); }, DecorationSet.prototype.mapInner = function(mapping, node, offset, oldOffset, options) { for(var newLocal, i = 0; i < this.local.length; i++){ var mapped = this.local[i].map(mapping, offset, oldOffset); mapped && mapped.type.valid(node, mapped) ? (newLocal || (newLocal = [])).push(mapped) : options.onRemove && options.onRemove(this.local[i].spec); } return this.children.length ? function(oldChildren, newLocal, mapping, node, offset, oldOffset, options) { for(var children = oldChildren.slice(), shift = function(oldStart, oldEnd, newStart, newEnd) { for(var i = 0; i < children.length; i += 3){ var end = children[i + 1], dSize = void 0; -1 != end && !(oldStart > end + oldOffset) && (oldEnd >= children[i] + oldOffset ? children[i + 1] = -1 : newStart >= offset && (dSize = newEnd - newStart - (oldEnd - oldStart)) && (children[i] += dSize, children[i + 1] += dSize)); } }, i = 0; i < mapping.maps.length; i++)mapping.maps[i].forEach(shift); for(var mustRebuild = !1, i$1 = 0; i$1 < children.length; i$1 += 3)if (-1 == children[i$1 + 1]) { // Touched nodes var from = mapping.map(oldChildren[i$1] + oldOffset), fromLocal = from - offset; if (fromLocal < 0 || fromLocal >= node.content.size) { mustRebuild = !0; continue; } // Must read oldChildren because children was tagged with -1 var toLocal = mapping.map(oldChildren[i$1 + 1] + oldOffset, -1) - offset, ref = node.content.findIndex(fromLocal), index = ref.index, childOffset = ref.offset, childNode = node.maybeChild(index); if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) { var mapped = children[i$1 + 2].mapInner(mapping, childNode, from + 1, oldChildren[i$1] + oldOffset + 1, options); mapped != empty ? (children[i$1] = fromLocal, children[i$1 + 1] = toLocal, children[i$1 + 2] = mapped) : (children[i$1 + 1] = -2, mustRebuild = !0); } else mustRebuild = !0; } // Remaining children must be collected and rebuilt into the appropriate structure if (mustRebuild) { var built = buildTree(function(children, oldChildren, decorations, mapping, offset, oldOffset, options) { for(var i = 0; i < children.length; i += 3)-1 == children[i + 1] && // Gather all decorations from the remaining marked children function gather(set, oldOffset) { for(var i = 0; i < set.local.length; i++){ var mapped = set.local[i].map(mapping, offset, oldOffset); mapped ? decorations.push(mapped) : options.onRemove && options.onRemove(set.local[i].spec); } for(var i$1 = 0; i$1 < set.children.length; i$1 += 3)gather(set.children[i$1 + 2], set.children[i$1] + oldOffset + 1); }(children[i + 2], oldChildren[i] + oldOffset + 1); return decorations; }(children, oldChildren, newLocal || [], mapping, offset, oldOffset, options), node, 0, options); newLocal = built.local; for(var i$2 = 0; i$2 < children.length; i$2 += 3)children[i$2 + 1] < 0 && (children.splice(i$2, 3), i$2 -= 3); for(var i$3 = 0, j = 0; i$3 < built.children.length; i$3 += 3){ for(var from$1 = built.children[i$3]; j < children.length && children[j] < from$1;)j += 3; children.splice(j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2]); } } return new DecorationSet(newLocal && newLocal.sort(byPos), children); }(this.children, newLocal, mapping, node, offset, oldOffset, options) : newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty; }, // :: (Node, [Decoration]) → DecorationSet // Add the given array of decorations to the ones in the set, // producing a new set. Needs access to the current document to // create the appropriate tree structure. DecorationSet.prototype.add = function(doc, decorations) { return decorations.length ? this == empty ? DecorationSet.create(doc, decorations) : this.addInner(doc, decorations, 0) : this; }, DecorationSet.prototype.addInner = function(doc, decorations, offset) { var children, this$1 = this, childIndex = 0; doc.forEach(function(childNode, childOffset) { var found, baseOffset = childOffset + offset; if (found = takeSpansForNode(decorations, childNode, baseOffset)) { for(children || (children = this$1.children.slice()); childIndex < children.length && children[childIndex] < childOffset;)childIndex += 3; children[childIndex] == childOffset ? children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1) : children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec)), childIndex += 3; } }); for(var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset), i = 0; i < local.length; i++)local[i].type.valid(doc, local[i]) || local.splice(i--, 1); return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children); }, // :: ([Decoration]) → DecorationSet // Create a new set that contains the decorations in this set, minus // the ones in the given array. DecorationSet.prototype.remove = function(decorations) { return 0 == decorations.length || this == empty ? this : this.removeInner(decorations, 0); }, DecorationSet.prototype.removeInner = function(decorations, offset) { for(var children = this.children, local = this.local, i = 0; i < children.length; i += 3){ for(var found = void 0, from = children[i] + offset, to = children[i + 1] + offset, j = 0, span = void 0; j < decorations.length; j++)(span = decorations[j]) && span.from > from && span.to < to && (decorations[j] = null, (found || (found = [])).push(span)); if (found) { children == this.children && (children = this.children.slice()); var removed = children[i + 2].removeInner(found, from + 1); removed != empty ? children[i + 2] = removed : (children.splice(i, 3), i -= 3); } } if (local.length) { for(var i$1 = 0, span$1 = void 0; i$1 < decorations.length; i$1++)if (span$1 = decorations[i$1]) for(var j$1 = 0; j$1 < local.length; j$1++)local[j$1].eq(span$1, offset) && (local == this.local && (local = this.local.slice()), local.splice(j$1--, 1)); } return children == this.children && local == this.local ? this : local.length || children.length ? new DecorationSet(local, children) : empty; }, DecorationSet.prototype.forChild = function(offset, node) { if (this == empty) return this; if (node.isLeaf) return DecorationSet.empty; for(var child, local, i = 0; i < this.children.length; i += 3)if (this.children[i] >= offset) { this.children[i] == offset && (child = this.children[i + 2]); break; } for(var start = offset + 1, end = start + node.content.size, i$1 = 0; i$1 < this.local.length; i$1++){ var dec = this.local[i$1]; if (dec.from < end && dec.to > start && dec.type instanceof InlineType) { var from = Math.max(start, dec.from) - start, to = Math.min(end, dec.to) - start; from < to && (local || (local = [])).push(dec.copy(from, to)); } } if (local) { var localSet = new DecorationSet(local.sort(byPos)); return child ? new DecorationGroup([ localSet, child ]) : localSet; } return child || empty; }, DecorationSet.prototype.eq = function(other) { if (this == other) return !0; if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) return !1; for(var i = 0; i < this.local.length; i++)if (!this.local[i].eq(other.local[i])) return !1; for(var i$1 = 0; i$1 < this.children.length; i$1 += 3)if (this.children[i$1] != other.children[i$1] || this.children[i$1 + 1] != other.children[i$1 + 1] || !this.children[i$1 + 2].eq(other.children[i$1 + 2])) return !1; return !0; }, DecorationSet.prototype.locals = function(node) { return removeOverlap(this.localsInner(node)); }, DecorationSet.prototype.localsInner = function(node) { if (this == empty) return none; if (node.inlineContent || !this.local.some(InlineType.is)) return this.local; for(var result = [], i = 0; i < this.local.length; i++)this.local[i].type instanceof InlineType || result.push(this.local[i]); return result; }; // DecorationSource:: interface // An object that can [provide](#view.EditorProps.decorations) // decorations. Implemented by [`DecorationSet`](#view.DecorationSet), // and passed to [node views](#view.EditorProps.nodeViews). // // map:: (Mapping, Node) → DecorationSource // Map the set of decorations in response to a change in the // document. var empty = new DecorationSet(); // :: DecorationSet // The empty set of decorations. DecorationSet.empty = empty, DecorationSet.removeOverlap = removeOverlap; // :- An abstraction that allows the code dealing with decorations to // treat multiple DecorationSet objects as if it were a single object // with (a subset of) the same interface. var DecorationGroup = function(members) { this.members = members; }; function moveSpans(spans, offset) { if (!offset || !spans.length) return spans; for(var result = [], i = 0; i < spans.length; i++){ var span = spans[i]; result.push(new Decoration(span.from + offset, span.to + offset, span.type)); } return result; } function takeSpansForNode(spans, node, offset) { if (node.isLeaf) return null; for(var end = offset + node.nodeSize, found = null, i = 0, span = void 0; i < spans.length; i++)(span = spans[i]) && span.from > offset && span.to < end && ((found || (found = [])).push(span), spans[i] = null); return found; } function withoutNulls(array) { for(var result = [], i = 0; i < array.length; i++)null != array[i] && result.push(array[i]); return result; } // : ([Decoration], Node, number) → DecorationSet // Build up a tree that corresponds to a set of decorations. `offset` // is a base offset that should be subtracted from the `from` and `to` // positions in the spans (so that we don't have to allocate new spans // for recursive calls). function buildTree(spans, node, offset, options) { var children = [], hasNulls = !1; node.forEach(function(childNode, localStart) { var found = takeSpansForNode(spans, childNode, localStart + offset); if (found) { hasNulls = !0; var subtree = buildTree(found, childNode, offset + localStart + 1, options); subtree != empty && children.push(localStart, localStart + childNode.nodeSize, subtree); } }); for(var locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos), i = 0; i < locals.length; i++)locals[i].type.valid(node, locals[i]) || (options.onRemove && options.onRemove(locals[i].spec), locals.splice(i--, 1)); return locals.length || children.length ? new DecorationSet(locals, children) : empty; } // : (Decoration, Decoration) → number // Used to sort decorations so that ones with a low start position // come first, and within a set with the same start position, those // with an smaller end position come first. function byPos(a, b) { return a.from - b.from || a.to - b.to; } // : ([Decoration]) → [Decoration] // Scan a sorted array of decorations for partially overlapping spans, // and split those so that only fully overlapping spans are left (to // make subsequent rendering easier). Will return the input array if // no partially overlapping spans are found (the common case). function removeOverlap(spans) { for(var working = spans, i = 0; i < working.length - 1; i++){ var span = working[i]; if (span.from != span.to) for(var j = i + 1; j < working.length; j++){ var next = working[j]; if (next.from == span.from) { next.to != span.to && (working == spans && (working = spans.slice()), // Followed by a partially overlapping larger span. Split that // span. working[j] = next.copy(next.from, span.to), insertAhead(working, j + 1, next.copy(span.to, next.to))); continue; } next.from < span.to && (working == spans && (working = spans.slice()), // The end of this one overlaps with a subsequent span. Split // this one. working[i] = span.copy(span.from, next.from), insertAhead(working, j, span.copy(next.from, span.to))); break; } } return working; } function insertAhead(array, i, deco) { for(; i < array.length && byPos(deco, array[i]) > 0;)i++; array.splice(i, 0, deco); } // : (EditorView) → union<DecorationSet, DecorationGroup> // Get the decorations associated with the current props of a view. function viewDecorations(view) { var found = []; return view.someProp("decorations", function(f) { var result = f(view.state); result && result != empty && found.push(result); }), view.cursorWrapper && found.push(DecorationSet.create(view.state.doc, [ view.cursorWrapper.deco ])), DecorationGroup.from(found); } DecorationGroup.prototype.map = function(mapping, doc) { var mappedDecos = this.members.map(function(member) { return member.map(mapping, doc, noSpec); }); return DecorationGroup.from(mappedDecos); }, DecorationGroup.prototype.forChild = function(offset, child) { if (child.isLeaf) return DecorationSet.empty; for(var found = [], i = 0; i < this.members.length; i++){ var result = this.members[i].forChild(offset, child); result != empty && (result instanceof DecorationGroup ? found = found.concat(result.members) : found.push(result)); } return DecorationGroup.from(found); }, DecorationGroup.prototype.eq = function(other) { if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) return !1; for(var i = 0; i < this.members.length; i++)if (!this.members[i].eq(other.members[i])) return !1; return !0; }, DecorationGroup.prototype.locals = function(node) { for(var result, sorted = !0, i = 0; i < this.members.length; i++){ var locals = this.members[i].localsInner(node); if (locals.length) { if (result) { sorted && (result = result.slice(), sorted = !1); for(var j = 0; j < locals.length; j++)result.push(locals[j]); } else result = locals; } } return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none; }, // : ([DecorationSet]) → union<DecorationSet, DecorationGroup> // Create a group for the given array of decoration sets, or return // a single set when possible. DecorationGroup.from = function(members) { switch(members.length){ case 0: return empty; case 1: return members[0]; default: return new DecorationGroup(members); } }; // ::- An editor view manages the DOM structure that represents an // editable document. Its state and behavior are determined by its // [props](#view.DirectEditorProps). var EditorView = function(place, props) { this._props = props, // :: EditorState // The view's current [state](#state.EditorState). this.state = props.state, this.directPlugins = props.plugins || [], this.directPlugins.forEach(checkStateComponent), this.dispatch = this.dispatch.bind(this), this._root = null, this.focused = !1, // Kludge used to work around a Chrome bug this.trackWrites = null, // :: dom.Element // An editable DOM node containing the document. (You probably // should not directly interfere with its content.) this.dom = place && place.mount || document.createElement("div"), place && (place.appendChild ? place.appendChild(this.dom) : place.apply ? place(this.dom) : place.mount && (this.mounted = !0)), // :: bool // Indicates whether the editor is currently [editable](#view.EditorProps.editable). this.editable = getEditable(this), this.markCursor = null, this.cursorWrapper = null, updateCursorWrapper(this), this.nodeViews = buildNodeViews(this), this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this), this.lastSelectedViewDesc = null, // :: ?{slice: Slice, move: bool} // When editor content is being dragged, this object contains // information about the dragged slice and whether it is being // copied or moved. At any other time, it is null. this.dragging = null, function(view) { for(var event in view.shiftKey = !1, view.mouseDown = null, view.lastKeyCode = null, view.lastKeyCodeTime = 0, view.lastClick = { time: 0, x: 0, y: 0, type: "" }, view.lastSelectionOrigin = null, view.lastSelectionTime = 0, view.lastIOSEnter = 0, view.lastIOSEnterFallbackTimeout = null, view.lastAndroidDelete = 0, view.composing = !1, view.composingTimeout = null, view.compositionNodes = [], view.compositionEndedAt = -200000000, view.domObserver = new DOMObserver(view, function(from, to, typeOver, added) { return function(view, from, to, typeOver, addedNodes) { if (from < 0) { var preferredPos, preferredSide, nextSel, tr, storedMarks, markChange, $from1, origin = view.lastSelectionTime > Date.now() - 50 ? view.lastSelectionOrigin : null, newSel = selectionFromDOM(view, origin); if (newSel && !view.state.selection.eq(newSel)) { var tr$1 = view.state.tr.setSelection(newSel); "pointer" == origin ? tr$1.setMeta("pointer", !0) : "key" == origin && tr$1.scrollIntoView(), view.dispatch(tr$1); } return; } var $before = view.state.doc.resolve(from), shared = $before.sharedDepth(to); from = $before.before(shared + 1), to = view.state.doc.resolve(to).after(shared + 1); var sel = view.state.selection, parse = // Note that all referencing and parsing is done with the // start-of-operation selection and document, since that's the one // that the DOM represents. If any changes came in in the meantime, // the modification is mapped over those before it is applied, in // readDOMChange. function(view, from_, to_) { var ref = view.docView.parseRange(from_, to_), parent = ref.node, fromOffset = ref.fromOffset, toOffset = ref.toOffset, from = ref.from, to = ref.to, domSel = view.root.getSelection(), find = null, anchor = domSel.anchorNode; // Work around issue in Chrome where backspacing sometimes replaces // the deleted content with a random BR node (issues #799, #831) if (anchor && view.dom.contains(1 == anchor.nodeType ? anchor : anchor.parentNode) && (find = [ { node: anchor, offset: domSel.anchorOffset } ], selectionCollapsed(domSel) || find.push({ node: domSel.focusNode, offset: domSel.focusOffset })), result.chrome && 8 === view.lastKeyCode) for(var off = toOffset; off > fromOffset; off--){ var node = parent.childNodes[off - 1], desc = node.pmViewDesc; if ("BR" == node.nodeName && !desc) { toOffset = off; break; } if (!desc || desc.size) break; } var startDoc = view.state.doc, parser = view.someProp("domParser") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.DOMParser.fromSchema(view.state.schema), $from = startDoc.resolve(from), sel = null, doc = parser.parse(parent, { topNode: $from.parent, topMatch: $from.parent.contentMatchAt($from.index()), topOpen: !0, from: fromOffset, to: toOffset, preserveWhitespace: !$from.parent.type.spec.code || "full", editableContent: !0, findPositions: find, ruleFromNode: ruleFromNode, context: $from }); if (find && null != find[0].pos) { var anchor$1 = find[0].pos, head = find[1] && find[1].pos; null == head && (head = anchor$1), sel = { anchor: anchor$1 + from, head: head + from }; } return { doc: doc, sel: sel, from: from, to: to }; }(view, from, to); // Chrome sometimes leaves the cursor before the inserted text when // composing after a cursor wrapper. This moves it forward. if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) { var text = view.cursorWrapper.deco.type.toDOM.nextSibling, size = text && text.nodeValue ? text.nodeValue.length : 1; parse.sel = { anchor: parse.sel.anchor + size, head: parse.sel.anchor + size }; } var doc = view.state.doc, compare = doc.slice(parse.from, parse.to); 8 === view.lastKeyCode && Date.now() - 100 < view.lastKeyCodeTime ? (preferredPos = view.state.selection.to, preferredSide = "end") : (preferredPos = view.state.selection.from, preferredSide = "start"), view.lastKeyCode = null; var change = function(a, b, pos, preferredPos, preferredSide) { var start = a.findDiffStart(b, pos); if (null == start) return null; var ref = a.findDiffEnd(b, pos + a.size, pos + b.size), endA = ref.a, endB = ref.b; if ("end" == preferredSide) { var adjust = Math.max(0, start - Math.min(endA, endB)); preferredPos -= endA + adjust - start; } if (endA < start && a.size < b.size) { var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0; start -= move, endB = start + (endB - endA), endA = start; } else if (endB < start) { var move$1 = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0; start -= move$1, endA = start + (endA - endB), endB = start; } return { start: start, endA: endA, endB: endB }; }(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide); if (!change) { if (typeOver && sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) change = { start: sel.from, endA: sel.to, endB: sel.to }; else if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) && addedNodes.some(function(n) { return "DIV" == n.nodeName || "P" == n.nodeName; }) && view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(13, "Enter")); })) { view.lastIOSEnter = 0; return; } else { if (parse.sel) { var sel$1 = resolveSelection(view, view.state.doc, parse.sel); sel$1 && !sel$1.eq(view.state.selection) && view.dispatch(view.state.tr.setSelection(sel$1)); } return; } } view.domChangeCount++, view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 ? change.start = view.state.selection.from : change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 && (change.endB += view.state.selection.to - change.endA, change.endA = view.state.selection.to)), result.ie && result.ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse.from && " \u00a0" == parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) && (change.start--, change.endA--, change.endB--); var $from = parse.doc.resolveNoCache(change.start - parse.from), $to = parse.doc.resolveNoCache(change.endB - parse.from), inlineChange = $from.sameParent($to) && $from.parent.inlineContent; // If this looks like the effect of pressing Enter (or was recorded // as being an iOS enter press), just dispatch an Enter key instead. if ((result.ios && view.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function(n) { return "DIV" == n.nodeName || "P" == n.nodeName; })) || !inlineChange && $from.pos < parse.doc.content.size && (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, !0)) && nextSel.head == $to.pos) && view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(13, "Enter")); })) { view.lastIOSEnter = 0; return; } // Same for backspace if (view.state.selection.anchor > change.start && function(old, start, end, $newStart, $newEnd) { if (!$newStart.parent.isTextblock || // The content must have shrunk end - start <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into skipClosingAndOpening($newStart, !0, !1) < $newEnd.pos) return !1; var $start = old.resolve(start); // Start must be at the end of a block if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) return !1; var $next = old.resolve(skipClosingAndOpening($start, !0, !0)); return(// The next textblock must start before end and end near it !(!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, !0, !1) < end) && $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content)); }(doc, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(8, "Backspace")); })) { result.android && result.chrome && view.domObserver.suppressSelectionUpdates(); // #820 return; } result.chrome && result.android && change.toB == change.from && (view.lastAndroidDelete = Date.now()), result.android && !inlineChange && $from.start() != $to.start() && 0 == $to.parentOffset && $from.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA && (change.endB -= 2, $to = parse.doc.resolveNoCache(change.endB - parse.from), setTimeout(function() { view.someProp("handleKeyDown", function(f) { return f(view, keyEvent(13, "Enter")); }); }, 20)); var chFrom = change.start, chTo = change.endA; if (inlineChange) { if ($from.pos == $to.pos) result.ie && result.ie_version <= 11 && 0 == $from.parentOffset && (view.domObserver.suppressSelectionUpdates(), setTimeout(function() { return selectionToDOM(view); }, 20)), tr = view.state.tr.delete(chFrom, chTo), storedMarks = doc.resolve(change.start).marksAcross(doc.resolve(change.endA)); else if (// Adding or removing a mark change.endA == change.endB && ($from1 = doc.resolve(change.start)) && (markChange = // : (Fragment, Fragment) → ?{mark: Mark, type: string} // Given two same-length, non-empty fragments of inline content, // determine whether the first could be created from the second by // removing or adding a single mark type. function(cur, prev) { for(var type, mark, update, curMarks = cur.firstChild.marks, prevMarks = prev.firstChild.marks, added = curMarks, removed = prevMarks, i = 0; i < prevMarks.length; i++)added = prevMarks[i].removeFromSet(added); for(var i$1 = 0; i$1 < curMarks.length; i$1++)removed = curMarks[i$1].removeFromSet(removed); if (1 == added.length && 0 == removed.length) mark = added[0], type = "add", update = function(node) { return node.mark(mark.addToSet(node.marks)); }; else { if (0 != added.length || 1 != removed.length) return null; mark = removed[0], type = "remove", update = function(node) { return node.mark(mark.removeFromSet(node.marks)); }; } for(var updated = [], i$2 = 0; i$2 < prev.childCount; i$2++)updated.push(update(prev.child(i$2))); if (prosemirror_model__WEBPACK_IMPORTED_MODULE_1__.Fragment.from(updated).eq(cur)) return { mark: mark, type: type }; }($from.parent.content.cut($from.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) tr = view.state.tr, "add" == markChange.type ? tr.addMark(chFrom, chTo, markChange.mark) : tr.removeMark(chFrom, chTo, markChange.mark); else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - +!$to.textOffset) { // Both positions in the same text node -- simply insert text var text$1 = $from.parent.textBetween($from.parentOffset, $to.parentOffset); if (view.someProp("handleTextInput", function(f) { return f(view, chFrom, chTo, text$1); })) return; tr = view.state.tr.insertText(text$1, chFrom, chTo); } } if (tr || (tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from))), parse.sel) { var sel$2 = resolveSelection(view, tr.doc, parse.sel); // Chrome Android will sometimes, during composition, report the // selection in the wrong place. If it looks like that is // happening, don't update the selection. // Edge just doesn't move the cursor forward when you start typing // in an empty block or between br nodes. sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty && (change.start != change.endB || view.lastAndroidDelete < Date.now() - 100) && (sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1) || result.ie && sel$2.empty && sel$2.head == chFrom) && tr.setSelection(sel$2); } storedMarks && tr.ensureMarks(storedMarks), view.dispatch(tr.scrollIntoView()); }(view, from, to, typeOver, added); }), view.domObserver.start(), // Used by hacks like the beforeinput handler to check whether anything happened in the DOM view.domChangeCount = 0, view.eventHandlers = Object.create(null), handlers)!function(event) { var handler = handlers[event]; view.dom.addEventListener(event, view.eventHandlers[event] = function(event) { !function(view, event) { if (!event.bubbles) return !0; if (event.defaultPrevented) return !1; for(var node = event.target; node != view.dom; node = node.parentNode)if (!node || 11 == node.nodeType || node.pmViewDesc && node.pmViewDesc.stopEvent(event)) return !1; return !0; }(view, event) || runCustomHandler(view, event) || !view.editable && event.type in editHandlers || handler(view, event); }); }(event); result.safari && view.dom.addEventListener("input", function() { return null; }), ensureListeners(view); }(this), this.prevDirectPlugins = [], this.pluginViews = [], this.updatePluginViews(); }, prototypeAccessors$2 = { props: { configurable: !0 }, root: { configurable: !0 } }; function computeDocDeco(view) { var attrs = Object.create(null); return attrs.class = "ProseMirror", attrs.contenteditable = String(view.editable), attrs.translate = "no", view.someProp("attributes", function(value) { if ("function" == typeof value && (value = value(view.state)), value) for(var attr in value)"class" == attr && (attrs.class += " " + value[attr]), "style" == attr ? attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr] : attrs[attr] || "contenteditable" == attr || "nodeName" == attr || (attrs[attr] = String(value[attr])); }), [ Decoration.node(0, view.state.doc.content.size, attrs) ]; } function updateCursorWrapper(view) { if (view.markCursor) { var dom = document.createElement("img"); dom.className = "ProseMirror-separator", dom.setAttribute("mark-placeholder", "true"), view.cursorWrapper = { dom: dom, deco: Decoration.widget(view.state.selection.head, dom, { raw: !0, marks: view.markCursor }) }; } else view.cursorWrapper = null; } function getEditable(view) { return !view.someProp("editable", function(value) { return !1 === value(view.state); }); } function buildNodeViews(view) { var result = {}; return view.someProp("nodeViews", function(obj) { for(var prop in obj)Object.prototype.hasOwnProperty.call(result, prop) || (result[prop] = obj[prop]); }), result; } function checkStateComponent(plugin) { if (plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction) throw RangeError("Plugins passed directly to the view must not have a state component"); } // composing:: boolean // Holds `true` when a // [composition](https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide) // is active. // :: DirectEditorProps // The view's current [props](#view.EditorProps). prototypeAccessors$2.props.get = function() { if (this._props.state != this.state) { var prev = this._props; for(var name in this._props = {}, prev)this._props[name] = prev[name]; this._props.state = this.state; } return this._props; }, // :: (DirectEditorProps) // Update the view's props. Will immediately cause an update to // the DOM. EditorView.prototype.update = function(props) { props.handleDOMEvents != this._props.handleDOMEvents && ensureListeners(this), this._props = props, props.plugins && (props.plugins.forEach(checkStateComponent), this.directPlugins = props.plugins), this.updateStateInner(props.state, !0); }, // :: (DirectEditorProps) // Update the view by updating existing props object with the object // given as argument. Equivalent to `view.update(Object.assign({}, // view.props, props))`. EditorView.prototype.setProps = function(props) { var updated = {}; for(var name in this._props)updated[name] = this._props[name]; for(var name$1 in updated.state = this.state, props)updated[name$1] = props[name$1]; this.update(updated); }, // :: (EditorState) // Update the editor's `state` prop, without touching any of the // other props. EditorView.prototype.updateState = function(state) { this.updateStateInner(state, this.state.plugins != state.plugins); }, EditorView.prototype.updateStateInner = function(state, reconfigured) { var refDOM, refTop, newRefTop, this$1 = this, prev = this.state, redraw = !1, updateSel = !1; if (state.storedMarks && this.composing && (clearComposition(this), updateSel = !0), this.state = state, reconfigured) { var nodeViews = buildNodeViews(this); (function(a, b) { var nA = 0, nB = 0; for(var prop in a){ if (a[prop] != b[prop]) return !0; nA++; } for(var _ in b)nB++; return nA != nB; })(nodeViews, this.nodeViews) && (this.nodeViews = nodeViews, redraw = !0), ensureListeners(this); } this.editable = getEditable(this), updateCursorWrapper(this); var innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this), scroll = reconfigured ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve", updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco); (updateDoc || !state.selection.eq(prev.selection)) && (updateSel = !0); var oldScrollPos = "preserve" == scroll && updateSel && null == this.dom.style.overflowAnchor && // Store the scroll position of the editor's parent nodes, along with // the top position of an element near the top of the editor, which // will be used to make sure the visible viewport remains stable even // when the size of the content above changes. function(view) { for(var refDOM, refTop, rect = view.dom.getBoundingClientRect(), startY = Math.max(0, rect.top), x = (rect.left + rect.right) / 2, y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5){ var dom = view.root.elementFromPoint(x, y); if (dom != view.dom && view.dom.contains(dom)) { var localRect = dom.getBoundingClientRect(); if (localRect.top >= startY - 20) { refDOM = dom, refTop = localRect.top; break; } } } return { refDOM: refDOM, refTop: refTop, stack: scrollStack(view.dom) }; }(this); if (updateSel) { this.domObserver.stop(); // Work around an issue in Chrome, IE, and Edge where changing // the DOM around an active selection puts it into a broken // state where the thing the user sees differs from the // selection reported by the Selection object (#710, #973, // #1011, #1013, #1035). var sel1, sel2, depth, anchorDOM, domSel, forceSelUpdate = updateDoc && (result.ie || result.chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && (sel1 = prev.selection, sel2 = state.selection, depth = Math.min(sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head)), sel1.$anchor.start(depth) != sel2.$anchor.start(depth)); if (updateDoc) { // If the node that the selection points into is written to, // Chrome sometimes starts misreporting the selection, so this // tracks that and forces a selection reset when our update // did write to the node. var chromeKludge = result.chrome ? this.trackWrites = this.root.getSelection().focusNode : null; (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) && (this.docView.updateOuterDeco([]), this.docView.destroy(), this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this)), chromeKludge && !this.trackWrites && (forceSelUpdate = !0); } forceSelUpdate || !(this.mouseDown && this.domObserver.currentSelection.eq(this.root.getSelection()) && (anchorDOM = this.docView.domFromPos(this.state.selection.anchor, 0), domSel = this.root.getSelection(), isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset))) ? selectionToDOM(this, forceSelUpdate) : (syncNodeSelection(this, state.selection), this.domObserver.setCurSelection()), this.domObserver.start(); } if (this.updatePluginViews(prev), "reset" == scroll) this.dom.scrollTop = 0; else if ("to selection" == scroll) { var startDOM = this.root.getSelection().focusNode; this.someProp("handleScrollToSelection", function(f) { return f(this$1); }) || (state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.NodeSelection ? // Handled scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect(), startDOM) : scrollRectIntoView(this, this.coordsAtPos(state.selection.head, 1), startDOM)); } else oldScrollPos && (refDOM = oldScrollPos.refDOM, refTop = oldScrollPos.refTop, restoreScrollStack(oldScrollPos.stack, 0 == (newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0) ? 0 : newRefTop - refTop)); }, EditorView.prototype.destroyPluginViews = function() { for(var view; view = this.pluginViews.pop();)view.destroy && view.destroy(); }, EditorView.prototype.updatePluginViews = function(prevState) { if (prevState && prevState.plugins == this.state.plugins && this.directPlugins == this.prevDirectPlugins) for(var i$2 = 0; i$2 < this.pluginViews.length; i$2++){ var pluginView = this.pluginViews[i$2]; pluginView.update && pluginView.update(this, prevState); } else { this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews(); for(var i = 0; i < this.directPlugins.length; i++){ var plugin = this.directPlugins[i]; plugin.spec.view && this.pluginViews.push(plugin.spec.view(this)); } for(var i$1 = 0; i$1 < this.state.plugins.length; i$1++){ var plugin$1 = this.state.plugins[i$1]; plugin$1.spec.view && this.pluginViews.push(plugin$1.spec.view(this)); } } }, // :: (string, ?(prop: *) → *) → * // Goes over the values of a prop, first those provided directly, // then those from plugins given to the view, then from plugins in // the state (in order), and calls `f` every time a non-undefined // value is found. When `f` returns a truthy value, that is // immediately returned. When `f` isn't provided, it is treated as // the identity function (the prop value is returned directly). EditorView.prototype.someProp = function(propName, f) { var value, prop = this._props && this._props[propName]; if (null != prop && (value = f ? f(prop) : prop)) return value; for(var i = 0; i < this.directPlugins.length; i++){ var prop$1 = this.directPlugins[i].props[propName]; if (null != prop$1 && (value = f ? f(prop$1) : prop$1)) return value; } var plugins = this.state.plugins; if (plugins) for(var i$1 = 0; i$1 < plugins.length; i$1++){ var prop$2 = plugins[i$1].props[propName]; if (null != prop$2 && (value = f ? f(prop$2) : prop$2)) return value; } }, // :: () → bool // Query whether the view has focus. EditorView.prototype.hasFocus = function() { return this.root.activeElement == this.dom; }, // :: () // Focus the editor. EditorView.prototype.focus = function() { this.domObserver.stop(), this.editable && // Feature-detects support for .focus({preventScroll: true}), and uses // a fallback kludge when not supported. function(dom) { if (dom.setActive) return dom.setActive(); // in IE if (preventScrollSupported) return dom.focus(preventScrollSupported); var stored = scrollStack(dom); dom.focus(null == preventScrollSupported ? { get preventScroll () { return preventScrollSupported = { preventScroll: !0 }, !0; } } : void 0), preventScrollSupported || (preventScrollSupported = !1, restoreScrollStack(stored, 0)); }(this.dom), selectionToDOM(this), this.domObserver.start(); }, // :: union<dom.Document, dom.DocumentFragment> // Get the document root in which the editor exists. This will // usually be the top-level `document`, but might be a [shadow // DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM) // root if the editor is inside one. prototypeAccessors$2.root.get = function() { var cached = this._root; if (null == cached) { for(var search = this.dom.parentNode; search; search = search.parentNode)if (9 == search.nodeType || 11 == search.nodeType && search.host) return search.getSelection || (Object.getPrototypeOf(search).getSelection = function() { return document.getSelection(); }), this._root = search; } return cached || document; }, // :: ({left: number, top: number}) → ?{pos: number, inside: number} // Given a pair of viewport coordinates, return the document // position that corresponds to them. May return null if the given // coordinates aren't inside of the editor. When an object is // returned, its `pos` property is the position nearest to the // coordinates, and its `inside` property holds the position of the // inner node that the position falls inside of, or -1 if it is at // the top level, not in any node. EditorView.prototype.posAtCoords = function(coords) { return(// Given an x,y position on the editor, get the position in the document. function(view, coords) { var node, offset, doc = view.dom.ownerDocument; if (doc.caretPositionFromPoint) try { // Firefox throws for this call in hard-to-predict circumstances (#994) var pos$1 = doc.caretPositionFromPoint(coords.left, coords.top); pos$1 && (node = pos$1.offsetNode, offset = pos$1.offset); } catch (_) {} if (!node && doc.caretRangeFromPoint) { var range = doc.caretRangeFromPoint(coords.left, coords.top); range && (node = range.startContainer, offset = range.startOffset); } var pos, elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top + 1); if (!elt || !view.dom.contains(1 != elt.nodeType ? elt.parentNode : elt)) { var box = view.dom.getBoundingClientRect(); if (!inRect(coords, box) || !(elt = function elementFromPoint(element, coords, box) { var len = element.childNodes.length; if (len && box.top < box.bottom) for(var startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;){ var child = element.childNodes[i]; if (1 == child.nodeType) for(var rects = child.getClientRects(), j = 0; j < rects.length; j++){ var rect = rects[j]; if (inRect(coords, rect)) return elementFromPoint(child, coords, rect); } if ((i = (i + 1) % len) == startI) break; } return element; }(view.dom, coords, box))) return null; } // Safari's caretRangeFromPoint returns nonsense when on a draggable element if (result.safari) for(var p = elt; node && p; p = parentNode(p))p.draggable && (node = offset = null); if (elt = (parent = (dom = elt).parentNode) && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left ? parent : dom, node) { if (result.gecko && 1 == node.nodeType && // Firefox will sometimes return offsets into <input> nodes, which // have no actual children, from caretPositionFromPoint (#953) (offset = Math.min(offset, node.childNodes.length)) < node.childNodes.length) { var dom, parent, box$1, next = node.childNodes[offset]; "IMG" == next.nodeName && (box$1 = next.getBoundingClientRect()).right <= coords.left && box$1.bottom > coords.top && offset++; } // Suspiciously specific kludge to work around caret*FromPoint // never returning a position at the end of the document node == view.dom && offset == node.childNodes.length - 1 && 1 == node.lastChild.nodeType && coords.top > node.lastChild.getBoundingClientRect().bottom ? pos = view.state.doc.content.size : (0 == offset || 1 != node.nodeType || "BR" != node.childNodes[offset - 1].nodeName) && (pos = function(view, node, offset, coords) { for(var outside = -1, cur = node; cur != view.dom;){ var desc = view.docView.nearestDesc(cur, !0); if (!desc) return null; if (desc.node.isBlock && desc.parent) { var rect = desc.dom.getBoundingClientRect(); if (rect.left > coords.left || rect.top > coords.top) outside = desc.posBefore; else if (rect.right < coords.left || rect.bottom < coords.top) outside = desc.posAfter; else break; } cur = desc.dom.parentNode; } return outside > -1 ? outside : view.docView.posFromDOM(node, offset); }(view, node, offset, coords)); } null == pos && (pos = function(view, elt, coords) { var ref = function findOffsetInNode(node, coords) { for(var closest, coordsClosest, dxClosest = 2e8, offset = 0, rowBot = coords.top, rowTop = coords.top, child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++){ var rects = void 0; if (1 == child.nodeType) rects = child.getClientRects(); else { if (3 != child.nodeType) continue; rects = textRange(child).getClientRects(); } for(var i = 0; i < rects.length; i++){ var rect = rects[i]; if (rect.top <= rowBot && rect.bottom >= rowTop) { rowBot = Math.max(rect.bottom, rowBot), rowTop = Math.min(rect.top, rowTop); var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0; if (dx < dxClosest) { closest = child, dxClosest = dx, coordsClosest = dx && 3 == closest.nodeType ? { left: rect.right < coords.left ? rect.right : rect.left, top: coords.top } : coords, 1 == child.nodeType && dx && (offset = childIndex + +(coords.left >= (rect.left + rect.right) / 2)); continue; } } !closest && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom) && (offset = childIndex + 1); } } return closest && 3 == closest.nodeType ? function(node, coords) { for(var len = node.nodeValue.length, range = document.createRange(), i = 0; i < len; i++){ range.setEnd(node, i + 1), range.setStart(node, i); var rect = singleRect(range, 1); if (rect.top != rect.bottom && inRect(coords, rect)) return { node: node, offset: i + +(coords.left >= (rect.left + rect.right) / 2) }; } return { node: node, offset: 0 }; }(closest, coordsClosest) : !closest || dxClosest && 1 == closest.nodeType ? { node: node, offset: offset } : findOffsetInNode(closest, coordsClosest); }(elt, coords), node = ref.node, offset = ref.offset, bias = -1; if (1 == node.nodeType && !node.firstChild) { var rect = node.getBoundingClientRect(); bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1; } return view.docView.posFromDOM(node, offset, bias); }(view, elt, coords)); var desc = view.docView.nearestDesc(elt, !0); return { pos: pos, inside: desc ? desc.posAtStart - desc.border : -1 }; }(this, coords)); }, // :: (number, number) → {left: number, right: number, top: number, bottom: number} // Returns the viewport rectangle at a given document position. // `left` and `right` will be the same number, as this returns a // flat cursor-ish rectangle. If the position is between two things // that aren't directly adjacent, `side` determines which element is // used. When < 0, the element before the position is used, // otherwise the element after. EditorView.prototype.coordsAtPos = function(pos, side) { return void 0 === side && (side = 1), coordsAtPos(this, pos, side); }, // :: (number, number) → {node: dom.Node, offset: number} // Find the DOM position that corresponds to the given document // position. When `side` is negative, find the position as close as // possible to the content before the position. When positive, // prefer positions close to the content after the position. When // zero, prefer as shallow a position as possible. // // Note that you should **not** mutate the editor's internal DOM, // only inspect it (and even that is usually not necessary). EditorView.prototype.domAtPos = function(pos, side) { return void 0 === side && (side = 0), this.docView.domFromPos(pos, side); }, // :: (number) → ?dom.Node // Find the DOM node that represents the document node after the // given position. May return `null` when the position doesn't point // in front of a node or if the node is inside an opaque node view. // // This is intended to be able to call things like // `getBoundingClientRect` on that DOM node. Do **not** mutate the // editor DOM directly, or add styling this way, since that will be // immediately overriden by the editor as it redraws the node. EditorView.prototype.nodeDOM = function(pos) { var desc = this.docView.descAt(pos); return desc ? desc.nodeDOM : null; }, // :: (dom.Node, number, ?number) → number // Find the document position that corresponds to a given DOM // position. (Whenever possible, it is preferable to inspect the // document structure directly, rather than poking around in the // DOM, but sometimes—for example when interpreting an event // target—you don't have a choice.) // // The `bias` parameter can be used to influence which side of a DOM // node to use when the position is inside a leaf node. EditorView.prototype.posAtDOM = function(node, offset, bias) { void 0 === bias && (bias = -1); var pos = this.docView.posFromDOM(node, offset, bias); if (null == pos) throw RangeError("DOM position not inside the editor"); return pos; }, // :: (union<"up", "down", "left", "right", "forward", "backward">, ?EditorState) → bool // Find out whether the selection is at the end of a textblock when // moving in a given direction. When, for example, given `"left"`, // it will return true if moving left from the current cursor // position would leave that position's parent textblock. Will apply // to the view's current state by default, but it is possible to // pass a different state. EditorView.prototype.endOfTextblock = function(dir, state) { var view, state1, sel, $pos; return view = this, state1 = state || this.state, cachedState == state1 && cachedDir == dir ? cachedResult : (cachedState = state1, cachedDir = dir, cachedResult = "up" == dir || "down" == dir ? (sel = state1.selection, $pos = "up" == dir ? sel.$from : sel.$to, withFlushedState(view, state1, function() { for(var dom = view.docView.domFromPos($pos.pos, "up" == dir ? -1 : 1).node;;){ var nearest = view.docView.nearestDesc(dom, !0); if (!nearest) break; if (nearest.node.isBlock) { dom = nearest.dom; break; } dom = nearest.dom.parentNode; } for(var coords = coordsAtPos(view, $pos.pos, 1), child = dom.firstChild; child; child = child.nextSibling){ var boxes = void 0; if (1 == child.nodeType) boxes = child.getClientRects(); else { if (3 != child.nodeType) continue; boxes = textRange(child, 0, child.nodeValue.length).getClientRects(); } for(var i = 0; i < boxes.length; i++){ var box = boxes[i]; if (box.bottom > box.top + 1 && ("up" == dir ? coords.top - box.top > (box.bottom - coords.top) * 2 : box.bottom - coords.bottom > (coords.bottom - box.top) * 2)) return !1; } } return !0; })) : function(view, state, dir) { var $head = state.selection.$head; if (!$head.parent.isTextblock) return !1; var offset = $head.parentOffset, atEnd = offset == $head.parent.content.size, sel = view.root.getSelection(); return(// If the textblock is all LTR, or the browser doesn't support // Selection.modify (Edge), fall back to a primitive approach maybeRTL.test($head.parent.textContent) && sel.modify ? withFlushedState(view, state, function() { // This is a huge hack, but appears to be the best we can // currently do: use `Selection.modify` to move the selection by // one character, and see if that moves the cursor out of the // textblock (or doesn't move it at all, when at the start/end of // the document). var oldRange = sel.getRangeAt(0), oldNode = sel.focusNode, oldOff = sel.focusOffset, oldBidiLevel = sel.caretBidiLevel; sel.modify("move", dir, "character"); var result = !($head.depth ? view.docView.domAfterPos($head.before()) : view.dom).contains(1 == sel.focusNode.nodeType ? sel.focusNode : sel.focusNode.parentNode) || oldNode == sel.focusNode && oldOff == sel.focusOffset; return(// Restore the previous selection sel.removeAllRanges(), sel.addRange(oldRange), null != oldBidiLevel && (sel.caretBidiLevel = oldBidiLevel), result); }) : "left" == dir || "backward" == dir ? !offset : atEnd); }(view, state1, dir)); }, // :: () // Removes the editor from the DOM and destroys all [node // views](#view.NodeView). EditorView.prototype.destroy = function() { this.docView && (function(view) { for(var type in view.domObserver.stop(), view.eventHandlers)view.dom.removeEventListener(type, view.eventHandlers[type]); clearTimeout(view.composingTimeout), clearTimeout(view.lastIOSEnterFallbackTimeout); }(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], viewDecorations(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null); }, // Used for testing. EditorView.prototype.dispatchEvent = function(event) { runCustomHandler(this, event) || !handlers[event.type] || !this.editable && event.type in editHandlers || handlers[event.type](this, event); }, // :: (Transaction) // Dispatch a transaction. Will call // [`dispatchTransaction`](#view.DirectEditorProps.dispatchTransaction) // when given, and otherwise defaults to applying the transaction to // the current state and calling // [`updateState`](#view.EditorView.updateState) with the result. // This method is bound to the view instance, so that it can be // easily passed around. EditorView.prototype.dispatch = function(tr) { var dispatchTransaction = this._props.dispatchTransaction; dispatchTransaction ? dispatchTransaction.call(this, tr) : this.updateState(this.state.apply(tr)); }, Object.defineProperties(EditorView.prototype, prototypeAccessors$2); // EditorProps:: interface // // Props are configuration values that can be passed to an editor view // or included in a plugin. This interface lists the supported props. // // The various event-handling functions may all return `true` to // indicate that they handled the given event. The view will then take // care to call `preventDefault` on the event, except with // `handleDOMEvents`, where the handler itself is responsible for that. // // How a prop is resolved depends on the prop. Handler functions are // called one at a time, starting with the base props and then // searching through the plugins (in order of appearance) until one of // them returns true. For some props, the first plugin that yields a // value gets precedence. // // handleDOMEvents:: ?Object<(view: EditorView, event: dom.Event) → bool> // Can be an object mapping DOM event type names to functions that // handle them. Such functions will be called before any handling // ProseMirror does of events fired on the editable DOM element. // Contrary to the other event handling props, when returning true // from such a function, you are responsible for calling // `preventDefault` yourself (or not, if you want to allow the // default behavior). // // handleKeyDown:: ?(view: EditorView, event: dom.KeyboardEvent) → bool // Called when the editor receives a `keydown` event. // // handleKeyPress:: ?(view: EditorView, event: dom.KeyboardEvent) → bool // Handler for `keypress` events. // // handleTextInput:: ?(view: EditorView, from: number, to: number, text: string) → bool // Whenever the user directly input text, this handler is called // before the input is applied. If it returns `true`, the default // behavior of actually inserting the text is suppressed. // // handleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a click, from the inside out. The // `direct` flag will be true for the inner node. // // handleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is clicked, after `handleClickOn` handlers // have been called. // // handleDoubleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a double click. // // handleDoubleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is double-clicked, after `handleDoubleClickOn`. // // handleTripleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool // Called for each node around a triple click. // // handleTripleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool // Called when the editor is triple-clicked, after `handleTripleClickOn`. // // handlePaste:: ?(view: EditorView, event: dom.ClipboardEvent, slice: Slice) → bool // Can be used to override the behavior of pasting. `slice` is the // pasted content parsed by the editor, but you can directly access // the event to get at the raw content. // // handleDrop:: ?(view: EditorView, event: dom.Event, slice: Slice, moved: bool) → bool // Called when something is dropped on the editor. `moved` will be // true if this drop moves from the current selection (which should // thus be deleted). // // handleScrollToSelection:: ?(view: EditorView) → bool // Called when the view, after updating its state, tries to scroll // the selection into view. A handler function may return false to // indicate that it did not handle the scrolling and further // handlers or the default behavior should be tried. // // createSelectionBetween:: ?(view: EditorView, anchor: ResolvedPos, head: ResolvedPos) → ?Selection // Can be used to override the way a selection is created when // reading a DOM selection between the given anchor and head. // // domParser:: ?DOMParser // The [parser](#model.DOMParser) to use when reading editor changes // from the DOM. Defaults to calling // [`DOMParser.fromSchema`](#model.DOMParser^fromSchema) on the // editor's schema. // // transformPastedHTML:: ?(html: string) → string // Can be used to transform pasted HTML text, _before_ it is parsed, // for example to clean it up. // // clipboardParser:: ?DOMParser // The [parser](#model.DOMParser) to use when reading content from // the clipboard. When not given, the value of the // [`domParser`](#view.EditorProps.domParser) prop is used. // // transformPastedText:: ?(text: string, plain: bool) → string // Transform pasted plain text. The `plain` flag will be true when // the text is pasted as plain text. // // clipboardTextParser:: ?(text: string, $context: ResolvedPos, plain: bool) → Slice // A function to parse text from the clipboard into a document // slice. Called after // [`transformPastedText`](#view.EditorProps.transformPastedText). // The default behavior is to split the text into lines, wrap them // in `<p>` tags, and call // [`clipboardParser`](#view.EditorProps.clipboardParser) on it. // The `plain` flag will be true when the text is pasted as plain text. // // transformPasted:: ?(Slice) → Slice // Can be used to transform pasted content before it is applied to // the document. // // nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration], innerDecorations: DecorationSource) → NodeView> // Allows you to pass custom rendering and behavior logic for nodes // and marks. Should map node and mark names to constructor // functions that produce a [`NodeView`](#view.NodeView) object // implementing the node's display behavior. For nodes, the third // argument `getPos` is a function that can be called to get the // node's current position, which can be useful when creating // transactions to update it. For marks, the third argument is a // boolean that indicates whether the mark's content is inline. // // `decorations` is an array of node or inline decorations that are // active around the node. They are automatically drawn in the // normal way, and you will usually just want to ignore this, but // they can also be used as a way to provide context information to // the node view without adding it to the document itself. // // `innerDecorations` holds the decorations for the node's content. // You can safely ignore this if your view has no content or a // `contentDOM` property, since the editor will draw the decorations // on the content. But if you, for example, want to create a nested // editor with the content, it may make sense to provide it with the // inner decorations. // // clipboardSerializer:: ?DOMSerializer // The DOM serializer to use when putting content onto the // clipboard. If not given, the result of // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema) // will be used. // // clipboardTextSerializer:: ?(Slice) → string // A function that will be called to get the text for the current // selection when copying text to the clipboard. By default, the // editor will use [`textBetween`](#model.Node.textBetween) on the // selected range. // // decorations:: ?(state: EditorState) → ?DecorationSource // A set of [document decorations](#view.Decoration) to show in the // view. // // editable:: ?(state: EditorState) → bool // When this returns false, the content of the view is not directly // editable. // // attributes:: ?union<Object<string>, (EditorState) → ?Object<string>> // Control the DOM attributes of the editable element. May be either // an object or a function going from an editor state to an object. // By default, the element will get a class `"ProseMirror"`, and // will have its `contentEditable` attribute determined by the // [`editable` prop](#view.EditorProps.editable). Additional classes // provided here will be added to the class. For other attributes, // the value provided first (as in // [`someProp`](#view.EditorView.someProp)) will be used. // // scrollThreshold:: ?union<number, {top: number, right: number, bottom: number, left: number}> // Determines the distance (in pixels) between the cursor and the // end of the visible viewport at which point, when scrolling the // cursor into view, scrolling takes place. Defaults to 0. // // scrollMargin:: ?union<number, {top: number, right: number, bottom: number, left: number}> // Determines the extra space (in pixels) that is left above or // below the cursor when it is scrolled into view. Defaults to 5. // DirectEditorProps:: interface extends EditorProps // // The props object given directly to the editor view supports two // fields that can't be used in plugins: // // state:: EditorState // The current state of the editor. // // plugins:: [Plugin] // A set of plugins to use in the view, applying their [plugin // view](#state.PluginSpec.view) and // [props](#state.PluginSpec.props). Passing plugins with a state // component (a [state field](#state.PluginSpec.state) field or a // [transaction)[#state.PluginSpec.filterTransaction] filter or // appender) will result in an error, since such plugins must be // present in the state to work. // // dispatchTransaction:: ?(tr: Transaction) // The callback over which to send transactions (state updates) // produced by the view. If you specify this, you probably want to // make sure this ends up calling the view's // [`updateState`](#view.EditorView.updateState) method with a new // state that has the transaction // [applied](#state.EditorState.apply). The callback will be bound to have // the view instance as its `this` binding. //# sourceMappingURL=index.es.js.map /***/ } } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/31084/xml2js/parser/input.js
JavaScript
// Generated by CoffeeScript 1.12.7 (function () { "use strict"; var bom, defaults, events, isEmpty, processItem, processors, sax, setImmediate, bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; }, extend = function (child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; sax = require("sax"); events = require("events"); bom = require("./bom"); processors = require("./processors"); setImmediate = require("timers").setImmediate; defaults = require("./defaults").defaults; isEmpty = function (thing) { return ( typeof thing === "object" && thing != null && Object.keys(thing).length === 0 ); }; processItem = function (processors, item, key) { var i, len, process; for (i = 0, len = processors.length; i < len; i++) { process = processors[i]; item = process(item, key); } return item; }; exports.Parser = (function (superClass) { extend(Parser, superClass); function Parser(opts) { this.parseStringPromise = bind(this.parseStringPromise, this); this.parseString = bind(this.parseString, this); this.reset = bind(this.reset, this); this.assignOrPush = bind(this.assignOrPush, this); this.processAsync = bind(this.processAsync, this); var key, ref, value; if (!(this instanceof exports.Parser)) { return new exports.Parser(opts); } this.options = {}; ref = defaults["0.2"]; for (key in ref) { if (!hasProp.call(ref, key)) continue; value = ref[key]; this.options[key] = value; } for (key in opts) { if (!hasProp.call(opts, key)) continue; value = opts[key]; this.options[key] = value; } if (this.options.xmlns) { this.options.xmlnskey = this.options.attrkey + "ns"; } if (this.options.normalizeTags) { if (!this.options.tagNameProcessors) { this.options.tagNameProcessors = []; } this.options.tagNameProcessors.unshift(processors.normalize); } this.reset(); } Parser.prototype.processAsync = function () { var chunk, err; try { if (this.remaining.length <= this.options.chunkSize) { chunk = this.remaining; this.remaining = ""; this.saxParser = this.saxParser.write(chunk); return this.saxParser.close(); } else { chunk = this.remaining.substr(0, this.options.chunkSize); this.remaining = this.remaining.substr( this.options.chunkSize, this.remaining.length ); this.saxParser = this.saxParser.write(chunk); return setImmediate(this.processAsync); } } catch (error1) { err = error1; if (!this.saxParser.errThrown) { this.saxParser.errThrown = true; return this.emit(err); } } }; Parser.prototype.assignOrPush = function (obj, key, newValue) { if (!(key in obj)) { if (!this.options.explicitArray) { return (obj[key] = newValue); } else { return (obj[key] = [newValue]); } } else { if (!(obj[key] instanceof Array)) { obj[key] = [obj[key]]; } return obj[key].push(newValue); } }; Parser.prototype.reset = function () { var attrkey, charkey, ontext, stack; this.removeAllListeners(); this.saxParser = sax.parser(this.options.strict, { trim: false, normalize: false, xmlns: this.options.xmlns, }); this.saxParser.errThrown = false; this.saxParser.onerror = (function (_this) { return function (error) { _this.saxParser.resume(); if (!_this.saxParser.errThrown) { _this.saxParser.errThrown = true; return _this.emit("error", error); } }; })(this); this.saxParser.onend = (function (_this) { return function () { if (!_this.saxParser.ended) { _this.saxParser.ended = true; return _this.emit("end", _this.resultObject); } }; })(this); this.saxParser.ended = false; this.EXPLICIT_CHARKEY = this.options.explicitCharkey; this.resultObject = null; stack = []; attrkey = this.options.attrkey; charkey = this.options.charkey; this.saxParser.onopentag = (function (_this) { return function (node) { var key, newValue, obj, processedKey, ref; obj = {}; obj[charkey] = ""; if (!_this.options.ignoreAttrs) { ref = node.attributes; for (key in ref) { if (!hasProp.call(ref, key)) continue; if ( !(attrkey in obj) && !_this.options.mergeAttrs ) { obj[attrkey] = {}; } newValue = _this.options.attrValueProcessors ? processItem( _this.options.attrValueProcessors, node.attributes[key], key ) : node.attributes[key]; processedKey = _this.options.attrNameProcessors ? processItem( _this.options.attrNameProcessors, key ) : key; if (_this.options.mergeAttrs) { _this.assignOrPush(obj, processedKey, newValue); } else { obj[attrkey][processedKey] = newValue; } } } obj["#name"] = _this.options.tagNameProcessors ? processItem( _this.options.tagNameProcessors, node.name ) : node.name; if (_this.options.xmlns) { obj[_this.options.xmlnskey] = { uri: node.uri, local: node.local, }; } return stack.push(obj); }; })(this); this.saxParser.onclosetag = (function (_this) { return function () { var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath; obj = stack.pop(); nodeName = obj["#name"]; if ( !_this.options.explicitChildren || !_this.options.preserveChildrenOrder ) { delete obj["#name"]; } if (obj.cdata === true) { cdata = obj.cdata; delete obj.cdata; } s = stack[stack.length - 1]; if (obj[charkey].match(/^\s*$/) && !cdata) { emptyStr = obj[charkey]; delete obj[charkey]; } else { if (_this.options.trim) { obj[charkey] = obj[charkey].trim(); } if (_this.options.normalize) { obj[charkey] = obj[charkey] .replace(/\s{2,}/g, " ") .trim(); } obj[charkey] = _this.options.valueProcessors ? processItem( _this.options.valueProcessors, obj[charkey], nodeName ) : obj[charkey]; if ( Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY ) { obj = obj[charkey]; } } if (isEmpty(obj)) { obj = _this.options.emptyTag !== "" ? _this.options.emptyTag : emptyStr; } if (_this.options.validator != null) { xpath = "/" + (function () { var i, len, results; results = []; for (i = 0, len = stack.length; i < len; i++) { node = stack[i]; results.push(node["#name"]); } return results; })() .concat(nodeName) .join("/"); (function () { var err; try { return (obj = _this.options.validator( xpath, s && s[nodeName], obj )); } catch (error1) { err = error1; return _this.emit("error", err); } })(); } if ( _this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === "object" ) { if (!_this.options.preserveChildrenOrder) { node = {}; if (_this.options.attrkey in obj) { node[_this.options.attrkey] = obj[_this.options.attrkey]; delete obj[_this.options.attrkey]; } if ( !_this.options.charsAsChildren && _this.options.charkey in obj ) { node[_this.options.charkey] = obj[_this.options.charkey]; delete obj[_this.options.charkey]; } if (Object.getOwnPropertyNames(obj).length > 0) { node[_this.options.childkey] = obj; } obj = node; } else if (s) { s[_this.options.childkey] = s[_this.options.childkey] || []; objClone = {}; for (key in obj) { if (!hasProp.call(obj, key)) continue; objClone[key] = obj[key]; } s[_this.options.childkey].push(objClone); delete obj["#name"]; if ( Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY ) { obj = obj[charkey]; } } } if (stack.length > 0) { return _this.assignOrPush(s, nodeName, obj); } else { if (_this.options.explicitRoot) { old = obj; obj = {}; obj[nodeName] = old; } _this.resultObject = obj; _this.saxParser.ended = true; return _this.emit("end", _this.resultObject); } }; })(this); ontext = (function (_this) { return function (text) { var charChild, s; s = stack[stack.length - 1]; if (s) { s[charkey] += text; if ( _this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, "").trim() !== "") ) { s[_this.options.childkey] = s[_this.options.childkey] || []; charChild = { "#name": "__text__", }; charChild[charkey] = text; if (_this.options.normalize) { charChild[charkey] = charChild[charkey] .replace(/\s{2,}/g, " ") .trim(); } s[_this.options.childkey].push(charChild); } return s; } }; })(this); this.saxParser.ontext = ontext; return (this.saxParser.oncdata = (function (_this) { return function (text) { var s; s = ontext(text); if (s) { return (s.cdata = true); } }; })(this)); }; Parser.prototype.parseString = function (str, cb) { var err; if (cb != null && typeof cb === "function") { this.on("end", function (result) { this.reset(); return cb(null, result); }); this.on("error", function (err) { this.reset(); return cb(err); }); } try { str = str.toString(); if (str.trim() === "") { this.emit("end", null); return true; } str = bom.stripBOM(str); if (this.options.async) { this.remaining = str; setImmediate(this.processAsync); return this.saxParser; } return this.saxParser.write(str).close(); } catch (error1) { err = error1; if (!(this.saxParser.errThrown || this.saxParser.ended)) { this.emit("error", err); return (this.saxParser.errThrown = true); } else if (this.saxParser.ended) { throw err; } } }; Parser.prototype.parseStringPromise = function (str) { return new Promise( (function (_this) { return function (resolve, reject) { return _this.parseString(str, function (err, value) { if (err) { return reject(err); } else { return resolve(value); } }); }; })(this) ); }; return Parser; })(events); exports.parseString = function (str, a, b) { var cb, options, parser; if (b != null) { if (typeof b === "function") { cb = b; } if (typeof a === "object") { options = a; } } else { if (typeof a === "function") { cb = a; } options = {}; } parser = new exports.Parser(options); return parser.parseString(str, cb); }; exports.parseStringPromise = function (str, a) { var options, parser; if (typeof a === "object") { options = a; } parser = new exports.Parser(options); return parser.parseStringPromise(str); }; }.call(this));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/31084/xml2js/parser/output.js
JavaScript
// Generated by CoffeeScript 1.12.7 (function() { "use strict"; var bom, defaults, events, processItem, processors, sax, setImmediate, bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }, extend = function(child, parent) { for(var key in parent)hasProp.call(parent, key) && (child[key] = parent[key]); function ctor() { this.constructor = child; } return ctor.prototype = parent.prototype, child.prototype = new ctor(), child.__super__ = parent.prototype, child; }, hasProp = {}.hasOwnProperty; sax = require("sax"), events = require("events"), bom = require("./bom"), processors = require("./processors"), setImmediate = require("timers").setImmediate, defaults = require("./defaults").defaults, processItem = function(processors, item, key) { var i, len; for(i = 0, len = processors.length; i < len; i++)item = (0, processors[i])(item, key); return item; }, exports.Parser = function(superClass) { function Parser(opts) { var key, ref, value; if (this.parseStringPromise = bind(this.parseStringPromise, this), this.parseString = bind(this.parseString, this), this.reset = bind(this.reset, this), this.assignOrPush = bind(this.assignOrPush, this), this.processAsync = bind(this.processAsync, this), !(this instanceof exports.Parser)) return new exports.Parser(opts); for(key in this.options = {}, ref = defaults["0.2"])hasProp.call(ref, key) && (value = ref[key], this.options[key] = value); for(key in opts)hasProp.call(opts, key) && (value = opts[key], this.options[key] = value); this.options.xmlns && (this.options.xmlnskey = this.options.attrkey + "ns"), this.options.normalizeTags && (this.options.tagNameProcessors || (this.options.tagNameProcessors = []), this.options.tagNameProcessors.unshift(processors.normalize)), this.reset(); } return extend(Parser, superClass), Parser.prototype.processAsync = function() { var chunk; try { if (this.remaining.length <= this.options.chunkSize) return chunk = this.remaining, this.remaining = "", this.saxParser = this.saxParser.write(chunk), this.saxParser.close(); return chunk = this.remaining.substr(0, this.options.chunkSize), this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length), this.saxParser = this.saxParser.write(chunk), setImmediate(this.processAsync); } catch (error1) { if (!this.saxParser.errThrown) return this.saxParser.errThrown = !0, this.emit(error1); } }, Parser.prototype.assignOrPush = function(obj, key, newValue) { return key in obj ? (obj[key] instanceof Array || (obj[key] = [ obj[key] ]), obj[key].push(newValue)) : this.options.explicitArray ? obj[key] = [ newValue ] : obj[key] = newValue; }, Parser.prototype.reset = function() { var attrkey, charkey, ontext, stack, _this, _this1, _this2, _this3, _this4; return this.removeAllListeners(), this.saxParser = sax.parser(this.options.strict, { trim: !1, normalize: !1, xmlns: this.options.xmlns }), this.saxParser.errThrown = !1, this.saxParser.onerror = (_this = this, function(error) { if (_this.saxParser.resume(), !_this.saxParser.errThrown) return _this.saxParser.errThrown = !0, _this.emit("error", error); }), this.saxParser.onend = (_this1 = this, function() { if (!_this1.saxParser.ended) return _this1.saxParser.ended = !0, _this1.emit("end", _this1.resultObject); }), this.saxParser.ended = !1, this.EXPLICIT_CHARKEY = this.options.explicitCharkey, this.resultObject = null, stack = [], attrkey = this.options.attrkey, charkey = this.options.charkey, this.saxParser.onopentag = (_this2 = this, function(node) { var key, newValue, obj, processedKey, ref; if ((obj = {})[charkey] = "", !_this2.options.ignoreAttrs) for(key in ref = node.attributes)hasProp.call(ref, key) && (attrkey in obj || _this2.options.mergeAttrs || (obj[attrkey] = {}), newValue = _this2.options.attrValueProcessors ? processItem(_this2.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key], processedKey = _this2.options.attrNameProcessors ? processItem(_this2.options.attrNameProcessors, key) : key, _this2.options.mergeAttrs ? _this2.assignOrPush(obj, processedKey, newValue) : obj[attrkey][processedKey] = newValue); return obj["#name"] = _this2.options.tagNameProcessors ? processItem(_this2.options.tagNameProcessors, node.name) : node.name, _this2.options.xmlns && (obj[_this2.options.xmlnskey] = { uri: node.uri, local: node.local }), stack.push(obj); }), this.saxParser.onclosetag = (_this3 = this, function() { var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath, thing; if (nodeName = (obj = stack.pop())["#name"], _this3.options.explicitChildren && _this3.options.preserveChildrenOrder || delete obj["#name"], !0 === obj.cdata && (cdata = obj.cdata, delete obj.cdata), s = stack[stack.length - 1], obj[charkey].match(/^\s*$/) && !cdata ? (emptyStr = obj[charkey], delete obj[charkey]) : (_this3.options.trim && (obj[charkey] = obj[charkey].trim()), _this3.options.normalize && (obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim()), obj[charkey] = _this3.options.valueProcessors ? processItem(_this3.options.valueProcessors, obj[charkey], nodeName) : obj[charkey], 1 === Object.keys(obj).length && charkey in obj && !_this3.EXPLICIT_CHARKEY && (obj = obj[charkey])), "object" == typeof (thing = obj) && null != thing && 0 === Object.keys(thing).length && (obj = "" !== _this3.options.emptyTag ? _this3.options.emptyTag : emptyStr), null != _this3.options.validator && (xpath = "/" + (function() { var i, len, results; for(i = 0, results = [], len = stack.length; i < len; i++)node = stack[i], results.push(node["#name"]); return results; })().concat(nodeName).join("/"), function() { try { obj = _this3.options.validator(xpath, s && s[nodeName], obj); } catch (error1) { return _this3.emit("error", error1); } }()), _this3.options.explicitChildren && !_this3.options.mergeAttrs && "object" == typeof obj) { if (_this3.options.preserveChildrenOrder) { if (s) { for(key in s[_this3.options.childkey] = s[_this3.options.childkey] || [], objClone = {}, obj)hasProp.call(obj, key) && (objClone[key] = obj[key]); s[_this3.options.childkey].push(objClone), delete obj["#name"], 1 === Object.keys(obj).length && charkey in obj && !_this3.EXPLICIT_CHARKEY && (obj = obj[charkey]); } } else node = {}, _this3.options.attrkey in obj && (node[_this3.options.attrkey] = obj[_this3.options.attrkey], delete obj[_this3.options.attrkey]), !_this3.options.charsAsChildren && _this3.options.charkey in obj && (node[_this3.options.charkey] = obj[_this3.options.charkey], delete obj[_this3.options.charkey]), Object.getOwnPropertyNames(obj).length > 0 && (node[_this3.options.childkey] = obj), obj = node; } return stack.length > 0 ? _this3.assignOrPush(s, nodeName, obj) : (_this3.options.explicitRoot && (old = obj, (obj = {})[nodeName] = old), _this3.resultObject = obj, _this3.saxParser.ended = !0, _this3.emit("end", _this3.resultObject)); }), _this4 = this, ontext = function(text) { var charChild, s; if (s = stack[stack.length - 1]) return s[charkey] += text, _this4.options.explicitChildren && _this4.options.preserveChildrenOrder && _this4.options.charsAsChildren && (_this4.options.includeWhiteChars || "" !== text.replace(/\\n/g, "").trim()) && (s[_this4.options.childkey] = s[_this4.options.childkey] || [], (charChild = { "#name": "__text__" })[charkey] = text, _this4.options.normalize && (charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim()), s[_this4.options.childkey].push(charChild)), s; }, this.saxParser.ontext = ontext, this.saxParser.oncdata = function(text) { var s; if (s = ontext(text)) return s.cdata = !0; }; }, Parser.prototype.parseString = function(str, cb) { null != cb && "function" == typeof cb && (this.on("end", function(result) { return this.reset(), cb(null, result); }), this.on("error", function(err) { return this.reset(), cb(err); })); try { if (str = str.toString(), "" === str.trim()) return this.emit("end", null), !0; if (str = bom.stripBOM(str), this.options.async) return this.remaining = str, setImmediate(this.processAsync), this.saxParser; return this.saxParser.write(str).close(); } catch (error1) { if (!(this.saxParser.errThrown || this.saxParser.ended)) return this.emit("error", error1), this.saxParser.errThrown = !0; if (this.saxParser.ended) throw error1; } }, Parser.prototype.parseStringPromise = function(str) { var _this; return new Promise((_this = this, function(resolve, reject) { return _this.parseString(str, function(err, value) { return err ? reject(err) : resolve(value); }); })); }, Parser; }(events), exports.parseString = function(str, a, b) { var cb, options; return null != b ? ("function" == typeof b && (cb = b), "object" == typeof a && (options = a)) : ("function" == typeof a && (cb = a), options = {}), new exports.Parser(options).parseString(str, cb); }, exports.parseStringPromise = function(str, a) { var options; return "object" == typeof a && (options = a), new exports.Parser(options).parseStringPromise(str); }; }).call(this);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [405], { /***/ 7154: /***/ function (module) { function _extends() { (module.exports = _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }), (module.exports.__esModule = true), (module.exports["default"] = module.exports); return _extends.apply(this, arguments); } (module.exports = _extends), (module.exports.__esModule = true), (module.exports["default"] = module.exports); /***/ }, /***/ 562: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Ki: function () { return /* binding */ toUint8; }, /* harmony export */ tm: function () { return /* binding */ bytesToNumber; }, /* harmony export */ hL: function () { return /* binding */ numberToBytes; }, /* harmony export */ d3: function () { return /* binding */ bytesToString; }, /* harmony export */ qX: function () { return /* binding */ stringToBytes; }, /* harmony export */ lx: function () { return /* binding */ concatTypedArrays; }, /* harmony export */ G3: function () { return /* binding */ bytesMatch; }, /* harmony export */ }); /* unused harmony exports countBits, countBytes, padStart, isTypedArray, toHexString, toBinaryString, ENDIANNESS, IS_BIG_ENDIAN, IS_LITTLE_ENDIAN, sliceBytes, reverseBytes */ /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( global_window__WEBPACK_IMPORTED_MODULE_0__ ); // const log2 = Math.log2 ? Math.log2 : (x) => (Math.log(x) / Math.log(2)); var repeat = function repeat(str, len) { var acc = ""; while (len--) { acc += str; } return acc; }; // count the number of bits it would take to represent a number // we used to do this with log2 but BigInt does not support builtin math // Math.ceil(log2(x)); var countBits = function countBits(x) { return x.toString(2).length; }; // count the number of whole bytes it would take to represent a number var countBytes = function countBytes(x) { return Math.ceil(countBits(x) / 8); }; var padStart = function padStart(b, len, str) { if (str === void 0) { str = " "; } return (repeat(str, len) + b.toString()).slice(-len); }; var isTypedArray = function isTypedArray(obj) { return ArrayBuffer.isView(obj); }; var toUint8 = function toUint8(bytes) { if (bytes instanceof Uint8Array) { return bytes; } if ( !Array.isArray(bytes) && !isTypedArray(bytes) && !(bytes instanceof ArrayBuffer) ) { // any non-number or NaN leads to empty uint8array // eslint-disable-next-line if ( typeof bytes !== "number" || (typeof bytes === "number" && bytes !== bytes) ) { bytes = 0; } else { bytes = [bytes]; } } return new Uint8Array( (bytes && bytes.buffer) || bytes, (bytes && bytes.byteOffset) || 0, (bytes && bytes.byteLength) || 0 ); }; var toHexString = function toHexString(bytes) { bytes = toUint8(bytes); var str = ""; for (var i = 0; i < bytes.length; i++) { str += padStart(bytes[i].toString(16), 2, "0"); } return str; }; var toBinaryString = function toBinaryString(bytes) { bytes = toUint8(bytes); var str = ""; for (var i = 0; i < bytes.length; i++) { str += padStart(bytes[i].toString(2), 8, "0"); } return str; }; var BigInt = global_window__WEBPACK_IMPORTED_MODULE_0___default().BigInt || Number; var BYTE_TABLE = [ BigInt("0x1"), BigInt("0x100"), BigInt("0x10000"), BigInt("0x1000000"), BigInt("0x100000000"), BigInt("0x10000000000"), BigInt("0x1000000000000"), BigInt("0x100000000000000"), BigInt("0x10000000000000000"), ]; var ENDIANNESS = (function () { var a = new Uint16Array([0xffcc]); var b = new Uint8Array(a.buffer, a.byteOffset, a.byteLength); if (b[0] === 0xff) { return "big"; } if (b[0] === 0xcc) { return "little"; } return "unknown"; })(); var IS_BIG_ENDIAN = ENDIANNESS === "big"; var IS_LITTLE_ENDIAN = ENDIANNESS === "little"; var bytesToNumber = function bytesToNumber(bytes, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$signed = _ref.signed, signed = _ref$signed === void 0 ? false : _ref$signed, _ref$le = _ref.le, le = _ref$le === void 0 ? false : _ref$le; bytes = toUint8(bytes); var fn = le ? "reduce" : "reduceRight"; var obj = bytes[fn] ? bytes[fn] : Array.prototype[fn]; var number = obj.call( bytes, function (total, byte, i) { var exponent = le ? i : Math.abs(i + 1 - bytes.length); return total + BigInt(byte) * BYTE_TABLE[exponent]; }, BigInt(0) ); if (signed) { var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1); number = BigInt(number); if (number > max) { number -= max; number -= max; number -= BigInt(2); } } return Number(number); }; var numberToBytes = function numberToBytes(number, _temp2) { var _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$le = _ref2.le, le = _ref2$le === void 0 ? false : _ref2$le; // eslint-disable-next-line if ( (typeof number !== "bigint" && typeof number !== "number") || (typeof number === "number" && number !== number) ) { number = 0; } number = BigInt(number); var byteCount = countBytes(number); var bytes = new Uint8Array(new ArrayBuffer(byteCount)); for (var i = 0; i < byteCount; i++) { var byteIndex = le ? i : Math.abs(i + 1 - bytes.length); bytes[byteIndex] = Number( (number / BYTE_TABLE[i]) & BigInt(0xff) ); if (number < 0) { bytes[byteIndex] = Math.abs(~bytes[byteIndex]); bytes[byteIndex] -= i === 0 ? 1 : 2; } } return bytes; }; var bytesToString = function bytesToString(bytes) { if (!bytes) { return ""; } // TODO: should toUint8 handle cases where we only have 8 bytes // but report more since this is a Uint16+ Array? bytes = Array.prototype.slice.call(bytes); var string = String.fromCharCode.apply(null, toUint8(bytes)); try { return decodeURIComponent(escape(string)); } catch (e) { // if decodeURIComponent/escape fails, we are dealing with partial // or full non string data. Just return the potentially garbled string. } return string; }; var stringToBytes = function stringToBytes(string, stringIsBytes) { if ( typeof string !== "string" && string && typeof string.toString === "function" ) { string = string.toString(); } if (typeof string !== "string") { return new Uint8Array(); } // If the string already is bytes, we don't have to do this // otherwise we do this so that we split multi length characters // into individual bytes if (!stringIsBytes) { string = unescape(encodeURIComponent(string)); } var view = new Uint8Array(string.length); for (var i = 0; i < string.length; i++) { view[i] = string.charCodeAt(i); } return view; }; var concatTypedArrays = function concatTypedArrays() { for ( var _len = arguments.length, buffers = new Array(_len), _key = 0; _key < _len; _key++ ) { buffers[_key] = arguments[_key]; } buffers = buffers.filter(function (b) { return ( b && (b.byteLength || b.length) && typeof b !== "string" ); }); if (buffers.length <= 1) { // for 0 length we will return empty uint8 // for 1 length we return the first uint8 return toUint8(buffers[0]); } var totalLen = buffers.reduce(function (total, buf, i) { return total + (buf.byteLength || buf.length); }, 0); var tempBuffer = new Uint8Array(totalLen); var offset = 0; buffers.forEach(function (buf) { buf = toUint8(buf); tempBuffer.set(buf, offset); offset += buf.byteLength; }); return tempBuffer; }; /** * Check if the bytes "b" are contained within bytes "a". * * @param {Uint8Array|Array} a * Bytes to check in * * @param {Uint8Array|Array} b * Bytes to check for * * @param {Object} options * options * * @param {Array|Uint8Array} [offset=0] * offset to use when looking at bytes in a * * @param {Array|Uint8Array} [mask=[]] * mask to use on bytes before comparison. * * @return {boolean} * If all bytes in b are inside of a, taking into account * bit masks. */ var bytesMatch = function bytesMatch(a, b, _temp3) { var _ref3 = _temp3 === void 0 ? {} : _temp3, _ref3$offset = _ref3.offset, offset = _ref3$offset === void 0 ? 0 : _ref3$offset, _ref3$mask = _ref3.mask, mask = _ref3$mask === void 0 ? [] : _ref3$mask; a = toUint8(a); b = toUint8(b); // ie 11 does not support uint8 every var fn = b.every ? b.every : Array.prototype.every; return ( b.length && a.length - offset >= b.length && // ie 11 doesn't support every on uin8 fn.call(b, function (bByte, i) { var aByte = mask[i] ? mask[i] & a[offset + i] : a[offset + i]; return bByte === aByte; }) ); }; var sliceBytes = function sliceBytes(src, start, end) { if (Uint8Array.prototype.slice) { return Uint8Array.prototype.slice.call(src, start, end); } return new Uint8Array( Array.prototype.slice.call(src, start, end) ); }; var reverseBytes = function reverseBytes(src) { if (src.reverse) { return src.reverse(); } return Array.prototype.reverse.call(src); }; /***/ }, /***/ 2260: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ws: function () { return /* binding */ translateLegacyCodec; }, /* harmony export */ kS: function () { return /* binding */ parseCodecs; }, /* harmony export */ Jg: function () { return /* binding */ codecsFromDefault; }, /* harmony export */ KL: function () { return /* binding */ isAudioCodec; }, /* harmony export */ _5: function () { return /* binding */ getMimeForCodec; }, /* harmony export */ p7: function () { return /* binding */ browserSupportsCodec; }, /* harmony export */ Hi: function () { return /* binding */ muxerSupportsCodec; }, /* harmony export */ lA: function () { return /* binding */ DEFAULT_AUDIO_CODEC; }, /* harmony export */ xz: function () { return /* binding */ DEFAULT_VIDEO_CODEC; }, /* harmony export */ }); /* unused harmony exports translateLegacyCodecs, mapLegacyAvcCodecs, isVideoCodec, isTextCodec */ /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( global_window__WEBPACK_IMPORTED_MODULE_0__ ); var regexs = { // to determine mime types mp4: /^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/, webm: /^(vp0?[89]|av0?1|opus|vorbis)/, ogg: /^(vp0?[89]|theora|flac|opus|vorbis)/, // to determine if a codec is audio or video video: /^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/, audio: /^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/, text: /^(stpp.ttml.im1t)/, // mux.js support regex muxerVideo: /^(avc0?1)/, muxerAudio: /^(mp4a)/, // match nothing as muxer does not support text right now. // there cannot never be a character before the start of a string // so this matches nothing. muxerText: /a^/, }; var mediaTypes = ["video", "audio", "text"]; var upperMediaTypes = ["Video", "Audio", "Text"]; /** * Replace the old apple-style `avc1.<dd>.<dd>` codec string with the standard * `avc1.<hhhhhh>` * * @param {string} codec * Codec string to translate * @return {string} * The translated codec string */ var translateLegacyCodec = function translateLegacyCodec(codec) { if (!codec) { return codec; } return codec.replace( /avc1\.(\d+)\.(\d+)/i, function (orig, profile, avcLevel) { var profileHex = ( "00" + Number(profile).toString(16) ).slice(-2); var avcLevelHex = ( "00" + Number(avcLevel).toString(16) ).slice(-2); return "avc1." + profileHex + "00" + avcLevelHex; } ); }; /** * Replace the old apple-style `avc1.<dd>.<dd>` codec strings with the standard * `avc1.<hhhhhh>` * * @param {string[]} codecs * An array of codec strings to translate * @return {string[]} * The translated array of codec strings */ var translateLegacyCodecs = function translateLegacyCodecs(codecs) { return codecs.map(translateLegacyCodec); }; /** * Replace codecs in the codec string with the old apple-style `avc1.<dd>.<dd>` to the * standard `avc1.<hhhhhh>`. * * @param {string} codecString * The codec string * @return {string} * The codec string with old apple-style codecs replaced * * @private */ var mapLegacyAvcCodecs = function mapLegacyAvcCodecs(codecString) { return codecString.replace( /avc1\.(\d+)\.(\d+)/i, function (match) { return translateLegacyCodecs([match])[0]; } ); }; /** * @typedef {Object} ParsedCodecInfo * @property {number} codecCount * Number of codecs parsed * @property {string} [videoCodec] * Parsed video codec (if found) * @property {string} [videoObjectTypeIndicator] * Video object type indicator (if found) * @property {string|null} audioProfile * Audio profile */ /** * Parses a codec string to retrieve the number of codecs specified, the video codec and * object type indicator, and the audio profile. * * @param {string} [codecString] * The codec string to parse * @return {ParsedCodecInfo} * Parsed codec info */ var parseCodecs = function parseCodecs(codecString) { if (codecString === void 0) { codecString = ""; } var codecs = codecString.split(","); var result = []; codecs.forEach(function (codec) { codec = codec.trim(); var codecType; mediaTypes.forEach(function (name) { var match = regexs[name].exec(codec.toLowerCase()); if (!match || match.length <= 1) { return; } codecType = name; // maintain codec case var type = codec.substring(0, match[1].length); var details = codec.replace(type, ""); result.push({ type: type, details: details, mediaType: name, }); }); if (!codecType) { result.push({ type: codec, details: "", mediaType: "unknown", }); } }); return result; }; /** * Returns a ParsedCodecInfo object for the default alternate audio playlist if there is * a default alternate audio playlist for the provided audio group. * * @param {Object} master * The master playlist * @param {string} audioGroupId * ID of the audio group for which to find the default codec info * @return {ParsedCodecInfo} * Parsed codec info */ var codecsFromDefault = function codecsFromDefault( master, audioGroupId ) { if (!master.mediaGroups.AUDIO || !audioGroupId) { return null; } var audioGroup = master.mediaGroups.AUDIO[audioGroupId]; if (!audioGroup) { return null; } for (var name in audioGroup) { var audioType = audioGroup[name]; if (audioType.default && audioType.playlists) { // codec should be the same for all playlists within the audio type return parseCodecs( audioType.playlists[0].attributes.CODECS ); } } return null; }; var isVideoCodec = function isVideoCodec(codec) { if (codec === void 0) { codec = ""; } return regexs.video.test(codec.trim().toLowerCase()); }; var isAudioCodec = function isAudioCodec(codec) { if (codec === void 0) { codec = ""; } return regexs.audio.test(codec.trim().toLowerCase()); }; var isTextCodec = function isTextCodec(codec) { if (codec === void 0) { codec = ""; } return regexs.text.test(codec.trim().toLowerCase()); }; var getMimeForCodec = function getMimeForCodec(codecString) { if (!codecString || typeof codecString !== "string") { return; } var codecs = codecString .toLowerCase() .split(",") .map(function (c) { return translateLegacyCodec(c.trim()); }); // default to video type var type = "video"; // only change to audio type if the only codec we have is // audio if (codecs.length === 1 && isAudioCodec(codecs[0])) { type = "audio"; } else if (codecs.length === 1 && isTextCodec(codecs[0])) { // text uses application/<container> for now type = "application"; } // default the container to mp4 var container = "mp4"; // every codec must be able to go into the container // for that container to be the correct one if ( codecs.every(function (c) { return regexs.mp4.test(c); }) ) { container = "mp4"; } else if ( codecs.every(function (c) { return regexs.webm.test(c); }) ) { container = "webm"; } else if ( codecs.every(function (c) { return regexs.ogg.test(c); }) ) { container = "ogg"; } return type + "/" + container + ';codecs="' + codecString + '"'; }; var browserSupportsCodec = function browserSupportsCodec( codecString ) { if (codecString === void 0) { codecString = ""; } return ( (global_window__WEBPACK_IMPORTED_MODULE_0___default() .MediaSource && global_window__WEBPACK_IMPORTED_MODULE_0___default() .MediaSource.isTypeSupported && global_window__WEBPACK_IMPORTED_MODULE_0___default().MediaSource.isTypeSupported( getMimeForCodec(codecString) )) || false ); }; var muxerSupportsCodec = function muxerSupportsCodec(codecString) { if (codecString === void 0) { codecString = ""; } return codecString .toLowerCase() .split(",") .every(function (codec) { codec = codec.trim(); // any match is supported. for (var i = 0; i < upperMediaTypes.length; i++) { var type = upperMediaTypes[i]; if (regexs["muxer" + type].test(codec)) { return true; } } return false; }); }; var DEFAULT_AUDIO_CODEC = "mp4a.40.2"; var DEFAULT_VIDEO_CODEC = "avc1.4d400d"; /***/ }, /***/ 6185: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Xm: function () { return /* binding */ detectContainerForBytes; }, cz: function () { return /* binding */ isLikelyFmp4MediaSegment; }, }); // UNUSED EXPORTS: isLikely // EXTERNAL MODULE: ./node_modules/@videojs/vhs-utils/es/byte-helpers.js var byte_helpers = __webpack_require__(562); // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/codec-helpers.js // https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter#AV1 var codec_helpers_getAv1Codec = function getAv1Codec(bytes) { var codec = ""; var profile = bytes[1] >>> 3; var level = bytes[1] & 0x1f; var tier = bytes[2] >>> 7; var highBitDepth = (bytes[2] & 0x40) >> 6; var twelveBit = (bytes[2] & 0x20) >> 5; var monochrome = (bytes[2] & 0x10) >> 4; var chromaSubsamplingX = (bytes[2] & 0x08) >> 3; var chromaSubsamplingY = (bytes[2] & 0x04) >> 2; var chromaSamplePosition = bytes[2] & 0x03; codec += profile + "." + padStart(level, 2, "0"); if (tier === 0) { codec += "M"; } else if (tier === 1) { codec += "H"; } var bitDepth; if (profile === 2 && highBitDepth) { bitDepth = twelveBit ? 12 : 10; } else { bitDepth = highBitDepth ? 10 : 8; } codec += "." + padStart(bitDepth, 2, "0"); // TODO: can we parse color range?? codec += "." + monochrome; codec += "." + chromaSubsamplingX + chromaSubsamplingY + chromaSamplePosition; return codec; }; var codec_helpers_getAvcCodec = function getAvcCodec(bytes) { var profileId = toHexString(bytes[1]); var constraintFlags = toHexString(bytes[2] & 0xfc); var levelId = toHexString(bytes[3]); return "" + profileId + constraintFlags + levelId; }; var codec_helpers_getHvcCodec = function getHvcCodec(bytes) { var codec = ""; var profileSpace = bytes[1] >> 6; var profileId = bytes[1] & 0x1f; var tierFlag = (bytes[1] & 0x20) >> 5; var profileCompat = bytes.subarray(2, 6); var constraintIds = bytes.subarray(6, 12); var levelId = bytes[12]; if (profileSpace === 1) { codec += "A"; } else if (profileSpace === 2) { codec += "B"; } else if (profileSpace === 3) { codec += "C"; } codec += profileId + "."; // ffmpeg does this in big endian var profileCompatVal = parseInt( toBinaryString(profileCompat).split("").reverse().join(""), 2 ); // apple does this in little endian... if (profileCompatVal > 255) { profileCompatVal = parseInt( toBinaryString(profileCompat), 2 ); } codec += profileCompatVal.toString(16) + "."; if (tierFlag === 0) { codec += "L"; } else { codec += "H"; } codec += levelId; var constraints = ""; for (var i = 0; i < constraintIds.length; i++) { var v = constraintIds[i]; if (v) { if (constraints) { constraints += "."; } constraints += v.toString(16); } } if (constraints) { codec += "." + constraints; } return codec; }; // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/opus-helpers.js var OPUS_HEAD = new Uint8Array([ // O, p, u, s 0x4f, 0x70, 0x75, 0x73, // H, e, a, d 0x48, 0x65, 0x61, 0x64, ]); // https://wiki.xiph.org/OggOpus // https://vfrmaniac.fushizen.eu/contents/opus_in_isobmff.html // https://opus-codec.org/docs/opusfile_api-0.7/structOpusHead.html var opus_helpers_parseOpusHead = function parseOpusHead(bytes) { var view = new DataView( bytes.buffer, bytes.byteOffset, bytes.byteLength ); var version = view.getUint8(0); // version 0, from mp4, does not use littleEndian. var littleEndian = version !== 0; var config = { version: version, channels: view.getUint8(1), preSkip: view.getUint16(2, littleEndian), sampleRate: view.getUint32(4, littleEndian), outputGain: view.getUint16(8, littleEndian), channelMappingFamily: view.getUint8(10), }; if (config.channelMappingFamily > 0 && bytes.length > 10) { config.streamCount = view.getUint8(11); config.twoChannelStreamCount = view.getUint8(12); config.channelMapping = []; for (var c = 0; c < config.channels; c++) { config.channelMapping.push(view.getUint8(13 + c)); } } return config; }; var setOpusHead = function setOpusHead(config) { var size = config.channelMappingFamily <= 0 ? 11 : 12 + config.channels; var view = new DataView(new ArrayBuffer(size)); var littleEndian = config.version !== 0; view.setUint8(0, config.version); view.setUint8(1, config.channels); view.setUint16(2, config.preSkip, littleEndian); view.setUint32(4, config.sampleRate, littleEndian); view.setUint16(8, config.outputGain, littleEndian); view.setUint8(10, config.channelMappingFamily); if (config.channelMappingFamily > 0) { view.setUint8(11, config.streamCount); config.channelMapping.foreach(function (cm, i) { view.setUint8(12 + i, cm); }); } return new Uint8Array(view.buffer); }; // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/mp4-helpers.js var normalizePath = function normalizePath(path) { if (typeof path === "string") { return (0, byte_helpers /* stringToBytes */.qX)(path); } if (typeof path === "number") { return path; } return path; }; var normalizePaths = function normalizePaths(paths) { if (!Array.isArray(paths)) { return [normalizePath(paths)]; } return paths.map(function (p) { return normalizePath(p); }); }; var DESCRIPTORS; var parseDescriptors = function parseDescriptors(bytes) { bytes = (0, byte_helpers /* toUint8 */.Ki)(bytes); var results = []; var i = 0; while (bytes.length > i) { var tag = bytes[i]; var size = 0; var headerSize = 0; // tag headerSize++; var byte = bytes[headerSize]; // first byte headerSize++; while (byte & 0x80) { size = (byte & 0x7f) << 7; byte = bytes[headerSize]; headerSize++; } size += byte & 0x7f; for (var z = 0; z < DESCRIPTORS.length; z++) { var _DESCRIPTORS$z = DESCRIPTORS[z], id = _DESCRIPTORS$z.id, parser = _DESCRIPTORS$z.parser; if (tag === id) { results.push( parser( bytes.subarray( headerSize, headerSize + size ) ) ); break; } } i += size + headerSize; } return results; }; DESCRIPTORS = [ { id: 0x03, parser: function parser(bytes) { var desc = { tag: 0x03, id: (bytes[0] << 8) | bytes[1], flags: bytes[2], size: 3, dependsOnEsId: 0, ocrEsId: 0, descriptors: [], url: "", }; // depends on es id if (desc.flags & 0x80) { desc.dependsOnEsId = (bytes[desc.size] << 8) | bytes[desc.size + 1]; desc.size += 2; } // url if (desc.flags & 0x40) { var len = bytes[desc.size]; desc.url = (0, byte_helpers /* bytesToString */.d3)( bytes.subarray( desc.size + 1, desc.size + 1 + len ) ); desc.size += len; } // ocr es id if (desc.flags & 0x20) { desc.ocrEsId = (bytes[desc.size] << 8) | bytes[desc.size + 1]; desc.size += 2; } desc.descriptors = parseDescriptors(bytes.subarray(desc.size)) || []; return desc; }, }, { id: 0x04, parser: function parser(bytes) { // DecoderConfigDescriptor var desc = { tag: 0x04, oti: bytes[0], streamType: bytes[1], bufferSize: (bytes[2] << 16) | (bytes[3] << 8) | bytes[4], maxBitrate: (bytes[5] << 24) | (bytes[6] << 16) | (bytes[7] << 8) | bytes[8], avgBitrate: (bytes[9] << 24) | (bytes[10] << 16) | (bytes[11] << 8) | bytes[12], descriptors: parseDescriptors(bytes.subarray(13)), }; return desc; }, }, { id: 0x05, parser: function parser(bytes) { // DecoderSpecificInfo return { tag: 0x05, bytes: bytes, }; }, }, { id: 0x06, parser: function parser(bytes) { // SLConfigDescriptor return { tag: 0x06, bytes: bytes, }; }, }, ]; /** * find any number of boxes by name given a path to it in an iso bmff * such as mp4. * * @param {TypedArray} bytes * bytes for the iso bmff to search for boxes in * * @param {Uint8Array[]|string[]|string|Uint8Array} name * An array of paths or a single path representing the name * of boxes to search through in bytes. Paths may be * uint8 (character codes) or strings. * * @param {boolean} [complete=false] * Should we search only for complete boxes on the final path. * This is very useful when you do not want to get back partial boxes * in the case of streaming files. * * @return {Uint8Array[]} * An array of the end paths that we found. */ var findBox = function findBox(bytes, paths, complete) { if (complete === void 0) { complete = false; } paths = normalizePaths(paths); bytes = (0, byte_helpers /* toUint8 */.Ki)(bytes); var results = []; if (!paths.length) { // short-circuit the search for empty paths return results; } var i = 0; while (i < bytes.length) { var size = ((bytes[i] << 24) | (bytes[i + 1] << 16) | (bytes[i + 2] << 8) | bytes[i + 3]) >>> 0; var type = bytes.subarray(i + 4, i + 8); // invalid box format. if (size === 0) { break; } var end = i + size; if (end > bytes.length) { // this box is bigger than the number of bytes we have // and complete is set, we cannot find any more boxes. if (complete) { break; } end = bytes.length; } var data = bytes.subarray(i + 8, end); if ((0, byte_helpers /* bytesMatch */.G3)(type, paths[0])) { if (paths.length === 1) { // this is the end of the path and we've found the box we were // looking for results.push(data); } else { // recursively search for the next box along the path results.push.apply( results, findBox(data, paths.slice(1), complete) ); } } i = end; } // we've finished searching all of bytes return results; }; /** * Search for a single matching box by name in an iso bmff format like * mp4. This function is useful for finding codec boxes which * can be placed arbitrarily in sample descriptions depending * on the version of the file or file type. * * @param {TypedArray} bytes * bytes for the iso bmff to search for boxes in * * @param {string|Uint8Array} name * The name of the box to find. * * @return {Uint8Array[]} * a subarray of bytes representing the name boxed we found. */ var findNamedBox = function findNamedBox(bytes, name) { name = normalizePath(name); if (!name.length) { // short-circuit the search for empty paths return bytes.subarray(bytes.length); } var i = 0; while (i < bytes.length) { if (bytesMatch(bytes.subarray(i, i + name.length), name)) { var size = ((bytes[i - 4] << 24) | (bytes[i - 3] << 16) | (bytes[i - 2] << 8) | bytes[i - 1]) >>> 0; var end = size > 1 ? i + size : bytes.byteLength; return bytes.subarray(i + 4, end); } i++; } // we've finished searching all of bytes return bytes.subarray(bytes.length); }; var parseSamples = function parseSamples( data, entrySize, parseEntry ) { if (entrySize === void 0) { entrySize = 4; } if (parseEntry === void 0) { parseEntry = function parseEntry(d) { return bytesToNumber(d); }; } var entries = []; if (!data || !data.length) { return entries; } var entryCount = bytesToNumber(data.subarray(4, 8)); for (var i = 8; entryCount; i += entrySize, entryCount--) { entries.push(parseEntry(data.subarray(i, i + entrySize))); } return entries; }; var buildFrameTable = function buildFrameTable(stbl, timescale) { var keySamples = parseSamples(findBox(stbl, ["stss"])[0]); var chunkOffsets = parseSamples(findBox(stbl, ["stco"])[0]); var timeToSamples = parseSamples( findBox(stbl, ["stts"])[0], 8, function (entry) { return { sampleCount: bytesToNumber(entry.subarray(0, 4)), sampleDelta: bytesToNumber(entry.subarray(4, 8)), }; } ); var samplesToChunks = parseSamples( findBox(stbl, ["stsc"])[0], 12, function (entry) { return { firstChunk: bytesToNumber(entry.subarray(0, 4)), samplesPerChunk: bytesToNumber( entry.subarray(4, 8) ), sampleDescriptionIndex: bytesToNumber( entry.subarray(8, 12) ), }; } ); var stsz = findBox(stbl, ["stsz"])[0]; // stsz starts with a 4 byte sampleSize which we don't need var sampleSizes = parseSamples( (stsz && stsz.length && stsz.subarray(4)) || null ); var frames = []; for ( var chunkIndex = 0; chunkIndex < chunkOffsets.length; chunkIndex++ ) { var samplesInChunk = void 0; for (var i = 0; i < samplesToChunks.length; i++) { var sampleToChunk = samplesToChunks[i]; var isThisOne = chunkIndex + 1 >= sampleToChunk.firstChunk && (i + 1 >= samplesToChunks.length || chunkIndex + 1 < samplesToChunks[i + 1].firstChunk); if (isThisOne) { samplesInChunk = sampleToChunk.samplesPerChunk; break; } } var chunkOffset = chunkOffsets[chunkIndex]; for (var _i = 0; _i < samplesInChunk; _i++) { var frameEnd = sampleSizes[frames.length]; // if we don't have key samples every frame is a keyframe var keyframe = !keySamples.length; if ( keySamples.length && keySamples.indexOf(frames.length + 1) !== -1 ) { keyframe = true; } var frame = { keyframe: keyframe, start: chunkOffset, end: chunkOffset + frameEnd, }; for (var k = 0; k < timeToSamples.length; k++) { var _timeToSamples$k = timeToSamples[k], sampleCount = _timeToSamples$k.sampleCount, sampleDelta = _timeToSamples$k.sampleDelta; if (frames.length <= sampleCount) { // ms to ns var lastTimestamp = frames.length ? frames[frames.length - 1].timestamp : 0; frame.timestamp = lastTimestamp + (sampleDelta / timescale) * 1000; frame.duration = sampleDelta; break; } } frames.push(frame); chunkOffset += frameEnd; } } return frames; }; var addSampleDescription = function addSampleDescription( track, bytes ) { var codec = bytesToString(bytes.subarray(0, 4)); if (track.type === "video") { track.info = track.info || {}; track.info.width = (bytes[28] << 8) | bytes[29]; track.info.height = (bytes[30] << 8) | bytes[31]; } else if (track.type === "audio") { track.info = track.info || {}; track.info.channels = (bytes[20] << 8) | bytes[21]; track.info.bitDepth = (bytes[22] << 8) | bytes[23]; track.info.sampleRate = (bytes[28] << 8) | bytes[29]; } if (codec === "avc1") { var avcC = findNamedBox(bytes, "avcC"); // AVCDecoderConfigurationRecord codec += "." + getAvcCodec(avcC); track.info.avcC = avcC; // TODO: do we need to parse all this? /* { configurationVersion: avcC[0], profile: avcC[1], profileCompatibility: avcC[2], level: avcC[3], lengthSizeMinusOne: avcC[4] & 0x3 }; let spsNalUnitCount = avcC[5] & 0x1F; const spsNalUnits = track.info.avc.spsNalUnits = []; // past spsNalUnitCount let offset = 6; while (spsNalUnitCount--) { const nalLen = avcC[offset] << 8 | avcC[offset + 1]; spsNalUnits.push(avcC.subarray(offset + 2, offset + 2 + nalLen)); offset += nalLen + 2; } let ppsNalUnitCount = avcC[offset]; const ppsNalUnits = track.info.avc.ppsNalUnits = []; // past ppsNalUnitCount offset += 1; while (ppsNalUnitCount--) { const nalLen = avcC[offset] << 8 | avcC[offset + 1]; ppsNalUnits.push(avcC.subarray(offset + 2, offset + 2 + nalLen)); offset += nalLen + 2; }*/ // HEVCDecoderConfigurationRecord } else if (codec === "hvc1" || codec === "hev1") { codec += "." + getHvcCodec(findNamedBox(bytes, "hvcC")); } else if (codec === "mp4a" || codec === "mp4v") { var esds = findNamedBox(bytes, "esds"); var esDescriptor = parseDescriptors(esds.subarray(4))[0]; var decoderConfig = esDescriptor && esDescriptor.descriptors.filter(function (_ref) { var tag = _ref.tag; return tag === 0x04; })[0]; if (decoderConfig) { // most codecs do not have a further '.' // such as 0xa5 for ac-3 and 0xa6 for e-ac-3 codec += "." + toHexString(decoderConfig.oti); if (decoderConfig.oti === 0x40) { codec += "." + ( decoderConfig.descriptors[0].bytes[0] >> 3 ).toString(); } else if (decoderConfig.oti === 0x20) { codec += "." + decoderConfig.descriptors[0].bytes[4].toString(); } else if (decoderConfig.oti === 0xdd) { codec = "vorbis"; } } else if (track.type === "audio") { codec += ".40.2"; } else { codec += ".20.9"; } } else if (codec === "av01") { // AV1DecoderConfigurationRecord codec += "." + getAv1Codec(findNamedBox(bytes, "av1C")); } else if (codec === "vp09") { // VPCodecConfigurationRecord var vpcC = findNamedBox(bytes, "vpcC"); // https://www.webmproject.org/vp9/mp4/ var profile = vpcC[0]; var level = vpcC[1]; var bitDepth = vpcC[2] >> 4; var chromaSubsampling = (vpcC[2] & 0x0f) >> 1; var videoFullRangeFlag = (vpcC[2] & 0x0f) >> 3; var colourPrimaries = vpcC[3]; var transferCharacteristics = vpcC[4]; var matrixCoefficients = vpcC[5]; codec += "." + padStart(profile, 2, "0"); codec += "." + padStart(level, 2, "0"); codec += "." + padStart(bitDepth, 2, "0"); codec += "." + padStart(chromaSubsampling, 2, "0"); codec += "." + padStart(colourPrimaries, 2, "0"); codec += "." + padStart(transferCharacteristics, 2, "0"); codec += "." + padStart(matrixCoefficients, 2, "0"); codec += "." + padStart(videoFullRangeFlag, 2, "0"); } else if (codec === "theo") { codec = "theora"; } else if (codec === "spex") { codec = "speex"; } else if (codec === ".mp3") { codec = "mp4a.40.34"; } else if (codec === "msVo") { codec = "vorbis"; } else if (codec === "Opus") { codec = "opus"; var dOps = findNamedBox(bytes, "dOps"); track.info.opus = parseOpusHead(dOps); // TODO: should this go into the webm code?? // Firefox requires a codecDelay for opus playback // see https://bugzilla.mozilla.org/show_bug.cgi?id=1276238 track.info.codecDelay = 6500000; } else { codec = codec.toLowerCase(); } /* eslint-enable */ // flac, ac-3, ec-3, opus track.codec = codec; }; var parseTracks = function parseTracks(bytes, frameTable) { if (frameTable === void 0) { frameTable = true; } bytes = toUint8(bytes); var traks = findBox(bytes, ["moov", "trak"], true); var tracks = []; traks.forEach(function (trak) { var track = { bytes: trak, }; var mdia = findBox(trak, ["mdia"])[0]; var hdlr = findBox(mdia, ["hdlr"])[0]; var trakType = bytesToString(hdlr.subarray(8, 12)); if (trakType === "soun") { track.type = "audio"; } else if (trakType === "vide") { track.type = "video"; } else { track.type = trakType; } var tkhd = findBox(trak, ["tkhd"])[0]; if (tkhd) { var view = new DataView( tkhd.buffer, tkhd.byteOffset, tkhd.byteLength ); var tkhdVersion = view.getUint8(0); track.number = tkhdVersion === 0 ? view.getUint32(12) : view.getUint32(20); } var mdhd = findBox(mdia, ["mdhd"])[0]; if (mdhd) { // mdhd is a FullBox, meaning it will have its own version as the first byte var version = mdhd[0]; var index = version === 0 ? 12 : 20; track.timescale = ((mdhd[index] << 24) | (mdhd[index + 1] << 16) | (mdhd[index + 2] << 8) | mdhd[index + 3]) >>> 0; } var stbl = findBox(mdia, ["minf", "stbl"])[0]; var stsd = findBox(stbl, ["stsd"])[0]; var descriptionCount = bytesToNumber(stsd.subarray(4, 8)); var offset = 8; // add codec and codec info while (descriptionCount--) { var len = bytesToNumber( stsd.subarray(offset, offset + 4) ); var sampleDescriptor = stsd.subarray( offset + 4, offset + 4 + len ); addSampleDescription(track, sampleDescriptor); offset += 4 + len; } if (frameTable) { track.frameTable = buildFrameTable( stbl, track.timescale ); } // codec has no sub parameters tracks.push(track); }); return tracks; }; var parseMediaInfo = function parseMediaInfo(bytes) { var mvhd = findBox(bytes, ["moov", "mvhd"], true)[0]; if (!mvhd || !mvhd.length) { return; } var info = {}; // ms to ns // mvhd v1 has 8 byte duration and other fields too if (mvhd[0] === 1) { info.timestampScale = bytesToNumber(mvhd.subarray(20, 24)); info.duration = bytesToNumber(mvhd.subarray(24, 32)); } else { info.timestampScale = bytesToNumber(mvhd.subarray(12, 16)); info.duration = bytesToNumber(mvhd.subarray(16, 20)); } info.bytes = mvhd; return info; }; // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/ebml-helpers.js // relevant specs for this parser: // https://matroska-org.github.io/libebml/specs.html // https://www.matroska.org/technical/elements.html // https://www.webmproject.org/docs/container/ var EBML_TAGS = { EBML: (0, byte_helpers /* toUint8 */.Ki)([ 0x1a, 0x45, 0xdf, 0xa3, ]), DocType: (0, byte_helpers /* toUint8 */.Ki)([0x42, 0x82]), Segment: (0, byte_helpers /* toUint8 */.Ki)([ 0x18, 0x53, 0x80, 0x67, ]), SegmentInfo: (0, byte_helpers /* toUint8 */.Ki)([ 0x15, 0x49, 0xa9, 0x66, ]), Tracks: (0, byte_helpers /* toUint8 */.Ki)([ 0x16, 0x54, 0xae, 0x6b, ]), Track: (0, byte_helpers /* toUint8 */.Ki)([0xae]), TrackNumber: (0, byte_helpers /* toUint8 */.Ki)([0xd7]), DefaultDuration: (0, byte_helpers /* toUint8 */.Ki)([ 0x23, 0xe3, 0x83, ]), TrackEntry: (0, byte_helpers /* toUint8 */.Ki)([0xae]), TrackType: (0, byte_helpers /* toUint8 */.Ki)([0x83]), FlagDefault: (0, byte_helpers /* toUint8 */.Ki)([0x88]), CodecID: (0, byte_helpers /* toUint8 */.Ki)([0x86]), CodecPrivate: (0, byte_helpers /* toUint8 */.Ki)([0x63, 0xa2]), VideoTrack: (0, byte_helpers /* toUint8 */.Ki)([0xe0]), AudioTrack: (0, byte_helpers /* toUint8 */.Ki)([0xe1]), // Not used yet, but will be used for live webm/mkv // see https://www.matroska.org/technical/basics.html#block-structure // see https://www.matroska.org/technical/basics.html#simpleblock-structure Cluster: (0, byte_helpers /* toUint8 */.Ki)([ 0x1f, 0x43, 0xb6, 0x75, ]), Timestamp: (0, byte_helpers /* toUint8 */.Ki)([0xe7]), TimestampScale: (0, byte_helpers /* toUint8 */.Ki)([ 0x2a, 0xd7, 0xb1, ]), BlockGroup: (0, byte_helpers /* toUint8 */.Ki)([0xa0]), BlockDuration: (0, byte_helpers /* toUint8 */.Ki)([0x9b]), Block: (0, byte_helpers /* toUint8 */.Ki)([0xa1]), SimpleBlock: (0, byte_helpers /* toUint8 */.Ki)([0xa3]), }; /** * This is a simple table to determine the length * of things in ebml. The length is one based (starts at 1, * rather than zero) and for every zero bit before a one bit * we add one to length. We also need this table because in some * case we have to xor all the length bits from another value. */ var LENGTH_TABLE = [128, 64, 32, 16, 8, 4, 2, 1]; var getLength = function getLength(byte) { var len = 1; for (var i = 0; i < LENGTH_TABLE.length; i++) { if (byte & LENGTH_TABLE[i]) { break; } len++; } return len; }; // length in ebml is stored in the first 4 to 8 bits // of the first byte. 4 for the id length and 8 for the // data size length. Length is measured by converting the number to binary // then 1 + the number of zeros before a 1 is encountered starting // from the left. var getvint = function getvint( bytes, offset, removeLength, signed ) { if (removeLength === void 0) { removeLength = true; } if (signed === void 0) { signed = false; } var length = getLength(bytes[offset]); var valueBytes = bytes.subarray(offset, offset + length); // NOTE that we do **not** subarray here because we need to copy these bytes // as they will be modified below to remove the dataSizeLen bits and we do not // want to modify the original data. normally we could just call slice on // uint8array but ie 11 does not support that... if (removeLength) { valueBytes = Array.prototype.slice.call( bytes, offset, offset + length ); valueBytes[0] ^= LENGTH_TABLE[length - 1]; } return { length: length, value: (0, byte_helpers /* bytesToNumber */.tm)( valueBytes, { signed: signed, } ), bytes: valueBytes, }; }; var ebml_helpers_normalizePath = function normalizePath(path) { if (typeof path === "string") { return path.match(/.{1,2}/g).map(function (p) { return normalizePath(p); }); } if (typeof path === "number") { return (0, byte_helpers /* numberToBytes */.hL)(path); } return path; }; var ebml_helpers_normalizePaths = function normalizePaths(paths) { if (!Array.isArray(paths)) { return [ebml_helpers_normalizePath(paths)]; } return paths.map(function (p) { return ebml_helpers_normalizePath(p); }); }; var getInfinityDataSize = function getInfinityDataSize( id, bytes, offset ) { if (offset >= bytes.length) { return bytes.length; } var innerid = getvint(bytes, offset, false); if ( (0, byte_helpers /* bytesMatch */.G3)( id.bytes, innerid.bytes ) ) { return offset; } var dataHeader = getvint(bytes, offset + innerid.length); return getInfinityDataSize( id, bytes, offset + dataHeader.length + dataHeader.value + innerid.length ); }; /** * Notes on the EBLM format. * * EBLM uses "vints" tags. Every vint tag contains * two parts * * 1. The length from the first byte. You get this by * converting the byte to binary and counting the zeros * before a 1. Then you add 1 to that. Examples * 00011111 = length 4 because there are 3 zeros before a 1. * 00100000 = length 3 because there are 2 zeros before a 1. * 00000011 = length 7 because there are 6 zeros before a 1. * * 2. The bits used for length are removed from the first byte * Then all the bytes are merged into a value. NOTE: this * is not the case for id ebml tags as there id includes * length bits. * */ var findEbml = function findEbml(bytes, paths) { paths = ebml_helpers_normalizePaths(paths); bytes = (0, byte_helpers /* toUint8 */.Ki)(bytes); var results = []; if (!paths.length) { return results; } var i = 0; while (i < bytes.length) { var id = getvint(bytes, i, false); var dataHeader = getvint(bytes, i + id.length); var dataStart = i + id.length + dataHeader.length; // dataSize is unknown or this is a live stream if (dataHeader.value === 0x7f) { dataHeader.value = getInfinityDataSize( id, bytes, dataStart ); if (dataHeader.value !== bytes.length) { dataHeader.value -= dataStart; } } var dataEnd = dataStart + dataHeader.value > bytes.length ? bytes.length : dataStart + dataHeader.value; var data = bytes.subarray(dataStart, dataEnd); if ( (0, byte_helpers /* bytesMatch */.G3)( paths[0], id.bytes ) ) { if (paths.length === 1) { // this is the end of the paths and we've found the tag we were // looking for results.push(data); } else { // recursively search for the next tag inside of the data // of this one results = results.concat( findEbml(data, paths.slice(1)) ); } } var totalLength = id.length + dataHeader.length + data.length; // move past this tag entirely, we are not looking for it i += totalLength; } return results; }; // see https://www.matroska.org/technical/basics.html#block-structure var decodeBlock = function decodeBlock( block, type, timestampScale, clusterTimestamp ) { var duration; if (type === "group") { duration = findEbml(block, [EBML_TAGS.BlockDuration])[0]; if (duration) { duration = bytesToNumber(duration); duration = ((1 / timestampScale) * duration * timestampScale) / 1000; } block = findEbml(block, [EBML_TAGS.Block])[0]; type = "block"; // treat data as a block after this point } var dv = new DataView( block.buffer, block.byteOffset, block.byteLength ); var trackNumber = getvint(block, 0); var timestamp = dv.getInt16(trackNumber.length, false); var flags = block[trackNumber.length + 2]; var data = block.subarray(trackNumber.length + 3); // pts/dts in seconds var ptsdts = ((1 / timestampScale) * (clusterTimestamp + timestamp) * timestampScale) / 1000; // return the frame var parsed = { duration: duration, trackNumber: trackNumber.value, keyframe: type === "simple" && flags >> 7 === 1, invisible: (flags & 0x08) >> 3 === 1, lacing: (flags & 0x06) >> 1, discardable: type === "simple" && (flags & 0x01) === 1, frames: [], pts: ptsdts, dts: ptsdts, timestamp: timestamp, }; if (!parsed.lacing) { parsed.frames.push(data); return parsed; } var numberOfFrames = data[0] + 1; var frameSizes = []; var offset = 1; // Fixed if (parsed.lacing === 2) { var sizeOfFrame = (data.length - offset) / numberOfFrames; for (var i = 0; i < numberOfFrames; i++) { frameSizes.push(sizeOfFrame); } } // xiph if (parsed.lacing === 1) { for (var _i = 0; _i < numberOfFrames - 1; _i++) { var size = 0; do { size += data[offset]; offset++; } while (data[offset - 1] === 0xff); frameSizes.push(size); } } // ebml if (parsed.lacing === 3) { // first vint is unsinged // after that vints are singed and // based on a compounding size var _size = 0; for (var _i2 = 0; _i2 < numberOfFrames - 1; _i2++) { var vint = _i2 === 0 ? getvint(data, offset) : getvint(data, offset, true, true); _size += vint.value; frameSizes.push(_size); offset += vint.length; } } frameSizes.forEach(function (size) { parsed.frames.push(data.subarray(offset, offset + size)); offset += size; }); return parsed; }; // VP9 Codec Feature Metadata (CodecPrivate) // https://www.webmproject.org/docs/container/ var parseVp9Private = function parseVp9Private(bytes) { var i = 0; var params = {}; while (i < bytes.length) { var id = bytes[i] & 0x7f; var len = bytes[i + 1]; var val = void 0; if (len === 1) { val = bytes[i + 2]; } else { val = bytes.subarray(i + 2, i + 2 + len); } if (id === 1) { params.profile = val; } else if (id === 2) { params.level = val; } else if (id === 3) { params.bitDepth = val; } else if (id === 4) { params.chromaSubsampling = val; } else { params[id] = val; } i += 2 + len; } return params; }; var ebml_helpers_parseTracks = function parseTracks(bytes) { bytes = toUint8(bytes); var decodedTracks = []; var tracks = findEbml(bytes, [ EBML_TAGS.Segment, EBML_TAGS.Tracks, EBML_TAGS.Track, ]); if (!tracks.length) { tracks = findEbml(bytes, [ EBML_TAGS.Tracks, EBML_TAGS.Track, ]); } if (!tracks.length) { tracks = findEbml(bytes, [EBML_TAGS.Track]); } if (!tracks.length) { return decodedTracks; } tracks.forEach(function (track) { var trackType = findEbml(track, EBML_TAGS.TrackType)[0]; if (!trackType || !trackType.length) { return; } // 1 is video, 2 is audio, 17 is subtitle // other values are unimportant in this context if (trackType[0] === 1) { trackType = "video"; } else if (trackType[0] === 2) { trackType = "audio"; } else if (trackType[0] === 17) { trackType = "subtitle"; } else { return; } // todo parse language var decodedTrack = { rawCodec: bytesToString( findEbml(track, [EBML_TAGS.CodecID])[0] ), type: trackType, codecPrivate: findEbml(track, [ EBML_TAGS.CodecPrivate, ])[0], number: bytesToNumber( findEbml(track, [EBML_TAGS.TrackNumber])[0] ), defaultDuration: bytesToNumber( findEbml(track, [EBML_TAGS.DefaultDuration])[0] ), default: findEbml(track, [EBML_TAGS.FlagDefault])[0], rawData: track, }; var codec = ""; if (/V_MPEG4\/ISO\/AVC/.test(decodedTrack.rawCodec)) { codec = "avc1." + getAvcCodec(decodedTrack.codecPrivate); } else if ( /V_MPEGH\/ISO\/HEVC/.test(decodedTrack.rawCodec) ) { codec = "hev1." + getHvcCodec(decodedTrack.codecPrivate); } else if ( /V_MPEG4\/ISO\/ASP/.test(decodedTrack.rawCodec) ) { if (decodedTrack.codecPrivate) { codec = "mp4v.20." + decodedTrack.codecPrivate[4].toString(); } else { codec = "mp4v.20.9"; } } else if (/^V_THEORA/.test(decodedTrack.rawCodec)) { codec = "theora"; } else if (/^V_VP8/.test(decodedTrack.rawCodec)) { codec = "vp8"; } else if (/^V_VP9/.test(decodedTrack.rawCodec)) { if (decodedTrack.codecPrivate) { var _parseVp9Private = parseVp9Private( decodedTrack.codecPrivate ), profile = _parseVp9Private.profile, level = _parseVp9Private.level, bitDepth = _parseVp9Private.bitDepth, chromaSubsampling = _parseVp9Private.chromaSubsampling; codec = "vp09."; codec += padStart(profile, 2, "0") + "."; codec += padStart(level, 2, "0") + "."; codec += padStart(bitDepth, 2, "0") + "."; codec += "" + padStart(chromaSubsampling, 2, "0"); // Video -> Colour -> Ebml name var matrixCoefficients = findEbml(track, [ 0xe0, [0x55, 0xb0], [0x55, 0xb1], ])[0] || []; var videoFullRangeFlag = findEbml(track, [ 0xe0, [0x55, 0xb0], [0x55, 0xb9], ])[0] || []; var transferCharacteristics = findEbml(track, [ 0xe0, [0x55, 0xb0], [0x55, 0xba], ])[0] || []; var colourPrimaries = findEbml(track, [ 0xe0, [0x55, 0xb0], [0x55, 0xbb], ])[0] || []; // if we find any optional codec parameter specify them all. if ( matrixCoefficients.length || videoFullRangeFlag.length || transferCharacteristics.length || colourPrimaries.length ) { codec += "." + padStart(colourPrimaries[0], 2, "0"); codec += "." + padStart( transferCharacteristics[0], 2, "0" ); codec += "." + padStart(matrixCoefficients[0], 2, "0"); codec += "." + padStart(videoFullRangeFlag[0], 2, "0"); } } else { codec = "vp9"; } } else if (/^V_AV1/.test(decodedTrack.rawCodec)) { codec = "av01." + getAv1Codec(decodedTrack.codecPrivate); } else if (/A_ALAC/.test(decodedTrack.rawCodec)) { codec = "alac"; } else if (/A_MPEG\/L2/.test(decodedTrack.rawCodec)) { codec = "mp2"; } else if (/A_MPEG\/L3/.test(decodedTrack.rawCodec)) { codec = "mp3"; } else if (/^A_AAC/.test(decodedTrack.rawCodec)) { if (decodedTrack.codecPrivate) { codec = "mp4a.40." + (decodedTrack.codecPrivate[0] >>> 3).toString(); } else { codec = "mp4a.40.2"; } } else if (/^A_AC3/.test(decodedTrack.rawCodec)) { codec = "ac-3"; } else if (/^A_PCM/.test(decodedTrack.rawCodec)) { codec = "pcm"; } else if (/^A_MS\/ACM/.test(decodedTrack.rawCodec)) { codec = "speex"; } else if (/^A_EAC3/.test(decodedTrack.rawCodec)) { codec = "ec-3"; } else if (/^A_VORBIS/.test(decodedTrack.rawCodec)) { codec = "vorbis"; } else if (/^A_FLAC/.test(decodedTrack.rawCodec)) { codec = "flac"; } else if (/^A_OPUS/.test(decodedTrack.rawCodec)) { codec = "opus"; } decodedTrack.codec = codec; decodedTracks.push(decodedTrack); }); return decodedTracks.sort(function (a, b) { return a.number - b.number; }); }; var parseData = function parseData(data, tracks) { var allBlocks = []; var segment = findEbml(data, [EBML_TAGS.Segment])[0]; var timestampScale = findEbml(segment, [ EBML_TAGS.SegmentInfo, EBML_TAGS.TimestampScale, ])[0]; // in nanoseconds, defaults to 1ms if (timestampScale && timestampScale.length) { timestampScale = bytesToNumber(timestampScale); } else { timestampScale = 1000000; } var clusters = findEbml(segment, [EBML_TAGS.Cluster]); if (!tracks) { tracks = ebml_helpers_parseTracks(segment); } clusters.forEach(function (cluster, ci) { var simpleBlocks = findEbml(cluster, [ EBML_TAGS.SimpleBlock, ]).map(function (b) { return { type: "simple", data: b, }; }); var blockGroups = findEbml(cluster, [ EBML_TAGS.BlockGroup, ]).map(function (b) { return { type: "group", data: b, }; }); var timestamp = findEbml(cluster, [EBML_TAGS.Timestamp])[0] || 0; if (timestamp && timestamp.length) { timestamp = bytesToNumber(timestamp); } // get all blocks then sort them into the correct order var blocks = simpleBlocks .concat(blockGroups) .sort(function (a, b) { return a.data.byteOffset - b.data.byteOffset; }); blocks.forEach(function (block, bi) { var decoded = decodeBlock( block.data, block.type, timestampScale, timestamp ); allBlocks.push(decoded); }); }); return { tracks: tracks, blocks: allBlocks, }; }; // EXTERNAL MODULE: ./node_modules/@videojs/vhs-utils/es/id3-helpers.js var id3_helpers = __webpack_require__(8925); // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/nal-helpers.js var NAL_TYPE_ONE = (0, byte_helpers /* toUint8 */.Ki)([ 0x00, 0x00, 0x00, 0x01, ]); var NAL_TYPE_TWO = (0, byte_helpers /* toUint8 */.Ki)([ 0x00, 0x00, 0x01, ]); var EMULATION_PREVENTION = (0, byte_helpers /* toUint8 */.Ki)([ 0x00, 0x00, 0x03, ]); /** * Expunge any "Emulation Prevention" bytes from a "Raw Byte * Sequence Payload" * * @param data {Uint8Array} the bytes of a RBSP from a NAL * unit * @return {Uint8Array} the RBSP without any Emulation * Prevention Bytes */ var discardEmulationPreventionBytes = function discardEmulationPreventionBytes(bytes) { var positions = []; var i = 1; // Find all `Emulation Prevention Bytes` while (i < bytes.length - 2) { if ( (0, byte_helpers /* bytesMatch */.G3)( bytes.subarray(i, i + 3), EMULATION_PREVENTION ) ) { positions.push(i + 2); i++; } i++; } // If no Emulation Prevention Bytes were found just return the original // array if (positions.length === 0) { return bytes; } // Create a new array to hold the NAL unit data var newLength = bytes.length - positions.length; var newData = new Uint8Array(newLength); var sourceIndex = 0; for (i = 0; i < newLength; sourceIndex++, i++) { if (sourceIndex === positions[0]) { // Skip this byte sourceIndex++; // Remove this position index positions.shift(); } newData[i] = bytes[sourceIndex]; } return newData; }; var findNal = function findNal(bytes, dataType, types, nalLimit) { if (nalLimit === void 0) { nalLimit = Infinity; } bytes = (0, byte_helpers /* toUint8 */.Ki)(bytes); types = [].concat(types); var i = 0; var nalStart; var nalsFound = 0; // keep searching until: // we reach the end of bytes // we reach the maximum number of nals they want to seach // NOTE: that we disregard nalLimit when we have found the start // of the nal we want so that we can find the end of the nal we want. while (i < bytes.length && (nalsFound < nalLimit || nalStart)) { var nalOffset = void 0; if ( (0, byte_helpers /* bytesMatch */.G3)( bytes.subarray(i), NAL_TYPE_ONE ) ) { nalOffset = 4; } else if ( (0, byte_helpers /* bytesMatch */.G3)( bytes.subarray(i), NAL_TYPE_TWO ) ) { nalOffset = 3; } // we are unsynced, // find the next nal unit if (!nalOffset) { i++; continue; } nalsFound++; if (nalStart) { return discardEmulationPreventionBytes( bytes.subarray(nalStart, i) ); } var nalType = void 0; if (dataType === "h264") { nalType = bytes[i + nalOffset] & 0x1f; } else if (dataType === "h265") { nalType = (bytes[i + nalOffset] >> 1) & 0x3f; } if (types.indexOf(nalType) !== -1) { nalStart = i + nalOffset; } // nal header is 1 length for h264, and 2 for h265 i += nalOffset + (dataType === "h264" ? 1 : 2); } return bytes.subarray(0, 0); }; var findH264Nal = function findH264Nal(bytes, type, nalLimit) { return findNal(bytes, "h264", type, nalLimit); }; var findH265Nal = function findH265Nal(bytes, type, nalLimit) { return findNal(bytes, "h265", type, nalLimit); }; // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/containers.js var CONSTANTS = { // "webm" string literal in hex webm: (0, byte_helpers /* toUint8 */.Ki)([ 0x77, 0x65, 0x62, 0x6d, ]), // "matroska" string literal in hex matroska: (0, byte_helpers /* toUint8 */.Ki)([ 0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61, ]), // "fLaC" string literal in hex flac: (0, byte_helpers /* toUint8 */.Ki)([ 0x66, 0x4c, 0x61, 0x43, ]), // "OggS" string literal in hex ogg: (0, byte_helpers /* toUint8 */.Ki)([ 0x4f, 0x67, 0x67, 0x53, ]), // ac-3 sync byte, also works for ec-3 as that is simply a codec // of ac-3 ac3: (0, byte_helpers /* toUint8 */.Ki)([0x0b, 0x77]), // "RIFF" string literal in hex used for wav and avi riff: (0, byte_helpers /* toUint8 */.Ki)([ 0x52, 0x49, 0x46, 0x46, ]), // "AVI" string literal in hex avi: (0, byte_helpers /* toUint8 */.Ki)([0x41, 0x56, 0x49]), // "WAVE" string literal in hex wav: (0, byte_helpers /* toUint8 */.Ki)([ 0x57, 0x41, 0x56, 0x45, ]), // "ftyp3g" string literal in hex "3gp": (0, byte_helpers /* toUint8 */.Ki)([ 0x66, 0x74, 0x79, 0x70, 0x33, 0x67, ]), // "ftyp" string literal in hex mp4: (0, byte_helpers /* toUint8 */.Ki)([ 0x66, 0x74, 0x79, 0x70, ]), // "styp" string literal in hex fmp4: (0, byte_helpers /* toUint8 */.Ki)([ 0x73, 0x74, 0x79, 0x70, ]), // "ftypqt" string literal in hex mov: (0, byte_helpers /* toUint8 */.Ki)([ 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, ]), // moov string literal in hex moov: (0, byte_helpers /* toUint8 */.Ki)([ 0x6d, 0x6f, 0x6f, 0x76, ]), // moof string literal in hex moof: (0, byte_helpers /* toUint8 */.Ki)([ 0x6d, 0x6f, 0x6f, 0x66, ]), }; var _isLikely = { aac: function aac(bytes) { var offset = (0, id3_helpers /* getId3Offset */.c)(bytes); return (0, byte_helpers /* bytesMatch */.G3)( bytes, [0xff, 0x10], { offset: offset, mask: [0xff, 0x16], } ); }, mp3: function mp3(bytes) { var offset = (0, id3_helpers /* getId3Offset */.c)(bytes); return (0, byte_helpers /* bytesMatch */.G3)( bytes, [0xff, 0x02], { offset: offset, mask: [0xff, 0x06], } ); }, webm: function webm(bytes) { var docType = findEbml(bytes, [ EBML_TAGS.EBML, EBML_TAGS.DocType, ])[0]; // check if DocType EBML tag is webm return (0, byte_helpers /* bytesMatch */.G3)( docType, CONSTANTS.webm ); }, mkv: function mkv(bytes) { var docType = findEbml(bytes, [ EBML_TAGS.EBML, EBML_TAGS.DocType, ])[0]; // check if DocType EBML tag is matroska return (0, byte_helpers /* bytesMatch */.G3)( docType, CONSTANTS.matroska ); }, mp4: function mp4(bytes) { // if this file is another base media file format, it is not mp4 if (_isLikely["3gp"](bytes) || _isLikely.mov(bytes)) { return false; } // if this file starts with a ftyp or styp box its mp4 if ( (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.mp4, { offset: 4, } ) || (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.fmp4, { offset: 4, } ) ) { return true; } // if this file starts with a moof/moov box its mp4 if ( (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.moof, { offset: 4, } ) || (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.moov, { offset: 4, } ) ) { return true; } }, mov: function mov(bytes) { return (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.mov, { offset: 4, } ); }, "3gp": function gp(bytes) { return (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS["3gp"], { offset: 4, } ); }, ac3: function ac3(bytes) { var offset = (0, id3_helpers /* getId3Offset */.c)(bytes); return (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.ac3, { offset: offset, } ); }, ts: function ts(bytes) { if (bytes.length < 189 && bytes.length >= 1) { return bytes[0] === 0x47; } var i = 0; // check the first 376 bytes for two matching sync bytes while (i + 188 < bytes.length && i < 188) { if (bytes[i] === 0x47 && bytes[i + 188] === 0x47) { return true; } i += 1; } return false; }, flac: function flac(bytes) { var offset = (0, id3_helpers /* getId3Offset */.c)(bytes); return (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.flac, { offset: offset, } ); }, ogg: function ogg(bytes) { return (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.ogg ); }, avi: function avi(bytes) { return ( (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.riff ) && (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.avi, { offset: 8, } ) ); }, wav: function wav(bytes) { return ( (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.riff ) && (0, byte_helpers /* bytesMatch */.G3)( bytes, CONSTANTS.wav, { offset: 8, } ) ); }, h264: function h264(bytes) { // find seq_parameter_set_rbsp return findH264Nal(bytes, 7, 3).length; }, h265: function h265(bytes) { // find video_parameter_set_rbsp or seq_parameter_set_rbsp return findH265Nal(bytes, [32, 33], 3).length; }, }; // get all the isLikely functions // but make sure 'ts' is above h264 and h265 // but below everything else as it is the least specific var isLikelyTypes = Object.keys(_isLikely) // remove ts, h264, h265 .filter(function (t) { return t !== "ts" && t !== "h264" && t !== "h265"; }) // add it back to the bottom .concat(["ts", "h264", "h265"]); // make sure we are dealing with uint8 data. isLikelyTypes.forEach(function (type) { var isLikelyFn = _isLikely[type]; _isLikely[type] = function (bytes) { return isLikelyFn( (0, byte_helpers /* toUint8 */.Ki)(bytes) ); }; }); // export after wrapping var isLikely = _isLikely; // A useful list of file signatures can be found here // https://en.wikipedia.org/wiki/List_of_file_signatures var detectContainerForBytes = function detectContainerForBytes( bytes ) { bytes = (0, byte_helpers /* toUint8 */.Ki)(bytes); for (var i = 0; i < isLikelyTypes.length; i++) { var type = isLikelyTypes[i]; if (isLikely[type](bytes)) { return type; } } return ""; }; // fmp4 is not a container var isLikelyFmp4MediaSegment = function isLikelyFmp4MediaSegment( bytes ) { return findBox(bytes, ["moof"]).length > 0; }; /***/ }, /***/ 6722: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ decodeB64ToUint8Array; }, /* harmony export */ }); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( global_window__WEBPACK_IMPORTED_MODULE_0__ ); /* provided dependency */ var Buffer = __webpack_require__(816)["Buffer"]; var atob = function atob(s) { return global_window__WEBPACK_IMPORTED_MODULE_0___default().atob ? global_window__WEBPACK_IMPORTED_MODULE_0___default().atob( s ) : Buffer.from(s, "base64").toString("binary"); }; function decodeB64ToUint8Array(b64Text) { var decodedString = atob(b64Text); var array = new Uint8Array(decodedString.length); for (var i = 0; i < decodedString.length; i++) { array[i] = decodedString.charCodeAt(i); } return array; } /***/ }, /***/ 8925: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ c: function () { return /* binding */ getId3Offset; }, /* harmony export */ }); /* unused harmony export getId3Size */ /* harmony import */ var _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(562); var ID3 = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */.Ki)([ 0x49, 0x44, 0x33, ]); var getId3Size = function getId3Size(bytes, offset) { if (offset === void 0) { offset = 0; } bytes = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */.Ki)( bytes ); var flags = bytes[offset + 5]; var returnSize = (bytes[offset + 6] << 21) | (bytes[offset + 7] << 14) | (bytes[offset + 8] << 7) | bytes[offset + 9]; var footerPresent = (flags & 16) >> 4; if (footerPresent) { return returnSize + 20; } return returnSize + 10; }; var getId3Offset = function getId3Offset(bytes, offset) { if (offset === void 0) { offset = 0; } bytes = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */.Ki)( bytes ); if ( bytes.length - offset < 10 || !(0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .bytesMatch */.G3)( bytes, ID3, { offset: offset, } ) ) { return offset; } offset += getId3Size(bytes, offset); // recursive check for id3 tags as some files // have multiple ID3 tag sections even though // they should not. return getId3Offset(bytes, offset); }; /***/ }, /***/ 8485: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ t: function () { return /* binding */ simpleTypeFromSourceType; }, /* harmony export */ }); var MPEGURL_REGEX = /^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i; var DASH_REGEX = /^application\/dash\+xml/i; /** * Returns a string that describes the type of source based on a video source object's * media type. * * @see {@link https://dev.w3.org/html5/pf-summary/video.html#dom-source-type|Source Type} * * @param {string} type * Video source object media type * @return {('hls'|'dash'|'vhs-json'|null)} * VHS source type string */ var simpleTypeFromSourceType = function simpleTypeFromSourceType( type ) { if (MPEGURL_REGEX.test(type)) { return "hls"; } if (DASH_REGEX.test(type)) { return "dash"; } // Denotes the special case of a manifest object passed to http-streaming instead of a // source URL. // // See https://en.wikipedia.org/wiki/Media_type for details on specifying media types. // // In this case, vnd stands for vendor, video.js for the organization, VHS for this // project, and the +json suffix identifies the structure of the media type. if (type === "application/vnd.videojs.vhs+json") { return "vhs-json"; } return null; }; /***/ }, /***/ 779: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony import */ var url_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9945); /* harmony import */ var url_toolkit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( url_toolkit__WEBPACK_IMPORTED_MODULE_0__ ); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8908); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n( global_window__WEBPACK_IMPORTED_MODULE_1__ ); var DEFAULT_LOCATION = "http://example.com"; var resolveUrl = function resolveUrl(baseUrl, relativeUrl) { // return early if we don't need to resolve if (/^[a-z]+:/i.test(relativeUrl)) { return relativeUrl; } // if baseUrl is a data URI, ignore it and resolve everything relative to window.location if (/^data:/.test(baseUrl)) { baseUrl = (global_window__WEBPACK_IMPORTED_MODULE_1___default() .location && global_window__WEBPACK_IMPORTED_MODULE_1___default() .location.href) || ""; } // IE11 supports URL but not the URL constructor // feature detect the behavior we want var nativeURL = typeof global_window__WEBPACK_IMPORTED_MODULE_1___default() .URL === "function"; var protocolLess = /^\/\//.test(baseUrl); // remove location if window.location isn't available (i.e. we're in node) // and if baseUrl isn't an absolute url var removeLocation = !global_window__WEBPACK_IMPORTED_MODULE_1___default() .location && !/\/\//i.test(baseUrl); // if the base URL is relative then combine with the current location if (nativeURL) { baseUrl = new (global_window__WEBPACK_IMPORTED_MODULE_1___default().URL)( baseUrl, global_window__WEBPACK_IMPORTED_MODULE_1___default() .location || DEFAULT_LOCATION ); } else if (!/\/\//i.test(baseUrl)) { baseUrl = url_toolkit__WEBPACK_IMPORTED_MODULE_0___default().buildAbsoluteURL( (global_window__WEBPACK_IMPORTED_MODULE_1___default() .location && global_window__WEBPACK_IMPORTED_MODULE_1___default() .location.href) || "", baseUrl ); } if (nativeURL) { var newUrl = new URL(relativeUrl, baseUrl); // if we're a protocol-less url, remove the protocol // and if we're location-less, remove the location // otherwise, return the url unmodified if (removeLocation) { return newUrl.href.slice(DEFAULT_LOCATION.length); } else if (protocolLess) { return newUrl.href.slice(newUrl.protocol.length); } return newUrl.href; } return url_toolkit__WEBPACK_IMPORTED_MODULE_0___default().buildAbsoluteURL( baseUrl, relativeUrl ); }; /* harmony default export */ __webpack_exports__["Z"] = resolveUrl; /***/ }, /***/ 3490: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { "use strict"; var window = __webpack_require__(8908); var httpResponseHandler = function httpResponseHandler( callback, decodeResponseBody ) { if (decodeResponseBody === void 0) { decodeResponseBody = false; } return function (err, response, responseBody) { // if the XHR failed, return that error if (err) { callback(err); return; } // if the HTTP status code is 4xx or 5xx, the request also failed if ( response.statusCode >= 400 && response.statusCode <= 599 ) { var cause = responseBody; if (decodeResponseBody) { if (window.TextDecoder) { var charset = getCharset( response.headers && response.headers["content-type"] ); try { cause = new TextDecoder(charset).decode( responseBody ); } catch (e) {} } else { cause = String.fromCharCode.apply( null, new Uint8Array(responseBody) ); } } callback({ cause: cause, }); return; } // otherwise, request succeeded callback(null, responseBody); }; }; function getCharset(contentTypeHeader) { if (contentTypeHeader === void 0) { contentTypeHeader = ""; } return contentTypeHeader .toLowerCase() .split(";") .reduce(function (charset, contentType) { var _contentType$split = contentType.split("="), type = _contentType$split[0], value = _contentType$split[1]; if (type.trim() === "charset") { return value.trim(); } return charset; }, "utf-8"); } module.exports = httpResponseHandler; /***/ }, /***/ 9603: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { "use strict"; var window = __webpack_require__(8908); var _extends = __webpack_require__(7154); var isFunction = __webpack_require__(7376); createXHR.httpHandler = __webpack_require__(3490); /** * @license * slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/> * Copyright (c) 2014 David Björklund * Available under the MIT license * <https://github.com/kesla/parse-headers/blob/master/LICENCE> */ var parseHeaders = function parseHeaders(headers) { var result = {}; if (!headers) { return result; } headers .trim() .split("\n") .forEach(function (row) { var index = row.indexOf(":"); var key = row.slice(0, index).trim().toLowerCase(); var value = row.slice(index + 1).trim(); if (typeof result[key] === "undefined") { result[key] = value; } else if (Array.isArray(result[key])) { result[key].push(value); } else { result[key] = [result[key], value]; } }); return result; }; module.exports = createXHR; // Allow use of default import syntax in TypeScript module.exports["default"] = createXHR; createXHR.XMLHttpRequest = window.XMLHttpRequest || noop; createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest; forEachArray( ["get", "put", "post", "patch", "head", "delete"], function (method) { createXHR[method === "delete" ? "del" : method] = function ( uri, options, callback ) { options = initParams(uri, options, callback); options.method = method.toUpperCase(); return _createXHR(options); }; } ); function forEachArray(array, iterator) { for (var i = 0; i < array.length; i++) { iterator(array[i]); } } function isEmpty(obj) { for (var i in obj) { if (obj.hasOwnProperty(i)) return false; } return true; } function initParams(uri, options, callback) { var params = uri; if (isFunction(options)) { callback = options; if (typeof uri === "string") { params = { uri: uri, }; } } else { params = _extends({}, options, { uri: uri, }); } params.callback = callback; return params; } function createXHR(uri, options, callback) { options = initParams(uri, options, callback); return _createXHR(options); } function _createXHR(options) { if (typeof options.callback === "undefined") { throw new Error("callback argument missing"); } var called = false; var callback = function cbOnce(err, response, body) { if (!called) { called = true; options.callback(err, response, body); } }; function readystatechange() { if (xhr.readyState === 4) { setTimeout(loadFunc, 0); } } function getBody() { // Chrome with requestType=blob throws errors arround when even testing access to responseText var body = undefined; if (xhr.response) { body = xhr.response; } else { body = xhr.responseText || getXml(xhr); } if (isJson) { try { body = JSON.parse(body); } catch (e) {} } return body; } function errorFunc(evt) { clearTimeout(timeoutTimer); if (!(evt instanceof Error)) { evt = new Error( "" + (evt || "Unknown XMLHttpRequest Error") ); } evt.statusCode = 0; return callback(evt, failureResponse); } // will load the data & process the response in a special response object function loadFunc() { if (aborted) return; var status; clearTimeout(timeoutTimer); if (options.useXDR && xhr.status === undefined) { //IE8 CORS GET successful response doesn't have a status field, but body is fine status = 200; } else { status = xhr.status === 1223 ? 204 : xhr.status; } var response = failureResponse; var err = null; if (status !== 0) { response = { body: getBody(), statusCode: status, method: method, headers: {}, url: uri, rawRequest: xhr, }; if (xhr.getAllResponseHeaders) { //remember xhr can in fact be XDR for CORS in IE response.headers = parseHeaders( xhr.getAllResponseHeaders() ); } } else { err = new Error("Internal XMLHttpRequest Error"); } return callback(err, response, response.body); } var xhr = options.xhr || null; if (!xhr) { if (options.cors || options.useXDR) { xhr = new createXHR.XDomainRequest(); } else { xhr = new createXHR.XMLHttpRequest(); } } var key; var aborted; var uri = (xhr.url = options.uri || options.url); var method = (xhr.method = options.method || "GET"); var body = options.body || options.data; var headers = (xhr.headers = options.headers || {}); var sync = !!options.sync; var isJson = false; var timeoutTimer; var failureResponse = { body: undefined, headers: {}, statusCode: 0, method: method, url: uri, rawRequest: xhr, }; if ("json" in options && options.json !== false) { isJson = true; headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user if (method !== "GET" && method !== "HEAD") { headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user body = JSON.stringify( options.json === true ? body : options.json ); } } xhr.onreadystatechange = readystatechange; xhr.onload = loadFunc; xhr.onerror = errorFunc; // IE9 must have onprogress be set to a unique function. xhr.onprogress = function () { // IE must die }; xhr.onabort = function () { aborted = true; }; xhr.ontimeout = errorFunc; xhr.open( method, uri, !sync, options.username, options.password ); //has to be after open if (!sync) { xhr.withCredentials = !!options.withCredentials; } // Cannot set timeout with sync request // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent if (!sync && options.timeout > 0) { timeoutTimer = setTimeout(function () { if (aborted) return; aborted = true; //IE9 may still call readystatechange xhr.abort("timeout"); var e = new Error("XMLHttpRequest timeout"); e.code = "ETIMEDOUT"; errorFunc(e); }, options.timeout); } if (xhr.setRequestHeader) { for (key in headers) { if (headers.hasOwnProperty(key)) { xhr.setRequestHeader(key, headers[key]); } } } else if (options.headers && !isEmpty(options.headers)) { throw new Error( "Headers cannot be set on an XDomainRequest object" ); } if ("responseType" in options) { xhr.responseType = options.responseType; } if ( "beforeSend" in options && typeof options.beforeSend === "function" ) { options.beforeSend(xhr); } // Microsoft Edge browser sends "undefined" when send is called with undefined value. // XMLHttpRequest spec says to pass null as body to indicate no body // See https://github.com/naugtur/xhr/issues/100. xhr.send(body || null); return xhr; } function getXml(xhr) { // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException" // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML. try { if (xhr.responseType === "document") { return xhr.responseXML; } var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror"; if (xhr.responseType === "" && !firefoxBugTakenEffect) { return xhr.responseXML; } } catch (e) {} return null; } function noop() {} /***/ }, /***/ 2167: /***/ function (__unused_webpack_module, exports) { "use strict"; /** * "Shallow freezes" an object to render it immutable. * Uses `Object.freeze` if available, * otherwise the immutability is only in the type. * * Is used to create "enum like" objects. * * @template T * @param {T} object the object to freeze * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default, * allows to inject custom object constructor for tests * @returns {Readonly<T>} * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze */ function freeze(object, oc) { if (oc === undefined) { oc = Object; } return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object; } /** * All mime types that are allowed as input to `DOMParser.parseFromString` * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec * @see DOMParser.prototype.parseFromString */ var MIME_TYPE = freeze({ /** * `text/html`, the only mime type that triggers treating an XML document as HTML. * * @see DOMParser.SupportedType.isHTML * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration * @see https://en.wikipedia.org/wiki/HTML Wikipedia * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec */ HTML: "text/html", /** * Helper method to check a mime type if it indicates an HTML document * * @param {string} [value] * @returns {boolean} * * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration * @see https://en.wikipedia.org/wiki/HTML Wikipedia * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */ isHTML: function (value) { return value === MIME_TYPE.HTML; }, /** * `application/xml`, the standard mime type for XML documents. * * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303 * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_APPLICATION: "application/xml", /** * `text/html`, an alias for `application/xml`. * * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303 * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_TEXT: "text/xml", /** * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace, * but is parsed as an XML document. * * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec * @see https://en.wikipedia.org/wiki/XHTML Wikipedia */ XML_XHTML_APPLICATION: "application/xhtml+xml", /** * `image/svg+xml`, * * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1 * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia */ XML_SVG_IMAGE: "image/svg+xml", }); /** * Namespaces that are used in this code base. * * @see http://www.w3.org/TR/REC-xml-names */ var NAMESPACE = freeze({ /** * The XHTML namespace. * * @see http://www.w3.org/1999/xhtml */ HTML: "http://www.w3.org/1999/xhtml", /** * Checks if `uri` equals `NAMESPACE.HTML`. * * @param {string} [uri] * * @see NAMESPACE.HTML */ isHTML: function (uri) { return uri === NAMESPACE.HTML; }, /** * The SVG namespace. * * @see http://www.w3.org/2000/svg */ SVG: "http://www.w3.org/2000/svg", /** * The `xml:` namespace. * * @see http://www.w3.org/XML/1998/namespace */ XML: "http://www.w3.org/XML/1998/namespace", /** * The `xmlns:` namespace * * @see https://www.w3.org/2000/xmlns/ */ XMLNS: "http://www.w3.org/2000/xmlns/", }); exports.freeze = freeze; exports.MIME_TYPE = MIME_TYPE; exports.NAMESPACE = NAMESPACE; /***/ }, /***/ 6129: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { var __webpack_unused_export__; var conventions = __webpack_require__(2167); var dom = __webpack_require__(1146); var entities = __webpack_require__(1045); var sax = __webpack_require__(6925); var DOMImplementation = dom.DOMImplementation; var NAMESPACE = conventions.NAMESPACE; var ParseError = sax.ParseError; var XMLReader = sax.XMLReader; function DOMParser(options) { this.options = options || { locator: {} }; } DOMParser.prototype.parseFromString = function (source, mimeType) { var options = this.options; var sax = new XMLReader(); var domBuilder = options.domBuilder || new DOMHandler(); //contentHandler and LexicalHandler var errorHandler = options.errorHandler; var locator = options.locator; var defaultNSMap = options.xmlns || {}; var isHTML = /\/x?html?$/.test(mimeType); //mimeType.toLowerCase().indexOf('html') > -1; var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES; if (locator) { domBuilder.setDocumentLocator(locator); } sax.errorHandler = buildErrorHandler( errorHandler, domBuilder, locator ); sax.domBuilder = options.domBuilder || domBuilder; if (isHTML) { defaultNSMap[""] = NAMESPACE.HTML; } defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML; if (source && typeof source === "string") { sax.parse(source, defaultNSMap, entityMap); } else { sax.errorHandler.error("invalid doc source"); } return domBuilder.doc; }; function buildErrorHandler(errorImpl, domBuilder, locator) { if (!errorImpl) { if (domBuilder instanceof DOMHandler) { return domBuilder; } errorImpl = domBuilder; } var errorHandler = {}; var isCallback = errorImpl instanceof Function; locator = locator || {}; function build(key) { var fn = errorImpl[key]; if (!fn && isCallback) { fn = errorImpl.length == 2 ? function (msg) { errorImpl(key, msg); } : errorImpl; } errorHandler[key] = (fn && function (msg) { fn( "[xmldom " + key + "]\t" + msg + _locator(locator) ); }) || function () {}; } build("warning"); build("error"); build("fatalError"); return errorHandler; } //console.log('#\n\n\n\n\n\n\n####') /** * +ContentHandler+ErrorHandler * +LexicalHandler+EntityResolver2 * -DeclHandler-DTDHandler * * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html */ function DOMHandler() { this.cdata = false; } function position(locator, node) { node.lineNumber = locator.lineNumber; node.columnNumber = locator.columnNumber; } /** * @see org.xml.sax.ContentHandler#startDocument * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html */ DOMHandler.prototype = { startDocument: function () { this.doc = new DOMImplementation().createDocument( null, null, null ); if (this.locator) { this.doc.documentURI = this.locator.systemId; } }, startElement: function (namespaceURI, localName, qName, attrs) { var doc = this.doc; var el = doc.createElementNS( namespaceURI, qName || localName ); var len = attrs.length; appendElement(this, el); this.currentElement = el; this.locator && position(this.locator, el); for (var i = 0; i < len; i++) { var namespaceURI = attrs.getURI(i); var value = attrs.getValue(i); var qName = attrs.getQName(i); var attr = doc.createAttributeNS(namespaceURI, qName); this.locator && position(attrs.getLocator(i), attr); attr.value = attr.nodeValue = value; el.setAttributeNode(attr); } }, endElement: function (namespaceURI, localName, qName) { var current = this.currentElement; var tagName = current.tagName; this.currentElement = current.parentNode; }, startPrefixMapping: function (prefix, uri) {}, endPrefixMapping: function (prefix) {}, processingInstruction: function (target, data) { var ins = this.doc.createProcessingInstruction( target, data ); this.locator && position(this.locator, ins); appendElement(this, ins); }, ignorableWhitespace: function (ch, start, length) {}, characters: function (chars, start, length) { chars = _toString.apply(this, arguments); //console.log(chars) if (chars) { if (this.cdata) { var charNode = this.doc.createCDATASection(chars); } else { var charNode = this.doc.createTextNode(chars); } if (this.currentElement) { this.currentElement.appendChild(charNode); } else if (/^\s*$/.test(chars)) { this.doc.appendChild(charNode); //process xml } this.locator && position(this.locator, charNode); } }, skippedEntity: function (name) {}, endDocument: function () { this.doc.normalize(); }, setDocumentLocator: function (locator) { if ((this.locator = locator)) { // && !('lineNumber' in locator)){ locator.lineNumber = 0; } }, //LexicalHandler comment: function (chars, start, length) { chars = _toString.apply(this, arguments); var comm = this.doc.createComment(chars); this.locator && position(this.locator, comm); appendElement(this, comm); }, startCDATA: function () { //used in characters() methods this.cdata = true; }, endCDATA: function () { this.cdata = false; }, startDTD: function (name, publicId, systemId) { var impl = this.doc.implementation; if (impl && impl.createDocumentType) { var dt = impl.createDocumentType( name, publicId, systemId ); this.locator && position(this.locator, dt); appendElement(this, dt); this.doc.doctype = dt; } }, /** * @see org.xml.sax.ErrorHandler * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html */ warning: function (error) { console.warn( "[xmldom warning]\t" + error, _locator(this.locator) ); }, error: function (error) { console.error( "[xmldom error]\t" + error, _locator(this.locator) ); }, fatalError: function (error) { throw new ParseError(error, this.locator); }, }; function _locator(l) { if (l) { return ( "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]" ); } } function _toString(chars, start, length) { if (typeof chars == "string") { return chars.substr(start, length); } else { //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") if (chars.length >= start + length || start) { return new java.lang.String(chars, start, length) + ""; } return chars; } } /* * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html * used method of org.xml.sax.ext.LexicalHandler: * #comment(chars, start, length) * #startCDATA() * #endCDATA() * #startDTD(name, publicId, systemId) * * * IGNORED method of org.xml.sax.ext.LexicalHandler: * #endDTD() * #startEntity(name) * #endEntity(name) * * * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html * IGNORED method of org.xml.sax.ext.DeclHandler * #attributeDecl(eName, aName, type, mode, value) * #elementDecl(name, model) * #externalEntityDecl(name, publicId, systemId) * #internalEntityDecl(name, value) * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html * IGNORED method of org.xml.sax.EntityResolver2 * #resolveEntity(String name,String publicId,String baseURI,String systemId) * #resolveEntity(publicId, systemId) * #getExternalSubset(name, baseURI) * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html * IGNORED method of org.xml.sax.DTDHandler * #notationDecl(name, publicId, systemId) {}; * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; */ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace( /\w+/g, function (key) { DOMHandler.prototype[key] = function () { return null; }; } ); /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ function appendElement(hander, node) { if (!hander.currentElement) { hander.doc.appendChild(node); } else { hander.currentElement.appendChild(node); } } //appendChild and setAttributeNS are preformance key __webpack_unused_export__ = DOMHandler; exports.DOMParser = DOMParser; /** * @deprecated Import/require from main entry point instead */ __webpack_unused_export__ = dom.DOMImplementation; /** * @deprecated Import/require from main entry point instead */ __webpack_unused_export__ = dom.XMLSerializer; /***/ }, /***/ 1146: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { var conventions = __webpack_require__(2167); var NAMESPACE = conventions.NAMESPACE; /** * A prerequisite for `[].filter`, to drop elements that are empty * @param {string} input * @returns {boolean} */ function notEmptyString(input) { return input !== ""; } /** * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace * @see https://infra.spec.whatwg.org/#ascii-whitespace * * @param {string} input * @returns {string[]} (can be empty) */ function splitOnASCIIWhitespace(input) { // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []; } /** * Adds element as a key to current if it is not already present. * * @param {Record<string, boolean | undefined>} current * @param {string} element * @returns {Record<string, boolean | undefined>} */ function orderedSetReducer(current, element) { if (!current.hasOwnProperty(element)) { current[element] = true; } return current; } /** * @see https://infra.spec.whatwg.org/#ordered-set * @param {string} input * @returns {string[]} */ function toOrderedSet(input) { if (!input) return []; var list = splitOnASCIIWhitespace(input); return Object.keys(list.reduce(orderedSetReducer, {})); } /** * Uses `list.indexOf` to implement something like `Array.prototype.includes`, * which we can not rely on being available. * * @param {any[]} list * @returns {function(any): boolean} */ function arrayIncludes(list) { return function (element) { return list && list.indexOf(element) !== -1; }; } function copy(src, dest) { for (var p in src) { dest[p] = src[p]; } } /** ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? */ function _extends(Class, Super) { var pt = Class.prototype; if (!(pt instanceof Super)) { function t() {} t.prototype = Super.prototype; t = new t(); copy(pt, t); Class.prototype = pt = t; } if (pt.constructor != Class) { if (typeof Class != "function") { console.error("unknown Class:" + Class); } pt.constructor = Class; } } // Node Types var NodeType = {}; var ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1); var ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2); var TEXT_NODE = (NodeType.TEXT_NODE = 3); var CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4); var ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5); var ENTITY_NODE = (NodeType.ENTITY_NODE = 6); var PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7); var COMMENT_NODE = (NodeType.COMMENT_NODE = 8); var DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9); var DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10); var DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11); var NOTATION_NODE = (NodeType.NOTATION_NODE = 12); // ExceptionCode var ExceptionCode = {}; var ExceptionMessage = {}; var INDEX_SIZE_ERR = (ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1] = "Index size error"), 1)); var DOMSTRING_SIZE_ERR = (ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2] = "DOMString size error"), 2)); var HIERARCHY_REQUEST_ERR = (ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3] = "Hierarchy request error"), 3)); var WRONG_DOCUMENT_ERR = (ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4] = "Wrong document"), 4)); var INVALID_CHARACTER_ERR = (ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5] = "Invalid character"), 5)); var NO_DATA_ALLOWED_ERR = (ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6] = "No data allowed"), 6)); var NO_MODIFICATION_ALLOWED_ERR = (ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7] = "No modification allowed"), 7)); var NOT_FOUND_ERR = (ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8] = "Not found"), 8)); var NOT_SUPPORTED_ERR = (ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9] = "Not supported"), 9)); var INUSE_ATTRIBUTE_ERR = (ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10] = "Attribute in use"), 10)); //level2 var INVALID_STATE_ERR = (ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11] = "Invalid state"), 11)); var SYNTAX_ERR = (ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12] = "Syntax error"), 12)); var INVALID_MODIFICATION_ERR = (ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13] = "Invalid modification"), 13)); var NAMESPACE_ERR = (ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14] = "Invalid namespace"), 14)); var INVALID_ACCESS_ERR = (ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15] = "Invalid access"), 15)); /** * DOM Level 2 * Object DOMException * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html */ function DOMException(code, message) { if (message instanceof Error) { var error = message; } else { error = this; Error.call(this, ExceptionMessage[code]); this.message = ExceptionMessage[code]; if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException); } error.code = code; if (message) this.message = this.message + ": " + message; return error; } DOMException.prototype = Error.prototype; copy(ExceptionCode, DOMException); /** * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. * The items in the NodeList are accessible via an integral index, starting from 0. */ function NodeList() {} NodeList.prototype = { /** * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. * @standard level1 */ length: 0, /** * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. * @standard level1 * @param index unsigned long * Index into the collection. * @return Node * The node at the indexth position in the NodeList, or null if that is not a valid index. */ item: function (index) { return this[index] || null; }, toString: function (isHTML, nodeFilter) { for (var buf = [], i = 0; i < this.length; i++) { serializeToString(this[i], buf, isHTML, nodeFilter); } return buf.join(""); }, }; function LiveNodeList(node, refresh) { this._node = node; this._refresh = refresh; _updateLiveList(this); } function _updateLiveList(list) { var inc = list._node._inc || list._node.ownerDocument._inc; if (list._inc != inc) { var ls = list._refresh(list._node); //console.log(ls.length) __set__(list, "length", ls.length); copy(ls, list); list._inc = inc; } } LiveNodeList.prototype.item = function (i) { _updateLiveList(this); return this[i]; }; _extends(LiveNodeList, NodeList); /** * Objects implementing the NamedNodeMap interface are used * to represent collections of nodes that can be accessed by name. * Note that NamedNodeMap does not inherit from NodeList; * NamedNodeMaps are not maintained in any particular order. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, * and does not imply that the DOM specifies an order to these Nodes. * NamedNodeMap objects in the DOM are live. * used for attributes or DocumentType entities */ function NamedNodeMap() {} function _findNodeIndex(list, node) { var i = list.length; while (i--) { if (list[i] === node) { return i; } } } function _addNamedNode(el, list, newAttr, oldAttr) { if (oldAttr) { list[_findNodeIndex(list, oldAttr)] = newAttr; } else { list[list.length++] = newAttr; } if (el) { newAttr.ownerElement = el; var doc = el.ownerDocument; if (doc) { oldAttr && _onRemoveAttribute(doc, el, oldAttr); _onAddAttribute(doc, el, newAttr); } } } function _removeNamedNode(el, list, attr) { //console.log('remove attr:'+attr) var i = _findNodeIndex(list, attr); if (i >= 0) { var lastIndex = list.length - 1; while (i < lastIndex) { list[i] = list[++i]; } list.length = lastIndex; if (el) { var doc = el.ownerDocument; if (doc) { _onRemoveAttribute(doc, el, attr); attr.ownerElement = null; } } } else { throw DOMException( NOT_FOUND_ERR, new Error(el.tagName + "@" + attr) ); } } NamedNodeMap.prototype = { length: 0, item: NodeList.prototype.item, getNamedItem: function (key) { // if(key.indexOf(':')>0 || key == 'xmlns'){ // return null; // } //console.log() var i = this.length; while (i--) { var attr = this[i]; //console.log(attr.nodeName,key) if (attr.nodeName == key) { return attr; } } }, setNamedItem: function (attr) { var el = attr.ownerElement; if (el && el != this._ownerElement) { throw new DOMException(INUSE_ATTRIBUTE_ERR); } var oldAttr = this.getNamedItem(attr.nodeName); _addNamedNode(this._ownerElement, this, attr, oldAttr); return oldAttr; }, /* returns Node */ setNamedItemNS: function (attr) { // raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR var el = attr.ownerElement, oldAttr; if (el && el != this._ownerElement) { throw new DOMException(INUSE_ATTRIBUTE_ERR); } oldAttr = this.getNamedItemNS( attr.namespaceURI, attr.localName ); _addNamedNode(this._ownerElement, this, attr, oldAttr); return oldAttr; }, /* returns Node */ removeNamedItem: function (key) { var attr = this.getNamedItem(key); _removeNamedNode(this._ownerElement, this, attr); return attr; }, // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR //for level2 removeNamedItemNS: function (namespaceURI, localName) { var attr = this.getNamedItemNS(namespaceURI, localName); _removeNamedNode(this._ownerElement, this, attr); return attr; }, getNamedItemNS: function (namespaceURI, localName) { var i = this.length; while (i--) { var node = this[i]; if ( node.localName == localName && node.namespaceURI == namespaceURI ) { return node; } } return null; }, }; /** * The DOMImplementation interface represents an object providing methods * which are not dependent on any particular document. * Such an object is returned by the `Document.implementation` property. * * __The individual methods describe the differences compared to the specs.__ * * @constructor * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial) * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard */ function DOMImplementation() {} DOMImplementation.prototype = { /** * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported. * The different implementations fairly diverged in what kind of features were reported. * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use. * * @deprecated It is deprecated and modern browsers return true in all cases. * * @param {string} feature * @param {string} [version] * @returns {boolean} always true * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard */ hasFeature: function (feature, version) { return true; }, /** * Creates an XML Document object of the specified type with its document element. * * __It behaves slightly different from the description in the living standard__: * - There is no interface/class `XMLDocument`, it returns a `Document` instance. * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared. * - this implementation is not validating names or qualified names * (when parsing XML strings, the SAX parser takes care of that) * * @param {string|null} namespaceURI * @param {string} qualifiedName * @param {DocumentType=null} doctype * @returns {Document} * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial) * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core * * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names */ createDocument: function ( namespaceURI, qualifiedName, doctype ) { var doc = new Document(); doc.implementation = this; doc.childNodes = new NodeList(); doc.doctype = doctype || null; if (doctype) { doc.appendChild(doctype); } if (qualifiedName) { var root = doc.createElementNS( namespaceURI, qualifiedName ); doc.appendChild(root); } return doc; }, /** * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`. * * __This behavior is slightly different from the in the specs__: * - this implementation is not validating names or qualified names * (when parsing XML strings, the SAX parser takes care of that) * * @param {string} qualifiedName * @param {string} [publicId] * @param {string} [systemId] * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()` * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard * * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names */ createDocumentType: function ( qualifiedName, publicId, systemId ) { var node = new DocumentType(); node.name = qualifiedName; node.nodeName = qualifiedName; node.publicId = publicId || ""; node.systemId = systemId || ""; return node; }, }; /** * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 */ function Node() {} Node.prototype = { firstChild: null, lastChild: null, previousSibling: null, nextSibling: null, attributes: null, parentNode: null, childNodes: null, ownerDocument: null, nodeValue: null, namespaceURI: null, prefix: null, localName: null, // Modified in DOM Level 2: insertBefore: function (newChild, refChild) { //raises return _insertBefore(this, newChild, refChild); }, replaceChild: function (newChild, oldChild) { //raises this.insertBefore(newChild, oldChild); if (oldChild) { this.removeChild(oldChild); } }, removeChild: function (oldChild) { return _removeChild(this, oldChild); }, appendChild: function (newChild) { return this.insertBefore(newChild, null); }, hasChildNodes: function () { return this.firstChild != null; }, cloneNode: function (deep) { return cloneNode(this.ownerDocument || this, this, deep); }, // Modified in DOM Level 2: normalize: function () { var child = this.firstChild; while (child) { var next = child.nextSibling; if ( next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE ) { this.removeChild(next); child.appendData(next.data); } else { child.normalize(); child = next; } } }, // Introduced in DOM Level 2: isSupported: function (feature, version) { return this.ownerDocument.implementation.hasFeature( feature, version ); }, // Introduced in DOM Level 2: hasAttributes: function () { return this.attributes.length > 0; }, /** * Look up the prefix associated to the given namespace URI, starting from this node. * **The default namespace declarations are ignored by this method.** * See Namespace Prefix Lookup for details on the algorithm used by this method. * * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._ * * @param {string | null} namespaceURI * @returns {string | null} * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix * @see https://github.com/xmldom/xmldom/issues/322 */ lookupPrefix: function (namespaceURI) { var el = this; while (el) { var map = el._nsMap; //console.dir(map) if (map) { for (var n in map) { if (map[n] == namespaceURI) { return n; } } } el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode; } return null; }, // Introduced in DOM Level 3: lookupNamespaceURI: function (prefix) { var el = this; while (el) { var map = el._nsMap; //console.dir(map) if (map) { if (prefix in map) { return map[prefix]; } } el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode; } return null; }, // Introduced in DOM Level 3: isDefaultNamespace: function (namespaceURI) { var prefix = this.lookupPrefix(namespaceURI); return prefix == null; }, }; function _xmlEncoder(c) { return ( (c == "<" && "&lt;") || (c == ">" && "&gt;") || (c == "&" && "&amp;") || (c == '"' && "&quot;") || "&#" + c.charCodeAt() + ";" ); } copy(NodeType, Node); copy(NodeType, Node.prototype); /** * @param callback return true for continue,false for break * @return boolean true: break visit; */ function _visitNode(node, callback) { if (callback(node)) { return true; } if ((node = node.firstChild)) { do { if (_visitNode(node, callback)) { return true; } } while ((node = node.nextSibling)); } } function Document() {} function _onAddAttribute(doc, el, newAttr) { doc && doc._inc++; var ns = newAttr.namespaceURI; if (ns === NAMESPACE.XMLNS) { //update namespace el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value; } } function _onRemoveAttribute(doc, el, newAttr, remove) { doc && doc._inc++; var ns = newAttr.namespaceURI; if (ns === NAMESPACE.XMLNS) { //update namespace delete el._nsMap[newAttr.prefix ? newAttr.localName : ""]; } } function _onUpdateChild(doc, el, newChild) { if (doc && doc._inc) { doc._inc++; //update childNodes var cs = el.childNodes; if (newChild) { cs[cs.length++] = newChild; } else { //console.log(1) var child = el.firstChild; var i = 0; while (child) { cs[i++] = child; child = child.nextSibling; } cs.length = i; } } } /** * attributes; * children; * * writeable properties: * nodeValue,Attr:value,CharacterData:data * prefix */ function _removeChild(parentNode, child) { var previous = child.previousSibling; var next = child.nextSibling; if (previous) { previous.nextSibling = next; } else { parentNode.firstChild = next; } if (next) { next.previousSibling = previous; } else { parentNode.lastChild = previous; } _onUpdateChild(parentNode.ownerDocument, parentNode); return child; } /** * preformance key(refChild == null) */ function _insertBefore(parentNode, newChild, nextChild) { var cp = newChild.parentNode; if (cp) { cp.removeChild(newChild); //remove and update } if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) { var newFirst = newChild.firstChild; if (newFirst == null) { return newChild; } var newLast = newChild.lastChild; } else { newFirst = newLast = newChild; } var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; newFirst.previousSibling = pre; newLast.nextSibling = nextChild; if (pre) { pre.nextSibling = newFirst; } else { parentNode.firstChild = newFirst; } if (nextChild == null) { parentNode.lastChild = newLast; } else { nextChild.previousSibling = newLast; } do { newFirst.parentNode = parentNode; } while ( newFirst !== newLast && (newFirst = newFirst.nextSibling) ); _onUpdateChild( parentNode.ownerDocument || parentNode, parentNode ); //console.log(parentNode.lastChild.nextSibling == null) if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { newChild.firstChild = newChild.lastChild = null; } return newChild; } function _appendSingleChild(parentNode, newChild) { var cp = newChild.parentNode; if (cp) { var pre = parentNode.lastChild; cp.removeChild(newChild); //remove and update var pre = parentNode.lastChild; } var pre = parentNode.lastChild; newChild.parentNode = parentNode; newChild.previousSibling = pre; newChild.nextSibling = null; if (pre) { pre.nextSibling = newChild; } else { parentNode.firstChild = newChild; } parentNode.lastChild = newChild; _onUpdateChild(parentNode.ownerDocument, parentNode, newChild); return newChild; //console.log("__aa",parentNode.lastChild.nextSibling == null) } Document.prototype = { //implementation : null, nodeName: "#document", nodeType: DOCUMENT_NODE, /** * The DocumentType node of the document. * * @readonly * @type DocumentType */ doctype: null, documentElement: null, _inc: 1, insertBefore: function (newChild, refChild) { //raises if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { var child = newChild.firstChild; while (child) { var next = child.nextSibling; this.insertBefore(child, refChild); child = next; } return newChild; } if ( this.documentElement == null && newChild.nodeType == ELEMENT_NODE ) { this.documentElement = newChild; } return ( _insertBefore(this, newChild, refChild), (newChild.ownerDocument = this), newChild ); }, removeChild: function (oldChild) { if (this.documentElement == oldChild) { this.documentElement = null; } return _removeChild(this, oldChild); }, // Introduced in DOM Level 2: importNode: function (importedNode, deep) { return importNode(this, importedNode, deep); }, // Introduced in DOM Level 2: getElementById: function (id) { var rtv = null; _visitNode(this.documentElement, function (node) { if (node.nodeType == ELEMENT_NODE) { if (node.getAttribute("id") == id) { rtv = node; return true; } } }); return rtv; }, /** * The `getElementsByClassName` method of `Document` interface returns an array-like object * of all child elements which have **all** of the given class name(s). * * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters. * * * Warning: This is a live LiveNodeList. * Changes in the DOM will reflect in the array as the changes occur. * If an element selected by this array no longer qualifies for the selector, * it will automatically be removed. Be aware of this for iteration purposes. * * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace * * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname */ getElementsByClassName: function (classNames) { var classNamesSet = toOrderedSet(classNames); return new LiveNodeList(this, function (base) { var ls = []; if (classNamesSet.length > 0) { _visitNode(base.documentElement, function (node) { if ( node !== base && node.nodeType === ELEMENT_NODE ) { var nodeClassNames = node.getAttribute("class"); // can be null if the attribute does not exist if (nodeClassNames) { // before splitting and iterating just compare them for the most common case var matches = classNames === nodeClassNames; if (!matches) { var nodeClassNamesSet = toOrderedSet(nodeClassNames); matches = classNamesSet.every( arrayIncludes(nodeClassNamesSet) ); } if (matches) { ls.push(node); } } } }); } return ls; }); }, //document factory method: createElement: function (tagName) { var node = new Element(); node.ownerDocument = this; node.nodeName = tagName; node.tagName = tagName; node.localName = tagName; node.childNodes = new NodeList(); var attrs = (node.attributes = new NamedNodeMap()); attrs._ownerElement = node; return node; }, createDocumentFragment: function () { var node = new DocumentFragment(); node.ownerDocument = this; node.childNodes = new NodeList(); return node; }, createTextNode: function (data) { var node = new Text(); node.ownerDocument = this; node.appendData(data); return node; }, createComment: function (data) { var node = new Comment(); node.ownerDocument = this; node.appendData(data); return node; }, createCDATASection: function (data) { var node = new CDATASection(); node.ownerDocument = this; node.appendData(data); return node; }, createProcessingInstruction: function (target, data) { var node = new ProcessingInstruction(); node.ownerDocument = this; node.tagName = node.target = target; node.nodeValue = node.data = data; return node; }, createAttribute: function (name) { var node = new Attr(); node.ownerDocument = this; node.name = name; node.nodeName = name; node.localName = name; node.specified = true; return node; }, createEntityReference: function (name) { var node = new EntityReference(); node.ownerDocument = this; node.nodeName = name; return node; }, // Introduced in DOM Level 2: createElementNS: function (namespaceURI, qualifiedName) { var node = new Element(); var pl = qualifiedName.split(":"); var attrs = (node.attributes = new NamedNodeMap()); node.childNodes = new NodeList(); node.ownerDocument = this; node.nodeName = qualifiedName; node.tagName = qualifiedName; node.namespaceURI = namespaceURI; if (pl.length == 2) { node.prefix = pl[0]; node.localName = pl[1]; } else { //el.prefix = null; node.localName = qualifiedName; } attrs._ownerElement = node; return node; }, // Introduced in DOM Level 2: createAttributeNS: function (namespaceURI, qualifiedName) { var node = new Attr(); var pl = qualifiedName.split(":"); node.ownerDocument = this; node.nodeName = qualifiedName; node.name = qualifiedName; node.namespaceURI = namespaceURI; node.specified = true; if (pl.length == 2) { node.prefix = pl[0]; node.localName = pl[1]; } else { //el.prefix = null; node.localName = qualifiedName; } return node; }, }; _extends(Document, Node); function Element() { this._nsMap = {}; } Element.prototype = { nodeType: ELEMENT_NODE, hasAttribute: function (name) { return this.getAttributeNode(name) != null; }, getAttribute: function (name) { var attr = this.getAttributeNode(name); return (attr && attr.value) || ""; }, getAttributeNode: function (name) { return this.attributes.getNamedItem(name); }, setAttribute: function (name, value) { var attr = this.ownerDocument.createAttribute(name); attr.value = attr.nodeValue = "" + value; this.setAttributeNode(attr); }, removeAttribute: function (name) { var attr = this.getAttributeNode(name); attr && this.removeAttributeNode(attr); }, //four real opeartion method appendChild: function (newChild) { if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) { return this.insertBefore(newChild, null); } else { return _appendSingleChild(this, newChild); } }, setAttributeNode: function (newAttr) { return this.attributes.setNamedItem(newAttr); }, setAttributeNodeNS: function (newAttr) { return this.attributes.setNamedItemNS(newAttr); }, removeAttributeNode: function (oldAttr) { //console.log(this == oldAttr.ownerElement) return this.attributes.removeNamedItem(oldAttr.nodeName); }, //get real attribute name,and remove it by removeAttributeNode removeAttributeNS: function (namespaceURI, localName) { var old = this.getAttributeNodeNS(namespaceURI, localName); old && this.removeAttributeNode(old); }, hasAttributeNS: function (namespaceURI, localName) { return ( this.getAttributeNodeNS(namespaceURI, localName) != null ); }, getAttributeNS: function (namespaceURI, localName) { var attr = this.getAttributeNodeNS(namespaceURI, localName); return (attr && attr.value) || ""; }, setAttributeNS: function (namespaceURI, qualifiedName, value) { var attr = this.ownerDocument.createAttributeNS( namespaceURI, qualifiedName ); attr.value = attr.nodeValue = "" + value; this.setAttributeNode(attr); }, getAttributeNodeNS: function (namespaceURI, localName) { return this.attributes.getNamedItemNS( namespaceURI, localName ); }, getElementsByTagName: function (tagName) { return new LiveNodeList(this, function (base) { var ls = []; _visitNode(base, function (node) { if ( node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName) ) { ls.push(node); } }); return ls; }); }, getElementsByTagNameNS: function (namespaceURI, localName) { return new LiveNodeList(this, function (base) { var ls = []; _visitNode(base, function (node) { if ( node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName) ) { ls.push(node); } }); return ls; }); }, }; Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName; Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS; _extends(Element, Node); function Attr() {} Attr.prototype.nodeType = ATTRIBUTE_NODE; _extends(Attr, Node); function CharacterData() {} CharacterData.prototype = { data: "", substringData: function (offset, count) { return this.data.substring(offset, offset + count); }, appendData: function (text) { text = this.data + text; this.nodeValue = this.data = text; this.length = text.length; }, insertData: function (offset, text) { this.replaceData(offset, 0, text); }, appendChild: function (newChild) { throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]); }, deleteData: function (offset, count) { this.replaceData(offset, count, ""); }, replaceData: function (offset, count, text) { var start = this.data.substring(0, offset); var end = this.data.substring(offset + count); text = start + text + end; this.nodeValue = this.data = text; this.length = text.length; }, }; _extends(CharacterData, Node); function Text() {} Text.prototype = { nodeName: "#text", nodeType: TEXT_NODE, splitText: function (offset) { var text = this.data; var newText = text.substring(offset); text = text.substring(0, offset); this.data = this.nodeValue = text; this.length = text.length; var newNode = this.ownerDocument.createTextNode(newText); if (this.parentNode) { this.parentNode.insertBefore(newNode, this.nextSibling); } return newNode; }, }; _extends(Text, CharacterData); function Comment() {} Comment.prototype = { nodeName: "#comment", nodeType: COMMENT_NODE, }; _extends(Comment, CharacterData); function CDATASection() {} CDATASection.prototype = { nodeName: "#cdata-section", nodeType: CDATA_SECTION_NODE, }; _extends(CDATASection, CharacterData); function DocumentType() {} DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE; _extends(DocumentType, Node); function Notation() {} Notation.prototype.nodeType = NOTATION_NODE; _extends(Notation, Node); function Entity() {} Entity.prototype.nodeType = ENTITY_NODE; _extends(Entity, Node); function EntityReference() {} EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE; _extends(EntityReference, Node); function DocumentFragment() {} DocumentFragment.prototype.nodeName = "#document-fragment"; DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE; _extends(DocumentFragment, Node); function ProcessingInstruction() {} ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; _extends(ProcessingInstruction, Node); function XMLSerializer() {} XMLSerializer.prototype.serializeToString = function ( node, isHtml, nodeFilter ) { return nodeSerializeToString.call(node, isHtml, nodeFilter); }; Node.prototype.toString = nodeSerializeToString; function nodeSerializeToString(isHtml, nodeFilter) { var buf = []; var refNode = (this.nodeType == 9 && this.documentElement) || this; var prefix = refNode.prefix; var uri = refNode.namespaceURI; if (uri && prefix == null) { //console.log(prefix) var prefix = refNode.lookupPrefix(uri); if (prefix == null) { //isHTML = true; var visibleNamespaces = [ { namespace: uri, prefix: null }, //{namespace:uri,prefix:''} ]; } } serializeToString( this, buf, isHtml, nodeFilter, visibleNamespaces ); //console.log('###',this.nodeType,uri,prefix,buf.join('')) return buf.join(""); } function needNamespaceDefine(node, isHTML, visibleNamespaces) { var prefix = node.prefix || ""; var uri = node.namespaceURI; // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) , // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl : // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty. // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using) // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared : // > [...] Furthermore, the attribute value [...] must not be an empty string. // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document. if (!uri) { return false; } if ( (prefix === "xml" && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS ) { return false; } var i = visibleNamespaces.length; while (i--) { var ns = visibleNamespaces[i]; // get namespace prefix if (ns.prefix === prefix) { return ns.namespace !== uri; } } return true; } /** * Well-formed constraint: No < in Attribute Values * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <. * @see https://www.w3.org/TR/xml/#CleanAttrVals * @see https://www.w3.org/TR/xml/#NT-AttValue */ function addSerializedAttribute(buf, qualifiedName, value) { buf.push( " ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"' ); } function serializeToString( node, buf, isHTML, nodeFilter, visibleNamespaces ) { if (!visibleNamespaces) { visibleNamespaces = []; } if (nodeFilter) { node = nodeFilter(node); if (node) { if (typeof node == "string") { buf.push(node); return; } } else { return; } //buf.sort.apply(attrs, attributeSorter); } switch (node.nodeType) { case ELEMENT_NODE: var attrs = node.attributes; var len = attrs.length; var child = node.firstChild; var nodeName = node.tagName; isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML; var prefixedNodeName = nodeName; if (!isHTML && !node.prefix && node.namespaceURI) { var defaultNS; // lookup current default ns from `xmlns` attribute for (var ai = 0; ai < attrs.length; ai++) { if (attrs.item(ai).name === "xmlns") { defaultNS = attrs.item(ai).value; break; } } if (!defaultNS) { // lookup current default ns in visibleNamespaces for ( var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi-- ) { var namespace = visibleNamespaces[nsi]; if ( namespace.prefix === "" && namespace.namespace === node.namespaceURI ) { defaultNS = namespace.namespace; break; } } } if (defaultNS !== node.namespaceURI) { for ( var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi-- ) { var namespace = visibleNamespaces[nsi]; if ( namespace.namespace === node.namespaceURI ) { if (namespace.prefix) { prefixedNodeName = namespace.prefix + ":" + nodeName; } break; } } } } buf.push("<", prefixedNodeName); for (var i = 0; i < len; i++) { // add namespaces for attributes var attr = attrs.item(i); if (attr.prefix == "xmlns") { visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value, }); } else if (attr.nodeName == "xmlns") { visibleNamespaces.push({ prefix: "", namespace: attr.value, }); } } for (var i = 0; i < len; i++) { var attr = attrs.item(i); if ( needNamespaceDefine( attr, isHTML, visibleNamespaces ) ) { var prefix = attr.prefix || ""; var uri = attr.namespaceURI; addSerializedAttribute( buf, prefix ? "xmlns:" + prefix : "xmlns", uri ); visibleNamespaces.push({ prefix: prefix, namespace: uri, }); } serializeToString( attr, buf, isHTML, nodeFilter, visibleNamespaces ); } // add namespace for current node if ( nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces) ) { var prefix = node.prefix || ""; var uri = node.namespaceURI; addSerializedAttribute( buf, prefix ? "xmlns:" + prefix : "xmlns", uri ); visibleNamespaces.push({ prefix: prefix, namespace: uri, }); } if ( child || (isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test( nodeName )) ) { buf.push(">"); //if is cdata child node if (isHTML && /^script$/i.test(nodeName)) { while (child) { if (child.data) { buf.push(child.data); } else { serializeToString( child, buf, isHTML, nodeFilter, visibleNamespaces.slice() ); } child = child.nextSibling; } } else { while (child) { serializeToString( child, buf, isHTML, nodeFilter, visibleNamespaces.slice() ); child = child.nextSibling; } } buf.push("</", prefixedNodeName, ">"); } else { buf.push("/>"); } // remove added visible namespaces //visibleNamespaces.length = startVisibleNamespaces; return; case DOCUMENT_NODE: case DOCUMENT_FRAGMENT_NODE: var child = node.firstChild; while (child) { serializeToString( child, buf, isHTML, nodeFilter, visibleNamespaces.slice() ); child = child.nextSibling; } return; case ATTRIBUTE_NODE: return addSerializedAttribute( buf, node.name, node.value ); case TEXT_NODE: /** * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. * If they are needed elsewhere, they must be escaped using either numeric character references or the strings * `&amp;` and `&lt;` respectively. * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility, * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content, * when that string is not marking the end of a CDATA section. * * In the content of elements, character data is any string of characters * which does not contain the start-delimiter of any markup * and does not include the CDATA-section-close delimiter, `]]>`. * * @see https://www.w3.org/TR/xml/#NT-CharData */ return buf.push( node.data .replace(/[<&]/g, _xmlEncoder) .replace(/]]>/g, "]]&gt;") ); case CDATA_SECTION_NODE: return buf.push("<![CDATA[", node.data, "]]>"); case COMMENT_NODE: return buf.push("<!--", node.data, "-->"); case DOCUMENT_TYPE_NODE: var pubid = node.publicId; var sysid = node.systemId; buf.push("<!DOCTYPE ", node.name); if (pubid) { buf.push(" PUBLIC ", pubid); if (sysid && sysid != ".") { buf.push(" ", sysid); } buf.push(">"); } else if (sysid && sysid != ".") { buf.push(" SYSTEM ", sysid, ">"); } else { var sub = node.internalSubset; if (sub) { buf.push(" [", sub, "]"); } buf.push(">"); } return; case PROCESSING_INSTRUCTION_NODE: return buf.push( "<?", node.target, " ", node.data, "?>" ); case ENTITY_REFERENCE_NODE: return buf.push("&", node.nodeName, ";"); //case ENTITY_NODE: //case NOTATION_NODE: default: buf.push("??", node.nodeName); } } function importNode(doc, node, deep) { var node2; switch (node.nodeType) { case ELEMENT_NODE: node2 = node.cloneNode(false); node2.ownerDocument = doc; //var attrs = node2.attributes; //var len = attrs.length; //for(var i=0;i<len;i++){ //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep)); //} case DOCUMENT_FRAGMENT_NODE: break; case ATTRIBUTE_NODE: deep = true; break; //case ENTITY_REFERENCE_NODE: //case PROCESSING_INSTRUCTION_NODE: ////case TEXT_NODE: //case CDATA_SECTION_NODE: //case COMMENT_NODE: // deep = false; // break; //case DOCUMENT_NODE: //case DOCUMENT_TYPE_NODE: //cannot be imported. //case ENTITY_NODE: //case NOTATION_NODE: //can not hit in level3 //default:throw e; } if (!node2) { node2 = node.cloneNode(false); //false } node2.ownerDocument = doc; node2.parentNode = null; if (deep) { var child = node.firstChild; while (child) { node2.appendChild(importNode(doc, child, deep)); child = child.nextSibling; } } return node2; } // //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1, // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,}; function cloneNode(doc, node, deep) { var node2 = new node.constructor(); for (var n in node) { var v = node[n]; if (typeof v != "object") { if (v != node2[n]) { node2[n] = v; } } } if (node.childNodes) { node2.childNodes = new NodeList(); } node2.ownerDocument = doc; switch (node2.nodeType) { case ELEMENT_NODE: var attrs = node.attributes; var attrs2 = (node2.attributes = new NamedNodeMap()); var len = attrs.length; attrs2._ownerElement = node2; for (var i = 0; i < len; i++) { node2.setAttributeNode( cloneNode(doc, attrs.item(i), true) ); } break; case ATTRIBUTE_NODE: deep = true; } if (deep) { var child = node.firstChild; while (child) { node2.appendChild(cloneNode(doc, child, deep)); child = child.nextSibling; } } return node2; } function __set__(object, key, value) { object[key] = value; } //do dynamic try { if (Object.defineProperty) { Object.defineProperty(LiveNodeList.prototype, "length", { get: function () { _updateLiveList(this); return this.$$length; }, }); Object.defineProperty(Node.prototype, "textContent", { get: function () { return getTextContent(this); }, set: function (data) { switch (this.nodeType) { case ELEMENT_NODE: case DOCUMENT_FRAGMENT_NODE: while (this.firstChild) { this.removeChild(this.firstChild); } if (data || String(data)) { this.appendChild( this.ownerDocument.createTextNode( data ) ); } break; default: this.data = data; this.value = data; this.nodeValue = data; } }, }); function getTextContent(node) { switch (node.nodeType) { case ELEMENT_NODE: case DOCUMENT_FRAGMENT_NODE: var buf = []; node = node.firstChild; while (node) { if ( node.nodeType !== 7 && node.nodeType !== 8 ) { buf.push(getTextContent(node)); } node = node.nextSibling; } return buf.join(""); default: return node.nodeValue; } } __set__ = function (object, key, value) { //console.log(value) object["$$" + key] = value; }; } } catch (e) { //ie8 } //if(typeof require == 'function'){ exports.DocumentType = DocumentType; exports.DOMException = DOMException; exports.DOMImplementation = DOMImplementation; exports.Element = Element; exports.Node = Node; exports.NodeList = NodeList; exports.XMLSerializer = XMLSerializer; //} /***/ }, /***/ 1045: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { var freeze = __webpack_require__(2167).freeze; /** * The entities that are predefined in every XML document. * * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1 * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0 * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia */ exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"', }); /** * A map of currently 241 entities that are detected in an HTML document. * They contain all entries from `XML_ENTITIES`. * * @see XML_ENTITIES * @see DOMParser.parseFromString * @see DOMImplementation.prototype.createHTMLDocument * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML) * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML) */ exports.HTML_ENTITIES = freeze({ lt: "<", gt: ">", amp: "&", quot: '"', apos: "'", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", nbsp: "\u00a0", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "­­", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", times: "×", divide: "÷", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "∧", or: "∨", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", fnof: "ƒ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "‌", zwj: "‍", lrm: "‎", rlm: "‏", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", bull: "•", hellip: "…", permil: "‰", prime: "′", Prime: "″", lsaquo: "‹", rsaquo: "›", oline: "‾", euro: "€", trade: "™", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", }); /** * @deprecated use `HTML_ENTITIES` instead * @see HTML_ENTITIES */ exports.entityMap = exports.HTML_ENTITIES; /***/ }, /***/ 3969: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { var __webpack_unused_export__; var dom = __webpack_require__(1146); __webpack_unused_export__ = dom.DOMImplementation; __webpack_unused_export__ = dom.XMLSerializer; exports.DOMParser = __webpack_require__(6129).DOMParser; /***/ }, /***/ 6925: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { var NAMESPACE = __webpack_require__(2167).NAMESPACE; //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] //[5] Name ::= NameStartChar (NameChar)* var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; //\u10000-\uEFFFF var nameChar = new RegExp( "[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]" ); var tagNamePattern = new RegExp( "^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$" ); //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/ //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',') //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE var S_TAG = 0; //tag name offerring var S_ATTR = 1; //attr name offerring var S_ATTR_SPACE = 2; //attr name end and space offer var S_EQ = 3; //=space? var S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only) var S_ATTR_END = 5; //attr value end and no space(quot end) var S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer) var S_TAG_CLOSE = 7; //closed el<el /> /** * Creates an error that will not be caught by XMLReader aka the SAX parser. * * @param {string} message * @param {any?} locator Optional, can provide details about the location in the source * @constructor */ function ParseError(message, locator) { this.message = message; this.locator = locator; if (Error.captureStackTrace) Error.captureStackTrace(this, ParseError); } ParseError.prototype = new Error(); ParseError.prototype.name = ParseError.name; function XMLReader() {} XMLReader.prototype = { parse: function (source, defaultNSMap, entityMap) { var domBuilder = this.domBuilder; domBuilder.startDocument(); _copy(defaultNSMap, (defaultNSMap = {})); parse( source, defaultNSMap, entityMap, domBuilder, this.errorHandler ); domBuilder.endDocument(); }, }; function parse( source, defaultNSMapCopy, entityMap, domBuilder, errorHandler ) { function fixedFromCharCode(code) { // String.prototype.fromCharCode does not supports // > 2 bytes unicode chars directly if (code > 0xffff) { code -= 0x10000; var surrogate1 = 0xd800 + (code >> 10), surrogate2 = 0xdc00 + (code & 0x3ff); return String.fromCharCode(surrogate1, surrogate2); } else { return String.fromCharCode(code); } } function entityReplacer(a) { var k = a.slice(1, -1); if (k in entityMap) { return entityMap[k]; } else if (k.charAt(0) === "#") { return fixedFromCharCode( parseInt(k.substr(1).replace("x", "0x")) ); } else { errorHandler.error("entity not found:" + a); return a; } } function appendText(end) { //has some bugs if (end > start) { var xt = source .substring(start, end) .replace(/&#?\w+;/g, entityReplacer); locator && position(start); domBuilder.characters(xt, 0, end - start); start = end; } } function position(p, m) { while (p >= lineEnd && (m = linePattern.exec(source))) { lineStart = m.index; lineEnd = lineStart + m[0].length; locator.lineNumber++; //console.log('line++:',locator,startPos,endPos) } locator.columnNumber = p - lineStart + 1; } var lineStart = 0; var lineEnd = 0; var linePattern = /.*(?:\r\n?|\n)|.*$/g; var locator = domBuilder.locator; var parseStack = [{ currentNSMap: defaultNSMapCopy }]; var closeMap = {}; var start = 0; while (true) { try { var tagStart = source.indexOf("<", start); if (tagStart < 0) { if (!source.substr(start).match(/^\s*$/)) { var doc = domBuilder.doc; var text = doc.createTextNode( source.substr(start) ); doc.appendChild(text); domBuilder.currentElement = text; } return; } if (tagStart > start) { appendText(tagStart); } switch (source.charAt(tagStart + 1)) { case "/": var end = source.indexOf(">", tagStart + 3); var tagName = source .substring(tagStart + 2, end) .replace(/[ \t\n\r]+$/g, ""); var config = parseStack.pop(); if (end < 0) { tagName = source .substring(tagStart + 2) .replace(/[\s<].*/, ""); errorHandler.error( "end tag name: " + tagName + " is not complete:" + config.tagName ); end = tagStart + 1 + tagName.length; } else if (tagName.match(/\s</)) { tagName = tagName.replace(/[\s<].*/, ""); errorHandler.error( "end tag name: " + tagName + " maybe not complete" ); end = tagStart + 1 + tagName.length; } var localNSMap = config.localNSMap; var endMatch = config.tagName == tagName; var endIgnoreCaseMach = endMatch || (config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase()); if (endIgnoreCaseMach) { domBuilder.endElement( config.uri, config.localName, tagName ); if (localNSMap) { for (var prefix in localNSMap) { domBuilder.endPrefixMapping(prefix); } } if (!endMatch) { errorHandler.fatalError( "end tag name: " + tagName + " is not match the current start tagName:" + config.tagName ); // No known test case } } else { parseStack.push(config); } end++; break; // end elment case "?": // <?...?> locator && position(tagStart); end = parseInstruction( source, tagStart, domBuilder ); break; case "!": // <!doctype,<![CDATA,<!-- locator && position(tagStart); end = parseDCC( source, tagStart, domBuilder, errorHandler ); break; default: locator && position(tagStart); var el = new ElementAttributes(); var currentNSMap = parseStack[parseStack.length - 1] .currentNSMap; //elStartEnd var end = parseElementStartPart( source, tagStart, el, currentNSMap, entityReplacer, errorHandler ); var len = el.length; if ( !el.closed && fixSelfClosed( source, end, el.tagName, closeMap ) ) { el.closed = true; if (!entityMap.nbsp) { errorHandler.warning( "unclosed xml attribute" ); } } if (locator && len) { var locator2 = copyLocator(locator, {}); //try{//attribute position fixed for (var i = 0; i < len; i++) { var a = el[i]; position(a.offset); a.locator = copyLocator(locator, {}); } domBuilder.locator = locator2; if ( appendElement( el, domBuilder, currentNSMap ) ) { parseStack.push(el); } domBuilder.locator = locator; } else { if ( appendElement( el, domBuilder, currentNSMap ) ) { parseStack.push(el); } } if (NAMESPACE.isHTML(el.uri) && !el.closed) { end = parseHtmlSpecialContent( source, end, el.tagName, entityReplacer, domBuilder ); } else { end++; } } } catch (e) { if (e instanceof ParseError) { throw e; } errorHandler.error("element parse error: " + e); end = -1; } if (end > start) { start = end; } else { //TODO: 这里有可能sax回退,有位置错误风险 appendText(Math.max(tagStart, start) + 1); } } } function copyLocator(f, t) { t.lineNumber = f.lineNumber; t.columnNumber = f.columnNumber; return t; } /** * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); * @return end of the elementStartPart(end of elementEndPart for selfClosed el) */ function parseElementStartPart( source, start, el, currentNSMap, entityReplacer, errorHandler ) { /** * @param {string} qname * @param {string} value * @param {number} startIndex */ function addAttribute(qname, value, startIndex) { if (el.attributeNames.hasOwnProperty(qname)) { errorHandler.fatalError( "Attribute " + qname + " redefined" ); } el.addValue(qname, value, startIndex); } var attrName; var value; var p = ++start; var s = S_TAG; //status while (true) { var c = source.charAt(p); switch (c) { case "=": if (s === S_ATTR) { //attrName attrName = source.slice(start, p); s = S_EQ; } else if (s === S_ATTR_SPACE) { s = S_EQ; } else { //fatalError: equal must after attrName or space after attrName throw new Error( "attribute equal must after attrName" ); // No known test case } break; case "'": case '"': if ( s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE ) { //equal if (s === S_ATTR) { errorHandler.warning( 'attribute value must after "="' ); attrName = source.slice(start, p); } start = p + 1; p = source.indexOf(c, start); if (p > 0) { value = source .slice(start, p) .replace(/&#?\w+;/g, entityReplacer); addAttribute(attrName, value, start - 1); s = S_ATTR_END; } else { //fatalError: no end quot match throw new Error( "attribute value no end '" + c + "' match" ); } } else if (s == S_ATTR_NOQUOT_VALUE) { value = source .slice(start, p) .replace(/&#?\w+;/g, entityReplacer); //console.log(attrName,value,start,p) addAttribute(attrName, value, start); //console.dir(el) errorHandler.warning( 'attribute "' + attrName + '" missed start quot(' + c + ")!!" ); start = p + 1; s = S_ATTR_END; } else { //fatalError: no equal before throw new Error( 'attribute value must after "="' ); // No known test case } break; case "/": switch (s) { case S_TAG: el.setTagName(source.slice(start, p)); case S_ATTR_END: case S_TAG_SPACE: case S_TAG_CLOSE: s = S_TAG_CLOSE; el.closed = true; case S_ATTR_NOQUOT_VALUE: case S_ATTR: case S_ATTR_SPACE: break; //case S_EQ: default: throw new Error( "attribute invalid close char('/')" ); // No known test case } break; case "": //end document errorHandler.error("unexpected end of input"); if (s == S_TAG) { el.setTagName(source.slice(start, p)); } return p; case ">": switch (s) { case S_TAG: el.setTagName(source.slice(start, p)); case S_ATTR_END: case S_TAG_SPACE: case S_TAG_CLOSE: break; //normal case S_ATTR_NOQUOT_VALUE: //Compatible state case S_ATTR: value = source.slice(start, p); if (value.slice(-1) === "/") { el.closed = true; value = value.slice(0, -1); } case S_ATTR_SPACE: if (s === S_ATTR_SPACE) { value = attrName; } if (s == S_ATTR_NOQUOT_VALUE) { errorHandler.warning( 'attribute "' + value + '" missed quot(")!' ); addAttribute( attrName, value.replace( /&#?\w+;/g, entityReplacer ), start ); } else { if ( !NAMESPACE.isHTML( currentNSMap[""] ) || !value.match( /^(?:disabled|checked|selected)$/i ) ) { errorHandler.warning( 'attribute "' + value + '" missed value!! "' + value + '" instead!!' ); } addAttribute(value, value, start); } break; case S_EQ: throw new Error("attribute value missed!!"); } // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName)) return p; /*xml space '\x20' | #x9 | #xD | #xA; */ case "\u0080": c = " "; default: if (c <= " ") { //space switch (s) { case S_TAG: el.setTagName(source.slice(start, p)); //tagName s = S_TAG_SPACE; break; case S_ATTR: attrName = source.slice(start, p); s = S_ATTR_SPACE; break; case S_ATTR_NOQUOT_VALUE: var value = source .slice(start, p) .replace( /&#?\w+;/g, entityReplacer ); errorHandler.warning( 'attribute "' + value + '" missed quot(")!!' ); addAttribute(attrName, value, start); case S_ATTR_END: s = S_TAG_SPACE; break; //case S_TAG_SPACE: //case S_EQ: //case S_ATTR_SPACE: // void();break; //case S_TAG_CLOSE: //ignore warning } } else { //not space //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE switch (s) { //case S_TAG:void();break; //case S_ATTR:void();break; //case S_ATTR_NOQUOT_VALUE:void();break; case S_ATTR_SPACE: var tagName = el.tagName; if ( !NAMESPACE.isHTML( currentNSMap[""] ) || !attrName.match( /^(?:disabled|checked|selected)$/i ) ) { errorHandler.warning( 'attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!' ); } addAttribute(attrName, attrName, start); start = p; s = S_ATTR; break; case S_ATTR_END: errorHandler.warning( 'attribute space is required"' + attrName + '"!!' ); case S_TAG_SPACE: s = S_ATTR; start = p; break; case S_EQ: s = S_ATTR_NOQUOT_VALUE; start = p; break; case S_TAG_CLOSE: throw new Error( "elements closed character '/' and '>' must be connected to" ); } } } //end outer switch //console.log('p++',p) p++; } } /** * @return true if has new namespace define */ function appendElement(el, domBuilder, currentNSMap) { var tagName = el.tagName; var localNSMap = null; //var currentNSMap = parseStack[parseStack.length-1].currentNSMap; var i = el.length; while (i--) { var a = el[i]; var qName = a.qName; var value = a.value; var nsp = qName.indexOf(":"); if (nsp > 0) { var prefix = (a.prefix = qName.slice(0, nsp)); var localName = qName.slice(nsp + 1); var nsPrefix = prefix === "xmlns" && localName; } else { localName = qName; prefix = null; nsPrefix = qName === "xmlns" && ""; } //can not set prefix,because prefix !== '' a.localName = localName; //prefix == null for no ns prefix attribute if (nsPrefix !== false) { //hack!! if (localNSMap == null) { localNSMap = {}; //console.log(currentNSMap,0) _copy(currentNSMap, (currentNSMap = {})); //console.log(currentNSMap,1) } currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value; a.uri = NAMESPACE.XMLNS; domBuilder.startPrefixMapping(nsPrefix, value); } } var i = el.length; while (i--) { a = el[i]; var prefix = a.prefix; if (prefix) { //no prefix attribute has no namespace if (prefix === "xml") { a.uri = NAMESPACE.XML; } if (prefix !== "xmlns") { a.uri = currentNSMap[prefix || ""]; //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} } } } var nsp = tagName.indexOf(":"); if (nsp > 0) { prefix = el.prefix = tagName.slice(0, nsp); localName = el.localName = tagName.slice(nsp + 1); } else { prefix = null; //important!! localName = el.localName = tagName; } //no prefix element has default namespace var ns = (el.uri = currentNSMap[prefix || ""]); domBuilder.startElement(ns, localName, tagName, el); //endPrefixMapping and startPrefixMapping have not any help for dom builder //localNSMap = null if (el.closed) { domBuilder.endElement(ns, localName, tagName); if (localNSMap) { for (prefix in localNSMap) { domBuilder.endPrefixMapping(prefix); } } } else { el.currentNSMap = currentNSMap; el.localNSMap = localNSMap; //parseStack.push(el); return true; } } function parseHtmlSpecialContent( source, elStartEnd, tagName, entityReplacer, domBuilder ) { if (/^(?:script|textarea)$/i.test(tagName)) { var elEndStart = source.indexOf( "</" + tagName + ">", elStartEnd ); var text = source.substring(elStartEnd + 1, elEndStart); if (/[&<]/.test(text)) { if (/^script$/i.test(tagName)) { //if(!/\]\]>/.test(text)){ //lexHandler.startCDATA(); domBuilder.characters(text, 0, text.length); //lexHandler.endCDATA(); return elEndStart; //} } //}else{//text area text = text.replace(/&#?\w+;/g, entityReplacer); domBuilder.characters(text, 0, text.length); return elEndStart; //} } } return elStartEnd + 1; } function fixSelfClosed(source, elStartEnd, tagName, closeMap) { //if(tagName in closeMap){ var pos = closeMap[tagName]; if (pos == null) { //console.log(tagName) pos = source.lastIndexOf("</" + tagName + ">"); if (pos < elStartEnd) { //忘记闭合 pos = source.lastIndexOf("</" + tagName); } closeMap[tagName] = pos; } return pos < elStartEnd; //} } function _copy(source, target) { for (var n in source) { target[n] = source[n]; } } function parseDCC(source, start, domBuilder, errorHandler) { //sure start with '<!' var next = source.charAt(start + 2); switch (next) { case "-": if (source.charAt(start + 3) === "-") { var end = source.indexOf("-->", start + 4); //append comment source.substring(4,end)//<!-- if (end > start) { domBuilder.comment( source, start + 4, end - start - 4 ); return end + 3; } else { errorHandler.error("Unclosed comment"); return -1; } } else { //error return -1; } default: if (source.substr(start + 3, 6) == "CDATA[") { var end = source.indexOf("]]>", start + 9); domBuilder.startCDATA(); domBuilder.characters( source, start + 9, end - start - 9 ); domBuilder.endCDATA(); return end + 3; } //<!DOCTYPE //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) var matchs = split(source, start); var len = matchs.length; if (len > 1 && /!doctype/i.test(matchs[0][0])) { var name = matchs[1][0]; var pubid = false; var sysid = false; if (len > 3) { if (/^public$/i.test(matchs[2][0])) { pubid = matchs[3][0]; sysid = len > 4 && matchs[4][0]; } else if (/^system$/i.test(matchs[2][0])) { sysid = matchs[3][0]; } } var lastMatch = matchs[len - 1]; domBuilder.startDTD(name, pubid, sysid); domBuilder.endDTD(); return lastMatch.index + lastMatch[0].length; } } return -1; } function parseInstruction(source, start, domBuilder) { var end = source.indexOf("?>", start); if (end) { var match = source .substring(start, end) .match(/^<\?(\S*)\s*([\s\S]*?)\s*$/); if (match) { var len = match[0].length; domBuilder.processingInstruction(match[1], match[2]); return end + 2; } else { //error return -1; } } return -1; } function ElementAttributes() { this.attributeNames = {}; } ElementAttributes.prototype = { setTagName: function (tagName) { if (!tagNamePattern.test(tagName)) { throw new Error("invalid tagName:" + tagName); } this.tagName = tagName; }, addValue: function (qName, value, offset) { if (!tagNamePattern.test(qName)) { throw new Error("invalid attribute:" + qName); } this.attributeNames[qName] = this.length; this[this.length++] = { qName: qName, value: value, offset: offset, }; }, length: 0, getLocalName: function (i) { return this[i].localName; }, getLocator: function (i) { return this[i].locator; }, getQName: function (i) { return this[i].qName; }, getURI: function (i) { return this[i].uri; }, getValue: function (i) { return this[i].value; }, // ,getIndex:function(uri, localName)){ // if(localName){ // // }else{ // var qName = uri // } // }, // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))}, // getType:function(uri,localName){} // getType:function(i){}, }; function split(source, start) { var match; var buf = []; var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g; reg.lastIndex = start; reg.exec(source); //skip < while ((match = reg.exec(source))) { buf.push(match); if (match[1]) return buf; } } exports.XMLReader = XMLReader; exports.ParseError = ParseError; /***/ }, /***/ 9144: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { var topLevel = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : {}; var minDoc = __webpack_require__(7579); var doccy; if (typeof document !== "undefined") { doccy = document; } else { doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"]; if (!doccy) { doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"] = minDoc; } } module.exports = doccy; /***/ }, /***/ 8908: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { var win; if (typeof window !== "undefined") { win = window; } else if (typeof __webpack_require__.g !== "undefined") { win = __webpack_require__.g; } else if (typeof self !== "undefined") { win = self; } else { win = {}; } module.exports = win; /***/ }, /***/ 7376: /***/ function (module) { module.exports = isFunction; var toString = Object.prototype.toString; function isFunction(fn) { if (!fn) { return false; } var string = toString.call(fn); return ( string === "[object Function]" || (typeof fn === "function" && string !== "[object RegExp]") || (typeof window !== "undefined" && // IE8 and below (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt)) ); } /***/ }, /***/ 7537: /***/ function (module, exports) { // Source: http://jsfiddle.net/vWx8V/ // http://stackoverflow.com/questions/5603195/full-list-of-javascript-keycodes /** * Conenience method returns corresponding value for given keyName or keyCode. * * @param {Mixed} keyCode {Number} or keyName {String} * @return {Mixed} * @api public */ function keyCode(searchInput) { // Keyboard Events if (searchInput && "object" === typeof searchInput) { var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode; if (hasKeyCode) searchInput = hasKeyCode; } // Numbers if ("number" === typeof searchInput) return names[searchInput]; // Everything else (cast to string) var search = String(searchInput); // check codes var foundNamedKey = codes[search.toLowerCase()]; if (foundNamedKey) return foundNamedKey; // check aliases var foundNamedKey = aliases[search.toLowerCase()]; if (foundNamedKey) return foundNamedKey; // weird character? if (search.length === 1) return search.charCodeAt(0); return undefined; } /** * Compares a keyboard event with a given keyCode or keyName. * * @param {Event} event Keyboard event that should be tested * @param {Mixed} keyCode {Number} or keyName {String} * @return {Boolean} * @api public */ keyCode.isEventKey = function isEventKey(event, nameOrCode) { if (event && "object" === typeof event) { var keyCode = event.which || event.keyCode || event.charCode; if (keyCode === null || keyCode === undefined) { return false; } if (typeof nameOrCode === "string") { // check codes var foundNamedKey = codes[nameOrCode.toLowerCase()]; if (foundNamedKey) { return foundNamedKey === keyCode; } // check aliases var foundNamedKey = aliases[nameOrCode.toLowerCase()]; if (foundNamedKey) { return foundNamedKey === keyCode; } } else if (typeof nameOrCode === "number") { return nameOrCode === keyCode; } return false; } }; exports = module.exports = keyCode; /** * Get by name * * exports.code['enter'] // => 13 */ var codes = (exports.code = exports.codes = { backspace: 8, tab: 9, enter: 13, shift: 16, ctrl: 17, alt: 18, "pause/break": 19, "caps lock": 20, esc: 27, space: 32, "page up": 33, "page down": 34, end: 35, home: 36, left: 37, up: 38, right: 39, down: 40, insert: 45, delete: 46, command: 91, "left command": 91, "right command": 93, "numpad *": 106, "numpad +": 107, "numpad -": 109, "numpad .": 110, "numpad /": 111, "num lock": 144, "scroll lock": 145, "my computer": 182, "my calculator": 183, ";": 186, "=": 187, ",": 188, "-": 189, ".": 190, "/": 191, "`": 192, "[": 219, "\\": 220, "]": 221, "'": 222, }); // Helper aliases var aliases = (exports.aliases = { windows: 91, "⇧": 16, "⌥": 18, "⌃": 17, "⌘": 91, ctl: 17, control: 17, option: 18, pause: 19, break: 19, caps: 20, return: 13, escape: 27, spc: 32, spacebar: 32, pgup: 33, pgdn: 34, ins: 45, del: 46, cmd: 91, }); /*! * Programatically add the following */ // lower case chars for (i = 97; i < 123; i++) codes[String.fromCharCode(i)] = i - 32; // numbers for (var i = 48; i < 58; i++) codes[i - 48] = i; // function keys for (i = 1; i < 13; i++) codes["f" + i] = i + 111; // numpad keys for (i = 0; i < 10; i++) codes["numpad " + i] = i + 96; /** * Get by code * * exports.name[13] // => 'Enter' */ var names = (exports.names = exports.title = {}); // title for backward compat // Create reverse mapping for (i in codes) names[codes[i]] = i; // Add aliases for (var alias in aliases) { codes[alias] = aliases[alias]; } /***/ }, /***/ 9323: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { _b: function () { return /* binding */ Parser; }, }); // UNUSED EXPORTS: LineStream, ParseStream // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js var inheritsLoose = __webpack_require__(4578); // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/stream.js /** * @file stream.js */ /** * A lightweight readable stream implemention that handles event dispatching. * * @class Stream */ var Stream = /*#__PURE__*/ (function () { function Stream() { this.listeners = {}; } /** * Add a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener the callback to be invoked when an event of * the specified type occurs */ var _proto = Stream.prototype; _proto.on = function on(type, listener) { if (!this.listeners[type]) { this.listeners[type] = []; } this.listeners[type].push(listener); }; /** * Remove a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener a function previously registered for this * type of event through `on` * @return {boolean} if we could turn it off or not */ _proto.off = function off(type, listener) { if (!this.listeners[type]) { return false; } var index = this.listeners[type].indexOf(listener); // TODO: which is better? // In Video.js we slice listener functions // on trigger so that it does not mess up the order // while we loop through. // // Here we slice on off so that the loop in trigger // can continue using it's old reference to loop without // messing up the order. this.listeners[type] = this.listeners[type].slice(0); this.listeners[type].splice(index, 1); return index > -1; }; /** * Trigger an event of the specified type on this stream. Any additional * arguments to this function are passed as parameters to event listeners. * * @param {string} type the event name */ _proto.trigger = function trigger(type) { var callbacks = this.listeners[type]; if (!callbacks) { return; } // Slicing the arguments on every invocation of this method // can add a significant amount of overhead. Avoid the // intermediate object creation for the common case of a // single callback argument if (arguments.length === 2) { var length = callbacks.length; for (var i = 0; i < length; ++i) { callbacks[i].call(this, arguments[1]); } } else { var args = Array.prototype.slice.call(arguments, 1); var _length = callbacks.length; for (var _i = 0; _i < _length; ++_i) { callbacks[_i].apply(this, args); } } }; /** * Destroys the stream and cleans up. */ _proto.dispose = function dispose() { this.listeners = {}; }; /** * Forwards all `data` events on this stream to the destination stream. The * destination stream should provide a method `push` to receive the data * events as they arrive. * * @param {Stream} destination the stream that will receive all `data` events * @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options */ _proto.pipe = function pipe(destination) { this.on("data", function (data) { destination.push(data); }); }; return Stream; })(); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js var esm_extends = __webpack_require__(7462); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js var assertThisInitialized = __webpack_require__(7326); // EXTERNAL MODULE: ./node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js var decode_b64_to_uint8_array = __webpack_require__(6722); // CONCATENATED MODULE: ./node_modules/m3u8-parser/dist/m3u8-parser.es.js /*! @name m3u8-parser @version 4.7.0 @license Apache-2.0 */ /** * A stream that buffers string input and generates a `data` event for each * line. * * @class LineStream * @extends Stream */ var LineStream = /*#__PURE__*/ (function (_Stream) { (0, inheritsLoose /* default */.Z)(LineStream, _Stream); function LineStream() { var _this; _this = _Stream.call(this) || this; _this.buffer = ""; return _this; } /** * Add new data to be parsed. * * @param {string} data the text to process */ var _proto = LineStream.prototype; _proto.push = function push(data) { var nextNewline; this.buffer += data; nextNewline = this.buffer.indexOf("\n"); for ( ; nextNewline > -1; nextNewline = this.buffer.indexOf("\n") ) { this.trigger( "data", this.buffer.substring(0, nextNewline) ); this.buffer = this.buffer.substring(nextNewline + 1); } }; return LineStream; })(Stream); var TAB = String.fromCharCode(0x09); var parseByterange = function parseByterange(byterangeString) { // optionally match and capture 0+ digits before `@` // optionally match and capture 0+ digits after `@` var match = /([0-9.]*)?@?([0-9.]*)?/.exec( byterangeString || "" ); var result = {}; if (match[1]) { result.length = parseInt(match[1], 10); } if (match[2]) { result.offset = parseInt(match[2], 10); } return result; }; /** * "forgiving" attribute list psuedo-grammar: * attributes -> keyvalue (',' keyvalue)* * keyvalue -> key '=' value * key -> [^=]* * value -> '"' [^"]* '"' | [^,]* */ var attributeSeparator = function attributeSeparator() { var key = "[^=]*"; var value = '"[^"]*"|[^,]*'; var keyvalue = "(?:" + key + ")=(?:" + value + ")"; return new RegExp("(?:^|,)(" + keyvalue + ")"); }; /** * Parse attributes from a line given the separator * * @param {string} attributes the attribute line to parse */ var parseAttributes = function parseAttributes(attributes) { // split the string using attributes as the separator var attrs = attributes.split(attributeSeparator()); var result = {}; var i = attrs.length; var attr; while (i--) { // filter out unmatched portions of the string if (attrs[i] === "") { continue; } // split the key and value attr = /([^=]*)=(.*)/.exec(attrs[i]).slice(1); // trim whitespace and remove optional quotes around the value attr[0] = attr[0].replace(/^\s+|\s+$/g, ""); attr[1] = attr[1].replace(/^\s+|\s+$/g, ""); attr[1] = attr[1].replace(/^['"](.*)['"]$/g, "$1"); result[attr[0]] = attr[1]; } return result; }; /** * A line-level M3U8 parser event stream. It expects to receive input one * line at a time and performs a context-free parse of its contents. A stream * interpretation of a manifest can be useful if the manifest is expected to * be too large to fit comfortably into memory or the entirety of the input * is not immediately available. Otherwise, it's probably much easier to work * with a regular `Parser` object. * * Produces `data` events with an object that captures the parser's * interpretation of the input. That object has a property `tag` that is one * of `uri`, `comment`, or `tag`. URIs only have a single additional * property, `line`, which captures the entirety of the input without * interpretation. Comments similarly have a single additional property * `text` which is the input without the leading `#`. * * Tags always have a property `tagType` which is the lower-cased version of * the M3U8 directive without the `#EXT` or `#EXT-X-` prefix. For instance, * `#EXT-X-MEDIA-SEQUENCE` becomes `media-sequence` when parsed. Unrecognized * tags are given the tag type `unknown` and a single additional property * `data` with the remainder of the input. * * @class ParseStream * @extends Stream */ var ParseStream = /*#__PURE__*/ (function (_Stream) { (0, inheritsLoose /* default */.Z)(ParseStream, _Stream); function ParseStream() { var _this; _this = _Stream.call(this) || this; _this.customParsers = []; _this.tagMappers = []; return _this; } /** * Parses an additional line of input. * * @param {string} line a single line of an M3U8 file to parse */ var _proto = ParseStream.prototype; _proto.push = function push(line) { var _this2 = this; var match; var event; // strip whitespace line = line.trim(); if (line.length === 0) { // ignore empty lines return; } // URIs if (line[0] !== "#") { this.trigger("data", { type: "uri", uri: line, }); return; } // map tags var newLines = this.tagMappers.reduce( function (acc, mapper) { var mappedLine = mapper(line); // skip if unchanged if (mappedLine === line) { return acc; } return acc.concat([mappedLine]); }, [line] ); newLines.forEach(function (newLine) { for (var i = 0; i < _this2.customParsers.length; i++) { if (_this2.customParsers[i].call(_this2, newLine)) { return; } } // Comments if (newLine.indexOf("#EXT") !== 0) { _this2.trigger("data", { type: "comment", text: newLine.slice(1), }); return; } // strip off any carriage returns here so the regex matching // doesn't have to account for them. newLine = newLine.replace("\r", ""); // Tags match = /^#EXTM3U/.exec(newLine); if (match) { _this2.trigger("data", { type: "tag", tagType: "m3u", }); return; } match = /^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(newLine); if (match) { event = { type: "tag", tagType: "inf", }; if (match[1]) { event.duration = parseFloat(match[1]); } if (match[2]) { event.title = match[2]; } _this2.trigger("data", event); return; } match = /^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec( newLine ); if (match) { event = { type: "tag", tagType: "targetduration", }; if (match[1]) { event.duration = parseInt(match[1], 10); } _this2.trigger("data", event); return; } match = /^#EXT-X-VERSION:?([0-9.]*)?/.exec(newLine); if (match) { event = { type: "tag", tagType: "version", }; if (match[1]) { event.version = parseInt(match[1], 10); } _this2.trigger("data", event); return; } match = /^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec( newLine ); if (match) { event = { type: "tag", tagType: "media-sequence", }; if (match[1]) { event.number = parseInt(match[1], 10); } _this2.trigger("data", event); return; } match = /^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec( newLine ); if (match) { event = { type: "tag", tagType: "discontinuity-sequence", }; if (match[1]) { event.number = parseInt(match[1], 10); } _this2.trigger("data", event); return; } match = /^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(newLine); if (match) { event = { type: "tag", tagType: "playlist-type", }; if (match[1]) { event.playlistType = match[1]; } _this2.trigger("data", event); return; } match = /^#EXT-X-BYTERANGE:?(.*)?$/.exec(newLine); if (match) { event = (0, esm_extends /* default */.Z)( parseByterange(match[1]), { type: "tag", tagType: "byterange", } ); _this2.trigger("data", event); return; } match = /^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(newLine); if (match) { event = { type: "tag", tagType: "allow-cache", }; if (match[1]) { event.allowed = !/NO/.test(match[1]); } _this2.trigger("data", event); return; } match = /^#EXT-X-MAP:?(.*)$/.exec(newLine); if (match) { event = { type: "tag", tagType: "map", }; if (match[1]) { var attributes = parseAttributes(match[1]); if (attributes.URI) { event.uri = attributes.URI; } if (attributes.BYTERANGE) { event.byterange = parseByterange( attributes.BYTERANGE ); } } _this2.trigger("data", event); return; } match = /^#EXT-X-STREAM-INF:?(.*)$/.exec(newLine); if (match) { event = { type: "tag", tagType: "stream-inf", }; if (match[1]) { event.attributes = parseAttributes(match[1]); if (event.attributes.RESOLUTION) { var split = event.attributes.RESOLUTION.split("x"); var resolution = {}; if (split[0]) { resolution.width = parseInt( split[0], 10 ); } if (split[1]) { resolution.height = parseInt( split[1], 10 ); } event.attributes.RESOLUTION = resolution; } if (event.attributes.BANDWIDTH) { event.attributes.BANDWIDTH = parseInt( event.attributes.BANDWIDTH, 10 ); } if (event.attributes["PROGRAM-ID"]) { event.attributes["PROGRAM-ID"] = parseInt( event.attributes["PROGRAM-ID"], 10 ); } } _this2.trigger("data", event); return; } match = /^#EXT-X-MEDIA:?(.*)$/.exec(newLine); if (match) { event = { type: "tag", tagType: "media", }; if (match[1]) { event.attributes = parseAttributes(match[1]); } _this2.trigger("data", event); return; } match = /^#EXT-X-ENDLIST/.exec(newLine); if (match) { _this2.trigger("data", { type: "tag", tagType: "endlist", }); return; } match = /^#EXT-X-DISCONTINUITY/.exec(newLine); if (match) { _this2.trigger("data", { type: "tag", tagType: "discontinuity", }); return; } match = /^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec( newLine ); if (match) { event = { type: "tag", tagType: "program-date-time", }; if (match[1]) { event.dateTimeString = match[1]; event.dateTimeObject = new Date(match[1]); } _this2.trigger("data", event); return; } match = /^#EXT-X-KEY:?(.*)$/.exec(newLine); if (match) { event = { type: "tag", tagType: "key", }; if (match[1]) { event.attributes = parseAttributes(match[1]); // parse the IV string into a Uint32Array if (event.attributes.IV) { if ( event.attributes.IV.substring( 0, 2 ).toLowerCase() === "0x" ) { event.attributes.IV = event.attributes.IV.substring(2); } event.attributes.IV = event.attributes.IV.match(/.{8}/g); event.attributes.IV[0] = parseInt( event.attributes.IV[0], 16 ); event.attributes.IV[1] = parseInt( event.attributes.IV[1], 16 ); event.attributes.IV[2] = parseInt( event.attributes.IV[2], 16 ); event.attributes.IV[3] = parseInt( event.attributes.IV[3], 16 ); event.attributes.IV = new Uint32Array( event.attributes.IV ); } } _this2.trigger("data", event); return; } match = /^#EXT-X-START:?(.*)$/.exec(newLine); if (match) { event = { type: "tag", tagType: "start", }; if (match[1]) { event.attributes = parseAttributes(match[1]); event.attributes["TIME-OFFSET"] = parseFloat( event.attributes["TIME-OFFSET"] ); event.attributes.PRECISE = /YES/.test( event.attributes.PRECISE ); } _this2.trigger("data", event); return; } match = /^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(newLine); if (match) { event = { type: "tag", tagType: "cue-out-cont", }; if (match[1]) { event.data = match[1]; } else { event.data = ""; } _this2.trigger("data", event); return; } match = /^#EXT-X-CUE-OUT:?(.*)?$/.exec(newLine); if (match) { event = { type: "tag", tagType: "cue-out", }; if (match[1]) { event.data = match[1]; } else { event.data = ""; } _this2.trigger("data", event); return; } match = /^#EXT-X-CUE-IN:?(.*)?$/.exec(newLine); if (match) { event = { type: "tag", tagType: "cue-in", }; if (match[1]) { event.data = match[1]; } else { event.data = ""; } _this2.trigger("data", event); return; } match = /^#EXT-X-SKIP:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "skip", }; event.attributes = parseAttributes(match[1]); if ( event.attributes.hasOwnProperty( "SKIPPED-SEGMENTS" ) ) { event.attributes["SKIPPED-SEGMENTS"] = parseInt( event.attributes["SKIPPED-SEGMENTS"], 10 ); } if ( event.attributes.hasOwnProperty( "RECENTLY-REMOVED-DATERANGES" ) ) { event.attributes[ "RECENTLY-REMOVED-DATERANGES" ] = event.attributes[ "RECENTLY-REMOVED-DATERANGES" ].split(TAB); } _this2.trigger("data", event); return; } match = /^#EXT-X-PART:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "part", }; event.attributes = parseAttributes(match[1]); ["DURATION"].forEach(function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseFloat( event.attributes[key] ); } }); ["INDEPENDENT", "GAP"].forEach(function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = /YES/.test( event.attributes[key] ); } }); if (event.attributes.hasOwnProperty("BYTERANGE")) { event.attributes.byterange = parseByterange( event.attributes.BYTERANGE ); } _this2.trigger("data", event); return; } match = /^#EXT-X-SERVER-CONTROL:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "server-control", }; event.attributes = parseAttributes(match[1]); [ "CAN-SKIP-UNTIL", "PART-HOLD-BACK", "HOLD-BACK", ].forEach(function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseFloat( event.attributes[key] ); } }); ["CAN-SKIP-DATERANGES", "CAN-BLOCK-RELOAD"].forEach( function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = /YES/.test( event.attributes[key] ); } } ); _this2.trigger("data", event); return; } match = /^#EXT-X-PART-INF:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "part-inf", }; event.attributes = parseAttributes(match[1]); ["PART-TARGET"].forEach(function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseFloat( event.attributes[key] ); } }); _this2.trigger("data", event); return; } match = /^#EXT-X-PRELOAD-HINT:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "preload-hint", }; event.attributes = parseAttributes(match[1]); ["BYTERANGE-START", "BYTERANGE-LENGTH"].forEach( function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseInt( event.attributes[key], 10 ); var subkey = key === "BYTERANGE-LENGTH" ? "length" : "offset"; event.attributes.byterange = event.attributes.byterange || {}; event.attributes.byterange[subkey] = event.attributes[key]; // only keep the parsed byterange object. delete event.attributes[key]; } } ); _this2.trigger("data", event); return; } match = /^#EXT-X-RENDITION-REPORT:(.*)$/.exec(newLine); if (match && match[1]) { event = { type: "tag", tagType: "rendition-report", }; event.attributes = parseAttributes(match[1]); ["LAST-MSN", "LAST-PART"].forEach(function (key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseInt( event.attributes[key], 10 ); } }); _this2.trigger("data", event); return; } // unknown tag type _this2.trigger("data", { type: "tag", data: newLine.slice(4), }); }); }; /** * Add a parser for custom headers * * @param {Object} options a map of options for the added parser * @param {RegExp} options.expression a regular expression to match the custom header * @param {string} options.customType the custom type to register to the output * @param {Function} [options.dataParser] function to parse the line into an object * @param {boolean} [options.segment] should tag data be attached to the segment object */ _proto.addParser = function addParser(_ref) { var _this3 = this; var expression = _ref.expression, customType = _ref.customType, dataParser = _ref.dataParser, segment = _ref.segment; if (typeof dataParser !== "function") { dataParser = function dataParser(line) { return line; }; } this.customParsers.push(function (line) { var match = expression.exec(line); if (match) { _this3.trigger("data", { type: "custom", data: dataParser(line), customType: customType, segment: segment, }); return true; } }); }; /** * Add a custom header mapper * * @param {Object} options * @param {RegExp} options.expression a regular expression to match the custom header * @param {Function} options.map function to translate tag into a different tag */ _proto.addTagMapper = function addTagMapper(_ref2) { var expression = _ref2.expression, map = _ref2.map; var mapFn = function mapFn(line) { if (expression.test(line)) { return map(line); } return line; }; this.tagMappers.push(mapFn); }; return ParseStream; })(Stream); var camelCase = function camelCase(str) { return str.toLowerCase().replace(/-(\w)/g, function (a) { return a[1].toUpperCase(); }); }; var camelCaseKeys = function camelCaseKeys(attributes) { var result = {}; Object.keys(attributes).forEach(function (key) { result[camelCase(key)] = attributes[key]; }); return result; }; // set SERVER-CONTROL hold back based upon targetDuration and partTargetDuration // we need this helper because defaults are based upon targetDuration and // partTargetDuration being set, but they may not be if SERVER-CONTROL appears before // target durations are set. var setHoldBack = function setHoldBack(manifest) { var serverControl = manifest.serverControl, targetDuration = manifest.targetDuration, partTargetDuration = manifest.partTargetDuration; if (!serverControl) { return; } var tag = "#EXT-X-SERVER-CONTROL"; var hb = "holdBack"; var phb = "partHoldBack"; var minTargetDuration = targetDuration && targetDuration * 3; var minPartDuration = partTargetDuration && partTargetDuration * 2; if (targetDuration && !serverControl.hasOwnProperty(hb)) { serverControl[hb] = minTargetDuration; this.trigger("info", { message: tag + " defaulting HOLD-BACK to targetDuration * 3 (" + minTargetDuration + ").", }); } if ( minTargetDuration && serverControl[hb] < minTargetDuration ) { this.trigger("warn", { message: tag + " clamping HOLD-BACK (" + serverControl[hb] + ") to targetDuration * 3 (" + minTargetDuration + ")", }); serverControl[hb] = minTargetDuration; } // default no part hold back to part target duration * 3 if (partTargetDuration && !serverControl.hasOwnProperty(phb)) { serverControl[phb] = partTargetDuration * 3; this.trigger("info", { message: tag + " defaulting PART-HOLD-BACK to partTargetDuration * 3 (" + serverControl[phb] + ").", }); } // if part hold back is too small default it to part target duration * 2 if ( partTargetDuration && serverControl[phb] < minPartDuration ) { this.trigger("warn", { message: tag + " clamping PART-HOLD-BACK (" + serverControl[phb] + ") to partTargetDuration * 2 (" + minPartDuration + ").", }); serverControl[phb] = minPartDuration; } }; /** * A parser for M3U8 files. The current interpretation of the input is * exposed as a property `manifest` on parser objects. It's just two lines to * create and parse a manifest once you have the contents available as a string: * * ```js * var parser = new m3u8.Parser(); * parser.push(xhr.responseText); * ``` * * New input can later be applied to update the manifest object by calling * `push` again. * * The parser attempts to create a usable manifest object even if the * underlying input is somewhat nonsensical. It emits `info` and `warning` * events during the parse if it encounters input that seems invalid or * requires some property of the manifest object to be defaulted. * * @class Parser * @extends Stream */ var Parser = /*#__PURE__*/ (function (_Stream) { (0, inheritsLoose /* default */.Z)(Parser, _Stream); function Parser() { var _this; _this = _Stream.call(this) || this; _this.lineStream = new LineStream(); _this.parseStream = new ParseStream(); _this.lineStream.pipe(_this.parseStream); /* eslint-disable consistent-this */ var self = (0, assertThisInitialized /* default */.Z)( _this ); /* eslint-enable consistent-this */ var uris = []; var currentUri = {}; // if specified, the active EXT-X-MAP definition var currentMap; // if specified, the active decryption key var _key; var hasParts = false; var noop = function noop() {}; var defaultMediaGroups = { AUDIO: {}, VIDEO: {}, "CLOSED-CAPTIONS": {}, SUBTITLES: {}, }; // This is the Widevine UUID from DASH IF IOP. The same exact string is // used in MPDs with Widevine encrypted streams. var widevineUuid = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"; // group segments into numbered timelines delineated by discontinuities var currentTimeline = 0; // the manifest is empty until the parse stream begins delivering data _this.manifest = { allowCache: true, discontinuityStarts: [], segments: [], }; // keep track of the last seen segment's byte range end, as segments are not required // to provide the offset, in which case it defaults to the next byte after the // previous segment var lastByterangeEnd = 0; // keep track of the last seen part's byte range end. var lastPartByterangeEnd = 0; _this.on("end", function () { // only add preloadSegment if we don't yet have a uri for it. // and we actually have parts/preloadHints if ( currentUri.uri || (!currentUri.parts && !currentUri.preloadHints) ) { return; } if (!currentUri.map && currentMap) { currentUri.map = currentMap; } if (!currentUri.key && _key) { currentUri.key = _key; } if ( !currentUri.timeline && typeof currentTimeline === "number" ) { currentUri.timeline = currentTimeline; } _this.manifest.preloadSegment = currentUri; }); // update the manifest with the m3u8 entry from the parse stream _this.parseStream.on("data", function (entry) { var mediaGroup; var rendition; ({ tag: function tag() { // switch based on the tag type (( { version: function version() { if (entry.version) { this.manifest.version = entry.version; } }, "allow-cache": function allowCache() { this.manifest.allowCache = entry.allowed; if (!("allowed" in entry)) { this.trigger("info", { message: "defaulting allowCache to YES", }); this.manifest.allowCache = true; } }, byterange: function byterange() { var byterange = {}; if ("length" in entry) { currentUri.byterange = byterange; byterange.length = entry.length; if (!("offset" in entry)) { /* * From the latest spec (as of this writing): * https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.2 * * Same text since EXT-X-BYTERANGE's introduction in draft 7: * https://tools.ietf.org/html/draft-pantos-http-live-streaming-07#section-3.3.1) * * "If o [offset] is not present, the sub-range begins at the next byte * following the sub-range of the previous media segment." */ entry.offset = lastByterangeEnd; } } if ("offset" in entry) { currentUri.byterange = byterange; byterange.offset = entry.offset; } lastByterangeEnd = byterange.offset + byterange.length; }, endlist: function endlist() { this.manifest.endList = true; }, inf: function inf() { if ( !( "mediaSequence" in this.manifest ) ) { this.manifest.mediaSequence = 0; this.trigger("info", { message: "defaulting media sequence to zero", }); } if ( !( "discontinuitySequence" in this.manifest ) ) { this.manifest.discontinuitySequence = 0; this.trigger("info", { message: "defaulting discontinuity sequence to zero", }); } if (entry.duration > 0) { currentUri.duration = entry.duration; } if (entry.duration === 0) { currentUri.duration = 0.01; this.trigger("info", { message: "updating zero segment duration to a small value", }); } this.manifest.segments = uris; }, key: function key() { if (!entry.attributes) { this.trigger("warn", { message: "ignoring key declaration without attribute list", }); return; } // clear the active encryption key if ( entry.attributes.METHOD === "NONE" ) { _key = null; return; } if (!entry.attributes.URI) { this.trigger("warn", { message: "ignoring key declaration without URI", }); return; } if ( entry.attributes.KEYFORMAT === "com.apple.streamingkeydelivery" ) { this.manifest.contentProtection = this.manifest .contentProtection || {}; // TODO: add full support for this. this.manifest.contentProtection[ "com.apple.fps.1_0" ] = { attributes: entry.attributes, }; return; } // check if the content is encrypted for Widevine // Widevine/HLS spec: https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf if ( entry.attributes.KEYFORMAT === widevineUuid ) { var VALID_METHODS = [ "SAMPLE-AES", "SAMPLE-AES-CTR", "SAMPLE-AES-CENC", ]; if ( VALID_METHODS.indexOf( entry.attributes.METHOD ) === -1 ) { this.trigger("warn", { message: "invalid key method provided for Widevine", }); return; } if ( entry.attributes.METHOD === "SAMPLE-AES-CENC" ) { this.trigger("warn", { message: "SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead", }); } if ( entry.attributes.URI.substring( 0, 23 ) !== "data:text/plain;base64," ) { this.trigger("warn", { message: "invalid key URI provided for Widevine", }); return; } if ( !( entry.attributes .KEYID && entry.attributes.KEYID.substring( 0, 2 ) === "0x" ) ) { this.trigger("warn", { message: "invalid key ID provided for Widevine", }); return; } // if Widevine key attributes are valid, store them as `contentProtection` // on the manifest to emulate Widevine tag structure in a DASH mpd this.manifest.contentProtection = this.manifest .contentProtection || {}; this.manifest.contentProtection[ "com.widevine.alpha" ] = { attributes: { schemeIdUri: entry.attributes .KEYFORMAT, // remove '0x' from the key id string keyId: entry.attributes.KEYID.substring( 2 ), }, // decode the base64-encoded PSSH box pssh: (0, decode_b64_to_uint8_array /* default */.Z)( entry.attributes.URI.split( "," )[1] ), }; return; } if (!entry.attributes.METHOD) { this.trigger("warn", { message: "defaulting key method to AES-128", }); } // setup an encryption key for upcoming segments _key = { method: entry.attributes.METHOD || "AES-128", uri: entry.attributes.URI, }; if ( typeof entry.attributes.IV !== "undefined" ) { _key.iv = entry.attributes.IV; } }, "media-sequence": function mediaSequence() { if (!isFinite(entry.number)) { this.trigger("warn", { message: "ignoring invalid media sequence: " + entry.number, }); return; } this.manifest.mediaSequence = entry.number; }, "discontinuity-sequence": function discontinuitySequence() { if (!isFinite(entry.number)) { this.trigger("warn", { message: "ignoring invalid discontinuity sequence: " + entry.number, }); return; } this.manifest.discontinuitySequence = entry.number; currentTimeline = entry.number; }, "playlist-type": function playlistType() { if ( !/VOD|EVENT/.test( entry.playlistType ) ) { this.trigger("warn", { message: "ignoring unknown playlist type: " + entry.playlist, }); return; } this.manifest.playlistType = entry.playlistType; }, map: function map() { currentMap = {}; if (entry.uri) { currentMap.uri = entry.uri; } if (entry.byterange) { currentMap.byterange = entry.byterange; } if (_key) { currentMap.key = _key; } }, "stream-inf": function streamInf() { this.manifest.playlists = uris; this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups; if (!entry.attributes) { this.trigger("warn", { message: "ignoring empty stream-inf attributes", }); return; } if (!currentUri.attributes) { currentUri.attributes = {}; } (0, esm_extends /* default */.Z)( currentUri.attributes, entry.attributes ); }, media: function media() { this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups; if ( !( entry.attributes && entry.attributes.TYPE && entry.attributes[ "GROUP-ID" ] && entry.attributes.NAME ) ) { this.trigger("warn", { message: "ignoring incomplete or missing media group", }); return; } // find the media group, creating defaults as necessary var mediaGroupType = this.manifest.mediaGroups[ entry.attributes.TYPE ]; mediaGroupType[ entry.attributes["GROUP-ID"] ] = mediaGroupType[ entry.attributes["GROUP-ID"] ] || {}; mediaGroup = mediaGroupType[ entry.attributes["GROUP-ID"] ]; // collect the rendition metadata rendition = { default: /yes/i.test( entry.attributes.DEFAULT ), }; if (rendition.default) { rendition.autoselect = true; } else { rendition.autoselect = /yes/i.test( entry.attributes .AUTOSELECT ); } if (entry.attributes.LANGUAGE) { rendition.language = entry.attributes.LANGUAGE; } if (entry.attributes.URI) { rendition.uri = entry.attributes.URI; } if ( entry.attributes["INSTREAM-ID"] ) { rendition.instreamId = entry.attributes[ "INSTREAM-ID" ]; } if ( entry.attributes.CHARACTERISTICS ) { rendition.characteristics = entry.attributes.CHARACTERISTICS; } if (entry.attributes.FORCED) { rendition.forced = /yes/i.test( entry.attributes.FORCED ); } // insert the new rendition mediaGroup[entry.attributes.NAME] = rendition; }, discontinuity: function discontinuity() { currentTimeline += 1; currentUri.discontinuity = true; this.manifest.discontinuityStarts.push( uris.length ); }, "program-date-time": function programDateTime() { if ( typeof this.manifest .dateTimeString === "undefined" ) { // PROGRAM-DATE-TIME is a media-segment tag, but for backwards // compatibility, we add the first occurence of the PROGRAM-DATE-TIME tag // to the manifest object // TODO: Consider removing this in future major version this.manifest.dateTimeString = entry.dateTimeString; this.manifest.dateTimeObject = entry.dateTimeObject; } currentUri.dateTimeString = entry.dateTimeString; currentUri.dateTimeObject = entry.dateTimeObject; }, targetduration: function targetduration() { if ( !isFinite(entry.duration) || entry.duration < 0 ) { this.trigger("warn", { message: "ignoring invalid target duration: " + entry.duration, }); return; } this.manifest.targetDuration = entry.duration; setHoldBack.call( this, this.manifest ); }, start: function start() { if ( !entry.attributes || isNaN( entry.attributes[ "TIME-OFFSET" ] ) ) { this.trigger("warn", { message: "ignoring start declaration without appropriate attribute list", }); return; } this.manifest.start = { timeOffset: entry.attributes[ "TIME-OFFSET" ], precise: entry.attributes.PRECISE, }; }, "cue-out": function cueOut() { currentUri.cueOut = entry.data; }, "cue-out-cont": function cueOutCont() { currentUri.cueOutCont = entry.data; }, "cue-in": function cueIn() { currentUri.cueIn = entry.data; }, skip: function skip() { this.manifest.skip = camelCaseKeys( entry.attributes ); this.warnOnMissingAttributes_( "#EXT-X-SKIP", entry.attributes, ["SKIPPED-SEGMENTS"] ); }, part: function part() { var _this2 = this; hasParts = true; // parts are always specifed before a segment var segmentIndex = this.manifest.segments.length; var part = camelCaseKeys( entry.attributes ); currentUri.parts = currentUri.parts || []; currentUri.parts.push(part); if (part.byterange) { if ( !part.byterange.hasOwnProperty( "offset" ) ) { part.byterange.offset = lastPartByterangeEnd; } lastPartByterangeEnd = part.byterange.offset + part.byterange.length; } var partIndex = currentUri.parts.length - 1; this.warnOnMissingAttributes_( "#EXT-X-PART #" + partIndex + " for segment #" + segmentIndex, entry.attributes, ["URI", "DURATION"] ); if ( this.manifest.renditionReports ) { this.manifest.renditionReports.forEach( function (r, i) { if ( !r.hasOwnProperty( "lastPart" ) ) { _this2.trigger( "warn", { message: "#EXT-X-RENDITION-REPORT #" + i + " lacks required attribute(s): LAST-PART", } ); } } ); } }, "server-control": function serverControl() { var attrs = (this.manifest.serverControl = camelCaseKeys( entry.attributes )); if ( !attrs.hasOwnProperty( "canBlockReload" ) ) { attrs.canBlockReload = false; this.trigger("info", { message: "#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false", }); } setHoldBack.call( this, this.manifest ); if ( attrs.canSkipDateranges && !attrs.hasOwnProperty( "canSkipUntil" ) ) { this.trigger("warn", { message: "#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set", }); } }, "preload-hint": function preloadHint() { // parts are always specifed before a segment var segmentIndex = this.manifest.segments.length; var hint = camelCaseKeys( entry.attributes ); var isPart = hint.type && hint.type === "PART"; currentUri.preloadHints = currentUri.preloadHints || []; currentUri.preloadHints.push(hint); if (hint.byterange) { if ( !hint.byterange.hasOwnProperty( "offset" ) ) { // use last part byterange end or zero if not a part. hint.byterange.offset = isPart ? lastPartByterangeEnd : 0; if (isPart) { lastPartByterangeEnd = hint.byterange .offset + hint.byterange .length; } } } var index = currentUri.preloadHints.length - 1; this.warnOnMissingAttributes_( "#EXT-X-PRELOAD-HINT #" + index + " for segment #" + segmentIndex, entry.attributes, ["TYPE", "URI"] ); if (!hint.type) { return; } // search through all preload hints except for the current one for // a duplicate type. for ( var i = 0; i < currentUri.preloadHints.length - 1; i++ ) { var otherHint = currentUri.preloadHints[i]; if (!otherHint.type) { continue; } if ( otherHint.type === hint.type ) { this.trigger("warn", { message: "#EXT-X-PRELOAD-HINT #" + index + " for segment #" + segmentIndex + " has the same TYPE " + hint.type + " as preload hint #" + i, }); } } }, "rendition-report": function renditionReport() { var report = camelCaseKeys( entry.attributes ); this.manifest.renditionReports = this.manifest .renditionReports || []; this.manifest.renditionReports.push( report ); var index = this.manifest .renditionReports .length - 1; var required = [ "LAST-MSN", "URI", ]; if (hasParts) { required.push("LAST-PART"); } this.warnOnMissingAttributes_( "#EXT-X-RENDITION-REPORT #" + index, entry.attributes, required ); }, "part-inf": function partInf() { this.manifest.partInf = camelCaseKeys(entry.attributes); this.warnOnMissingAttributes_( "#EXT-X-PART-INF", entry.attributes, ["PART-TARGET"] ); if ( this.manifest.partInf.partTarget ) { this.manifest.partTargetDuration = this.manifest.partInf.partTarget; } setHoldBack.call( this, this.manifest ); }, }[entry.tagType] || noop ).call(self)); }, uri: function uri() { currentUri.uri = entry.uri; uris.push(currentUri); // if no explicit duration was declared, use the target duration if ( this.manifest.targetDuration && !("duration" in currentUri) ) { this.trigger("warn", { message: "defaulting segment duration to the target duration", }); currentUri.duration = this.manifest.targetDuration; } // annotate with encryption information, if necessary if (_key) { currentUri.key = _key; } currentUri.timeline = currentTimeline; // annotate with initialization segment information, if necessary if (currentMap) { currentUri.map = currentMap; } // reset the last byterange end as it needs to be 0 between parts lastPartByterangeEnd = 0; // prepare for the next URI currentUri = {}; }, comment: function comment() { // comments are not important for playback }, custom: function custom() { // if this is segment-level data attach the output to the segment if (entry.segment) { currentUri.custom = currentUri.custom || {}; currentUri.custom[entry.customType] = entry.data; // if this is manifest-level data attach to the top level manifest object } else { this.manifest.custom = this.manifest.custom || {}; this.manifest.custom[entry.customType] = entry.data; } }, }[entry.type].call(self)); }); return _this; } var _proto = Parser.prototype; _proto.warnOnMissingAttributes_ = function warnOnMissingAttributes_( identifier, attributes, required ) { var missing = []; required.forEach(function (key) { if (!attributes.hasOwnProperty(key)) { missing.push(key); } }); if (missing.length) { this.trigger("warn", { message: identifier + " lacks required attribute(s): " + missing.join(", "), }); } }; /** * Parse the input string and update the manifest object. * * @param {string} chunk a potentially incomplete portion of the manifest */ _proto.push = function push(chunk) { this.lineStream.push(chunk); }; /** * Flush any remaining input. This can be handy if the last line of an M3U8 * manifest did not contain a trailing newline but the file has been * completely received. */ _proto.end = function end() { // flush any buffered input this.lineStream.push("\n"); this.trigger("end"); }; /** * Add an additional parser for non-standard tags * * @param {Object} options a map of options for the added parser * @param {RegExp} options.expression a regular expression to match the custom header * @param {string} options.type the type to register to the output * @param {Function} [options.dataParser] function to parse the line into an object * @param {boolean} [options.segment] should tag data be attached to the segment object */ _proto.addParser = function addParser(options) { this.parseStream.addParser(options); }; /** * Add a custom header mapper * * @param {Object} options * @param {RegExp} options.expression a regular expression to match the custom header * @param {Function} options.map function to translate tag into a different tag */ _proto.addTagMapper = function addTagMapper(options) { this.parseStream.addTagMapper(options); }; return Parser; })(Stream); /***/ }, /***/ 973: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ jp: function () { return /* binding */ addSidxSegmentsToPlaylist; }, /* harmony export */ mm: function () { return /* binding */ generateSidxKey; }, /* harmony export */ Qc: function () { return /* binding */ parse; }, /* harmony export */ LG: function () { return /* binding */ parseUTCTiming; }, /* harmony export */ }); /* unused harmony exports VERSION, inheritAttributes, stringToMpdXml, toM3u8, toPlaylists */ /* harmony import */ var _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(779); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8908); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n( global_window__WEBPACK_IMPORTED_MODULE_1__ ); /* harmony import */ var _videojs_vhs_utils_es_decode_b64_to_uint8_array__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6722); /* harmony import */ var _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3969); /*! @name mpd-parser @version 0.19.2 @license Apache-2.0 */ var version = "0.19.2"; var isObject = function isObject(obj) { return !!obj && typeof obj === "object"; }; var merge = function merge() { for ( var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++ ) { objects[_key] = arguments[_key]; } return objects.reduce(function (result, source) { if (typeof source !== "object") { return result; } Object.keys(source).forEach(function (key) { if ( Array.isArray(result[key]) && Array.isArray(source[key]) ) { result[key] = result[key].concat(source[key]); } else if ( isObject(result[key]) && isObject(source[key]) ) { result[key] = merge(result[key], source[key]); } else { result[key] = source[key]; } }); return result; }, {}); }; var values = function values(o) { return Object.keys(o).map(function (k) { return o[k]; }); }; var range = function range(start, end) { var result = []; for (var i = start; i < end; i++) { result.push(i); } return result; }; var flatten = function flatten(lists) { return lists.reduce(function (x, y) { return x.concat(y); }, []); }; var from = function from(list) { if (!list.length) { return []; } var result = []; for (var i = 0; i < list.length; i++) { result.push(list[i]); } return result; }; var findIndexes = function findIndexes(l, key) { return l.reduce(function (a, e, i) { if (e[key]) { a.push(i); } return a; }, []); }; var errors = { INVALID_NUMBER_OF_PERIOD: "INVALID_NUMBER_OF_PERIOD", DASH_EMPTY_MANIFEST: "DASH_EMPTY_MANIFEST", DASH_INVALID_XML: "DASH_INVALID_XML", NO_BASE_URL: "NO_BASE_URL", MISSING_SEGMENT_INFORMATION: "MISSING_SEGMENT_INFORMATION", SEGMENT_TIME_UNSPECIFIED: "SEGMENT_TIME_UNSPECIFIED", UNSUPPORTED_UTC_TIMING_SCHEME: "UNSUPPORTED_UTC_TIMING_SCHEME", }; /** * @typedef {Object} SingleUri * @property {string} uri - relative location of segment * @property {string} resolvedUri - resolved location of segment * @property {Object} byterange - Object containing information on how to make byte range * requests following byte-range-spec per RFC2616. * @property {String} byterange.length - length of range request * @property {String} byterange.offset - byte offset of range request * * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 */ /** * Converts a URLType node (5.3.9.2.3 Table 13) to a segment object * that conforms to how m3u8-parser is structured * * @see https://github.com/videojs/m3u8-parser * * @param {string} baseUrl - baseUrl provided by <BaseUrl> nodes * @param {string} source - source url for segment * @param {string} range - optional range used for range calls, * follows RFC 2616, Clause 14.35.1 * @return {SingleUri} full segment information transformed into a format similar * to m3u8-parser */ var urlTypeToSegment = function urlTypeToSegment(_ref) { var _ref$baseUrl = _ref.baseUrl, baseUrl = _ref$baseUrl === void 0 ? "" : _ref$baseUrl, _ref$source = _ref.source, source = _ref$source === void 0 ? "" : _ref$source, _ref$range = _ref.range, range = _ref$range === void 0 ? "" : _ref$range, _ref$indexRange = _ref.indexRange, indexRange = _ref$indexRange === void 0 ? "" : _ref$indexRange; var segment = { uri: source, resolvedUri: (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */.Z)( baseUrl || "", source ), }; if (range || indexRange) { var rangeStr = range ? range : indexRange; var ranges = rangeStr.split("-"); var startRange = parseInt(ranges[0], 10); var endRange = parseInt(ranges[1], 10); // byterange should be inclusive according to // RFC 2616, Clause 14.35.1 segment.byterange = { length: endRange - startRange + 1, offset: startRange, }; } return segment; }; var byteRangeToString = function byteRangeToString(byterange) { // `endRange` is one less than `offset + length` because the HTTP range // header uses inclusive ranges var endRange = byterange.offset + byterange.length - 1; return byterange.offset + "-" + endRange; }; /** * parse the end number attribue that can be a string * number, or undefined. * * @param {string|number|undefined} endNumber * The end number attribute. * * @return {number|null} * The result of parsing the end number. */ var parseEndNumber = function parseEndNumber(endNumber) { if (endNumber && typeof endNumber !== "number") { endNumber = parseInt(endNumber, 10); } if (isNaN(endNumber)) { return null; } return endNumber; }; /** * Functions for calculating the range of available segments in static and dynamic * manifests. */ var segmentRange = { /** * Returns the entire range of available segments for a static MPD * * @param {Object} attributes * Inheritied MPD attributes * @return {{ start: number, end: number }} * The start and end numbers for available segments */ static: function _static(attributes) { var duration = attributes.duration, _attributes$timescale = attributes.timescale, timescale = _attributes$timescale === void 0 ? 1 : _attributes$timescale, sourceDuration = attributes.sourceDuration, periodDuration = attributes.periodDuration; var endNumber = parseEndNumber(attributes.endNumber); var segmentDuration = duration / timescale; if (typeof endNumber === "number") { return { start: 0, end: endNumber, }; } if (typeof periodDuration === "number") { return { start: 0, end: periodDuration / segmentDuration, }; } return { start: 0, end: sourceDuration / segmentDuration, }; }, /** * Returns the current live window range of available segments for a dynamic MPD * * @param {Object} attributes * Inheritied MPD attributes * @return {{ start: number, end: number }} * The start and end numbers for available segments */ dynamic: function dynamic(attributes) { var NOW = attributes.NOW, clientOffset = attributes.clientOffset, availabilityStartTime = attributes.availabilityStartTime, _attributes$timescale2 = attributes.timescale, timescale = _attributes$timescale2 === void 0 ? 1 : _attributes$timescale2, duration = attributes.duration, _attributes$start = attributes.start, start = _attributes$start === void 0 ? 0 : _attributes$start, _attributes$minimumUp = attributes.minimumUpdatePeriod, minimumUpdatePeriod = _attributes$minimumUp === void 0 ? 0 : _attributes$minimumUp, _attributes$timeShift = attributes.timeShiftBufferDepth, timeShiftBufferDepth = _attributes$timeShift === void 0 ? Infinity : _attributes$timeShift; var endNumber = parseEndNumber(attributes.endNumber); var now = (NOW + clientOffset) / 1000; var periodStartWC = availabilityStartTime + start; var periodEndWC = now + minimumUpdatePeriod; var periodDuration = periodEndWC - periodStartWC; var segmentCount = Math.ceil( (periodDuration * timescale) / duration ); var availableStart = Math.floor( ((now - periodStartWC - timeShiftBufferDepth) * timescale) / duration ); var availableEnd = Math.floor( ((now - periodStartWC) * timescale) / duration ); return { start: Math.max(0, availableStart), end: typeof endNumber === "number" ? endNumber : Math.min(segmentCount, availableEnd), }; }, }; /** * Maps a range of numbers to objects with information needed to build the corresponding * segment list * * @name toSegmentsCallback * @function * @param {number} number * Number of the segment * @param {number} index * Index of the number in the range list * @return {{ number: Number, duration: Number, timeline: Number, time: Number }} * Object with segment timing and duration info */ /** * Returns a callback for Array.prototype.map for mapping a range of numbers to * information needed to build the segment list. * * @param {Object} attributes * Inherited MPD attributes * @return {toSegmentsCallback} * Callback map function */ var toSegments = function toSegments(attributes) { return function (number, index) { var duration = attributes.duration, _attributes$timescale3 = attributes.timescale, timescale = _attributes$timescale3 === void 0 ? 1 : _attributes$timescale3, periodIndex = attributes.periodIndex, _attributes$startNumb = attributes.startNumber, startNumber = _attributes$startNumb === void 0 ? 1 : _attributes$startNumb; return { number: startNumber + number, duration: duration / timescale, timeline: periodIndex, time: index * duration, }; }; }; /** * Returns a list of objects containing segment timing and duration info used for * building the list of segments. This uses the @duration attribute specified * in the MPD manifest to derive the range of segments. * * @param {Object} attributes * Inherited MPD attributes * @return {{number: number, duration: number, time: number, timeline: number}[]} * List of Objects with segment timing and duration info */ var parseByDuration = function parseByDuration(attributes) { var type = attributes.type, duration = attributes.duration, _attributes$timescale4 = attributes.timescale, timescale = _attributes$timescale4 === void 0 ? 1 : _attributes$timescale4, periodDuration = attributes.periodDuration, sourceDuration = attributes.sourceDuration; var _segmentRange$type = segmentRange[type](attributes), start = _segmentRange$type.start, end = _segmentRange$type.end; var segments = range(start, end).map(toSegments(attributes)); if (type === "static") { var index = segments.length - 1; // section is either a period or the full source var sectionDuration = typeof periodDuration === "number" ? periodDuration : sourceDuration; // final segment may be less than full segment duration segments[index].duration = sectionDuration - (duration / timescale) * index; } return segments; }; /** * Translates SegmentBase into a set of segments. * (DASH SPEC Section 5.3.9.3.2) contains a set of <SegmentURL> nodes. Each * node should be translated into segment. * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @return {Object.<Array>} list of segments */ var segmentsFromBase = function segmentsFromBase(attributes) { var baseUrl = attributes.baseUrl, _attributes$initializ = attributes.initialization, initialization = _attributes$initializ === void 0 ? {} : _attributes$initializ, sourceDuration = attributes.sourceDuration, _attributes$indexRang = attributes.indexRange, indexRange = _attributes$indexRang === void 0 ? "" : _attributes$indexRang, duration = attributes.duration; // base url is required for SegmentBase to work, per spec (Section 5.3.9.2.1) if (!baseUrl) { throw new Error(errors.NO_BASE_URL); } var initSegment = urlTypeToSegment({ baseUrl: baseUrl, source: initialization.sourceURL, range: initialization.range, }); var segment = urlTypeToSegment({ baseUrl: baseUrl, source: baseUrl, indexRange: indexRange, }); segment.map = initSegment; // If there is a duration, use it, otherwise use the given duration of the source // (since SegmentBase is only for one total segment) if (duration) { var segmentTimeInfo = parseByDuration(attributes); if (segmentTimeInfo.length) { segment.duration = segmentTimeInfo[0].duration; segment.timeline = segmentTimeInfo[0].timeline; } } else if (sourceDuration) { segment.duration = sourceDuration; segment.timeline = 0; } // This is used for mediaSequence segment.number = 0; return [segment]; }; /** * Given a playlist, a sidx box, and a baseUrl, update the segment list of the playlist * according to the sidx information given. * * playlist.sidx has metadadata about the sidx where-as the sidx param * is the parsed sidx box itself. * * @param {Object} playlist the playlist to update the sidx information for * @param {Object} sidx the parsed sidx box * @return {Object} the playlist object with the updated sidx information */ var addSidxSegmentsToPlaylist = function addSidxSegmentsToPlaylist( playlist, sidx, baseUrl ) { // Retain init segment information var initSegment = playlist.sidx.map ? playlist.sidx.map : null; // Retain source duration from initial main manifest parsing var sourceDuration = playlist.sidx.duration; // Retain source timeline var timeline = playlist.timeline || 0; var sidxByteRange = playlist.sidx.byterange; var sidxEnd = sidxByteRange.offset + sidxByteRange.length; // Retain timescale of the parsed sidx var timescale = sidx.timescale; // referenceType 1 refers to other sidx boxes var mediaReferences = sidx.references.filter(function (r) { return r.referenceType !== 1; }); var segments = []; var type = playlist.endList ? "static" : "dynamic"; // firstOffset is the offset from the end of the sidx box var startIndex = sidxEnd + sidx.firstOffset; for (var i = 0; i < mediaReferences.length; i++) { var reference = sidx.references[i]; // size of the referenced (sub)segment var size = reference.referencedSize; // duration of the referenced (sub)segment, in the timescale // this will be converted to seconds when generating segments var duration = reference.subsegmentDuration; // should be an inclusive range var endIndex = startIndex + size - 1; var indexRange = startIndex + "-" + endIndex; var attributes = { baseUrl: baseUrl, timescale: timescale, timeline: timeline, // this is used in parseByDuration periodIndex: timeline, duration: duration, sourceDuration: sourceDuration, indexRange: indexRange, type: type, }; var segment = segmentsFromBase(attributes)[0]; if (initSegment) { segment.map = initSegment; } segments.push(segment); startIndex += size; } playlist.segments = segments; return playlist; }; var generateSidxKey = function generateSidxKey(sidx) { return ( sidx && sidx.uri + "-" + byteRangeToString(sidx.byterange) ); }; var mergeDiscontiguousPlaylists = function mergeDiscontiguousPlaylists(playlists) { var mergedPlaylists = values( playlists.reduce(function (acc, playlist) { // assuming playlist IDs are the same across periods // TODO: handle multiperiod where representation sets are not the same // across periods var name = playlist.attributes.id + (playlist.attributes.lang || ""); // Periods after first if (acc[name]) { var _acc$name$segments; // first segment of subsequent periods signal a discontinuity if (playlist.segments[0]) { playlist.segments[0].discontinuity = true; } (_acc$name$segments = acc[name].segments).push.apply( _acc$name$segments, playlist.segments ); // bubble up contentProtection, this assumes all DRM content // has the same contentProtection if (playlist.attributes.contentProtection) { acc[name].attributes.contentProtection = playlist.attributes.contentProtection; } } else { // first Period acc[name] = playlist; } return acc; }, {}) ); return mergedPlaylists.map(function (playlist) { playlist.discontinuityStarts = findIndexes( playlist.segments, "discontinuity" ); return playlist; }); }; var addSidxSegmentsToPlaylist$1 = function addSidxSegmentsToPlaylist$1(playlist, sidxMapping) { var sidxKey = generateSidxKey(playlist.sidx); var sidxMatch = sidxKey && sidxMapping[sidxKey] && sidxMapping[sidxKey].sidx; if (sidxMatch) { addSidxSegmentsToPlaylist( playlist, sidxMatch, playlist.sidx.resolvedUri ); } return playlist; }; var addSidxSegmentsToPlaylists = function addSidxSegmentsToPlaylists(playlists, sidxMapping) { if (sidxMapping === void 0) { sidxMapping = {}; } if (!Object.keys(sidxMapping).length) { return playlists; } for (var i in playlists) { playlists[i] = addSidxSegmentsToPlaylist$1( playlists[i], sidxMapping ); } return playlists; }; var formatAudioPlaylist = function formatAudioPlaylist( _ref, isAudioOnly ) { var _attributes; var attributes = _ref.attributes, segments = _ref.segments, sidx = _ref.sidx; var playlist = { attributes: ((_attributes = { NAME: attributes.id, BANDWIDTH: attributes.bandwidth, CODECS: attributes.codecs, }), (_attributes["PROGRAM-ID"] = 1), _attributes), uri: "", endList: attributes.type === "static", timeline: attributes.periodIndex, resolvedUri: "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1, }; if (attributes.contentProtection) { playlist.contentProtection = attributes.contentProtection; } if (sidx) { playlist.sidx = sidx; } if (isAudioOnly) { playlist.attributes.AUDIO = "audio"; playlist.attributes.SUBTITLES = "subs"; } return playlist; }; var formatVttPlaylist = function formatVttPlaylist(_ref2) { var _m3u8Attributes; var attributes = _ref2.attributes, segments = _ref2.segments; if (typeof segments === "undefined") { // vtt tracks may use single file in BaseURL segments = [ { uri: attributes.baseUrl, timeline: attributes.periodIndex, resolvedUri: attributes.baseUrl || "", duration: attributes.sourceDuration, number: 0, }, ]; // targetDuration should be the same duration as the only segment attributes.duration = attributes.sourceDuration; } var m3u8Attributes = ((_m3u8Attributes = { NAME: attributes.id, BANDWIDTH: attributes.bandwidth, }), (_m3u8Attributes["PROGRAM-ID"] = 1), _m3u8Attributes); if (attributes.codecs) { m3u8Attributes.CODECS = attributes.codecs; } return { attributes: m3u8Attributes, uri: "", endList: attributes.type === "static", timeline: attributes.periodIndex, resolvedUri: attributes.baseUrl || "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1, }; }; var organizeAudioPlaylists = function organizeAudioPlaylists( playlists, sidxMapping, isAudioOnly ) { if (sidxMapping === void 0) { sidxMapping = {}; } if (isAudioOnly === void 0) { isAudioOnly = false; } var mainPlaylist; var formattedPlaylists = playlists.reduce(function ( a, playlist ) { var role = (playlist.attributes.role && playlist.attributes.role.value) || ""; var language = playlist.attributes.lang || ""; var label = playlist.attributes.label || "main"; if (language && !playlist.attributes.label) { var roleLabel = role ? " (" + role + ")" : ""; label = "" + playlist.attributes.lang + roleLabel; } if (!a[label]) { a[label] = { language: language, autoselect: true, default: role === "main", playlists: [], uri: "", }; } var formatted = addSidxSegmentsToPlaylist$1( formatAudioPlaylist(playlist, isAudioOnly), sidxMapping ); a[label].playlists.push(formatted); if ( typeof mainPlaylist === "undefined" && role === "main" ) { mainPlaylist = playlist; mainPlaylist.default = true; } return a; }, {}); // if no playlists have role "main", mark the first as main if (!mainPlaylist) { var firstLabel = Object.keys(formattedPlaylists)[0]; formattedPlaylists[firstLabel].default = true; } return formattedPlaylists; }; var organizeVttPlaylists = function organizeVttPlaylists( playlists, sidxMapping ) { if (sidxMapping === void 0) { sidxMapping = {}; } return playlists.reduce(function (a, playlist) { var label = playlist.attributes.lang || "text"; if (!a[label]) { a[label] = { language: label, default: false, autoselect: false, playlists: [], uri: "", }; } a[label].playlists.push( addSidxSegmentsToPlaylist$1( formatVttPlaylist(playlist), sidxMapping ) ); return a; }, {}); }; var organizeCaptionServices = function organizeCaptionServices( captionServices ) { return captionServices.reduce(function (svcObj, svc) { if (!svc) { return svcObj; } svc.forEach(function (service) { var channel = service.channel, language = service.language; svcObj[language] = { autoselect: false, default: false, instreamId: channel, language: language, }; if (service.hasOwnProperty("aspectRatio")) { svcObj[language].aspectRatio = service.aspectRatio; } if (service.hasOwnProperty("easyReader")) { svcObj[language].easyReader = service.easyReader; } if (service.hasOwnProperty("3D")) { svcObj[language]["3D"] = service["3D"]; } }); return svcObj; }, {}); }; var formatVideoPlaylist = function formatVideoPlaylist(_ref3) { var _attributes2; var attributes = _ref3.attributes, segments = _ref3.segments, sidx = _ref3.sidx; var playlist = { attributes: ((_attributes2 = { NAME: attributes.id, AUDIO: "audio", SUBTITLES: "subs", RESOLUTION: { width: attributes.width, height: attributes.height, }, CODECS: attributes.codecs, BANDWIDTH: attributes.bandwidth, }), (_attributes2["PROGRAM-ID"] = 1), _attributes2), uri: "", endList: attributes.type === "static", timeline: attributes.periodIndex, resolvedUri: "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1, }; if (attributes.contentProtection) { playlist.contentProtection = attributes.contentProtection; } if (sidx) { playlist.sidx = sidx; } return playlist; }; var videoOnly = function videoOnly(_ref4) { var attributes = _ref4.attributes; return ( attributes.mimeType === "video/mp4" || attributes.mimeType === "video/webm" || attributes.contentType === "video" ); }; var audioOnly = function audioOnly(_ref5) { var attributes = _ref5.attributes; return ( attributes.mimeType === "audio/mp4" || attributes.mimeType === "audio/webm" || attributes.contentType === "audio" ); }; var vttOnly = function vttOnly(_ref6) { var attributes = _ref6.attributes; return ( attributes.mimeType === "text/vtt" || attributes.contentType === "text" ); }; var toM3u8 = function toM3u8( dashPlaylists, locations, sidxMapping ) { var _mediaGroups; if (sidxMapping === void 0) { sidxMapping = {}; } if (!dashPlaylists.length) { return {}; } // grab all main manifest attributes var _dashPlaylists$0$attr = dashPlaylists[0].attributes, duration = _dashPlaylists$0$attr.sourceDuration, type = _dashPlaylists$0$attr.type, suggestedPresentationDelay = _dashPlaylists$0$attr.suggestedPresentationDelay, minimumUpdatePeriod = _dashPlaylists$0$attr.minimumUpdatePeriod; var videoPlaylists = mergeDiscontiguousPlaylists( dashPlaylists.filter(videoOnly) ).map(formatVideoPlaylist); var audioPlaylists = mergeDiscontiguousPlaylists( dashPlaylists.filter(audioOnly) ); var vttPlaylists = dashPlaylists.filter(vttOnly); var captions = dashPlaylists .map(function (playlist) { return playlist.attributes.captionServices; }) .filter(Boolean); var manifest = { allowCache: true, discontinuityStarts: [], segments: [], endList: true, mediaGroups: ((_mediaGroups = { AUDIO: {}, VIDEO: {}, }), (_mediaGroups["CLOSED-CAPTIONS"] = {}), (_mediaGroups.SUBTITLES = {}), _mediaGroups), uri: "", duration: duration, playlists: addSidxSegmentsToPlaylists( videoPlaylists, sidxMapping ), }; if (minimumUpdatePeriod >= 0) { manifest.minimumUpdatePeriod = minimumUpdatePeriod * 1000; } if (locations) { manifest.locations = locations; } if (type === "dynamic") { manifest.suggestedPresentationDelay = suggestedPresentationDelay; } var isAudioOnly = manifest.playlists.length === 0; if (audioPlaylists.length) { manifest.mediaGroups.AUDIO.audio = organizeAudioPlaylists( audioPlaylists, sidxMapping, isAudioOnly ); } if (vttPlaylists.length) { manifest.mediaGroups.SUBTITLES.subs = organizeVttPlaylists( vttPlaylists, sidxMapping ); } if (captions.length) { manifest.mediaGroups["CLOSED-CAPTIONS"].cc = organizeCaptionServices(captions); } return manifest; }; /** * Calculates the R (repetition) value for a live stream (for the final segment * in a manifest where the r value is negative 1) * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {number} time * current time (typically the total time up until the final segment) * @param {number} duration * duration property for the given <S /> * * @return {number} * R value to reach the end of the given period */ var getLiveRValue = function getLiveRValue( attributes, time, duration ) { var NOW = attributes.NOW, clientOffset = attributes.clientOffset, availabilityStartTime = attributes.availabilityStartTime, _attributes$timescale = attributes.timescale, timescale = _attributes$timescale === void 0 ? 1 : _attributes$timescale, _attributes$start = attributes.start, start = _attributes$start === void 0 ? 0 : _attributes$start, _attributes$minimumUp = attributes.minimumUpdatePeriod, minimumUpdatePeriod = _attributes$minimumUp === void 0 ? 0 : _attributes$minimumUp; var now = (NOW + clientOffset) / 1000; var periodStartWC = availabilityStartTime + start; var periodEndWC = now + minimumUpdatePeriod; var periodDuration = periodEndWC - periodStartWC; return Math.ceil( (periodDuration * timescale - time) / duration ); }; /** * Uses information provided by SegmentTemplate.SegmentTimeline to determine segment * timing and duration * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {Object[]} segmentTimeline * List of objects representing the attributes of each S element contained within * * @return {{number: number, duration: number, time: number, timeline: number}[]} * List of Objects with segment timing and duration info */ var parseByTimeline = function parseByTimeline( attributes, segmentTimeline ) { var type = attributes.type, _attributes$minimumUp2 = attributes.minimumUpdatePeriod, minimumUpdatePeriod = _attributes$minimumUp2 === void 0 ? 0 : _attributes$minimumUp2, _attributes$media = attributes.media, media = _attributes$media === void 0 ? "" : _attributes$media, sourceDuration = attributes.sourceDuration, _attributes$timescale2 = attributes.timescale, timescale = _attributes$timescale2 === void 0 ? 1 : _attributes$timescale2, _attributes$startNumb = attributes.startNumber, startNumber = _attributes$startNumb === void 0 ? 1 : _attributes$startNumb, timeline = attributes.periodIndex; var segments = []; var time = -1; for ( var sIndex = 0; sIndex < segmentTimeline.length; sIndex++ ) { var S = segmentTimeline[sIndex]; var duration = S.d; var repeat = S.r || 0; var segmentTime = S.t || 0; if (time < 0) { // first segment time = segmentTime; } if (segmentTime && segmentTime > time) { // discontinuity // TODO: How to handle this type of discontinuity // timeline++ here would treat it like HLS discontuity and content would // get appended without gap // E.G. // <S t="0" d="1" /> // <S d="1" /> // <S d="1" /> // <S t="5" d="1" /> // would have $Time$ values of [0, 1, 2, 5] // should this be appened at time positions [0, 1, 2, 3],(#EXT-X-DISCONTINUITY) // or [0, 1, 2, gap, gap, 5]? (#EXT-X-GAP) // does the value of sourceDuration consider this when calculating arbitrary // negative @r repeat value? // E.G. Same elements as above with this added at the end // <S d="1" r="-1" /> // with a sourceDuration of 10 // Would the 2 gaps be included in the time duration calculations resulting in // 8 segments with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9] or 10 segments // with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9, 10, 11] ? time = segmentTime; } var count = void 0; if (repeat < 0) { var nextS = sIndex + 1; if (nextS === segmentTimeline.length) { // last segment if ( type === "dynamic" && minimumUpdatePeriod > 0 && media.indexOf("$Number$") > 0 ) { count = getLiveRValue( attributes, time, duration ); } else { // TODO: This may be incorrect depending on conclusion of TODO above count = (sourceDuration * timescale - time) / duration; } } else { count = (segmentTimeline[nextS].t - time) / duration; } } else { count = repeat + 1; } var end = startNumber + segments.length + count; var number = startNumber + segments.length; while (number < end) { segments.push({ number: number, duration: duration / timescale, time: time, timeline: timeline, }); time += duration; number++; } } return segments; }; var identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g; /** * Replaces template identifiers with corresponding values. To be used as the callback * for String.prototype.replace * * @name replaceCallback * @function * @param {string} match * Entire match of identifier * @param {string} identifier * Name of matched identifier * @param {string} format * Format tag string. Its presence indicates that padding is expected * @param {string} width * Desired length of the replaced value. Values less than this width shall be left * zero padded * @return {string} * Replacement for the matched identifier */ /** * Returns a function to be used as a callback for String.prototype.replace to replace * template identifiers * * @param {Obect} values * Object containing values that shall be used to replace known identifiers * @param {number} values.RepresentationID * Value of the Representation@id attribute * @param {number} values.Number * Number of the corresponding segment * @param {number} values.Bandwidth * Value of the Representation@bandwidth attribute. * @param {number} values.Time * Timestamp value of the corresponding segment * @return {replaceCallback} * Callback to be used with String.prototype.replace to replace identifiers */ var identifierReplacement = function identifierReplacement(values) { return function (match, identifier, format, width) { if (match === "$$") { // escape sequence return "$"; } if (typeof values[identifier] === "undefined") { return match; } var value = "" + values[identifier]; if (identifier === "RepresentationID") { // Format tag shall not be present with RepresentationID return value; } if (!format) { width = 1; } else { width = parseInt(width, 10); } if (value.length >= width) { return value; } return ( "" + new Array(width - value.length + 1).join("0") + value ); }; }; /** * Constructs a segment url from a template string * * @param {string} url * Template string to construct url from * @param {Obect} values * Object containing values that shall be used to replace known identifiers * @param {number} values.RepresentationID * Value of the Representation@id attribute * @param {number} values.Number * Number of the corresponding segment * @param {number} values.Bandwidth * Value of the Representation@bandwidth attribute. * @param {number} values.Time * Timestamp value of the corresponding segment * @return {string} * Segment url with identifiers replaced */ var constructTemplateUrl = function constructTemplateUrl( url, values ) { return url.replace( identifierPattern, identifierReplacement(values) ); }; /** * Generates a list of objects containing timing and duration information about each * segment needed to generate segment uris and the complete segment object * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {Object[]|undefined} segmentTimeline * List of objects representing the attributes of each S element contained within * the SegmentTimeline element * @return {{number: number, duration: number, time: number, timeline: number}[]} * List of Objects with segment timing and duration info */ var parseTemplateInfo = function parseTemplateInfo( attributes, segmentTimeline ) { if (!attributes.duration && !segmentTimeline) { // if neither @duration or SegmentTimeline are present, then there shall be exactly // one media segment return [ { number: attributes.startNumber || 1, duration: attributes.sourceDuration, time: 0, timeline: attributes.periodIndex, }, ]; } if (attributes.duration) { return parseByDuration(attributes); } return parseByTimeline(attributes, segmentTimeline); }; /** * Generates a list of segments using information provided by the SegmentTemplate element * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {Object[]|undefined} segmentTimeline * List of objects representing the attributes of each S element contained within * the SegmentTimeline element * @return {Object[]} * List of segment objects */ var segmentsFromTemplate = function segmentsFromTemplate( attributes, segmentTimeline ) { var templateValues = { RepresentationID: attributes.id, Bandwidth: attributes.bandwidth || 0, }; var _attributes$initializ = attributes.initialization, initialization = _attributes$initializ === void 0 ? { sourceURL: "", range: "", } : _attributes$initializ; var mapSegment = urlTypeToSegment({ baseUrl: attributes.baseUrl, source: constructTemplateUrl( initialization.sourceURL, templateValues ), range: initialization.range, }); var segments = parseTemplateInfo(attributes, segmentTimeline); return segments.map(function (segment) { templateValues.Number = segment.number; templateValues.Time = segment.time; var uri = constructTemplateUrl( attributes.media || "", templateValues ); // See DASH spec section 5.3.9.2.2 // - if timescale isn't present on any level, default to 1. var timescale = attributes.timescale || 1; // - if presentationTimeOffset isn't present on any level, default to 0 var presentationTimeOffset = attributes.presentationTimeOffset || 0; var presentationTime = // Even if the @t attribute is not specified for the segment, segment.time is // calculated in mpd-parser prior to this, so it's assumed to be available. attributes.periodStart + (segment.time - presentationTimeOffset) / timescale; var map = { uri: uri, timeline: segment.timeline, duration: segment.duration, resolvedUri: (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */.Z)( attributes.baseUrl || "", uri ), map: mapSegment, number: segment.number, presentationTime: presentationTime, }; return map; }); }; /** * Converts a <SegmentUrl> (of type URLType from the DASH spec 5.3.9.2 Table 14) * to an object that matches the output of a segment in videojs/mpd-parser * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {Object} segmentUrl * <SegmentURL> node to translate into a segment object * @return {Object} translated segment object */ var SegmentURLToSegmentObject = function SegmentURLToSegmentObject( attributes, segmentUrl ) { var baseUrl = attributes.baseUrl, _attributes$initializ = attributes.initialization, initialization = _attributes$initializ === void 0 ? {} : _attributes$initializ; var initSegment = urlTypeToSegment({ baseUrl: baseUrl, source: initialization.sourceURL, range: initialization.range, }); var segment = urlTypeToSegment({ baseUrl: baseUrl, source: segmentUrl.media, range: segmentUrl.mediaRange, }); segment.map = initSegment; return segment; }; /** * Generates a list of segments using information provided by the SegmentList element * SegmentList (DASH SPEC Section 5.3.9.3.2) contains a set of <SegmentURL> nodes. Each * node should be translated into segment. * * @param {Object} attributes * Object containing all inherited attributes from parent elements with attribute * names as keys * @param {Object[]|undefined} segmentTimeline * List of objects representing the attributes of each S element contained within * the SegmentTimeline element * @return {Object.<Array>} list of segments */ var segmentsFromList = function segmentsFromList( attributes, segmentTimeline ) { var duration = attributes.duration, _attributes$segmentUr = attributes.segmentUrls, segmentUrls = _attributes$segmentUr === void 0 ? [] : _attributes$segmentUr, periodStart = attributes.periodStart; // Per spec (5.3.9.2.1) no way to determine segment duration OR // if both SegmentTimeline and @duration are defined, it is outside of spec. if ( (!duration && !segmentTimeline) || (duration && segmentTimeline) ) { throw new Error(errors.SEGMENT_TIME_UNSPECIFIED); } var segmentUrlMap = segmentUrls.map(function ( segmentUrlObject ) { return SegmentURLToSegmentObject( attributes, segmentUrlObject ); }); var segmentTimeInfo; if (duration) { segmentTimeInfo = parseByDuration(attributes); } if (segmentTimeline) { segmentTimeInfo = parseByTimeline( attributes, segmentTimeline ); } var segments = segmentTimeInfo .map(function (segmentTime, index) { if (segmentUrlMap[index]) { var segment = segmentUrlMap[index]; // See DASH spec section 5.3.9.2.2 // - if timescale isn't present on any level, default to 1. var timescale = attributes.timescale || 1; // - if presentationTimeOffset isn't present on any level, default to 0 var presentationTimeOffset = attributes.presentationTimeOffset || 0; segment.timeline = segmentTime.timeline; segment.duration = segmentTime.duration; segment.number = segmentTime.number; segment.presentationTime = periodStart + (segmentTime.time - presentationTimeOffset) / timescale; return segment; } // Since we're mapping we should get rid of any blank segments (in case // the given SegmentTimeline is handling for more elements than we have // SegmentURLs for). }) .filter(function (segment) { return segment; }); return segments; }; var generateSegments = function generateSegments(_ref) { var attributes = _ref.attributes, segmentInfo = _ref.segmentInfo; var segmentAttributes; var segmentsFn; if (segmentInfo.template) { segmentsFn = segmentsFromTemplate; segmentAttributes = merge(attributes, segmentInfo.template); } else if (segmentInfo.base) { segmentsFn = segmentsFromBase; segmentAttributes = merge(attributes, segmentInfo.base); } else if (segmentInfo.list) { segmentsFn = segmentsFromList; segmentAttributes = merge(attributes, segmentInfo.list); } var segmentsInfo = { attributes: attributes, }; if (!segmentsFn) { return segmentsInfo; } var segments = segmentsFn( segmentAttributes, segmentInfo.segmentTimeline ); // The @duration attribute will be used to determin the playlist's targetDuration which // must be in seconds. Since we've generated the segment list, we no longer need // @duration to be in @timescale units, so we can convert it here. if (segmentAttributes.duration) { var _segmentAttributes = segmentAttributes, duration = _segmentAttributes.duration, _segmentAttributes$ti = _segmentAttributes.timescale, timescale = _segmentAttributes$ti === void 0 ? 1 : _segmentAttributes$ti; segmentAttributes.duration = duration / timescale; } else if (segments.length) { // if there is no @duration attribute, use the largest segment duration as // as target duration segmentAttributes.duration = segments.reduce(function ( max, segment ) { return Math.max(max, Math.ceil(segment.duration)); }, 0); } else { segmentAttributes.duration = 0; } segmentsInfo.attributes = segmentAttributes; segmentsInfo.segments = segments; // This is a sidx box without actual segment information if (segmentInfo.base && segmentAttributes.indexRange) { segmentsInfo.sidx = segments[0]; segmentsInfo.segments = []; } return segmentsInfo; }; var toPlaylists = function toPlaylists(representations) { return representations.map(generateSegments); }; var findChildren = function findChildren(element, name) { return from(element.childNodes).filter(function (_ref) { var tagName = _ref.tagName; return tagName === name; }); }; var getContent = function getContent(element) { return element.textContent.trim(); }; var parseDuration = function parseDuration(str) { var SECONDS_IN_YEAR = 365 * 24 * 60 * 60; var SECONDS_IN_MONTH = 30 * 24 * 60 * 60; var SECONDS_IN_DAY = 24 * 60 * 60; var SECONDS_IN_HOUR = 60 * 60; var SECONDS_IN_MIN = 60; // P10Y10M10DT10H10M10.1S var durationRegex = /P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/; var match = durationRegex.exec(str); if (!match) { return 0; } var _match$slice = match.slice(1), year = _match$slice[0], month = _match$slice[1], day = _match$slice[2], hour = _match$slice[3], minute = _match$slice[4], second = _match$slice[5]; return ( parseFloat(year || 0) * SECONDS_IN_YEAR + parseFloat(month || 0) * SECONDS_IN_MONTH + parseFloat(day || 0) * SECONDS_IN_DAY + parseFloat(hour || 0) * SECONDS_IN_HOUR + parseFloat(minute || 0) * SECONDS_IN_MIN + parseFloat(second || 0) ); }; var parseDate = function parseDate(str) { // Date format without timezone according to ISO 8601 // YYY-MM-DDThh:mm:ss.ssssss var dateRegex = /^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/; // If the date string does not specifiy a timezone, we must specifiy UTC. This is // expressed by ending with 'Z' if (dateRegex.test(str)) { str += "Z"; } return Date.parse(str); }; var parsers = { /** * Specifies the duration of the entire Media Presentation. Format is a duration string * as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ mediaPresentationDuration: function mediaPresentationDuration( value ) { return parseDuration(value); }, /** * Specifies the Segment availability start time for all Segments referred to in this * MPD. For a dynamic manifest, it specifies the anchor for the earliest availability * time. Format is a date string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The date as seconds from unix epoch */ availabilityStartTime: function availabilityStartTime(value) { return parseDate(value) / 1000; }, /** * Specifies the smallest period between potential changes to the MPD. Format is a * duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ minimumUpdatePeriod: function minimumUpdatePeriod(value) { return parseDuration(value); }, /** * Specifies the suggested presentation delay. Format is a * duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ suggestedPresentationDelay: function suggestedPresentationDelay( value ) { return parseDuration(value); }, /** * specifices the type of mpd. Can be either "static" or "dynamic" * * @param {string} value * value of attribute as a string * * @return {string} * The type as a string */ type: function type(value) { return value; }, /** * Specifies the duration of the smallest time shifting buffer for any Representation * in the MPD. Format is a duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ timeShiftBufferDepth: function timeShiftBufferDepth(value) { return parseDuration(value); }, /** * Specifies the PeriodStart time of the Period relative to the availabilityStarttime. * Format is a duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ start: function start(value) { return parseDuration(value); }, /** * Specifies the width of the visual presentation * * @param {string} value * value of attribute as a string * @return {number} * The parsed width */ width: function width(value) { return parseInt(value, 10); }, /** * Specifies the height of the visual presentation * * @param {string} value * value of attribute as a string * @return {number} * The parsed height */ height: function height(value) { return parseInt(value, 10); }, /** * Specifies the bitrate of the representation * * @param {string} value * value of attribute as a string * @return {number} * The parsed bandwidth */ bandwidth: function bandwidth(value) { return parseInt(value, 10); }, /** * Specifies the number of the first Media Segment in this Representation in the Period * * @param {string} value * value of attribute as a string * @return {number} * The parsed number */ startNumber: function startNumber(value) { return parseInt(value, 10); }, /** * Specifies the timescale in units per seconds * * @param {string} value * value of attribute as a string * @return {number} * The parsed timescale */ timescale: function timescale(value) { return parseInt(value, 10); }, /** * Specifies the presentationTimeOffset. * * @param {string} value * value of the attribute as a string * * @return {number} * The parsed presentationTimeOffset */ presentationTimeOffset: function presentationTimeOffset(value) { return parseInt(value, 10); }, /** * Specifies the constant approximate Segment duration * NOTE: The <Period> element also contains an @duration attribute. This duration * specifies the duration of the Period. This attribute is currently not * supported by the rest of the parser, however we still check for it to prevent * errors. * * @param {string} value * value of attribute as a string * @return {number} * The parsed duration */ duration: function duration(value) { var parsedValue = parseInt(value, 10); if (isNaN(parsedValue)) { return parseDuration(value); } return parsedValue; }, /** * Specifies the Segment duration, in units of the value of the @timescale. * * @param {string} value * value of attribute as a string * @return {number} * The parsed duration */ d: function d(value) { return parseInt(value, 10); }, /** * Specifies the MPD start time, in @timescale units, the first Segment in the series * starts relative to the beginning of the Period * * @param {string} value * value of attribute as a string * @return {number} * The parsed time */ t: function t(value) { return parseInt(value, 10); }, /** * Specifies the repeat count of the number of following contiguous Segments with the * same duration expressed by the value of @d * * @param {string} value * value of attribute as a string * @return {number} * The parsed number */ r: function r(value) { return parseInt(value, 10); }, /** * Default parser for all other attributes. Acts as a no-op and just returns the value * as a string * * @param {string} value * value of attribute as a string * @return {string} * Unparsed value */ DEFAULT: function DEFAULT(value) { return value; }, }; /** * Gets all the attributes and values of the provided node, parses attributes with known * types, and returns an object with attribute names mapped to values. * * @param {Node} el * The node to parse attributes from * @return {Object} * Object with all attributes of el parsed */ var parseAttributes = function parseAttributes(el) { if (!(el && el.attributes)) { return {}; } return from(el.attributes).reduce(function (a, e) { var parseFn = parsers[e.name] || parsers.DEFAULT; a[e.name] = parseFn(e.value); return a; }, {}); }; var keySystemsMap = { "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b": "org.w3.clearkey", "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": "com.widevine.alpha", "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": "com.microsoft.playready", "urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb": "com.adobe.primetime", }; /** * Builds a list of urls that is the product of the reference urls and BaseURL values * * @param {string[]} referenceUrls * List of reference urls to resolve to * @param {Node[]} baseUrlElements * List of BaseURL nodes from the mpd * @return {string[]} * List of resolved urls */ var buildBaseUrls = function buildBaseUrls( referenceUrls, baseUrlElements ) { if (!baseUrlElements.length) { return referenceUrls; } return flatten( referenceUrls.map(function (reference) { return baseUrlElements.map(function (baseUrlElement) { return (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */.Z)(reference, getContent(baseUrlElement)); }); }) ); }; /** * Contains all Segment information for its containing AdaptationSet * * @typedef {Object} SegmentInformation * @property {Object|undefined} template * Contains the attributes for the SegmentTemplate node * @property {Object[]|undefined} segmentTimeline * Contains a list of atrributes for each S node within the SegmentTimeline node * @property {Object|undefined} list * Contains the attributes for the SegmentList node * @property {Object|undefined} base * Contains the attributes for the SegmentBase node */ /** * Returns all available Segment information contained within the AdaptationSet node * * @param {Node} adaptationSet * The AdaptationSet node to get Segment information from * @return {SegmentInformation} * The Segment information contained within the provided AdaptationSet */ var getSegmentInformation = function getSegmentInformation( adaptationSet ) { var segmentTemplate = findChildren( adaptationSet, "SegmentTemplate" )[0]; var segmentList = findChildren(adaptationSet, "SegmentList")[0]; var segmentUrls = segmentList && findChildren(segmentList, "SegmentURL").map(function (s) { return merge( { tag: "SegmentURL", }, parseAttributes(s) ); }); var segmentBase = findChildren(adaptationSet, "SegmentBase")[0]; var segmentTimelineParentNode = segmentList || segmentTemplate; var segmentTimeline = segmentTimelineParentNode && findChildren( segmentTimelineParentNode, "SegmentTimeline" )[0]; var segmentInitializationParentNode = segmentList || segmentBase || segmentTemplate; var segmentInitialization = segmentInitializationParentNode && findChildren( segmentInitializationParentNode, "Initialization" )[0]; // SegmentTemplate is handled slightly differently, since it can have both // @initialization and an <Initialization> node. @initialization can be templated, // while the node can have a url and range specified. If the <SegmentTemplate> has // both @initialization and an <Initialization> subelement we opt to override with // the node, as this interaction is not defined in the spec. var template = segmentTemplate && parseAttributes(segmentTemplate); if (template && segmentInitialization) { template.initialization = segmentInitialization && parseAttributes(segmentInitialization); } else if (template && template.initialization) { // If it is @initialization we convert it to an object since this is the format that // later functions will rely on for the initialization segment. This is only valid // for <SegmentTemplate> template.initialization = { sourceURL: template.initialization, }; } var segmentInfo = { template: template, segmentTimeline: segmentTimeline && findChildren(segmentTimeline, "S").map(function (s) { return parseAttributes(s); }), list: segmentList && merge(parseAttributes(segmentList), { segmentUrls: segmentUrls, initialization: parseAttributes( segmentInitialization ), }), base: segmentBase && merge(parseAttributes(segmentBase), { initialization: parseAttributes( segmentInitialization ), }), }; Object.keys(segmentInfo).forEach(function (key) { if (!segmentInfo[key]) { delete segmentInfo[key]; } }); return segmentInfo; }; /** * Contains Segment information and attributes needed to construct a Playlist object * from a Representation * * @typedef {Object} RepresentationInformation * @property {SegmentInformation} segmentInfo * Segment information for this Representation * @property {Object} attributes * Inherited attributes for this Representation */ /** * Maps a Representation node to an object containing Segment information and attributes * * @name inheritBaseUrlsCallback * @function * @param {Node} representation * Representation node from the mpd * @return {RepresentationInformation} * Representation information needed to construct a Playlist object */ /** * Returns a callback for Array.prototype.map for mapping Representation nodes to * Segment information and attributes using inherited BaseURL nodes. * * @param {Object} adaptationSetAttributes * Contains attributes inherited by the AdaptationSet * @param {string[]} adaptationSetBaseUrls * Contains list of resolved base urls inherited by the AdaptationSet * @param {SegmentInformation} adaptationSetSegmentInfo * Contains Segment information for the AdaptationSet * @return {inheritBaseUrlsCallback} * Callback map function */ var inheritBaseUrls = function inheritBaseUrls( adaptationSetAttributes, adaptationSetBaseUrls, adaptationSetSegmentInfo ) { return function (representation) { var repBaseUrlElements = findChildren( representation, "BaseURL" ); var repBaseUrls = buildBaseUrls( adaptationSetBaseUrls, repBaseUrlElements ); var attributes = merge( adaptationSetAttributes, parseAttributes(representation) ); var representationSegmentInfo = getSegmentInformation(representation); return repBaseUrls.map(function (baseUrl) { return { segmentInfo: merge( adaptationSetSegmentInfo, representationSegmentInfo ), attributes: merge(attributes, { baseUrl: baseUrl, }), }; }); }; }; /** * Tranforms a series of content protection nodes to * an object containing pssh data by key system * * @param {Node[]} contentProtectionNodes * Content protection nodes * @return {Object} * Object containing pssh data by key system */ var generateKeySystemInformation = function generateKeySystemInformation(contentProtectionNodes) { return contentProtectionNodes.reduce(function (acc, node) { var attributes = parseAttributes(node); var keySystem = keySystemsMap[attributes.schemeIdUri]; if (keySystem) { acc[keySystem] = { attributes: attributes, }; var psshNode = findChildren(node, "cenc:pssh")[0]; if (psshNode) { var pssh = getContent(psshNode); var psshBuffer = pssh && (0, _videojs_vhs_utils_es_decode_b64_to_uint8_array__WEBPACK_IMPORTED_MODULE_2__ /* ["default"] */.Z)( pssh ); acc[keySystem].pssh = psshBuffer; } } return acc; }, {}); }; // defined in ANSI_SCTE 214-1 2016 var parseCaptionServiceMetadata = function parseCaptionServiceMetadata(service) { // 608 captions if ( service.schemeIdUri === "urn:scte:dash:cc:cea-608:2015" ) { var values = typeof service.value !== "string" ? [] : service.value.split(";"); return values.map(function (value) { var channel; var language; // default language to value language = value; if (/^CC\d=/.test(value)) { var _value$split = value.split("="); channel = _value$split[0]; language = _value$split[1]; } else if (/^CC\d$/.test(value)) { channel = value; } return { channel: channel, language: language, }; }); } else if ( service.schemeIdUri === "urn:scte:dash:cc:cea-708:2015" ) { var _values = typeof service.value !== "string" ? [] : service.value.split(";"); return _values.map(function (value) { var flags = { // service or channel number 1-63 channel: undefined, // language is a 3ALPHA per ISO 639.2/B // field is required language: undefined, // BIT 1/0 or ? // default value is 1, meaning 16:9 aspect ratio, 0 is 4:3, ? is unknown aspectRatio: 1, // BIT 1/0 // easy reader flag indicated the text is tailed to the needs of beginning readers // default 0, or off easyReader: 0, // BIT 1/0 // If 3d metadata is present (CEA-708.1) then 1 // default 0 "3D": 0, }; if (/=/.test(value)) { var _value$split2 = value.split("="), channel = _value$split2[0], _value$split2$ = _value$split2[1], opts = _value$split2$ === void 0 ? "" : _value$split2$; flags.channel = channel; flags.language = value; opts.split(",").forEach(function (opt) { var _opt$split = opt.split(":"), name = _opt$split[0], val = _opt$split[1]; if (name === "lang") { flags.language = val; // er for easyReadery } else if (name === "er") { flags.easyReader = Number(val); // war for wide aspect ratio } else if (name === "war") { flags.aspectRatio = Number(val); } else if (name === "3D") { flags["3D"] = Number(val); } }); } else { flags.language = value; } if (flags.channel) { flags.channel = "SERVICE" + flags.channel; } return flags; }); } }; /** * Maps an AdaptationSet node to a list of Representation information objects * * @name toRepresentationsCallback * @function * @param {Node} adaptationSet * AdaptationSet node from the mpd * @return {RepresentationInformation[]} * List of objects containing Representaion information */ /** * Returns a callback for Array.prototype.map for mapping AdaptationSet nodes to a list of * Representation information objects * * @param {Object} periodAttributes * Contains attributes inherited by the Period * @param {string[]} periodBaseUrls * Contains list of resolved base urls inherited by the Period * @param {string[]} periodSegmentInfo * Contains Segment Information at the period level * @return {toRepresentationsCallback} * Callback map function */ var toRepresentations = function toRepresentations( periodAttributes, periodBaseUrls, periodSegmentInfo ) { return function (adaptationSet) { var adaptationSetAttributes = parseAttributes(adaptationSet); var adaptationSetBaseUrls = buildBaseUrls( periodBaseUrls, findChildren(adaptationSet, "BaseURL") ); var role = findChildren(adaptationSet, "Role")[0]; var roleAttributes = { role: parseAttributes(role), }; var attrs = merge( periodAttributes, adaptationSetAttributes, roleAttributes ); var accessibility = findChildren( adaptationSet, "Accessibility" )[0]; var captionServices = parseCaptionServiceMetadata( parseAttributes(accessibility) ); if (captionServices) { attrs = merge(attrs, { captionServices: captionServices, }); } var label = findChildren(adaptationSet, "Label")[0]; if (label && label.childNodes.length) { var labelVal = label.childNodes[0].nodeValue.trim(); attrs = merge(attrs, { label: labelVal, }); } var contentProtection = generateKeySystemInformation( findChildren(adaptationSet, "ContentProtection") ); if (Object.keys(contentProtection).length) { attrs = merge(attrs, { contentProtection: contentProtection, }); } var segmentInfo = getSegmentInformation(adaptationSet); var representations = findChildren( adaptationSet, "Representation" ); var adaptationSetSegmentInfo = merge( periodSegmentInfo, segmentInfo ); return flatten( representations.map( inheritBaseUrls( attrs, adaptationSetBaseUrls, adaptationSetSegmentInfo ) ) ); }; }; /** * Contains all period information for mapping nodes onto adaptation sets. * * @typedef {Object} PeriodInformation * @property {Node} period.node * Period node from the mpd * @property {Object} period.attributes * Parsed period attributes from node plus any added */ /** * Maps a PeriodInformation object to a list of Representation information objects for all * AdaptationSet nodes contained within the Period. * * @name toAdaptationSetsCallback * @function * @param {PeriodInformation} period * Period object containing necessary period information * @param {number} periodIndex * Index of the Period within the mpd * @return {RepresentationInformation[]} * List of objects containing Representaion information */ /** * Returns a callback for Array.prototype.map for mapping Period nodes to a list of * Representation information objects * * @param {Object} mpdAttributes * Contains attributes inherited by the mpd * @param {string[]} mpdBaseUrls * Contains list of resolved base urls inherited by the mpd * @return {toAdaptationSetsCallback} * Callback map function */ var toAdaptationSets = function toAdaptationSets( mpdAttributes, mpdBaseUrls ) { return function (period, index) { var periodBaseUrls = buildBaseUrls( mpdBaseUrls, findChildren(period.node, "BaseURL") ); var parsedPeriodId = parseInt(period.attributes.id, 10); // fallback to mapping index if Period@id is not a number var periodIndex = global_window__WEBPACK_IMPORTED_MODULE_1___default().isNaN( parsedPeriodId ) ? index : parsedPeriodId; var periodAttributes = merge(mpdAttributes, { periodIndex: periodIndex, periodStart: period.attributes.start, }); if (typeof period.attributes.duration === "number") { periodAttributes.periodDuration = period.attributes.duration; } var adaptationSets = findChildren( period.node, "AdaptationSet" ); var periodSegmentInfo = getSegmentInformation(period.node); return flatten( adaptationSets.map( toRepresentations( periodAttributes, periodBaseUrls, periodSegmentInfo ) ) ); }; }; /** * Gets Period@start property for a given period. * * @param {Object} options * Options object * @param {Object} options.attributes * Period attributes * @param {Object} [options.priorPeriodAttributes] * Prior period attributes (if prior period is available) * @param {string} options.mpdType * The MPD@type these periods came from * @return {number|null} * The period start, or null if it's an early available period or error */ var getPeriodStart = function getPeriodStart(_ref) { var attributes = _ref.attributes, priorPeriodAttributes = _ref.priorPeriodAttributes, mpdType = _ref.mpdType; // Summary of period start time calculation from DASH spec section 5.3.2.1 // // A period's start is the first period's start + time elapsed after playing all // prior periods to this one. Periods continue one after the other in time (without // gaps) until the end of the presentation. // // The value of Period@start should be: // 1. if Period@start is present: value of Period@start // 2. if previous period exists and it has @duration: previous Period@start + // previous Period@duration // 3. if this is first period and MPD@type is 'static': 0 // 4. in all other cases, consider the period an "early available period" (note: not // currently supported) // (1) if (typeof attributes.start === "number") { return attributes.start; } // (2) if ( priorPeriodAttributes && typeof priorPeriodAttributes.start === "number" && typeof priorPeriodAttributes.duration === "number" ) { return ( priorPeriodAttributes.start + priorPeriodAttributes.duration ); } // (3) if (!priorPeriodAttributes && mpdType === "static") { return 0; } // (4) // There is currently no logic for calculating the Period@start value if there is // no Period@start or prior Period@start and Period@duration available. This is not made // explicit by the DASH interop guidelines or the DASH spec, however, since there's // nothing about any other resolution strategies, it's implied. Thus, this case should // be considered an early available period, or error, and null should suffice for both // of those cases. return null; }; /** * Traverses the mpd xml tree to generate a list of Representation information objects * that have inherited attributes from parent nodes * * @param {Node} mpd * The root node of the mpd * @param {Object} options * Available options for inheritAttributes * @param {string} options.manifestUri * The uri source of the mpd * @param {number} options.NOW * Current time per DASH IOP. Default is current time in ms since epoch * @param {number} options.clientOffset * Client time difference from NOW (in milliseconds) * @return {RepresentationInformation[]} * List of objects containing Representation information */ var inheritAttributes = function inheritAttributes(mpd, options) { if (options === void 0) { options = {}; } var _options = options, _options$manifestUri = _options.manifestUri, manifestUri = _options$manifestUri === void 0 ? "" : _options$manifestUri, _options$NOW = _options.NOW, NOW = _options$NOW === void 0 ? Date.now() : _options$NOW, _options$clientOffset = _options.clientOffset, clientOffset = _options$clientOffset === void 0 ? 0 : _options$clientOffset; var periodNodes = findChildren(mpd, "Period"); if (!periodNodes.length) { throw new Error(errors.INVALID_NUMBER_OF_PERIOD); } var locations = findChildren(mpd, "Location"); var mpdAttributes = parseAttributes(mpd); var mpdBaseUrls = buildBaseUrls( [manifestUri], findChildren(mpd, "BaseURL") ); // See DASH spec section 5.3.1.2, Semantics of MPD element. Default type to 'static'. mpdAttributes.type = mpdAttributes.type || "static"; mpdAttributes.sourceDuration = mpdAttributes.mediaPresentationDuration || 0; mpdAttributes.NOW = NOW; mpdAttributes.clientOffset = clientOffset; if (locations.length) { mpdAttributes.locations = locations.map(getContent); } var periods = []; // Since toAdaptationSets acts on individual periods right now, the simplest approach to // adding properties that require looking at prior periods is to parse attributes and add // missing ones before toAdaptationSets is called. If more such properties are added, it // may be better to refactor toAdaptationSets. periodNodes.forEach(function (node, index) { var attributes = parseAttributes(node); // Use the last modified prior period, as it may contain added information necessary // for this period. var priorPeriod = periods[index - 1]; attributes.start = getPeriodStart({ attributes: attributes, priorPeriodAttributes: priorPeriod ? priorPeriod.attributes : null, mpdType: mpdAttributes.type, }); periods.push({ node: node, attributes: attributes, }); }); return { locations: mpdAttributes.locations, representationInfo: flatten( periods.map( toAdaptationSets(mpdAttributes, mpdBaseUrls) ) ), }; }; var stringToMpdXml = function stringToMpdXml(manifestString) { if (manifestString === "") { throw new Error(errors.DASH_EMPTY_MANIFEST); } var parser = new _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__.DOMParser(); var xml; var mpd; try { xml = parser.parseFromString( manifestString, "application/xml" ); mpd = xml && xml.documentElement.tagName === "MPD" ? xml.documentElement : null; } catch (e) { // ie 11 throwsw on invalid xml } if ( !mpd || (mpd && mpd.getElementsByTagName("parsererror").length > 0) ) { throw new Error(errors.DASH_INVALID_XML); } return mpd; }; /** * Parses the manifest for a UTCTiming node, returning the nodes attributes if found * * @param {string} mpd * XML string of the MPD manifest * @return {Object|null} * Attributes of UTCTiming node specified in the manifest. Null if none found */ var parseUTCTimingScheme = function parseUTCTimingScheme(mpd) { var UTCTimingNode = findChildren(mpd, "UTCTiming")[0]; if (!UTCTimingNode) { return null; } var attributes = parseAttributes(UTCTimingNode); switch (attributes.schemeIdUri) { case "urn:mpeg:dash:utc:http-head:2014": case "urn:mpeg:dash:utc:http-head:2012": attributes.method = "HEAD"; break; case "urn:mpeg:dash:utc:http-xsdate:2014": case "urn:mpeg:dash:utc:http-iso:2014": case "urn:mpeg:dash:utc:http-xsdate:2012": case "urn:mpeg:dash:utc:http-iso:2012": attributes.method = "GET"; break; case "urn:mpeg:dash:utc:direct:2014": case "urn:mpeg:dash:utc:direct:2012": attributes.method = "DIRECT"; attributes.value = Date.parse(attributes.value); break; case "urn:mpeg:dash:utc:http-ntp:2014": case "urn:mpeg:dash:utc:ntp:2014": case "urn:mpeg:dash:utc:sntp:2014": default: throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME); } return attributes; }; var VERSION = /* unused pure expression or super */ null && version; var parse = function parse(manifestString, options) { if (options === void 0) { options = {}; } var parsedManifestInfo = inheritAttributes( stringToMpdXml(manifestString), options ); var playlists = toPlaylists( parsedManifestInfo.representationInfo ); return toM3u8( playlists, parsedManifestInfo.locations, options.sidxMapping ); }; /** * Parses the manifest for a UTCTiming node, returning the nodes attributes if found * * @param {string} manifestString * XML string of the MPD manifest * @return {Object|null} * Attributes of UTCTiming node specified in the manifest. Null if none found */ var parseUTCTiming = function parseUTCTiming(manifestString) { return parseUTCTimingScheme(stringToMpdXml(manifestString)); }; /***/ }, /***/ 4221: /***/ function (module) { var MAX_UINT32 = Math.pow(2, 32); var parseSidx = function (data) { var view = new DataView( data.buffer, data.byteOffset, data.byteLength ), result = { version: data[0], flags: new Uint8Array(data.subarray(1, 4)), references: [], referenceId: view.getUint32(4), timescale: view.getUint32(8), }, i = 12; if (result.version === 0) { result.earliestPresentationTime = view.getUint32(i); result.firstOffset = view.getUint32(i + 4); i += 8; } else { // read 64 bits result.earliestPresentationTime = view.getUint32(i) * MAX_UINT32 + view.getUint32(i + 4); result.firstOffset = view.getUint32(i + 8) * MAX_UINT32 + view.getUint32(i + 12); i += 16; } i += 2; // reserved var referenceCount = view.getUint16(i); i += 2; // start of references for (; referenceCount > 0; i += 12, referenceCount--) { result.references.push({ referenceType: (data[i] & 0x80) >>> 7, referencedSize: view.getUint32(i) & 0x7fffffff, subsegmentDuration: view.getUint32(i + 4), startsWithSap: !!(data[i + 8] & 0x80), sapType: (data[i + 8] & 0x70) >>> 4, sapDeltaTime: view.getUint32(i + 8) & 0x0fffffff, }); } return result; }; module.exports = parseSidx; /***/ }, /***/ 1489: /***/ function (module) { /** * mux.js * * Copyright (c) Brightcove * Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE */ var ONE_SECOND_IN_TS = 90000, // 90kHz clock secondsToVideoTs, secondsToAudioTs, videoTsToSeconds, audioTsToSeconds, audioTsToVideoTs, videoTsToAudioTs, metadataTsToSeconds; secondsToVideoTs = function (seconds) { return seconds * ONE_SECOND_IN_TS; }; secondsToAudioTs = function (seconds, sampleRate) { return seconds * sampleRate; }; videoTsToSeconds = function (timestamp) { return timestamp / ONE_SECOND_IN_TS; }; audioTsToSeconds = function (timestamp, sampleRate) { return timestamp / sampleRate; }; audioTsToVideoTs = function (timestamp, sampleRate) { return secondsToVideoTs( audioTsToSeconds(timestamp, sampleRate) ); }; videoTsToAudioTs = function (timestamp, sampleRate) { return secondsToAudioTs( videoTsToSeconds(timestamp), sampleRate ); }; /** * Adjust ID3 tag or caption timing information by the timeline pts values * (if keepOriginalTimestamps is false) and convert to seconds */ metadataTsToSeconds = function ( timestamp, timelineStartPts, keepOriginalTimestamps ) { return videoTsToSeconds( keepOriginalTimestamps ? timestamp : timestamp - timelineStartPts ); }; module.exports = { ONE_SECOND_IN_TS: ONE_SECOND_IN_TS, secondsToVideoTs: secondsToVideoTs, secondsToAudioTs: secondsToAudioTs, videoTsToSeconds: videoTsToSeconds, audioTsToSeconds: audioTsToSeconds, audioTsToVideoTs: audioTsToVideoTs, videoTsToAudioTs: videoTsToAudioTs, metadataTsToSeconds: metadataTsToSeconds, }; /***/ }, /***/ 8581: /***/ function ( __unused_webpack_module, __unused_webpack_exports, __webpack_require__ ) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/", function () { return __webpack_require__(4816); }, ]); if (false) { } /***/ }, /***/ 4816: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function () { return /* binding */ Home; }, }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // EXTERNAL MODULE: ./styles/Home.module.css var Home_module = __webpack_require__(214); var Home_module_default = /*#__PURE__*/ __webpack_require__.n(Home_module); // EXTERNAL MODULE: ./node_modules/video.js/dist/video.es.js var video_es = __webpack_require__(5215); // EXTERNAL MODULE: ./node_modules/video.js/dist/video-js.css var video_js = __webpack_require__(3512); // CONCATENATED MODULE: ./components/VideoJS.js var VideoJS = function (props) { var videoRef = react.useRef(null); var playerRef = react.useRef(null); var options = props.options, onReady = props.onReady; react.useEffect( function () { // make sure Video.js player is only initialized once if (!playerRef.current) { var videoElement = videoRef.current; if (!videoElement) return; var player = (playerRef.current = (0, video_es /* default */.Z)( videoElement, options, function () { console.log("player is ready"); onReady && onReady(player); } )); } else { // you can update player here [update player through props] // const player = playerRef.current; // player.autoplay(options.autoplay); // player.src(options.sources); } }, [onReady, options, videoRef] ); // Dispose the Video.js player when the functional component unmounts react.useEffect( function () { return function () { var player = playerRef.current; if (player) { player.dispose(); playerRef.current = null; } }; }, [playerRef] ); return /*#__PURE__*/ (0, jsx_runtime.jsx)("div", { "data-vjs-player": true, children: /*#__PURE__*/ (0, jsx_runtime.jsx)("video", { ref: videoRef, className: "video-js vjs-big-play-centered", }), }); }; /* harmony default export */ var components_VideoJS = VideoJS; // CONCATENATED MODULE: ./pages/index.js function Home() { var playerRef = (0, react.useRef)(null); var videoJsOptions = { autoplay: true, controls: true, responsive: true, fluid: true, sources: [ { src: "https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8", type: "application/x-mpegurl", }, ], }; var handlePlayerReady = function (player) { playerRef.current = player; // you can handle player events here player.on("waiting", function () { console.log("player is waiting"); }); player.on("dispose", function () { console.log("player will dispose"); }); }; return /*#__PURE__*/ (0, jsx_runtime.jsx)("div", { className: Home_module_default().container, children: /*#__PURE__*/ (0, jsx_runtime.jsx)("main", { className: Home_module_default().main, children: /*#__PURE__*/ (0, jsx_runtime.jsx)( components_VideoJS, { options: videoJsOptions, onReady: handlePlayerReady, } ), }), }); } /***/ }, /***/ 214: /***/ function (module) { // extracted by mini-css-extract-plugin module.exports = { container: "Home_container__bCOhY", main: "Home_main__nLjiQ", footer: "Home_footer____T7K", title: "Home_title__T09hD", description: "Home_description__41Owk", code: "Home_code__suPER", grid: "Home_grid__GxQ85", card: "Home_card___LpL1", logo: "Home_logo__27_tb", }; /***/ }, /***/ 3512: /***/ function () { // extracted by mini-css-extract-plugin /***/ }, /***/ 5974: /***/ function (module) { module.exports = SafeParseTuple; function SafeParseTuple(obj, reviver) { var json; var error = null; try { json = JSON.parse(obj, reviver); } catch (err) { error = err; } return [error, json]; } /***/ }, /***/ 9945: /***/ function (module) { // see https://tools.ietf.org/html/rfc1808 (function (root) { var URL_REGEX = /^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/; var FIRST_SEGMENT_REGEX = /^([^\/?#]*)([^]*)$/; var SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g; var SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g; var URLToolkit = { // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or // // E.g // With opts.alwaysNormalize = false (default, spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g // With opts.alwaysNormalize = true (not spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/g buildAbsoluteURL: function (baseURL, relativeURL, opts) { opts = opts || {}; // remove any remaining space and CRLF baseURL = baseURL.trim(); relativeURL = relativeURL.trim(); if (!relativeURL) { // 2a) If the embedded URL is entirely empty, it inherits the // entire base URL (i.e., is set equal to the base URL) // and we are done. if (!opts.alwaysNormalize) { return baseURL; } var basePartsForNormalise = URLToolkit.parseURL(baseURL); if (!basePartsForNormalise) { throw new Error( "Error trying to parse base URL." ); } basePartsForNormalise.path = URLToolkit.normalizePath( basePartsForNormalise.path ); return URLToolkit.buildURLFromParts( basePartsForNormalise ); } var relativeParts = URLToolkit.parseURL(relativeURL); if (!relativeParts) { throw new Error( "Error trying to parse relative URL." ); } if (relativeParts.scheme) { // 2b) If the embedded URL starts with a scheme name, it is // interpreted as an absolute URL and we are done. if (!opts.alwaysNormalize) { return relativeURL; } relativeParts.path = URLToolkit.normalizePath( relativeParts.path ); return URLToolkit.buildURLFromParts(relativeParts); } var baseParts = URLToolkit.parseURL(baseURL); if (!baseParts) { throw new Error("Error trying to parse base URL."); } if ( !baseParts.netLoc && baseParts.path && baseParts.path[0] !== "/" ) { // If netLoc missing and path doesn't start with '/', assume everthing before the first '/' is the netLoc // This causes 'example.com/a' to be handled as '//example.com/a' instead of '/example.com/a' var pathParts = FIRST_SEGMENT_REGEX.exec( baseParts.path ); baseParts.netLoc = pathParts[1]; baseParts.path = pathParts[2]; } if (baseParts.netLoc && !baseParts.path) { baseParts.path = "/"; } var builtParts = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: baseParts.scheme, netLoc: relativeParts.netLoc, path: null, params: relativeParts.params, query: relativeParts.query, fragment: relativeParts.fragment, }; if (!relativeParts.netLoc) { // 3) If the embedded URL's <net_loc> is non-empty, we skip to // Step 7. Otherwise, the embedded URL inherits the <net_loc> // (if any) of the base URL. builtParts.netLoc = baseParts.netLoc; // 4) If the embedded URL path is preceded by a slash "/", the // path is not relative and we skip to Step 7. if (relativeParts.path[0] !== "/") { if (!relativeParts.path) { // 5) If the embedded URL path is empty (and not preceded by a // slash), then the embedded URL inherits the base URL path builtParts.path = baseParts.path; // 5a) if the embedded URL's <params> is non-empty, we skip to // step 7; otherwise, it inherits the <params> of the base // URL (if any) and if (!relativeParts.params) { builtParts.params = baseParts.params; // 5b) if the embedded URL's <query> is non-empty, we skip to // step 7; otherwise, it inherits the <query> of the base // URL (if any) and we skip to step 7. if (!relativeParts.query) { builtParts.query = baseParts.query; } } } else { // 6) The last segment of the base URL's path (anything // following the rightmost slash "/", or the entire path if no // slash is present) is removed and the embedded URL's path is // appended in its place. var baseURLPath = baseParts.path; var newPath = baseURLPath.substring( 0, baseURLPath.lastIndexOf("/") + 1 ) + relativeParts.path; builtParts.path = URLToolkit.normalizePath(newPath); } } } if (builtParts.path === null) { builtParts.path = opts.alwaysNormalize ? URLToolkit.normalizePath(relativeParts.path) : relativeParts.path; } return URLToolkit.buildURLFromParts(builtParts); }, parseURL: function (url) { var parts = URL_REGEX.exec(url); if (!parts) { return null; } return { scheme: parts[1] || "", netLoc: parts[2] || "", path: parts[3] || "", params: parts[4] || "", query: parts[5] || "", fragment: parts[6] || "", }; }, normalizePath: function (path) { // The following operations are // then applied, in order, to the new path: // 6a) All occurrences of "./", where "." is a complete path // segment, are removed. // 6b) If the path ends with "." as a complete path segment, // that "." is removed. path = path .split("") .reverse() .join("") .replace(SLASH_DOT_REGEX, ""); // 6c) All occurrences of "<segment>/../", where <segment> is a // complete path segment not equal to "..", are removed. // Removal of these path segments is performed iteratively, // removing the leftmost matching pattern on each iteration, // until no matching pattern remains. // 6d) If the path ends with "<segment>/..", where <segment> is a // complete path segment not equal to "..", that // "<segment>/.." is removed. while ( path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, "")) .length ) {} return path.split("").reverse().join(""); }, buildURLFromParts: function (parts) { return ( parts.scheme + parts.netLoc + parts.path + parts.params + parts.query + parts.fragment ); }, }; if (true) module.exports = URLToolkit; else { } })(this); /***/ }, /***/ 3407: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Default exports for Node. Export the extended versions of VTTCue and // VTTRegion in Node since we likely want the capability to convert back and // forth between JSON. If we don't then it's not that big of a deal since we're // off browser. var window = __webpack_require__(8908); var vttjs = (module.exports = { WebVTT: __webpack_require__(3706), VTTCue: __webpack_require__(2230), VTTRegion: __webpack_require__(3710), }); window.vttjs = vttjs; window.WebVTT = vttjs.WebVTT; var cueShim = vttjs.VTTCue; var regionShim = vttjs.VTTRegion; var nativeVTTCue = window.VTTCue; var nativeVTTRegion = window.VTTRegion; vttjs.shim = function () { window.VTTCue = cueShim; window.VTTRegion = regionShim; }; vttjs.restore = function () { window.VTTCue = nativeVTTCue; window.VTTRegion = nativeVTTRegion; }; if (!window.VTTCue) { vttjs.shim(); } /***/ }, /***/ 3706: /***/ function ( module, __unused_webpack_exports, __webpack_require__ ) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ var document = __webpack_require__(9144); var _objCreate = Object.create || (function () { function F() {} return function (o) { if (arguments.length !== 1) { throw new Error( "Object.create shim only accepts one parameter." ); } F.prototype = o; return new F(); }; })(); // Creates a new ParserError object from an errorData object. The errorData // object should have default code and message properties. The default message // property can be overriden by passing in a message parameter. // See ParsingError.Errors below for acceptable errors. function ParsingError(errorData, message) { this.name = "ParsingError"; this.code = errorData.code; this.message = message || errorData.message; } ParsingError.prototype = _objCreate(Error.prototype); ParsingError.prototype.constructor = ParsingError; // ParsingError metadata for acceptable ParsingErrors. ParsingError.Errors = { BadSignature: { code: 0, message: "Malformed WebVTT signature.", }, BadTimeStamp: { code: 1, message: "Malformed time stamp.", }, }; // Try to parse input as a time stamp. function parseTimeStamp(input) { function computeSeconds(h, m, s, f) { return ( (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000 ); } var m = input.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/); if (!m) { return null; } if (m[3]) { // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds] return computeSeconds( m[1], m[2], m[3].replace(":", ""), m[4] ); } else if (m[1] > 59) { // Timestamp takes the form of [hours]:[minutes].[milliseconds] // First position is hours as it's over 59. return computeSeconds(m[1], m[2], 0, m[4]); } else { // Timestamp takes the form of [minutes]:[seconds].[milliseconds] return computeSeconds(0, m[1], m[2], m[4]); } } // A settings object holds key/value pairs and will ignore anything but the first // assignment to a specific key. function Settings() { this.values = _objCreate(null); } Settings.prototype = { // Only accept the first assignment to any key. set: function (k, v) { if (!this.get(k) && v !== "") { this.values[k] = v; } }, // Return the value for a key, or a default value. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with // a number of possible default values as properties where 'defaultKey' is // the key of the property that will be chosen; otherwise it's assumed to be // a single value. get: function (k, dflt, defaultKey) { if (defaultKey) { return this.has(k) ? this.values[k] : dflt[defaultKey]; } return this.has(k) ? this.values[k] : dflt; }, // Check whether we have a value for a key. has: function (k) { return k in this.values; }, // Accept a setting if its one of the given alternatives. alt: function (k, v, a) { for (var n = 0; n < a.length; ++n) { if (v === a[n]) { this.set(k, v); break; } } }, // Accept a setting if its a valid (signed) integer. integer: function (k, v) { if (/^-?\d+$/.test(v)) { // integer this.set(k, parseInt(v, 10)); } }, // Accept a setting if its a valid percentage. percent: function (k, v) { var m; if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) { v = parseFloat(v); if (v >= 0 && v <= 100) { this.set(k, v); return true; } } return false; }, }; // Helper function to parse input into groups separated by 'groupDelim', and // interprete each group as a key/value pair separated by 'keyValueDelim'. function parseOptions(input, callback, keyValueDelim, groupDelim) { var groups = groupDelim ? input.split(groupDelim) : [input]; for (var i in groups) { if (typeof groups[i] !== "string") { continue; } var kv = groups[i].split(keyValueDelim); if (kv.length !== 2) { continue; } var k = kv[0]; var v = kv[1]; callback(k, v); } } function parseCue(input, cue, regionList) { // Remember the original input if we need to throw an error. var oInput = input; // 4.1 WebVTT timestamp function consumeTimeStamp() { var ts = parseTimeStamp(input); if (ts === null) { throw new ParsingError( ParsingError.Errors.BadTimeStamp, "Malformed timestamp: " + oInput ); } // Remove time stamp from input. input = input.replace(/^[^\sa-zA-Z-]+/, ""); return ts; } // 4.4.2 WebVTT cue settings function consumeCueSettings(input, cue) { var settings = new Settings(); parseOptions( input, function (k, v) { switch (k) { case "region": // Find the last region we parsed with the same region id. for ( var i = regionList.length - 1; i >= 0; i-- ) { if (regionList[i].id === v) { settings.set( k, regionList[i].region ); break; } } break; case "vertical": settings.alt(k, v, ["rl", "lr"]); break; case "line": var vals = v.split(","), vals0 = vals[0]; settings.integer(k, vals0); settings.percent(k, vals0) ? settings.set("snapToLines", false) : null; settings.alt(k, vals0, ["auto"]); if (vals.length === 2) { settings.alt("lineAlign", vals[1], [ "start", "center", "end", ]); } break; case "position": vals = v.split(","); settings.percent(k, vals[0]); if (vals.length === 2) { settings.alt("positionAlign", vals[1], [ "start", "center", "end", ]); } break; case "size": settings.percent(k, v); break; case "align": settings.alt(k, v, [ "start", "center", "end", "left", "right", ]); break; } }, /:/, /\s/ ); // Apply default values for any missing fields. cue.region = settings.get("region", null); cue.vertical = settings.get("vertical", ""); try { cue.line = settings.get("line", "auto"); } catch (e) {} cue.lineAlign = settings.get("lineAlign", "start"); cue.snapToLines = settings.get("snapToLines", true); cue.size = settings.get("size", 100); // Safari still uses the old middle value and won't accept center try { cue.align = settings.get("align", "center"); } catch (e) { cue.align = settings.get("align", "middle"); } try { cue.position = settings.get("position", "auto"); } catch (e) { cue.position = settings.get( "position", { start: 0, left: 0, center: 50, middle: 50, end: 100, right: 100, }, cue.align ); } cue.positionAlign = settings.get( "positionAlign", { start: "start", left: "start", center: "center", middle: "center", end: "end", right: "end", }, cue.align ); } function skipWhitespace() { input = input.replace(/^\s+/, ""); } // 4.1 WebVTT cue timings. skipWhitespace(); cue.startTime = consumeTimeStamp(); // (1) collect cue start time skipWhitespace(); if (input.substr(0, 3) !== "-->") { // (3) next characters must match "-->" throw new ParsingError( ParsingError.Errors.BadTimeStamp, "Malformed time stamp (time stamps must be separated by '-->'): " + oInput ); } input = input.substr(3); skipWhitespace(); cue.endTime = consumeTimeStamp(); // (5) collect cue end time // 4.1 WebVTT cue settings list. skipWhitespace(); consumeCueSettings(input, cue); } // When evaluating this file as part of a Webpack bundle for server // side rendering, `document` is an empty object. var TEXTAREA_ELEMENT = document.createElement && document.createElement("textarea"); var TAG_NAME = { c: "span", i: "i", b: "b", u: "u", ruby: "ruby", rt: "rt", v: "span", lang: "span", }; // 5.1 default text color // 5.2 default text background color is equivalent to text color with bg_ prefix var DEFAULT_COLOR_CLASS = { white: "rgba(255,255,255,1)", lime: "rgba(0,255,0,1)", cyan: "rgba(0,255,255,1)", red: "rgba(255,0,0,1)", yellow: "rgba(255,255,0,1)", magenta: "rgba(255,0,255,1)", blue: "rgba(0,0,255,1)", black: "rgba(0,0,0,1)", }; var TAG_ANNOTATION = { v: "title", lang: "lang", }; var NEEDS_PARENT = { rt: "ruby", }; // Parse content into a document fragment. function parseContent(window, input) { function nextToken() { // Check for end-of-string. if (!input) { return null; } // Consume 'n' characters from the input. function consume(result) { input = input.substr(result.length); return result; } var m = input.match(/^([^<]*)(<[^>]*>?)?/); // If there is some text before the next tag, return it, otherwise return // the tag. return consume(m[1] ? m[1] : m[2]); } function unescape(s) { TEXTAREA_ELEMENT.innerHTML = s; s = TEXTAREA_ELEMENT.textContent; TEXTAREA_ELEMENT.textContent = ""; return s; } function shouldAdd(current, element) { return ( !NEEDS_PARENT[element.localName] || NEEDS_PARENT[element.localName] === current.localName ); } // Create an element for this tag. function createElement(type, annotation) { var tagName = TAG_NAME[type]; if (!tagName) { return null; } var element = window.document.createElement(tagName); var name = TAG_ANNOTATION[type]; if (name && annotation) { element[name] = annotation.trim(); } return element; } var rootDiv = window.document.createElement("div"), current = rootDiv, t, tagStack = []; while ((t = nextToken()) !== null) { if (t[0] === "<") { if (t[1] === "/") { // If the closing tag matches, move back up to the parent node. if ( tagStack.length && tagStack[tagStack.length - 1] === t.substr(2).replace(">", "") ) { tagStack.pop(); current = current.parentNode; } // Otherwise just ignore the end tag. continue; } var ts = parseTimeStamp(t.substr(1, t.length - 2)); var node; if (ts) { // Timestamps are lead nodes as well. node = window.document.createProcessingInstruction( "timestamp", ts ); current.appendChild(node); continue; } var m = t.match( /^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/ ); // If we can't parse the tag, skip to the next tag. if (!m) { continue; } // Try to construct an element, and ignore the tag if we couldn't. node = createElement(m[1], m[3]); if (!node) { continue; } // Determine if the tag should be added based on the context of where it // is placed in the cuetext. if (!shouldAdd(current, node)) { continue; } // Set the class list (as a list of classes, separated by space). if (m[2]) { var classes = m[2].split("."); classes.forEach(function (cl) { var bgColor = /^bg_/.test(cl); // slice out `bg_` if it's a background color var colorName = bgColor ? cl.slice(3) : cl; if ( DEFAULT_COLOR_CLASS.hasOwnProperty( colorName ) ) { var propName = bgColor ? "background-color" : "color"; var propValue = DEFAULT_COLOR_CLASS[colorName]; node.style[propName] = propValue; } }); node.className = classes.join(" "); } // Append the node to the current node, and enter the scope of the new // node. tagStack.push(m[1]); current.appendChild(node); current = node; continue; } // Text nodes are leaf nodes. current.appendChild( window.document.createTextNode(unescape(t)) ); } return rootDiv; } // This is a list of all the Unicode characters that have a strong // right-to-left category. What this means is that these characters are // written right-to-left for sure. It was generated by pulling all the strong // right-to-left characters out of the Unicode data table. That table can // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt var strongRTLRanges = [ [0x5be, 0x5be], [0x5c0, 0x5c0], [0x5c3, 0x5c3], [0x5c6, 0x5c6], [0x5d0, 0x5ea], [0x5f0, 0x5f4], [0x608, 0x608], [0x60b, 0x60b], [0x60d, 0x60d], [0x61b, 0x61b], [0x61e, 0x64a], [0x66d, 0x66f], [0x671, 0x6d5], [0x6e5, 0x6e6], [0x6ee, 0x6ef], [0x6fa, 0x70d], [0x70f, 0x710], [0x712, 0x72f], [0x74d, 0x7a5], [0x7b1, 0x7b1], [0x7c0, 0x7ea], [0x7f4, 0x7f5], [0x7fa, 0x7fa], [0x800, 0x815], [0x81a, 0x81a], [0x824, 0x824], [0x828, 0x828], [0x830, 0x83e], [0x840, 0x858], [0x85e, 0x85e], [0x8a0, 0x8a0], [0x8a2, 0x8ac], [0x200f, 0x200f], [0xfb1d, 0xfb1d], [0xfb1f, 0xfb28], [0xfb2a, 0xfb36], [0xfb38, 0xfb3c], [0xfb3e, 0xfb3e], [0xfb40, 0xfb41], [0xfb43, 0xfb44], [0xfb46, 0xfbc1], [0xfbd3, 0xfd3d], [0xfd50, 0xfd8f], [0xfd92, 0xfdc7], [0xfdf0, 0xfdfc], [0xfe70, 0xfe74], [0xfe76, 0xfefc], [0x10800, 0x10805], [0x10808, 0x10808], [0x1080a, 0x10835], [0x10837, 0x10838], [0x1083c, 0x1083c], [0x1083f, 0x10855], [0x10857, 0x1085f], [0x10900, 0x1091b], [0x10920, 0x10939], [0x1093f, 0x1093f], [0x10980, 0x109b7], [0x109be, 0x109bf], [0x10a00, 0x10a00], [0x10a10, 0x10a13], [0x10a15, 0x10a17], [0x10a19, 0x10a33], [0x10a40, 0x10a47], [0x10a50, 0x10a58], [0x10a60, 0x10a7f], [0x10b00, 0x10b35], [0x10b40, 0x10b55], [0x10b58, 0x10b72], [0x10b78, 0x10b7f], [0x10c00, 0x10c48], [0x1ee00, 0x1ee03], [0x1ee05, 0x1ee1f], [0x1ee21, 0x1ee22], [0x1ee24, 0x1ee24], [0x1ee27, 0x1ee27], [0x1ee29, 0x1ee32], [0x1ee34, 0x1ee37], [0x1ee39, 0x1ee39], [0x1ee3b, 0x1ee3b], [0x1ee42, 0x1ee42], [0x1ee47, 0x1ee47], [0x1ee49, 0x1ee49], [0x1ee4b, 0x1ee4b], [0x1ee4d, 0x1ee4f], [0x1ee51, 0x1ee52], [0x1ee54, 0x1ee54], [0x1ee57, 0x1ee57], [0x1ee59, 0x1ee59], [0x1ee5b, 0x1ee5b], [0x1ee5d, 0x1ee5d], [0x1ee5f, 0x1ee5f], [0x1ee61, 0x1ee62], [0x1ee64, 0x1ee64], [0x1ee67, 0x1ee6a], [0x1ee6c, 0x1ee72], [0x1ee74, 0x1ee77], [0x1ee79, 0x1ee7c], [0x1ee7e, 0x1ee7e], [0x1ee80, 0x1ee89], [0x1ee8b, 0x1ee9b], [0x1eea1, 0x1eea3], [0x1eea5, 0x1eea9], [0x1eeab, 0x1eebb], [0x10fffd, 0x10fffd], ]; function isStrongRTLChar(charCode) { for (var i = 0; i < strongRTLRanges.length; i++) { var currentRange = strongRTLRanges[i]; if ( charCode >= currentRange[0] && charCode <= currentRange[1] ) { return true; } } return false; } function determineBidi(cueDiv) { var nodeStack = [], text = "", charCode; if (!cueDiv || !cueDiv.childNodes) { return "ltr"; } function pushNodes(nodeStack, node) { for (var i = node.childNodes.length - 1; i >= 0; i--) { nodeStack.push(node.childNodes[i]); } } function nextTextNode(nodeStack) { if (!nodeStack || !nodeStack.length) { return null; } var node = nodeStack.pop(), text = node.textContent || node.innerText; if (text) { // TODO: This should match all unicode type B characters (paragraph // separator characters). See issue #115. var m = text.match(/^.*(\n|\r)/); if (m) { nodeStack.length = 0; return m[0]; } return text; } if (node.tagName === "ruby") { return nextTextNode(nodeStack); } if (node.childNodes) { pushNodes(nodeStack, node); return nextTextNode(nodeStack); } } pushNodes(nodeStack, cueDiv); while ((text = nextTextNode(nodeStack))) { for (var i = 0; i < text.length; i++) { charCode = text.charCodeAt(i); if (isStrongRTLChar(charCode)) { return "rtl"; } } } return "ltr"; } function computeLinePos(cue) { if ( typeof cue.line === "number" && (cue.snapToLines || (cue.line >= 0 && cue.line <= 100)) ) { return cue.line; } if ( !cue.track || !cue.track.textTrackList || !cue.track.textTrackList.mediaElement ) { return -1; } var track = cue.track, trackList = track.textTrackList, count = 0; for ( var i = 0; i < trackList.length && trackList[i] !== track; i++ ) { if (trackList[i].mode === "showing") { count++; } } return ++count * -1; } function StyleBox() {} // Apply styles to a div. If there is no div passed then it defaults to the // div on 'this'. StyleBox.prototype.applyStyles = function (styles, div) { div = div || this.div; for (var prop in styles) { if (styles.hasOwnProperty(prop)) { div.style[prop] = styles[prop]; } } }; StyleBox.prototype.formatStyle = function (val, unit) { return val === 0 ? 0 : val + unit; }; // Constructs the computed display state of the cue (a div). Places the div // into the overlay which should be a block level element (usually a div). function CueStyleBox(window, cue, styleOptions) { StyleBox.call(this); this.cue = cue; // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will // have inline positioning and will function as the cue background box. this.cueDiv = parseContent(window, cue.text); var styles = { color: "rgba(255, 255, 255, 1)", backgroundColor: "rgba(0, 0, 0, 0.8)", position: "relative", left: 0, right: 0, top: 0, bottom: 0, display: "inline", writingMode: cue.vertical === "" ? "horizontal-tb" : cue.vertical === "lr" ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext", }; this.applyStyles(styles, this.cueDiv); // Create an absolutely positioned div that will be used to position the cue // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS // mirrors of them except middle instead of center on Safari. this.div = window.document.createElement("div"); styles = { direction: determineBidi(this.cueDiv), writingMode: cue.vertical === "" ? "horizontal-tb" : cue.vertical === "lr" ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext", textAlign: cue.align === "middle" ? "center" : cue.align, font: styleOptions.font, whiteSpace: "pre-line", position: "absolute", }; this.applyStyles(styles); this.div.appendChild(this.cueDiv); // Calculate the distance from the reference edge of the viewport to the text // position of the cue box. The reference edge will be resolved later when // the box orientation styles are applied. var textPos = 0; switch (cue.positionAlign) { case "start": textPos = cue.position; break; case "center": textPos = cue.position - cue.size / 2; break; case "end": textPos = cue.position - cue.size; break; } // Horizontal box orientation; textPos is the distance from the left edge of the // area to the left edge of the box and cue.size is the distance extending to // the right from there. if (cue.vertical === "") { this.applyStyles({ left: this.formatStyle(textPos, "%"), width: this.formatStyle(cue.size, "%"), }); // Vertical box orientation; textPos is the distance from the top edge of the // area to the top edge of the box and cue.size is the height extending // downwards from there. } else { this.applyStyles({ top: this.formatStyle(textPos, "%"), height: this.formatStyle(cue.size, "%"), }); } this.move = function (box) { this.applyStyles({ top: this.formatStyle(box.top, "px"), bottom: this.formatStyle(box.bottom, "px"), left: this.formatStyle(box.left, "px"), right: this.formatStyle(box.right, "px"), height: this.formatStyle(box.height, "px"), width: this.formatStyle(box.width, "px"), }); }; } CueStyleBox.prototype = _objCreate(StyleBox.prototype); CueStyleBox.prototype.constructor = CueStyleBox; // Represents the co-ordinates of an Element in a way that we can easily // compute things with such as if it overlaps or intersects with another Element. // Can initialize it with either a StyleBox or another BoxPosition. function BoxPosition(obj) { // Either a BoxPosition was passed in and we need to copy it, or a StyleBox // was passed in and we need to copy the results of 'getBoundingClientRect' // as the object returned is readonly. All co-ordinate values are in reference // to the viewport origin (top left). var lh, height, width, top; if (obj.div) { height = obj.div.offsetHeight; width = obj.div.offsetWidth; top = obj.div.offsetTop; var rects = (rects = obj.div.childNodes) && (rects = rects[0]) && rects.getClientRects && rects.getClientRects(); obj = obj.div.getBoundingClientRect(); // In certain cases the outter div will be slightly larger then the sum of // the inner div's lines. This could be due to bold text, etc, on some platforms. // In this case we should get the average line height and use that. This will // result in the desired behaviour. lh = rects ? Math.max( (rects[0] && rects[0].height) || 0, obj.height / rects.length ) : 0; } this.left = obj.left; this.right = obj.right; this.top = obj.top || top; this.height = obj.height || height; this.bottom = obj.bottom || top + (obj.height || height); this.width = obj.width || width; this.lineHeight = lh !== undefined ? lh : obj.lineHeight; } // Move the box along a particular axis. Optionally pass in an amount to move // the box. If no amount is passed then the default is the line height of the // box. BoxPosition.prototype.move = function (axis, toMove) { toMove = toMove !== undefined ? toMove : this.lineHeight; switch (axis) { case "+x": this.left += toMove; this.right += toMove; break; case "-x": this.left -= toMove; this.right -= toMove; break; case "+y": this.top += toMove; this.bottom += toMove; break; case "-y": this.top -= toMove; this.bottom -= toMove; break; } }; // Check if this box overlaps another box, b2. BoxPosition.prototype.overlaps = function (b2) { return ( this.left < b2.right && this.right > b2.left && this.top < b2.bottom && this.bottom > b2.top ); }; // Check if this box overlaps any other boxes in boxes. BoxPosition.prototype.overlapsAny = function (boxes) { for (var i = 0; i < boxes.length; i++) { if (this.overlaps(boxes[i])) { return true; } } return false; }; // Check if this box is within another box. BoxPosition.prototype.within = function (container) { return ( this.top >= container.top && this.bottom <= container.bottom && this.left >= container.left && this.right <= container.right ); }; // Check if this box is entirely within the container or it is overlapping // on the edge opposite of the axis direction passed. For example, if "+x" is // passed and the box is overlapping on the left edge of the container, then // return true. BoxPosition.prototype.overlapsOppositeAxis = function ( container, axis ) { switch (axis) { case "+x": return this.left < container.left; case "-x": return this.right > container.right; case "+y": return this.top < container.top; case "-y": return this.bottom > container.bottom; } }; // Find the percentage of the area that this box is overlapping with another // box. BoxPosition.prototype.intersectPercentage = function (b2) { var x = Math.max( 0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left) ), y = Math.max( 0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top) ), intersectArea = x * y; return intersectArea / (this.height * this.width); }; // Convert the positions from this box to CSS compatible positions using // the reference container's positions. This has to be done because this // box's positions are in reference to the viewport origin, whereas, CSS // values are in referecne to their respective edges. BoxPosition.prototype.toCSSCompatValues = function (reference) { return { top: this.top - reference.top, bottom: reference.bottom - this.bottom, left: this.left - reference.left, right: reference.right - this.right, height: this.height, width: this.width, }; }; // Get an object that represents the box's position without anything extra. // Can pass a StyleBox, HTMLElement, or another BoxPositon. BoxPosition.getSimpleBoxPosition = function (obj) { var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0; var width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0; var top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0; obj = obj.div ? obj.div.getBoundingClientRect() : obj.tagName ? obj.getBoundingClientRect() : obj; var ret = { left: obj.left, right: obj.right, top: obj.top || top, height: obj.height || height, bottom: obj.bottom || top + (obj.height || height), width: obj.width || width, }; return ret; }; // Move a StyleBox to its specified, or next best, position. The containerBox // is the box that contains the StyleBox, such as a div. boxPositions are // a list of other boxes that the styleBox can't overlap with. function moveBoxToLinePosition( window, styleBox, containerBox, boxPositions ) { // Find the best position for a cue box, b, on the video. The axis parameter // is a list of axis, the order of which, it will move the box along. For example: // Passing ["+x", "-x"] will move the box first along the x axis in the positive // direction. If it doesn't find a good position for it there it will then move // it along the x axis in the negative direction. function findBestPosition(b, axis) { var bestPosition, specifiedPosition = new BoxPosition(b), percentage = 1; // Highest possible so the first thing we get is better. for (var i = 0; i < axis.length; i++) { while ( b.overlapsOppositeAxis(containerBox, axis[i]) || (b.within(containerBox) && b.overlapsAny(boxPositions)) ) { b.move(axis[i]); } // We found a spot where we aren't overlapping anything. This is our // best position. if (b.within(containerBox)) { return b; } var p = b.intersectPercentage(containerBox); // If we're outside the container box less then we were on our last try // then remember this position as the best position. if (percentage > p) { bestPosition = new BoxPosition(b); percentage = p; } // Reset the box position to the specified position. b = new BoxPosition(specifiedPosition); } return bestPosition || specifiedPosition; } var boxPosition = new BoxPosition(styleBox), cue = styleBox.cue, linePos = computeLinePos(cue), axis = []; // If we have a line number to align the cue to. if (cue.snapToLines) { var size; switch (cue.vertical) { case "": axis = ["+y", "-y"]; size = "height"; break; case "rl": axis = ["+x", "-x"]; size = "width"; break; case "lr": axis = ["-x", "+x"]; size = "width"; break; } var step = boxPosition.lineHeight, position = step * Math.round(linePos), maxPosition = containerBox[size] + step, initialAxis = axis[0]; // If the specified intial position is greater then the max position then // clamp the box to the amount of steps it would take for the box to // reach the max position. if (Math.abs(position) > maxPosition) { position = position < 0 ? -1 : 1; position *= Math.ceil(maxPosition / step) * step; } // If computed line position returns negative then line numbers are // relative to the bottom of the video instead of the top. Therefore, we // need to increase our initial position by the length or width of the // video, depending on the writing direction, and reverse our axis directions. if (linePos < 0) { position += cue.vertical === "" ? containerBox.height : containerBox.width; axis = axis.reverse(); } // Move the box to the specified position. This may not be its best // position. boxPosition.move(initialAxis, position); } else { // If we have a percentage line value for the cue. var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100; switch (cue.lineAlign) { case "center": linePos -= calculatedPercentage / 2; break; case "end": linePos -= calculatedPercentage; break; } // Apply initial line position to the cue box. switch (cue.vertical) { case "": styleBox.applyStyles({ top: styleBox.formatStyle(linePos, "%"), }); break; case "rl": styleBox.applyStyles({ left: styleBox.formatStyle(linePos, "%"), }); break; case "lr": styleBox.applyStyles({ right: styleBox.formatStyle(linePos, "%"), }); break; } axis = ["+y", "-x", "+x", "-y"]; // Get the box position again after we've applied the specified positioning // to it. boxPosition = new BoxPosition(styleBox); } var bestPosition = findBestPosition(boxPosition, axis); styleBox.move(bestPosition.toCSSCompatValues(containerBox)); } function WebVTT() { // Nothing } // Helper to allow strings to be decoded instead of the default binary utf8 data. WebVTT.StringDecoder = function () { return { decode: function (data) { if (!data) { return ""; } if (typeof data !== "string") { throw new Error("Error - expected string data."); } return decodeURIComponent(encodeURIComponent(data)); }, }; }; WebVTT.convertCueToDOMTree = function (window, cuetext) { if (!window || !cuetext) { return null; } return parseContent(window, cuetext); }; var FONT_SIZE_PERCENT = 0.05; var FONT_STYLE = "sans-serif"; var CUE_BACKGROUND_PADDING = "1.5%"; // Runs the processing model over the cues and regions passed to it. // @param overlay A block level element (usually a div) that the computed cues // and regions will be placed into. WebVTT.processCues = function (window, cues, overlay) { if (!window || !cues || !overlay) { return null; } // Remove all previous children. while (overlay.firstChild) { overlay.removeChild(overlay.firstChild); } var paddedOverlay = window.document.createElement("div"); paddedOverlay.style.position = "absolute"; paddedOverlay.style.left = "0"; paddedOverlay.style.right = "0"; paddedOverlay.style.top = "0"; paddedOverlay.style.bottom = "0"; paddedOverlay.style.margin = CUE_BACKGROUND_PADDING; overlay.appendChild(paddedOverlay); // Determine if we need to compute the display states of the cues. This could // be the case if a cue's state has been changed since the last computation or // if it has not been computed yet. function shouldCompute(cues) { for (var i = 0; i < cues.length; i++) { if (cues[i].hasBeenReset || !cues[i].displayState) { return true; } } return false; } // We don't need to recompute the cues' display states. Just reuse them. if (!shouldCompute(cues)) { for (var i = 0; i < cues.length; i++) { paddedOverlay.appendChild(cues[i].displayState); } return; } var boxPositions = [], containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay), fontSize = Math.round( containerBox.height * FONT_SIZE_PERCENT * 100 ) / 100; var styleOptions = { font: fontSize + "px " + FONT_STYLE, }; (function () { var styleBox, cue; for (var i = 0; i < cues.length; i++) { cue = cues[i]; // Compute the intial position and styles of the cue div. styleBox = new CueStyleBox(window, cue, styleOptions); paddedOverlay.appendChild(styleBox.div); // Move the cue div to it's correct line position. moveBoxToLinePosition( window, styleBox, containerBox, boxPositions ); // Remember the computed div so that we don't have to recompute it later // if we don't have too. cue.displayState = styleBox.div; boxPositions.push( BoxPosition.getSimpleBoxPosition(styleBox) ); } })(); }; WebVTT.Parser = function (window, vttjs, decoder) { if (!decoder) { decoder = vttjs; vttjs = {}; } if (!vttjs) { vttjs = {}; } this.window = window; this.vttjs = vttjs; this.state = "INITIAL"; this.buffer = ""; this.decoder = decoder || new TextDecoder("utf8"); this.regionList = []; }; WebVTT.Parser.prototype = { // If the error is a ParsingError then report it to the consumer if // possible. If it's not a ParsingError then throw it like normal. reportOrThrowError: function (e) { if (e instanceof ParsingError) { this.onparsingerror && this.onparsingerror(e); } else { throw e; } }, parse: function (data) { var self = this; // If there is no data then we won't decode it, but will just try to parse // whatever is in buffer already. This may occur in circumstances, for // example when flush() is called. if (data) { // Try to decode the data that we received. self.buffer += self.decoder.decode(data, { stream: true, }); } function collectNextLine() { var buffer = self.buffer; var pos = 0; while ( pos < buffer.length && buffer[pos] !== "\r" && buffer[pos] !== "\n" ) { ++pos; } var line = buffer.substr(0, pos); // Advance the buffer early in case we fail below. if (buffer[pos] === "\r") { ++pos; } if (buffer[pos] === "\n") { ++pos; } self.buffer = buffer.substr(pos); return line; } // 3.4 WebVTT region and WebVTT region settings syntax function parseRegion(input) { var settings = new Settings(); parseOptions( input, function (k, v) { switch (k) { case "id": settings.set(k, v); break; case "width": settings.percent(k, v); break; case "lines": settings.integer(k, v); break; case "regionanchor": case "viewportanchor": var xy = v.split(","); if (xy.length !== 2) { break; } // We have to make sure both x and y parse, so use a temporary // settings object here. var anchor = new Settings(); anchor.percent("x", xy[0]); anchor.percent("y", xy[1]); if ( !anchor.has("x") || !anchor.has("y") ) { break; } settings.set(k + "X", anchor.get("x")); settings.set(k + "Y", anchor.get("y")); break; case "scroll": settings.alt(k, v, ["up"]); break; } }, /=/, /\s/ ); // Create the region, using default values for any values that were not // specified. if (settings.has("id")) { var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)(); region.width = settings.get("width", 100); region.lines = settings.get("lines", 3); region.regionAnchorX = settings.get( "regionanchorX", 0 ); region.regionAnchorY = settings.get( "regionanchorY", 100 ); region.viewportAnchorX = settings.get( "viewportanchorX", 0 ); region.viewportAnchorY = settings.get( "viewportanchorY", 100 ); region.scroll = settings.get("scroll", ""); // Register the region. self.onregion && self.onregion(region); // Remember the VTTRegion for later in case we parse any VTTCues that // reference it. self.regionList.push({ id: settings.get("id"), region: region, }); } } // draft-pantos-http-live-streaming-20 // https://tools.ietf.org/html/draft-pantos-http-live-streaming-20#section-3.5 // 3.5 WebVTT function parseTimestampMap(input) { var settings = new Settings(); parseOptions( input, function (k, v) { switch (k) { case "MPEGT": settings.integer(k + "S", v); break; case "LOCA": settings.set( k + "L", parseTimeStamp(v) ); break; } }, /[^\d]:/, /,/ ); self.ontimestampmap && self.ontimestampmap({ MPEGTS: settings.get("MPEGTS"), LOCAL: settings.get("LOCAL"), }); } // 3.2 WebVTT metadata header syntax function parseHeader(input) { if (input.match(/X-TIMESTAMP-MAP/)) { // This line contains HLS X-TIMESTAMP-MAP metadata parseOptions( input, function (k, v) { switch (k) { case "X-TIMESTAMP-MAP": parseTimestampMap(v); break; } }, /=/ ); } else { parseOptions( input, function (k, v) { switch (k) { case "Region": // 3.3 WebVTT region metadata header syntax parseRegion(v); break; } }, /:/ ); } } // 5.1 WebVTT file parsing. try { var line; if (self.state === "INITIAL") { // We can't start parsing until we have the first line. if (!/\r\n|\n/.test(self.buffer)) { return this; } line = collectNextLine(); var m = line.match(/^WEBVTT([ \t].*)?$/); if (!m || !m[0]) { throw new ParsingError( ParsingError.Errors.BadSignature ); } self.state = "HEADER"; } var alreadyCollectedLine = false; while (self.buffer) { // We can't parse a line until we have the full line. if (!/\r\n|\n/.test(self.buffer)) { return this; } if (!alreadyCollectedLine) { line = collectNextLine(); } else { alreadyCollectedLine = false; } switch (self.state) { case "HEADER": // 13-18 - Allow a header (metadata) under the WEBVTT line. if (/:/.test(line)) { parseHeader(line); } else if (!line) { // An empty line terminates the header and starts the body (cues). self.state = "ID"; } continue; case "NOTE": // Ignore NOTE blocks. if (!line) { self.state = "ID"; } continue; case "ID": // Check for the start of NOTE blocks. if (/^NOTE($|[ \t])/.test(line)) { self.state = "NOTE"; break; } // 19-29 - Allow any number of line terminators, then initialize new cue values. if (!line) { continue; } self.cue = new (self.vttjs.VTTCue || self.window.VTTCue)(0, 0, ""); // Safari still uses the old middle value and won't accept center try { self.cue.align = "center"; } catch (e) { self.cue.align = "middle"; } self.state = "CUE"; // 30-39 - Check if self line contains an optional identifier or timing data. if (line.indexOf("-->") === -1) { self.cue.id = line; continue; } // Process line as start of a cue. /*falls through*/ case "CUE": // 40 - Collect cue timings and settings. try { parseCue( line, self.cue, self.regionList ); } catch (e) { self.reportOrThrowError(e); // In case of an error ignore rest of the cue. self.cue = null; self.state = "BADCUE"; continue; } self.state = "CUETEXT"; continue; case "CUETEXT": var hasSubstring = line.indexOf("-->") !== -1; // 34 - If we have an empty line then report the cue. // 35 - If we have the special substring '-->' then report the cue, // but do not collect the line as we need to process the current // one as a new cue. if ( !line || (hasSubstring && (alreadyCollectedLine = true)) ) { // We are done parsing self cue. self.oncue && self.oncue(self.cue); self.cue = null; self.state = "ID"; continue; } if (self.cue.text) { self.cue.text += "\n"; } self.cue.text += line .replace(/\u2028/g, "\n") .replace(/u2029/g, "\n"); continue; case "BADCUE": // BADCUE // 54-62 - Collect and discard the remaining cue. if (!line) { self.state = "ID"; } continue; } } } catch (e) { self.reportOrThrowError(e); // If we are currently parsing a cue, report what we have. if ( self.state === "CUETEXT" && self.cue && self.oncue ) { self.oncue(self.cue); } self.cue = null; // Enter BADWEBVTT state if header was not parsed correctly otherwise // another exception occurred so enter BADCUE state. self.state = self.state === "INITIAL" ? "BADWEBVTT" : "BADCUE"; } return this; }, flush: function () { var self = this; try { // Finish decoding the stream. self.buffer += self.decoder.decode(); // Synthesize the end of the current cue or region. if (self.cue || self.state === "HEADER") { self.buffer += "\n\n"; self.parse(); } // If we've flushed, parsed, and we're still on the INITIAL state then // that means we don't have enough of the stream to parse the first // line. if (self.state === "INITIAL") { throw new ParsingError( ParsingError.Errors.BadSignature ); } } catch (e) { self.reportOrThrowError(e); } self.onflush && self.onflush(); return this; }, }; module.exports = WebVTT; /***/ }, /***/ 2230: /***/ function (module) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var autoKeyword = "auto"; var directionSetting = { "": 1, lr: 1, rl: 1, }; var alignSetting = { start: 1, center: 1, end: 1, left: 1, right: 1, auto: 1, "line-left": 1, "line-right": 1, }; function findDirectionSetting(value) { if (typeof value !== "string") { return false; } var dir = directionSetting[value.toLowerCase()]; return dir ? value.toLowerCase() : false; } function findAlignSetting(value) { if (typeof value !== "string") { return false; } var align = alignSetting[value.toLowerCase()]; return align ? value.toLowerCase() : false; } function VTTCue(startTime, endTime, text) { /** * Shim implementation specific properties. These properties are not in * the spec. */ // Lets us know when the VTTCue's data has changed in such a way that we need // to recompute its display state. This lets us compute its display state // lazily. this.hasBeenReset = false; /** * VTTCue and TextTrackCue properties * http://dev.w3.org/html5/webvtt/#vttcue-interface */ var _id = ""; var _pauseOnExit = false; var _startTime = startTime; var _endTime = endTime; var _text = text; var _region = null; var _vertical = ""; var _snapToLines = true; var _line = "auto"; var _lineAlign = "start"; var _position = "auto"; var _positionAlign = "auto"; var _size = 100; var _align = "center"; Object.defineProperties(this, { id: { enumerable: true, get: function () { return _id; }, set: function (value) { _id = "" + value; }, }, pauseOnExit: { enumerable: true, get: function () { return _pauseOnExit; }, set: function (value) { _pauseOnExit = !!value; }, }, startTime: { enumerable: true, get: function () { return _startTime; }, set: function (value) { if (typeof value !== "number") { throw new TypeError( "Start time must be set to a number." ); } _startTime = value; this.hasBeenReset = true; }, }, endTime: { enumerable: true, get: function () { return _endTime; }, set: function (value) { if (typeof value !== "number") { throw new TypeError( "End time must be set to a number." ); } _endTime = value; this.hasBeenReset = true; }, }, text: { enumerable: true, get: function () { return _text; }, set: function (value) { _text = "" + value; this.hasBeenReset = true; }, }, region: { enumerable: true, get: function () { return _region; }, set: function (value) { _region = value; this.hasBeenReset = true; }, }, vertical: { enumerable: true, get: function () { return _vertical; }, set: function (value) { var setting = findDirectionSetting(value); // Have to check for false because the setting an be an empty string. if (setting === false) { throw new SyntaxError( "Vertical: an invalid or illegal direction string was specified." ); } _vertical = setting; this.hasBeenReset = true; }, }, snapToLines: { enumerable: true, get: function () { return _snapToLines; }, set: function (value) { _snapToLines = !!value; this.hasBeenReset = true; }, }, line: { enumerable: true, get: function () { return _line; }, set: function (value) { if ( typeof value !== "number" && value !== autoKeyword ) { throw new SyntaxError( "Line: an invalid number or illegal string was specified." ); } _line = value; this.hasBeenReset = true; }, }, lineAlign: { enumerable: true, get: function () { return _lineAlign; }, set: function (value) { var setting = findAlignSetting(value); if (!setting) { console.warn( "lineAlign: an invalid or illegal string was specified." ); } else { _lineAlign = setting; this.hasBeenReset = true; } }, }, position: { enumerable: true, get: function () { return _position; }, set: function (value) { if (value < 0 || value > 100) { throw new Error( "Position must be between 0 and 100." ); } _position = value; this.hasBeenReset = true; }, }, positionAlign: { enumerable: true, get: function () { return _positionAlign; }, set: function (value) { var setting = findAlignSetting(value); if (!setting) { console.warn( "positionAlign: an invalid or illegal string was specified." ); } else { _positionAlign = setting; this.hasBeenReset = true; } }, }, size: { enumerable: true, get: function () { return _size; }, set: function (value) { if (value < 0 || value > 100) { throw new Error( "Size must be between 0 and 100." ); } _size = value; this.hasBeenReset = true; }, }, align: { enumerable: true, get: function () { return _align; }, set: function (value) { var setting = findAlignSetting(value); if (!setting) { throw new SyntaxError( "align: an invalid or illegal alignment string was specified." ); } _align = setting; this.hasBeenReset = true; }, }, }); /** * Other <track> spec defined properties */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state this.displayState = undefined; } /** * VTTCue methods */ VTTCue.prototype.getCueAsHTML = function () { // Assume WebVTT.convertCueToDOMTree is on the global. return WebVTT.convertCueToDOMTree(window, this.text); }; module.exports = VTTCue; /***/ }, /***/ 3710: /***/ function (module) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var scrollSetting = { "": true, up: true, }; function findScrollSetting(value) { if (typeof value !== "string") { return false; } var scroll = scrollSetting[value.toLowerCase()]; return scroll ? value.toLowerCase() : false; } function isValidPercentValue(value) { return typeof value === "number" && value >= 0 && value <= 100; } // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface function VTTRegion() { var _width = 100; var _lines = 3; var _regionAnchorX = 0; var _regionAnchorY = 100; var _viewportAnchorX = 0; var _viewportAnchorY = 100; var _scroll = ""; Object.defineProperties(this, { width: { enumerable: true, get: function () { return _width; }, set: function (value) { if (!isValidPercentValue(value)) { throw new Error( "Width must be between 0 and 100." ); } _width = value; }, }, lines: { enumerable: true, get: function () { return _lines; }, set: function (value) { if (typeof value !== "number") { throw new TypeError( "Lines must be set to a number." ); } _lines = value; }, }, regionAnchorY: { enumerable: true, get: function () { return _regionAnchorY; }, set: function (value) { if (!isValidPercentValue(value)) { throw new Error( "RegionAnchorX must be between 0 and 100." ); } _regionAnchorY = value; }, }, regionAnchorX: { enumerable: true, get: function () { return _regionAnchorX; }, set: function (value) { if (!isValidPercentValue(value)) { throw new Error( "RegionAnchorY must be between 0 and 100." ); } _regionAnchorX = value; }, }, viewportAnchorY: { enumerable: true, get: function () { return _viewportAnchorY; }, set: function (value) { if (!isValidPercentValue(value)) { throw new Error( "ViewportAnchorY must be between 0 and 100." ); } _viewportAnchorY = value; }, }, viewportAnchorX: { enumerable: true, get: function () { return _viewportAnchorX; }, set: function (value) { if (!isValidPercentValue(value)) { throw new Error( "ViewportAnchorX must be between 0 and 100." ); } _viewportAnchorX = value; }, }, scroll: { enumerable: true, get: function () { return _scroll; }, set: function (value) { var setting = findScrollSetting(value); // Have to check for false as an empty string is a legal value. if (setting === false) { console.warn( "Scroll: an invalid or illegal string was specified." ); } else { _scroll = setting; } }, }, }); } module.exports = VTTRegion; /***/ }, /***/ 4782: /***/ function (__unused_webpack_module, exports) { "use strict"; exports.byteLength = byteLength; exports.toByteArray = toByteArray; exports.fromByteArray = fromByteArray; var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i]; revLookup[code.charCodeAt(i)] = i; } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup["-".charCodeAt(0)] = 62; revLookup["_".charCodeAt(0)] = 63; function getLens(b64) { var len = b64.length; if (len % 4 > 0) { throw new Error( "Invalid string. Length must be a multiple of 4" ); } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf("="); if (validLen === -1) validLen = len; var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4); return [validLen, placeHoldersLen]; } // base64 is 4/3 + up to two characters of the original data function byteLength(b64) { var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; } function _byteLength(b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; } function toByteArray(b64) { var tmp; var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen; var i; for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; arr[curByte++] = (tmp >> 16) & 0xff; arr[curByte++] = (tmp >> 8) & 0xff; arr[curByte++] = tmp & 0xff; } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); arr[curByte++] = tmp & 0xff; } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); arr[curByte++] = (tmp >> 8) & 0xff; arr[curByte++] = tmp & 0xff; } return arr; } function tripletToBase64(num) { return ( lookup[(num >> 18) & 0x3f] + lookup[(num >> 12) & 0x3f] + lookup[(num >> 6) & 0x3f] + lookup[num & 0x3f] ); } function encodeChunk(uint8, start, end) { var tmp; var output = []; for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xff0000) + ((uint8[i + 1] << 8) & 0xff00) + (uint8[i + 2] & 0xff); output.push(tripletToBase64(tmp)); } return output.join(""); } function fromByteArray(uint8) { var tmp; var len = uint8.length; var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes var parts = []; var maxChunkLength = 16383; // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for ( var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength ) { parts.push( encodeChunk( uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength ) ); } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1]; parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + "==" ); } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1]; parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3f] + lookup[(tmp << 2) & 0x3f] + "=" ); } return parts.join(""); } /***/ }, /***/ 816: /***/ function ( __unused_webpack_module, exports, __webpack_require__ ) { "use strict"; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ /* eslint-disable no-proto */ var base64 = __webpack_require__(4782); var ieee754 = __webpack_require__(8898); var customInspectSymbol = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("nodejs.util.inspect.custom") : null; exports.Buffer = Buffer; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 0x7fffffff; exports.kMaxLength = K_MAX_LENGTH; /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) * === false Print warning and recommend using `buffer` v4.x which has an Object * implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * * We report that the browser does not support typed arrays if the are not subclassable * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support * for __proto__ and has a buggy typed array implementation. */ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); if ( !Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function" ) { console.error( "This browser lacks typed array (Uint8Array) support which is required by " + "`buffer` v5.x. Use `buffer` v4.x if you require old browser support." ); } function typedArraySupport() { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1); var proto = { foo: function () { return 42; }, }; Object.setPrototypeOf(proto, Uint8Array.prototype); Object.setPrototypeOf(arr, proto); return arr.foo() === 42; } catch (e) { return false; } } Object.defineProperty(Buffer.prototype, "parent", { enumerable: true, get: function () { if (!Buffer.isBuffer(this)) return undefined; return this.buffer; }, }); Object.defineProperty(Buffer.prototype, "offset", { enumerable: true, get: function () { if (!Buffer.isBuffer(this)) return undefined; return this.byteOffset; }, }); function createBuffer(length) { if (length > K_MAX_LENGTH) { throw new RangeError( 'The value "' + length + '" is invalid for option "size"' ); } // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length); Object.setPrototypeOf(buf, Buffer.prototype); return buf; } /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ function Buffer(arg, encodingOrOffset, length) { // Common case. if (typeof arg === "number") { if (typeof encodingOrOffset === "string") { throw new TypeError( 'The "string" argument must be of type string. Received type number' ); } return allocUnsafe(arg); } return from(arg, encodingOrOffset, length); } Buffer.poolSize = 8192; // not used by this implementation function from(value, encodingOrOffset, length) { if (typeof value === "string") { return fromString(value, encodingOrOffset); } if (ArrayBuffer.isView(value)) { return fromArrayLike(value); } if (value == null) { throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value ); } if ( isInstance(value, ArrayBuffer) || (value && isInstance(value.buffer, ArrayBuffer)) ) { return fromArrayBuffer(value, encodingOrOffset, length); } if ( typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || (value && isInstance(value.buffer, SharedArrayBuffer))) ) { return fromArrayBuffer(value, encodingOrOffset, length); } if (typeof value === "number") { throw new TypeError( 'The "value" argument must not be of type number. Received type number' ); } var valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { return Buffer.from(valueOf, encodingOrOffset, length); } var b = fromObject(value); if (b) return b; if ( typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function" ) { return Buffer.from( value[Symbol.toPrimitive]("string"), encodingOrOffset, length ); } throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value ); } /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function (value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: // https://github.com/feross/buffer/pull/148 Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); Object.setPrototypeOf(Buffer, Uint8Array); function assertSize(size) { if (typeof size !== "number") { throw new TypeError( '"size" argument must be of type number' ); } else if (size < 0) { throw new RangeError( 'The value "' + size + '" is invalid for option "size"' ); } } function alloc(size, fill, encoding) { assertSize(size); if (size <= 0) { return createBuffer(size); } if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); } return createBuffer(size); } /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function (size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function (size) { return allocUnsafe(size); }; /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function (size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") { encoding = "utf8"; } if (!Buffer.isEncoding(encoding)) { throw new TypeError("Unknown encoding: " + encoding); } var length = byteLength(string, encoding) | 0; var buf = createBuffer(length); var actual = buf.write(string, encoding); if (actual !== length) { // Writing a hex string, for example, that contains invalid characters will // cause everything after the first invalid character to be ignored. (e.g. // 'abxxcd' will be treated as 'ab') buf = buf.slice(0, actual); } return buf; } function fromArrayLike(array) { var length = array.length < 0 ? 0 : checked(array.length) | 0; var buf = createBuffer(length); for (var i = 0; i < length; i += 1) { buf[i] = array[i] & 255; } return buf; } function fromArrayBuffer(array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError( '"offset" is outside of buffer bounds' ); } if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError( '"length" is outside of buffer bounds' ); } var buf; if (byteOffset === undefined && length === undefined) { buf = new Uint8Array(array); } else if (length === undefined) { buf = new Uint8Array(array, byteOffset); } else { buf = new Uint8Array(array, byteOffset, length); } // Return an augmented `Uint8Array` instance Object.setPrototypeOf(buf, Buffer.prototype); return buf; } function fromObject(obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0; var buf = createBuffer(len); if (buf.length === 0) { return buf; } obj.copy(buf, 0, 0, len); return buf; } if (obj.length !== undefined) { if ( typeof obj.length !== "number" || numberIsNaN(obj.length) ) { return createBuffer(0); } return fromArrayLike(obj); } if (obj.type === "Buffer" && Array.isArray(obj.data)) { return fromArrayLike(obj.data); } } function checked(length) { // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= K_MAX_LENGTH) { throw new RangeError( "Attempt to allocate Buffer larger than maximum " + "size: 0x" + K_MAX_LENGTH.toString(16) + " bytes" ); } return length | 0; } function SlowBuffer(length) { if (+length != length) { // eslint-disable-line eqeqeq length = 0; } return Buffer.alloc(+length); } Buffer.isBuffer = function isBuffer(b) { return ( b != null && b._isBuffer === true && b !== Buffer.prototype ); // so Buffer.isBuffer(Buffer.prototype) will be false }; Buffer.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError( 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' ); } if (a === b) return 0; var x = a.length; var y = b.length; for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i]; y = b[i]; break; } } if (x < y) return -1; if (y < x) return 1; return 0; }; Buffer.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": case "utf-8": case "ascii": case "latin1": case "binary": case "base64": case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return true; default: return false; } }; Buffer.concat = function concat(list, length) { if (!Array.isArray(list)) { throw new TypeError( '"list" argument must be an Array of Buffers' ); } if (list.length === 0) { return Buffer.alloc(0); } var i; if (length === undefined) { length = 0; for (i = 0; i < list.length; ++i) { length += list[i].length; } } var buffer = Buffer.allocUnsafe(length); var pos = 0; for (i = 0; i < list.length; ++i) { var buf = list[i]; if (isInstance(buf, Uint8Array)) { buf = Buffer.from(buf); } if (!Buffer.isBuffer(buf)) { throw new TypeError( '"list" argument must be an Array of Buffers' ); } buf.copy(buffer, pos); pos += buf.length; } return buffer; }; function byteLength(string, encoding) { if (Buffer.isBuffer(string)) { return string.length; } if ( ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer) ) { return string.byteLength; } if (typeof string !== "string") { throw new TypeError( 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + "Received type " + typeof string ); } var len = string.length; var mustMatch = arguments.length > 2 && arguments[2] === true; if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion var loweredCase = false; for (;;) { switch (encoding) { case "ascii": case "latin1": case "binary": return len; case "utf8": case "utf-8": return utf8ToBytes(string).length; case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return len * 2; case "hex": return len >>> 1; case "base64": return base64ToBytes(string).length; default: if (loweredCase) { return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 } encoding = ("" + encoding).toLowerCase(); loweredCase = true; } } } Buffer.byteLength = byteLength; function slowToString(encoding, start, end) { var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only // property of a typed array. // This behaves neither like String nor Uint8Array in that we set start/end // to their upper/lower bounds if the value passed is out of range. // undefined is handled specially as per ECMA-262 6th Edition, // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. if (start === undefined || start < 0) { start = 0; } // Return early if start > this.length. Done here to prevent potential uint32 // coercion fail below. if (start > this.length) { return ""; } if (end === undefined || end > this.length) { end = this.length; } if (end <= 0) { return ""; } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0; start >>>= 0; if (end <= start) { return ""; } if (!encoding) encoding = "utf8"; while (true) { switch (encoding) { case "hex": return hexSlice(this, start, end); case "utf8": case "utf-8": return utf8Slice(this, start, end); case "ascii": return asciiSlice(this, start, end); case "latin1": case "binary": return latin1Slice(this, start, end); case "base64": return base64Slice(this, start, end); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return utf16leSlice(this, start, end); default: if (loweredCase) throw new TypeError( "Unknown encoding: " + encoding ); encoding = (encoding + "").toLowerCase(); loweredCase = true; } } } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) // to detect a Buffer instance. It's not possible to use `instanceof Buffer` // reliably in a browserify context because there could be multiple different // copies of the 'buffer' package in use. This method works even for Buffer // instances that were created from another copy of the `buffer` package. // See: https://github.com/feross/buffer/issues/154 Buffer.prototype._isBuffer = true; function swap(b, n, m) { var i = b[n]; b[n] = b[m]; b[m] = i; } Buffer.prototype.swap16 = function swap16() { var len = this.length; if (len % 2 !== 0) { throw new RangeError( "Buffer size must be a multiple of 16-bits" ); } for (var i = 0; i < len; i += 2) { swap(this, i, i + 1); } return this; }; Buffer.prototype.swap32 = function swap32() { var len = this.length; if (len % 4 !== 0) { throw new RangeError( "Buffer size must be a multiple of 32-bits" ); } for (var i = 0; i < len; i += 4) { swap(this, i, i + 3); swap(this, i + 1, i + 2); } return this; }; Buffer.prototype.swap64 = function swap64() { var len = this.length; if (len % 8 !== 0) { throw new RangeError( "Buffer size must be a multiple of 64-bits" ); } for (var i = 0; i < len; i += 8) { swap(this, i, i + 7); swap(this, i + 1, i + 6); swap(this, i + 2, i + 5); swap(this, i + 3, i + 4); } return this; }; Buffer.prototype.toString = function toString() { var length = this.length; if (length === 0) return ""; if (arguments.length === 0) return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; Buffer.prototype.toLocaleString = Buffer.prototype.toString; Buffer.prototype.equals = function equals(b) { if (!Buffer.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; return Buffer.compare(this, b) === 0; }; Buffer.prototype.inspect = function inspect() { var str = ""; var max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max) .replace(/(.{2})/g, "$1 ") .trim(); if (this.length > max) str += " ... "; return "<Buffer " + str + ">"; }; if (customInspectSymbol) { Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; } Buffer.prototype.compare = function compare( target, start, end, thisStart, thisEnd ) { if (isInstance(target, Uint8Array)) { target = Buffer.from( target, target.offset, target.byteLength ); } if (!Buffer.isBuffer(target)) { throw new TypeError( 'The "target" argument must be one of type Buffer or Uint8Array. ' + "Received type " + typeof target ); } if (start === undefined) { start = 0; } if (end === undefined) { end = target ? target.length : 0; } if (thisStart === undefined) { thisStart = 0; } if (thisEnd === undefined) { thisEnd = this.length; } if ( start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length ) { throw new RangeError("out of range index"); } if (thisStart >= thisEnd && start >= end) { return 0; } if (thisStart >= thisEnd) { return -1; } if (start >= end) { return 1; } start >>>= 0; end >>>= 0; thisStart >>>= 0; thisEnd >>>= 0; if (this === target) return 0; var x = thisEnd - thisStart; var y = end - start; var len = Math.min(x, y); var thisCopy = this.slice(thisStart, thisEnd); var targetCopy = target.slice(start, end); for (var i = 0; i < len; ++i) { if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i]; y = targetCopy[i]; break; } } if (x < y) return -1; if (y < x) return 1; return 0; }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, // OR the last index of `val` in `buffer` at offset <= `byteOffset`. // // Arguments: // - buffer - a Buffer to search // - val - a string, Buffer, or number // - byteOffset - an index into `buffer`; will be clamped to an int32 // - encoding - an optional encoding, relevant is val is a string // - dir - true for indexOf, false for lastIndexOf function bidirectionalIndexOf( buffer, val, byteOffset, encoding, dir ) { // Empty buffer means no match if (buffer.length === 0) return -1; // Normalize byteOffset if (typeof byteOffset === "string") { encoding = byteOffset; byteOffset = 0; } else if (byteOffset > 0x7fffffff) { byteOffset = 0x7fffffff; } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000; } byteOffset = +byteOffset; // Coerce to Number. if (numberIsNaN(byteOffset)) { // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : buffer.length - 1; } // Normalize byteOffset: negative offsets start from the end of the buffer if (byteOffset < 0) byteOffset = buffer.length + byteOffset; if (byteOffset >= buffer.length) { if (dir) return -1; else byteOffset = buffer.length - 1; } else if (byteOffset < 0) { if (dir) byteOffset = 0; else return -1; } // Normalize val if (typeof val === "string") { val = Buffer.from(val, encoding); } // Finally, search either indexOf (if dir is true) or lastIndexOf if (Buffer.isBuffer(val)) { // Special case: looking for empty string/buffer always fails if (val.length === 0) { return -1; } return arrayIndexOf(buffer, val, byteOffset, encoding, dir); } else if (typeof val === "number") { val = val & 0xff; // Search for a byte value [0-255] if (typeof Uint8Array.prototype.indexOf === "function") { if (dir) { return Uint8Array.prototype.indexOf.call( buffer, val, byteOffset ); } else { return Uint8Array.prototype.lastIndexOf.call( buffer, val, byteOffset ); } } return arrayIndexOf( buffer, [val], byteOffset, encoding, dir ); } throw new TypeError("val must be string, number or Buffer"); } function arrayIndexOf(arr, val, byteOffset, encoding, dir) { var indexSize = 1; var arrLength = arr.length; var valLength = val.length; if (encoding !== undefined) { encoding = String(encoding).toLowerCase(); if ( encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le" ) { if (arr.length < 2 || val.length < 2) { return -1; } indexSize = 2; arrLength /= 2; valLength /= 2; byteOffset /= 2; } } function read(buf, i) { if (indexSize === 1) { return buf[i]; } else { return buf.readUInt16BE(i * indexSize); } } var i; if (dir) { var foundIndex = -1; for (i = byteOffset; i < arrLength; i++) { if ( read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex) ) { if (foundIndex === -1) foundIndex = i; if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; } else { if (foundIndex !== -1) i -= i - foundIndex; foundIndex = -1; } } } else { if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; for (i = byteOffset; i >= 0; i--) { var found = true; for (var j = 0; j < valLength; j++) { if (read(arr, i + j) !== read(val, j)) { found = false; break; } } if (found) return i; } } return -1; } Buffer.prototype.includes = function includes( val, byteOffset, encoding ) { return this.indexOf(val, byteOffset, encoding) !== -1; }; Buffer.prototype.indexOf = function indexOf( val, byteOffset, encoding ) { return bidirectionalIndexOf( this, val, byteOffset, encoding, true ); }; Buffer.prototype.lastIndexOf = function lastIndexOf( val, byteOffset, encoding ) { return bidirectionalIndexOf( this, val, byteOffset, encoding, false ); }; function hexWrite(buf, string, offset, length) { offset = Number(offset) || 0; var remaining = buf.length - offset; if (!length) { length = remaining; } else { length = Number(length); if (length > remaining) { length = remaining; } } var strLen = string.length; if (length > strLen / 2) { length = strLen / 2; } for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16); if (numberIsNaN(parsed)) return i; buf[offset + i] = parsed; } return i; } function utf8Write(buf, string, offset, length) { return blitBuffer( utf8ToBytes(string, buf.length - offset), buf, offset, length ); } function asciiWrite(buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length); } function latin1Write(buf, string, offset, length) { return asciiWrite(buf, string, offset, length); } function base64Write(buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length); } function ucs2Write(buf, string, offset, length) { return blitBuffer( utf16leToBytes(string, buf.length - offset), buf, offset, length ); } Buffer.prototype.write = function write( string, offset, length, encoding ) { // Buffer#write(string) if (offset === undefined) { encoding = "utf8"; length = this.length; offset = 0; // Buffer#write(string, encoding) } else if (length === undefined && typeof offset === "string") { encoding = offset; length = this.length; offset = 0; // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { offset = offset >>> 0; if (isFinite(length)) { length = length >>> 0; if (encoding === undefined) encoding = "utf8"; } else { encoding = length; length = undefined; } } else { throw new Error( "Buffer.write(string, encoding, offset[, length]) is no longer supported" ); } var remaining = this.length - offset; if (length === undefined || length > remaining) length = remaining; if ( (string.length > 0 && (length < 0 || offset < 0)) || offset > this.length ) { throw new RangeError( "Attempt to write outside buffer bounds" ); } if (!encoding) encoding = "utf8"; var loweredCase = false; for (;;) { switch (encoding) { case "hex": return hexWrite(this, string, offset, length); case "utf8": case "utf-8": return utf8Write(this, string, offset, length); case "ascii": return asciiWrite(this, string, offset, length); case "latin1": case "binary": return latin1Write(this, string, offset, length); case "base64": // Warning: maxLength not taken into account in base64Write return base64Write(this, string, offset, length); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return ucs2Write(this, string, offset, length); default: if (loweredCase) throw new TypeError( "Unknown encoding: " + encoding ); encoding = ("" + encoding).toLowerCase(); loweredCase = true; } } }; Buffer.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0), }; }; function base64Slice(buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf); } else { return base64.fromByteArray(buf.slice(start, end)); } } function utf8Slice(buf, start, end) { end = Math.min(buf.length, end); var res = []; var i = start; while (i < end) { var firstByte = buf[i]; var codePoint = null; var bytesPerSequence = firstByte > 0xef ? 4 : firstByte > 0xdf ? 3 : firstByte > 0xbf ? 2 : 1; if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint; switch (bytesPerSequence) { case 1: if (firstByte < 0x80) { codePoint = firstByte; } break; case 2: secondByte = buf[i + 1]; if ((secondByte & 0xc0) === 0x80) { tempCodePoint = ((firstByte & 0x1f) << 0x6) | (secondByte & 0x3f); if (tempCodePoint > 0x7f) { codePoint = tempCodePoint; } } break; case 3: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; if ( (secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80 ) { tempCodePoint = ((firstByte & 0xf) << 0xc) | ((secondByte & 0x3f) << 0x6) | (thirdByte & 0x3f); if ( tempCodePoint > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff) ) { codePoint = tempCodePoint; } } break; case 4: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; fourthByte = buf[i + 3]; if ( (secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80 && (fourthByte & 0xc0) === 0x80 ) { tempCodePoint = ((firstByte & 0xf) << 0x12) | ((secondByte & 0x3f) << 0xc) | ((thirdByte & 0x3f) << 0x6) | (fourthByte & 0x3f); if ( tempCodePoint > 0xffff && tempCodePoint < 0x110000 ) { codePoint = tempCodePoint; } } } } if (codePoint === null) { // we did not generate a valid codePoint so insert a // replacement char (U+FFFD) and advance only 1 byte codePoint = 0xfffd; bytesPerSequence = 1; } else if (codePoint > 0xffff) { // encode to utf16 (surrogate pair dance) codePoint -= 0x10000; res.push(((codePoint >>> 10) & 0x3ff) | 0xd800); codePoint = 0xdc00 | (codePoint & 0x3ff); } res.push(codePoint); i += bytesPerSequence; } return decodeCodePointsArray(res); } // Based on http://stackoverflow.com/a/22747272/680742, the browser with // the lowest limit is Chrome, with 0x10000 args. // We go 1 magnitude less, for safety var MAX_ARGUMENTS_LENGTH = 0x1000; function decodeCodePointsArray(codePoints) { var len = codePoints.length; if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints); // avoid extra slice() } // Decode in chunks to avoid "call stack size exceeded". var res = ""; var i = 0; while (i < len) { res += String.fromCharCode.apply( String, codePoints.slice(i, (i += MAX_ARGUMENTS_LENGTH)) ); } return res; } function asciiSlice(buf, start, end) { var ret = ""; end = Math.min(buf.length, end); for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7f); } return ret; } function latin1Slice(buf, start, end) { var ret = ""; end = Math.min(buf.length, end); for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]); } return ret; } function hexSlice(buf, start, end) { var len = buf.length; if (!start || start < 0) start = 0; if (!end || end < 0 || end > len) end = len; var out = ""; for (var i = start; i < end; ++i) { out += hexSliceLookupTable[buf[i]]; } return out; } function utf16leSlice(buf, start, end) { var bytes = buf.slice(start, end); var res = ""; for (var i = 0; i < bytes.length; i += 2) { res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); } return res; } Buffer.prototype.slice = function slice(start, end) { var len = this.length; start = ~~start; end = end === undefined ? len : ~~end; if (start < 0) { start += len; if (start < 0) start = 0; } else if (start > len) { start = len; } if (end < 0) { end += len; if (end < 0) end = 0; } else if (end > len) { end = len; } if (end < start) end = start; var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance Object.setPrototypeOf(newBuf, Buffer.prototype); return newBuf; }; /* * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset(offset, ext, length) { if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint"); if (offset + ext > length) throw new RangeError( "Trying to access beyond buffer length" ); } Buffer.prototype.readUIntLE = function readUIntLE( offset, byteLength, noAssert ) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul; } return val; }; Buffer.prototype.readUIntBE = function readUIntBE( offset, byteLength, noAssert ) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { checkOffset(offset, byteLength, this.length); } var val = this[offset + --byteLength]; var mul = 1; while (byteLength > 0 && (mul *= 0x100)) { val += this[offset + --byteLength] * mul; } return val; }; Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; Buffer.prototype.readUInt16LE = function readUInt16LE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | (this[offset + 1] << 8); }; Buffer.prototype.readUInt16BE = function readUInt16BE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return (this[offset] << 8) | this[offset + 1]; }; Buffer.prototype.readUInt32LE = function readUInt32LE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ( (this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + this[offset + 3] * 0x1000000 ); }; Buffer.prototype.readUInt32BE = function readUInt32BE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ( this[offset] * 0x1000000 + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]) ); }; Buffer.prototype.readIntLE = function readIntLE( offset, byteLength, noAssert ) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul; } mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readIntBE = function readIntBE( offset, byteLength, noAssert ) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var i = byteLength; var mul = 1; var val = this[offset + --i]; while (i > 0 && (mul *= 0x100)) { val += this[offset + --i] * mul; } mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); if (!(this[offset] & 0x80)) return this[offset]; return (0xff - this[offset] + 1) * -1; }; Buffer.prototype.readInt16LE = function readInt16LE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset] | (this[offset + 1] << 8); return val & 0x8000 ? val | 0xffff0000 : val; }; Buffer.prototype.readInt16BE = function readInt16BE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset + 1] | (this[offset] << 8); return val & 0x8000 ? val | 0xffff0000 : val; }; Buffer.prototype.readInt32LE = function readInt32LE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ( this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24) ); }; Buffer.prototype.readInt32BE = function readInt32BE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ( (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3] ); }; Buffer.prototype.readFloatLE = function readFloatLE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, true, 23, 4); }; Buffer.prototype.readFloatBE = function readFloatBE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, false, 23, 4); }; Buffer.prototype.readDoubleLE = function readDoubleLE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, true, 52, 8); }; Buffer.prototype.readDoubleBE = function readDoubleBE( offset, noAssert ) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, false, 52, 8); }; function checkInt(buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError( '"buffer" argument must be a Buffer instance' ); if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buf.length) throw new RangeError("Index out of range"); } Buffer.prototype.writeUIntLE = function writeUIntLE( value, offset, byteLength, noAssert ) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var mul = 1; var i = 0; this[offset] = value & 0xff; while (++i < byteLength && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xff; } return offset + byteLength; }; Buffer.prototype.writeUIntBE = function writeUIntBE( value, offset, byteLength, noAssert ) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var i = byteLength - 1; var mul = 1; this[offset + i] = value & 0xff; while (--i >= 0 && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xff; } return offset + byteLength; }; Buffer.prototype.writeUInt8 = function writeUInt8( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); this[offset] = value & 0xff; return offset + 1; }; Buffer.prototype.writeUInt16LE = function writeUInt16LE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeUInt16BE = function writeUInt16BE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = value >>> 8; this[offset + 1] = value & 0xff; return offset + 2; }; Buffer.prototype.writeUInt32LE = function writeUInt32LE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset + 3] = value >>> 24; this[offset + 2] = value >>> 16; this[offset + 1] = value >>> 8; this[offset] = value & 0xff; return offset + 4; }; Buffer.prototype.writeUInt32BE = function writeUInt32BE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 0xff; return offset + 4; }; Buffer.prototype.writeIntLE = function writeIntLE( value, offset, byteLength, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt( this, value, offset, byteLength, limit - 1, -limit ); } var i = 0; var mul = 1; var sub = 0; this[offset] = value & 0xff; while (++i < byteLength && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { sub = 1; } this[offset + i] = (((value / mul) >> 0) - sub) & 0xff; } return offset + byteLength; }; Buffer.prototype.writeIntBE = function writeIntBE( value, offset, byteLength, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt( this, value, offset, byteLength, limit - 1, -limit ); } var i = byteLength - 1; var mul = 1; var sub = 0; this[offset + i] = value & 0xff; while (--i >= 0 && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { sub = 1; } this[offset + i] = (((value / mul) >> 0) - sub) & 0xff; } return offset + byteLength; }; Buffer.prototype.writeInt8 = function writeInt8( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); if (value < 0) value = 0xff + value + 1; this[offset] = value & 0xff; return offset + 1; }; Buffer.prototype.writeInt16LE = function writeInt16LE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeInt16BE = function writeInt16BE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = value >>> 8; this[offset + 1] = value & 0xff; return offset + 2; }; Buffer.prototype.writeInt32LE = function writeInt32LE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; this[offset + 2] = value >>> 16; this[offset + 3] = value >>> 24; return offset + 4; }; Buffer.prototype.writeInt32BE = function writeInt32BE( value, offset, noAssert ) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); if (value < 0) value = 0xffffffff + value + 1; this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 0xff; return offset + 4; }; function checkIEEE754(buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError("Index out of range"); if (offset < 0) throw new RangeError("Index out of range"); } function writeFloat(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754( buf, value, offset, 4, 3.4028234663852886e38, -3.4028234663852886e38 ); } ieee754.write(buf, value, offset, littleEndian, 23, 4); return offset + 4; } Buffer.prototype.writeFloatLE = function writeFloatLE( value, offset, noAssert ) { return writeFloat(this, value, offset, true, noAssert); }; Buffer.prototype.writeFloatBE = function writeFloatBE( value, offset, noAssert ) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754( buf, value, offset, 8, 1.7976931348623157e308, -1.7976931348623157e308 ); } ieee754.write(buf, value, offset, littleEndian, 52, 8); return offset + 8; } Buffer.prototype.writeDoubleLE = function writeDoubleLE( value, offset, noAssert ) { return writeDouble(this, value, offset, true, noAssert); }; Buffer.prototype.writeDoubleBE = function writeDoubleBE( value, offset, noAssert ) { return writeDouble(this, value, offset, false, noAssert); }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function copy( target, targetStart, start, end ) { if (!Buffer.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; if (!end && end !== 0) end = this.length; if (targetStart >= target.length) targetStart = target.length; if (!targetStart) targetStart = 0; if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done if (end === start) return 0; if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions if (targetStart < 0) { throw new RangeError("targetStart out of bounds"); } if (start < 0 || start >= this.length) throw new RangeError("Index out of range"); if (end < 0) throw new RangeError("sourceEnd out of bounds"); // Are we oob? if (end > this.length) end = this.length; if (target.length - targetStart < end - start) { end = target.length - targetStart + start; } var len = end - start; if ( this === target && typeof Uint8Array.prototype.copyWithin === "function" ) { // Use built-in when available, missing from IE11 this.copyWithin(targetStart, start, end); } else if ( this === target && start < targetStart && targetStart < end ) { // descending copy from end for (var i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start]; } } else { Uint8Array.prototype.set.call( target, this.subarray(start, end), targetStart ); } return len; }; // Usage: // buffer.fill(number[, offset[, end]]) // buffer.fill(buffer[, offset[, end]]) // buffer.fill(string[, offset[, end]][, encoding]) Buffer.prototype.fill = function fill(val, start, end, encoding) { // Handle string cases: if (typeof val === "string") { if (typeof start === "string") { encoding = start; start = 0; end = this.length; } else if (typeof end === "string") { encoding = end; end = this.length; } if ( encoding !== undefined && typeof encoding !== "string" ) { throw new TypeError("encoding must be a string"); } if ( typeof encoding === "string" && !Buffer.isEncoding(encoding) ) { throw new TypeError("Unknown encoding: " + encoding); } if (val.length === 1) { var code = val.charCodeAt(0); if ( (encoding === "utf8" && code < 128) || encoding === "latin1" ) { // Fast path: If `val` fits into a single byte, use that numeric value. val = code; } } } else if (typeof val === "number") { val = val & 255; } else if (typeof val === "boolean") { val = Number(val); } // Invalid ranges are not set to a default, so can range check early. if (start < 0 || this.length < start || this.length < end) { throw new RangeError("Out of range index"); } if (end <= start) { return this; } start = start >>> 0; end = end === undefined ? this.length : end >>> 0; if (!val) val = 0; var i; if (typeof val === "number") { for (i = start; i < end; ++i) { this[i] = val; } } else { var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); var len = bytes.length; if (len === 0) { throw new TypeError( 'The value "' + val + '" is invalid for argument "value"' ); } for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len]; } } return this; }; // HELPER FUNCTIONS // ================ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; function base64clean(str) { // Node takes equal signs as end of the Base64 encoding str = str.split("=")[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not str = str.trim().replace(INVALID_BASE64_RE, ""); // Node converts strings with length < 2 to '' if (str.length < 2) return ""; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not while (str.length % 4 !== 0) { str = str + "="; } return str; } function utf8ToBytes(string, units) { units = units || Infinity; var codePoint; var length = string.length; var leadSurrogate = null; var bytes = []; for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i); // is surrogate component if (codePoint > 0xd7ff && codePoint < 0xe000) { // last char was a lead if (!leadSurrogate) { // no lead yet if (codePoint > 0xdbff) { // unexpected trail if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); continue; } else if (i + 1 === length) { // unpaired lead if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); continue; } // valid lead leadSurrogate = codePoint; continue; } // 2 leads in a row if (codePoint < 0xdc00) { if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); leadSurrogate = codePoint; continue; } // valid surrogate pair codePoint = (((leadSurrogate - 0xd800) << 10) | (codePoint - 0xdc00)) + 0x10000; } else if (leadSurrogate) { // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd); } leadSurrogate = null; // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break; bytes.push(codePoint); } else if (codePoint < 0x800) { if ((units -= 2) < 0) break; bytes.push( (codePoint >> 0x6) | 0xc0, (codePoint & 0x3f) | 0x80 ); } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break; bytes.push( (codePoint >> 0xc) | 0xe0, ((codePoint >> 0x6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80 ); } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break; bytes.push( (codePoint >> 0x12) | 0xf0, ((codePoint >> 0xc) & 0x3f) | 0x80, ((codePoint >> 0x6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80 ); } else { throw new Error("Invalid code point"); } } return bytes; } function asciiToBytes(str) { var byteArray = []; for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xff); } return byteArray; } function utf16leToBytes(str, units) { var c, hi, lo; var byteArray = []; for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break; c = str.charCodeAt(i); hi = c >> 8; lo = c % 256; byteArray.push(lo); byteArray.push(hi); } return byteArray; } function base64ToBytes(str) { return base64.toByteArray(base64clean(str)); } function blitBuffer(src, dst, offset, length) { for (var i = 0; i < length; ++i) { if (i + offset >= dst.length || i >= src.length) break; dst[i + offset] = src[i]; } return i; } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass // the `instanceof` check but they should be treated as of that type. // See: https://github.com/feross/buffer/issues/166 function isInstance(obj, type) { return ( obj instanceof type || (obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name) ); } function numberIsNaN(obj) { // For IE11 support return obj !== obj; // eslint-disable-line no-self-compare } // Create lookup table for `toString('hex')` // See: https://github.com/feross/buffer/issues/219 var hexSliceLookupTable = (function () { var alphabet = "0123456789abcdef"; var table = new Array(256); for (var i = 0; i < 16; ++i) { var i16 = i * 16; for (var j = 0; j < 16; ++j) { table[i16 + j] = alphabet[i] + alphabet[j]; } } return table; })(); /***/ }, /***/ 8898: /***/ function (__unused_webpack_module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var nBits = -7; var i = isLE ? nBytes - 1 : 0; var d = isLE ? -1 : 1; var s = buffer[offset + i]; i += d; e = s & ((1 << -nBits) - 1); s >>= -nBits; nBits += eLen; for ( ; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8 ) {} m = e & ((1 << -nBits) - 1); e >>= -nBits; nBits += mLen; for ( ; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8 ) {} if (e === 0) { e = 1 - eBias; } else if (e === eMax) { return m ? NaN : (s ? -1 : 1) * Infinity; } else { m = m + Math.pow(2, mLen); e = e - eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - mLen); }; exports.write = function ( buffer, value, offset, isLE, mLen, nBytes ) { var e, m, c; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; var i = isLE ? 0 : nBytes - 1; var d = isLE ? 1 : -1; var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; value = Math.abs(value); if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0; e = eMax; } else { e = Math.floor(Math.log(value) / Math.LN2); if (value * (c = Math.pow(2, -e)) < 1) { e--; c *= 2; } if (e + eBias >= 1) { value += rt / c; } else { value += rt * Math.pow(2, 1 - eBias); } if (value * c >= 2) { e++; c /= 2; } if (e + eBias >= eMax) { m = 0; e = eMax; } else if (e + eBias >= 1) { m = (value * c - 1) * Math.pow(2, mLen); e = e + eBias; } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); e = 0; } } for ( ; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8 ) {} e = (e << mLen) | m; eLen += mLen; for ( ; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8 ) {} buffer[offset + i - d] |= s * 128; }; /***/ }, /***/ 7579: /***/ function () { /* (ignored) */ /***/ }, /***/ 7326: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ _assertThisInitialized; }, /* harmony export */ }); function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" ); } return self; } /***/ }, /***/ 8852: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function () { return /* binding */ _construct; }, }); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js var setPrototypeOf = __webpack_require__(9611); // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call( Reflect.construct(Boolean, [], function () {}) ); return true; } catch (e) { return false; } } // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/construct.js function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) (0, setPrototypeOf /* default */.Z)( instance, Class.prototype ); return instance; }; } return _construct.apply(null, arguments); } /***/ }, /***/ 7462: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ _extends; }, /* harmony export */ }); function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /***/ }, /***/ 136: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ _inherits; }, /* harmony export */ }); /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9611); function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError( "Super expression must either be null or a function" ); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true, }, }), writable: false, }); if (superClass) (0, _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */.Z)( subClass, superClass ); } /***/ }, /***/ 4578: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ _inheritsLoose; }, /* harmony export */ }); /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9611); function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; (0, _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */.Z)( subClass, superClass ); } /***/ }, /***/ 9611: /***/ function ( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function () { return /* binding */ _setPrototypeOf; }, /* harmony export */ }); function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /***/ }, }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__((__webpack_require__.s = moduleId)); }; /******/ __webpack_require__.O(0, [544, 774, 888, 179], function () { return __webpack_exec__(8581); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ }, ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 405 ], { /***/ 7154: /***/ function(module) { function _extends() { return module.exports = _extends = Object.assign || function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }, module.exports.__esModule = !0, module.exports.default = module.exports, _extends.apply(this, arguments); } module.exports = _extends, module.exports.__esModule = !0, module.exports.default = module.exports; /***/ }, /***/ 562: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Ki: function() { return /* binding */ toUint8; }, /* harmony export */ tm: function() { return /* binding */ bytesToNumber; }, /* harmony export */ hL: function() { return /* binding */ numberToBytes; }, /* harmony export */ d3: function() { return /* binding */ bytesToString; }, /* harmony export */ qX: function() { return /* binding */ stringToBytes; }, /* harmony export */ lx: function() { return /* binding */ concatTypedArrays; }, /* harmony export */ G3: function() { return /* binding */ bytesMatch; } }); /* unused harmony exports countBits, countBytes, padStart, isTypedArray, toHexString, toBinaryString, ENDIANNESS, IS_BIG_ENDIAN, IS_LITTLE_ENDIAN, sliceBytes, reverseBytes */ /* harmony import */ var a, b, global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908), global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_0__), toUint8 = function(bytes) { return bytes instanceof Uint8Array ? bytes : (Array.isArray(bytes) || ArrayBuffer.isView(bytes) || bytes instanceof ArrayBuffer || (bytes = "number" != typeof bytes || "number" == typeof bytes && bytes != bytes ? 0 : [ bytes ]), new Uint8Array(bytes && bytes.buffer || bytes, bytes && bytes.byteOffset || 0, bytes && bytes.byteLength || 0)); }, BigInt = global_window__WEBPACK_IMPORTED_MODULE_0___default().BigInt || Number, BYTE_TABLE = [ BigInt("0x1"), BigInt("0x100"), BigInt("0x10000"), BigInt("0x1000000"), BigInt("0x100000000"), BigInt("0x10000000000"), BigInt("0x1000000000000"), BigInt("0x100000000000000"), BigInt("0x10000000000000000") ]; 0xff === (b = new Uint8Array((a = new Uint16Array([ 0xffcc ])).buffer, a.byteOffset, a.byteLength))[0] || b[0]; var bytesToNumber = function(bytes, _temp) { var _ref = void 0 === _temp ? {} : _temp, _ref$signed = _ref.signed, _ref$le = _ref.le, le = void 0 !== _ref$le && _ref$le; bytes = toUint8(bytes); var fn = le ? "reduce" : "reduceRight", number = (bytes[fn] ? bytes[fn] : Array.prototype[fn]).call(bytes, function(total, byte, i) { var exponent = le ? i : Math.abs(i + 1 - bytes.length); return total + BigInt(byte) * BYTE_TABLE[exponent]; }, BigInt(0)); if (void 0 !== _ref$signed && _ref$signed) { var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1); (number = BigInt(number)) > max && (number -= max, number -= max, number -= BigInt(2)); } return Number(number); }, numberToBytes = function(number, _temp2) { var _ref2$le = (void 0 === _temp2 ? {} : _temp2).le, le = void 0 !== _ref2$le && _ref2$le; ("bigint" != typeof number && "number" != typeof number || "number" == typeof number && number != number) && (number = 0); for(var byteCount = Math.ceil((number = BigInt(number)).toString(2).length / 8), bytes = new Uint8Array(new ArrayBuffer(byteCount)), i = 0; i < byteCount; i++){ var byteIndex = le ? i : Math.abs(i + 1 - bytes.length); bytes[byteIndex] = Number(number / BYTE_TABLE[i] & BigInt(0xff)), number < 0 && (bytes[byteIndex] = Math.abs(~bytes[byteIndex]), bytes[byteIndex] -= 0 === i ? 1 : 2); } return bytes; }, bytesToString = function(bytes) { if (!bytes) return ""; // TODO: should toUint8 handle cases where we only have 8 bytes // but report more since this is a Uint16+ Array? bytes = Array.prototype.slice.call(bytes); var string = String.fromCharCode.apply(null, toUint8(bytes)); try { return decodeURIComponent(escape(string)); } catch (e) { // if decodeURIComponent/escape fails, we are dealing with partial // or full non string data. Just return the potentially garbled string. } return string; }, stringToBytes = function(string, stringIsBytes) { if ("string" != typeof string && string && "function" == typeof string.toString && (string = string.toString()), "string" != typeof string) return new Uint8Array(); // If the string already is bytes, we don't have to do this stringIsBytes || (string = unescape(encodeURIComponent(string))); for(var view = new Uint8Array(string.length), i = 0; i < string.length; i++)view[i] = string.charCodeAt(i); return view; }, concatTypedArrays = function() { for(var _len = arguments.length, buffers = Array(_len), _key = 0; _key < _len; _key++)buffers[_key] = arguments[_key]; if ((buffers = buffers.filter(function(b) { return b && (b.byteLength || b.length) && "string" != typeof b; })).length <= 1) // for 0 length we will return empty uint8 // for 1 length we return the first uint8 return toUint8(buffers[0]); var tempBuffer = new Uint8Array(buffers.reduce(function(total, buf, i) { return total + (buf.byteLength || buf.length); }, 0)), offset = 0; return buffers.forEach(function(buf) { buf = toUint8(buf), tempBuffer.set(buf, offset), offset += buf.byteLength; }), tempBuffer; }, bytesMatch = function(a, b, _temp3) { var _ref3 = void 0 === _temp3 ? {} : _temp3, _ref3$offset = _ref3.offset, offset = void 0 === _ref3$offset ? 0 : _ref3$offset, _ref3$mask = _ref3.mask, mask = void 0 === _ref3$mask ? [] : _ref3$mask; a = toUint8(a); var fn = (b = toUint8(b)).every ? b.every : Array.prototype.every; return b.length && a.length - offset >= b.length && // ie 11 doesn't support every on uin8 fn.call(b, function(bByte, i) { return bByte === (mask[i] ? mask[i] & a[offset + i] : a[offset + i]); }); }; /***/ }, /***/ 2260: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ws: function() { return /* binding */ translateLegacyCodec; }, /* harmony export */ kS: function() { return /* binding */ parseCodecs; }, /* harmony export */ Jg: function() { return /* binding */ codecsFromDefault; }, /* harmony export */ KL: function() { return /* binding */ isAudioCodec; }, /* harmony export */ _5: function() { return /* binding */ getMimeForCodec; }, /* harmony export */ p7: function() { return /* binding */ browserSupportsCodec; }, /* harmony export */ Hi: function() { return /* binding */ muxerSupportsCodec; }, /* harmony export */ lA: function() { return /* binding */ DEFAULT_AUDIO_CODEC; }, /* harmony export */ xz: function() { return /* binding */ DEFAULT_VIDEO_CODEC; } }); /* unused harmony exports translateLegacyCodecs, mapLegacyAvcCodecs, isVideoCodec, isTextCodec */ /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908), global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_0__), regexs = { // to determine mime types mp4: /^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/, webm: /^(vp0?[89]|av0?1|opus|vorbis)/, ogg: /^(vp0?[89]|theora|flac|opus|vorbis)/, // to determine if a codec is audio or video video: /^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/, audio: /^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/, text: /^(stpp.ttml.im1t)/, // mux.js support regex muxerVideo: /^(avc0?1)/, muxerAudio: /^(mp4a)/, // match nothing as muxer does not support text right now. // there cannot never be a character before the start of a string // so this matches nothing. muxerText: /a^/ }, mediaTypes = [ "video", "audio", "text" ], upperMediaTypes = [ "Video", "Audio", "Text" ], translateLegacyCodec = function(codec) { return codec ? codec.replace(/avc1\.(\d+)\.(\d+)/i, function(orig, profile, avcLevel) { return "avc1." + ("00" + Number(profile).toString(16)).slice(-2) + "00" + ("00" + Number(avcLevel).toString(16)).slice(-2); }) : codec; }, parseCodecs = function(codecString) { void 0 === codecString && (codecString = ""); var codecs = codecString.split(","), result = []; return codecs.forEach(function(codec) { var codecType; codec = codec.trim(), mediaTypes.forEach(function(name) { var match = regexs[name].exec(codec.toLowerCase()); if (match && !(match.length <= 1)) { codecType = name; // maintain codec case var type = codec.substring(0, match[1].length), details = codec.replace(type, ""); result.push({ type: type, details: details, mediaType: name }); } }), codecType || result.push({ type: codec, details: "", mediaType: "unknown" }); }), result; }, codecsFromDefault = function(master, audioGroupId) { if (!master.mediaGroups.AUDIO || !audioGroupId) return null; var audioGroup = master.mediaGroups.AUDIO[audioGroupId]; if (!audioGroup) return null; for(var name in audioGroup){ var audioType = audioGroup[name]; if (audioType.default && audioType.playlists) // codec should be the same for all playlists within the audio type return parseCodecs(audioType.playlists[0].attributes.CODECS); } return null; }, isAudioCodec = function(codec) { return void 0 === codec && (codec = ""), regexs.audio.test(codec.trim().toLowerCase()); }, getMimeForCodec = function(codecString) { if (codecString && "string" == typeof codecString) { var codec, codecs = codecString.toLowerCase().split(",").map(function(c) { return translateLegacyCodec(c.trim()); }), type = "video"; // default to video type // audio 1 === codecs.length && isAudioCodec(codecs[0]) ? type = "audio" : 1 === codecs.length && (void 0 === (codec = codecs[0]) && (codec = ""), regexs.text.test(codec.trim().toLowerCase())) && // text uses application/<container> for now (type = "application"); // default the container to mp4 var container = "mp4"; // every codec must be able to go into the container return codecs.every(function(c) { return regexs.mp4.test(c); }) ? container = "mp4" : codecs.every(function(c) { return regexs.webm.test(c); }) ? container = "webm" : codecs.every(function(c) { return regexs.ogg.test(c); }) && (container = "ogg"), type + "/" + container + ';codecs="' + codecString + '"'; } }, browserSupportsCodec = function(codecString) { return void 0 === codecString && (codecString = ""), global_window__WEBPACK_IMPORTED_MODULE_0___default().MediaSource && global_window__WEBPACK_IMPORTED_MODULE_0___default().MediaSource.isTypeSupported && global_window__WEBPACK_IMPORTED_MODULE_0___default().MediaSource.isTypeSupported(getMimeForCodec(codecString)) || !1; }, muxerSupportsCodec = function(codecString) { return void 0 === codecString && (codecString = ""), codecString.toLowerCase().split(",").every(function(codec) { codec = codec.trim(); // any match is supported. for(var i = 0; i < upperMediaTypes.length; i++)if (regexs["muxer" + upperMediaTypes[i]].test(codec)) return !0; return !1; }); }, DEFAULT_AUDIO_CODEC = "mp4a.40.2", DEFAULT_VIDEO_CODEC = "avc1.4d400d"; /***/ }, /***/ 6185: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Xm: function() { return /* binding */ detectContainerForBytes; }, cz: function() { return /* binding */ isLikelyFmp4MediaSegment; } }); // UNUSED EXPORTS: isLikely // EXTERNAL MODULE: ./node_modules/@videojs/vhs-utils/es/byte-helpers.js var DESCRIPTORS, byte_helpers = __webpack_require__(562); // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/codec-helpers.js new Uint8Array([ // O, p, u, s 0x4f, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 ]); // https://wiki.xiph.org/OggOpus var normalizePath = function(path) { return "string" == typeof path ? (0, byte_helpers /* stringToBytes */ .qX)(path) : path; }, parseDescriptors = function(bytes) { bytes = (0, byte_helpers /* toUint8 */ .Ki)(bytes); for(var results = [], i = 0; bytes.length > i;){ var tag = bytes[i], size = 0, headerSize = 0, byte = bytes[++headerSize]; for(headerSize++; 0x80 & byte;)size = (0x7f & byte) << 7, byte = bytes[headerSize], headerSize++; size += 0x7f & byte; for(var z = 0; z < DESCRIPTORS.length; z++){ var _DESCRIPTORS$z = DESCRIPTORS[z], id = _DESCRIPTORS$z.id, parser = _DESCRIPTORS$z.parser; if (tag === id) { results.push(parser(bytes.subarray(headerSize, headerSize + size))); break; } } i += size + headerSize; } return results; }; DESCRIPTORS = [ { id: 0x03, parser: function(bytes) { var desc = { tag: 0x03, id: bytes[0] << 8 | bytes[1], flags: bytes[2], size: 3, dependsOnEsId: 0, ocrEsId: 0, descriptors: [], url: "" }; // depends on es id if (0x80 & desc.flags && (desc.dependsOnEsId = bytes[desc.size] << 8 | bytes[desc.size + 1], desc.size += 2), 0x40 & desc.flags) { var len = bytes[desc.size]; desc.url = (0, byte_helpers /* bytesToString */ .d3)(bytes.subarray(desc.size + 1, desc.size + 1 + len)), desc.size += len; } // ocr es id return 0x20 & desc.flags && (desc.ocrEsId = bytes[desc.size] << 8 | bytes[desc.size + 1], desc.size += 2), desc.descriptors = parseDescriptors(bytes.subarray(desc.size)) || [], desc; } }, { id: 0x04, parser: function(bytes) { return { tag: 0x04, oti: bytes[0], streamType: bytes[1], bufferSize: bytes[2] << 16 | bytes[3] << 8 | bytes[4], maxBitrate: bytes[5] << 24 | bytes[6] << 16 | bytes[7] << 8 | bytes[8], avgBitrate: bytes[9] << 24 | bytes[10] << 16 | bytes[11] << 8 | bytes[12], descriptors: parseDescriptors(bytes.subarray(13)) }; } }, { id: 0x05, parser: function(bytes) { // DecoderSpecificInfo return { tag: 0x05, bytes: bytes }; } }, { id: 0x06, parser: function(bytes) { // SLConfigDescriptor return { tag: 0x06, bytes: bytes }; } } ]; /** * find any number of boxes by name given a path to it in an iso bmff * such as mp4. * * @param {TypedArray} bytes * bytes for the iso bmff to search for boxes in * * @param {Uint8Array[]|string[]|string|Uint8Array} name * An array of paths or a single path representing the name * of boxes to search through in bytes. Paths may be * uint8 (character codes) or strings. * * @param {boolean} [complete=false] * Should we search only for complete boxes on the final path. * This is very useful when you do not want to get back partial boxes * in the case of streaming files. * * @return {Uint8Array[]} * An array of the end paths that we found. */ var findBox = function findBox(bytes, paths, complete) { void 0 === complete && (complete = !1), paths = Array.isArray(paths1 = paths) ? paths1.map(function(p) { return normalizePath(p); }) : [ normalizePath(paths1) ], bytes = (0, byte_helpers /* toUint8 */ .Ki)(bytes); var paths1, results = []; if (!paths.length) // short-circuit the search for empty paths return results; for(var i = 0; i < bytes.length;){ var size = (bytes[i] << 24 | bytes[i + 1] << 16 | bytes[i + 2] << 8 | bytes[i + 3]) >>> 0, type = bytes.subarray(i + 4, i + 8); if (0 === size) break; var end = i + size; if (end > bytes.length) { // this box is bigger than the number of bytes we have // and complete is set, we cannot find any more boxes. if (complete) break; end = bytes.length; } var data = bytes.subarray(i + 8, end); (0, byte_helpers /* bytesMatch */ .G3)(type, paths[0]) && (1 === paths.length ? // this is the end of the path and we've found the box we were // looking for results.push(data) : // recursively search for the next box along the path results.push.apply(results, findBox(data, paths.slice(1), complete))), i = end; } // we've finished searching all of bytes return results; }, EBML_TAGS = { EBML: (0, byte_helpers /* toUint8 */ .Ki)([ 0x1a, 0x45, 0xdf, 0xa3 ]), DocType: (0, byte_helpers /* toUint8 */ .Ki)([ 0x42, 0x82 ]), Segment: (0, byte_helpers /* toUint8 */ .Ki)([ 0x18, 0x53, 0x80, 0x67 ]), SegmentInfo: (0, byte_helpers /* toUint8 */ .Ki)([ 0x15, 0x49, 0xa9, 0x66 ]), Tracks: (0, byte_helpers /* toUint8 */ .Ki)([ 0x16, 0x54, 0xae, 0x6b ]), Track: (0, byte_helpers /* toUint8 */ .Ki)([ 0xae ]), TrackNumber: (0, byte_helpers /* toUint8 */ .Ki)([ 0xd7 ]), DefaultDuration: (0, byte_helpers /* toUint8 */ .Ki)([ 0x23, 0xe3, 0x83 ]), TrackEntry: (0, byte_helpers /* toUint8 */ .Ki)([ 0xae ]), TrackType: (0, byte_helpers /* toUint8 */ .Ki)([ 0x83 ]), FlagDefault: (0, byte_helpers /* toUint8 */ .Ki)([ 0x88 ]), CodecID: (0, byte_helpers /* toUint8 */ .Ki)([ 0x86 ]), CodecPrivate: (0, byte_helpers /* toUint8 */ .Ki)([ 0x63, 0xa2 ]), VideoTrack: (0, byte_helpers /* toUint8 */ .Ki)([ 0xe0 ]), AudioTrack: (0, byte_helpers /* toUint8 */ .Ki)([ 0xe1 ]), // Not used yet, but will be used for live webm/mkv // see https://www.matroska.org/technical/basics.html#block-structure // see https://www.matroska.org/technical/basics.html#simpleblock-structure Cluster: (0, byte_helpers /* toUint8 */ .Ki)([ 0x1f, 0x43, 0xb6, 0x75 ]), Timestamp: (0, byte_helpers /* toUint8 */ .Ki)([ 0xe7 ]), TimestampScale: (0, byte_helpers /* toUint8 */ .Ki)([ 0x2a, 0xd7, 0xb1 ]), BlockGroup: (0, byte_helpers /* toUint8 */ .Ki)([ 0xa0 ]), BlockDuration: (0, byte_helpers /* toUint8 */ .Ki)([ 0x9b ]), Block: (0, byte_helpers /* toUint8 */ .Ki)([ 0xa1 ]), SimpleBlock: (0, byte_helpers /* toUint8 */ .Ki)([ 0xa3 ]) }, LENGTH_TABLE = [ 128, 64, 32, 16, 8, 4, 2, 1 ], getLength = function(byte) { for(var len = 1, i = 0; i < LENGTH_TABLE.length && !(byte & LENGTH_TABLE[i]); i++)len++; return len; }, getvint = function(bytes, offset, removeLength, signed) { void 0 === removeLength && (removeLength = !0), void 0 === signed && (signed = !1); var length = getLength(bytes[offset]), valueBytes = bytes.subarray(offset, offset + length); return removeLength && (valueBytes = Array.prototype.slice.call(bytes, offset, offset + length), valueBytes[0] ^= LENGTH_TABLE[length - 1]), { length: length, value: (0, byte_helpers /* bytesToNumber */ .tm)(valueBytes, { signed: signed }), bytes: valueBytes }; }, ebml_helpers_normalizePath = function normalizePath(path) { return "string" == typeof path ? path.match(/.{1,2}/g).map(function(p) { return normalizePath(p); }) : "number" == typeof path ? (0, byte_helpers /* numberToBytes */ .hL)(path) : path; }, getInfinityDataSize = function getInfinityDataSize(id, bytes, offset) { if (offset >= bytes.length) return bytes.length; var innerid = getvint(bytes, offset, !1); if ((0, byte_helpers /* bytesMatch */ .G3)(id.bytes, innerid.bytes)) return offset; var dataHeader = getvint(bytes, offset + innerid.length); return getInfinityDataSize(id, bytes, offset + dataHeader.length + dataHeader.value + innerid.length); }, findEbml = function findEbml(bytes, paths) { paths = Array.isArray(paths1 = paths) ? paths1.map(function(p) { return ebml_helpers_normalizePath(p); }) : [ ebml_helpers_normalizePath(paths1) ], bytes = (0, byte_helpers /* toUint8 */ .Ki)(bytes); var paths1, results = []; if (!paths.length) return results; for(var i = 0; i < bytes.length;){ var id = getvint(bytes, i, !1), dataHeader = getvint(bytes, i + id.length), dataStart = i + id.length + dataHeader.length; 0x7f === dataHeader.value && (dataHeader.value = getInfinityDataSize(id, bytes, dataStart), dataHeader.value !== bytes.length && (dataHeader.value -= dataStart)); var dataEnd = dataStart + dataHeader.value > bytes.length ? bytes.length : dataStart + dataHeader.value, data = bytes.subarray(dataStart, dataEnd); (0, byte_helpers /* bytesMatch */ .G3)(paths[0], id.bytes) && (1 === paths.length ? // this is the end of the paths and we've found the tag we were // looking for results.push(data) : // recursively search for the next tag inside of the data // of this one results = results.concat(findEbml(data, paths.slice(1)))), i += id.length + dataHeader.length + data.length; } return results; }, id3_helpers = __webpack_require__(8925), NAL_TYPE_ONE = (0, byte_helpers /* toUint8 */ .Ki)([ 0x00, 0x00, 0x00, 0x01 ]), NAL_TYPE_TWO = (0, byte_helpers /* toUint8 */ .Ki)([ 0x00, 0x00, 0x01 ]), EMULATION_PREVENTION = (0, byte_helpers /* toUint8 */ .Ki)([ 0x00, 0x00, 0x03 ]), discardEmulationPreventionBytes = function(bytes) { for(var positions = [], i = 1; i < bytes.length - 2;)(0, byte_helpers /* bytesMatch */ .G3)(bytes.subarray(i, i + 3), EMULATION_PREVENTION) && (positions.push(i + 2), i++), i++; // If no Emulation Prevention Bytes were found just return the original // array if (0 === positions.length) return bytes; // Create a new array to hold the NAL unit data var newLength = bytes.length - positions.length, newData = new Uint8Array(newLength), sourceIndex = 0; for(i = 0; i < newLength; sourceIndex++, i++)sourceIndex === positions[0] && (// Skip this byte sourceIndex++, positions.shift()), newData[i] = bytes[sourceIndex]; return newData; }, findNal = function(bytes, dataType, types, nalLimit) { void 0 === nalLimit && (nalLimit = 1 / 0), bytes = (0, byte_helpers /* toUint8 */ .Ki)(bytes), types = [].concat(types); // we reach the end of bytes // we reach the maximum number of nals they want to seach // NOTE: that we disregard nalLimit when we have found the start // of the nal we want so that we can find the end of the nal we want. for(var nalStart, i = 0, nalsFound = 0; i < bytes.length && (nalsFound < nalLimit || nalStart);){ var nalOffset = void 0; // find the next nal unit if ((0, byte_helpers /* bytesMatch */ .G3)(bytes.subarray(i), NAL_TYPE_ONE) ? nalOffset = 4 : (0, byte_helpers /* bytesMatch */ .G3)(bytes.subarray(i), NAL_TYPE_TWO) && (nalOffset = 3), !nalOffset) { i++; continue; } if (nalsFound++, nalStart) return discardEmulationPreventionBytes(bytes.subarray(nalStart, i)); var nalType = void 0; "h264" === dataType ? nalType = 0x1f & bytes[i + nalOffset] : "h265" === dataType && (nalType = bytes[i + nalOffset] >> 1 & 0x3f), -1 !== types.indexOf(nalType) && (nalStart = i + nalOffset), i += nalOffset + ("h264" === dataType ? 1 : 2); } return bytes.subarray(0, 0); }, CONSTANTS = { // "webm" string literal in hex webm: (0, byte_helpers /* toUint8 */ .Ki)([ 0x77, 0x65, 0x62, 0x6d ]), // "matroska" string literal in hex matroska: (0, byte_helpers /* toUint8 */ .Ki)([ 0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61 ]), // "fLaC" string literal in hex flac: (0, byte_helpers /* toUint8 */ .Ki)([ 0x66, 0x4c, 0x61, 0x43 ]), // "OggS" string literal in hex ogg: (0, byte_helpers /* toUint8 */ .Ki)([ 0x4f, 0x67, 0x67, 0x53 ]), // ac-3 sync byte, also works for ec-3 as that is simply a codec // of ac-3 ac3: (0, byte_helpers /* toUint8 */ .Ki)([ 0x0b, 0x77 ]), // "RIFF" string literal in hex used for wav and avi riff: (0, byte_helpers /* toUint8 */ .Ki)([ 0x52, 0x49, 0x46, 0x46 ]), // "AVI" string literal in hex avi: (0, byte_helpers /* toUint8 */ .Ki)([ 0x41, 0x56, 0x49 ]), // "WAVE" string literal in hex wav: (0, byte_helpers /* toUint8 */ .Ki)([ 0x57, 0x41, 0x56, 0x45 ]), // "ftyp3g" string literal in hex "3gp": (0, byte_helpers /* toUint8 */ .Ki)([ 0x66, 0x74, 0x79, 0x70, 0x33, 0x67 ]), // "ftyp" string literal in hex mp4: (0, byte_helpers /* toUint8 */ .Ki)([ 0x66, 0x74, 0x79, 0x70 ]), // "styp" string literal in hex fmp4: (0, byte_helpers /* toUint8 */ .Ki)([ 0x73, 0x74, 0x79, 0x70 ]), // "ftypqt" string literal in hex mov: (0, byte_helpers /* toUint8 */ .Ki)([ 0x66, 0x74, 0x79, 0x70, 0x71, 0x74 ]), // moov string literal in hex moov: (0, byte_helpers /* toUint8 */ .Ki)([ 0x6d, 0x6f, 0x6f, 0x76 ]), // moof string literal in hex moof: (0, byte_helpers /* toUint8 */ .Ki)([ 0x6d, 0x6f, 0x6f, 0x66 ]) }, _isLikely = { aac: function(bytes) { var offset = (0, id3_helpers /* getId3Offset */ .c)(bytes); return (0, byte_helpers /* bytesMatch */ .G3)(bytes, [ 0xff, 0x10 ], { offset: offset, mask: [ 0xff, 0x16 ] }); }, mp3: function(bytes) { var offset = (0, id3_helpers /* getId3Offset */ .c)(bytes); return (0, byte_helpers /* bytesMatch */ .G3)(bytes, [ 0xff, 0x02 ], { offset: offset, mask: [ 0xff, 0x06 ] }); }, webm: function(bytes) { var docType = findEbml(bytes, [ EBML_TAGS.EBML, EBML_TAGS.DocType ])[0]; // check if DocType EBML tag is webm return (0, byte_helpers /* bytesMatch */ .G3)(docType, CONSTANTS.webm); }, mkv: function(bytes) { var docType = findEbml(bytes, [ EBML_TAGS.EBML, EBML_TAGS.DocType ])[0]; // check if DocType EBML tag is matroska return (0, byte_helpers /* bytesMatch */ .G3)(docType, CONSTANTS.matroska); }, mp4: function(bytes) { return(// if this file is another base media file format, it is not mp4 !(_isLikely["3gp"](bytes) || _isLikely.mov(bytes)) && (!!((0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.mp4, { offset: 4 }) || (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.fmp4, { offset: 4 }) || (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.moof, { offset: 4 }) || (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.moov, { offset: 4 })) || void 0) // if this file starts with a ftyp or styp box its mp4 ); }, mov: function(bytes) { return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.mov, { offset: 4 }); }, "3gp": function(bytes) { return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS["3gp"], { offset: 4 }); }, ac3: function(bytes) { var offset = (0, id3_helpers /* getId3Offset */ .c)(bytes); return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.ac3, { offset: offset }); }, ts: function(bytes) { if (bytes.length < 189 && bytes.length >= 1) return 0x47 === bytes[0]; for(var i = 0; i + 188 < bytes.length && i < 188;){ if (0x47 === bytes[i] && 0x47 === bytes[i + 188]) return !0; i += 1; } return !1; }, flac: function(bytes) { var offset = (0, id3_helpers /* getId3Offset */ .c)(bytes); return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.flac, { offset: offset }); }, ogg: function(bytes) { return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.ogg); }, avi: function(bytes) { return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.riff) && (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.avi, { offset: 8 }); }, wav: function(bytes) { return (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.riff) && (0, byte_helpers /* bytesMatch */ .G3)(bytes, CONSTANTS.wav, { offset: 8 }); }, h264: function(bytes) { // find seq_parameter_set_rbsp return findNal(bytes, "h264", 7, 3).length; }, h265: function(bytes) { // find video_parameter_set_rbsp or seq_parameter_set_rbsp return findNal(bytes, "h265", [ 32, 33 ], 3).length; } }, isLikelyTypes = Object.keys(_isLikely) // remove ts, h264, h265 .filter(function(t) { return "ts" !== t && "h264" !== t && "h265" !== t; }) // add it back to the bottom .concat([ "ts", "h264", "h265" ]); isLikelyTypes.forEach(function(type) { var isLikelyFn = _isLikely[type]; _isLikely[type] = function(bytes) { return isLikelyFn((0, byte_helpers /* toUint8 */ .Ki)(bytes)); }; }); // export after wrapping // https://en.wikipedia.org/wiki/List_of_file_signatures var detectContainerForBytes = function(bytes) { bytes = (0, byte_helpers /* toUint8 */ .Ki)(bytes); for(var i = 0; i < isLikelyTypes.length; i++){ var type = isLikelyTypes[i]; if (_isLikely[type](bytes)) return type; } return ""; }, isLikelyFmp4MediaSegment = function(bytes) { return findBox(bytes, [ "moof" ]).length > 0; }; // fmp4 is not a container /***/ }, /***/ 6722: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ decodeB64ToUint8Array; } }); /* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8908), global_window__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_0__), Buffer = __webpack_require__(816).Buffer; function decodeB64ToUint8Array(b64Text) { for(var decodedString = global_window__WEBPACK_IMPORTED_MODULE_0___default().atob ? global_window__WEBPACK_IMPORTED_MODULE_0___default().atob(b64Text) : Buffer.from(b64Text, "base64").toString("binary"), array = new Uint8Array(decodedString.length), i = 0; i < decodedString.length; i++)array[i] = decodedString.charCodeAt(i); return array; } /***/ }, /***/ 8925: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ c: function() { return /* binding */ getId3Offset; } }); /* unused harmony export getId3Size */ /* harmony import */ var _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(562), ID3 = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */ .Ki)([ 0x49, 0x44, 0x33 ]), getId3Size = function(bytes, offset) { void 0 === offset && (offset = 0); var flags = (bytes = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */ .Ki)(bytes))[offset + 5], returnSize = bytes[offset + 6] << 21 | bytes[offset + 7] << 14 | bytes[offset + 8] << 7 | bytes[offset + 9]; return (16 & flags) >> 4 ? returnSize + 20 : returnSize + 10; }, getId3Offset = function getId3Offset(bytes, offset) { return (void 0 === offset && (offset = 0), (bytes = (0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .toUint8 */ .Ki)(bytes)).length - offset < 10 || !(0, _byte_helpers_js__WEBPACK_IMPORTED_MODULE_0__ /* .bytesMatch */ .G3)(bytes, ID3, { offset: offset })) ? offset : (offset += getId3Size(bytes, offset), getId3Offset(bytes, offset)); }; /***/ }, /***/ 8485: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ t: function() { return /* binding */ simpleTypeFromSourceType; } }); var MPEGURL_REGEX = /^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i, DASH_REGEX = /^application\/dash\+xml/i, simpleTypeFromSourceType = function(type) { return MPEGURL_REGEX.test(type) ? "hls" : DASH_REGEX.test(type) ? "dash" : "application/vnd.videojs.vhs+json" === type ? "vhs-json" : null; }; /***/ }, /***/ 779: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var url_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9945), url_toolkit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(url_toolkit__WEBPACK_IMPORTED_MODULE_0__), global_window__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8908), global_window__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_1__), DEFAULT_LOCATION = "http://example.com"; /* harmony default export */ __webpack_exports__.Z = function(baseUrl, relativeUrl) { // return early if we don't need to resolve if (/^[a-z]+:/i.test(relativeUrl)) return relativeUrl; // if baseUrl is a data URI, ignore it and resolve everything relative to window.location /^data:/.test(baseUrl) && (baseUrl = global_window__WEBPACK_IMPORTED_MODULE_1___default().location && global_window__WEBPACK_IMPORTED_MODULE_1___default().location.href || ""); // feature detect the behavior we want var nativeURL = "function" == typeof global_window__WEBPACK_IMPORTED_MODULE_1___default().URL, protocolLess = /^\/\//.test(baseUrl), removeLocation = !global_window__WEBPACK_IMPORTED_MODULE_1___default().location && !/\/\//i.test(baseUrl); if (nativeURL ? baseUrl = new (global_window__WEBPACK_IMPORTED_MODULE_1___default()).URL(baseUrl, global_window__WEBPACK_IMPORTED_MODULE_1___default().location || DEFAULT_LOCATION) : /\/\//i.test(baseUrl) || (baseUrl = url_toolkit__WEBPACK_IMPORTED_MODULE_0___default().buildAbsoluteURL(global_window__WEBPACK_IMPORTED_MODULE_1___default().location && global_window__WEBPACK_IMPORTED_MODULE_1___default().location.href || "", baseUrl)), nativeURL) { var newUrl = new URL(relativeUrl, baseUrl); // if we're a protocol-less url, remove the protocol return(// and if we're location-less, remove the location // otherwise, return the url unmodified removeLocation ? newUrl.href.slice(DEFAULT_LOCATION.length) : protocolLess ? newUrl.href.slice(newUrl.protocol.length) : newUrl.href); } return url_toolkit__WEBPACK_IMPORTED_MODULE_0___default().buildAbsoluteURL(baseUrl, relativeUrl); }; /***/ }, /***/ 3490: /***/ function(module, __unused_webpack_exports, __webpack_require__) { "use strict"; var window1 = __webpack_require__(8908); module.exports = function(callback, decodeResponseBody) { return void 0 === decodeResponseBody && (decodeResponseBody = !1), function(err, response, responseBody) { // if the XHR failed, return that error if (err) { callback(err); return; } // if the HTTP status code is 4xx or 5xx, the request also failed if (response.statusCode >= 400 && response.statusCode <= 599) { var cause = responseBody; if (decodeResponseBody) { if (window1.TextDecoder) { var contentTypeHeader, charset = (void 0 === (contentTypeHeader = response.headers && response.headers["content-type"]) && (contentTypeHeader = ""), contentTypeHeader.toLowerCase().split(";").reduce(function(charset, contentType) { var _contentType$split = contentType.split("="), type = _contentType$split[0], value = _contentType$split[1]; return "charset" === type.trim() ? value.trim() : charset; }, "utf-8")); try { cause = new TextDecoder(charset).decode(responseBody); } catch (e) {} } else cause = String.fromCharCode.apply(null, new Uint8Array(responseBody)); } callback({ cause: cause }); return; } // otherwise, request succeeded callback(null, responseBody); }; }; /***/ }, /***/ 9603: /***/ function(module, __unused_webpack_exports, __webpack_require__) { "use strict"; var window1 = __webpack_require__(8908), _extends = __webpack_require__(7154), isFunction = __webpack_require__(7376); createXHR.httpHandler = __webpack_require__(3490); /** * @license * slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/> * Copyright (c) 2014 David Björklund * Available under the MIT license * <https://github.com/kesla/parse-headers/blob/master/LICENCE> */ var parseHeaders = function(headers) { var result = {}; return headers && headers.trim().split("\n").forEach(function(row) { var index = row.indexOf(":"), key = row.slice(0, index).trim().toLowerCase(), value = row.slice(index + 1).trim(); void 0 === result[key] ? result[key] = value : Array.isArray(result[key]) ? result[key].push(value) : result[key] = [ result[key], value ]; }), result; }; function initParams(uri, options, callback) { var params = uri; return isFunction(options) ? (callback = options, "string" == typeof uri && (params = { uri: uri })) : params = _extends({}, options, { uri: uri }), params.callback = callback, params; } function createXHR(uri, options, callback) { return _createXHR(options = initParams(uri, options, callback)); } function _createXHR(options) { if (void 0 === options.callback) throw Error("callback argument missing"); var key, aborted, timeoutTimer, called = !1, callback = function(err, response, body) { called || (called = !0, options.callback(err, response, body)); }; function errorFunc(evt) { return clearTimeout(timeoutTimer), evt instanceof Error || (evt = Error("" + (evt || "Unknown XMLHttpRequest Error"))), evt.statusCode = 0, callback(evt, failureResponse); } // will load the data & process the response in a special response object function loadFunc() { if (!aborted) { clearTimeout(timeoutTimer); var status = options.useXDR && void 0 === xhr.status ? 200 : 1223 === xhr.status ? 204 : xhr.status, response = failureResponse, err = null; return 0 !== status ? (response = { body: function() { // Chrome with requestType=blob throws errors arround when even testing access to responseText var body = void 0; if (body = xhr.response ? xhr.response : xhr.responseText || function(xhr) { // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException" // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML. try { if ("document" === xhr.responseType) return xhr.responseXML; var firefoxBugTakenEffect = xhr.responseXML && "parsererror" === xhr.responseXML.documentElement.nodeName; if ("" === xhr.responseType && !firefoxBugTakenEffect) return xhr.responseXML; } catch (e) {} return null; }(xhr), isJson) try { body = JSON.parse(body); } catch (e) {} return body; }(), statusCode: status, method: method, headers: {}, url: uri, rawRequest: xhr }, xhr.getAllResponseHeaders && //remember xhr can in fact be XDR for CORS in IE (response.headers = parseHeaders(xhr.getAllResponseHeaders()))) : err = Error("Internal XMLHttpRequest Error"), callback(err, response, response.body); } } var xhr = options.xhr || null; xhr || (xhr = options.cors || options.useXDR ? new createXHR.XDomainRequest() : new createXHR.XMLHttpRequest()); var uri = xhr.url = options.uri || options.url, method = xhr.method = options.method || "GET", body = options.body || options.data, headers = xhr.headers = options.headers || {}, sync = !!options.sync, isJson = !1, failureResponse = { body: void 0, headers: {}, statusCode: 0, method: method, url: uri, rawRequest: xhr }; if ("json" in options && !1 !== options.json && (isJson = !0, headers.accept || headers.Accept || (headers.Accept = "application/json"), "GET" !== method && "HEAD" !== method && (headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"), body = JSON.stringify(!0 === options.json ? body : options.json))), xhr.onreadystatechange = function() { 4 === xhr.readyState && setTimeout(loadFunc, 0); }, xhr.onload = loadFunc, xhr.onerror = errorFunc, xhr.onprogress = function() { // IE must die }, xhr.onabort = function() { aborted = !0; }, xhr.ontimeout = errorFunc, xhr.open(method, uri, !sync, options.username, options.password), sync || (xhr.withCredentials = !!options.withCredentials), !sync && options.timeout > 0 && (timeoutTimer = setTimeout(function() { if (!aborted) { aborted = !0, xhr.abort("timeout"); var e = Error("XMLHttpRequest timeout"); e.code = "ETIMEDOUT", errorFunc(e); } }, options.timeout)), xhr.setRequestHeader) for(key in headers)headers.hasOwnProperty(key) && xhr.setRequestHeader(key, headers[key]); else if (options.headers && !function(obj) { for(var i in obj)if (obj.hasOwnProperty(i)) return !1; return !0; }(options.headers)) throw Error("Headers cannot be set on an XDomainRequest object"); return "responseType" in options && (xhr.responseType = options.responseType), "beforeSend" in options && "function" == typeof options.beforeSend && options.beforeSend(xhr), // XMLHttpRequest spec says to pass null as body to indicate no body // See https://github.com/naugtur/xhr/issues/100. xhr.send(body || null), xhr; } module.exports = createXHR, module.exports.default = createXHR, createXHR.XMLHttpRequest = window1.XMLHttpRequest || function() {}, createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window1.XDomainRequest, function(array, iterator) { for(var i = 0; i < array.length; i++)iterator(array[i]); }([ "get", "put", "post", "patch", "head", "delete" ], function(method) { createXHR["delete" === method ? "del" : method] = function(uri, options, callback) { return (options = initParams(uri, options, callback)).method = method.toUpperCase(), _createXHR(options); }; }); /***/ }, /***/ 2167: /***/ function(__unused_webpack_module, exports) { "use strict"; /** * "Shallow freezes" an object to render it immutable. * Uses `Object.freeze` if available, * otherwise the immutability is only in the type. * * Is used to create "enum like" objects. * * @template T * @param {T} object the object to freeze * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default, * allows to inject custom object constructor for tests * @returns {Readonly<T>} * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze */ function freeze(object, oc) { return void 0 === oc && (oc = Object), oc && "function" == typeof oc.freeze ? oc.freeze(object) : object; } /** * All mime types that are allowed as input to `DOMParser.parseFromString` * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec * @see DOMParser.prototype.parseFromString */ var MIME_TYPE = freeze({ /** * `text/html`, the only mime type that triggers treating an XML document as HTML. * * @see DOMParser.SupportedType.isHTML * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration * @see https://en.wikipedia.org/wiki/HTML Wikipedia * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec */ HTML: "text/html", /** * Helper method to check a mime type if it indicates an HTML document * * @param {string} [value] * @returns {boolean} * * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration * @see https://en.wikipedia.org/wiki/HTML Wikipedia * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */ isHTML: function(value) { return value === MIME_TYPE.HTML; }, /** * `application/xml`, the standard mime type for XML documents. * * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303 * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_APPLICATION: "application/xml", /** * `text/html`, an alias for `application/xml`. * * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303 * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia */ XML_TEXT: "text/xml", /** * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace, * but is parsed as an XML document. * * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec * @see https://en.wikipedia.org/wiki/XHTML Wikipedia */ XML_XHTML_APPLICATION: "application/xhtml+xml", /** * `image/svg+xml`, * * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1 * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia */ XML_SVG_IMAGE: "image/svg+xml" }), NAMESPACE = freeze({ /** * The XHTML namespace. * * @see http://www.w3.org/1999/xhtml */ HTML: "http://www.w3.org/1999/xhtml", /** * Checks if `uri` equals `NAMESPACE.HTML`. * * @param {string} [uri] * * @see NAMESPACE.HTML */ isHTML: function(uri) { return uri === NAMESPACE.HTML; }, /** * The SVG namespace. * * @see http://www.w3.org/2000/svg */ SVG: "http://www.w3.org/2000/svg", /** * The `xml:` namespace. * * @see http://www.w3.org/XML/1998/namespace */ XML: "http://www.w3.org/XML/1998/namespace", /** * The `xmlns:` namespace * * @see https://www.w3.org/2000/xmlns/ */ XMLNS: "http://www.w3.org/2000/xmlns/" }); exports.freeze = freeze, exports.MIME_TYPE = MIME_TYPE, exports.NAMESPACE = NAMESPACE; /***/ }, /***/ 6129: /***/ function(__unused_webpack_module, exports, __webpack_require__) { var conventions = __webpack_require__(2167), dom = __webpack_require__(1146), entities = __webpack_require__(1045), sax = __webpack_require__(6925), DOMImplementation = dom.DOMImplementation, NAMESPACE = conventions.NAMESPACE, ParseError = sax.ParseError, XMLReader = sax.XMLReader; function DOMParser(options) { this.options = options || { locator: {} }; } //console.log('#\n\n\n\n\n\n\n####') /** * +ContentHandler+ErrorHandler * +LexicalHandler+EntityResolver2 * -DeclHandler-DTDHandler * * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html */ function DOMHandler() { this.cdata = !1; } function position(locator, node) { node.lineNumber = locator.lineNumber, node.columnNumber = locator.columnNumber; } function _locator(l) { if (l) return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]"; } function _toString(chars, start, length) { return "string" == typeof chars ? chars.substr(start, length) : //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") chars.length >= start + length || start ? new java.lang.String(chars, start, length) + "" : chars; } /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ function appendElement(hander, node) { hander.currentElement ? hander.currentElement.appendChild(node) : hander.doc.appendChild(node); } //appendChild and setAttributeNS are preformance key DOMParser.prototype.parseFromString = function(source, mimeType) { var options = this.options, sax = new XMLReader(), domBuilder = options.domBuilder || new DOMHandler(), errorHandler = options.errorHandler, locator = options.locator, defaultNSMap = options.xmlns || {}, isHTML = /\/x?html?$/.test(mimeType), entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES; return locator && domBuilder.setDocumentLocator(locator), sax.errorHandler = function(errorImpl, domBuilder, locator) { if (!errorImpl) { if (domBuilder instanceof DOMHandler) return domBuilder; errorImpl = domBuilder; } var errorHandler = {}, isCallback = errorImpl instanceof Function; function build(key) { var fn = errorImpl[key]; !fn && isCallback && (fn = 2 == errorImpl.length ? function(msg) { errorImpl(key, msg); } : errorImpl), errorHandler[key] = fn && function(msg) { fn("[xmldom " + key + "]\t" + msg + _locator(locator)); } || function() {}; } return locator = locator || {}, build("warning"), build("error"), build("fatalError"), errorHandler; }(errorHandler, domBuilder, locator), sax.domBuilder = options.domBuilder || domBuilder, isHTML && (defaultNSMap[""] = NAMESPACE.HTML), defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML, source && "string" == typeof source ? sax.parse(source, defaultNSMap, entityMap) : sax.errorHandler.error("invalid doc source"), domBuilder.doc; }, /** * @see org.xml.sax.ContentHandler#startDocument * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html */ DOMHandler.prototype = { startDocument: function() { this.doc = new DOMImplementation().createDocument(null, null, null), this.locator && (this.doc.documentURI = this.locator.systemId); }, startElement: function(namespaceURI, localName, qName, attrs) { var doc = this.doc, el = doc.createElementNS(namespaceURI, qName || localName), len = attrs.length; appendElement(this, el), this.currentElement = el, this.locator && position(this.locator, el); for(var i = 0; i < len; i++){ var namespaceURI = attrs.getURI(i), value = attrs.getValue(i), qName = attrs.getQName(i), attr = doc.createAttributeNS(namespaceURI, qName); this.locator && position(attrs.getLocator(i), attr), attr.value = attr.nodeValue = value, el.setAttributeNode(attr); } }, endElement: function(namespaceURI, localName, qName) { var current = this.currentElement; current.tagName, this.currentElement = current.parentNode; }, startPrefixMapping: function(prefix, uri) {}, endPrefixMapping: function(prefix) {}, processingInstruction: function(target, data) { var ins = this.doc.createProcessingInstruction(target, data); this.locator && position(this.locator, ins), appendElement(this, ins); }, ignorableWhitespace: function(ch, start, length) {}, characters: function(chars, start, length) { //console.log(chars) if (chars = _toString.apply(this, arguments)) { if (this.cdata) var charNode = this.doc.createCDATASection(chars); else var charNode = this.doc.createTextNode(chars); this.currentElement ? this.currentElement.appendChild(charNode) : /^\s*$/.test(chars) && this.doc.appendChild(charNode), this.locator && position(this.locator, charNode); } }, skippedEntity: function(name) {}, endDocument: function() { this.doc.normalize(); }, setDocumentLocator: function(locator) { (this.locator = locator) && // && !('lineNumber' in locator)){ (locator.lineNumber = 0); }, //LexicalHandler comment: function(chars, start, length) { chars = _toString.apply(this, arguments); var comm = this.doc.createComment(chars); this.locator && position(this.locator, comm), appendElement(this, comm); }, startCDATA: function() { //used in characters() methods this.cdata = !0; }, endCDATA: function() { this.cdata = !1; }, startDTD: function(name, publicId, systemId) { var impl = this.doc.implementation; if (impl && impl.createDocumentType) { var dt = impl.createDocumentType(name, publicId, systemId); this.locator && position(this.locator, dt), appendElement(this, dt), this.doc.doctype = dt; } }, /** * @see org.xml.sax.ErrorHandler * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html */ warning: function(error) { console.warn("[xmldom warning]\t" + error, _locator(this.locator)); }, error: function(error) { console.error("[xmldom error]\t" + error, _locator(this.locator)); }, fatalError: function(error) { throw new ParseError(error, this.locator); } }, /* * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html * used method of org.xml.sax.ext.LexicalHandler: * #comment(chars, start, length) * #startCDATA() * #endCDATA() * #startDTD(name, publicId, systemId) * * * IGNORED method of org.xml.sax.ext.LexicalHandler: * #endDTD() * #startEntity(name) * #endEntity(name) * * * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html * IGNORED method of org.xml.sax.ext.DeclHandler * #attributeDecl(eName, aName, type, mode, value) * #elementDecl(name, model) * #externalEntityDecl(name, publicId, systemId) * #internalEntityDecl(name, value) * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html * IGNORED method of org.xml.sax.EntityResolver2 * #resolveEntity(String name,String publicId,String baseURI,String systemId) * #resolveEntity(publicId, systemId) * #getExternalSubset(name, baseURI) * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html * IGNORED method of org.xml.sax.DTDHandler * #notationDecl(name, publicId, systemId) {}; * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; */ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) { DOMHandler.prototype[key] = function() { return null; }; }), exports.DOMParser = DOMParser, dom.DOMImplementation, dom.XMLSerializer; /***/ }, /***/ 1146: /***/ function(__unused_webpack_module, exports, __webpack_require__) { var NAMESPACE = __webpack_require__(2167).NAMESPACE; /** * A prerequisite for `[].filter`, to drop elements that are empty * @param {string} input * @returns {boolean} */ function notEmptyString(input) { return "" !== input; } /** * Adds element as a key to current if it is not already present. * * @param {Record<string, boolean | undefined>} current * @param {string} element * @returns {Record<string, boolean | undefined>} */ function orderedSetReducer(current, element) { return current.hasOwnProperty(element) || (current[element] = !0), current; } /** * @see https://infra.spec.whatwg.org/#ordered-set * @param {string} input * @returns {string[]} */ function toOrderedSet(input) { return input ? Object.keys((input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []).reduce(orderedSetReducer, {})) : []; } function copy(src, dest) { for(var p in src)dest[p] = src[p]; } /** ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? */ function _extends(Class, Super) { var pt = Class.prototype; if (!(pt instanceof Super)) { function t() {} t.prototype = Super.prototype, copy(pt, t = new t()), Class.prototype = pt = t; } pt.constructor != Class && ("function" != typeof Class && console.error("unknown Class:" + Class), pt.constructor = Class); } // Node Types var NodeType = {}, ELEMENT_NODE = NodeType.ELEMENT_NODE = 1, ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2, TEXT_NODE = NodeType.TEXT_NODE = 3, CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4, ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = NodeType.ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7, COMMENT_NODE = NodeType.COMMENT_NODE = 8, DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = NodeType.NOTATION_NODE = 12, ExceptionCode = {}, ExceptionMessage = {}; ExceptionMessage[1] = "Index size error", ExceptionCode.INDEX_SIZE_ERR = 1, ExceptionMessage[2] = "DOMString size error", ExceptionCode.DOMSTRING_SIZE_ERR = 2; var HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", ExceptionCode.HIERARCHY_REQUEST_ERR = 3); ExceptionMessage[4] = "Wrong document", ExceptionCode.WRONG_DOCUMENT_ERR = 4, ExceptionMessage[5] = "Invalid character", ExceptionCode.INVALID_CHARACTER_ERR = 5, ExceptionMessage[6] = "No data allowed", ExceptionCode.NO_DATA_ALLOWED_ERR = 6, ExceptionMessage[7] = "No modification allowed", ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = 7; var NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", ExceptionCode.NOT_FOUND_ERR = 8); ExceptionMessage[9] = "Not supported", ExceptionCode.NOT_SUPPORTED_ERR = 9; var INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", ExceptionCode.INUSE_ATTRIBUTE_ERR = 10); /** * DOM Level 2 * Object DOMException * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html */ function DOMException(code, message) { if (message instanceof Error) var error = message; else error = this, Error.call(this, ExceptionMessage[code]), this.message = ExceptionMessage[code], Error.captureStackTrace && Error.captureStackTrace(this, DOMException); return error.code = code, message && (this.message = this.message + ": " + message), error; } /** * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. * The items in the NodeList are accessible via an integral index, starting from 0. */ function NodeList() {} function LiveNodeList(node, refresh) { this._node = node, this._refresh = refresh, _updateLiveList(this); } function _updateLiveList(list) { var inc = list._node._inc || list._node.ownerDocument._inc; if (list._inc != inc) { var ls = list._refresh(list._node); //console.log(ls.length) __set__(list, "length", ls.length), copy(ls, list), list._inc = inc; } } /** * Objects implementing the NamedNodeMap interface are used * to represent collections of nodes that can be accessed by name. * Note that NamedNodeMap does not inherit from NodeList; * NamedNodeMaps are not maintained in any particular order. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, * and does not imply that the DOM specifies an order to these Nodes. * NamedNodeMap objects in the DOM are live. * used for attributes or DocumentType entities */ function NamedNodeMap() {} function _findNodeIndex(list, node) { for(var i = list.length; i--;)if (list[i] === node) return i; } function _addNamedNode(el, list, newAttr, oldAttr) { if (oldAttr ? list[_findNodeIndex(list, oldAttr)] = newAttr : list[list.length++] = newAttr, el) { newAttr.ownerElement = el; var doc = el.ownerDocument; doc && (oldAttr && _onRemoveAttribute(doc, el, oldAttr), doc && doc._inc++, newAttr.namespaceURI === NAMESPACE.XMLNS && //update namespace (el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value)); } } function _removeNamedNode(el, list, attr) { //console.log('remove attr:'+attr) var i = _findNodeIndex(list, attr); if (i >= 0) { for(var lastIndex = list.length - 1; i < lastIndex;)list[i] = list[++i]; if (list.length = lastIndex, el) { var doc = el.ownerDocument; doc && (_onRemoveAttribute(doc, el, attr), attr.ownerElement = null); } } else throw DOMException(NOT_FOUND_ERR, Error(el.tagName + "@" + attr)); } /** * The DOMImplementation interface represents an object providing methods * which are not dependent on any particular document. * Such an object is returned by the `Document.implementation` property. * * __The individual methods describe the differences compared to the specs.__ * * @constructor * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial) * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard */ function DOMImplementation() {} /** * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 */ function Node() {} function _xmlEncoder(c) { return "<" == c && "&lt;" || ">" == c && "&gt;" || "&" == c && "&amp;" || '"' == c && "&quot;" || "&#" + c.charCodeAt() + ";"; } /** * @param callback return true for continue,false for break * @return boolean true: break visit; */ function _visitNode(node, callback) { if (callback(node)) return !0; if (node = node.firstChild) do if (_visitNode(node, callback)) return !0; while (node = node.nextSibling) } function Document() {} function _onRemoveAttribute(doc, el, newAttr, remove) { doc && doc._inc++, newAttr.namespaceURI === NAMESPACE.XMLNS && //update namespace delete el._nsMap[newAttr.prefix ? newAttr.localName : ""]; } function _onUpdateChild(doc, el, newChild) { if (doc && doc._inc) { doc._inc++; //update childNodes var cs = el.childNodes; if (newChild) cs[cs.length++] = newChild; else { for(//console.log(1) var child = el.firstChild, i = 0; child;)cs[i++] = child, child = child.nextSibling; cs.length = i; } } } /** * attributes; * children; * * writeable properties: * nodeValue,Attr:value,CharacterData:data * prefix */ function _removeChild(parentNode, child) { var previous = child.previousSibling, next = child.nextSibling; return previous ? previous.nextSibling = next : parentNode.firstChild = next, next ? next.previousSibling = previous : parentNode.lastChild = previous, _onUpdateChild(parentNode.ownerDocument, parentNode), child; } /** * preformance key(refChild == null) */ function _insertBefore(parentNode, newChild, nextChild) { var cp = newChild.parentNode; if (cp && cp.removeChild(newChild), newChild.nodeType === DOCUMENT_FRAGMENT_NODE) { var newFirst = newChild.firstChild; if (null == newFirst) return newChild; var newLast = newChild.lastChild; } else newFirst = newLast = newChild; var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; newFirst.previousSibling = pre, newLast.nextSibling = nextChild, pre ? pre.nextSibling = newFirst : parentNode.firstChild = newFirst, null == nextChild ? parentNode.lastChild = newLast : nextChild.previousSibling = newLast; do newFirst.parentNode = parentNode; while (newFirst !== newLast && (newFirst = newFirst.nextSibling)) return _onUpdateChild(parentNode.ownerDocument || parentNode, parentNode), newChild.nodeType == DOCUMENT_FRAGMENT_NODE && (newChild.firstChild = newChild.lastChild = null), newChild; } function Element() { this._nsMap = {}; } function Attr() {} function CharacterData() {} function Text() {} function Comment() {} function CDATASection() {} function DocumentType() {} function Notation() {} function Entity() {} function EntityReference() {} function DocumentFragment() {} function ProcessingInstruction() {} function XMLSerializer() {} function nodeSerializeToString(isHtml, nodeFilter) { var buf = [], refNode = 9 == this.nodeType && this.documentElement || this, prefix = refNode.prefix, uri = refNode.namespaceURI; if (uri && null == prefix) { //console.log(prefix) var prefix = refNode.lookupPrefix(uri); if (null == prefix) //isHTML = true; var visibleNamespaces = [ { namespace: uri, prefix: null } ]; } //console.log('###',this.nodeType,uri,prefix,buf.join('')) return serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces), buf.join(""); } function needNamespaceDefine(node, isHTML, visibleNamespaces) { var prefix = node.prefix || "", uri = node.namespaceURI; // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) , // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl : // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty. // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using) // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared : // > [...] Furthermore, the attribute value [...] must not be an empty string. // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document. if (!uri || "xml" === prefix && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) return !1; for(var i = visibleNamespaces.length; i--;){ var ns = visibleNamespaces[i]; // get namespace prefix if (ns.prefix === prefix) return ns.namespace !== uri; } return !0; } /** * Well-formed constraint: No < in Attribute Values * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <. * @see https://www.w3.org/TR/xml/#CleanAttrVals * @see https://www.w3.org/TR/xml/#NT-AttValue */ function addSerializedAttribute(buf, qualifiedName, value) { buf.push(" ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"'); } function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) { if (visibleNamespaces || (visibleNamespaces = []), nodeFilter) { if (!(node = nodeFilter(node))) return; if ("string" == typeof node) { buf.push(node); return; } //buf.sort.apply(attrs, attributeSorter); } switch(node.nodeType){ case ELEMENT_NODE: var defaultNS, attrs = node.attributes, len = attrs.length, child = node.firstChild, nodeName = node.tagName; isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML; var prefixedNodeName = nodeName; if (!isHTML && !node.prefix && node.namespaceURI) { // lookup current default ns from `xmlns` attribute for(var ai = 0; ai < attrs.length; ai++)if ("xmlns" === attrs.item(ai).name) { defaultNS = attrs.item(ai).value; break; } if (!defaultNS) // lookup current default ns in visibleNamespaces for(var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--){ var namespace = visibleNamespaces[nsi]; if ("" === namespace.prefix && namespace.namespace === node.namespaceURI) { defaultNS = namespace.namespace; break; } } if (defaultNS !== node.namespaceURI) for(var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--){ var namespace = visibleNamespaces[nsi]; if (namespace.namespace === node.namespaceURI) { namespace.prefix && (prefixedNodeName = namespace.prefix + ":" + nodeName); break; } } } buf.push("<", prefixedNodeName); for(var i = 0; i < len; i++){ // add namespaces for attributes var attr = attrs.item(i); "xmlns" == attr.prefix ? visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value }) : "xmlns" == attr.nodeName && visibleNamespaces.push({ prefix: "", namespace: attr.value }); } for(var i = 0; i < len; i++){ var attr = attrs.item(i); if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) { var prefix = attr.prefix || "", uri = attr.namespaceURI; addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri), visibleNamespaces.push({ prefix: prefix, namespace: uri }); } serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces); } // add namespace for current node if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) { var prefix = node.prefix || "", uri = node.namespaceURI; addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri), visibleNamespaces.push({ prefix: prefix, namespace: uri }); } if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) { //if is cdata child node if (buf.push(">"), isHTML && /^script$/i.test(nodeName)) for(; child;)child.data ? buf.push(child.data) : serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice()), child = child.nextSibling; else for(; child;)serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice()), child = child.nextSibling; buf.push("</", prefixedNodeName, ">"); } else buf.push("/>"); // remove added visible namespaces //visibleNamespaces.length = startVisibleNamespaces; return; case DOCUMENT_NODE: case DOCUMENT_FRAGMENT_NODE: for(var child = node.firstChild; child;)serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice()), child = child.nextSibling; return; case ATTRIBUTE_NODE: return addSerializedAttribute(buf, node.name, node.value); case TEXT_NODE: /** * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. * If they are needed elsewhere, they must be escaped using either numeric character references or the strings * `&amp;` and `&lt;` respectively. * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility, * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content, * when that string is not marking the end of a CDATA section. * * In the content of elements, character data is any string of characters * which does not contain the start-delimiter of any markup * and does not include the CDATA-section-close delimiter, `]]>`. * * @see https://www.w3.org/TR/xml/#NT-CharData */ return buf.push(node.data.replace(/[<&]/g, _xmlEncoder).replace(/]]>/g, "]]&gt;")); case CDATA_SECTION_NODE: return buf.push("<![CDATA[", node.data, "]]>"); case COMMENT_NODE: return buf.push("<!--", node.data, "-->"); case DOCUMENT_TYPE_NODE: var pubid = node.publicId, sysid = node.systemId; if (buf.push("<!DOCTYPE ", node.name), pubid) buf.push(" PUBLIC ", pubid), sysid && "." != sysid && buf.push(" ", sysid), buf.push(">"); else if (sysid && "." != sysid) buf.push(" SYSTEM ", sysid, ">"); else { var sub = node.internalSubset; sub && buf.push(" [", sub, "]"), buf.push(">"); } return; case PROCESSING_INSTRUCTION_NODE: return buf.push("<?", node.target, " ", node.data, "?>"); case ENTITY_REFERENCE_NODE: return buf.push("&", node.nodeName, ";"); //case ENTITY_NODE: //case NOTATION_NODE: default: buf.push("??", node.nodeName); } } function __set__(object, key, value) { object[key] = value; } ExceptionMessage[11] = "Invalid state", ExceptionCode.INVALID_STATE_ERR = 11, ExceptionMessage[12] = "Syntax error", ExceptionCode.SYNTAX_ERR = 12, ExceptionMessage[13] = "Invalid modification", ExceptionCode.INVALID_MODIFICATION_ERR = 13, ExceptionMessage[14] = "Invalid namespace", ExceptionCode.NAMESPACE_ERR = 14, ExceptionMessage[15] = "Invalid access", ExceptionCode.INVALID_ACCESS_ERR = 15, DOMException.prototype = Error.prototype, copy(ExceptionCode, DOMException), NodeList.prototype = { /** * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. * @standard level1 */ length: 0, /** * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. * @standard level1 * @param index unsigned long * Index into the collection. * @return Node * The node at the indexth position in the NodeList, or null if that is not a valid index. */ item: function(index) { return this[index] || null; }, toString: function(isHTML, nodeFilter) { for(var buf = [], i = 0; i < this.length; i++)serializeToString(this[i], buf, isHTML, nodeFilter); return buf.join(""); } }, LiveNodeList.prototype.item = function(i) { return _updateLiveList(this), this[i]; }, _extends(LiveNodeList, NodeList), NamedNodeMap.prototype = { length: 0, item: NodeList.prototype.item, getNamedItem: function(key) { for(// if(key.indexOf(':')>0 || key == 'xmlns'){ // return null; // } //console.log() var i = this.length; i--;){ var attr = this[i]; //console.log(attr.nodeName,key) if (attr.nodeName == key) return attr; } }, setNamedItem: function(attr) { var el = attr.ownerElement; if (el && el != this._ownerElement) throw new DOMException(INUSE_ATTRIBUTE_ERR); var oldAttr = this.getNamedItem(attr.nodeName); return _addNamedNode(this._ownerElement, this, attr, oldAttr), oldAttr; }, /* returns Node */ setNamedItemNS: function(attr) { // raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR var oldAttr, el = attr.ownerElement; if (el && el != this._ownerElement) throw new DOMException(INUSE_ATTRIBUTE_ERR); return oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName), _addNamedNode(this._ownerElement, this, attr, oldAttr), oldAttr; }, /* returns Node */ removeNamedItem: function(key) { var attr = this.getNamedItem(key); return _removeNamedNode(this._ownerElement, this, attr), attr; }, //for level2 removeNamedItemNS: function(namespaceURI, localName) { var attr = this.getNamedItemNS(namespaceURI, localName); return _removeNamedNode(this._ownerElement, this, attr), attr; }, getNamedItemNS: function(namespaceURI, localName) { for(var i = this.length; i--;){ var node = this[i]; if (node.localName == localName && node.namespaceURI == namespaceURI) return node; } return null; } }, DOMImplementation.prototype = { /** * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported. * The different implementations fairly diverged in what kind of features were reported. * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use. * * @deprecated It is deprecated and modern browsers return true in all cases. * * @param {string} feature * @param {string} [version] * @returns {boolean} always true * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard */ hasFeature: function(feature, version) { return !0; }, /** * Creates an XML Document object of the specified type with its document element. * * __It behaves slightly different from the description in the living standard__: * - There is no interface/class `XMLDocument`, it returns a `Document` instance. * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared. * - this implementation is not validating names or qualified names * (when parsing XML strings, the SAX parser takes care of that) * * @param {string|null} namespaceURI * @param {string} qualifiedName * @param {DocumentType=null} doctype * @returns {Document} * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial) * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core * * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names */ createDocument: function(namespaceURI, qualifiedName, doctype) { var doc = new Document(); if (doc.implementation = this, doc.childNodes = new NodeList(), doc.doctype = doctype || null, doctype && doc.appendChild(doctype), qualifiedName) { var root = doc.createElementNS(namespaceURI, qualifiedName); doc.appendChild(root); } return doc; }, /** * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`. * * __This behavior is slightly different from the in the specs__: * - this implementation is not validating names or qualified names * (when parsing XML strings, the SAX parser takes care of that) * * @param {string} qualifiedName * @param {string} [publicId] * @param {string} [systemId] * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()` * * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard * * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names */ createDocumentType: function(qualifiedName, publicId, systemId) { var node = new DocumentType(); return node.name = qualifiedName, node.nodeName = qualifiedName, node.publicId = publicId || "", node.systemId = systemId || "", node; } }, Node.prototype = { firstChild: null, lastChild: null, previousSibling: null, nextSibling: null, attributes: null, parentNode: null, childNodes: null, ownerDocument: null, nodeValue: null, namespaceURI: null, prefix: null, localName: null, // Modified in DOM Level 2: insertBefore: function(newChild, refChild) { //raises return _insertBefore(this, newChild, refChild); }, replaceChild: function(newChild, oldChild) { //raises this.insertBefore(newChild, oldChild), oldChild && this.removeChild(oldChild); }, removeChild: function(oldChild) { return _removeChild(this, oldChild); }, appendChild: function(newChild) { return this.insertBefore(newChild, null); }, hasChildNodes: function() { return null != this.firstChild; }, cloneNode: function(deep) { return(// //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1, // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,}; function cloneNode(doc, node, deep) { var node2 = new node.constructor(); for(var n in node){ var v = node[n]; "object" != typeof v && v != node2[n] && (node2[n] = v); } switch(node.childNodes && (node2.childNodes = new NodeList()), node2.ownerDocument = doc, node2.nodeType){ case ELEMENT_NODE: var attrs = node.attributes, attrs2 = node2.attributes = new NamedNodeMap(), len = attrs.length; attrs2._ownerElement = node2; for(var i = 0; i < len; i++)node2.setAttributeNode(cloneNode(doc, attrs.item(i), !0)); break; case ATTRIBUTE_NODE: deep = !0; } if (deep) for(var child = node.firstChild; child;)node2.appendChild(cloneNode(doc, child, deep)), child = child.nextSibling; return node2; }(this.ownerDocument || this, this, deep)); }, // Modified in DOM Level 2: normalize: function() { for(var child = this.firstChild; child;){ var next = child.nextSibling; next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE ? (this.removeChild(next), child.appendData(next.data)) : (child.normalize(), child = next); } }, // Introduced in DOM Level 2: isSupported: function(feature, version) { return this.ownerDocument.implementation.hasFeature(feature, version); }, // Introduced in DOM Level 2: hasAttributes: function() { return this.attributes.length > 0; }, /** * Look up the prefix associated to the given namespace URI, starting from this node. * **The default namespace declarations are ignored by this method.** * See Namespace Prefix Lookup for details on the algorithm used by this method. * * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._ * * @param {string | null} namespaceURI * @returns {string | null} * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix * @see https://github.com/xmldom/xmldom/issues/322 */ lookupPrefix: function(namespaceURI) { for(var el = this; el;){ var map = el._nsMap; //console.dir(map) if (map) { for(var n in map)if (map[n] == namespaceURI) return n; } el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode; } return null; }, // Introduced in DOM Level 3: lookupNamespaceURI: function(prefix) { for(var el = this; el;){ var map = el._nsMap; //console.dir(map) if (map && prefix in map) return map[prefix]; el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode; } return null; }, // Introduced in DOM Level 3: isDefaultNamespace: function(namespaceURI) { return null == this.lookupPrefix(namespaceURI); } }, copy(NodeType, Node), copy(NodeType, Node.prototype), Document.prototype = { //implementation : null, nodeName: "#document", nodeType: DOCUMENT_NODE, /** * The DocumentType node of the document. * * @readonly * @type DocumentType */ doctype: null, documentElement: null, _inc: 1, insertBefore: function(newChild, refChild) { //raises if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { for(var child = newChild.firstChild; child;){ var next = child.nextSibling; this.insertBefore(child, refChild), child = next; } return newChild; } return null == this.documentElement && newChild.nodeType == ELEMENT_NODE && (this.documentElement = newChild), _insertBefore(this, newChild, refChild), newChild.ownerDocument = this, newChild; }, removeChild: function(oldChild) { return this.documentElement == oldChild && (this.documentElement = null), _removeChild(this, oldChild); }, // Introduced in DOM Level 2: importNode: function(importedNode, deep) { return function importNode(doc, node, deep) { var node2; switch(node.nodeType){ case ELEMENT_NODE: (node2 = node.cloneNode(!1)).ownerDocument = doc; //var attrs = node2.attributes; //var len = attrs.length; //for(var i=0;i<len;i++){ //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep)); //} case DOCUMENT_FRAGMENT_NODE: break; case ATTRIBUTE_NODE: deep = !0; } if (node2 || (node2 = node.cloneNode(!1)), node2.ownerDocument = doc, node2.parentNode = null, deep) for(var child = node.firstChild; child;)node2.appendChild(importNode(doc, child, deep)), child = child.nextSibling; return node2; }(this, importedNode, deep); }, // Introduced in DOM Level 2: getElementById: function(id) { var rtv = null; return _visitNode(this.documentElement, function(node) { if (node.nodeType == ELEMENT_NODE && node.getAttribute("id") == id) return rtv = node, !0; }), rtv; }, /** * The `getElementsByClassName` method of `Document` interface returns an array-like object * of all child elements which have **all** of the given class name(s). * * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters. * * * Warning: This is a live LiveNodeList. * Changes in the DOM will reflect in the array as the changes occur. * If an element selected by this array no longer qualifies for the selector, * it will automatically be removed. Be aware of this for iteration purposes. * * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace * * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname */ getElementsByClassName: function(classNames) { var classNamesSet = toOrderedSet(classNames); return new LiveNodeList(this, function(base) { var ls = []; return classNamesSet.length > 0 && _visitNode(base.documentElement, function(node) { if (node !== base && node.nodeType === ELEMENT_NODE) { var nodeClassNames = node.getAttribute("class"); // can be null if the attribute does not exist if (nodeClassNames) { // before splitting and iterating just compare them for the most common case var matches = classNames === nodeClassNames; if (!matches) { var nodeClassNamesSet = toOrderedSet(nodeClassNames); matches = classNamesSet.every(function(element) { return nodeClassNamesSet && -1 !== nodeClassNamesSet.indexOf(element); }); } matches && ls.push(node); } } }), ls; }); }, //document factory method: createElement: function(tagName) { var node = new Element(); return node.ownerDocument = this, node.nodeName = tagName, node.tagName = tagName, node.localName = tagName, node.childNodes = new NodeList(), (node.attributes = new NamedNodeMap())._ownerElement = node, node; }, createDocumentFragment: function() { var node = new DocumentFragment(); return node.ownerDocument = this, node.childNodes = new NodeList(), node; }, createTextNode: function(data) { var node = new Text(); return node.ownerDocument = this, node.appendData(data), node; }, createComment: function(data) { var node = new Comment(); return node.ownerDocument = this, node.appendData(data), node; }, createCDATASection: function(data) { var node = new CDATASection(); return node.ownerDocument = this, node.appendData(data), node; }, createProcessingInstruction: function(target, data) { var node = new ProcessingInstruction(); return node.ownerDocument = this, node.tagName = node.target = target, node.nodeValue = node.data = data, node; }, createAttribute: function(name) { var node = new Attr(); return node.ownerDocument = this, node.name = name, node.nodeName = name, node.localName = name, node.specified = !0, node; }, createEntityReference: function(name) { var node = new EntityReference(); return node.ownerDocument = this, node.nodeName = name, node; }, // Introduced in DOM Level 2: createElementNS: function(namespaceURI, qualifiedName) { var node = new Element(), pl = qualifiedName.split(":"), attrs = node.attributes = new NamedNodeMap(); return node.childNodes = new NodeList(), node.ownerDocument = this, node.nodeName = qualifiedName, node.tagName = qualifiedName, node.namespaceURI = namespaceURI, 2 == pl.length ? (node.prefix = pl[0], node.localName = pl[1]) : //el.prefix = null; node.localName = qualifiedName, attrs._ownerElement = node, node; }, // Introduced in DOM Level 2: createAttributeNS: function(namespaceURI, qualifiedName) { var node = new Attr(), pl = qualifiedName.split(":"); return node.ownerDocument = this, node.nodeName = qualifiedName, node.name = qualifiedName, node.namespaceURI = namespaceURI, node.specified = !0, 2 == pl.length ? (node.prefix = pl[0], node.localName = pl[1]) : //el.prefix = null; node.localName = qualifiedName, node; } }, _extends(Document, Node), Element.prototype = { nodeType: ELEMENT_NODE, hasAttribute: function(name) { return null != this.getAttributeNode(name); }, getAttribute: function(name) { var attr = this.getAttributeNode(name); return attr && attr.value || ""; }, getAttributeNode: function(name) { return this.attributes.getNamedItem(name); }, setAttribute: function(name, value) { var attr = this.ownerDocument.createAttribute(name); attr.value = attr.nodeValue = "" + value, this.setAttributeNode(attr); }, removeAttribute: function(name) { var attr = this.getAttributeNode(name); attr && this.removeAttributeNode(attr); }, //four real opeartion method appendChild: function(newChild) { return newChild.nodeType === DOCUMENT_FRAGMENT_NODE ? this.insertBefore(newChild, null) : function(parentNode, newChild) { var cp = newChild.parentNode; if (cp) { var pre = parentNode.lastChild; cp.removeChild(newChild); //remove and update var pre = parentNode.lastChild; } var pre = parentNode.lastChild; return newChild.parentNode = parentNode, newChild.previousSibling = pre, newChild.nextSibling = null, pre ? pre.nextSibling = newChild : parentNode.firstChild = newChild, parentNode.lastChild = newChild, _onUpdateChild(parentNode.ownerDocument, parentNode, newChild), newChild; //console.log("__aa",parentNode.lastChild.nextSibling == null) }(this, newChild); }, setAttributeNode: function(newAttr) { return this.attributes.setNamedItem(newAttr); }, setAttributeNodeNS: function(newAttr) { return this.attributes.setNamedItemNS(newAttr); }, removeAttributeNode: function(oldAttr) { //console.log(this == oldAttr.ownerElement) return this.attributes.removeNamedItem(oldAttr.nodeName); }, //get real attribute name,and remove it by removeAttributeNode removeAttributeNS: function(namespaceURI, localName) { var old = this.getAttributeNodeNS(namespaceURI, localName); old && this.removeAttributeNode(old); }, hasAttributeNS: function(namespaceURI, localName) { return null != this.getAttributeNodeNS(namespaceURI, localName); }, getAttributeNS: function(namespaceURI, localName) { var attr = this.getAttributeNodeNS(namespaceURI, localName); return attr && attr.value || ""; }, setAttributeNS: function(namespaceURI, qualifiedName, value) { var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); attr.value = attr.nodeValue = "" + value, this.setAttributeNode(attr); }, getAttributeNodeNS: function(namespaceURI, localName) { return this.attributes.getNamedItemNS(namespaceURI, localName); }, getElementsByTagName: function(tagName) { return new LiveNodeList(this, function(base) { var ls = []; return _visitNode(base, function(node) { node !== base && node.nodeType == ELEMENT_NODE && ("*" === tagName || node.tagName == tagName) && ls.push(node); }), ls; }); }, getElementsByTagNameNS: function(namespaceURI, localName) { return new LiveNodeList(this, function(base) { var ls = []; return _visitNode(base, function(node) { node !== base && node.nodeType === ELEMENT_NODE && ("*" === namespaceURI || node.namespaceURI === namespaceURI) && ("*" === localName || node.localName == localName) && ls.push(node); }), ls; }); } }, Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName, Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS, _extends(Element, Node), Attr.prototype.nodeType = ATTRIBUTE_NODE, _extends(Attr, Node), CharacterData.prototype = { data: "", substringData: function(offset, count) { return this.data.substring(offset, offset + count); }, appendData: function(text) { text = this.data + text, this.nodeValue = this.data = text, this.length = text.length; }, insertData: function(offset, text) { this.replaceData(offset, 0, text); }, appendChild: function(newChild) { throw Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]); }, deleteData: function(offset, count) { this.replaceData(offset, count, ""); }, replaceData: function(offset, count, text) { text = this.data.substring(0, offset) + text + this.data.substring(offset + count), this.nodeValue = this.data = text, this.length = text.length; } }, _extends(CharacterData, Node), Text.prototype = { nodeName: "#text", nodeType: TEXT_NODE, splitText: function(offset) { var text = this.data, newText = text.substring(offset); text = text.substring(0, offset), this.data = this.nodeValue = text, this.length = text.length; var newNode = this.ownerDocument.createTextNode(newText); return this.parentNode && this.parentNode.insertBefore(newNode, this.nextSibling), newNode; } }, _extends(Text, CharacterData), Comment.prototype = { nodeName: "#comment", nodeType: COMMENT_NODE }, _extends(Comment, CharacterData), CDATASection.prototype = { nodeName: "#cdata-section", nodeType: CDATA_SECTION_NODE }, _extends(CDATASection, CharacterData), DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE, _extends(DocumentType, Node), Notation.prototype.nodeType = NOTATION_NODE, _extends(Notation, Node), Entity.prototype.nodeType = ENTITY_NODE, _extends(Entity, Node), EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE, _extends(EntityReference, Node), DocumentFragment.prototype.nodeName = "#document-fragment", DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE, _extends(DocumentFragment, Node), ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE, _extends(ProcessingInstruction, Node), XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) { return nodeSerializeToString.call(node, isHtml, nodeFilter); }, Node.prototype.toString = nodeSerializeToString; //do dynamic try { Object.defineProperty && (Object.defineProperty(LiveNodeList.prototype, "length", { get: function() { return _updateLiveList(this), this.$$length; } }), Object.defineProperty(Node.prototype, "textContent", { get: function() { return function getTextContent(node) { switch(node.nodeType){ case ELEMENT_NODE: case DOCUMENT_FRAGMENT_NODE: var buf = []; for(node = node.firstChild; node;)7 !== node.nodeType && 8 !== node.nodeType && buf.push(getTextContent(node)), node = node.nextSibling; return buf.join(""); default: return node.nodeValue; } }(this); }, set: function(data) { switch(this.nodeType){ case ELEMENT_NODE: case DOCUMENT_FRAGMENT_NODE: for(; this.firstChild;)this.removeChild(this.firstChild); (data || String(data)) && this.appendChild(this.ownerDocument.createTextNode(data)); break; default: this.data = data, this.value = data, this.nodeValue = data; } } }), __set__ = function(object, key, value) { //console.log(value) object["$$" + key] = value; }); } catch (e) { //ie8 } //if(typeof require == 'function'){ exports.DocumentType = DocumentType, exports.DOMException = DOMException, exports.DOMImplementation = DOMImplementation, exports.Element = Element, exports.Node = Node, exports.NodeList = NodeList, exports.XMLSerializer = XMLSerializer; //} /***/ }, /***/ 1045: /***/ function(__unused_webpack_module, exports, __webpack_require__) { var freeze = __webpack_require__(2167).freeze; /** * The entities that are predefined in every XML document. * * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1 * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0 * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia */ exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }), /** * A map of currently 241 entities that are detected in an HTML document. * They contain all entries from `XML_ENTITIES`. * * @see XML_ENTITIES * @see DOMParser.parseFromString * @see DOMImplementation.prototype.createHTMLDocument * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML) * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML) */ exports.HTML_ENTITIES = freeze({ lt: "<", gt: ">", amp: "&", quot: '"', apos: "'", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", nbsp: "\u00a0", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "­­", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", times: "×", divide: "÷", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "∧", or: "∨", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", fnof: "ƒ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "‌", zwj: "‍", lrm: "‎", rlm: "‏", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", bull: "•", hellip: "…", permil: "‰", prime: "′", Prime: "″", lsaquo: "‹", rsaquo: "›", oline: "‾", euro: "€", trade: "™", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦" }), /** * @deprecated use `HTML_ENTITIES` instead * @see HTML_ENTITIES */ exports.entityMap = exports.HTML_ENTITIES; /***/ }, /***/ 3969: /***/ function(__unused_webpack_module, exports, __webpack_require__) { var dom = __webpack_require__(1146); dom.DOMImplementation, dom.XMLSerializer, exports.DOMParser = __webpack_require__(6129).DOMParser; /***/ }, /***/ 6925: /***/ function(__unused_webpack_module, exports, __webpack_require__) { var NAMESPACE = __webpack_require__(2167).NAMESPACE, nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/, nameChar = RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"), tagNamePattern = RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$"); /** * Creates an error that will not be caught by XMLReader aka the SAX parser. * * @param {string} message * @param {any?} locator Optional, can provide details about the location in the source * @constructor */ function ParseError(message, locator) { this.message = message, this.locator = locator, Error.captureStackTrace && Error.captureStackTrace(this, ParseError); } function XMLReader() {} function copyLocator(f, t) { return t.lineNumber = f.lineNumber, t.columnNumber = f.columnNumber, t; } /** * @return true if has new namespace define */ function appendElement(el, domBuilder, currentNSMap) { for(var tagName = el.tagName, localNSMap = null, i = el.length; i--;){ var a = el[i], qName = a.qName, value = a.value, nsp = qName.indexOf(":"); if (nsp > 0) var prefix = a.prefix = qName.slice(0, nsp), localName = qName.slice(nsp + 1), nsPrefix = "xmlns" === prefix && localName; else localName = qName, prefix = null, nsPrefix = "xmlns" === qName && ""; //can not set prefix,because prefix !== '' a.localName = localName, !1 !== nsPrefix && (null == localNSMap && (localNSMap = {}, //console.log(currentNSMap,0) _copy(currentNSMap, currentNSMap = {})), currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value, a.uri = NAMESPACE.XMLNS, domBuilder.startPrefixMapping(nsPrefix, value)); } for(var i = el.length; i--;){ var prefix = (a = el[i]).prefix; prefix && ("xml" === prefix && (a.uri = NAMESPACE.XML), "xmlns" !== prefix && (a.uri = currentNSMap[prefix || ""])); } var nsp = tagName.indexOf(":"); nsp > 0 ? (prefix = el.prefix = tagName.slice(0, nsp), localName = el.localName = tagName.slice(nsp + 1)) : (prefix = null, localName = el.localName = tagName); //no prefix element has default namespace var ns = el.uri = currentNSMap[prefix || ""]; //endPrefixMapping and startPrefixMapping have not any help for dom builder //localNSMap = null if (domBuilder.startElement(ns, localName, tagName, el), !el.closed) //parseStack.push(el); return el.currentNSMap = currentNSMap, el.localNSMap = localNSMap, !0; if (domBuilder.endElement(ns, localName, tagName), localNSMap) for(prefix in localNSMap)domBuilder.endPrefixMapping(prefix); } function _copy(source, target) { for(var n in source)target[n] = source[n]; } function ElementAttributes() { this.attributeNames = {}; } ParseError.prototype = Error(), ParseError.prototype.name = ParseError.name, XMLReader.prototype = { parse: function(source, defaultNSMap, entityMap) { var domBuilder = this.domBuilder; domBuilder.startDocument(), _copy(defaultNSMap, defaultNSMap = {}), function(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) { function entityReplacer(a) { var code, k = a.slice(1, -1); return k in entityMap ? entityMap[k] : "#" !== k.charAt(0) ? (errorHandler.error("entity not found:" + a), a) : // String.prototype.fromCharCode does not supports // > 2 bytes unicode chars directly (code = parseInt(k.substr(1).replace("x", "0x"))) > 0xffff ? String.fromCharCode(0xd800 + ((code -= 0x10000) >> 10), 0xdc00 + (0x3ff & code)) : String.fromCharCode(code); } function appendText(end) { //has some bugs if (end > start) { var xt = source.substring(start, end).replace(/&#?\w+;/g, entityReplacer); locator && position(start), domBuilder.characters(xt, 0, end - start), start = end; } } function position(p, m) { for(; p >= lineEnd && (m = linePattern.exec(source));)lineEnd = (lineStart = m.index) + m[0].length, locator.lineNumber++; locator.columnNumber = p - lineStart + 1; } for(var lineStart = 0, lineEnd = 0, linePattern = /.*(?:\r\n?|\n)|.*$/g, locator = domBuilder.locator, parseStack = [ { currentNSMap: defaultNSMapCopy } ], closeMap = {}, start = 0;;){ try { var tagStart = source.indexOf("<", start); if (tagStart < 0) { if (!source.substr(start).match(/^\s*$/)) { var doc = domBuilder.doc, text = doc.createTextNode(source.substr(start)); doc.appendChild(text), domBuilder.currentElement = text; } return; } switch(tagStart > start && appendText(tagStart), source.charAt(tagStart + 1)){ case "/": var end = source.indexOf(">", tagStart + 3), tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, ""), config = parseStack.pop(); end < 0 ? (tagName = source.substring(tagStart + 2).replace(/[\s<].*/, ""), errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName), end = tagStart + 1 + tagName.length) : tagName.match(/\s</) && (tagName = tagName.replace(/[\s<].*/, ""), errorHandler.error("end tag name: " + tagName + " maybe not complete"), end = tagStart + 1 + tagName.length); var localNSMap = config.localNSMap, endMatch = config.tagName == tagName; if (endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase()) { if (domBuilder.endElement(config.uri, config.localName, tagName), localNSMap) for(var prefix in localNSMap)domBuilder.endPrefixMapping(prefix); endMatch || errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName); } else parseStack.push(config); end++; break; // end elment case "?": locator && position(tagStart), end = function(source, start, domBuilder) { var end = source.indexOf("?>", start); if (end) { var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/); if (match) return match[0].length, domBuilder.processingInstruction(match[1], match[2]), end + 2; } return -1; }(source, tagStart, domBuilder); break; case "!": locator && position(tagStart), end = function(source, start, domBuilder, errorHandler) { if ("-" === source.charAt(start + 2)) { if ("-" === source.charAt(start + 3)) { var end = source.indexOf("-->", start + 4); //append comment source.substring(4,end)//<!-- if (end > start) return domBuilder.comment(source, start + 4, end - start - 4), end + 3; errorHandler.error("Unclosed comment"); } } else { if ("CDATA[" == source.substr(start + 3, 6)) { var end = source.indexOf("]]>", start + 9); return domBuilder.startCDATA(), domBuilder.characters(source, start + 9, end - start - 9), domBuilder.endCDATA(), end + 3; } //<!DOCTYPE //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) var matchs = function(source, start) { var match, buf = [], reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g; for(reg.lastIndex = start, reg.exec(source); match = reg.exec(source);)if (buf.push(match), match[1]) return buf; }(source, start), len = matchs.length; if (len > 1 && /!doctype/i.test(matchs[0][0])) { var name = matchs[1][0], pubid = !1, sysid = !1; len > 3 && (/^public$/i.test(matchs[2][0]) ? (pubid = matchs[3][0], sysid = len > 4 && matchs[4][0]) : /^system$/i.test(matchs[2][0]) && (sysid = matchs[3][0])); var lastMatch = matchs[len - 1]; return domBuilder.startDTD(name, pubid, sysid), domBuilder.endDTD(), lastMatch.index + lastMatch[0].length; } } return -1; }(source, tagStart, domBuilder, errorHandler); break; default: locator && position(tagStart); var el = new ElementAttributes(), currentNSMap = parseStack[parseStack.length - 1].currentNSMap, end = /** * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); * @return end of the elementStartPart(end of elementEndPart for selfClosed el) */ function(source, start, el, currentNSMap, entityReplacer, errorHandler) { /** * @param {string} qname * @param {string} value * @param {number} startIndex */ function addAttribute(qname, value, startIndex) { el.attributeNames.hasOwnProperty(qname) && errorHandler.fatalError("Attribute " + qname + " redefined"), el.addValue(qname, value, startIndex); } for(var attrName, value, p = ++start, s = 0;;){ var c = source.charAt(p); switch(c){ case "=": if (1 === s) //attrName attrName = source.slice(start, p), s = 3; else if (2 === s) s = 3; else //fatalError: equal must after attrName or space after attrName throw Error("attribute equal must after attrName"); // No known test case break; case "'": case '"': if (3 === s || 1 === s //|| s == S_ATTR_SPACE ) { if (1 === s && (errorHandler.warning('attribute value must after "="'), attrName = source.slice(start, p)), start = p + 1, (p = source.indexOf(c, start)) > 0) addAttribute(attrName, value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer), start - 1), s = 5; else //fatalError: no end quot match throw Error("attribute value no end '" + c + "' match"); } else if (4 == s) //console.log(attrName,value,start,p) addAttribute(attrName, value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer), start), //console.dir(el) errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!"), start = p + 1, s = 5; else //fatalError: no equal before throw Error('attribute value must after "="'); // No known test case break; case "/": switch(s){ case 0: el.setTagName(source.slice(start, p)); case 5: case 6: case 7: s = 7, el.closed = !0; case 4: case 1: case 2: break; //case S_EQ: default: throw Error("attribute invalid close char('/')"); // No known test case } break; case "": return errorHandler.error("unexpected end of input"), 0 == s && el.setTagName(source.slice(start, p)), p; case ">": switch(s){ case 0: el.setTagName(source.slice(start, p)); case 5: case 6: case 7: break; //normal case 4: case 1: "/" === (value = source.slice(start, p)).slice(-1) && (el.closed = !0, value = value.slice(0, -1)); case 2: 2 === s && (value = attrName), 4 == s ? (errorHandler.warning('attribute "' + value + '" missed quot(")!'), addAttribute(attrName, value.replace(/&#?\w+;/g, entityReplacer), start)) : (NAMESPACE.isHTML(currentNSMap[""]) && value.match(/^(?:disabled|checked|selected)$/i) || errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!'), addAttribute(value, value, start)); break; case 3: throw Error("attribute value missed!!"); } // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName)) return p; /*xml space '\x20' | #x9 | #xD | #xA; */ case "\u0080": c = " "; default: if (c <= " ") //space switch(s){ case 0: el.setTagName(source.slice(start, p)), s = 6; break; case 1: attrName = source.slice(start, p), s = 2; break; case 4: var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer); errorHandler.warning('attribute "' + value + '" missed quot(")!!'), addAttribute(attrName, value, start); case 5: s = 6; } else //not space //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE switch(s){ //case S_TAG:void();break; //case S_ATTR:void();break; //case S_ATTR_NOQUOT_VALUE:void();break; case 2: el.tagName, NAMESPACE.isHTML(currentNSMap[""]) && attrName.match(/^(?:disabled|checked|selected)$/i) || errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!'), addAttribute(attrName, attrName, start), start = p, s = 1; break; case 5: errorHandler.warning('attribute space is required"' + attrName + '"!!'); case 6: s = 1, start = p; break; case 3: s = 4, start = p; break; case 7: throw Error("elements closed character '/' and '>' must be connected to"); } } //end outer switch //console.log('p++',p) p++; } }(source, tagStart, el, currentNSMap, entityReplacer, errorHandler), len = el.length; if (!el.closed && function(source, elStartEnd, tagName, closeMap) { //if(tagName in closeMap){ var pos = closeMap[tagName]; return null == pos && (//console.log(tagName) (pos = source.lastIndexOf("</" + tagName + ">")) < elStartEnd && //忘记闭合 (pos = source.lastIndexOf("</" + tagName)), closeMap[tagName] = pos), pos < elStartEnd; //} }(source, end, el.tagName, closeMap) && (el.closed = !0, entityMap.nbsp || errorHandler.warning("unclosed xml attribute")), locator && len) { //try{//attribute position fixed for(var locator2 = copyLocator(locator, {}), i = 0; i < len; i++){ var a = el[i]; position(a.offset), a.locator = copyLocator(locator, {}); } domBuilder.locator = locator2, appendElement(el, domBuilder, currentNSMap) && parseStack.push(el), domBuilder.locator = locator; } else appendElement(el, domBuilder, currentNSMap) && parseStack.push(el); NAMESPACE.isHTML(el.uri) && !el.closed ? end = function(source, elStartEnd, tagName, entityReplacer, domBuilder) { if (/^(?:script|textarea)$/i.test(tagName)) { var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd), text = source.substring(elStartEnd + 1, elEndStart); if (/[&<]/.test(text)) return /^script$/i.test(tagName) || (text = text.replace(/&#?\w+;/g, entityReplacer)), //if(!/\]\]>/.test(text)){ //lexHandler.startCDATA(); domBuilder.characters(text, 0, text.length), elEndStart; } return elStartEnd + 1; }(source, end, el.tagName, entityReplacer, domBuilder) : end++; } } catch (e) { if (e instanceof ParseError) throw e; errorHandler.error("element parse error: " + e), end = -1; } end > start ? start = end : //TODO: 这里有可能sax回退,有位置错误风险 appendText(Math.max(tagStart, start) + 1); } }(source, defaultNSMap, entityMap, domBuilder, this.errorHandler), domBuilder.endDocument(); } }, ElementAttributes.prototype = { setTagName: function(tagName) { if (!tagNamePattern.test(tagName)) throw Error("invalid tagName:" + tagName); this.tagName = tagName; }, addValue: function(qName, value, offset) { if (!tagNamePattern.test(qName)) throw Error("invalid attribute:" + qName); this.attributeNames[qName] = this.length, this[this.length++] = { qName: qName, value: value, offset: offset }; }, length: 0, getLocalName: function(i) { return this[i].localName; }, getLocator: function(i) { return this[i].locator; }, getQName: function(i) { return this[i].qName; }, getURI: function(i) { return this[i].uri; }, getValue: function(i) { return this[i].value; } }, exports.XMLReader = XMLReader, exports.ParseError = ParseError; /***/ }, /***/ 9144: /***/ function(module, __unused_webpack_exports, __webpack_require__) { var doccy, topLevel = void 0 !== __webpack_require__.g ? __webpack_require__.g : "undefined" != typeof window ? window : {}, minDoc = __webpack_require__(7579); "undefined" != typeof document ? doccy = document : (doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"]) || (doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"] = minDoc), module.exports = doccy; /***/ }, /***/ 8908: /***/ function(module, __unused_webpack_exports, __webpack_require__) { module.exports = "undefined" != typeof window ? window : void 0 !== __webpack_require__.g ? __webpack_require__.g : "undefined" != typeof self ? self : {}; /***/ }, /***/ 7376: /***/ function(module) { module.exports = function(fn) { if (!fn) return !1; var string = toString.call(fn); return "[object Function]" === string || "function" == typeof fn && "[object RegExp]" !== string || "undefined" != typeof window && // IE8 and below (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt); }; var toString = Object.prototype.toString; /***/ }, /***/ 7537: /***/ function(module, exports) { // Source: http://jsfiddle.net/vWx8V/ // http://stackoverflow.com/questions/5603195/full-list-of-javascript-keycodes /** * Conenience method returns corresponding value for given keyName or keyCode. * * @param {Mixed} keyCode {Number} or keyName {String} * @return {Mixed} * @api public */ function keyCode(searchInput) { // Keyboard Events if (searchInput && "object" == typeof searchInput) { var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode; hasKeyCode && (searchInput = hasKeyCode); } // Numbers if ("number" == typeof searchInput) return names[searchInput]; // Everything else (cast to string) var search = String(searchInput), foundNamedKey = codes[search.toLowerCase()]; if (foundNamedKey) return foundNamedKey; // check aliases var foundNamedKey = aliases[search.toLowerCase()]; return foundNamedKey || (1 === search.length ? search.charCodeAt(0) : void 0); } /** * Compares a keyboard event with a given keyCode or keyName. * * @param {Event} event Keyboard event that should be tested * @param {Mixed} keyCode {Number} or keyName {String} * @return {Boolean} * @api public */ keyCode.isEventKey = function(event, nameOrCode) { if (event && "object" == typeof event) { var keyCode = event.which || event.keyCode || event.charCode; if (null == keyCode) return !1; if ("string" == typeof nameOrCode) { // check codes var foundNamedKey = codes[nameOrCode.toLowerCase()]; if (foundNamedKey) return foundNamedKey === keyCode; // check aliases var foundNamedKey = aliases[nameOrCode.toLowerCase()]; if (foundNamedKey) return foundNamedKey === keyCode; } else if ("number" == typeof nameOrCode) return nameOrCode === keyCode; return !1; } }; /** * Get by name * * exports.code['enter'] // => 13 */ var codes = (exports = module.exports = keyCode).code = exports.codes = { backspace: 8, tab: 9, enter: 13, shift: 16, ctrl: 17, alt: 18, "pause/break": 19, "caps lock": 20, esc: 27, space: 32, "page up": 33, "page down": 34, end: 35, home: 36, left: 37, up: 38, right: 39, down: 40, insert: 45, delete: 46, command: 91, "left command": 91, "right command": 93, "numpad *": 106, "numpad +": 107, "numpad -": 109, "numpad .": 110, "numpad /": 111, "num lock": 144, "scroll lock": 145, "my computer": 182, "my calculator": 183, ";": 186, "=": 187, ",": 188, "-": 189, ".": 190, "/": 191, "`": 192, "[": 219, "\\": 220, "]": 221, "'": 222 }, aliases = exports.aliases = { windows: 91, "⇧": 16, "⌥": 18, "⌃": 17, "⌘": 91, ctl: 17, control: 17, option: 18, pause: 19, break: 19, caps: 20, return: 13, escape: 27, spc: 32, spacebar: 32, pgup: 33, pgdn: 34, ins: 45, del: 46, cmd: 91 }; /*! * Programatically add the following */ // lower case chars for(i = 97; i < 123; i++)codes[String.fromCharCode(i)] = i - 32; // numbers for(var i = 48; i < 58; i++)codes[i - 48] = i; // function keys for(i = 1; i < 13; i++)codes["f" + i] = i + 111; // numpad keys for(i = 0; i < 10; i++)codes["numpad " + i] = i + 96; /** * Get by code * * exports.name[13] // => 'Enter' */ var names = exports.names = exports.title = {}; // title for backward compat // Create reverse mapping for(i in codes)names[codes[i]] = i; // Add aliases for(var alias in aliases)codes[alias] = aliases[alias]; /***/ }, /***/ 9323: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { _b: function() { return /* binding */ Parser; } }); // UNUSED EXPORTS: LineStream, ParseStream // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js var inheritsLoose = __webpack_require__(4578), Stream = /*#__PURE__*/ function() { function Stream() { this.listeners = {}; } /** * Add a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener the callback to be invoked when an event of * the specified type occurs */ var _proto = Stream.prototype; return _proto.on = function(type, listener) { this.listeners[type] || (this.listeners[type] = []), this.listeners[type].push(listener); }, /** * Remove a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener a function previously registered for this * type of event through `on` * @return {boolean} if we could turn it off or not */ _proto.off = function(type, listener) { if (!this.listeners[type]) return !1; var index = this.listeners[type].indexOf(listener); // TODO: which is better? return(// In Video.js we slice listener functions // on trigger so that it does not mess up the order // while we loop through. // // Here we slice on off so that the loop in trigger // can continue using it's old reference to loop without // messing up the order. this.listeners[type] = this.listeners[type].slice(0), this.listeners[type].splice(index, 1), index > -1); }, /** * Trigger an event of the specified type on this stream. Any additional * arguments to this function are passed as parameters to event listeners. * * @param {string} type the event name */ _proto.trigger = function(type) { var callbacks = this.listeners[type]; if (callbacks) { // can add a significant amount of overhead. Avoid the // intermediate object creation for the common case of a // single callback argument if (2 == arguments.length) for(var length = callbacks.length, i = 0; i < length; ++i)callbacks[i].call(this, arguments[1]); else for(var args = Array.prototype.slice.call(arguments, 1), _length = callbacks.length, _i = 0; _i < _length; ++_i)callbacks[_i].apply(this, args); } // Slicing the arguments on every invocation of this method }, /** * Destroys the stream and cleans up. */ _proto.dispose = function() { this.listeners = {}; }, /** * Forwards all `data` events on this stream to the destination stream. The * destination stream should provide a method `push` to receive the data * events as they arrive. * * @param {Stream} destination the stream that will receive all `data` events * @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options */ _proto.pipe = function(destination) { this.on("data", function(data) { destination.push(data); }); }, Stream; }(), esm_extends = __webpack_require__(7462), assertThisInitialized = __webpack_require__(7326), decode_b64_to_uint8_array = __webpack_require__(6722), LineStream = /*#__PURE__*/ function(_Stream) { function LineStream() { var _this; return (_this = _Stream.call(this) || this).buffer = "", _this; } return (0, inheritsLoose /* default */ .Z)(LineStream, _Stream), LineStream.prototype.push = function(data) { var nextNewline; for(this.buffer += data, nextNewline = this.buffer.indexOf("\n"); nextNewline > -1; nextNewline = this.buffer.indexOf("\n"))this.trigger("data", this.buffer.substring(0, nextNewline)), this.buffer = this.buffer.substring(nextNewline + 1); }, LineStream; }(Stream), parseByterange = function(byterangeString) { // optionally match and capture 0+ digits before `@` // optionally match and capture 0+ digits after `@` var match = /([0-9.]*)?@?([0-9.]*)?/.exec(byterangeString || ""), result = {}; return match[1] && (result.length = parseInt(match[1], 10)), match[2] && (result.offset = parseInt(match[2], 10)), result; }, parseAttributes = function(attributes) { for(// split the string using attributes as the separator var attr, attrs = attributes.split(RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')), result = {}, i = attrs.length; i--;)// filter out unmatched portions of the string "" !== attrs[i] && ((attr = /([^=]*)=(.*)/.exec(attrs[i]).slice(1))[0] = attr[0].replace(/^\s+|\s+$/g, ""), attr[1] = attr[1].replace(/^\s+|\s+$/g, ""), attr[1] = attr[1].replace(/^['"](.*)['"]$/g, "$1"), result[attr[0]] = attr[1]); // split the key and value return result; }, ParseStream = /*#__PURE__*/ function(_Stream) { function ParseStream() { var _this; return (_this = _Stream.call(this) || this).customParsers = [], _this.tagMappers = [], _this; } (0, inheritsLoose /* default */ .Z)(ParseStream, _Stream); /** * Parses an additional line of input. * * @param {string} line a single line of an M3U8 file to parse */ var _proto = ParseStream.prototype; return _proto.push = function(line) { var match, event, _this2 = this; if (0 !== (line = line.trim()).length) { if ("#" !== line[0]) { this.trigger("data", { type: "uri", uri: line }); return; } // map tags this.tagMappers.reduce(function(acc, mapper) { var mappedLine = mapper(line); // skip if unchanged return mappedLine === line ? acc : acc.concat([ mappedLine ]); }, [ line ]).forEach(function(newLine) { for(var i = 0; i < _this2.customParsers.length; i++)if (_this2.customParsers[i].call(_this2, newLine)) return; // Comments if (0 !== newLine.indexOf("#EXT")) { _this2.trigger("data", { type: "comment", text: newLine.slice(1) }); return; } // strip off any carriage returns here so the regex matching if (// doesn't have to account for them. newLine = newLine.replace("\r", ""), match = /^#EXTM3U/.exec(newLine)) { _this2.trigger("data", { type: "tag", tagType: "m3u" }); return; } if (match = /^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(newLine)) { event = { type: "tag", tagType: "inf" }, match[1] && (event.duration = parseFloat(match[1])), match[2] && (event.title = match[2]), _this2.trigger("data", event); return; } if (match = /^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(newLine)) { event = { type: "tag", tagType: "targetduration" }, match[1] && (event.duration = parseInt(match[1], 10)), _this2.trigger("data", event); return; } if (match = /^#EXT-X-VERSION:?([0-9.]*)?/.exec(newLine)) { event = { type: "tag", tagType: "version" }, match[1] && (event.version = parseInt(match[1], 10)), _this2.trigger("data", event); return; } if (match = /^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(newLine)) { event = { type: "tag", tagType: "media-sequence" }, match[1] && (event.number = parseInt(match[1], 10)), _this2.trigger("data", event); return; } if (match = /^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(newLine)) { event = { type: "tag", tagType: "discontinuity-sequence" }, match[1] && (event.number = parseInt(match[1], 10)), _this2.trigger("data", event); return; } if (match = /^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(newLine)) { event = { type: "tag", tagType: "playlist-type" }, match[1] && (event.playlistType = match[1]), _this2.trigger("data", event); return; } if (match = /^#EXT-X-BYTERANGE:?(.*)?$/.exec(newLine)) { event = (0, esm_extends /* default */ .Z)(parseByterange(match[1]), { type: "tag", tagType: "byterange" }), _this2.trigger("data", event); return; } if (match = /^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(newLine)) { event = { type: "tag", tagType: "allow-cache" }, match[1] && (event.allowed = !/NO/.test(match[1])), _this2.trigger("data", event); return; } if (match = /^#EXT-X-MAP:?(.*)$/.exec(newLine)) { if (event = { type: "tag", tagType: "map" }, match[1]) { var attributes = parseAttributes(match[1]); attributes.URI && (event.uri = attributes.URI), attributes.BYTERANGE && (event.byterange = parseByterange(attributes.BYTERANGE)); } _this2.trigger("data", event); return; } if (match = /^#EXT-X-STREAM-INF:?(.*)$/.exec(newLine)) { if (event = { type: "tag", tagType: "stream-inf" }, match[1]) { if (event.attributes = parseAttributes(match[1]), event.attributes.RESOLUTION) { var split = event.attributes.RESOLUTION.split("x"), resolution = {}; split[0] && (resolution.width = parseInt(split[0], 10)), split[1] && (resolution.height = parseInt(split[1], 10)), event.attributes.RESOLUTION = resolution; } event.attributes.BANDWIDTH && (event.attributes.BANDWIDTH = parseInt(event.attributes.BANDWIDTH, 10)), event.attributes["PROGRAM-ID"] && (event.attributes["PROGRAM-ID"] = parseInt(event.attributes["PROGRAM-ID"], 10)); } _this2.trigger("data", event); return; } if (match = /^#EXT-X-MEDIA:?(.*)$/.exec(newLine)) { event = { type: "tag", tagType: "media" }, match[1] && (event.attributes = parseAttributes(match[1])), _this2.trigger("data", event); return; } if (match = /^#EXT-X-ENDLIST/.exec(newLine)) { _this2.trigger("data", { type: "tag", tagType: "endlist" }); return; } if (match = /^#EXT-X-DISCONTINUITY/.exec(newLine)) { _this2.trigger("data", { type: "tag", tagType: "discontinuity" }); return; } if (match = /^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(newLine)) { event = { type: "tag", tagType: "program-date-time" }, match[1] && (event.dateTimeString = match[1], event.dateTimeObject = new Date(match[1])), _this2.trigger("data", event); return; } if (match = /^#EXT-X-KEY:?(.*)$/.exec(newLine)) { event = { type: "tag", tagType: "key" }, match[1] && (event.attributes = parseAttributes(match[1]), event.attributes.IV && ("0x" === event.attributes.IV.substring(0, 2).toLowerCase() && (event.attributes.IV = event.attributes.IV.substring(2)), event.attributes.IV = event.attributes.IV.match(/.{8}/g), event.attributes.IV[0] = parseInt(event.attributes.IV[0], 16), event.attributes.IV[1] = parseInt(event.attributes.IV[1], 16), event.attributes.IV[2] = parseInt(event.attributes.IV[2], 16), event.attributes.IV[3] = parseInt(event.attributes.IV[3], 16), event.attributes.IV = new Uint32Array(event.attributes.IV))), _this2.trigger("data", event); return; } if (match = /^#EXT-X-START:?(.*)$/.exec(newLine)) { event = { type: "tag", tagType: "start" }, match[1] && (event.attributes = parseAttributes(match[1]), event.attributes["TIME-OFFSET"] = parseFloat(event.attributes["TIME-OFFSET"]), event.attributes.PRECISE = /YES/.test(event.attributes.PRECISE)), _this2.trigger("data", event); return; } if (match = /^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(newLine)) { event = { type: "tag", tagType: "cue-out-cont" }, match[1] ? event.data = match[1] : event.data = "", _this2.trigger("data", event); return; } if (match = /^#EXT-X-CUE-OUT:?(.*)?$/.exec(newLine)) { event = { type: "tag", tagType: "cue-out" }, match[1] ? event.data = match[1] : event.data = "", _this2.trigger("data", event); return; } if (match = /^#EXT-X-CUE-IN:?(.*)?$/.exec(newLine)) { event = { type: "tag", tagType: "cue-in" }, match[1] ? event.data = match[1] : event.data = "", _this2.trigger("data", event); return; } if ((match = /^#EXT-X-SKIP:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "skip" }).attributes = parseAttributes(match[1]), event.attributes.hasOwnProperty("SKIPPED-SEGMENTS") && (event.attributes["SKIPPED-SEGMENTS"] = parseInt(event.attributes["SKIPPED-SEGMENTS"], 10)), event.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES") && (event.attributes["RECENTLY-REMOVED-DATERANGES"] = event.attributes["RECENTLY-REMOVED-DATERANGES"].split(" ")), _this2.trigger("data", event); return; } if ((match = /^#EXT-X-PART:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "part" }).attributes = parseAttributes(match[1]), [ "DURATION" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = parseFloat(event.attributes[key])); }), [ "INDEPENDENT", "GAP" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = /YES/.test(event.attributes[key])); }), event.attributes.hasOwnProperty("BYTERANGE") && (event.attributes.byterange = parseByterange(event.attributes.BYTERANGE)), _this2.trigger("data", event); return; } if ((match = /^#EXT-X-SERVER-CONTROL:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "server-control" }).attributes = parseAttributes(match[1]), [ "CAN-SKIP-UNTIL", "PART-HOLD-BACK", "HOLD-BACK" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = parseFloat(event.attributes[key])); }), [ "CAN-SKIP-DATERANGES", "CAN-BLOCK-RELOAD" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = /YES/.test(event.attributes[key])); }), _this2.trigger("data", event); return; } if ((match = /^#EXT-X-PART-INF:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "part-inf" }).attributes = parseAttributes(match[1]), [ "PART-TARGET" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = parseFloat(event.attributes[key])); }), _this2.trigger("data", event); return; } if ((match = /^#EXT-X-PRELOAD-HINT:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "preload-hint" }).attributes = parseAttributes(match[1]), [ "BYTERANGE-START", "BYTERANGE-LENGTH" ].forEach(function(key) { if (event.attributes.hasOwnProperty(key)) { event.attributes[key] = parseInt(event.attributes[key], 10); var subkey = "BYTERANGE-LENGTH" === key ? "length" : "offset"; event.attributes.byterange = event.attributes.byterange || {}, event.attributes.byterange[subkey] = event.attributes[key], delete event.attributes[key]; } }), _this2.trigger("data", event); return; } if ((match = /^#EXT-X-RENDITION-REPORT:(.*)$/.exec(newLine)) && match[1]) { (event = { type: "tag", tagType: "rendition-report" }).attributes = parseAttributes(match[1]), [ "LAST-MSN", "LAST-PART" ].forEach(function(key) { event.attributes.hasOwnProperty(key) && (event.attributes[key] = parseInt(event.attributes[key], 10)); }), _this2.trigger("data", event); return; } // unknown tag type _this2.trigger("data", { type: "tag", data: newLine.slice(4) }); }); } // URIs }, /** * Add a parser for custom headers * * @param {Object} options a map of options for the added parser * @param {RegExp} options.expression a regular expression to match the custom header * @param {string} options.customType the custom type to register to the output * @param {Function} [options.dataParser] function to parse the line into an object * @param {boolean} [options.segment] should tag data be attached to the segment object */ _proto.addParser = function(_ref) { var _this3 = this, expression = _ref.expression, customType = _ref.customType, dataParser = _ref.dataParser, segment = _ref.segment; "function" != typeof dataParser && (dataParser = function(line) { return line; }), this.customParsers.push(function(line) { if (expression.exec(line)) return _this3.trigger("data", { type: "custom", data: dataParser(line), customType: customType, segment: segment }), !0; }); }, /** * Add a custom header mapper * * @param {Object} options * @param {RegExp} options.expression a regular expression to match the custom header * @param {Function} options.map function to translate tag into a different tag */ _proto.addTagMapper = function(_ref2) { var expression = _ref2.expression, map = _ref2.map; this.tagMappers.push(function(line) { return expression.test(line) ? map(line) : line; }); }, ParseStream; }(Stream), camelCaseKeys = function(attributes) { var result = {}; return Object.keys(attributes).forEach(function(key) { result[key.toLowerCase().replace(/-(\w)/g, function(a) { return a[1].toUpperCase(); })] = attributes[key]; }), result; }, setHoldBack = function(manifest) { var serverControl = manifest.serverControl, targetDuration = manifest.targetDuration, partTargetDuration = manifest.partTargetDuration; if (serverControl) { var tag = "#EXT-X-SERVER-CONTROL", hb = "holdBack", phb = "partHoldBack", minTargetDuration = targetDuration && 3 * targetDuration, minPartDuration = partTargetDuration && 2 * partTargetDuration; targetDuration && !serverControl.hasOwnProperty(hb) && (serverControl[hb] = minTargetDuration, this.trigger("info", { message: tag + " defaulting HOLD-BACK to targetDuration * 3 (" + minTargetDuration + ")." })), minTargetDuration && serverControl[hb] < minTargetDuration && (this.trigger("warn", { message: tag + " clamping HOLD-BACK (" + serverControl[hb] + ") to targetDuration * 3 (" + minTargetDuration + ")" }), serverControl[hb] = minTargetDuration), partTargetDuration && !serverControl.hasOwnProperty(phb) && (serverControl[phb] = 3 * partTargetDuration, this.trigger("info", { message: tag + " defaulting PART-HOLD-BACK to partTargetDuration * 3 (" + serverControl[phb] + ")." })), partTargetDuration && serverControl[phb] < minPartDuration && (this.trigger("warn", { message: tag + " clamping PART-HOLD-BACK (" + serverControl[phb] + ") to partTargetDuration * 2 (" + minPartDuration + ")." }), serverControl[phb] = minPartDuration); } }, Parser = /*#__PURE__*/ function(_Stream) { function Parser() { (_this = _Stream.call(this) || this).lineStream = new LineStream(), _this.parseStream = new ParseStream(), _this.lineStream.pipe(_this.parseStream); /* eslint-disable consistent-this */ var _this, currentMap, _key, self1 = (0, assertThisInitialized /* default */ .Z)(_this), uris = [], currentUri = {}, hasParts = !1, noop = function() {}, defaultMediaGroups = { AUDIO: {}, VIDEO: {}, "CLOSED-CAPTIONS": {}, SUBTITLES: {} }, currentTimeline = 0; _this.manifest = { allowCache: !0, discontinuityStarts: [], segments: [] }; // to provide the offset, in which case it defaults to the next byte after the // previous segment var lastByterangeEnd = 0, lastPartByterangeEnd = 0; // keep track of the last seen part's byte range end. return _this.on("end", function() { // only add preloadSegment if we don't yet have a uri for it. // and we actually have parts/preloadHints !currentUri.uri && (currentUri.parts || currentUri.preloadHints) && (!currentUri.map && currentMap && (currentUri.map = currentMap), !currentUri.key && _key && (currentUri.key = _key), currentUri.timeline || "number" != typeof currentTimeline || (currentUri.timeline = currentTimeline), _this.manifest.preloadSegment = currentUri); }), _this.parseStream.on("data", function(entry) { var mediaGroup, rendition; ({ tag: function() { // switch based on the tag type (({ version: function() { entry.version && (this.manifest.version = entry.version); }, "allow-cache": function() { this.manifest.allowCache = entry.allowed, "allowed" in entry || (this.trigger("info", { message: "defaulting allowCache to YES" }), this.manifest.allowCache = !0); }, byterange: function() { var byterange = {}; "length" in entry && (currentUri.byterange = byterange, byterange.length = entry.length, "offset" in entry || /* * From the latest spec (as of this writing): * https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.2 * * Same text since EXT-X-BYTERANGE's introduction in draft 7: * https://tools.ietf.org/html/draft-pantos-http-live-streaming-07#section-3.3.1) * * "If o [offset] is not present, the sub-range begins at the next byte * following the sub-range of the previous media segment." */ (entry.offset = lastByterangeEnd)), "offset" in entry && (currentUri.byterange = byterange, byterange.offset = entry.offset), lastByterangeEnd = byterange.offset + byterange.length; }, endlist: function() { this.manifest.endList = !0; }, inf: function() { "mediaSequence" in this.manifest || (this.manifest.mediaSequence = 0, this.trigger("info", { message: "defaulting media sequence to zero" })), "discontinuitySequence" in this.manifest || (this.manifest.discontinuitySequence = 0, this.trigger("info", { message: "defaulting discontinuity sequence to zero" })), entry.duration > 0 && (currentUri.duration = entry.duration), 0 === entry.duration && (currentUri.duration = 0.01, this.trigger("info", { message: "updating zero segment duration to a small value" })), this.manifest.segments = uris; }, key: function() { if (!entry.attributes) { this.trigger("warn", { message: "ignoring key declaration without attribute list" }); return; } // clear the active encryption key if ("NONE" === entry.attributes.METHOD) { _key = null; return; } if (!entry.attributes.URI) { this.trigger("warn", { message: "ignoring key declaration without URI" }); return; } if ("com.apple.streamingkeydelivery" === entry.attributes.KEYFORMAT) { this.manifest.contentProtection = this.manifest.contentProtection || {}, this.manifest.contentProtection["com.apple.fps.1_0"] = { attributes: entry.attributes }; return; } // check if the content is encrypted for Widevine // Widevine/HLS spec: https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf if ("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" === entry.attributes.KEYFORMAT) { if (-1 === [ "SAMPLE-AES", "SAMPLE-AES-CTR", "SAMPLE-AES-CENC" ].indexOf(entry.attributes.METHOD)) { this.trigger("warn", { message: "invalid key method provided for Widevine" }); return; } if ("SAMPLE-AES-CENC" === entry.attributes.METHOD && this.trigger("warn", { message: "SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead" }), "data:text/plain;base64," !== entry.attributes.URI.substring(0, 23)) { this.trigger("warn", { message: "invalid key URI provided for Widevine" }); return; } if (!(entry.attributes.KEYID && "0x" === entry.attributes.KEYID.substring(0, 2))) { this.trigger("warn", { message: "invalid key ID provided for Widevine" }); return; } // if Widevine key attributes are valid, store them as `contentProtection` // on the manifest to emulate Widevine tag structure in a DASH mpd this.manifest.contentProtection = this.manifest.contentProtection || {}, this.manifest.contentProtection["com.widevine.alpha"] = { attributes: { schemeIdUri: entry.attributes.KEYFORMAT, // remove '0x' from the key id string keyId: entry.attributes.KEYID.substring(2) }, // decode the base64-encoded PSSH box pssh: (0, decode_b64_to_uint8_array /* default */ .Z)(entry.attributes.URI.split(",")[1]) }; return; } entry.attributes.METHOD || this.trigger("warn", { message: "defaulting key method to AES-128" }), _key = { method: entry.attributes.METHOD || "AES-128", uri: entry.attributes.URI }, void 0 !== entry.attributes.IV && (_key.iv = entry.attributes.IV); }, "media-sequence": function() { if (!isFinite(entry.number)) { this.trigger("warn", { message: "ignoring invalid media sequence: " + entry.number }); return; } this.manifest.mediaSequence = entry.number; }, "discontinuity-sequence": function() { if (!isFinite(entry.number)) { this.trigger("warn", { message: "ignoring invalid discontinuity sequence: " + entry.number }); return; } this.manifest.discontinuitySequence = entry.number, currentTimeline = entry.number; }, "playlist-type": function() { if (!/VOD|EVENT/.test(entry.playlistType)) { this.trigger("warn", { message: "ignoring unknown playlist type: " + entry.playlist }); return; } this.manifest.playlistType = entry.playlistType; }, map: function() { currentMap = {}, entry.uri && (currentMap.uri = entry.uri), entry.byterange && (currentMap.byterange = entry.byterange), _key && (currentMap.key = _key); }, "stream-inf": function() { if (this.manifest.playlists = uris, this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups, !entry.attributes) { this.trigger("warn", { message: "ignoring empty stream-inf attributes" }); return; } currentUri.attributes || (currentUri.attributes = {}), (0, esm_extends /* default */ .Z)(currentUri.attributes, entry.attributes); }, media: function() { if (this.manifest.mediaGroups = this.manifest.mediaGroups || defaultMediaGroups, !(entry.attributes && entry.attributes.TYPE && entry.attributes["GROUP-ID"] && entry.attributes.NAME)) { this.trigger("warn", { message: "ignoring incomplete or missing media group" }); return; } // find the media group, creating defaults as necessary var mediaGroupType = this.manifest.mediaGroups[entry.attributes.TYPE]; mediaGroupType[entry.attributes["GROUP-ID"]] = mediaGroupType[entry.attributes["GROUP-ID"]] || {}, mediaGroup = mediaGroupType[entry.attributes["GROUP-ID"]], (rendition = { default: /yes/i.test(entry.attributes.DEFAULT) }).default ? rendition.autoselect = !0 : rendition.autoselect = /yes/i.test(entry.attributes.AUTOSELECT), entry.attributes.LANGUAGE && (rendition.language = entry.attributes.LANGUAGE), entry.attributes.URI && (rendition.uri = entry.attributes.URI), entry.attributes["INSTREAM-ID"] && (rendition.instreamId = entry.attributes["INSTREAM-ID"]), entry.attributes.CHARACTERISTICS && (rendition.characteristics = entry.attributes.CHARACTERISTICS), entry.attributes.FORCED && (rendition.forced = /yes/i.test(entry.attributes.FORCED)), mediaGroup[entry.attributes.NAME] = rendition; }, discontinuity: function() { currentTimeline += 1, currentUri.discontinuity = !0, this.manifest.discontinuityStarts.push(uris.length); }, "program-date-time": function() { void 0 === this.manifest.dateTimeString && (// PROGRAM-DATE-TIME is a media-segment tag, but for backwards // compatibility, we add the first occurence of the PROGRAM-DATE-TIME tag // to the manifest object // TODO: Consider removing this in future major version this.manifest.dateTimeString = entry.dateTimeString, this.manifest.dateTimeObject = entry.dateTimeObject), currentUri.dateTimeString = entry.dateTimeString, currentUri.dateTimeObject = entry.dateTimeObject; }, targetduration: function() { if (!isFinite(entry.duration) || entry.duration < 0) { this.trigger("warn", { message: "ignoring invalid target duration: " + entry.duration }); return; } this.manifest.targetDuration = entry.duration, setHoldBack.call(this, this.manifest); }, start: function() { if (!entry.attributes || isNaN(entry.attributes["TIME-OFFSET"])) { this.trigger("warn", { message: "ignoring start declaration without appropriate attribute list" }); return; } this.manifest.start = { timeOffset: entry.attributes["TIME-OFFSET"], precise: entry.attributes.PRECISE }; }, "cue-out": function() { currentUri.cueOut = entry.data; }, "cue-out-cont": function() { currentUri.cueOutCont = entry.data; }, "cue-in": function() { currentUri.cueIn = entry.data; }, skip: function() { this.manifest.skip = camelCaseKeys(entry.attributes), this.warnOnMissingAttributes_("#EXT-X-SKIP", entry.attributes, [ "SKIPPED-SEGMENTS" ]); }, part: function() { var _this2 = this; hasParts = !0; var segmentIndex = this.manifest.segments.length, part = camelCaseKeys(entry.attributes); currentUri.parts = currentUri.parts || [], currentUri.parts.push(part), part.byterange && (part.byterange.hasOwnProperty("offset") || (part.byterange.offset = lastPartByterangeEnd), lastPartByterangeEnd = part.byterange.offset + part.byterange.length); var partIndex = currentUri.parts.length - 1; this.warnOnMissingAttributes_("#EXT-X-PART #" + partIndex + " for segment #" + segmentIndex, entry.attributes, [ "URI", "DURATION" ]), this.manifest.renditionReports && this.manifest.renditionReports.forEach(function(r, i) { r.hasOwnProperty("lastPart") || _this2.trigger("warn", { message: "#EXT-X-RENDITION-REPORT #" + i + " lacks required attribute(s): LAST-PART" }); }); }, "server-control": function() { var attrs = this.manifest.serverControl = camelCaseKeys(entry.attributes); attrs.hasOwnProperty("canBlockReload") || (attrs.canBlockReload = !1, this.trigger("info", { message: "#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false" })), setHoldBack.call(this, this.manifest), attrs.canSkipDateranges && !attrs.hasOwnProperty("canSkipUntil") && this.trigger("warn", { message: "#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set" }); }, "preload-hint": function() { // parts are always specifed before a segment var segmentIndex = this.manifest.segments.length, hint = camelCaseKeys(entry.attributes), isPart = hint.type && "PART" === hint.type; currentUri.preloadHints = currentUri.preloadHints || [], currentUri.preloadHints.push(hint), hint.byterange && !hint.byterange.hasOwnProperty("offset") && (// use last part byterange end or zero if not a part. hint.byterange.offset = isPart ? lastPartByterangeEnd : 0, isPart && (lastPartByterangeEnd = hint.byterange.offset + hint.byterange.length)); var index = currentUri.preloadHints.length - 1; if (this.warnOnMissingAttributes_("#EXT-X-PRELOAD-HINT #" + index + " for segment #" + segmentIndex, entry.attributes, [ "TYPE", "URI" ]), hint.type) // a duplicate type. for(var i = 0; i < currentUri.preloadHints.length - 1; i++){ var otherHint = currentUri.preloadHints[i]; otherHint.type && otherHint.type === hint.type && this.trigger("warn", { message: "#EXT-X-PRELOAD-HINT #" + index + " for segment #" + segmentIndex + " has the same TYPE " + hint.type + " as preload hint #" + i }); } // search through all preload hints except for the current one for }, "rendition-report": function() { var report = camelCaseKeys(entry.attributes); this.manifest.renditionReports = this.manifest.renditionReports || [], this.manifest.renditionReports.push(report); var index = this.manifest.renditionReports.length - 1, required = [ "LAST-MSN", "URI" ]; hasParts && required.push("LAST-PART"), this.warnOnMissingAttributes_("#EXT-X-RENDITION-REPORT #" + index, entry.attributes, required); }, "part-inf": function() { this.manifest.partInf = camelCaseKeys(entry.attributes), this.warnOnMissingAttributes_("#EXT-X-PART-INF", entry.attributes, [ "PART-TARGET" ]), this.manifest.partInf.partTarget && (this.manifest.partTargetDuration = this.manifest.partInf.partTarget), setHoldBack.call(this, this.manifest); } })[entry.tagType] || noop).call(self1); }, uri: function() { currentUri.uri = entry.uri, uris.push(currentUri), !this.manifest.targetDuration || "duration" in currentUri || (this.trigger("warn", { message: "defaulting segment duration to the target duration" }), currentUri.duration = this.manifest.targetDuration), _key && (currentUri.key = _key), currentUri.timeline = currentTimeline, currentMap && (currentUri.map = currentMap), lastPartByterangeEnd = 0, currentUri = {}; }, comment: function() { // comments are not important for playback }, custom: function() { // if this is segment-level data attach the output to the segment entry.segment ? (currentUri.custom = currentUri.custom || {}, currentUri.custom[entry.customType] = entry.data) : (this.manifest.custom = this.manifest.custom || {}, this.manifest.custom[entry.customType] = entry.data); } })[entry.type].call(self1); }), _this; } (0, inheritsLoose /* default */ .Z)(Parser, _Stream); var _proto = Parser.prototype; return _proto.warnOnMissingAttributes_ = function(identifier, attributes, required) { var missing = []; required.forEach(function(key) { attributes.hasOwnProperty(key) || missing.push(key); }), missing.length && this.trigger("warn", { message: identifier + " lacks required attribute(s): " + missing.join(", ") }); }, /** * Parse the input string and update the manifest object. * * @param {string} chunk a potentially incomplete portion of the manifest */ _proto.push = function(chunk) { this.lineStream.push(chunk); }, /** * Flush any remaining input. This can be handy if the last line of an M3U8 * manifest did not contain a trailing newline but the file has been * completely received. */ _proto.end = function() { // flush any buffered input this.lineStream.push("\n"), this.trigger("end"); }, /** * Add an additional parser for non-standard tags * * @param {Object} options a map of options for the added parser * @param {RegExp} options.expression a regular expression to match the custom header * @param {string} options.type the type to register to the output * @param {Function} [options.dataParser] function to parse the line into an object * @param {boolean} [options.segment] should tag data be attached to the segment object */ _proto.addParser = function(options) { this.parseStream.addParser(options); }, /** * Add a custom header mapper * * @param {Object} options * @param {RegExp} options.expression a regular expression to match the custom header * @param {Function} options.map function to translate tag into a different tag */ _proto.addTagMapper = function(options) { this.parseStream.addTagMapper(options); }, Parser; }(Stream); // CONCATENATED MODULE: ./node_modules/@videojs/vhs-utils/es/stream.js /***/ }, /***/ 973: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ jp: function() { return /* binding */ addSidxSegmentsToPlaylist; }, /* harmony export */ mm: function() { return /* binding */ generateSidxKey; }, /* harmony export */ Qc: function() { return /* binding */ parse; }, /* harmony export */ LG: function() { return /* binding */ parseUTCTiming; } }); /* unused harmony exports VERSION, inheritAttributes, stringToMpdXml, toM3u8, toPlaylists */ /* harmony import */ var _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(779), global_window__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8908), global_window__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_1__), _videojs_vhs_utils_es_decode_b64_to_uint8_array__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6722), _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3969), isObject = function(obj) { return !!obj && "object" == typeof obj; }, merge = function merge() { for(var _len = arguments.length, objects = Array(_len), _key = 0; _key < _len; _key++)objects[_key] = arguments[_key]; return objects.reduce(function(result, source) { return "object" != typeof source || Object.keys(source).forEach(function(key) { Array.isArray(result[key]) && Array.isArray(source[key]) ? result[key] = result[key].concat(source[key]) : isObject(result[key]) && isObject(source[key]) ? result[key] = merge(result[key], source[key]) : result[key] = source[key]; }), result; }, {}); }, range = function(start, end) { for(var result = [], i = start; i < end; i++)result.push(i); return result; }, flatten = function(lists) { return lists.reduce(function(x, y) { return x.concat(y); }, []); }, from = function(list) { if (!list.length) return []; for(var result = [], i = 0; i < list.length; i++)result.push(list[i]); return result; }, errors = { INVALID_NUMBER_OF_PERIOD: "INVALID_NUMBER_OF_PERIOD", DASH_EMPTY_MANIFEST: "DASH_EMPTY_MANIFEST", DASH_INVALID_XML: "DASH_INVALID_XML", NO_BASE_URL: "NO_BASE_URL", SEGMENT_TIME_UNSPECIFIED: "SEGMENT_TIME_UNSPECIFIED", UNSUPPORTED_UTC_TIMING_SCHEME: "UNSUPPORTED_UTC_TIMING_SCHEME" }, urlTypeToSegment = function(_ref) { var _ref$baseUrl = _ref.baseUrl, _ref$source = _ref.source, source = void 0 === _ref$source ? "" : _ref$source, _ref$range = _ref.range, range = void 0 === _ref$range ? "" : _ref$range, _ref$indexRange = _ref.indexRange, indexRange = void 0 === _ref$indexRange ? "" : _ref$indexRange, segment = { uri: source, resolvedUri: (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */ .Z)((void 0 === _ref$baseUrl ? "" : _ref$baseUrl) || "", source) }; if (range || indexRange) { var ranges = (range || indexRange).split("-"), startRange = parseInt(ranges[0], 10); // RFC 2616, Clause 14.35.1 segment.byterange = { length: parseInt(ranges[1], 10) - startRange + 1, offset: startRange }; } return segment; }, byteRangeToString = function(byterange) { // `endRange` is one less than `offset + length` because the HTTP range // header uses inclusive ranges var endRange = byterange.offset + byterange.length - 1; return byterange.offset + "-" + endRange; }, parseEndNumber = function(endNumber) { return (endNumber && "number" != typeof endNumber && (endNumber = parseInt(endNumber, 10)), isNaN(endNumber)) ? null : endNumber; }, segmentRange = { /** * Returns the entire range of available segments for a static MPD * * @param {Object} attributes * Inheritied MPD attributes * @return {{ start: number, end: number }} * The start and end numbers for available segments */ static: function(attributes) { var duration = attributes.duration, _attributes$timescale = attributes.timescale, sourceDuration = attributes.sourceDuration, periodDuration = attributes.periodDuration, endNumber = parseEndNumber(attributes.endNumber), segmentDuration = duration / (void 0 === _attributes$timescale ? 1 : _attributes$timescale); return "number" == typeof endNumber ? { start: 0, end: endNumber } : "number" == typeof periodDuration ? { start: 0, end: periodDuration / segmentDuration } : { start: 0, end: sourceDuration / segmentDuration }; }, /** * Returns the current live window range of available segments for a dynamic MPD * * @param {Object} attributes * Inheritied MPD attributes * @return {{ start: number, end: number }} * The start and end numbers for available segments */ dynamic: function(attributes) { var NOW = attributes.NOW, clientOffset = attributes.clientOffset, availabilityStartTime = attributes.availabilityStartTime, _attributes$timescale2 = attributes.timescale, timescale = void 0 === _attributes$timescale2 ? 1 : _attributes$timescale2, duration = attributes.duration, _attributes$start = attributes.start, _attributes$minimumUp = attributes.minimumUpdatePeriod, _attributes$timeShift = attributes.timeShiftBufferDepth, endNumber = parseEndNumber(attributes.endNumber), now = (NOW + clientOffset) / 1000, periodStartWC = availabilityStartTime + (void 0 === _attributes$start ? 0 : _attributes$start), segmentCount = Math.ceil((now + (void 0 === _attributes$minimumUp ? 0 : _attributes$minimumUp) - periodStartWC) * timescale / duration), availableStart = Math.floor((now - periodStartWC - (void 0 === _attributes$timeShift ? 1 / 0 : _attributes$timeShift)) * timescale / duration), availableEnd = Math.floor((now - periodStartWC) * timescale / duration); return { start: Math.max(0, availableStart), end: "number" == typeof endNumber ? endNumber : Math.min(segmentCount, availableEnd) }; } }, parseByDuration = function(attributes) { var type = attributes.type, duration = attributes.duration, _attributes$timescale4 = attributes.timescale, periodDuration = attributes.periodDuration, sourceDuration = attributes.sourceDuration, _segmentRange$type = segmentRange[type](attributes), segments = range(_segmentRange$type.start, _segmentRange$type.end).map(function(number, index) { var duration = attributes.duration, _attributes$timescale3 = attributes.timescale, periodIndex = attributes.periodIndex, _attributes$startNumb = attributes.startNumber; return { number: (void 0 === _attributes$startNumb ? 1 : _attributes$startNumb) + number, duration: duration / (void 0 === _attributes$timescale3 ? 1 : _attributes$timescale3), timeline: periodIndex, time: index * duration }; }); if ("static" === type) { var index = segments.length - 1; // section is either a period or the full source segments[index].duration = ("number" == typeof periodDuration ? periodDuration : sourceDuration) - duration / (void 0 === _attributes$timescale4 ? 1 : _attributes$timescale4) * index; } return segments; }, segmentsFromBase = function(attributes) { var baseUrl = attributes.baseUrl, _attributes$initializ = attributes.initialization, initialization = void 0 === _attributes$initializ ? {} : _attributes$initializ, sourceDuration = attributes.sourceDuration, _attributes$indexRang = attributes.indexRange, duration = attributes.duration; // base url is required for SegmentBase to work, per spec (Section 5.3.9.2.1) if (!baseUrl) throw Error(errors.NO_BASE_URL); var initSegment = urlTypeToSegment({ baseUrl: baseUrl, source: initialization.sourceURL, range: initialization.range }), segment = urlTypeToSegment({ baseUrl: baseUrl, source: baseUrl, indexRange: void 0 === _attributes$indexRang ? "" : _attributes$indexRang }); // (since SegmentBase is only for one total segment) if (segment.map = initSegment, duration) { var segmentTimeInfo = parseByDuration(attributes); segmentTimeInfo.length && (segment.duration = segmentTimeInfo[0].duration, segment.timeline = segmentTimeInfo[0].timeline); } else sourceDuration && (segment.duration = sourceDuration, segment.timeline = 0); // This is used for mediaSequence return segment.number = 0, [ segment ]; }, addSidxSegmentsToPlaylist = function(playlist, sidx, baseUrl) { for(var initSegment = playlist.sidx.map ? playlist.sidx.map : null, sourceDuration = playlist.sidx.duration, timeline = playlist.timeline || 0, sidxByteRange = playlist.sidx.byterange, sidxEnd = sidxByteRange.offset + sidxByteRange.length, timescale = sidx.timescale, mediaReferences = sidx.references.filter(function(r) { return 1 !== r.referenceType; }), segments = [], type = playlist.endList ? "static" : "dynamic", startIndex = sidxEnd + sidx.firstOffset, i = 0; i < mediaReferences.length; i++){ var reference = sidx.references[i], size = reference.referencedSize, duration = reference.subsegmentDuration, endIndex = startIndex + size - 1, segment = segmentsFromBase({ baseUrl: baseUrl, timescale: timescale, timeline: timeline, // this is used in parseByDuration periodIndex: timeline, duration: duration, sourceDuration: sourceDuration, indexRange: startIndex + "-" + endIndex, type: type })[0]; // size of the referenced (sub)segment initSegment && (segment.map = initSegment), segments.push(segment), startIndex += size; } return playlist.segments = segments, playlist; }, generateSidxKey = function(sidx) { return sidx && sidx.uri + "-" + byteRangeToString(sidx.byterange); }, mergeDiscontiguousPlaylists = function(playlists) { var o; return Object.keys(o = playlists.reduce(function(acc, playlist) { // assuming playlist IDs are the same across periods // TODO: handle multiperiod where representation sets are not the same // across periods var _acc$name$segments, name = playlist.attributes.id + (playlist.attributes.lang || ""); // Periods after first return acc[name] ? (playlist.segments[0] && (playlist.segments[0].discontinuity = !0), (_acc$name$segments = acc[name].segments).push.apply(_acc$name$segments, playlist.segments), playlist.attributes.contentProtection && (acc[name].attributes.contentProtection = playlist.attributes.contentProtection)) : // first Period acc[name] = playlist, acc; }, {})).map(function(k) { return o[k]; }).map(function(playlist) { return playlist.discontinuityStarts = playlist.segments.reduce(function(a, e, i) { return e.discontinuity && a.push(i), a; }, []), playlist; }); }, addSidxSegmentsToPlaylist$1 = function(playlist, sidxMapping) { var sidxKey = generateSidxKey(playlist.sidx), sidxMatch = sidxKey && sidxMapping[sidxKey] && sidxMapping[sidxKey].sidx; return sidxMatch && addSidxSegmentsToPlaylist(playlist, sidxMatch, playlist.sidx.resolvedUri), playlist; }, addSidxSegmentsToPlaylists = function(playlists, sidxMapping) { if (void 0 === sidxMapping && (sidxMapping = {}), !Object.keys(sidxMapping).length) return playlists; for(var i in playlists)playlists[i] = addSidxSegmentsToPlaylist$1(playlists[i], sidxMapping); return playlists; }, formatAudioPlaylist = function(_ref, isAudioOnly) { var _attributes, attributes = _ref.attributes, segments = _ref.segments, sidx = _ref.sidx, playlist = { attributes: ((_attributes = { NAME: attributes.id, BANDWIDTH: attributes.bandwidth, CODECS: attributes.codecs })["PROGRAM-ID"] = 1, _attributes), uri: "", endList: "static" === attributes.type, timeline: attributes.periodIndex, resolvedUri: "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1 }; return attributes.contentProtection && (playlist.contentProtection = attributes.contentProtection), sidx && (playlist.sidx = sidx), isAudioOnly && (playlist.attributes.AUDIO = "audio", playlist.attributes.SUBTITLES = "subs"), playlist; }, formatVttPlaylist = function(_ref2) { var _m3u8Attributes, attributes = _ref2.attributes, segments = _ref2.segments; void 0 === segments && (// vtt tracks may use single file in BaseURL segments = [ { uri: attributes.baseUrl, timeline: attributes.periodIndex, resolvedUri: attributes.baseUrl || "", duration: attributes.sourceDuration, number: 0 } ], attributes.duration = attributes.sourceDuration); var m3u8Attributes = ((_m3u8Attributes = { NAME: attributes.id, BANDWIDTH: attributes.bandwidth })["PROGRAM-ID"] = 1, _m3u8Attributes); return attributes.codecs && (m3u8Attributes.CODECS = attributes.codecs), { attributes: m3u8Attributes, uri: "", endList: "static" === attributes.type, timeline: attributes.periodIndex, resolvedUri: attributes.baseUrl || "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1 }; }, organizeAudioPlaylists = function(playlists, sidxMapping, isAudioOnly) { void 0 === sidxMapping && (sidxMapping = {}), void 0 === isAudioOnly && (isAudioOnly = !1); var mainPlaylist, formattedPlaylists = playlists.reduce(function(a, playlist) { var role = playlist.attributes.role && playlist.attributes.role.value || "", language = playlist.attributes.lang || "", label = playlist.attributes.label || "main"; language && !playlist.attributes.label && (label = "" + playlist.attributes.lang + (role ? " (" + role + ")" : "")), a[label] || (a[label] = { language: language, autoselect: !0, default: "main" === role, playlists: [], uri: "" }); var formatted = addSidxSegmentsToPlaylist$1(formatAudioPlaylist(playlist, isAudioOnly), sidxMapping); return a[label].playlists.push(formatted), void 0 === mainPlaylist && "main" === role && ((mainPlaylist = playlist).default = !0), a; }, {}); // if no playlists have role "main", mark the first as main if (!mainPlaylist) { var firstLabel = Object.keys(formattedPlaylists)[0]; formattedPlaylists[firstLabel].default = !0; } return formattedPlaylists; }, formatVideoPlaylist = function(_ref3) { var _attributes2, attributes = _ref3.attributes, segments = _ref3.segments, sidx = _ref3.sidx, playlist = { attributes: ((_attributes2 = { NAME: attributes.id, AUDIO: "audio", SUBTITLES: "subs", RESOLUTION: { width: attributes.width, height: attributes.height }, CODECS: attributes.codecs, BANDWIDTH: attributes.bandwidth })["PROGRAM-ID"] = 1, _attributes2), uri: "", endList: "static" === attributes.type, timeline: attributes.periodIndex, resolvedUri: "", targetDuration: attributes.duration, segments: segments, mediaSequence: segments.length ? segments[0].number : 1 }; return attributes.contentProtection && (playlist.contentProtection = attributes.contentProtection), sidx && (playlist.sidx = sidx), playlist; }, videoOnly = function(_ref4) { var attributes = _ref4.attributes; return "video/mp4" === attributes.mimeType || "video/webm" === attributes.mimeType || "video" === attributes.contentType; }, audioOnly = function(_ref5) { var attributes = _ref5.attributes; return "audio/mp4" === attributes.mimeType || "audio/webm" === attributes.mimeType || "audio" === attributes.contentType; }, vttOnly = function(_ref6) { var attributes = _ref6.attributes; return "text/vtt" === attributes.mimeType || "text" === attributes.contentType; }, toM3u8 = function(dashPlaylists, locations, sidxMapping) { if (void 0 === sidxMapping && (sidxMapping = {}), !dashPlaylists.length) return {}; // grab all main manifest attributes var sidxMapping1, _mediaGroups, _dashPlaylists$0$attr = dashPlaylists[0].attributes, duration = _dashPlaylists$0$attr.sourceDuration, type = _dashPlaylists$0$attr.type, suggestedPresentationDelay = _dashPlaylists$0$attr.suggestedPresentationDelay, minimumUpdatePeriod = _dashPlaylists$0$attr.minimumUpdatePeriod, videoPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(videoOnly)).map(formatVideoPlaylist), audioPlaylists = mergeDiscontiguousPlaylists(dashPlaylists.filter(audioOnly)), vttPlaylists = dashPlaylists.filter(vttOnly), captions = dashPlaylists.map(function(playlist) { return playlist.attributes.captionServices; }).filter(Boolean), manifest = { allowCache: !0, discontinuityStarts: [], segments: [], endList: !0, mediaGroups: ((_mediaGroups = { AUDIO: {}, VIDEO: {} })["CLOSED-CAPTIONS"] = {}, _mediaGroups.SUBTITLES = {}, _mediaGroups), uri: "", duration: duration, playlists: addSidxSegmentsToPlaylists(videoPlaylists, sidxMapping) }; minimumUpdatePeriod >= 0 && (manifest.minimumUpdatePeriod = 1000 * minimumUpdatePeriod), locations && (manifest.locations = locations), "dynamic" === type && (manifest.suggestedPresentationDelay = suggestedPresentationDelay); var isAudioOnly = 0 === manifest.playlists.length; return audioPlaylists.length && (manifest.mediaGroups.AUDIO.audio = organizeAudioPlaylists(audioPlaylists, sidxMapping, isAudioOnly)), vttPlaylists.length && (manifest.mediaGroups.SUBTITLES.subs = (void 0 === (sidxMapping1 = sidxMapping) && (sidxMapping1 = {}), vttPlaylists.reduce(function(a, playlist) { var label = playlist.attributes.lang || "text"; return a[label] || (a[label] = { language: label, default: !1, autoselect: !1, playlists: [], uri: "" }), a[label].playlists.push(addSidxSegmentsToPlaylist$1(formatVttPlaylist(playlist), sidxMapping1)), a; }, {}))), captions.length && (manifest.mediaGroups["CLOSED-CAPTIONS"].cc = captions.reduce(function(svcObj, svc) { return svc && svc.forEach(function(service) { var channel = service.channel, language = service.language; svcObj[language] = { autoselect: !1, default: !1, instreamId: channel, language: language }, service.hasOwnProperty("aspectRatio") && (svcObj[language].aspectRatio = service.aspectRatio), service.hasOwnProperty("easyReader") && (svcObj[language].easyReader = service.easyReader), service.hasOwnProperty("3D") && (svcObj[language]["3D"] = service["3D"]); }), svcObj; }, {})), manifest; }, getLiveRValue = function(attributes, time, duration) { var NOW = attributes.NOW, clientOffset = attributes.clientOffset, availabilityStartTime = attributes.availabilityStartTime, _attributes$timescale = attributes.timescale, _attributes$start = attributes.start, _attributes$minimumUp = attributes.minimumUpdatePeriod; return Math.ceil((((NOW + clientOffset) / 1000 + (void 0 === _attributes$minimumUp ? 0 : _attributes$minimumUp) - (availabilityStartTime + (void 0 === _attributes$start ? 0 : _attributes$start))) * (void 0 === _attributes$timescale ? 1 : _attributes$timescale) - time) / duration); }, parseByTimeline = function(attributes, segmentTimeline) { for(var type = attributes.type, _attributes$minimumUp2 = attributes.minimumUpdatePeriod, minimumUpdatePeriod = void 0 === _attributes$minimumUp2 ? 0 : _attributes$minimumUp2, _attributes$media = attributes.media, media = void 0 === _attributes$media ? "" : _attributes$media, sourceDuration = attributes.sourceDuration, _attributes$timescale2 = attributes.timescale, timescale = void 0 === _attributes$timescale2 ? 1 : _attributes$timescale2, _attributes$startNumb = attributes.startNumber, startNumber = void 0 === _attributes$startNumb ? 1 : _attributes$startNumb, timeline = attributes.periodIndex, segments = [], time = -1, sIndex = 0; sIndex < segmentTimeline.length; sIndex++){ var S = segmentTimeline[sIndex], duration = S.d, repeat = S.r || 0, segmentTime = S.t || 0; time < 0 && // first segment (time = segmentTime), segmentTime && segmentTime > time && // discontinuity // TODO: How to handle this type of discontinuity // timeline++ here would treat it like HLS discontuity and content would // get appended without gap // E.G. // <S t="0" d="1" /> // <S d="1" /> // <S d="1" /> // <S t="5" d="1" /> // would have $Time$ values of [0, 1, 2, 5] // should this be appened at time positions [0, 1, 2, 3],(#EXT-X-DISCONTINUITY) // or [0, 1, 2, gap, gap, 5]? (#EXT-X-GAP) // does the value of sourceDuration consider this when calculating arbitrary // negative @r repeat value? // E.G. Same elements as above with this added at the end // <S d="1" r="-1" /> // with a sourceDuration of 10 // Would the 2 gaps be included in the time duration calculations resulting in // 8 segments with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9] or 10 segments // with $Time$ values of [0, 1, 2, 5, 6, 7, 8, 9, 10, 11] ? (time = segmentTime); var count = void 0; if (repeat < 0) { var nextS = sIndex + 1; count = nextS === segmentTimeline.length ? "dynamic" === type && minimumUpdatePeriod > 0 && media.indexOf("$Number$") > 0 ? getLiveRValue(attributes, time, duration) : (sourceDuration * timescale - time) / duration : (segmentTimeline[nextS].t - time) / duration; } else count = repeat + 1; for(var end = startNumber + segments.length + count, number = startNumber + segments.length; number < end;)segments.push({ number: number, duration: duration / timescale, time: time, timeline: timeline }), time += duration, number++; } return segments; }, identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g, constructTemplateUrl = function(url, values) { return url.replace(identifierPattern, function(match, identifier, format, width) { if ("$$" === match) // escape sequence return "$"; if (void 0 === values[identifier]) return match; var value = "" + values[identifier]; return "RepresentationID" === identifier ? value : (width = format ? parseInt(width, 10) : 1, value.length >= width) ? value : "" + Array(width - value.length + 1).join("0") + value; }); }, segmentsFromTemplate = function(attributes, segmentTimeline) { var templateValues = { RepresentationID: attributes.id, Bandwidth: attributes.bandwidth || 0 }, _attributes$initializ = attributes.initialization, initialization = void 0 === _attributes$initializ ? { sourceURL: "", range: "" } : _attributes$initializ, mapSegment = urlTypeToSegment({ baseUrl: attributes.baseUrl, source: constructTemplateUrl(initialization.sourceURL, templateValues), range: initialization.range }); return (attributes.duration || segmentTimeline ? attributes.duration ? parseByDuration(attributes) : parseByTimeline(attributes, segmentTimeline) : [ { number: attributes.startNumber || 1, duration: attributes.sourceDuration, time: 0, timeline: attributes.periodIndex } ]).map(function(segment) { templateValues.Number = segment.number, templateValues.Time = segment.time; var uri = constructTemplateUrl(attributes.media || "", templateValues), timescale = attributes.timescale || 1, presentationTimeOffset = attributes.presentationTimeOffset || 0, presentationTime = // calculated in mpd-parser prior to this, so it's assumed to be available. attributes.periodStart + (segment.time - presentationTimeOffset) / timescale; // See DASH spec section 5.3.9.2.2 return { uri: uri, timeline: segment.timeline, duration: segment.duration, resolvedUri: (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */ .Z)(attributes.baseUrl || "", uri), map: mapSegment, number: segment.number, presentationTime: presentationTime }; }); }, SegmentURLToSegmentObject = function(attributes, segmentUrl) { var baseUrl = attributes.baseUrl, _attributes$initializ = attributes.initialization, initialization = void 0 === _attributes$initializ ? {} : _attributes$initializ, initSegment = urlTypeToSegment({ baseUrl: baseUrl, source: initialization.sourceURL, range: initialization.range }), segment = urlTypeToSegment({ baseUrl: baseUrl, source: segmentUrl.media, range: segmentUrl.mediaRange }); return segment.map = initSegment, segment; }, segmentsFromList = function(attributes, segmentTimeline) { var segmentTimeInfo, duration = attributes.duration, _attributes$segmentUr = attributes.segmentUrls, periodStart = attributes.periodStart; // Per spec (5.3.9.2.1) no way to determine segment duration OR // if both SegmentTimeline and @duration are defined, it is outside of spec. if (!duration && !segmentTimeline || duration && segmentTimeline) throw Error(errors.SEGMENT_TIME_UNSPECIFIED); var segmentUrlMap = (void 0 === _attributes$segmentUr ? [] : _attributes$segmentUr).map(function(segmentUrlObject) { return SegmentURLToSegmentObject(attributes, segmentUrlObject); }); return duration && (segmentTimeInfo = parseByDuration(attributes)), segmentTimeline && (segmentTimeInfo = parseByTimeline(attributes, segmentTimeline)), segmentTimeInfo.map(function(segmentTime, index) { if (segmentUrlMap[index]) { var segment = segmentUrlMap[index], timescale = attributes.timescale || 1, presentationTimeOffset = attributes.presentationTimeOffset || 0; // See DASH spec section 5.3.9.2.2 return segment.timeline = segmentTime.timeline, segment.duration = segmentTime.duration, segment.number = segmentTime.number, segment.presentationTime = periodStart + (segmentTime.time - presentationTimeOffset) / timescale, segment; } // Since we're mapping we should get rid of any blank segments (in case // the given SegmentTimeline is handling for more elements than we have // SegmentURLs for). }).filter(function(segment) { return segment; }); }, generateSegments = function(_ref) { var segmentAttributes, segmentsFn, attributes = _ref.attributes, segmentInfo = _ref.segmentInfo; segmentInfo.template ? (segmentsFn = segmentsFromTemplate, segmentAttributes = merge(attributes, segmentInfo.template)) : segmentInfo.base ? (segmentsFn = segmentsFromBase, segmentAttributes = merge(attributes, segmentInfo.base)) : segmentInfo.list && (segmentsFn = segmentsFromList, segmentAttributes = merge(attributes, segmentInfo.list)); var segmentsInfo = { attributes: attributes }; if (!segmentsFn) return segmentsInfo; var segments = segmentsFn(segmentAttributes, segmentInfo.segmentTimeline); // The @duration attribute will be used to determin the playlist's targetDuration which // must be in seconds. Since we've generated the segment list, we no longer need // @duration to be in @timescale units, so we can convert it here. if (segmentAttributes.duration) { var _segmentAttributes = segmentAttributes, duration = _segmentAttributes.duration, _segmentAttributes$ti = _segmentAttributes.timescale; segmentAttributes.duration = duration / (void 0 === _segmentAttributes$ti ? 1 : _segmentAttributes$ti); } else segments.length ? // if there is no @duration attribute, use the largest segment duration as // as target duration segmentAttributes.duration = segments.reduce(function(max, segment) { return Math.max(max, Math.ceil(segment.duration)); }, 0) : segmentAttributes.duration = 0; return segmentsInfo.attributes = segmentAttributes, segmentsInfo.segments = segments, segmentInfo.base && segmentAttributes.indexRange && (segmentsInfo.sidx = segments[0], segmentsInfo.segments = []), segmentsInfo; }, findChildren = function(element, name) { return from(element.childNodes).filter(function(_ref) { return _ref.tagName === name; }); }, getContent = function(element) { return element.textContent.trim(); }, parseDuration = function(str) { var match = /P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(str); if (!match) return 0; var _match$slice = match.slice(1), year = _match$slice[0], month = _match$slice[1], day = _match$slice[2], hour = _match$slice[3], minute = _match$slice[4], second = _match$slice[5]; return 31536000 * parseFloat(year || 0) + 2592000 * parseFloat(month || 0) + 86400 * parseFloat(day || 0) + 3600 * parseFloat(hour || 0) + 60 * parseFloat(minute || 0) + parseFloat(second || 0); }, parsers = { /** * Specifies the duration of the entire Media Presentation. Format is a duration string * as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ mediaPresentationDuration: function(value) { return parseDuration(value); }, /** * Specifies the Segment availability start time for all Segments referred to in this * MPD. For a dynamic manifest, it specifies the anchor for the earliest availability * time. Format is a date string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The date as seconds from unix epoch */ availabilityStartTime: function(value) { var str; return str = value, /^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(str) && (str += "Z"), Date.parse(str) / 1000; }, /** * Specifies the smallest period between potential changes to the MPD. Format is a * duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ minimumUpdatePeriod: function(value) { return parseDuration(value); }, /** * Specifies the suggested presentation delay. Format is a * duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ suggestedPresentationDelay: function(value) { return parseDuration(value); }, /** * specifices the type of mpd. Can be either "static" or "dynamic" * * @param {string} value * value of attribute as a string * * @return {string} * The type as a string */ type: function(value) { return value; }, /** * Specifies the duration of the smallest time shifting buffer for any Representation * in the MPD. Format is a duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ timeShiftBufferDepth: function(value) { return parseDuration(value); }, /** * Specifies the PeriodStart time of the Period relative to the availabilityStarttime. * Format is a duration string as specified in ISO 8601 * * @param {string} value * value of attribute as a string * @return {number} * The duration in seconds */ start: function(value) { return parseDuration(value); }, /** * Specifies the width of the visual presentation * * @param {string} value * value of attribute as a string * @return {number} * The parsed width */ width: function(value) { return parseInt(value, 10); }, /** * Specifies the height of the visual presentation * * @param {string} value * value of attribute as a string * @return {number} * The parsed height */ height: function(value) { return parseInt(value, 10); }, /** * Specifies the bitrate of the representation * * @param {string} value * value of attribute as a string * @return {number} * The parsed bandwidth */ bandwidth: function(value) { return parseInt(value, 10); }, /** * Specifies the number of the first Media Segment in this Representation in the Period * * @param {string} value * value of attribute as a string * @return {number} * The parsed number */ startNumber: function(value) { return parseInt(value, 10); }, /** * Specifies the timescale in units per seconds * * @param {string} value * value of attribute as a string * @return {number} * The parsed timescale */ timescale: function(value) { return parseInt(value, 10); }, /** * Specifies the presentationTimeOffset. * * @param {string} value * value of the attribute as a string * * @return {number} * The parsed presentationTimeOffset */ presentationTimeOffset: function(value) { return parseInt(value, 10); }, /** * Specifies the constant approximate Segment duration * NOTE: The <Period> element also contains an @duration attribute. This duration * specifies the duration of the Period. This attribute is currently not * supported by the rest of the parser, however we still check for it to prevent * errors. * * @param {string} value * value of attribute as a string * @return {number} * The parsed duration */ duration: function(value) { var parsedValue = parseInt(value, 10); return isNaN(parsedValue) ? parseDuration(value) : parsedValue; }, /** * Specifies the Segment duration, in units of the value of the @timescale. * * @param {string} value * value of attribute as a string * @return {number} * The parsed duration */ d: function(value) { return parseInt(value, 10); }, /** * Specifies the MPD start time, in @timescale units, the first Segment in the series * starts relative to the beginning of the Period * * @param {string} value * value of attribute as a string * @return {number} * The parsed time */ t: function(value) { return parseInt(value, 10); }, /** * Specifies the repeat count of the number of following contiguous Segments with the * same duration expressed by the value of @d * * @param {string} value * value of attribute as a string * @return {number} * The parsed number */ r: function(value) { return parseInt(value, 10); }, /** * Default parser for all other attributes. Acts as a no-op and just returns the value * as a string * * @param {string} value * value of attribute as a string * @return {string} * Unparsed value */ DEFAULT: function(value) { return value; } }, parseAttributes = function(el) { return el && el.attributes ? from(el.attributes).reduce(function(a, e) { var parseFn = parsers[e.name] || parsers.DEFAULT; return a[e.name] = parseFn(e.value), a; }, {}) : {}; }, keySystemsMap = { "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b": "org.w3.clearkey", "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": "com.widevine.alpha", "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": "com.microsoft.playready", "urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb": "com.adobe.primetime" }, buildBaseUrls = function(referenceUrls, baseUrlElements) { return baseUrlElements.length ? flatten(referenceUrls.map(function(reference) { return baseUrlElements.map(function(baseUrlElement) { return (0, _videojs_vhs_utils_es_resolve_url__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */ .Z)(reference, getContent(baseUrlElement)); }); })) : referenceUrls; }, getSegmentInformation = function(adaptationSet) { var segmentTemplate = findChildren(adaptationSet, "SegmentTemplate")[0], segmentList = findChildren(adaptationSet, "SegmentList")[0], segmentUrls = segmentList && findChildren(segmentList, "SegmentURL").map(function(s) { return merge({ tag: "SegmentURL" }, parseAttributes(s)); }), segmentBase = findChildren(adaptationSet, "SegmentBase")[0], segmentTimelineParentNode = segmentList || segmentTemplate, segmentTimeline = segmentTimelineParentNode && findChildren(segmentTimelineParentNode, "SegmentTimeline")[0], segmentInitializationParentNode = segmentList || segmentBase || segmentTemplate, segmentInitialization = segmentInitializationParentNode && findChildren(segmentInitializationParentNode, "Initialization")[0], template = segmentTemplate && parseAttributes(segmentTemplate); template && segmentInitialization ? template.initialization = segmentInitialization && parseAttributes(segmentInitialization) : template && template.initialization && // If it is @initialization we convert it to an object since this is the format that // later functions will rely on for the initialization segment. This is only valid // for <SegmentTemplate> (template.initialization = { sourceURL: template.initialization }); var segmentInfo = { template: template, segmentTimeline: segmentTimeline && findChildren(segmentTimeline, "S").map(function(s) { return parseAttributes(s); }), list: segmentList && merge(parseAttributes(segmentList), { segmentUrls: segmentUrls, initialization: parseAttributes(segmentInitialization) }), base: segmentBase && merge(parseAttributes(segmentBase), { initialization: parseAttributes(segmentInitialization) }) }; return Object.keys(segmentInfo).forEach(function(key) { segmentInfo[key] || delete segmentInfo[key]; }), segmentInfo; }, getPeriodStart = function(_ref) { var attributes = _ref.attributes, priorPeriodAttributes = _ref.priorPeriodAttributes, mpdType = _ref.mpdType; return(// Summary of period start time calculation from DASH spec section 5.3.2.1 // // A period's start is the first period's start + time elapsed after playing all // prior periods to this one. Periods continue one after the other in time (without // gaps) until the end of the presentation. // // The value of Period@start should be: // 1. if Period@start is present: value of Period@start // 2. if previous period exists and it has @duration: previous Period@start + // previous Period@duration // 3. if this is first period and MPD@type is 'static': 0 // 4. in all other cases, consider the period an "early available period" (note: not // currently supported) // (1) "number" == typeof attributes.start ? attributes.start : priorPeriodAttributes && "number" == typeof priorPeriodAttributes.start && "number" == typeof priorPeriodAttributes.duration ? priorPeriodAttributes.start + priorPeriodAttributes.duration : priorPeriodAttributes || "static" !== mpdType ? null : 0 // (2) ); }, inheritAttributes = function(mpd, options) { void 0 === options && (options = {}); var _options = options, _options$manifestUri = _options.manifestUri, _options$NOW = _options.NOW, NOW = void 0 === _options$NOW ? Date.now() : _options$NOW, _options$clientOffset = _options.clientOffset, periodNodes = findChildren(mpd, "Period"); if (!periodNodes.length) throw Error(errors.INVALID_NUMBER_OF_PERIOD); var locations = findChildren(mpd, "Location"), mpdAttributes = parseAttributes(mpd), mpdBaseUrls = buildBaseUrls([ void 0 === _options$manifestUri ? "" : _options$manifestUri ], findChildren(mpd, "BaseURL")); mpdAttributes.type = mpdAttributes.type || "static", mpdAttributes.sourceDuration = mpdAttributes.mediaPresentationDuration || 0, mpdAttributes.NOW = NOW, mpdAttributes.clientOffset = void 0 === _options$clientOffset ? 0 : _options$clientOffset, locations.length && (mpdAttributes.locations = locations.map(getContent)); var periods = []; // Since toAdaptationSets acts on individual periods right now, the simplest approach to return(// adding properties that require looking at prior periods is to parse attributes and add // missing ones before toAdaptationSets is called. If more such properties are added, it // may be better to refactor toAdaptationSets. periodNodes.forEach(function(node, index) { var attributes = parseAttributes(node), priorPeriod = periods[index - 1]; // Use the last modified prior period, as it may contain added information necessary attributes.start = getPeriodStart({ attributes: attributes, priorPeriodAttributes: priorPeriod ? priorPeriod.attributes : null, mpdType: mpdAttributes.type }), periods.push({ node: node, attributes: attributes }); }), { locations: mpdAttributes.locations, representationInfo: flatten(periods.map(function(period, index) { var periodBaseUrls = buildBaseUrls(mpdBaseUrls, findChildren(period.node, "BaseURL")), parsedPeriodId = parseInt(period.attributes.id, 10), periodAttributes = merge(mpdAttributes, { periodIndex: global_window__WEBPACK_IMPORTED_MODULE_1___default().isNaN(parsedPeriodId) ? index : parsedPeriodId, periodStart: period.attributes.start }); "number" == typeof period.attributes.duration && (periodAttributes.periodDuration = period.attributes.duration); var adaptationSets = findChildren(period.node, "AdaptationSet"), periodSegmentInfo = getSegmentInformation(period.node); return flatten(adaptationSets.map(function(adaptationSet) { var service, adaptationSetAttributes, adaptationSetAttributes1 = parseAttributes(adaptationSet), adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls, findChildren(adaptationSet, "BaseURL")), attrs = merge(periodAttributes, adaptationSetAttributes1, { role: parseAttributes(findChildren(adaptationSet, "Role")[0]) }), captionServices = // 608 captions "urn:scte:dash:cc:cea-608:2015" === (service = parseAttributes(findChildren(adaptationSet, "Accessibility")[0])).schemeIdUri ? ("string" != typeof service.value ? [] : service.value.split(";")).map(function(value) { if (language = value, /^CC\d=/.test(value)) { var channel, language, _value$split = value.split("="); channel = _value$split[0], language = _value$split[1]; } else /^CC\d$/.test(value) && (channel = value); return { channel: channel, language: language }; }) : "urn:scte:dash:cc:cea-708:2015" === service.schemeIdUri ? ("string" != typeof service.value ? [] : service.value.split(";")).map(function(value) { var flags = { // service or channel number 1-63 channel: void 0, // language is a 3ALPHA per ISO 639.2/B // field is required language: void 0, // BIT 1/0 or ? // default value is 1, meaning 16:9 aspect ratio, 0 is 4:3, ? is unknown aspectRatio: 1, // BIT 1/0 // easy reader flag indicated the text is tailed to the needs of beginning readers // default 0, or off easyReader: 0, // BIT 1/0 // If 3d metadata is present (CEA-708.1) then 1 // default 0 "3D": 0 }; if (/=/.test(value)) { var _value$split2 = value.split("="), channel = _value$split2[0], _value$split2$ = _value$split2[1]; flags.channel = channel, flags.language = value, (void 0 === _value$split2$ ? "" : _value$split2$).split(",").forEach(function(opt) { var _opt$split = opt.split(":"), name = _opt$split[0], val = _opt$split[1]; "lang" === name ? flags.language = val : "er" === name ? flags.easyReader = Number(val) : "war" === name ? flags.aspectRatio = Number(val) : "3D" === name && (flags["3D"] = Number(val)); }); } else flags.language = value; return flags.channel && (flags.channel = "SERVICE" + flags.channel), flags; }) : void 0; captionServices && (attrs = merge(attrs, { captionServices: captionServices })); var label = findChildren(adaptationSet, "Label")[0]; label && label.childNodes.length && (attrs = merge(attrs, { label: label.childNodes[0].nodeValue.trim() })); var contentProtection = findChildren(adaptationSet, "ContentProtection").reduce(function(acc, node) { var attributes = parseAttributes(node), keySystem = keySystemsMap[attributes.schemeIdUri]; if (keySystem) { acc[keySystem] = { attributes: attributes }; var psshNode = findChildren(node, "cenc:pssh")[0]; if (psshNode) { var pssh = getContent(psshNode), psshBuffer = pssh && (0, _videojs_vhs_utils_es_decode_b64_to_uint8_array__WEBPACK_IMPORTED_MODULE_2__ /* ["default"] */ .Z)(pssh); acc[keySystem].pssh = psshBuffer; } } return acc; }, {}); Object.keys(contentProtection).length && (attrs = merge(attrs, { contentProtection: contentProtection })); var segmentInfo = getSegmentInformation(adaptationSet), representations = findChildren(adaptationSet, "Representation"), adaptationSetSegmentInfo = merge(periodSegmentInfo, segmentInfo); return flatten(representations.map((adaptationSetAttributes = attrs, function(representation) { var repBaseUrls = buildBaseUrls(adaptationSetBaseUrls, findChildren(representation, "BaseURL")), attributes = merge(adaptationSetAttributes, parseAttributes(representation)), representationSegmentInfo = getSegmentInformation(representation); return repBaseUrls.map(function(baseUrl) { return { segmentInfo: merge(adaptationSetSegmentInfo, representationSegmentInfo), attributes: merge(attributes, { baseUrl: baseUrl }) }; }); }))); })); })) }); }, stringToMpdXml = function(manifestString) { if ("" === manifestString) throw Error(errors.DASH_EMPTY_MANIFEST); var xml, mpd, parser = new _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__.DOMParser(); try { mpd = (xml = parser.parseFromString(manifestString, "application/xml")) && "MPD" === xml.documentElement.tagName ? xml.documentElement : null; } catch (e) { // ie 11 throwsw on invalid xml } if (!mpd || mpd && mpd.getElementsByTagName("parsererror").length > 0) throw Error(errors.DASH_INVALID_XML); return mpd; }, parseUTCTimingScheme = function(mpd) { var UTCTimingNode = findChildren(mpd, "UTCTiming")[0]; if (!UTCTimingNode) return null; var attributes = parseAttributes(UTCTimingNode); switch(attributes.schemeIdUri){ case "urn:mpeg:dash:utc:http-head:2014": case "urn:mpeg:dash:utc:http-head:2012": attributes.method = "HEAD"; break; case "urn:mpeg:dash:utc:http-xsdate:2014": case "urn:mpeg:dash:utc:http-iso:2014": case "urn:mpeg:dash:utc:http-xsdate:2012": case "urn:mpeg:dash:utc:http-iso:2012": attributes.method = "GET"; break; case "urn:mpeg:dash:utc:direct:2014": case "urn:mpeg:dash:utc:direct:2012": attributes.method = "DIRECT", attributes.value = Date.parse(attributes.value); break; default: throw Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME); } return attributes; }, parse = function(manifestString, options) { void 0 === options && (options = {}); var parsedManifestInfo = inheritAttributes(stringToMpdXml(manifestString), options); return toM3u8(parsedManifestInfo.representationInfo.map(generateSegments), parsedManifestInfo.locations, options.sidxMapping); }, parseUTCTiming = function(manifestString) { return parseUTCTimingScheme(stringToMpdXml(manifestString)); }; /***/ }, /***/ 4221: /***/ function(module) { module.exports = function(data) { var view = new DataView(data.buffer, data.byteOffset, data.byteLength), result = { version: data[0], flags: new Uint8Array(data.subarray(1, 4)), references: [], referenceId: view.getUint32(4), timescale: view.getUint32(8) }, i = 12; 0 === result.version ? (result.earliestPresentationTime = view.getUint32(i), result.firstOffset = view.getUint32(i + 4), i += 8) : (// read 64 bits result.earliestPresentationTime = 4294967296 * view.getUint32(i) + view.getUint32(i + 4), result.firstOffset = 4294967296 * view.getUint32(i + 8) + view.getUint32(i + 12), i += 16), i += 2; var referenceCount = view.getUint16(i); for(i += 2; referenceCount > 0; i += 12, referenceCount--)result.references.push({ referenceType: (0x80 & data[i]) >>> 7, referencedSize: 0x7fffffff & view.getUint32(i), subsegmentDuration: view.getUint32(i + 4), startsWithSap: !!(0x80 & data[i + 8]), sapType: (0x70 & data[i + 8]) >>> 4, sapDeltaTime: 0x0fffffff & view.getUint32(i + 8) }); return result; }; /***/ }, /***/ 1489: /***/ function(module) { /** * mux.js * * Copyright (c) Brightcove * Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE */ var secondsToVideoTs, secondsToAudioTs, videoTsToSeconds, audioTsToSeconds; module.exports = { ONE_SECOND_IN_TS: 90000, secondsToVideoTs: secondsToVideoTs = function(seconds) { return 90000 * seconds; }, secondsToAudioTs: secondsToAudioTs = function(seconds, sampleRate) { return seconds * sampleRate; }, videoTsToSeconds: videoTsToSeconds = function(timestamp) { return timestamp / 90000; }, audioTsToSeconds: audioTsToSeconds = function(timestamp, sampleRate) { return timestamp / sampleRate; }, audioTsToVideoTs: function(timestamp, sampleRate) { return secondsToVideoTs(audioTsToSeconds(timestamp, sampleRate)); }, videoTsToAudioTs: function(timestamp, sampleRate) { return secondsToAudioTs(videoTsToSeconds(timestamp), sampleRate); }, metadataTsToSeconds: function(timestamp, timelineStartPts, keepOriginalTimestamps) { return videoTsToSeconds(keepOriginalTimestamps ? timestamp : timestamp - timelineStartPts); } }; /***/ }, /***/ 8581: /***/ function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/", function() { return __webpack_require__(4816); } ]); /***/ }, /***/ 4816: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function() { return /* binding */ Home; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), Home_module = __webpack_require__(214), Home_module_default = /*#__PURE__*/ __webpack_require__.n(Home_module), video_es = __webpack_require__(5215); __webpack_require__(3512); /* harmony default export */ var components_VideoJS = function(props) { var videoRef = react.useRef(null), playerRef = react.useRef(null), options = props.options, onReady = props.onReady; return react.useEffect(function() { // make sure Video.js player is only initialized once if (!playerRef.current) { var videoElement = videoRef.current; if (videoElement) var player = playerRef.current = (0, video_es /* default */ .Z)(videoElement, options, function() { console.log("player is ready"), onReady && onReady(player); }); } }, [ onReady, options, videoRef ]), // Dispose the Video.js player when the functional component unmounts react.useEffect(function() { return function() { var player = playerRef.current; player && (player.dispose(), playerRef.current = null); }; }, [ playerRef ]), /*#__PURE__*/ (0, jsx_runtime.jsx)("div", { "data-vjs-player": !0, children: /*#__PURE__*/ (0, jsx_runtime.jsx)("video", { ref: videoRef, className: "video-js vjs-big-play-centered" }) }); }; // CONCATENATED MODULE: ./pages/index.js function Home() { var playerRef = (0, react.useRef)(null); return /*#__PURE__*/ (0, jsx_runtime.jsx)("div", { className: Home_module_default().container, children: /*#__PURE__*/ (0, jsx_runtime.jsx)("main", { className: Home_module_default().main, children: /*#__PURE__*/ (0, jsx_runtime.jsx)(components_VideoJS, { options: { autoplay: !0, controls: !0, responsive: !0, fluid: !0, sources: [ { src: "https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8", type: "application/x-mpegurl" } ] }, onReady: function(player) { playerRef.current = player, // you can handle player events here player.on("waiting", function() { console.log("player is waiting"); }), player.on("dispose", function() { console.log("player will dispose"); }); } }) }) }); } /***/ }, /***/ 214: /***/ function(module) { // extracted by mini-css-extract-plugin module.exports = { container: "Home_container__bCOhY", main: "Home_main__nLjiQ", footer: "Home_footer____T7K", title: "Home_title__T09hD", description: "Home_description__41Owk", code: "Home_code__suPER", grid: "Home_grid__GxQ85", card: "Home_card___LpL1", logo: "Home_logo__27_tb" }; /***/ }, /***/ 3512: /***/ function() { // extracted by mini-css-extract-plugin /***/ }, /***/ 5974: /***/ function(module) { module.exports = function(obj, reviver) { var json, error = null; try { json = JSON.parse(obj, reviver); } catch (err) { error = err; } return [ error, json ]; }; /***/ }, /***/ 9945: /***/ function(module) { var URL_REGEX, FIRST_SEGMENT_REGEX, SLASH_DOT_REGEX, SLASH_DOT_DOT_REGEX, URLToolkit; URL_REGEX = /^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/, FIRST_SEGMENT_REGEX = /^([^\/?#]*)([^]*)$/, SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g, SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g, module.exports = URLToolkit = { // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or // // E.g // With opts.alwaysNormalize = false (default, spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g // With opts.alwaysNormalize = true (not spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/g buildAbsoluteURL: function(baseURL, relativeURL, opts) { if (opts = opts || {}, // remove any remaining space and CRLF baseURL = baseURL.trim(), !(relativeURL = relativeURL.trim())) { // 2a) If the embedded URL is entirely empty, it inherits the // entire base URL (i.e., is set equal to the base URL) // and we are done. if (!opts.alwaysNormalize) return baseURL; var basePartsForNormalise = URLToolkit.parseURL(baseURL); if (!basePartsForNormalise) throw Error("Error trying to parse base URL."); return basePartsForNormalise.path = URLToolkit.normalizePath(basePartsForNormalise.path), URLToolkit.buildURLFromParts(basePartsForNormalise); } var relativeParts = URLToolkit.parseURL(relativeURL); if (!relativeParts) throw Error("Error trying to parse relative URL."); if (relativeParts.scheme) return(// 2b) If the embedded URL starts with a scheme name, it is // interpreted as an absolute URL and we are done. opts.alwaysNormalize ? (relativeParts.path = URLToolkit.normalizePath(relativeParts.path), URLToolkit.buildURLFromParts(relativeParts)) : relativeURL); var baseParts = URLToolkit.parseURL(baseURL); if (!baseParts) throw Error("Error trying to parse base URL."); if (!baseParts.netLoc && baseParts.path && "/" !== baseParts.path[0]) { // If netLoc missing and path doesn't start with '/', assume everthing before the first '/' is the netLoc // This causes 'example.com/a' to be handled as '//example.com/a' instead of '/example.com/a' var pathParts = FIRST_SEGMENT_REGEX.exec(baseParts.path); baseParts.netLoc = pathParts[1], baseParts.path = pathParts[2]; } baseParts.netLoc && !baseParts.path && (baseParts.path = "/"); var builtParts = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: baseParts.scheme, netLoc: relativeParts.netLoc, path: null, params: relativeParts.params, query: relativeParts.query, fragment: relativeParts.fragment }; if (!relativeParts.netLoc && (// 3) If the embedded URL's <net_loc> is non-empty, we skip to // Step 7. Otherwise, the embedded URL inherits the <net_loc> // (if any) of the base URL. builtParts.netLoc = baseParts.netLoc, "/" !== relativeParts.path[0])) { if (relativeParts.path) { // 6) The last segment of the base URL's path (anything // following the rightmost slash "/", or the entire path if no // slash is present) is removed and the embedded URL's path is // appended in its place. var baseURLPath = baseParts.path, newPath = baseURLPath.substring(0, baseURLPath.lastIndexOf("/") + 1) + relativeParts.path; builtParts.path = URLToolkit.normalizePath(newPath); } else // 5) If the embedded URL path is empty (and not preceded by a // slash), then the embedded URL inherits the base URL path builtParts.path = baseParts.path, relativeParts.params || (builtParts.params = baseParts.params, relativeParts.query || (builtParts.query = baseParts.query)); } return null === builtParts.path && (builtParts.path = opts.alwaysNormalize ? URLToolkit.normalizePath(relativeParts.path) : relativeParts.path), URLToolkit.buildURLFromParts(builtParts); }, parseURL: function(url) { var parts = URL_REGEX.exec(url); return parts ? { scheme: parts[1] || "", netLoc: parts[2] || "", path: parts[3] || "", params: parts[4] || "", query: parts[5] || "", fragment: parts[6] || "" } : null; }, normalizePath: function(path) { // 6c) All occurrences of "<segment>/../", where <segment> is a // complete path segment not equal to "..", are removed. // Removal of these path segments is performed iteratively, // removing the leftmost matching pattern on each iteration, // until no matching pattern remains. // 6d) If the path ends with "<segment>/..", where <segment> is a // complete path segment not equal to "..", that // "<segment>/.." is removed. for(// The following operations are // then applied, in order, to the new path: // 6a) All occurrences of "./", where "." is a complete path // segment, are removed. // 6b) If the path ends with "." as a complete path segment, // that "." is removed. path = path.split("").reverse().join("").replace(SLASH_DOT_REGEX, ""); path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, "")).length;); return path.split("").reverse().join(""); }, buildURLFromParts: function(parts) { return parts.scheme + parts.netLoc + parts.path + parts.params + parts.query + parts.fragment; } }; /***/ }, /***/ 3407: /***/ function(module, __unused_webpack_exports, __webpack_require__) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Default exports for Node. Export the extended versions of VTTCue and // VTTRegion in Node since we likely want the capability to convert back and // forth between JSON. If we don't then it's not that big of a deal since we're // off browser. var window1 = __webpack_require__(8908), vttjs = module.exports = { WebVTT: __webpack_require__(3706), VTTCue: __webpack_require__(2230), VTTRegion: __webpack_require__(3710) }; window1.vttjs = vttjs, window1.WebVTT = vttjs.WebVTT; var cueShim = vttjs.VTTCue, regionShim = vttjs.VTTRegion, nativeVTTCue = window1.VTTCue, nativeVTTRegion = window1.VTTRegion; vttjs.shim = function() { window1.VTTCue = cueShim, window1.VTTRegion = regionShim; }, vttjs.restore = function() { window1.VTTCue = nativeVTTCue, window1.VTTRegion = nativeVTTRegion; }, window1.VTTCue || vttjs.shim(); /***/ }, /***/ 3706: /***/ function(module, __unused_webpack_exports, __webpack_require__) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ var document1 = __webpack_require__(9144), _objCreate = Object.create || function() { function F() {} return function(o) { if (1 != arguments.length) throw Error("Object.create shim only accepts one parameter."); return F.prototype = o, new F(); }; }(); // Creates a new ParserError object from an errorData object. The errorData // object should have default code and message properties. The default message // property can be overriden by passing in a message parameter. // See ParsingError.Errors below for acceptable errors. function ParsingError(errorData, message) { this.name = "ParsingError", this.code = errorData.code, this.message = message || errorData.message; } // Try to parse input as a time stamp. function parseTimeStamp(input) { function computeSeconds(h, m, s, f) { return (0 | h) * 3600 + (0 | m) * 60 + (0 | s) + (0 | f) / 1000; } var m = input.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/); return m ? m[3] ? computeSeconds(m[1], m[2], m[3].replace(":", ""), m[4]) : m[1] > 59 ? computeSeconds(m[1], m[2], 0, m[4]) : computeSeconds(0, m[1], m[2], m[4]) : null; } // A settings object holds key/value pairs and will ignore anything but the first // assignment to a specific key. function Settings() { this.values = _objCreate(null); } // Helper function to parse input into groups separated by 'groupDelim', and // interprete each group as a key/value pair separated by 'keyValueDelim'. function parseOptions(input, callback, keyValueDelim, groupDelim) { var groups = groupDelim ? input.split(groupDelim) : [ input ]; for(var i in groups)if ("string" == typeof groups[i]) { var kv = groups[i].split(keyValueDelim); 2 === kv.length && callback(kv[0], kv[1]); } } ParsingError.prototype = _objCreate(Error.prototype), ParsingError.prototype.constructor = ParsingError, // ParsingError metadata for acceptable ParsingErrors. ParsingError.Errors = { BadSignature: { code: 0, message: "Malformed WebVTT signature." }, BadTimeStamp: { code: 1, message: "Malformed time stamp." } }, Settings.prototype = { // Only accept the first assignment to any key. set: function(k, v) { this.get(k) || "" === v || (this.values[k] = v); }, // Return the value for a key, or a default value. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with // a number of possible default values as properties where 'defaultKey' is // the key of the property that will be chosen; otherwise it's assumed to be // a single value. get: function(k, dflt, defaultKey) { return defaultKey ? this.has(k) ? this.values[k] : dflt[defaultKey] : this.has(k) ? this.values[k] : dflt; }, // Check whether we have a value for a key. has: function(k) { return k in this.values; }, // Accept a setting if its one of the given alternatives. alt: function(k, v, a) { for(var n = 0; n < a.length; ++n)if (v === a[n]) { this.set(k, v); break; } }, // Accept a setting if its a valid (signed) integer. integer: function(k, v) { /^-?\d+$/.test(v) && // integer this.set(k, parseInt(v, 10)); }, // Accept a setting if its a valid percentage. percent: function(k, v) { return !!(v.match(/^([\d]{1,3})(\.[\d]*)?%$/) && (v = parseFloat(v)) >= 0 && v <= 100) && (this.set(k, v), !0); } }; // When evaluating this file as part of a Webpack bundle for server // side rendering, `document` is an empty object. var TEXTAREA_ELEMENT = document1.createElement && document1.createElement("textarea"), TAG_NAME = { c: "span", i: "i", b: "b", u: "u", ruby: "ruby", rt: "rt", v: "span", lang: "span" }, DEFAULT_COLOR_CLASS = { white: "rgba(255,255,255,1)", lime: "rgba(0,255,0,1)", cyan: "rgba(0,255,255,1)", red: "rgba(255,0,0,1)", yellow: "rgba(255,255,0,1)", magenta: "rgba(255,0,255,1)", blue: "rgba(0,0,255,1)", black: "rgba(0,0,0,1)" }, TAG_ANNOTATION = { v: "title", lang: "lang" }, NEEDS_PARENT = { rt: "ruby" }; // Parse content into a document fragment. function parseContent(window1, input) { for(var t, rootDiv = window1.document.createElement("div"), current = rootDiv, tagStack = []; null !== (t = function() { // Check for end-of-string. if (!input) return null; var result, m = input.match(/^([^<]*)(<[^>]*>?)?/); // If there is some text before the next tag, return it, otherwise return // the tag. return result = m[1] ? m[1] : m[2], input = input.substr(result.length), result; }());){ if ("<" === t[0]) { if ("/" === t[1]) { // If the closing tag matches, move back up to the parent node. tagStack.length && tagStack[tagStack.length - 1] === t.substr(2).replace(">", "") && (tagStack.pop(), current = current.parentNode); continue; } var s, current1, element, node, ts = parseTimeStamp(t.substr(1, t.length - 2)); if (ts) { // Timestamps are lead nodes as well. node = window1.document.createProcessingInstruction("timestamp", ts), current.appendChild(node); continue; } var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/); // If we can't parse the tag, skip to the next tag. if (!m || !// Try to construct an element, and ignore the tag if we couldn't. (node = // Create an element for this tag. function(type, annotation) { var tagName = TAG_NAME[type]; if (!tagName) return null; var element = window1.document.createElement(tagName), name = TAG_ANNOTATION[type]; return name && annotation && (element[name] = annotation.trim()), element; }(m[1], m[3])) || (current1 = current, NEEDS_PARENT[(element = node).localName] && NEEDS_PARENT[element.localName] !== current1.localName)) continue; // Set the class list (as a list of classes, separated by space). if (m[2]) { var classes = m[2].split("."); classes.forEach(function(cl) { var bgColor = /^bg_/.test(cl), colorName = bgColor ? cl.slice(3) : cl; if (DEFAULT_COLOR_CLASS.hasOwnProperty(colorName)) { var propName = bgColor ? "background-color" : "color", propValue = DEFAULT_COLOR_CLASS[colorName]; node.style[propName] = propValue; } }), node.className = classes.join(" "); } // Append the node to the current node, and enter the scope of the new // node. tagStack.push(m[1]), current.appendChild(node), current = node; continue; } // Text nodes are leaf nodes. current.appendChild(window1.document.createTextNode((TEXTAREA_ELEMENT.innerHTML = s = t, s = TEXTAREA_ELEMENT.textContent, TEXTAREA_ELEMENT.textContent = "", s))); } return rootDiv; } // This is a list of all the Unicode characters that have a strong // right-to-left category. What this means is that these characters are // written right-to-left for sure. It was generated by pulling all the strong // right-to-left characters out of the Unicode data table. That table can // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt var strongRTLRanges = [ [ 0x5be, 0x5be ], [ 0x5c0, 0x5c0 ], [ 0x5c3, 0x5c3 ], [ 0x5c6, 0x5c6 ], [ 0x5d0, 0x5ea ], [ 0x5f0, 0x5f4 ], [ 0x608, 0x608 ], [ 0x60b, 0x60b ], [ 0x60d, 0x60d ], [ 0x61b, 0x61b ], [ 0x61e, 0x64a ], [ 0x66d, 0x66f ], [ 0x671, 0x6d5 ], [ 0x6e5, 0x6e6 ], [ 0x6ee, 0x6ef ], [ 0x6fa, 0x70d ], [ 0x70f, 0x710 ], [ 0x712, 0x72f ], [ 0x74d, 0x7a5 ], [ 0x7b1, 0x7b1 ], [ 0x7c0, 0x7ea ], [ 0x7f4, 0x7f5 ], [ 0x7fa, 0x7fa ], [ 0x800, 0x815 ], [ 0x81a, 0x81a ], [ 0x824, 0x824 ], [ 0x828, 0x828 ], [ 0x830, 0x83e ], [ 0x840, 0x858 ], [ 0x85e, 0x85e ], [ 0x8a0, 0x8a0 ], [ 0x8a2, 0x8ac ], [ 0x200f, 0x200f ], [ 0xfb1d, 0xfb1d ], [ 0xfb1f, 0xfb28 ], [ 0xfb2a, 0xfb36 ], [ 0xfb38, 0xfb3c ], [ 0xfb3e, 0xfb3e ], [ 0xfb40, 0xfb41 ], [ 0xfb43, 0xfb44 ], [ 0xfb46, 0xfbc1 ], [ 0xfbd3, 0xfd3d ], [ 0xfd50, 0xfd8f ], [ 0xfd92, 0xfdc7 ], [ 0xfdf0, 0xfdfc ], [ 0xfe70, 0xfe74 ], [ 0xfe76, 0xfefc ], [ 0x10800, 0x10805 ], [ 0x10808, 0x10808 ], [ 0x1080a, 0x10835 ], [ 0x10837, 0x10838 ], [ 0x1083c, 0x1083c ], [ 0x1083f, 0x10855 ], [ 0x10857, 0x1085f ], [ 0x10900, 0x1091b ], [ 0x10920, 0x10939 ], [ 0x1093f, 0x1093f ], [ 0x10980, 0x109b7 ], [ 0x109be, 0x109bf ], [ 0x10a00, 0x10a00 ], [ 0x10a10, 0x10a13 ], [ 0x10a15, 0x10a17 ], [ 0x10a19, 0x10a33 ], [ 0x10a40, 0x10a47 ], [ 0x10a50, 0x10a58 ], [ 0x10a60, 0x10a7f ], [ 0x10b00, 0x10b35 ], [ 0x10b40, 0x10b55 ], [ 0x10b58, 0x10b72 ], [ 0x10b78, 0x10b7f ], [ 0x10c00, 0x10c48 ], [ 0x1ee00, 0x1ee03 ], [ 0x1ee05, 0x1ee1f ], [ 0x1ee21, 0x1ee22 ], [ 0x1ee24, 0x1ee24 ], [ 0x1ee27, 0x1ee27 ], [ 0x1ee29, 0x1ee32 ], [ 0x1ee34, 0x1ee37 ], [ 0x1ee39, 0x1ee39 ], [ 0x1ee3b, 0x1ee3b ], [ 0x1ee42, 0x1ee42 ], [ 0x1ee47, 0x1ee47 ], [ 0x1ee49, 0x1ee49 ], [ 0x1ee4b, 0x1ee4b ], [ 0x1ee4d, 0x1ee4f ], [ 0x1ee51, 0x1ee52 ], [ 0x1ee54, 0x1ee54 ], [ 0x1ee57, 0x1ee57 ], [ 0x1ee59, 0x1ee59 ], [ 0x1ee5b, 0x1ee5b ], [ 0x1ee5d, 0x1ee5d ], [ 0x1ee5f, 0x1ee5f ], [ 0x1ee61, 0x1ee62 ], [ 0x1ee64, 0x1ee64 ], [ 0x1ee67, 0x1ee6a ], [ 0x1ee6c, 0x1ee72 ], [ 0x1ee74, 0x1ee77 ], [ 0x1ee79, 0x1ee7c ], [ 0x1ee7e, 0x1ee7e ], [ 0x1ee80, 0x1ee89 ], [ 0x1ee8b, 0x1ee9b ], [ 0x1eea1, 0x1eea3 ], [ 0x1eea5, 0x1eea9 ], [ 0x1eeab, 0x1eebb ], [ 0x10fffd, 0x10fffd ] ]; function StyleBox() {} // Constructs the computed display state of the cue (a div). Places the div // into the overlay which should be a block level element (usually a div). function CueStyleBox(window1, cue, styleOptions) { StyleBox.call(this), this.cue = cue, // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will // have inline positioning and will function as the cue background box. this.cueDiv = parseContent(window1, cue.text); var styles = { color: "rgba(255, 255, 255, 1)", backgroundColor: "rgba(0, 0, 0, 0.8)", position: "relative", left: 0, right: 0, top: 0, bottom: 0, display: "inline", writingMode: "" === cue.vertical ? "horizontal-tb" : "lr" === cue.vertical ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext" }; this.applyStyles(styles, this.cueDiv), // Create an absolutely positioned div that will be used to position the cue // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS // mirrors of them except middle instead of center on Safari. this.div = window1.document.createElement("div"), styles = { direction: function(cueDiv) { var nodeStack = [], text = ""; if (!cueDiv || !cueDiv.childNodes) return "ltr"; function pushNodes(nodeStack, node) { for(var i = node.childNodes.length - 1; i >= 0; i--)nodeStack.push(node.childNodes[i]); } for(pushNodes(nodeStack, cueDiv); text = function nextTextNode(nodeStack) { if (!nodeStack || !nodeStack.length) return null; var node = nodeStack.pop(), text = node.textContent || node.innerText; if (text) { // TODO: This should match all unicode type B characters (paragraph // separator characters). See issue #115. var m = text.match(/^.*(\n|\r)/); return m ? (nodeStack.length = 0, m[0]) : text; } return "ruby" === node.tagName ? nextTextNode(nodeStack) : node.childNodes ? (pushNodes(nodeStack, node), nextTextNode(nodeStack)) : void 0; }(nodeStack);)for(var i = 0; i < text.length; i++)if (function(charCode) { for(var i = 0; i < strongRTLRanges.length; i++){ var currentRange = strongRTLRanges[i]; if (charCode >= currentRange[0] && charCode <= currentRange[1]) return !0; } return !1; }(text.charCodeAt(i))) return "rtl"; return "ltr"; }(this.cueDiv), writingMode: "" === cue.vertical ? "horizontal-tb" : "lr" === cue.vertical ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext", textAlign: "middle" === cue.align ? "center" : cue.align, font: styleOptions.font, whiteSpace: "pre-line", position: "absolute" }, this.applyStyles(styles), this.div.appendChild(this.cueDiv); // Calculate the distance from the reference edge of the viewport to the text // position of the cue box. The reference edge will be resolved later when // the box orientation styles are applied. var textPos = 0; switch(cue.positionAlign){ case "start": textPos = cue.position; break; case "center": textPos = cue.position - cue.size / 2; break; case "end": textPos = cue.position - cue.size; } "" === cue.vertical ? this.applyStyles({ left: this.formatStyle(textPos, "%"), width: this.formatStyle(cue.size, "%") }) : this.applyStyles({ top: this.formatStyle(textPos, "%"), height: this.formatStyle(cue.size, "%") }), this.move = function(box) { this.applyStyles({ top: this.formatStyle(box.top, "px"), bottom: this.formatStyle(box.bottom, "px"), left: this.formatStyle(box.left, "px"), right: this.formatStyle(box.right, "px"), height: this.formatStyle(box.height, "px"), width: this.formatStyle(box.width, "px") }); }; } // Represents the co-ordinates of an Element in a way that we can easily // compute things with such as if it overlaps or intersects with another Element. // Can initialize it with either a StyleBox or another BoxPosition. function BoxPosition(obj) { // Either a BoxPosition was passed in and we need to copy it, or a StyleBox // was passed in and we need to copy the results of 'getBoundingClientRect' // as the object returned is readonly. All co-ordinate values are in reference // to the viewport origin (top left). var lh, height, width, top; if (obj.div) { height = obj.div.offsetHeight, width = obj.div.offsetWidth, top = obj.div.offsetTop; var rects = (rects = obj.div.childNodes) && (rects = rects[0]) && rects.getClientRects && rects.getClientRects(); obj = obj.div.getBoundingClientRect(), // In certain cases the outter div will be slightly larger then the sum of // the inner div's lines. This could be due to bold text, etc, on some platforms. // In this case we should get the average line height and use that. This will // result in the desired behaviour. lh = rects ? Math.max(rects[0] && rects[0].height || 0, obj.height / rects.length) : 0; } this.left = obj.left, this.right = obj.right, this.top = obj.top || top, this.height = obj.height || height, this.bottom = obj.bottom || top + (obj.height || height), this.width = obj.width || width, this.lineHeight = void 0 !== lh ? lh : obj.lineHeight; } function WebVTT1() { // Nothing } // Apply styles to a div. If there is no div passed then it defaults to the // div on 'this'. StyleBox.prototype.applyStyles = function(styles, div) { for(var prop in div = div || this.div, styles)styles.hasOwnProperty(prop) && (div.style[prop] = styles[prop]); }, StyleBox.prototype.formatStyle = function(val, unit) { return 0 === val ? 0 : val + unit; }, CueStyleBox.prototype = _objCreate(StyleBox.prototype), CueStyleBox.prototype.constructor = CueStyleBox, // Move the box along a particular axis. Optionally pass in an amount to move // the box. If no amount is passed then the default is the line height of the // box. BoxPosition.prototype.move = function(axis, toMove) { switch(toMove = void 0 !== toMove ? toMove : this.lineHeight, axis){ case "+x": this.left += toMove, this.right += toMove; break; case "-x": this.left -= toMove, this.right -= toMove; break; case "+y": this.top += toMove, this.bottom += toMove; break; case "-y": this.top -= toMove, this.bottom -= toMove; } }, // Check if this box overlaps another box, b2. BoxPosition.prototype.overlaps = function(b2) { return this.left < b2.right && this.right > b2.left && this.top < b2.bottom && this.bottom > b2.top; }, // Check if this box overlaps any other boxes in boxes. BoxPosition.prototype.overlapsAny = function(boxes) { for(var i = 0; i < boxes.length; i++)if (this.overlaps(boxes[i])) return !0; return !1; }, // Check if this box is within another box. BoxPosition.prototype.within = function(container) { return this.top >= container.top && this.bottom <= container.bottom && this.left >= container.left && this.right <= container.right; }, // Check if this box is entirely within the container or it is overlapping // on the edge opposite of the axis direction passed. For example, if "+x" is // passed and the box is overlapping on the left edge of the container, then // return true. BoxPosition.prototype.overlapsOppositeAxis = function(container, axis) { switch(axis){ case "+x": return this.left < container.left; case "-x": return this.right > container.right; case "+y": return this.top < container.top; case "-y": return this.bottom > container.bottom; } }, // Find the percentage of the area that this box is overlapping with another // box. BoxPosition.prototype.intersectPercentage = function(b2) { return Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left)) * Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top)) / (this.height * this.width); }, // Convert the positions from this box to CSS compatible positions using // the reference container's positions. This has to be done because this // box's positions are in reference to the viewport origin, whereas, CSS // values are in referecne to their respective edges. BoxPosition.prototype.toCSSCompatValues = function(reference) { return { top: this.top - reference.top, bottom: reference.bottom - this.bottom, left: this.left - reference.left, right: reference.right - this.right, height: this.height, width: this.width }; }, // Get an object that represents the box's position without anything extra. // Can pass a StyleBox, HTMLElement, or another BoxPositon. BoxPosition.getSimpleBoxPosition = function(obj) { var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0, width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0, top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0; return { left: (obj = obj.div ? obj.div.getBoundingClientRect() : obj.tagName ? obj.getBoundingClientRect() : obj).left, right: obj.right, top: obj.top || top, height: obj.height || height, bottom: obj.bottom || top + (obj.height || height), width: obj.width || width }; }, // Helper to allow strings to be decoded instead of the default binary utf8 data. WebVTT1.StringDecoder = function() { return { decode: function(data) { if (!data) return ""; if ("string" != typeof data) throw Error("Error - expected string data."); return decodeURIComponent(encodeURIComponent(data)); } }; }, WebVTT1.convertCueToDOMTree = function(window1, cuetext) { return window1 && cuetext ? parseContent(window1, cuetext) : null; }, // Runs the processing model over the cues and regions passed to it. // @param overlay A block level element (usually a div) that the computed cues // and regions will be placed into. WebVTT1.processCues = function(window1, cues, overlay) { if (!window1 || !cues || !overlay) return null; // Remove all previous children. for(; overlay.firstChild;)overlay.removeChild(overlay.firstChild); var paddedOverlay = window1.document.createElement("div"); // We don't need to recompute the cues' display states. Just reuse them. if (paddedOverlay.style.position = "absolute", paddedOverlay.style.left = "0", paddedOverlay.style.right = "0", paddedOverlay.style.top = "0", paddedOverlay.style.bottom = "0", paddedOverlay.style.margin = "1.5%", overlay.appendChild(paddedOverlay), !// Determine if we need to compute the display states of the cues. This could // be the case if a cue's state has been changed since the last computation or // if it has not been computed yet. function(cues) { for(var i = 0; i < cues.length; i++)if (cues[i].hasBeenReset || !cues[i].displayState) return !0; return !1; }(cues)) { for(var i = 0; i < cues.length; i++)paddedOverlay.appendChild(cues[i].displayState); return; } var boxPositions = [], containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay), styleOptions = { font: Math.round(5 * containerBox.height) / 100 + "px sans-serif" }; !function() { for(var styleBox, cue, i = 0; i < cues.length; i++)// Compute the intial position and styles of the cue div. styleBox = new CueStyleBox(window1, cue = cues[i], styleOptions), paddedOverlay.appendChild(styleBox.div), // Move the cue div to it's correct line position. // Move a StyleBox to its specified, or next best, position. The containerBox // is the box that contains the StyleBox, such as a div. boxPositions are // a list of other boxes that the styleBox can't overlap with. function(window1, styleBox, containerBox, boxPositions) { var boxPosition = new BoxPosition(styleBox), cue = styleBox.cue, linePos = function(cue) { if ("number" == typeof cue.line && (cue.snapToLines || cue.line >= 0 && cue.line <= 100)) return cue.line; if (!cue.track || !cue.track.textTrackList || !cue.track.textTrackList.mediaElement) return -1; for(var track = cue.track, trackList = track.textTrackList, count = 0, i = 0; i < trackList.length && trackList[i] !== track; i++)"showing" === trackList[i].mode && count++; return -1 * ++count; }(cue), axis = []; // If we have a line number to align the cue to. if (cue.snapToLines) { switch(cue.vertical){ case "": axis = [ "+y", "-y" ], size = "height"; break; case "rl": axis = [ "+x", "-x" ], size = "width"; break; case "lr": axis = [ "-x", "+x" ], size = "width"; } var size, step = boxPosition.lineHeight, position = step * Math.round(linePos), maxPosition = containerBox[size] + step, initialAxis = axis[0]; Math.abs(position) > maxPosition && (position = Math.ceil(maxPosition / step) * step * (position < 0 ? -1 : 1)), linePos < 0 && (position += "" === cue.vertical ? containerBox.height : containerBox.width, axis = axis.reverse()), // Move the box to the specified position. This may not be its best // position. boxPosition.move(initialAxis, position); } else { // If we have a percentage line value for the cue. var calculatedPercentage = boxPosition.lineHeight / containerBox.height * 100; switch(cue.lineAlign){ case "center": linePos -= calculatedPercentage / 2; break; case "end": linePos -= calculatedPercentage; } // Apply initial line position to the cue box. switch(cue.vertical){ case "": styleBox.applyStyles({ top: styleBox.formatStyle(linePos, "%") }); break; case "rl": styleBox.applyStyles({ left: styleBox.formatStyle(linePos, "%") }); break; case "lr": styleBox.applyStyles({ right: styleBox.formatStyle(linePos, "%") }); } axis = [ "+y", "-x", "+x", "-y" ], // Get the box position again after we've applied the specified positioning // to it. boxPosition = new BoxPosition(styleBox); } var bestPosition = // Find the best position for a cue box, b, on the video. The axis parameter // is a list of axis, the order of which, it will move the box along. For example: // Passing ["+x", "-x"] will move the box first along the x axis in the positive // direction. If it doesn't find a good position for it there it will then move // it along the x axis in the negative direction. function(b, axis) { for(var bestPosition, specifiedPosition = new BoxPosition(b), percentage = 1, i = 0; i < axis.length; i++){ for(; b.overlapsOppositeAxis(containerBox, axis[i]) || b.within(containerBox) && b.overlapsAny(boxPositions);)b.move(axis[i]); // We found a spot where we aren't overlapping anything. This is our // best position. if (b.within(containerBox)) return b; var p = b.intersectPercentage(containerBox); percentage > p && (bestPosition = new BoxPosition(b), percentage = p), // Reset the box position to the specified position. b = new BoxPosition(specifiedPosition); } return bestPosition || specifiedPosition; }(boxPosition, axis); styleBox.move(bestPosition.toCSSCompatValues(containerBox)); }(0, styleBox, containerBox, boxPositions), // Remember the computed div so that we don't have to recompute it later // if we don't have too. cue.displayState = styleBox.div, boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox)); }(); }, WebVTT1.Parser = function(window1, vttjs, decoder) { decoder || (decoder = vttjs, vttjs = {}), vttjs || (vttjs = {}), this.window = window1, this.vttjs = vttjs, this.state = "INITIAL", this.buffer = "", this.decoder = decoder || new TextDecoder("utf8"), this.regionList = []; }, WebVTT1.Parser.prototype = { // If the error is a ParsingError then report it to the consumer if // possible. If it's not a ParsingError then throw it like normal. reportOrThrowError: function(e) { if (e instanceof ParsingError) this.onparsingerror && this.onparsingerror(e); else throw e; }, parse: function(data) { var self1 = this; function collectNextLine() { for(var buffer = self1.buffer, pos = 0; pos < buffer.length && "\r" !== buffer[pos] && "\n" !== buffer[pos];)++pos; var line = buffer.substr(0, pos); return "\r" === buffer[pos] && ++pos, "\n" === buffer[pos] && ++pos, self1.buffer = buffer.substr(pos), line; } data && // Try to decode the data that we received. (self1.buffer += self1.decoder.decode(data, { stream: !0 })); // 5.1 WebVTT file parsing. try { if ("INITIAL" === self1.state) { // We can't start parsing until we have the first line. if (!/\r\n|\n/.test(self1.buffer)) return this; var input, line = collectNextLine(), m = line.match(/^WEBVTT([ \t].*)?$/); if (!m || !m[0]) throw new ParsingError(ParsingError.Errors.BadSignature); self1.state = "HEADER"; } for(var alreadyCollectedLine = !1; // We can't parse a line until we have the full line. self1.buffer && /\r\n|\n/.test(self1.buffer);)switch(alreadyCollectedLine ? alreadyCollectedLine = !1 : line = collectNextLine(), self1.state){ case "HEADER": // 13-18 - Allow a header (metadata) under the WEBVTT line. /:/.test(line) ? (input = line).match(/X-TIMESTAMP-MAP/) ? // This line contains HLS X-TIMESTAMP-MAP metadata parseOptions(input, function(k, v) { if ("X-TIMESTAMP-MAP" === k) { var settings; settings = new Settings(), parseOptions(v, function(k, v) { switch(k){ case "MPEGT": settings.integer(k + "S", v); break; case "LOCA": settings.set(k + "L", parseTimeStamp(v)); } }, /[^\d]:/, /,/), self1.ontimestampmap && self1.ontimestampmap({ MPEGTS: settings.get("MPEGTS"), LOCAL: settings.get("LOCAL") }); } }, /=/) : parseOptions(input, function(k, v) { "Region" === k && // 3.3 WebVTT region metadata header syntax // 3.4 WebVTT region and WebVTT region settings syntax function(input) { var settings = new Settings(); // Create the region, using default values for any values that were not // specified. if (parseOptions(input, function(k, v) { switch(k){ case "id": settings.set(k, v); break; case "width": settings.percent(k, v); break; case "lines": settings.integer(k, v); break; case "regionanchor": case "viewportanchor": var xy = v.split(","); if (2 !== xy.length) break; // We have to make sure both x and y parse, so use a temporary // settings object here. var anchor = new Settings(); if (anchor.percent("x", xy[0]), anchor.percent("y", xy[1]), !anchor.has("x") || !anchor.has("y")) break; settings.set(k + "X", anchor.get("x")), settings.set(k + "Y", anchor.get("y")); break; case "scroll": settings.alt(k, v, [ "up" ]); } }, /=/, /\s/), settings.has("id")) { var region = new (self1.vttjs.VTTRegion || self1.window.VTTRegion)(); region.width = settings.get("width", 100), region.lines = settings.get("lines", 3), region.regionAnchorX = settings.get("regionanchorX", 0), region.regionAnchorY = settings.get("regionanchorY", 100), region.viewportAnchorX = settings.get("viewportanchorX", 0), region.viewportAnchorY = settings.get("viewportanchorY", 100), region.scroll = settings.get("scroll", ""), // Register the region. self1.onregion && self1.onregion(region), // Remember the VTTRegion for later in case we parse any VTTCues that // reference it. self1.regionList.push({ id: settings.get("id"), region: region }); } }(v); }, /:/) : line || // An empty line terminates the header and starts the body (cues). (self1.state = "ID"); continue; case "NOTE": // Ignore NOTE blocks. line || (self1.state = "ID"); continue; case "ID": // Check for the start of NOTE blocks. if (/^NOTE($|[ \t])/.test(line)) { self1.state = "NOTE"; break; } // 19-29 - Allow any number of line terminators, then initialize new cue values. if (!line) continue; self1.cue = new (self1.vttjs.VTTCue || self1.window.VTTCue)(0, 0, ""); // Safari still uses the old middle value and won't accept center try { self1.cue.align = "center"; } catch (e) { self1.cue.align = "middle"; } // 30-39 - Check if self line contains an optional identifier or timing data. if (self1.state = "CUE", -1 === line.indexOf("-->")) { self1.cue.id = line; continue; } // Process line as start of a cue. /*falls through*/ case "CUE": // 40 - Collect cue timings and settings. try { !function(input, cue, regionList) { // Remember the original input if we need to throw an error. var oInput = input; // 4.1 WebVTT timestamp function consumeTimeStamp() { var ts = parseTimeStamp(input); if (null === ts) throw new ParsingError(ParsingError.Errors.BadTimeStamp, "Malformed timestamp: " + oInput); return(// Remove time stamp from input. input = input.replace(/^[^\sa-zA-Z-]+/, ""), ts); } function skipWhitespace() { input = input.replace(/^\s+/, ""); } if (// 4.1 WebVTT cue timings. skipWhitespace(), cue.startTime = consumeTimeStamp(), skipWhitespace(), "-->" !== input.substr(0, 3)) // (3) next characters must match "-->" throw new ParsingError(ParsingError.Errors.BadTimeStamp, "Malformed time stamp (time stamps must be separated by '-->'): " + oInput); input = input.substr(3), skipWhitespace(), cue.endTime = consumeTimeStamp(), // 4.1 WebVTT cue settings list. skipWhitespace(), // 4.4.2 WebVTT cue settings function(input, cue) { var settings = new Settings(); parseOptions(input, function(k, v) { switch(k){ case "region": // Find the last region we parsed with the same region id. for(var i = regionList.length - 1; i >= 0; i--)if (regionList[i].id === v) { settings.set(k, regionList[i].region); break; } break; case "vertical": settings.alt(k, v, [ "rl", "lr" ]); break; case "line": var vals = v.split(","), vals0 = vals[0]; settings.integer(k, vals0), settings.percent(k, vals0) && settings.set("snapToLines", !1), settings.alt(k, vals0, [ "auto" ]), 2 === vals.length && settings.alt("lineAlign", vals[1], [ "start", "center", "end" ]); break; case "position": vals = v.split(","), settings.percent(k, vals[0]), 2 === vals.length && settings.alt("positionAlign", vals[1], [ "start", "center", "end" ]); break; case "size": settings.percent(k, v); break; case "align": settings.alt(k, v, [ "start", "center", "end", "left", "right" ]); } }, /:/, /\s/), // Apply default values for any missing fields. cue.region = settings.get("region", null), cue.vertical = settings.get("vertical", ""); try { cue.line = settings.get("line", "auto"); } catch (e) {} cue.lineAlign = settings.get("lineAlign", "start"), cue.snapToLines = settings.get("snapToLines", !0), cue.size = settings.get("size", 100); // Safari still uses the old middle value and won't accept center try { cue.align = settings.get("align", "center"); } catch (e) { cue.align = settings.get("align", "middle"); } try { cue.position = settings.get("position", "auto"); } catch (e) { cue.position = settings.get("position", { start: 0, left: 0, center: 50, middle: 50, end: 100, right: 100 }, cue.align); } cue.positionAlign = settings.get("positionAlign", { start: "start", left: "start", center: "center", middle: "center", end: "end", right: "end" }, cue.align); }(input, cue); }(line, self1.cue, self1.regionList); } catch (e) { self1.reportOrThrowError(e), // In case of an error ignore rest of the cue. self1.cue = null, self1.state = "BADCUE"; continue; } self1.state = "CUETEXT"; continue; case "CUETEXT": var hasSubstring = -1 !== line.indexOf("-->"); // 34 - If we have an empty line then report the cue. // 35 - If we have the special substring '-->' then report the cue, // but do not collect the line as we need to process the current // one as a new cue. if (!line || hasSubstring && (alreadyCollectedLine = !0)) { // We are done parsing self cue. self1.oncue && self1.oncue(self1.cue), self1.cue = null, self1.state = "ID"; continue; } self1.cue.text && (self1.cue.text += "\n"), self1.cue.text += line.replace(/\u2028/g, "\n").replace(/u2029/g, "\n"); continue; case "BADCUE": // 54-62 - Collect and discard the remaining cue. line || (self1.state = "ID"); continue; } } catch (e) { self1.reportOrThrowError(e), "CUETEXT" === self1.state && self1.cue && self1.oncue && self1.oncue(self1.cue), self1.cue = null, // Enter BADWEBVTT state if header was not parsed correctly otherwise // another exception occurred so enter BADCUE state. self1.state = "INITIAL" === self1.state ? "BADWEBVTT" : "BADCUE"; } return this; }, flush: function() { try { // If we've flushed, parsed, and we're still on the INITIAL state then // that means we don't have enough of the stream to parse the first // line. if (// Finish decoding the stream. this.buffer += this.decoder.decode(), (this.cue || "HEADER" === this.state) && (this.buffer += "\n\n", this.parse()), "INITIAL" === this.state) throw new ParsingError(ParsingError.Errors.BadSignature); } catch (e) { this.reportOrThrowError(e); } return this.onflush && this.onflush(), this; } }, module.exports = WebVTT1; /***/ }, /***/ 2230: /***/ function(module) { var directionSetting = { "": 1, lr: 1, rl: 1 }, alignSetting = { start: 1, center: 1, end: 1, left: 1, right: 1, auto: 1, "line-left": 1, "line-right": 1 }; function findAlignSetting(value) { return "string" == typeof value && !!alignSetting[value.toLowerCase()] && value.toLowerCase(); } function VTTCue(startTime, endTime, text) { /** * Shim implementation specific properties. These properties are not in * the spec. */ // Lets us know when the VTTCue's data has changed in such a way that we need // to recompute its display state. This lets us compute its display state // lazily. this.hasBeenReset = !1; /** * VTTCue and TextTrackCue properties * http://dev.w3.org/html5/webvtt/#vttcue-interface */ var _id = "", _pauseOnExit = !1, _startTime = startTime, _endTime = endTime, _text = text, _region = null, _vertical = "", _snapToLines = !0, _line = "auto", _lineAlign = "start", _position = "auto", _positionAlign = "auto", _size = 100, _align = "center"; Object.defineProperties(this, { id: { enumerable: !0, get: function() { return _id; }, set: function(value) { _id = "" + value; } }, pauseOnExit: { enumerable: !0, get: function() { return _pauseOnExit; }, set: function(value) { _pauseOnExit = !!value; } }, startTime: { enumerable: !0, get: function() { return _startTime; }, set: function(value) { if ("number" != typeof value) throw TypeError("Start time must be set to a number."); _startTime = value, this.hasBeenReset = !0; } }, endTime: { enumerable: !0, get: function() { return _endTime; }, set: function(value) { if ("number" != typeof value) throw TypeError("End time must be set to a number."); _endTime = value, this.hasBeenReset = !0; } }, text: { enumerable: !0, get: function() { return _text; }, set: function(value) { _text = "" + value, this.hasBeenReset = !0; } }, region: { enumerable: !0, get: function() { return _region; }, set: function(value) { _region = value, this.hasBeenReset = !0; } }, vertical: { enumerable: !0, get: function() { return _vertical; }, set: function(value) { var setting = "string" == typeof value && !!directionSetting[value.toLowerCase()] && value.toLowerCase(); // Have to check for false because the setting an be an empty string. if (!1 === setting) throw SyntaxError("Vertical: an invalid or illegal direction string was specified."); _vertical = setting, this.hasBeenReset = !0; } }, snapToLines: { enumerable: !0, get: function() { return _snapToLines; }, set: function(value) { _snapToLines = !!value, this.hasBeenReset = !0; } }, line: { enumerable: !0, get: function() { return _line; }, set: function(value) { if ("number" != typeof value && "auto" !== value) throw SyntaxError("Line: an invalid number or illegal string was specified."); _line = value, this.hasBeenReset = !0; } }, lineAlign: { enumerable: !0, get: function() { return _lineAlign; }, set: function(value) { var setting = findAlignSetting(value); setting ? (_lineAlign = setting, this.hasBeenReset = !0) : console.warn("lineAlign: an invalid or illegal string was specified."); } }, position: { enumerable: !0, get: function() { return _position; }, set: function(value) { if (value < 0 || value > 100) throw Error("Position must be between 0 and 100."); _position = value, this.hasBeenReset = !0; } }, positionAlign: { enumerable: !0, get: function() { return _positionAlign; }, set: function(value) { var setting = findAlignSetting(value); setting ? (_positionAlign = setting, this.hasBeenReset = !0) : console.warn("positionAlign: an invalid or illegal string was specified."); } }, size: { enumerable: !0, get: function() { return _size; }, set: function(value) { if (value < 0 || value > 100) throw Error("Size must be between 0 and 100."); _size = value, this.hasBeenReset = !0; } }, align: { enumerable: !0, get: function() { return _align; }, set: function(value) { var setting = findAlignSetting(value); if (!setting) throw SyntaxError("align: an invalid or illegal alignment string was specified."); _align = setting, this.hasBeenReset = !0; } } }), /** * Other <track> spec defined properties */ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state this.displayState = void 0; } /** * VTTCue methods */ VTTCue.prototype.getCueAsHTML = function() { // Assume WebVTT.convertCueToDOMTree is on the global. return WebVTT.convertCueToDOMTree(window, this.text); }, module.exports = VTTCue; /***/ }, /***/ 3710: /***/ function(module) { /** * Copyright 2013 vtt.js Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var scrollSetting = { "": !0, up: !0 }; function isValidPercentValue(value) { return "number" == typeof value && value >= 0 && value <= 100; } module.exports = // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface function() { var _width = 100, _lines = 3, _regionAnchorX = 0, _regionAnchorY = 100, _viewportAnchorX = 0, _viewportAnchorY = 100, _scroll = ""; Object.defineProperties(this, { width: { enumerable: !0, get: function() { return _width; }, set: function(value) { if (!isValidPercentValue(value)) throw Error("Width must be between 0 and 100."); _width = value; } }, lines: { enumerable: !0, get: function() { return _lines; }, set: function(value) { if ("number" != typeof value) throw TypeError("Lines must be set to a number."); _lines = value; } }, regionAnchorY: { enumerable: !0, get: function() { return _regionAnchorY; }, set: function(value) { if (!isValidPercentValue(value)) throw Error("RegionAnchorX must be between 0 and 100."); _regionAnchorY = value; } }, regionAnchorX: { enumerable: !0, get: function() { return _regionAnchorX; }, set: function(value) { if (!isValidPercentValue(value)) throw Error("RegionAnchorY must be between 0 and 100."); _regionAnchorX = value; } }, viewportAnchorY: { enumerable: !0, get: function() { return _viewportAnchorY; }, set: function(value) { if (!isValidPercentValue(value)) throw Error("ViewportAnchorY must be between 0 and 100."); _viewportAnchorY = value; } }, viewportAnchorX: { enumerable: !0, get: function() { return _viewportAnchorX; }, set: function(value) { if (!isValidPercentValue(value)) throw Error("ViewportAnchorX must be between 0 and 100."); _viewportAnchorX = value; } }, scroll: { enumerable: !0, get: function() { return _scroll; }, set: function(value) { var setting = "string" == typeof value && !!scrollSetting[value.toLowerCase()] && value.toLowerCase(); // Have to check for false as an empty string is a legal value. !1 === setting ? console.warn("Scroll: an invalid or illegal string was specified.") : _scroll = setting; } } }); }; /***/ }, /***/ 4782: /***/ function(__unused_webpack_module, exports) { "use strict"; exports.byteLength = // base64 is 4/3 + up to two characters of the original data function(b64) { var lens = getLens(b64), validLen = lens[0], placeHoldersLen = lens[1]; return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; }, exports.toByteArray = function(b64) { var tmp, i, lens = getLens(b64), validLen = lens[0], placeHoldersLen = lens[1], arr = new Arr((validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen), curByte = 0, len = placeHoldersLen > 0 ? validLen - 4 : validLen; for(i = 0; i < len; i += 4)tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)], arr[curByte++] = tmp >> 16 & 0xff, arr[curByte++] = tmp >> 8 & 0xff, arr[curByte++] = 0xff & tmp; return 2 === placeHoldersLen && (tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4, arr[curByte++] = 0xff & tmp), 1 === placeHoldersLen && (tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2, arr[curByte++] = tmp >> 8 & 0xff, arr[curByte++] = 0xff & tmp), arr; }, exports.fromByteArray = function(uint8) { // go through the array every three bytes, we'll deal with trailing stuff later for(var tmp, len = uint8.length, extraBytes = len % 3, parts = [], i = 0, len2 = len - extraBytes; i < len2; i += 16383)parts.push(function(uint8, start, end) { for(var tmp, output = [], i = start; i < end; i += 3)output.push(lookup[(tmp = (uint8[i] << 16 & 0xff0000) + (uint8[i + 1] << 8 & 0xff00) + (0xff & uint8[i + 2])) >> 18 & 0x3f] + lookup[tmp >> 12 & 0x3f] + lookup[tmp >> 6 & 0x3f] + lookup[0x3f & tmp]); return output.join(""); }(uint8, i, i + 16383 > len2 ? len2 : i + 16383)); return 1 === extraBytes ? parts.push(lookup[(tmp = uint8[len - 1]) >> 2] + lookup[tmp << 4 & 0x3f] + "==") : 2 === extraBytes && parts.push(lookup[(tmp = (uint8[len - 2] << 8) + uint8[len - 1]) >> 10] + lookup[tmp >> 4 & 0x3f] + lookup[tmp << 2 & 0x3f] + "="), parts.join(""); }; for(var lookup = [], revLookup = [], Arr = "undefined" != typeof Uint8Array ? Uint8Array : Array, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i = 0, len = code.length; i < len; ++i)lookup[i] = code[i], revLookup[code.charCodeAt(i)] = i; function getLens(b64) { var len = b64.length; if (len % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4"); // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf("="); -1 === validLen && (validLen = len); var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; return [ validLen, placeHoldersLen ]; } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup["-".charCodeAt(0)] = 62, revLookup["_".charCodeAt(0)] = 63; /***/ }, /***/ 816: /***/ function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ /* eslint-disable no-proto */ var base64 = __webpack_require__(4782), ieee754 = __webpack_require__(8898), customInspectSymbol = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("nodejs.util.inspect.custom") : null; function createBuffer(length) { if (length > 0x7fffffff) throw RangeError('The value "' + length + '" is invalid for option "size"'); // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length); return Object.setPrototypeOf(buf, Buffer.prototype), buf; } /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ function Buffer(arg, encodingOrOffset, length) { // Common case. if ("number" == typeof arg) { if ("string" == typeof encodingOrOffset) throw TypeError('The "string" argument must be of type string. Received type number'); return allocUnsafe(arg); } return from(arg, encodingOrOffset, length); } function from(value, encodingOrOffset, length) { if ("string" == typeof value) return function(string, encoding) { if (("string" != typeof encoding || "" === encoding) && (encoding = "utf8"), !Buffer.isEncoding(encoding)) throw TypeError("Unknown encoding: " + encoding); var length = 0 | byteLength(string, encoding), buf = createBuffer(length), actual = buf.write(string, encoding); return actual !== length && // Writing a hex string, for example, that contains invalid characters will // cause everything after the first invalid character to be ignored. (e.g. // 'abxxcd' will be treated as 'ab') (buf = buf.slice(0, actual)), buf; }(value, encodingOrOffset); if (ArrayBuffer.isView(value)) return fromArrayLike(value); if (null == value) throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer) || "undefined" != typeof SharedArrayBuffer && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) return function(array, byteOffset, length) { var buf; if (byteOffset < 0 || array.byteLength < byteOffset) throw RangeError('"offset" is outside of buffer bounds'); if (array.byteLength < byteOffset + (length || 0)) throw RangeError('"length" is outside of buffer bounds'); return(// Return an augmented `Uint8Array` instance Object.setPrototypeOf(buf = void 0 === byteOffset && void 0 === length ? new Uint8Array(array) : void 0 === length ? new Uint8Array(array, byteOffset) : new Uint8Array(array, byteOffset, length), Buffer.prototype), buf); }(value, encodingOrOffset, length); if ("number" == typeof value) throw TypeError('The "value" argument must not be of type number. Received type number'); var valueOf = value.valueOf && value.valueOf(); if (null != valueOf && valueOf !== value) return Buffer.from(valueOf, encodingOrOffset, length); var b = function(obj) { if (Buffer.isBuffer(obj)) { var obj1, len = 0 | checked(obj.length), buf = createBuffer(len); return 0 === buf.length || obj.copy(buf, 0, 0, len), buf; } return void 0 !== obj.length ? "number" != typeof obj.length || (obj1 = obj.length) != obj1 ? createBuffer(0) : fromArrayLike(obj) : "Buffer" === obj.type && Array.isArray(obj.data) ? fromArrayLike(obj.data) : void 0; }(value); if (b) return b; if ("undefined" != typeof Symbol && null != Symbol.toPrimitive && "function" == typeof value[Symbol.toPrimitive]) return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); } function assertSize(size) { if ("number" != typeof size) throw TypeError('"size" argument must be of type number'); if (size < 0) throw RangeError('The value "' + size + '" is invalid for option "size"'); } function allocUnsafe(size) { return assertSize(size), createBuffer(size < 0 ? 0 : 0 | checked(size)); } function fromArrayLike(array) { for(var length = array.length < 0 ? 0 : 0 | checked(array.length), buf = createBuffer(length), i = 0; i < length; i += 1)buf[i] = 255 & array[i]; return buf; } function checked(length) { // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= 0x7fffffff) throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes"); return 0 | length; } function byteLength(string, encoding) { if (Buffer.isBuffer(string)) return string.length; if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) return string.byteLength; if ("string" != typeof string) throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string); var len = string.length, mustMatch = arguments.length > 2 && !0 === arguments[2]; if (!mustMatch && 0 === len) return 0; for(// Use a for loop to avoid recursion var loweredCase = !1;;)switch(encoding){ case "ascii": case "latin1": case "binary": return len; case "utf8": case "utf-8": return utf8ToBytes(string).length; case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return 2 * len; case "hex": return len >>> 1; case "base64": return base64ToBytes(string).length; default: if (loweredCase) return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 encoding = ("" + encoding).toLowerCase(), loweredCase = !0; } } function slowToString(encoding, start, end) { var start1, end1, loweredCase = !1; // Return early if start > this.length. Done here to prevent potential uint32 // coercion fail below. if ((void 0 === start || start < 0) && (start = 0), start > this.length || ((void 0 === end || end > this.length) && (end = this.length), end <= 0 || // Force coersion to uint32. This will also coerce falsey/NaN values to 0. (end >>>= 0) <= (start >>>= 0))) return ""; for(encoding || (encoding = "utf8");;)switch(encoding){ case "hex": return function(buf, start, end) { var len = buf.length; (!start || start < 0) && (start = 0), (!end || end < 0 || end > len) && (end = len); for(var out = "", i = start; i < end; ++i)out += hexSliceLookupTable[buf[i]]; return out; }(this, start, end); case "utf8": case "utf-8": return utf8Slice(this, start, end); case "ascii": return function(buf, start, end) { var ret = ""; end = Math.min(buf.length, end); for(var i = start; i < end; ++i)ret += String.fromCharCode(0x7f & buf[i]); return ret; }(this, start, end); case "latin1": case "binary": return function(buf, start, end) { var ret = ""; end = Math.min(buf.length, end); for(var i = start; i < end; ++i)ret += String.fromCharCode(buf[i]); return ret; }(this, start, end); case "base64": return start1 = start, end1 = end, 0 === start1 && end1 === this.length ? base64.fromByteArray(this) : base64.fromByteArray(this.slice(start1, end1)); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return function(buf, start, end) { for(var bytes = buf.slice(start, end), res = "", i = 0; i < bytes.length; i += 2)res += String.fromCharCode(bytes[i] + 256 * bytes[i + 1]); return res; }(this, start, end); default: if (loweredCase) throw TypeError("Unknown encoding: " + encoding); encoding = (encoding + "").toLowerCase(), loweredCase = !0; } } function swap(b, n, m) { var i = b[n]; b[n] = b[m], b[m] = i; } // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, // OR the last index of `val` in `buffer` at offset <= `byteOffset`. // // Arguments: // - buffer - a Buffer to search // - val - a string, Buffer, or number // - byteOffset - an index into `buffer`; will be clamped to an int32 // - encoding - an optional encoding, relevant is val is a string // - dir - true for indexOf, false for lastIndexOf function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { var obj; // Empty buffer means no match if (0 === buffer.length) return -1; if ("string" == typeof byteOffset ? (encoding = byteOffset, byteOffset = 0) : byteOffset > 0x7fffffff ? byteOffset = 0x7fffffff : byteOffset < -2147483648 && (byteOffset = -2147483648), (obj = byteOffset *= 1) != obj && // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer (byteOffset = dir ? 0 : buffer.length - 1), byteOffset < 0 && (byteOffset = buffer.length + byteOffset), byteOffset >= buffer.length) { if (dir) return -1; byteOffset = buffer.length - 1; } else if (byteOffset < 0) { if (!dir) return -1; byteOffset = 0; } // Finally, search either indexOf (if dir is true) or lastIndexOf if ("string" == typeof val && (val = Buffer.from(val, encoding)), Buffer.isBuffer(val)) return(// Special case: looking for empty string/buffer always fails 0 === val.length ? -1 : arrayIndexOf(buffer, val, byteOffset, encoding, dir)); if ("number" == typeof val) return (val &= 0xff, "function" == typeof Uint8Array.prototype.indexOf) ? dir ? Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) : Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) : arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir); throw TypeError("val must be string, number or Buffer"); } function arrayIndexOf(arr, val, byteOffset, encoding, dir) { var i, indexSize = 1, arrLength = arr.length, valLength = val.length; if (void 0 !== encoding && ("ucs2" === (encoding = String(encoding).toLowerCase()) || "ucs-2" === encoding || "utf16le" === encoding || "utf-16le" === encoding)) { if (arr.length < 2 || val.length < 2) return -1; indexSize = 2, arrLength /= 2, valLength /= 2, byteOffset /= 2; } function read(buf, i) { return 1 === indexSize ? buf[i] : buf.readUInt16BE(i * indexSize); } if (dir) { var foundIndex = -1; for(i = byteOffset; i < arrLength; i++)if (read(arr, i) === read(val, -1 === foundIndex ? 0 : i - foundIndex)) { if (-1 === foundIndex && (foundIndex = i), i - foundIndex + 1 === valLength) return foundIndex * indexSize; } else -1 !== foundIndex && (i -= i - foundIndex), foundIndex = -1; } else for(byteOffset + valLength > arrLength && (byteOffset = arrLength - valLength), i = byteOffset; i >= 0; i--){ for(var found = !0, j = 0; j < valLength; j++)if (read(arr, i + j) !== read(val, j)) { found = !1; break; } if (found) return i; } return -1; } function utf8Slice(buf, start, end) { end = Math.min(buf.length, end); for(var res = [], i = start; i < end;){ var secondByte, thirdByte, fourthByte, tempCodePoint, firstByte = buf[i], codePoint = null, bytesPerSequence = firstByte > 0xef ? 4 : firstByte > 0xdf ? 3 : firstByte > 0xbf ? 2 : 1; if (i + bytesPerSequence <= end) switch(bytesPerSequence){ case 1: firstByte < 0x80 && (codePoint = firstByte); break; case 2: (0xc0 & (secondByte = buf[i + 1])) == 0x80 && (tempCodePoint = (0x1f & firstByte) << 0x6 | 0x3f & secondByte) > 0x7f && (codePoint = tempCodePoint); break; case 3: secondByte = buf[i + 1], thirdByte = buf[i + 2], (0xc0 & secondByte) == 0x80 && (0xc0 & thirdByte) == 0x80 && (tempCodePoint = (0xf & firstByte) << 0xc | (0x3f & secondByte) << 0x6 | 0x3f & thirdByte) > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff) && (codePoint = tempCodePoint); break; case 4: secondByte = buf[i + 1], thirdByte = buf[i + 2], fourthByte = buf[i + 3], (0xc0 & secondByte) == 0x80 && (0xc0 & thirdByte) == 0x80 && (0xc0 & fourthByte) == 0x80 && (tempCodePoint = (0xf & firstByte) << 0x12 | (0x3f & secondByte) << 0xc | (0x3f & thirdByte) << 0x6 | 0x3f & fourthByte) > 0xffff && tempCodePoint < 0x110000 && (codePoint = tempCodePoint); } null === codePoint ? (// we did not generate a valid codePoint so insert a // replacement char (U+FFFD) and advance only 1 byte codePoint = 0xfffd, bytesPerSequence = 1) : codePoint > 0xffff && (// encode to utf16 (surrogate pair dance) codePoint -= 0x10000, res.push(codePoint >>> 10 & 0x3ff | 0xd800), codePoint = 0xdc00 | 0x3ff & codePoint), res.push(codePoint), i += bytesPerSequence; } return function(codePoints) { var len = codePoints.length; if (len <= 0x1000) return String.fromCharCode.apply(String, codePoints); // avoid extra slice() for(// Decode in chunks to avoid "call stack size exceeded". var res = "", i = 0; i < len;)res += String.fromCharCode.apply(String, codePoints.slice(i, i += 0x1000)); return res; }(res); } /* * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset(offset, ext, length) { if (offset % 1 != 0 || offset < 0) throw RangeError("offset is not uint"); if (offset + ext > length) throw RangeError("Trying to access beyond buffer length"); } function checkInt(buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) throw RangeError('"value" argument is out of bounds'); if (offset + ext > buf.length) throw RangeError("Index out of range"); } function checkIEEE754(buf, value, offset, ext, max, min) { if (offset + ext > buf.length || offset < 0) throw RangeError("Index out of range"); } function writeFloat(buf, value, offset, littleEndian, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkIEEE754(buf, value, offset, 4, 3.4028234663852886e38, -340282346638528860000000000000000000000), ieee754.write(buf, value, offset, littleEndian, 23, 4), offset + 4; } function writeDouble(buf, value, offset, littleEndian, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkIEEE754(buf, value, offset, 8, 1.7976931348623157e308, -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000), ieee754.write(buf, value, offset, littleEndian, 52, 8), offset + 8; } exports.Buffer = Buffer, exports.SlowBuffer = function(length) { return +length != length && // eslint-disable-line eqeqeq (length = 0), Buffer.alloc(+length); }, exports.INSPECT_MAX_BYTES = 50, exports.kMaxLength = 0x7fffffff, /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) * === false Print warning and recommend using `buffer` v4.x which has an Object * implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * * We report that the browser does not support typed arrays if the are not subclassable * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support * for __proto__ and has a buggy typed array implementation. */ Buffer.TYPED_ARRAY_SUPPORT = function() { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1), proto = { foo: function() { return 42; } }; return Object.setPrototypeOf(proto, Uint8Array.prototype), Object.setPrototypeOf(arr, proto), 42 === arr.foo(); } catch (e) { return !1; } }(), Buffer.TYPED_ARRAY_SUPPORT || "undefined" == typeof console || "function" != typeof console.error || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(Buffer.prototype, "parent", { enumerable: !0, get: function() { if (Buffer.isBuffer(this)) return this.buffer; } }), Object.defineProperty(Buffer.prototype, "offset", { enumerable: !0, get: function() { if (Buffer.isBuffer(this)) return this.byteOffset; } }), Buffer.poolSize = 8192, /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }, // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: // https://github.com/feross/buffer/pull/148 Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype), Object.setPrototypeOf(Buffer, Uint8Array), /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function(size, fill, encoding) { return (assertSize(size), size <= 0) ? createBuffer(size) : void 0 !== fill ? "string" == typeof encoding ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill) : createBuffer(size); }, /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function(size) { return allocUnsafe(size); }, /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function(size) { return allocUnsafe(size); }, Buffer.isBuffer = function(b) { return null != b && !0 === b._isBuffer && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false }, Buffer.compare = function(a, b) { if (isInstance(a, Uint8Array) && (a = Buffer.from(a, a.offset, a.byteLength)), isInstance(b, Uint8Array) && (b = Buffer.from(b, b.offset, b.byteLength)), !Buffer.isBuffer(a) || !Buffer.isBuffer(b)) throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); if (a === b) return 0; for(var x = a.length, y = b.length, i = 0, len = Math.min(x, y); i < len; ++i)if (a[i] !== b[i]) { x = a[i], y = b[i]; break; } return x < y ? -1 : +(y < x); }, Buffer.isEncoding = function(encoding) { switch(String(encoding).toLowerCase()){ case "hex": case "utf8": case "utf-8": case "ascii": case "latin1": case "binary": case "base64": case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return !0; default: return !1; } }, Buffer.concat = function(list, length) { if (!Array.isArray(list)) throw TypeError('"list" argument must be an Array of Buffers'); if (0 === list.length) return Buffer.alloc(0); if (void 0 === length) for(i = 0, length = 0; i < list.length; ++i)length += list[i].length; var i, buffer = Buffer.allocUnsafe(length), pos = 0; for(i = 0; i < list.length; ++i){ var buf = list[i]; if (isInstance(buf, Uint8Array) && (buf = Buffer.from(buf)), !Buffer.isBuffer(buf)) throw TypeError('"list" argument must be an Array of Buffers'); buf.copy(buffer, pos), pos += buf.length; } return buffer; }, Buffer.byteLength = byteLength, // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) // to detect a Buffer instance. It's not possible to use `instanceof Buffer` // reliably in a browserify context because there could be multiple different // copies of the 'buffer' package in use. This method works even for Buffer // instances that were created from another copy of the `buffer` package. // See: https://github.com/feross/buffer/issues/154 Buffer.prototype._isBuffer = !0, Buffer.prototype.swap16 = function() { var len = this.length; if (len % 2 != 0) throw RangeError("Buffer size must be a multiple of 16-bits"); for(var i = 0; i < len; i += 2)swap(this, i, i + 1); return this; }, Buffer.prototype.swap32 = function() { var len = this.length; if (len % 4 != 0) throw RangeError("Buffer size must be a multiple of 32-bits"); for(var i = 0; i < len; i += 4)swap(this, i, i + 3), swap(this, i + 1, i + 2); return this; }, Buffer.prototype.swap64 = function() { var len = this.length; if (len % 8 != 0) throw RangeError("Buffer size must be a multiple of 64-bits"); for(var i = 0; i < len; i += 8)swap(this, i, i + 7), swap(this, i + 1, i + 6), swap(this, i + 2, i + 5), swap(this, i + 3, i + 4); return this; }, Buffer.prototype.toString = function() { var length = this.length; return 0 === length ? "" : 0 == arguments.length ? utf8Slice(this, 0, length) : slowToString.apply(this, arguments); }, Buffer.prototype.toLocaleString = Buffer.prototype.toString, Buffer.prototype.equals = function(b) { if (!Buffer.isBuffer(b)) throw TypeError("Argument must be a Buffer"); return this === b || 0 === Buffer.compare(this, b); }, Buffer.prototype.inspect = function() { var str = "", max = exports.INSPECT_MAX_BYTES; return str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(), this.length > max && (str += " ... "), "<Buffer " + str + ">"; }, customInspectSymbol && (Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect), Buffer.prototype.compare = function(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array) && (target = Buffer.from(target, target.offset, target.byteLength)), !Buffer.isBuffer(target)) throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); if (void 0 === start && (start = 0), void 0 === end && (end = target ? target.length : 0), void 0 === thisStart && (thisStart = 0), void 0 === thisEnd && (thisEnd = this.length), start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw RangeError("out of range index"); if (thisStart >= thisEnd && start >= end) return 0; if (thisStart >= thisEnd) return -1; if (start >= end) return 1; if (start >>>= 0, end >>>= 0, thisStart >>>= 0, thisEnd >>>= 0, this === target) return 0; for(var x = thisEnd - thisStart, y = end - start, len = Math.min(x, y), thisCopy = this.slice(thisStart, thisEnd), targetCopy = target.slice(start, end), i = 0; i < len; ++i)if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i], y = targetCopy[i]; break; } return x < y ? -1 : +(y < x); }, Buffer.prototype.includes = function(val, byteOffset, encoding) { return -1 !== this.indexOf(val, byteOffset, encoding); }, Buffer.prototype.indexOf = function(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, !0); }, Buffer.prototype.lastIndexOf = function(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, !1); }, Buffer.prototype.write = function(string, offset, length, encoding) { // Buffer#write(string) if (void 0 === offset) encoding = "utf8", length = this.length, offset = 0; else if (void 0 === length && "string" == typeof offset) encoding = offset, length = this.length, offset = 0; else if (isFinite(offset)) offset >>>= 0, isFinite(length) ? (length >>>= 0, void 0 === encoding && (encoding = "utf8")) : (encoding = length, length = void 0); else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); var offset1, length1, offset2, length2, offset3, length3, offset4, length4, offset5, length5, remaining = this.length - offset; if ((void 0 === length || length > remaining) && (length = remaining), string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw RangeError("Attempt to write outside buffer bounds"); encoding || (encoding = "utf8"); for(var loweredCase = !1;;)switch(encoding){ case "hex": return function(buf, string, offset, length) { offset = Number(offset) || 0; var remaining = buf.length - offset; length ? (length = Number(length)) > remaining && (length = remaining) : length = remaining; var strLen = string.length; length > strLen / 2 && (length = strLen / 2); for(var i = 0; i < length; ++i){ var parsed = parseInt(string.substr(2 * i, 2), 16); if (parsed != parsed) break; buf[offset + i] = parsed; } return i; }(this, string, offset, length); case "utf8": case "utf-8": return offset2 = offset, length2 = length, blitBuffer(utf8ToBytes(string, this.length - offset2), this, offset2, length2); case "ascii": return offset3 = offset, length3 = length, blitBuffer(asciiToBytes(string), this, offset3, length3); case "latin1": case "binary": return offset1 = offset, length1 = length, blitBuffer(asciiToBytes(string), this, offset1, length1); case "base64": // Warning: maxLength not taken into account in base64Write return offset4 = offset, length4 = length, blitBuffer(base64ToBytes(string), this, offset4, length4); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return offset5 = offset, length5 = length, blitBuffer(function(str, units) { for(var c, hi, byteArray = [], i = 0; i < str.length && !((units -= 2) < 0); ++i)hi = (c = str.charCodeAt(i)) >> 8, byteArray.push(c % 256), byteArray.push(hi); return byteArray; }(string, this.length - offset5), this, offset5, length5); default: if (loweredCase) throw TypeError("Unknown encoding: " + encoding); encoding = ("" + encoding).toLowerCase(), loweredCase = !0; } }, Buffer.prototype.toJSON = function() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; }, Buffer.prototype.slice = function(start, end) { var len = this.length; start = ~~start, end = void 0 === end ? len : ~~end, start < 0 ? (start += len) < 0 && (start = 0) : start > len && (start = len), end < 0 ? (end += len) < 0 && (end = 0) : end > len && (end = len), end < start && (end = start); var newBuf = this.subarray(start, end); return(// Return an augmented `Uint8Array` instance Object.setPrototypeOf(newBuf, Buffer.prototype), newBuf); }, Buffer.prototype.readUIntLE = function(offset, byteLength, noAssert) { offset >>>= 0, byteLength >>>= 0, noAssert || checkOffset(offset, byteLength, this.length); for(var val = this[offset], mul = 1, i = 0; ++i < byteLength && (mul *= 0x100);)val += this[offset + i] * mul; return val; }, Buffer.prototype.readUIntBE = function(offset, byteLength, noAssert) { offset >>>= 0, byteLength >>>= 0, noAssert || checkOffset(offset, byteLength, this.length); for(var val = this[offset + --byteLength], mul = 1; byteLength > 0 && (mul *= 0x100);)val += this[offset + --byteLength] * mul; return val; }, Buffer.prototype.readUInt8 = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 1, this.length), this[offset]; }, Buffer.prototype.readUInt16LE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 2, this.length), this[offset] | this[offset + 1] << 8; }, Buffer.prototype.readUInt16BE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 2, this.length), this[offset] << 8 | this[offset + 1]; }, Buffer.prototype.readUInt32LE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + 0x1000000 * this[offset + 3]; }, Buffer.prototype.readUInt32BE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), 0x1000000 * this[offset] + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }, Buffer.prototype.readIntLE = function(offset, byteLength, noAssert) { offset >>>= 0, byteLength >>>= 0, noAssert || checkOffset(offset, byteLength, this.length); for(var val = this[offset], mul = 1, i = 0; ++i < byteLength && (mul *= 0x100);)val += this[offset + i] * mul; return val >= (mul *= 0x80) && (val -= Math.pow(2, 8 * byteLength)), val; }, Buffer.prototype.readIntBE = function(offset, byteLength, noAssert) { offset >>>= 0, byteLength >>>= 0, noAssert || checkOffset(offset, byteLength, this.length); for(var i = byteLength, mul = 1, val = this[offset + --i]; i > 0 && (mul *= 0x100);)val += this[offset + --i] * mul; return val >= (mul *= 0x80) && (val -= Math.pow(2, 8 * byteLength)), val; }, Buffer.prototype.readInt8 = function(offset, noAssert) { return (offset >>>= 0, noAssert || checkOffset(offset, 1, this.length), 0x80 & this[offset]) ? -((0xff - this[offset] + 1) * 1) : this[offset]; }, Buffer.prototype.readInt16LE = function(offset, noAssert) { offset >>>= 0, noAssert || checkOffset(offset, 2, this.length); var val = this[offset] | this[offset + 1] << 8; return 0x8000 & val ? 0xffff0000 | val : val; }, Buffer.prototype.readInt16BE = function(offset, noAssert) { offset >>>= 0, noAssert || checkOffset(offset, 2, this.length); var val = this[offset + 1] | this[offset] << 8; return 0x8000 & val ? 0xffff0000 | val : val; }, Buffer.prototype.readInt32LE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }, Buffer.prototype.readInt32BE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }, Buffer.prototype.readFloatLE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), ieee754.read(this, offset, !0, 23, 4); }, Buffer.prototype.readFloatBE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 4, this.length), ieee754.read(this, offset, !1, 23, 4); }, Buffer.prototype.readDoubleLE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 8, this.length), ieee754.read(this, offset, !0, 52, 8); }, Buffer.prototype.readDoubleBE = function(offset, noAssert) { return offset >>>= 0, noAssert || checkOffset(offset, 8, this.length), ieee754.read(this, offset, !1, 52, 8); }, Buffer.prototype.writeUIntLE = function(value, offset, byteLength, noAssert) { if (value *= 1, offset >>>= 0, byteLength >>>= 0, !noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var mul = 1, i = 0; for(this[offset] = 0xff & value; ++i < byteLength && (mul *= 0x100);)this[offset + i] = value / mul & 0xff; return offset + byteLength; }, Buffer.prototype.writeUIntBE = function(value, offset, byteLength, noAssert) { if (value *= 1, offset >>>= 0, byteLength >>>= 0, !noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var i = byteLength - 1, mul = 1; for(this[offset + i] = 0xff & value; --i >= 0 && (mul *= 0x100);)this[offset + i] = value / mul & 0xff; return offset + byteLength; }, Buffer.prototype.writeUInt8 = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 1, 0xff, 0), this[offset] = 0xff & value, offset + 1; }, Buffer.prototype.writeUInt16LE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 2, 0xffff, 0), this[offset] = 0xff & value, this[offset + 1] = value >>> 8, offset + 2; }, Buffer.prototype.writeUInt16BE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 2, 0xffff, 0), this[offset] = value >>> 8, this[offset + 1] = 0xff & value, offset + 2; }, Buffer.prototype.writeUInt32LE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 4, 0xffffffff, 0), this[offset + 3] = value >>> 24, this[offset + 2] = value >>> 16, this[offset + 1] = value >>> 8, this[offset] = 0xff & value, offset + 4; }, Buffer.prototype.writeUInt32BE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 4, 0xffffffff, 0), this[offset] = value >>> 24, this[offset + 1] = value >>> 16, this[offset + 2] = value >>> 8, this[offset + 3] = 0xff & value, offset + 4; }, Buffer.prototype.writeIntLE = function(value, offset, byteLength, noAssert) { if (value *= 1, offset >>>= 0, !noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } var i = 0, mul = 1, sub = 0; for(this[offset] = 0xff & value; ++i < byteLength && (mul *= 0x100);)value < 0 && 0 === sub && 0 !== this[offset + i - 1] && (sub = 1), this[offset + i] = (value / mul >> 0) - sub & 0xff; return offset + byteLength; }, Buffer.prototype.writeIntBE = function(value, offset, byteLength, noAssert) { if (value *= 1, offset >>>= 0, !noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } var i = byteLength - 1, mul = 1, sub = 0; for(this[offset + i] = 0xff & value; --i >= 0 && (mul *= 0x100);)value < 0 && 0 === sub && 0 !== this[offset + i + 1] && (sub = 1), this[offset + i] = (value / mul >> 0) - sub & 0xff; return offset + byteLength; }, Buffer.prototype.writeInt8 = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 1, 0x7f, -128), value < 0 && (value = 0xff + value + 1), this[offset] = 0xff & value, offset + 1; }, Buffer.prototype.writeInt16LE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 2, 0x7fff, -32768), this[offset] = 0xff & value, this[offset + 1] = value >>> 8, offset + 2; }, Buffer.prototype.writeInt16BE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 2, 0x7fff, -32768), this[offset] = value >>> 8, this[offset + 1] = 0xff & value, offset + 2; }, Buffer.prototype.writeInt32LE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 4, 0x7fffffff, -2147483648), this[offset] = 0xff & value, this[offset + 1] = value >>> 8, this[offset + 2] = value >>> 16, this[offset + 3] = value >>> 24, offset + 4; }, Buffer.prototype.writeInt32BE = function(value, offset, noAssert) { return value *= 1, offset >>>= 0, noAssert || checkInt(this, value, offset, 4, 0x7fffffff, -2147483648), value < 0 && (value = 0xffffffff + value + 1), this[offset] = value >>> 24, this[offset + 1] = value >>> 16, this[offset + 2] = value >>> 8, this[offset + 3] = 0xff & value, offset + 4; }, Buffer.prototype.writeFloatLE = function(value, offset, noAssert) { return writeFloat(this, value, offset, !0, noAssert); }, Buffer.prototype.writeFloatBE = function(value, offset, noAssert) { return writeFloat(this, value, offset, !1, noAssert); }, Buffer.prototype.writeDoubleLE = function(value, offset, noAssert) { return writeDouble(this, value, offset, !0, noAssert); }, Buffer.prototype.writeDoubleBE = function(value, offset, noAssert) { return writeDouble(this, value, offset, !1, noAssert); }, // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function(target, targetStart, start, end) { if (!Buffer.isBuffer(target)) throw TypeError("argument should be a Buffer"); // Copy 0 bytes; we're done if (start || (start = 0), end || 0 === end || (end = this.length), targetStart >= target.length && (targetStart = target.length), targetStart || (targetStart = 0), end > 0 && end < start && (end = start), end === start || 0 === target.length || 0 === this.length) return 0; // Fatal error conditions if (targetStart < 0) throw RangeError("targetStart out of bounds"); if (start < 0 || start >= this.length) throw RangeError("Index out of range"); if (end < 0) throw RangeError("sourceEnd out of bounds"); end > this.length && (end = this.length), target.length - targetStart < end - start && (end = target.length - targetStart + start); var len = end - start; if (this === target && "function" == typeof Uint8Array.prototype.copyWithin) // Use built-in when available, missing from IE11 this.copyWithin(targetStart, start, end); else if (this === target && start < targetStart && targetStart < end) // descending copy from end for(var i = len - 1; i >= 0; --i)target[i + targetStart] = this[i + start]; else Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); return len; }, // Usage: // buffer.fill(number[, offset[, end]]) // buffer.fill(buffer[, offset[, end]]) // buffer.fill(string[, offset[, end]][, encoding]) Buffer.prototype.fill = function(val, start, end, encoding) { // Handle string cases: if ("string" == typeof val) { if ("string" == typeof start ? (encoding = start, start = 0, end = this.length) : "string" == typeof end && (encoding = end, end = this.length), void 0 !== encoding && "string" != typeof encoding) throw TypeError("encoding must be a string"); if ("string" == typeof encoding && !Buffer.isEncoding(encoding)) throw TypeError("Unknown encoding: " + encoding); if (1 === val.length) { var i, code = val.charCodeAt(0); ("utf8" === encoding && code < 128 || "latin1" === encoding) && // Fast path: If `val` fits into a single byte, use that numeric value. (val = code); } } else "number" == typeof val ? val &= 255 : "boolean" == typeof val && (val = Number(val)); // Invalid ranges are not set to a default, so can range check early. if (start < 0 || this.length < start || this.length < end) throw RangeError("Out of range index"); if (end <= start) return this; if (start >>>= 0, end = void 0 === end ? this.length : end >>> 0, val || (val = 0), "number" == typeof val) for(i = start; i < end; ++i)this[i] = val; else { var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding), len = bytes.length; if (0 === len) throw TypeError('The value "' + val + '" is invalid for argument "value"'); for(i = 0; i < end - start; ++i)this[i + start] = bytes[i % len]; } return this; }; // HELPER FUNCTIONS // ================ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; function utf8ToBytes(string, units) { units = units || 1 / 0; for(var codePoint, length = string.length, leadSurrogate = null, bytes = [], i = 0; i < length; ++i){ // is surrogate component if ((codePoint = string.charCodeAt(i)) > 0xd7ff && codePoint < 0xe000) { // last char was a lead if (!leadSurrogate) { // no lead yet if (codePoint > 0xdbff || i + 1 === length) { // unexpected trail (units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd); continue; } // valid lead leadSurrogate = codePoint; continue; } // 2 leads in a row if (codePoint < 0xdc00) { (units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd), leadSurrogate = codePoint; continue; } // valid surrogate pair codePoint = (leadSurrogate - 0xd800 << 10 | codePoint - 0xdc00) + 0x10000; } else leadSurrogate && (units -= 3) > -1 && bytes.push(0xef, 0xbf, 0xbd); // encode utf8 if (leadSurrogate = null, codePoint < 0x80) { if ((units -= 1) < 0) break; bytes.push(codePoint); } else if (codePoint < 0x800) { if ((units -= 2) < 0) break; bytes.push(codePoint >> 0x6 | 0xc0, 0x3f & codePoint | 0x80); } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break; bytes.push(codePoint >> 0xc | 0xe0, codePoint >> 0x6 & 0x3f | 0x80, 0x3f & codePoint | 0x80); } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break; bytes.push(codePoint >> 0x12 | 0xf0, codePoint >> 0xc & 0x3f | 0x80, codePoint >> 0x6 & 0x3f | 0x80, 0x3f & codePoint | 0x80); } else throw Error("Invalid code point"); } return bytes; } function asciiToBytes(str) { for(var byteArray = [], i = 0; i < str.length; ++i)// Node's code seems to be doing this and not & 0x7F.. byteArray.push(0xff & str.charCodeAt(i)); return byteArray; } function base64ToBytes(str) { return base64.toByteArray(function(str) { // Node converts strings with length < 2 to '' if (// Node strips out invalid characters like \n and \t from the string, base64-js does not (str = // Node takes equal signs as end of the Base64 encoding (str = str.split("=")[0]).trim().replace(INVALID_BASE64_RE, "")).length < 2) return ""; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not for(; str.length % 4 != 0;)str += "="; return str; }(str)); } function blitBuffer(src, dst, offset, length) { for(var i = 0; i < length && !(i + offset >= dst.length) && !(i >= src.length); ++i)dst[i + offset] = src[i]; return i; } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass // the `instanceof` check but they should be treated as of that type. // See: https://github.com/feross/buffer/issues/166 function isInstance(obj, type) { return obj instanceof type || null != obj && null != obj.constructor && null != obj.constructor.name && obj.constructor.name === type.name; } // Create lookup table for `toString('hex')` // See: https://github.com/feross/buffer/issues/219 var hexSliceLookupTable = function() { for(var alphabet = "0123456789abcdef", table = Array(256), i = 0; i < 16; ++i)for(var i16 = 16 * i, j = 0; j < 16; ++j)table[i16 + j] = alphabet[i] + alphabet[j]; return table; }(); /***/ }, /***/ 8898: /***/ function(__unused_webpack_module, exports) { exports.read = function(buffer, offset, isLE, mLen, nBytes) { var e, m, eLen = 8 * nBytes - mLen - 1, eMax = (1 << eLen) - 1, eBias = eMax >> 1, nBits = -7, i = isLE ? nBytes - 1 : 0, d = isLE ? -1 : 1, s = buffer[offset + i]; for(i += d, e = s & (1 << -nBits) - 1, s >>= -nBits, nBits += eLen; nBits > 0; e = 256 * e + buffer[offset + i], i += d, nBits -= 8); for(m = e & (1 << -nBits) - 1, e >>= -nBits, nBits += mLen; nBits > 0; m = 256 * m + buffer[offset + i], i += d, nBits -= 8); if (0 === e) e = 1 - eBias; else { if (e === eMax) return m ? NaN : 1 / 0 * (s ? -1 : 1); m += Math.pow(2, mLen), e -= eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - mLen); }, exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { var e, m, c, eLen = 8 * nBytes - mLen - 1, eMax = (1 << eLen) - 1, eBias = eMax >> 1, rt = 0.00000005960464477539062 * (23 === mLen), i = isLE ? 0 : nBytes - 1, d = isLE ? 1 : -1, s = +(value < 0 || 0 === value && 1 / value < 0); for(isNaN(value = Math.abs(value)) || value === 1 / 0 ? (m = +!!isNaN(value), e = eMax) : (e = Math.floor(Math.log(value) / Math.LN2), value * (c = Math.pow(2, -e)) < 1 && (e--, c *= 2), e + eBias >= 1 ? value += rt / c : value += rt * Math.pow(2, 1 - eBias), value * c >= 2 && (e++, c /= 2), e + eBias >= eMax ? (m = 0, e = eMax) : e + eBias >= 1 ? (m = (value * c - 1) * Math.pow(2, mLen), e += eBias) : (m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen), e = 0)); mLen >= 8; buffer[offset + i] = 0xff & m, i += d, m /= 256, mLen -= 8); for(e = e << mLen | m, eLen += mLen; eLen > 0; buffer[offset + i] = 0xff & e, i += d, e /= 256, eLen -= 8); buffer[offset + i - d] |= 128 * s; }; /***/ }, /***/ 7579: /***/ function() { /* (ignored) */ /***/ }, /***/ 7326: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; function _assertThisInitialized(self1) { if (void 0 === self1) throw ReferenceError("this hasn't been initialised - super() hasn't been called"); return self1; } /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ _assertThisInitialized; } }); /***/ }, /***/ 8852: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function() { return /* binding */ _construct; } }); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js var setPrototypeOf = __webpack_require__(9611); // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js function _construct(Parent, args, Class) { return (_construct = !function() { if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0; } catch (e) { return !1; } } // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/construct.js () ? function(Parent, args, Class) { var a = [ null ]; a.push.apply(a, args); var instance = new (Function.bind.apply(Parent, a))(); return Class && (0, setPrototypeOf /* default */ .Z)(instance, Class.prototype), instance; } : Reflect.construct).apply(null, arguments); } /***/ }, /***/ 7462: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; function _extends() { return (_extends = Object.assign || function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ _extends; } }); /***/ }, /***/ 136: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ _inherits; } }); /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9611); function _inherits(subClass, superClass) { if ("function" != typeof superClass && null !== superClass) throw TypeError("Super expression must either be null or a function"); Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: !0, configurable: !0 } }), writable: !1 }), superClass && (0, _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */ .Z)(subClass, superClass); } /***/ }, /***/ 4578: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ _inheritsLoose; } }); /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9611); function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype), subClass.prototype.constructor = subClass, (0, _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ /* ["default"] */ .Z)(subClass, superClass); } /***/ }, /***/ 9611: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; function _setPrototypeOf(o, p) { return (_setPrototypeOf = Object.setPrototypeOf || function(o, p) { return o.__proto__ = p, o; })(o, p); } /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ _setPrototypeOf; } }); /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 544, 774, 888, 179 ], function() { return __webpack_require__(__webpack_require__.s = 8581); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33458/static/chunks/pages/no-spread-2db60295b526e113/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [492], { /***/ 5467: /***/ function ( __unused_webpack_module, __unused_webpack_exports, __webpack_require__ ) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/no-spread", function () { return __webpack_require__(1918); }, ]); if (false) { } /***/ }, /***/ 2726: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function () { return /* binding */ components_Form; }, }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // CONCATENATED MODULE: ./components/Input.js function Input(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)("input", { value: value, onChange: onChange, }); } /* harmony default export */ var components_Input = Input; // CONCATENATED MODULE: ./components/Form.js function Form(param) { var value = param.value, onChange = param.onChange; (0, react.useEffect)(function () { // If parent component spreads the props, // will cause remount on every re-render console.log("EFFECT"); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)(components_Input, { value: value, onChange: onChange, }); } /* harmony default export */ var components_Form = Form; /***/ }, /***/ 1918: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function () { return /* binding */ PageWithNoSpread; }, }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // EXTERNAL MODULE: ./components/Form.js + 1 modules var Form = __webpack_require__(2726); // CONCATENATED MODULE: ./components/NoSpread.js function ContainerNoSpread(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)( Form /* default */.Z, { value: value, onChange: onChange, } ); } /* harmony default export */ var NoSpread = ContainerNoSpread; // CONCATENATED MODULE: ./pages/no-spread.js function PageWithNoSpread() { var ref = (0, react.useState)(""), text = ref[0], setText = ref[1]; var handleChange = (0, react.useCallback)(function (e) { setText(e.target.value); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)(NoSpread, { onChange: handleChange, value: text, }); } /***/ }, }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__((__webpack_require__.s = moduleId)); }; /******/ __webpack_require__.O(0, [774, 888, 179], function () { return __webpack_exec__(5467); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ }, ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33458/static/chunks/pages/no-spread-2db60295b526e113/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 492 ], { /***/ 5467: /***/ function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/no-spread", function() { return __webpack_require__(1918); } ]); /***/ }, /***/ 2726: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function() { return /* binding */ components_Form; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), components_Input = function(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)("input", { value: value, onChange: onChange }); }, components_Form = function(param) { var value = param.value, onChange = param.onChange; return (0, react.useEffect)(function() { // If parent component spreads the props, // will cause remount on every re-render console.log("EFFECT"); }, []), /*#__PURE__*/ (0, jsx_runtime.jsx)(components_Input, { value: value, onChange: onChange }); }; /***/ }, /***/ 1918: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function() { return /* binding */ PageWithNoSpread; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), Form = __webpack_require__(2726), NoSpread = function(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)(Form /* default */ .Z, { value: value, onChange: onChange }); }; function PageWithNoSpread() { var ref = (0, react.useState)(""), text = ref[0], setText = ref[1], handleChange = (0, react.useCallback)(function(e) { setText(e.target.value); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)(NoSpread, { onChange: handleChange, value: text }); } /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 774, 888, 179 ], function() { return __webpack_require__(__webpack_require__.s = 5467); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33458/static/chunks/pages/spread-be872e60d968a0f7/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [217], { /***/ 2809: /***/ function ( __unused_webpack_module, __unused_webpack_exports, __webpack_require__ ) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/spread", function () { return __webpack_require__(1767); }, ]); if (false) { } /***/ }, /***/ 2726: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function () { return /* binding */ components_Form; }, }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // CONCATENATED MODULE: ./components/Input.js function Input(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)("input", { value: value, onChange: onChange, }); } /* harmony default export */ var components_Input = Input; // CONCATENATED MODULE: ./components/Form.js function Form(param) { var value = param.value, onChange = param.onChange; (0, react.useEffect)(function () { // If parent component spreads the props, // will cause remount on every re-render console.log("EFFECT"); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)(components_Input, { value: value, onChange: onChange, }); } /* harmony default export */ var components_Form = Form; /***/ }, /***/ 1767: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function () { return /* binding */ PageWithSpread; }, }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // EXTERNAL MODULE: ./components/Form.js + 1 modules var Form = __webpack_require__(2726); // CONCATENATED MODULE: ./components/Container.js function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true, }); } else { obj[key] = value; } return obj; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === "function") { ownKeys = ownKeys.concat( Object.getOwnPropertySymbols(source).filter( function (sym) { return Object.getOwnPropertyDescriptor( source, sym ).enumerable; } ) ); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function Container(props) { return /*#__PURE__*/ (0, jsx_runtime.jsx)( Form /* default */.Z, _objectSpread({}, props) ); } /* harmony default export */ var components_Container = Container; // CONCATENATED MODULE: ./pages/spread.js function PageWithSpread() { var ref = (0, react.useState)(""), text = ref[0], setText = ref[1]; var handleChange = (0, react.useCallback)(function (e) { setText(e.target.value); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)( components_Container, { onChange: handleChange, value: text, } ); } /***/ }, }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__((__webpack_require__.s = moduleId)); }; /******/ __webpack_require__.O(0, [774, 888, 179], function () { return __webpack_exec__(2809); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ }, ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/33458/static/chunks/pages/spread-be872e60d968a0f7/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 217 ], { /***/ 2809: /***/ function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/spread", function() { return __webpack_require__(1767); } ]); /***/ }, /***/ 2726: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { Z: function() { return /* binding */ components_Form; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), components_Input = function(param) { var value = param.value, onChange = param.onChange; return /*#__PURE__*/ (0, jsx_runtime.jsx)("input", { value: value, onChange: onChange }); }, components_Form = function(param) { var value = param.value, onChange = param.onChange; return (0, react.useEffect)(function() { // If parent component spreads the props, // will cause remount on every re-render console.log("EFFECT"); }, []), /*#__PURE__*/ (0, jsx_runtime.jsx)(components_Input, { value: value, onChange: onChange }); }; /***/ }, /***/ 1767: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function() { return /* binding */ PageWithSpread; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), Form = __webpack_require__(2726), components_Container = function(props) { return /*#__PURE__*/ (0, jsx_runtime.jsx)(Form /* default */ .Z, function(target) { for(var i = 1; i < arguments.length; i++){ var source = null != arguments[i] ? arguments[i] : {}, ownKeys = Object.keys(source); "function" == typeof Object.getOwnPropertySymbols && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; }))), ownKeys.forEach(function(key) { var value; value = source[key], key in target ? Object.defineProperty(target, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }) : target[key] = value; }); } return target; }({}, props)); }; function PageWithSpread() { var ref = (0, react.useState)(""), text = ref[0], setText = ref[1], handleChange = (0, react.useCallback)(function(e) { setText(e.target.value); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsx)(components_Container, { onChange: handleChange, value: text }); } /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 774, 888, 179 ], function() { return __webpack_require__(__webpack_require__.s = 2809); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/1/input.js
JavaScript
/** * Create a code check from a regex. * * @param {RegExp} regex * @returns {(code: Code) => code is number} */ export function regexCheck(regex) { return check; /** * Check whether a code matches the bound regex. * * @param {Code} code Character code * @returns {code is number} Whether the character code matches the bound regex */ function check(code) { return code !== null && regex.test(String.fromCharCode(code)); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/1/output.js
JavaScript
/** * Create a code check from a regex. * * @param {RegExp} regex * @returns {(code: Code) => code is number} */ export function regexCheck(regex) { return(/** * Check whether a code matches the bound regex. * * @param {Code} code Character code * @returns {code is number} Whether the character code matches the bound regex */ function(code) { return null !== code && regex.test(String.fromCharCode(code)); }); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/2/input.js
JavaScript
/** * Create a code check from a regex. * * @param {RegExp} regex * @returns {(code: Code) => code is number} */ function regexCheck(regex) { return check; /** * Check whether a code matches the bound regex. * * @param {Code} code Character code * @returns {code is number} Whether the character code matches the bound regex */ function check(code) { return code !== null && regex.test(String.fromCharCode(code)); } } console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo")); console.log(regexCheck("Foo"));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/2/output.js
JavaScript
/** * Create a code check from a regex. * * @param {RegExp} regex * @returns {(code: Code) => code is number} */ function regexCheck(regex) { return(/** * Check whether a code matches the bound regex. * * @param {Code} code Character code * @returns {code is number} Whether the character code matches the bound regex */ function(code) { return null !== code && regex.test(String.fromCharCode(code)); }); } console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo")), console.log(regexCheck("Foo"));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/3/input.js
JavaScript
/// The data structure for documents. @nonabstract export class Text { /// @internal constructor() { } /// Get the line description around the given position. lineAt(pos) { if (pos < 0 || pos > this.length) throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`); return this.lineInner(pos, false, 1, 0); } /// Get the description for the given (1-based) line number. line(n) { if (n < 1 || n > this.lines) throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`); return this.lineInner(n, true, 1, 0); } /// Replace a range of the text with the given content. replace(from, to, text) { let parts = []; this.decompose(0, from, parts, 2 /* Open.To */); if (text.length) text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */); this.decompose(to, this.length, parts, 1 /* Open.From */); return TextNode.from(parts, this.length - (to - from) + text.length); } /// Append another document to this one. append(other) { return this.replace(this.length, this.length, other); } /// Retrieve the text between the given points. slice(from, to = this.length) { let parts = []; this.decompose(from, to, parts, 0); return TextNode.from(parts, to - from); } /// Test whether this text is equal to another instance. eq(other) { if (other == this) return true; if (other.length != this.length || other.lines != this.lines) return false; let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1); let a = new RawTextCursor(this), b = new RawTextCursor(other); for (let skip = start, pos = start; ;) { a.next(skip); b.next(skip); skip = 0; if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value) return false; pos += a.value.length; if (a.done || pos >= end) return true; } } /// Iterate over the text. When `dir` is `-1`, iteration happens /// from end to start. This will return lines and the breaks between /// them as separate strings. iter(dir = 1) { return new RawTextCursor(this, dir); } /// Iterate over a range of the text. When `from` > `to`, the /// iterator will run in reverse. iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); } /// Return a cursor that iterates over the given range of lines, /// _without_ returning the line breaks between, and yielding empty /// strings for empty lines. /// /// When `from` and `to` are given, they should be 1-based line numbers. iterLines(from, to) { let inner; if (from == null) { inner = this.iter(); } else { if (to == null) to = this.lines + 1; let start = this.line(from).from; inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to)); } return new LineCursor(inner); } /// @internal toString() { return this.sliceString(0); } /// Convert the document to an array of lines (which can be /// deserialized again via [`Text.of`](#state.Text^of)). toJSON() { let lines = []; this.flatten(lines); return lines; } /// Create a `Text` instance for the given array of lines. static of(text) { if (text.length == 0) throw new RangeError("A document must have at least one line"); if (text.length == 1 && !text[0]) return Text.empty; return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, [])); } } Symbol.iterator; // Leaves store an array of line strings. There are always line breaks // between these strings. Leaves are limited in size and have to be // contained in TextNode instances for bigger documents. class TextLeaf extends Text { constructor(text, length = textLength(text)) { super(); this.text = text; this.length = length; } get lines() { return this.text.length; } get children() { return null; } lineInner(target, isLine, line, offset) { for (let i = 0; ; i++) { let string = this.text[i], end = offset + string.length; if ((isLine ? line : end) >= target) return new Line(offset, end, line, string); offset = end + 1; line++; } } decompose(from, to, target, open) { let text = from <= 0 && to >= this.length ? this : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from)); if (open & 1 /* Open.From */) { let prev = target.pop(); let joined = appendText(text.text, prev.text.slice(), 0, text.length); if (joined.length <= 32 /* Tree.Branch */) { target.push(new TextLeaf(joined, prev.length + text.length)); } else { let mid = joined.length >> 1; target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid))); } } else { target.push(text); } } replace(from, to, text) { if (!(text instanceof TextLeaf)) return super.replace(from, to, text); let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to); let newLen = this.length + text.length - (to - from); if (lines.length <= 32 /* Tree.Branch */) return new TextLeaf(lines, newLen); return TextNode.from(TextLeaf.split(lines, []), newLen); } sliceString(from, to = this.length, lineSep = "\n") { let result = ""; for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) { let line = this.text[i], end = pos + line.length; if (pos > from && i) result += lineSep; if (from < end && to > pos) result += line.slice(Math.max(0, from - pos), to - pos); pos = end + 1; } return result; } flatten(target) { for (let line of this.text) target.push(line); } scanIdentical() { return 0; } static split(text, target) { let part = [], len = -1; for (let line of text) { part.push(line); len += line.length + 1; if (part.length == 32 /* Tree.Branch */) { target.push(new TextLeaf(part, len)); part = []; len = -1; } } if (len > -1) target.push(new TextLeaf(part, len)); return target; } } // Nodes provide the tree structure of the `Text` type. They store a // number of other nodes or leaves, taking care to balance themselves // on changes. There are implied line breaks _between_ the children of // a node (but not before the first or after the last child). class TextNode extends Text { constructor(children, length) { super(); this.children = children; this.length = length; this.lines = 0; for (let child of children) this.lines += child.lines; } lineInner(target, isLine, line, offset) { for (let i = 0; ; i++) { let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1; if ((isLine ? endLine : end) >= target) return child.lineInner(target, isLine, line, offset); offset = end + 1; line = endLine + 1; } } decompose(from, to, target, open) { for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) { let child = this.children[i], end = pos + child.length; if (from <= end && to >= pos) { let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0)); if (pos >= from && end <= to && !childOpen) target.push(child); else child.decompose(from - pos, to - pos, target, childOpen); } pos = end + 1; } } replace(from, to, text) { if (text.lines < this.lines) for (let i = 0, pos = 0; i < this.children.length; i++) { let child = this.children[i], end = pos + child.length; // Fast path: if the change only affects one child and the // child's size remains in the acceptable range, only update // that child if (from >= pos && to <= end) { let updated = child.replace(from - pos, to - pos, text); let totalLines = this.lines - child.lines + updated.lines; if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) && updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) { let copy = this.children.slice(); copy[i] = updated; return new TextNode(copy, this.length - (to - from) + text.length); } return super.replace(pos, end, updated); } pos = end + 1; } return super.replace(from, to, text); } sliceString(from, to = this.length, lineSep = "\n") { let result = ""; for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) { let child = this.children[i], end = pos + child.length; if (pos > from && i) result += lineSep; if (from < end && to > pos) result += child.sliceString(from - pos, to - pos, lineSep); pos = end + 1; } return result; } flatten(target) { for (let child of this.children) child.flatten(target); } scanIdentical(other, dir) { if (!(other instanceof TextNode)) return 0; let length = 0; let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length] : [this.children.length - 1, other.children.length - 1, -1, -1]; for (; ; iA += dir, iB += dir) { if (iA == eA || iB == eB) return length; let chA = this.children[iA], chB = other.children[iB]; if (chA != chB) return length + chA.scanIdentical(chB, dir); length += chA.length + 1; } } static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) { let lines = 0; for (let ch of children) lines += ch.lines; if (lines < 32 /* Tree.Branch */) { let flat = []; for (let ch of children) ch.flatten(flat); return new TextLeaf(flat, length); } let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1; let chunked = [], currentLines = 0, currentLen = -1, currentChunk = []; function add(child) { let last; if (child.lines > maxChunk && child instanceof TextNode) { for (let node of child.children) add(node); } else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) { flush(); chunked.push(child); } else if (child instanceof TextLeaf && currentLines && (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf && child.lines + last.lines <= 32 /* Tree.Branch */) { currentLines += child.lines; currentLen += child.length + 1; currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length); } else { if (currentLines + child.lines > chunk) flush(); currentLines += child.lines; currentLen += child.length + 1; currentChunk.push(child); } } function flush() { if (currentLines == 0) return; chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen)); currentLen = -1; currentLines = currentChunk.length = 0; } for (let child of children) add(child); flush(); return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length); } } Text.empty = new TextLeaf([""], 0); function textLength(text) { let length = -1; for (let line of text) length += line.length + 1; return length; } function appendText(text, target, from = 0, to = 1e9) { for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) { let line = text[i], end = pos + line.length; if (end >= from) { if (end > to) line = line.slice(0, to - pos); if (pos < from) line = line.slice(from - pos); if (first) { target[target.length - 1] += line; first = false; } else target.push(line); } pos = end + 1; } return target; } function sliceText(text, from, to) { return appendText(text, [""], from, to); } class RawTextCursor { constructor(text, dir = 1) { this.dir = dir; this.done = false; this.lineBreak = false; this.value = ""; this.nodes = [text]; this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1]; } nextInner(skip, dir) { this.done = this.lineBreak = false; for (; ;) { let last = this.nodes.length - 1; let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1; let size = top instanceof TextLeaf ? top.text.length : top.children.length; if (offset == (dir > 0 ? size : 0)) { if (last == 0) { this.done = true; this.value = ""; return this; } if (dir > 0) this.offsets[last - 1]++; this.nodes.pop(); this.offsets.pop(); } else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) { this.offsets[last] += dir; if (skip == 0) { this.lineBreak = true; this.value = "\n"; return this; } skip--; } else if (top instanceof TextLeaf) { // Move to the next string let next = top.text[offset + (dir < 0 ? -1 : 0)]; this.offsets[last] += dir; if (next.length > Math.max(0, skip)) { this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip); return this; } skip -= next.length; } else { let next = top.children[offset + (dir < 0 ? -1 : 0)]; if (skip > next.length) { skip -= next.length; this.offsets[last] += dir; } else { if (dir < 0) this.offsets[last]--; this.nodes.push(next); this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1); } } } } next(skip = 0) { if (skip < 0) { this.nextInner(-skip, (-this.dir)); skip = this.value.length; } return this.nextInner(skip, this.dir); } } Symbol.iterator; class PartialTextCursor { constructor(text, start, end) { this.value = ""; this.done = false; this.cursor = new RawTextCursor(text, start > end ? -1 : 1); this.pos = start > end ? text.length : 0; this.from = Math.min(start, end); this.to = Math.max(start, end); } nextInner(skip, dir) { if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) { this.value = ""; this.done = true; return this; } skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos); let limit = dir < 0 ? this.pos - this.from : this.to - this.pos; if (skip > limit) skip = limit; limit -= skip; let { value } = this.cursor.next(skip); this.pos += (value.length + skip) * dir; this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit); this.done = !this.value; return this; } next(skip = 0) { if (skip < 0) skip = Math.max(skip, this.from - this.pos); else if (skip > 0) skip = Math.min(skip, this.to - this.pos); return this.nextInner(skip, this.cursor.dir); } get lineBreak() { return this.cursor.lineBreak && this.value != ""; } } Symbol.iterator; class LineCursor { constructor(inner) { this.inner = inner; this.afterBreak = true; this.value = ""; this.done = false; } next(skip = 0) { let { done, lineBreak, value } = this.inner.next(skip); if (done) { this.done = true; this.value = ""; } else if (lineBreak) { if (this.afterBreak) { this.value = ""; } else { this.afterBreak = true; this.next(); } } else { this.value = value; this.afterBreak = false; } return this; } get lineBreak() { return false; } } Symbol.iterator; if (typeof Symbol != "undefined") { Text.prototype[Symbol.iterator] = function () { return this.iter(); }; RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] = LineCursor.prototype[Symbol.iterator] = function () { return this; }; } /// This type describes a line in the document. It is created /// on-demand when lines are [queried](#state.Text.lineAt). export class Line { /// @internal constructor( /// The position of the start of the line. from, /// The position at the end of the line (_before_ the line break, /// or at the end of document for the last line). to, /// This line's line number (1-based). number, /// The line's content. text) { this.from = from; this.to = to; this.number = number; this.text = text; } /// The length of the line (not including any line break after it). get length() { return this.to - this.from; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/36127/2/3/output.js
JavaScript
/// The data structure for documents. @nonabstract export class Text { /// @internal constructor(){} /// Get the line description around the given position. lineAt(t) { if (t < 0 || t > this.length) throw RangeError(`Invalid position ${t} in document of length ${this.length}`); return this.lineInner(t, !1, 1, 0); } /// Get the description for the given (1-based) line number. line(t) { if (t < 1 || t > this.lines) throw RangeError(`Invalid line number ${t} in ${this.lines}-line document`); return this.lineInner(t, !0, 1, 0); } /// Replace a range of the text with the given content. replace(t, n, i) { let s = []; return this.decompose(0, t, s, 2 /* Open.To */ ), i.length && i.decompose(0, i.length, s, 3 /* Open.To */ ), this.decompose(n, this.length, s, 1 /* Open.From */ ), e.from(s, this.length - (n - t) + i.length); } /// Append another document to this one. append(t) { return this.replace(this.length, this.length, t); } /// Retrieve the text between the given points. slice(t, n = this.length) { let i = []; return this.decompose(t, n, i, 0), e.from(i, n - t); } /// Test whether this text is equal to another instance. eq(t) { if (t == this) return !0; if (t.length != this.length || t.lines != this.lines) return !1; let e = this.scanIdentical(t, 1), n = this.length - this.scanIdentical(t, -1), s = new i(this), h = new i(t); for(let t = e, i = e;;){ if (s.next(t), h.next(t), t = 0, s.lineBreak != h.lineBreak || s.done != h.done || s.value != h.value) return !1; if (i += s.value.length, s.done || i >= n) return !0; } } /// Iterate over the text. When `dir` is `-1`, iteration happens /// from end to start. This will return lines and the breaks between /// them as separate strings. iter(t = 1) { return new i(this, t); } /// Iterate over a range of the text. When `from` > `to`, the /// iterator will run in reverse. iterRange(t, e = this.length) { return new s(this, t, e); } /// Return a cursor that iterates over the given range of lines, /// _without_ returning the line breaks between, and yielding empty /// strings for empty lines. /// /// When `from` and `to` are given, they should be 1-based line numbers. iterLines(t, e) { let n; if (null == t) n = this.iter(); else { null == e && (e = this.lines + 1); let i = this.line(t).from; n = this.iterRange(i, Math.max(i, e == this.lines + 1 ? this.length : e <= 1 ? 0 : this.line(e - 1).to)); } return new h(n); } /// @internal toString() { return this.sliceString(0); } /// Convert the document to an array of lines (which can be /// deserialized again via [`Text.of`](#state.Text^of)). toJSON() { let t = []; return this.flatten(t), t; } /// Create a `Text` instance for the given array of lines. static of(n) { if (0 == n.length) throw RangeError("A document must have at least one line"); return 1 != n.length || n[0] ? n.length <= 32 /* Tree.Branch */ ? new t(n) : e.from(t.split(n, [])) : Text.empty; } } // Leaves store an array of line strings. There are always line breaks // between these strings. Leaves are limited in size and have to be // contained in TextNode instances for bigger documents. class t extends Text { constructor(t, e = function(t) { let e = -1; for (let n of t)e += n.length + 1; return e; }(t)){ super(), this.text = t, this.length = e; } get lines() { return this.text.length; } get children() { return null; } lineInner(t, e, n, i) { for(let s = 0;; s++){ let h = this.text[s], l = i + h.length; if ((e ? n : l) >= t) return new Line(i, l, n, h); i = l + 1, n++; } } decompose(e, i, s, h) { let l = e <= 0 && i >= this.length ? this : new t(n(this.text, [ "" ], e, i), Math.min(i, this.length) - Math.max(0, e)); if (1 /* Open.From */ & h) { let e = s.pop(), i = n(l.text, e.text.slice(), 0, l.length); if (i.length <= 32 /* Tree.Branch */ ) s.push(new t(i, e.length + l.length)); else { let e = i.length >> 1; s.push(new t(i.slice(0, e)), new t(i.slice(e))); } } else s.push(l); } replace(i, s, h) { if (!(h instanceof t)) return super.replace(i, s, h); let l = n(this.text, n(h.text, n(this.text, [ "" ], 0, i)), s), r = this.length + h.length - (s - i); return l.length <= 32 /* Tree.Branch */ ? new t(l, r) : e.from(t.split(l, []), r); } sliceString(t, e = this.length, n = "\n") { let i = ""; for(let s = 0, h = 0; s <= e && h < this.text.length; h++){ let l = this.text[h], r = s + l.length; s > t && h && (i += n), t < r && e > s && (i += l.slice(Math.max(0, t - s), e - s)), s = r + 1; } return i; } flatten(t) { for (let e of this.text)t.push(e); } scanIdentical() { return 0; } static split(e, n) { let i = [], s = -1; for (let h of e)i.push(h), s += h.length + 1, 32 /* Tree.Branch */ == i.length && (n.push(new t(i, s)), i = [], s = -1); return s > -1 && n.push(new t(i, s)), n; } } // Nodes provide the tree structure of the `Text` type. They store a // number of other nodes or leaves, taking care to balance themselves // on changes. There are implied line breaks _between_ the children of // a node (but not before the first or after the last child). class e extends Text { constructor(t, e){ for (let n of (super(), this.children = t, this.length = e, this.lines = 0, t))this.lines += n.lines; } lineInner(t, e, n, i) { for(let s = 0;; s++){ let h = this.children[s], l = i + h.length, r = n + h.lines - 1; if ((e ? r : l) >= t) return h.lineInner(t, e, n, i); i = l + 1, n = r + 1; } } decompose(t, e, n, i) { for(let s = 0, h = 0; h <= e && s < this.children.length; s++){ let l = this.children[s], r = h + l.length; if (t <= r && e >= h) { let s = i & (+(h <= t) | 2 /* Open.To */ * (r >= e)); h >= t && r <= e && !s ? n.push(l) : l.decompose(t - h, e - h, n, s); } h = r + 1; } } replace(t, n, i) { if (i.lines < this.lines) for(let s = 0, h = 0; s < this.children.length; s++){ let l = this.children[s], r = h + l.length; // Fast path: if the change only affects one child and the // child's size remains in the acceptable range, only update // that child if (t >= h && n <= r) { let o = l.replace(t - h, n - h, i), f = this.lines - l.lines + o.lines; if (o.lines < f >> 4 && o.lines > f >> 6) { let h = this.children.slice(); return h[s] = o, new e(h, this.length - (n - t) + i.length); } return super.replace(h, r, o); } h = r + 1; } return super.replace(t, n, i); } sliceString(t, e = this.length, n = "\n") { let i = ""; for(let s = 0, h = 0; s < this.children.length && h <= e; s++){ let l = this.children[s], r = h + l.length; h > t && s && (i += n), t < r && e > h && (i += l.sliceString(t - h, e - h, n)), h = r + 1; } return i; } flatten(t) { for (let e of this.children)e.flatten(t); } scanIdentical(t, n) { if (!(t instanceof e)) return 0; let i = 0, [s, h, l, r] = n > 0 ? [ 0, 0, this.children.length, t.children.length ] : [ this.children.length - 1, t.children.length - 1, -1, -1 ]; for(;; s += n, h += n){ if (s == l || h == r) return i; let e = this.children[s], o = t.children[h]; if (e != o) return i + e.scanIdentical(o, n); i += e.length + 1; } } static from(n, i = n.reduce((t, e)=>t + e.length + 1, -1)) { let s = 0; for (let t of n)s += t.lines; if (s < 32 /* Tree.Branch */ ) { let e = []; for (let t of n)t.flatten(e); return new t(e, i); } let h = Math.max(32 /* Tree.Branch */ , s >> 5 /* Tree.BranchShift */ ), l = h << 1, r = h >> 1, o = [], f = 0, c = -1, u = []; function a() { 0 != f && (o.push(1 == u.length ? u[0] : e.from(u, c)), c = -1, f = u.length = 0); } for (let i of n)!function n(i) { let s; if (i.lines > l && i instanceof e) for (let t of i.children)n(t); else i.lines > r && (f > r || !f) ? (a(), o.push(i)) : i instanceof t && f && (s = u[u.length - 1]) instanceof t && i.lines + s.lines <= 32 /* Tree.Branch */ ? (f += i.lines, c += i.length + 1, u[u.length - 1] = new t(s.text.concat(i.text), s.length + 1 + i.length)) : (f + i.lines > h && a(), f += i.lines, c += i.length + 1, u.push(i)); }(i); return a(), 1 == o.length ? o[0] : new e(o, i); } } function n(t, e, i = 0, s = 1e9) { for(let n = 0, h = 0, l = !0; h < t.length && n <= s; h++){ let r = t[h], o = n + r.length; o >= i && (o > s && (r = r.slice(0, s - n)), n < i && (r = r.slice(i - n)), l ? (e[e.length - 1] += r, l = !1) : e.push(r)), n = o + 1; } return e; } Text.empty = new t([ "" ], 0); class i { constructor(e, n = 1){ this.dir = n, this.done = !1, this.lineBreak = !1, this.value = "", this.nodes = [ e ], this.offsets = [ n > 0 ? 1 : (e instanceof t ? e.text.length : e.children.length) << 1 ]; } nextInner(e, n) { for(this.done = this.lineBreak = !1;;){ let i = this.nodes.length - 1, s = this.nodes[i], h = this.offsets[i], l = h >> 1, r = s instanceof t ? s.text.length : s.children.length; if (l == (n > 0 ? r : 0)) { if (0 == i) return this.done = !0, this.value = "", this; n > 0 && this.offsets[i - 1]++, this.nodes.pop(), this.offsets.pop(); } else if ((1 & h) == (n > 0 ? 0 : 1)) { if (this.offsets[i] += n, 0 == e) return this.lineBreak = !0, this.value = "\n", this; e--; } else if (s instanceof t) { // Move to the next string let t = s.text[l + (n < 0 ? -1 : 0)]; if (this.offsets[i] += n, t.length > Math.max(0, e)) return this.value = 0 == e ? t : n > 0 ? t.slice(e) : t.slice(0, t.length - e), this; e -= t.length; } else { let h = s.children[l + (n < 0 ? -1 : 0)]; e > h.length ? (e -= h.length, this.offsets[i] += n) : (n < 0 && this.offsets[i]--, this.nodes.push(h), this.offsets.push(n > 0 ? 1 : (h instanceof t ? h.text.length : h.children.length) << 1)); } } } next(t = 0) { return t < 0 && (this.nextInner(-t, -this.dir), t = this.value.length), this.nextInner(t, this.dir); } } class s { constructor(t, e, n){ this.value = "", this.done = !1, this.cursor = new i(t, e > n ? -1 : 1), this.pos = e > n ? t.length : 0, this.from = Math.min(e, n), this.to = Math.max(e, n); } nextInner(t, e) { if (e < 0 ? this.pos <= this.from : this.pos >= this.to) return this.value = "", this.done = !0, this; t += Math.max(0, e < 0 ? this.pos - this.to : this.from - this.pos); let n = e < 0 ? this.pos - this.from : this.to - this.pos; t > n && (t = n), n -= t; let { value: i } = this.cursor.next(t); return this.pos += (i.length + t) * e, this.value = i.length <= n ? i : e < 0 ? i.slice(i.length - n) : i.slice(0, n), this.done = !this.value, this; } next(t = 0) { return t < 0 ? t = Math.max(t, this.from - this.pos) : t > 0 && (t = Math.min(t, this.to - this.pos)), this.nextInner(t, this.cursor.dir); } get lineBreak() { return this.cursor.lineBreak && "" != this.value; } } class h { constructor(t){ this.inner = t, this.afterBreak = !0, this.value = "", this.done = !1; } next(t = 0) { let { done: e, lineBreak: n, value: i } = this.inner.next(t); return e ? (this.done = !0, this.value = "") : n ? this.afterBreak ? this.value = "" : (this.afterBreak = !0, this.next()) : (this.value = i, this.afterBreak = !1), this; } get lineBreak() { return !1; } } "undefined" != typeof Symbol && (Text.prototype[Symbol.iterator] = function() { return this.iter(); }, i.prototype[Symbol.iterator] = s.prototype[Symbol.iterator] = h.prototype[Symbol.iterator] = function() { return this; }); /// This type describes a line in the document. It is created /// on-demand when lines are [queried](#state.Text.lineAt). export class Line { /// @internal constructor(/// The position of the start of the line. t, /// The position at the end of the line (_before_ the line break, /// or at the end of document for the last line). e, /// This line's line number (1-based). n, /// The line's content. i){ this.from = t, this.to = e, this.number = n, this.text = i; } /// The length of the line (not including any line break after it). get length() { return this.to - this.from; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/39538/static/chunks/pages/index-1bd068cedc2b5af3/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[405], { /***/ 1412: /***/ (function (__unused_webpack_module, exports) { "use strict"; var __webpack_unused_export__; __webpack_unused_export__ = ({ value: true }); exports.Z = _defineProperty; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /***/ }), /***/ 5702: /***/ (function (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/", function () { return __webpack_require__(1107); } ]); if (false) { } /***/ }), /***/ 9838: /***/ (function (module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); var _defineProperty = (__webpack_require__(1412)/* ["default"] */.Z); var _slicedToArray = (__webpack_require__(8693)/* ["default"] */.Z); var _toConsumableArray = (__webpack_require__(9947)/* ["default"] */.Z); Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = Image; var _extends = (__webpack_require__(2769)/* ["default"] */.Z); var _interop_require_default = (__webpack_require__(4507)/* ["default"] */.Z); var _interop_require_wildcard = (__webpack_require__(8167)/* ["default"] */.Z); var _object_without_properties_loose = (__webpack_require__(4719)/* ["default"] */.Z); var _react = _interop_require_wildcard(__webpack_require__(959)); var _head = _interop_require_default(__webpack_require__(4357)); var _imageConfig = __webpack_require__(1773); var _useIntersection = __webpack_require__(757); var _imageConfigContext = __webpack_require__(9664); var _utils = __webpack_require__(8827); var _normalizeTrailingSlash = __webpack_require__(8236); function Image(_param) { var src = _param.src, sizes = _param.sizes, _unoptimized = _param.unoptimized, unoptimized = _unoptimized === void 0 ? false : _unoptimized, _priority = _param.priority, priority = _priority === void 0 ? false : _priority, loading = _param.loading, _lazyRoot = _param.lazyRoot, lazyRoot = _lazyRoot === void 0 ? null : _lazyRoot, lazyBoundary = _param.lazyBoundary, className = _param.className, quality = _param.quality, width = _param.width, height = _param.height, style = _param.style, objectFit = _param.objectFit, objectPosition = _param.objectPosition, onLoadingComplete = _param.onLoadingComplete, _placeholder = _param.placeholder, placeholder = _placeholder === void 0 ? "empty" : _placeholder, blurDataURL = _param.blurDataURL, all = _object_without_properties_loose(_param, [ "src", "sizes", "unoptimized", "priority", "loading", "lazyRoot", "lazyBoundary", "className", "quality", "width", "height", "style", "objectFit", "objectPosition", "onLoadingComplete", "placeholder", "blurDataURL" ]); var configContext = (0, _react).useContext(_imageConfigContext.ImageConfigContext); var config = (0, _react).useMemo(function () { var c = configEnv || configContext || _imageConfig.imageConfigDefault; var allSizes = _toConsumableArray(c.deviceSizes).concat(_toConsumableArray(c.imageSizes)).sort(function (a, b) { return a - b; }); var deviceSizes = c.deviceSizes.sort(function (a, b) { return a - b; }); return _extends({}, c, { allSizes: allSizes, deviceSizes: deviceSizes }); }, [ configContext ]); var rest = all; var layout = sizes ? "responsive" : "intrinsic"; if ("layout" in rest) { // Override default layout if the user specified one: if (rest.layout) layout = rest.layout; // Remove property so it's not spread on <img>: delete rest.layout; } var loader = defaultImageLoader; if ("loader" in rest) { if (rest.loader) { var customImageLoader = rest.loader; var _tmp; _tmp = function (obj) { var _ = obj.config, opts = _object_without_properties_loose(obj, [ "config" ]); // The config object is internal only so we must // not pass it to the user-defined loader() return customImageLoader(opts); }, loader = _tmp, _tmp; } // Remove property so it's not spread on <img> delete rest.loader; } var staticSrc = ""; if (isStaticImport(src)) { var staticImageData = isStaticRequire(src) ? src.default : src; if (!staticImageData.src) { throw new Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ".concat(JSON.stringify(staticImageData))); } blurDataURL = blurDataURL || staticImageData.blurDataURL; staticSrc = staticImageData.src; if (!layout || layout !== "fill") { height = height || staticImageData.height; width = width || staticImageData.width; if (!staticImageData.height || !staticImageData.width) { throw new Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ".concat(JSON.stringify(staticImageData))); } } } src = typeof src === "string" ? src : staticSrc; var isLazy = !priority && (loading === "lazy" || typeof loading === "undefined"); if (src.startsWith("data:") || src.startsWith("blob:")) { // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs unoptimized = true; isLazy = false; } if (true && loadedImageURLs.has(src)) { isLazy = false; } if (experimentalUnoptimized) { unoptimized = true; } var ref = _slicedToArray((0, _react).useState(false), 2), blurComplete = ref[0], setBlurComplete = ref[1]; var ref1 = _slicedToArray((0, _useIntersection).useIntersection({ rootRef: lazyRoot, rootMargin: lazyBoundary || "200px", disabled: !isLazy }), 3), setIntersection = ref1[0], isIntersected = ref1[1], resetIntersected = ref1[2]; var isVisible = !isLazy || isIntersected; var wrapperStyle = { boxSizing: "border-box", display: "block", overflow: "hidden", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }; var sizerStyle = { boxSizing: "border-box", display: "block", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }; var hasSizer = false; var sizerSvgUrl; var layoutStyle = { position: "absolute", top: 0, left: 0, bottom: 0, right: 0, boxSizing: "border-box", padding: 0, border: "none", margin: "auto", display: "block", width: 0, height: 0, minWidth: "100%", maxWidth: "100%", minHeight: "100%", maxHeight: "100%", objectFit: objectFit, objectPosition: objectPosition }; var widthInt = getInt(width); var heightInt = getInt(height); var qualityInt = getInt(quality); if (false) { var overwrittenStyles, url, urlStr, VALID_BLUR_EXT; } var imgStyle = Object.assign({}, style, layoutStyle); var blurStyle = placeholder === "blur" && !blurComplete ? { backgroundSize: objectFit || "cover", backgroundPosition: objectPosition || "0% 0%", filter: "blur(20px)", backgroundImage: 'url("'.concat(blurDataURL, '")') } : {}; if (layout === "fill") { // <Image src="i.png" layout="fill" /> wrapperStyle.display = "block"; wrapperStyle.position = "absolute"; wrapperStyle.top = 0; wrapperStyle.left = 0; wrapperStyle.bottom = 0; wrapperStyle.right = 0; } else if (typeof widthInt !== "undefined" && typeof heightInt !== "undefined") { // <Image src="i.png" width="100" height="100" /> var quotient = heightInt / widthInt; var paddingTop = isNaN(quotient) ? "100%" : "".concat(quotient * 100, "%"); if (layout === "responsive") { // <Image src="i.png" width="100" height="100" layout="responsive" /> wrapperStyle.display = "block"; wrapperStyle.position = "relative"; hasSizer = true; sizerStyle.paddingTop = paddingTop; } else if (layout === "intrinsic") { // <Image src="i.png" width="100" height="100" layout="intrinsic" /> wrapperStyle.display = "inline-block"; wrapperStyle.position = "relative"; wrapperStyle.maxWidth = "100%"; hasSizer = true; sizerStyle.maxWidth = "100%"; sizerSvgUrl = "data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27".concat(widthInt, "%27%20height=%27").concat(heightInt, "%27/%3e"); } else if (layout === "fixed") { // <Image src="i.png" width="100" height="100" layout="fixed" /> wrapperStyle.display = "inline-block"; wrapperStyle.position = "relative"; wrapperStyle.width = widthInt; wrapperStyle.height = heightInt; } } else { // <Image src="i.png" /> if (false) { } } var imgAttributes = { src: emptyDataURL, srcSet: undefined, sizes: undefined }; if (isVisible) { imgAttributes = generateImgAttrs({ config: config, src: src, unoptimized: unoptimized, layout: layout, width: widthInt, quality: qualityInt, sizes: sizes, loader: loader }); } var srcString = src; if (false) { var fullUrl; } var imageSrcSetPropName = "imagesrcset"; var imageSizesPropName = "imagesizes"; if (true) { imageSrcSetPropName = "imageSrcSet"; imageSizesPropName = "imageSizes"; } var _obj; var linkProps = (_obj = {}, // Note: imagesrcset and imagesizes are not in the link element type with react 17. _defineProperty(_obj, imageSrcSetPropName, imgAttributes.srcSet), _defineProperty(_obj, imageSizesPropName, imgAttributes.sizes), _obj); var useLayoutEffect = false ? 0 : _react.default.useLayoutEffect; var onLoadingCompleteRef = (0, _react).useRef(onLoadingComplete); var previousImageSrc = (0, _react).useRef(src); (0, _react).useEffect(function () { onLoadingCompleteRef.current = onLoadingComplete; }, [ onLoadingComplete ]); useLayoutEffect(function () { if (previousImageSrc.current !== src) { resetIntersected(); previousImageSrc.current = src; } }, [ resetIntersected, src ]); var imgElementArgs = _extends({ isLazy: isLazy, imgAttributes: imgAttributes, heightInt: heightInt, widthInt: widthInt, qualityInt: qualityInt, layout: layout, className: className, imgStyle: imgStyle, blurStyle: blurStyle, loading: loading, config: config, unoptimized: unoptimized, placeholder: placeholder, loader: loader, srcString: srcString, onLoadingCompleteRef: onLoadingCompleteRef, setBlurComplete: setBlurComplete, setIntersection: setIntersection, isVisible: isVisible, noscriptSizes: sizes }, rest); return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement("span", { style: wrapperStyle }, hasSizer ? /*#__PURE__*/ _react.default.createElement("span", { style: sizerStyle }, sizerSvgUrl ? /*#__PURE__*/ _react.default.createElement("img", { style: { display: "block", maxWidth: "100%", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }, alt: "", "aria-hidden": true, src: sizerSvgUrl }) : null) : null, /*#__PURE__*/ _react.default.createElement(ImageElement, Object.assign({}, imgElementArgs))), priority ? // for browsers that do not support `imagesrcset`, and in those cases // it would likely cause the incorrect image to be preloaded. // // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-imagesrcset /*#__PURE__*/ _react.default.createElement(_head.default, null, /*#__PURE__*/ _react.default.createElement("link", Object.assign({ key: "__nimg-" + imgAttributes.src + imgAttributes.srcSet + imgAttributes.sizes, rel: "preload", as: "image", href: imgAttributes.srcSet ? undefined : imgAttributes.src }, linkProps))) : null); } var ref = { "deviceSizes": [640, 750, 828, 1080, 1200, 1920, 2048, 3840], "imageSizes": [16, 32, 48, 64, 96, 128, 256, 384], "path": "/_next/image", "loader": "default", "dangerouslyAllowSVG": false } || {}, _experimentalRemotePatterns = ref.experimentalRemotePatterns, experimentalRemotePatterns = _experimentalRemotePatterns === void 0 ? [] : _experimentalRemotePatterns, experimentalUnoptimized = ref.experimentalUnoptimized; var configEnv = { "deviceSizes": [640, 750, 828, 1080, 1200, 1920, 2048, 3840], "imageSizes": [16, 32, 48, 64, 96, 128, 256, 384], "path": "/_next/image", "loader": "default", "dangerouslyAllowSVG": false }; var loadedImageURLs = new Set(); var allImgs = new Map(); var perfObserver; var emptyDataURL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"; if (false) { } var VALID_LOADING_VALUES = (/* unused pure expression or super */ null && ([ "lazy", "eager", undefined ])); var loaders = new Map([ [ "default", defaultLoader ], [ "imgix", imgixLoader ], [ "cloudinary", cloudinaryLoader ], [ "akamai", akamaiLoader ], [ "custom", customLoader ], ]); var VALID_LAYOUT_VALUES = (/* unused pure expression or super */ null && ([ "fill", "fixed", "intrinsic", "responsive", undefined, ])); function isStaticRequire(src) { return src.default !== undefined; } function isStaticImageData(src) { return src.src !== undefined; } function isStaticImport(src) { return typeof src === "object" && (isStaticRequire(src) || isStaticImageData(src)); } function getWidths(param, width, layout, sizes) { var deviceSizes = param.deviceSizes, allSizes = param.allSizes; if (sizes && (layout === "fill" || layout === "responsive")) { // Find all the "vw" percent sizes used in the sizes prop var viewportWidthRe = /(^|\s)(1?\d?\d)vw/g; var percentSizes = []; for (var match; match = viewportWidthRe.exec(sizes); match) { percentSizes.push(parseInt(match[2])); } if (percentSizes.length) { var _Math; var smallestRatio = (_Math = Math).min.apply(_Math, _toConsumableArray(percentSizes)) * 0.01; return { widths: allSizes.filter(function (s) { return s >= deviceSizes[0] * smallestRatio; }), kind: "w" }; } return { widths: allSizes, kind: "w" }; } if (typeof width !== "number" || layout === "fill" || layout === "responsive") { return { widths: deviceSizes, kind: "w" }; } var widths = _toConsumableArray(new Set(// > are actually 3x in the green color, but only 1.5x in the red and // > blue colors. Showing a 3x resolution image in the app vs a 2x // > resolution image will be visually the same, though the 3x image // > takes significantly more data. Even true 3x resolution screens are // > wasteful as the human eye cannot see that level of detail without // > something like a magnifying glass. // https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html [ width, width * 2 /*, width * 3*/ ].map(function (w) { return allSizes.find(function (p) { return p >= w; }) || allSizes[allSizes.length - 1]; }))); return { widths: widths, kind: "x" }; } function generateImgAttrs(param) { var config = param.config, src = param.src, unoptimized = param.unoptimized, layout = param.layout, width = param.width, quality = param.quality, sizes = param.sizes, loader = param.loader; if (unoptimized) { return { src: src, srcSet: undefined, sizes: undefined }; } var ref = getWidths(config, width, layout, sizes), widths = ref.widths, kind = ref.kind; var last = widths.length - 1; return { sizes: !sizes && kind === "w" ? "100vw" : sizes, srcSet: widths.map(function (w, i) { return "".concat(loader({ config: config, src: src, quality: quality, width: w }), " ").concat(kind === "w" ? w : i + 1).concat(kind); }).join(", "), // It's intended to keep `src` the last attribute because React updates // attributes in order. If we keep `src` the first one, Safari will // immediately start to fetch `src`, before `sizes` and `srcSet` are even // updated by React. That causes multiple unnecessary requests if `srcSet` // and `sizes` are defined. // This bug cannot be reproduced in Chrome or Firefox. src: loader({ config: config, src: src, quality: quality, width: widths[last] }) }; } function getInt(x) { if (typeof x === "number") { return x; } if (typeof x === "string") { return parseInt(x, 10); } return undefined; } function defaultImageLoader(loaderProps) { var ref; var loaderKey = ((ref = loaderProps.config) == null ? void 0 : ref.loader) || "default"; var load = loaders.get(loaderKey); if (load) { return load(loaderProps); } throw new Error('Unknown "loader" found in "next.config.js". Expected: '.concat(_imageConfig.VALID_LOADERS.join(", "), ". Received: ").concat(loaderKey)); } // See https://stackoverflow.com/q/39777833/266535 for why we use this ref // handler instead of the img's onLoad attribute. function handleLoading(img, src, layout, placeholder, onLoadingCompleteRef, setBlurComplete) { if (!img || img.src === emptyDataURL || img["data-loaded-src"] === src) { return; } img["data-loaded-src"] = src; var p = "decode" in img ? img.decode() : Promise.resolve(); p.catch(function () { }).then(function () { if (!img.parentNode) { // Exit early in case of race condition: // - onload() is called // - decode() is called but incomplete // - unmount is called // - decode() completes return; } loadedImageURLs.add(src); if (placeholder === "blur") { setBlurComplete(true); } if (onLoadingCompleteRef == null ? void 0 : onLoadingCompleteRef.current) { var naturalWidth = img.naturalWidth, naturalHeight = img.naturalHeight; // Pass back read-only primitive values but not the // underlying DOM element because it could be misused. onLoadingCompleteRef.current({ naturalWidth: naturalWidth, naturalHeight: naturalHeight }); } if (false) { var parent, ref; } }); } var ImageElement = function (_param) { var imgAttributes = _param.imgAttributes, heightInt = _param.heightInt, widthInt = _param.widthInt, qualityInt = _param.qualityInt, layout = _param.layout, className = _param.className, imgStyle = _param.imgStyle, blurStyle = _param.blurStyle, isLazy = _param.isLazy, placeholder = _param.placeholder, loading = _param.loading, srcString = _param.srcString, config = _param.config, unoptimized = _param.unoptimized, loader = _param.loader, onLoadingCompleteRef = _param.onLoadingCompleteRef, setBlurComplete = _param.setBlurComplete, setIntersection = _param.setIntersection, onLoad = _param.onLoad, onError = _param.onError, isVisible = _param.isVisible, noscriptSizes = _param.noscriptSizes, rest = _object_without_properties_loose(_param, [ "imgAttributes", "heightInt", "widthInt", "qualityInt", "layout", "className", "imgStyle", "blurStyle", "isLazy", "placeholder", "loading", "srcString", "config", "unoptimized", "loader", "onLoadingCompleteRef", "setBlurComplete", "setIntersection", "onLoad", "onError", "isVisible", "noscriptSizes" ]); loading = isLazy ? "lazy" : loading; return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement("img", Object.assign({}, rest, imgAttributes, { decoding: "async", "data-nimg": layout, className: className, style: _extends({}, imgStyle, blurStyle), ref: (0, _react).useCallback(function (img) { if (false) { } setIntersection(img); if (img == null ? void 0 : img.complete) { handleLoading(img, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete); } }, [ setIntersection, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete, ]), onLoad: function (event) { var img = event.currentTarget; handleLoading(img, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete); if (onLoad) { onLoad(event); } }, onError: function (event) { if (placeholder === "blur") { // If the real image fails to load, this will still remove the placeholder. setBlurComplete(true); } if (onError) { onError(event); } } })), (isLazy || placeholder === "blur") && /*#__PURE__*/ _react.default.createElement("noscript", null, /*#__PURE__*/ _react.default.createElement("img", Object.assign({}, rest, generateImgAttrs({ config: config, src: srcString, unoptimized: unoptimized, layout: layout, width: widthInt, quality: qualityInt, sizes: noscriptSizes, loader: loader }), { decoding: "async", "data-nimg": layout, style: imgStyle, className: className, // @ts-ignore - TODO: upgrade to `@types/react@17` loading: loading })))); }; function normalizeSrc(src) { return src[0] === "/" ? src.slice(1) : src; } function imgixLoader(param) { var config = param.config, src = param.src, width = param.width, quality = param.quality; // Demo: https://static.imgix.net/daisy.png?auto=format&fit=max&w=300 var url = new URL("".concat(config.path).concat(normalizeSrc(src))); var params = url.searchParams; // auto params can be combined with comma separation, or reiteration params.set("auto", params.getAll("auto").join(",") || "format"); params.set("fit", params.get("fit") || "max"); params.set("w", params.get("w") || width.toString()); if (quality) { params.set("q", quality.toString()); } return url.href; } function akamaiLoader(param) { var config = param.config, src = param.src, width = param.width; return "".concat(config.path).concat(normalizeSrc(src), "?imwidth=").concat(width); } function cloudinaryLoader(param) { var config = param.config, src = param.src, width = param.width, quality = param.quality; // Demo: https://res.cloudinary.com/demo/image/upload/w_300,c_limit,q_auto/turtles.jpg var params = [ "f_auto", "c_limit", "w_" + width, "q_" + (quality || "auto") ]; var paramsString = params.join(",") + "/"; return "".concat(config.path).concat(paramsString).concat(normalizeSrc(src)); } function customLoader(param) { var src = param.src; throw new Error('Image with src "'.concat(src, '" is missing "loader" prop.') + "\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader"); } function defaultLoader(param) { var config = param.config, src = param.src, width = param.width, quality = param.quality; if (false) { var hasMatch, parsedSrc, missingValues; } if (src.endsWith(".svg") && !config.dangerouslyAllowSVG) { // Special case to make svg serve as-is to avoid proxying // through the built-in Image Optimization API. return src; } return "".concat((0, _normalizeTrailingSlash).normalizePathTrailingSlash(config.path), "?url=").concat(encodeURIComponent(src), "&w=").concat(width, "&q=").concat(quality || 75); } if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") { Object.defineProperty(exports.default, "__esModule", { value: true }); Object.assign(exports.default, exports); module.exports = exports.default; } //# sourceMappingURL=image.js.map /***/ }), /***/ 757: /***/ (function (module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); var _slicedToArray = (__webpack_require__(8693)/* ["default"] */.Z); Object.defineProperty(exports, "__esModule", ({ value: true })); exports.useIntersection = useIntersection; var _react = __webpack_require__(959); var _requestIdleCallback = __webpack_require__(6501); var hasIntersectionObserver = typeof IntersectionObserver === "function"; function useIntersection(param) { var rootRef = param.rootRef, rootMargin = param.rootMargin, disabled = param.disabled; var isDisabled = disabled || !hasIntersectionObserver; var unobserve = (0, _react).useRef(); var ref = _slicedToArray((0, _react).useState(false), 2), visible = ref[0], setVisible = ref[1]; var ref1 = _slicedToArray((0, _react).useState(null), 2), element = ref1[0], setElement = ref1[1]; (0, _react).useEffect(function () { if (hasIntersectionObserver) { if (unobserve.current) { unobserve.current(); unobserve.current = undefined; } if (isDisabled || visible) return; if (element && element.tagName) { unobserve.current = observe(element, function (isVisible) { return isVisible && setVisible(isVisible); }, { root: rootRef == null ? void 0 : rootRef.current, rootMargin: rootMargin }); } return function () { unobserve.current == null ? void 0 : unobserve.current(); unobserve.current = undefined; }; } else { if (!visible) { var idleCallback = (0, _requestIdleCallback).requestIdleCallback(function () { return setVisible(true); }); return function () { return (0, _requestIdleCallback).cancelIdleCallback(idleCallback); }; } } }, [ element, isDisabled, rootMargin, rootRef, visible ]); var resetVisible = (0, _react).useCallback(function () { setVisible(false); }, []); return [ setElement, visible, resetVisible ]; } var observers = new Map(); var idList = []; function observe(element, callback, options) { var ref = createObserver(options), id = ref.id, observer = ref.observer, elements = ref.elements; elements.set(element, callback); observer.observe(element); return function unobserve() { elements.delete(element); observer.unobserve(element); // Destroy observer when there's nothing left to watch: if (elements.size === 0) { observer.disconnect(); observers.delete(id); var index = idList.findIndex(function (obj) { return obj.root === id.root && obj.margin === id.margin; }); if (index > -1) { idList.splice(index, 1); } } }; } function createObserver(options) { var id = { root: options.root || null, margin: options.rootMargin || "" }; var existing = idList.find(function (obj) { return obj.root === id.root && obj.margin === id.margin; }); var instance; if (existing) { instance = observers.get(existing); if (instance) { return instance; } } var elements = new Map(); var observer = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { var callback = elements.get(entry.target); var isVisible = entry.isIntersecting || entry.intersectionRatio > 0; if (callback && isVisible) { callback(isVisible); } }); }, options); instance = { id: id, observer: observer, elements: elements }; idList.push(id); observers.set(id, instance); return instance; } if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") { Object.defineProperty(exports.default, "__esModule", { value: true }); Object.assign(exports.default, exports); module.exports = exports.default; } //# sourceMappingURL=use-intersection.js.map /***/ }), /***/ 1107: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "default": function () { return /* binding */ pages; } }); // EXTERNAL MODULE: ./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(1527); // EXTERNAL MODULE: ./node_modules/.pnpm/next@12.2.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/head.js var head = __webpack_require__(6224); var head_default = /*#__PURE__*/__webpack_require__.n(head); // EXTERNAL MODULE: ./node_modules/.pnpm/next@12.2.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/image.js var next_image = __webpack_require__(8206); var image_default = /*#__PURE__*/__webpack_require__.n(next_image); // EXTERNAL MODULE: ./node_modules/.pnpm/react@18.2.0/node_modules/react/index.js var react = __webpack_require__(959); // EXTERNAL MODULE: ./styles/Home.module.css var Home_module = __webpack_require__(9915); var Home_module_default = /*#__PURE__*/__webpack_require__.n(Home_module); ;// CONCATENATED MODULE: ./utils/image.ts var IMAGE_SIZE = 40; var preloadImage = function () { new Image(IMAGE_SIZE, IMAGE_SIZE).src = "/vercel.svg"; }; ;// CONCATENATED MODULE: ./pages/index.tsx var Home = function () { (0, react.useEffect)(function () { console.log(IMAGE_SIZE); preloadImage(); }, []); return /*#__PURE__*/ (0, jsx_runtime.jsxs)("div", { className: (Home_module_default()).container, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)((head_default()), { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("title", { children: "Create Next App" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("meta", { name: "description", content: "Generated by create next app" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("link", { rel: "icon", href: "/favicon.ico" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("main", { className: (Home_module_default()).main, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)("h1", { className: (Home_module_default()).title, children: [ "Welcome to ", /*#__PURE__*/ (0, jsx_runtime.jsx)("a", { href: "https://nextjs.org", children: "Next.js!" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("p", { className: (Home_module_default()).description, children: [ "Get started by editing", " ", /*#__PURE__*/ (0, jsx_runtime.jsx)("code", { className: (Home_module_default()).code, children: "pages/index.tsx" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("div", { className: (Home_module_default()).grid, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://nextjs.org/docs", className: (Home_module_default()).card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Documentation →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Find in-depth information about Next.js features and API." }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://nextjs.org/learn", className: (Home_module_default()).card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Learn →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Learn about Next.js in an interactive course with quizzes!" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://github.com/vercel/next.js/tree/canary/examples", className: (Home_module_default()).card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Examples →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Discover and deploy boilerplate example Next.js projects." }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app", className: (Home_module_default()).card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Deploy →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Instantly deploy your Next.js site to a public URL with Vercel." }) ] }) ] }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsx)("footer", { className: (Home_module_default()).footer, children: /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app", target: "_blank", rel: "noopener noreferrer", children: [ "Powered by", " ", /*#__PURE__*/ (0, jsx_runtime.jsx)("span", { className: (Home_module_default()).logo, children: /*#__PURE__*/ (0, jsx_runtime.jsx)((image_default()), { src: "/vercel.svg", alt: "Vercel Logo", width: 72, height: 16 }) }) ] }) }) ] }); }; /* harmony default export */ var pages = (Home); /***/ }), /***/ 9915: /***/ (function (module) { // extracted by mini-css-extract-plugin module.exports = { "container": "Home_container__bCOhY", "main": "Home_main__nLjiQ", "footer": "Home_footer____T7K", "title": "Home_title__T09hD", "description": "Home_description__41Owk", "code": "Home_code__suPER", "grid": "Home_grid__GxQ85", "card": "Home_card___LpL1", "logo": "Home_logo__27_tb" }; /***/ }), /***/ 6224: /***/ (function (module, __unused_webpack_exports, __webpack_require__) { module.exports = __webpack_require__(4357) /***/ }), /***/ 8206: /***/ (function (module, __unused_webpack_exports, __webpack_require__) { module.exports = __webpack_require__(9838) /***/ }) }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ __webpack_require__.O(0, [774, 888, 179], function () { return __webpack_exec__(5702); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/39538/static/chunks/pages/index-1bd068cedc2b5af3/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 405 ], { /***/ 1412: /***/ function(__unused_webpack_module, exports) { "use strict"; exports.Z = function(obj, key, value) { return key in obj ? Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }) : obj[key] = value, obj; }; /***/ }, /***/ 5702: /***/ function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { (window.__NEXT_P = window.__NEXT_P || []).push([ "/", function() { return __webpack_require__(1107); } ]); /***/ }, /***/ 9838: /***/ function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var _defineProperty = __webpack_require__(1412)/* ["default"] */ .Z, _slicedToArray = __webpack_require__(8693)/* ["default"] */ .Z, _toConsumableArray = __webpack_require__(9947)/* ["default"] */ .Z; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.default = function(_param) { var src, sizerSvgUrl, _obj, src1 = _param.src, sizes = _param.sizes, _unoptimized = _param.unoptimized, unoptimized = void 0 !== _unoptimized && _unoptimized, _priority = _param.priority, priority = void 0 !== _priority && _priority, loading = _param.loading, _lazyRoot = _param.lazyRoot, lazyBoundary = _param.lazyBoundary, className = _param.className, quality = _param.quality, width = _param.width, height = _param.height, style = _param.style, objectFit = _param.objectFit, objectPosition = _param.objectPosition, onLoadingComplete = _param.onLoadingComplete, _placeholder = _param.placeholder, placeholder = void 0 === _placeholder ? "empty" : _placeholder, blurDataURL = _param.blurDataURL, all = _object_without_properties_loose(_param, [ "src", "sizes", "unoptimized", "priority", "loading", "lazyRoot", "lazyBoundary", "className", "quality", "width", "height", "style", "objectFit", "objectPosition", "onLoadingComplete", "placeholder", "blurDataURL" ]), configContext = _react.useContext(_imageConfigContext.ImageConfigContext), config = _react.useMemo(function() { var c = configEnv || configContext || _imageConfig.imageConfigDefault, allSizes = _toConsumableArray(c.deviceSizes).concat(_toConsumableArray(c.imageSizes)).sort(function(a, b) { return a - b; }), deviceSizes = c.deviceSizes.sort(function(a, b) { return a - b; }); return _extends({}, c, { allSizes: allSizes, deviceSizes: deviceSizes }); }, [ configContext ]), layout = sizes ? "responsive" : "intrinsic"; "layout" in all && (all.layout && (layout = all.layout), // Remove property so it's not spread on <img>: delete all.layout); var loader = defaultImageLoader; if ("loader" in all) { if (all.loader) { var customImageLoader = all.loader; loader = function(obj) { // The config object is internal only so we must // not pass it to the user-defined loader() return obj.config, customImageLoader(_object_without_properties_loose(obj, [ "config" ])); }; } // Remove property so it's not spread on <img> delete all.loader; } var staticSrc = ""; if ("object" == typeof (src = src1) && (isStaticRequire(src) || void 0 !== src.src)) { var staticImageData = isStaticRequire(src1) ? src1.default : src1; if (!staticImageData.src) throw Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ".concat(JSON.stringify(staticImageData))); if (blurDataURL = blurDataURL || staticImageData.blurDataURL, staticSrc = staticImageData.src, (!layout || "fill" !== layout) && (height = height || staticImageData.height, width = width || staticImageData.width, !staticImageData.height || !staticImageData.width)) throw Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ".concat(JSON.stringify(staticImageData))); } var isLazy = !priority && ("lazy" === loading || void 0 === loading); ((src1 = "string" == typeof src1 ? src1 : staticSrc).startsWith("data:") || src1.startsWith("blob:")) && (// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs unoptimized = !0, isLazy = !1), loadedImageURLs.has(src1) && (isLazy = !1), experimentalUnoptimized && (unoptimized = !0); var ref = _slicedToArray(_react.useState(!1), 2), blurComplete = ref[0], setBlurComplete = ref[1], ref1 = _slicedToArray(_useIntersection.useIntersection({ rootRef: void 0 === _lazyRoot ? null : _lazyRoot, rootMargin: lazyBoundary || "200px", disabled: !isLazy }), 3), setIntersection = ref1[0], isIntersected = ref1[1], resetIntersected = ref1[2], isVisible = !isLazy || isIntersected, wrapperStyle = { boxSizing: "border-box", display: "block", overflow: "hidden", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }, sizerStyle = { boxSizing: "border-box", display: "block", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }, hasSizer = !1, widthInt = getInt(width), heightInt = getInt(height), qualityInt = getInt(quality), imgStyle = Object.assign({}, style, { position: "absolute", top: 0, left: 0, bottom: 0, right: 0, boxSizing: "border-box", padding: 0, border: "none", margin: "auto", display: "block", width: 0, height: 0, minWidth: "100%", maxWidth: "100%", minHeight: "100%", maxHeight: "100%", objectFit: objectFit, objectPosition: objectPosition }), blurStyle = "blur" !== placeholder || blurComplete ? {} : { backgroundSize: objectFit || "cover", backgroundPosition: objectPosition || "0% 0%", filter: "blur(20px)", backgroundImage: 'url("'.concat(blurDataURL, '")') }; if ("fill" === layout) // <Image src="i.png" layout="fill" /> wrapperStyle.display = "block", wrapperStyle.position = "absolute", wrapperStyle.top = 0, wrapperStyle.left = 0, wrapperStyle.bottom = 0, wrapperStyle.right = 0; else if (void 0 !== widthInt && void 0 !== heightInt) { // <Image src="i.png" width="100" height="100" /> var quotient = heightInt / widthInt, paddingTop = isNaN(quotient) ? "100%" : "".concat(100 * quotient, "%"); "responsive" === layout ? (// <Image src="i.png" width="100" height="100" layout="responsive" /> wrapperStyle.display = "block", wrapperStyle.position = "relative", hasSizer = !0, sizerStyle.paddingTop = paddingTop) : "intrinsic" === layout ? (// <Image src="i.png" width="100" height="100" layout="intrinsic" /> wrapperStyle.display = "inline-block", wrapperStyle.position = "relative", wrapperStyle.maxWidth = "100%", hasSizer = !0, sizerStyle.maxWidth = "100%", sizerSvgUrl = "data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27".concat(widthInt, "%27%20height=%27").concat(heightInt, "%27/%3e")) : "fixed" === layout && (// <Image src="i.png" width="100" height="100" layout="fixed" /> wrapperStyle.display = "inline-block", wrapperStyle.position = "relative", wrapperStyle.width = widthInt, wrapperStyle.height = heightInt); } var imgAttributes = { src: emptyDataURL, srcSet: void 0, sizes: void 0 }; isVisible && (imgAttributes = generateImgAttrs({ config: config, src: src1, unoptimized: unoptimized, layout: layout, width: widthInt, quality: qualityInt, sizes: sizes, loader: loader })); var srcString = src1, imageSizesPropName = "imagesizes"; imageSizesPropName = "imageSizes"; var linkProps = (_defineProperty(_obj = {}, "imageSrcSet", imgAttributes.srcSet), _defineProperty(_obj, imageSizesPropName, imgAttributes.sizes), _obj), useLayoutEffect = _react.default.useLayoutEffect, onLoadingCompleteRef = _react.useRef(onLoadingComplete), previousImageSrc = _react.useRef(src1); _react.useEffect(function() { onLoadingCompleteRef.current = onLoadingComplete; }, [ onLoadingComplete ]), useLayoutEffect(function() { previousImageSrc.current !== src1 && (resetIntersected(), previousImageSrc.current = src1); }, [ resetIntersected, src1 ]); var imgElementArgs = _extends({ isLazy: isLazy, imgAttributes: imgAttributes, heightInt: heightInt, widthInt: widthInt, qualityInt: qualityInt, layout: layout, className: className, imgStyle: imgStyle, blurStyle: blurStyle, loading: loading, config: config, unoptimized: unoptimized, placeholder: placeholder, loader: loader, srcString: srcString, onLoadingCompleteRef: onLoadingCompleteRef, setBlurComplete: setBlurComplete, setIntersection: setIntersection, isVisible: isVisible, noscriptSizes: sizes }, all); return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement("span", { style: wrapperStyle }, hasSizer ? /*#__PURE__*/ _react.default.createElement("span", { style: sizerStyle }, sizerSvgUrl ? /*#__PURE__*/ _react.default.createElement("img", { style: { display: "block", maxWidth: "100%", width: "initial", height: "initial", background: "none", opacity: 1, border: 0, margin: 0, padding: 0 }, alt: "", "aria-hidden": !0, src: sizerSvgUrl }) : null) : null, /*#__PURE__*/ _react.default.createElement(ImageElement, Object.assign({}, imgElementArgs))), priority ? // it would likely cause the incorrect image to be preloaded. // // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-imagesrcset /*#__PURE__*/ _react.default.createElement(_head.default, null, /*#__PURE__*/ _react.default.createElement("link", Object.assign({ key: "__nimg-" + imgAttributes.src + imgAttributes.srcSet + imgAttributes.sizes, rel: "preload", as: "image", href: imgAttributes.srcSet ? void 0 : imgAttributes.src }, linkProps))) : null); }; var _extends = __webpack_require__(2769)/* ["default"] */ .Z, _interop_require_default = __webpack_require__(4507)/* ["default"] */ .Z, _interop_require_wildcard = __webpack_require__(8167)/* ["default"] */ .Z, _object_without_properties_loose = __webpack_require__(4719)/* ["default"] */ .Z, _react = _interop_require_wildcard(__webpack_require__(959)), _head = _interop_require_default(__webpack_require__(4357)), _imageConfig = __webpack_require__(1773), _useIntersection = __webpack_require__(757), _imageConfigContext = __webpack_require__(9664); __webpack_require__(8827); var _normalizeTrailingSlash = __webpack_require__(8236), ref = { deviceSizes: [ 640, 750, 828, 1080, 1200, 1920, 2048, 3840 ], imageSizes: [ 16, 32, 48, 64, 96, 128, 256, 384 ], path: "/_next/image", loader: "default", dangerouslyAllowSVG: !1 }, experimentalUnoptimized = (ref.experimentalRemotePatterns, ref.experimentalUnoptimized), configEnv = { deviceSizes: [ 640, 750, 828, 1080, 1200, 1920, 2048, 3840 ], imageSizes: [ 16, 32, 48, 64, 96, 128, 256, 384 ], path: "/_next/image", loader: "default", dangerouslyAllowSVG: !1 }, loadedImageURLs = new Set(), emptyDataURL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", loaders = new Map([ [ "default", function(param) { var config = param.config, src = param.src, width = param.width, quality = param.quality; return src.endsWith(".svg") && !config.dangerouslyAllowSVG ? src : "".concat(_normalizeTrailingSlash.normalizePathTrailingSlash(config.path), "?url=").concat(encodeURIComponent(src), "&w=").concat(width, "&q=").concat(quality || 75); } ], [ "imgix", function(param) { var config = param.config, src = param.src, width = param.width, quality = param.quality, url = new URL("".concat(config.path).concat(normalizeSrc(src))), params = url.searchParams; return(// auto params can be combined with comma separation, or reiteration params.set("auto", params.getAll("auto").join(",") || "format"), params.set("fit", params.get("fit") || "max"), params.set("w", params.get("w") || width.toString()), quality && params.set("q", quality.toString()), url.href); } ], [ "cloudinary", function(param) { var config = param.config, src = param.src, paramsString = [ "f_auto", "c_limit", "w_" + param.width, "q_" + (param.quality || "auto") ].join(",") + "/"; return "".concat(config.path).concat(paramsString).concat(normalizeSrc(src)); } ], [ "akamai", function(param) { var config = param.config, src = param.src, width = param.width; return "".concat(config.path).concat(normalizeSrc(src), "?imwidth=").concat(width); } ], [ "custom", function(param) { var src = param.src; throw Error('Image with src "'.concat(src, '" is missing "loader" prop.') + "\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader"); } ] ]); function isStaticRequire(src) { return void 0 !== src.default; } function generateImgAttrs(param) { var config = param.config, src = param.src, unoptimized = param.unoptimized, layout = param.layout, width = param.width, quality = param.quality, sizes = param.sizes, loader = param.loader; if (unoptimized) return { src: src, srcSet: void 0, sizes: void 0 }; var ref = function(param, width, layout, sizes) { var deviceSizes = param.deviceSizes, allSizes = param.allSizes; if (sizes && ("fill" === layout || "responsive" === layout)) { for(// Find all the "vw" percent sizes used in the sizes prop var viewportWidthRe = /(^|\s)(1?\d?\d)vw/g, percentSizes = []; match = viewportWidthRe.exec(sizes); match)percentSizes.push(parseInt(match[2])); if (percentSizes.length) { var match, _Math, smallestRatio = 0.01 * (_Math = Math).min.apply(_Math, _toConsumableArray(percentSizes)); return { widths: allSizes.filter(function(s) { return s >= deviceSizes[0] * smallestRatio; }), kind: "w" }; } return { widths: allSizes, kind: "w" }; } return "number" != typeof width || "fill" === layout || "responsive" === layout ? { widths: deviceSizes, kind: "w" } : { widths: _toConsumableArray(new Set(// > blue colors. Showing a 3x resolution image in the app vs a 2x // > resolution image will be visually the same, though the 3x image // > takes significantly more data. Even true 3x resolution screens are // > wasteful as the human eye cannot see that level of detail without // > something like a magnifying glass. // https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html [ width, 2 /*, width * 3*/ * width ].map(function(w) { return allSizes.find(function(p) { return p >= w; }) || allSizes[allSizes.length - 1]; }))), kind: "x" }; }(config, width, layout, sizes), widths = ref.widths, kind = ref.kind, last = widths.length - 1; return { sizes: sizes || "w" !== kind ? sizes : "100vw", srcSet: widths.map(function(w, i) { return "".concat(loader({ config: config, src: src, quality: quality, width: w }), " ").concat("w" === kind ? w : i + 1).concat(kind); }).join(", "), // It's intended to keep `src` the last attribute because React updates // attributes in order. If we keep `src` the first one, Safari will // immediately start to fetch `src`, before `sizes` and `srcSet` are even // updated by React. That causes multiple unnecessary requests if `srcSet` // and `sizes` are defined. // This bug cannot be reproduced in Chrome or Firefox. src: loader({ config: config, src: src, quality: quality, width: widths[last] }) }; } function getInt(x) { return "number" == typeof x ? x : "string" == typeof x ? parseInt(x, 10) : void 0; } function defaultImageLoader(loaderProps) { var ref, loaderKey = (null == (ref = loaderProps.config) ? void 0 : ref.loader) || "default", load = loaders.get(loaderKey); if (load) return load(loaderProps); throw Error('Unknown "loader" found in "next.config.js". Expected: '.concat(_imageConfig.VALID_LOADERS.join(", "), ". Received: ").concat(loaderKey)); } // See https://stackoverflow.com/q/39777833/266535 for why we use this ref // handler instead of the img's onLoad attribute. function handleLoading(img, src, layout, placeholder, onLoadingCompleteRef, setBlurComplete) { img && img.src !== emptyDataURL && img["data-loaded-src"] !== src && (img["data-loaded-src"] = src, ("decode" in img ? img.decode() : Promise.resolve()).catch(function() {}).then(function() { if (img.parentNode && (loadedImageURLs.add(src), "blur" === placeholder && setBlurComplete(!0), null == onLoadingCompleteRef ? void 0 : onLoadingCompleteRef.current)) { var naturalWidth = img.naturalWidth, naturalHeight = img.naturalHeight; // Pass back read-only primitive values but not the // underlying DOM element because it could be misused. onLoadingCompleteRef.current({ naturalWidth: naturalWidth, naturalHeight: naturalHeight }); } })); } var ImageElement = function(_param) { var imgAttributes = _param.imgAttributes, widthInt = (_param.heightInt, _param.widthInt), qualityInt = _param.qualityInt, layout = _param.layout, className = _param.className, imgStyle = _param.imgStyle, blurStyle = _param.blurStyle, isLazy = _param.isLazy, placeholder = _param.placeholder, loading = _param.loading, srcString = _param.srcString, config = _param.config, unoptimized = _param.unoptimized, loader = _param.loader, onLoadingCompleteRef = _param.onLoadingCompleteRef, setBlurComplete = _param.setBlurComplete, setIntersection = _param.setIntersection, onLoad = _param.onLoad, onError = _param.onError, noscriptSizes = (_param.isVisible, _param.noscriptSizes), rest = _object_without_properties_loose(_param, [ "imgAttributes", "heightInt", "widthInt", "qualityInt", "layout", "className", "imgStyle", "blurStyle", "isLazy", "placeholder", "loading", "srcString", "config", "unoptimized", "loader", "onLoadingCompleteRef", "setBlurComplete", "setIntersection", "onLoad", "onError", "isVisible", "noscriptSizes" ]); return loading = isLazy ? "lazy" : loading, /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement("img", Object.assign({}, rest, imgAttributes, { decoding: "async", "data-nimg": layout, className: className, style: _extends({}, imgStyle, blurStyle), ref: _react.useCallback(function(img) { setIntersection(img), (null == img ? void 0 : img.complete) && handleLoading(img, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete); }, [ setIntersection, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete ]), onLoad: function(event) { handleLoading(event.currentTarget, srcString, layout, placeholder, onLoadingCompleteRef, setBlurComplete), onLoad && onLoad(event); }, onError: function(event) { "blur" === placeholder && // If the real image fails to load, this will still remove the placeholder. setBlurComplete(!0), onError && onError(event); } })), (isLazy || "blur" === placeholder) && /*#__PURE__*/ _react.default.createElement("noscript", null, /*#__PURE__*/ _react.default.createElement("img", Object.assign({}, rest, generateImgAttrs({ config: config, src: srcString, unoptimized: unoptimized, layout: layout, width: widthInt, quality: qualityInt, sizes: noscriptSizes, loader: loader }), { decoding: "async", "data-nimg": layout, style: imgStyle, className: className, // @ts-ignore - TODO: upgrade to `@types/react@17` loading: loading })))); }; function normalizeSrc(src) { return "/" === src[0] ? src.slice(1) : src; } ("function" == typeof exports.default || "object" == typeof exports.default && null !== exports.default) && void 0 === exports.default.__esModule && (Object.defineProperty(exports.default, "__esModule", { value: !0 }), Object.assign(exports.default, exports), module.exports = exports.default); /***/ }, /***/ 757: /***/ function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var _slicedToArray = __webpack_require__(8693)/* ["default"] */ .Z; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.useIntersection = function(param) { var rootRef = param.rootRef, rootMargin = param.rootMargin, isDisabled = param.disabled || !hasIntersectionObserver, unobserve = _react.useRef(), ref = _slicedToArray(_react.useState(!1), 2), visible = ref[0], setVisible = ref[1], ref1 = _slicedToArray(_react.useState(null), 2), element = ref1[0], setElement = ref1[1]; return _react.useEffect(function() { if (hasIntersectionObserver) { if (unobserve.current && (unobserve.current(), unobserve.current = void 0), !isDisabled && !visible) { var ref, id, observer, elements; return element && element.tagName && (id = (ref = function(options) { var instance, id = { root: options.root || null, margin: options.rootMargin || "" }, existing = idList.find(function(obj) { return obj.root === id.root && obj.margin === id.margin; }); if (existing && (instance = observers.get(existing))) return instance; var elements = new Map(); return instance = { id: id, observer: new IntersectionObserver(function(entries) { entries.forEach(function(entry) { var callback = elements.get(entry.target), isVisible = entry.isIntersecting || entry.intersectionRatio > 0; callback && isVisible && callback(isVisible); }); }, options), elements: elements }, idList.push(id), observers.set(id, instance), instance; }({ root: null == rootRef ? void 0 : rootRef.current, rootMargin: rootMargin })).id, observer = ref.observer, (elements = ref.elements).set(element, function(isVisible) { return isVisible && setVisible(isVisible); }), observer.observe(element), unobserve.current = function() { // Destroy observer when there's nothing left to watch: if (elements.delete(element), observer.unobserve(element), 0 === elements.size) { observer.disconnect(), observers.delete(id); var index = idList.findIndex(function(obj) { return obj.root === id.root && obj.margin === id.margin; }); index > -1 && idList.splice(index, 1); } }), function() { null == unobserve.current || unobserve.current(), unobserve.current = void 0; }; } } else if (!visible) { var idleCallback = _requestIdleCallback.requestIdleCallback(function() { return setVisible(!0); }); return function() { return _requestIdleCallback.cancelIdleCallback(idleCallback); }; } }, [ element, isDisabled, rootMargin, rootRef, visible ]), [ setElement, visible, _react.useCallback(function() { setVisible(!1); }, []) ]; }; var _react = __webpack_require__(959), _requestIdleCallback = __webpack_require__(6501), hasIntersectionObserver = "function" == typeof IntersectionObserver, observers = new Map(), idList = []; ("function" == typeof exports.default || "object" == typeof exports.default && null !== exports.default) && void 0 === exports.default.__esModule && (Object.defineProperty(exports.default, "__esModule", { value: !0 }), Object.assign(exports.default, exports), module.exports = exports.default); /***/ }, /***/ 1107: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function() { return /* binding */ pages; } }); // EXTERNAL MODULE: ./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(1527), head = __webpack_require__(6224), head_default = /*#__PURE__*/ __webpack_require__.n(head), next_image = __webpack_require__(8206), image_default = /*#__PURE__*/ __webpack_require__.n(next_image), react = __webpack_require__(959), Home_module = __webpack_require__(9915), Home_module_default = /*#__PURE__*/ __webpack_require__.n(Home_module), preloadImage = function() { new Image(40, 40).src = "/vercel.svg"; }, pages = function() { return (0, react.useEffect)(function() { console.log(40), preloadImage(); }, []), /*#__PURE__*/ (0, jsx_runtime.jsxs)("div", { className: Home_module_default().container, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)(head_default(), { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("title", { children: "Create Next App" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("meta", { name: "description", content: "Generated by create next app" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("link", { rel: "icon", href: "/favicon.ico" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("main", { className: Home_module_default().main, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)("h1", { className: Home_module_default().title, children: [ "Welcome to ", /*#__PURE__*/ (0, jsx_runtime.jsx)("a", { href: "https://nextjs.org", children: "Next.js!" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("p", { className: Home_module_default().description, children: [ "Get started by editing", " ", /*#__PURE__*/ (0, jsx_runtime.jsx)("code", { className: Home_module_default().code, children: "pages/index.tsx" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("div", { className: Home_module_default().grid, children: [ /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://nextjs.org/docs", className: Home_module_default().card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Documentation →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Find in-depth information about Next.js features and API." }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://nextjs.org/learn", className: Home_module_default().card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Learn →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Learn about Next.js in an interactive course with quizzes!" }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://github.com/vercel/next.js/tree/canary/examples", className: Home_module_default().card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Examples →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Discover and deploy boilerplate example Next.js projects." }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app", className: Home_module_default().card, children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)("h2", { children: "Deploy →" }), /*#__PURE__*/ (0, jsx_runtime.jsx)("p", { children: "Instantly deploy your Next.js site to a public URL with Vercel." }) ] }) ] }) ] }), /*#__PURE__*/ (0, jsx_runtime.jsx)("footer", { className: Home_module_default().footer, children: /*#__PURE__*/ (0, jsx_runtime.jsxs)("a", { href: "https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app", target: "_blank", rel: "noopener noreferrer", children: [ "Powered by", " ", /*#__PURE__*/ (0, jsx_runtime.jsx)("span", { className: Home_module_default().logo, children: /*#__PURE__*/ (0, jsx_runtime.jsx)(image_default(), { src: "/vercel.svg", alt: "Vercel Logo", width: 72, height: 16 }) }) ] }) }) ] }); }; /***/ }, /***/ 9915: /***/ function(module) { // extracted by mini-css-extract-plugin module.exports = { container: "Home_container__bCOhY", main: "Home_main__nLjiQ", footer: "Home_footer____T7K", title: "Home_title__T09hD", description: "Home_description__41Owk", code: "Home_code__suPER", grid: "Home_grid__GxQ85", card: "Home_card___LpL1", logo: "Home_logo__27_tb" }; /***/ }, /***/ 6224: /***/ function(module, __unused_webpack_exports, __webpack_require__) { module.exports = __webpack_require__(4357); /***/ }, /***/ 8206: /***/ function(module, __unused_webpack_exports, __webpack_require__) { module.exports = __webpack_require__(9838); /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 774, 888, 179 ], function() { return __webpack_require__(__webpack_require__.s = 5702); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/41527/1/input.js
JavaScript
import Delta from 'quill-delta'; import { EmbedBlot, Scope } from 'parchment'; import Quill from '../core/quill'; import logger from '../core/logger'; import Module from '../core/module'; const debug = logger('quill:toolbar'); class Toolbar extends Module { constructor(quill, options) { super(quill, options); if (Array.isArray(this.options.container)) { const container = document.createElement('div'); addControls(container, this.options.container); quill.container.parentNode.insertBefore(container, quill.container); this.container = container; } else if (typeof this.options.container === 'string') { this.container = document.querySelector(this.options.container); } else { this.container = this.options.container; } if (!(this.container instanceof HTMLElement)) { debug.error('Container required for toolbar', this.options); return; } this.container.classList.add('ql-toolbar'); this.controls = []; this.handlers = {}; Object.keys(this.options.handlers).forEach((format) => { this.addHandler(format, this.options.handlers[format]); }); Array.from(this.container.querySelectorAll('button, select')).forEach((input) => { this.attach(input); }); this.quill.on(Quill.events.EDITOR_CHANGE, (type, range) => { if (type === Quill.events.SELECTION_CHANGE) { this.update(range); } }); this.quill.on(Quill.events.SCROLL_OPTIMIZE, () => { const [range] = this.quill.selection.getRange(); this.update(range); }); } addHandler(format, handler) { this.handlers[format] = handler; } attach(input) { let format = Array.from(input.classList).find((className) => { return className.indexOf('ql-') === 0; }); if (!format) return; format = format.slice('ql-'.length); if (input.tagName === 'BUTTON') { input.setAttribute('type', 'button'); } if (this.handlers[format] == null && this.quill.scroll.query(format) == null) { debug.warn('ignoring attaching to nonexistent format', format, input); return; } const eventName = input.tagName === 'SELECT' ? 'change' : 'click'; input.addEventListener(eventName, (e) => { let value; if (input.tagName === 'SELECT') { if (input.selectedIndex < 0) return; const selected = input.options[input.selectedIndex]; if (selected.hasAttribute('selected')) { value = false; } else { value = selected.value || false; } } else { if (input.classList.contains('ql-active')) { value = false; } else { value = input.value || !input.hasAttribute('value'); } e.preventDefault(); } this.quill.focus(); const [range] = this.quill.selection.getRange(); if (this.handlers[format] != null) { this.handlers[format].call(this, value); } else if (this.quill.scroll.query(format).prototype instanceof EmbedBlot) { value = prompt(`Enter ${format}`); if (!value) return; this.quill.updateContents(new Delta().retain(range.index).delete(range.length).insert({ [format]: value }), Quill.sources.USER); } else { this.quill.format(format, value, Quill.sources.USER); } this.update(range); }); this.controls.push([ format, input ]); } update(range) { const formats = range == null ? {} : this.quill.getFormat(range); this.controls.forEach((pair) => { const [format, input] = pair; if (input.tagName === 'SELECT') { let option; if (range == null) { option = null; } else if (formats[format] == null) { option = input.querySelector('option[selected]'); } else if (!Array.isArray(formats[format])) { let value = formats[format]; if (typeof value === 'string') { value = value.replace(/"/g, '\\"'); } option = input.querySelector(`option[value="${value}"]`); } if (option == null) { input.value = ''; input.selectedIndex = -1; } else { option.selected = true; } } else if (range == null) { input.classList.remove('ql-active'); } else if (input.hasAttribute('value')) { const isActive = formats[format] === input.getAttribute('value') || formats[format] != null && formats[format].toString() === input.getAttribute('value') || formats[format] == null && !input.getAttribute('value'); input.classList.toggle('ql-active', isActive); } else { input.classList.toggle('ql-active', formats[format] != null); } }); } } Toolbar.DEFAULTS = {}; function addButton(container, format, value) { const input = document.createElement('button'); input.setAttribute('type', 'button'); input.classList.add(`ql-${format}`); if (value != null) { input.value = value; } container.appendChild(input); } function addControls(container, groups) { if (!Array.isArray(groups[0])) { groups = [ groups ]; } groups.forEach((controls) => { const group = document.createElement('span'); group.classList.add('ql-formats'); controls.forEach((control) => { if (typeof control === 'string') { addButton(group, control); } else { const format = Object.keys(control)[0]; const value = control[format]; if (Array.isArray(value)) { addSelect(group, format, value); } else { addButton(group, format, value); } } }); container.appendChild(group); }); } function addSelect(container, format, values) { const input = document.createElement('select'); input.classList.add(`ql-${format}`); values.forEach((value) => { const option = document.createElement('option'); if (value !== false) { option.setAttribute('value', value); } else { option.setAttribute('selected', 'selected'); } input.appendChild(option); }); container.appendChild(input); } Toolbar.DEFAULTS = { container: null, handlers: { clean() { const range = this.quill.getSelection(); if (range == null) return; if (range.length === 0) { const formats = this.quill.getFormat(); Object.keys(formats).forEach((name) => { if (this.quill.scroll.query(name, Scope.INLINE) != null) { this.quill.format(name, false, Quill.sources.USER); } }); } else { this.quill.removeFormat(range, Quill.sources.USER); } }, direction(value) { const { align } = this.quill.getFormat(); if (value === 'rtl' && align == null) { this.quill.format('align', 'right', Quill.sources.USER); } else if (!value && align === 'right') { this.quill.format('align', false, Quill.sources.USER); } this.quill.format('direction', value, Quill.sources.USER); }, indent(value) { const range = this.quill.getSelection(); const formats = this.quill.getFormat(range); const indent = parseInt(formats.indent || 0, 10); if (value === '+1' || value === '-1') { let modifier = value === '+1' ? 1 : -1; if (formats.direction === 'rtl') modifier *= -1; this.quill.format('indent', indent + modifier, Quill.sources.USER); } }, link(value) { if (value === true) { value = prompt('Enter link URL:'); } this.quill.format('link', value, Quill.sources.USER); }, list(value) { const range = this.quill.getSelection(); const formats = this.quill.getFormat(range); if (value === 'check') { if (formats.list === 'checked' || formats.list === 'unchecked') { this.quill.format('list', false, Quill.sources.USER); } else { this.quill.format('list', 'unchecked', Quill.sources.USER); } } else { this.quill.format('list', value, Quill.sources.USER); } } } }; export { Toolbar as default, addControls };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/41527/1/output.js
JavaScript
import Delta from 'quill-delta'; import { EmbedBlot, Scope } from 'parchment'; import Quill from '../core/quill'; import logger from '../core/logger'; import Module from '../core/module'; const debug = logger('quill:toolbar'); class Toolbar extends Module { constructor(quill, options){ if (super(quill, options), Array.isArray(this.options.container)) { const container = document.createElement('div'); addControls(container, this.options.container), quill.container.parentNode.insertBefore(container, quill.container), this.container = container; } else 'string' == typeof this.options.container ? this.container = document.querySelector(this.options.container) : this.container = this.options.container; if (!(this.container instanceof HTMLElement)) { debug.error('Container required for toolbar', this.options); return; } this.container.classList.add('ql-toolbar'), this.controls = [], this.handlers = {}, Object.keys(this.options.handlers).forEach((format)=>{ this.addHandler(format, this.options.handlers[format]); }), Array.from(this.container.querySelectorAll('button, select')).forEach((input)=>{ this.attach(input); }), this.quill.on(Quill.events.EDITOR_CHANGE, (type, range)=>{ type === Quill.events.SELECTION_CHANGE && this.update(range); }), this.quill.on(Quill.events.SCROLL_OPTIMIZE, ()=>{ const [range] = this.quill.selection.getRange(); this.update(range); }); } addHandler(format, handler) { this.handlers[format] = handler; } attach(input) { let format = Array.from(input.classList).find((className)=>0 === className.indexOf('ql-')); if (!format) return; if (format = format.slice(3), 'BUTTON' === input.tagName && input.setAttribute('type', 'button'), null == this.handlers[format] && null == this.quill.scroll.query(format)) { debug.warn('ignoring attaching to nonexistent format', format, input); return; } const eventName = 'SELECT' === input.tagName ? 'change' : 'click'; input.addEventListener(eventName, (e)=>{ let value; if ('SELECT' === input.tagName) { if (input.selectedIndex < 0) return; const selected = input.options[input.selectedIndex]; value = !selected.hasAttribute('selected') && (selected.value || !1); } else value = !input.classList.contains('ql-active') && (input.value || !input.hasAttribute('value')), e.preventDefault(); this.quill.focus(); const [range] = this.quill.selection.getRange(); if (null != this.handlers[format]) this.handlers[format].call(this, value); else if (this.quill.scroll.query(format).prototype instanceof EmbedBlot) { if (!(value = prompt(`Enter ${format}`))) return; this.quill.updateContents(new Delta().retain(range.index).delete(range.length).insert({ [format]: value }), Quill.sources.USER); } else this.quill.format(format, value, Quill.sources.USER); this.update(range); }), this.controls.push([ format, input ]); } update(range) { const formats = null == range ? {} : this.quill.getFormat(range); this.controls.forEach((pair)=>{ const [format, input] = pair; if ('SELECT' === input.tagName) { let option; if (null == range) option = null; else if (null == formats[format]) option = input.querySelector('option[selected]'); else if (!Array.isArray(formats[format])) { let value = formats[format]; 'string' == typeof value && (value = value.replace(/"/g, '\\"')), option = input.querySelector(`option[value="${value}"]`); } null == option ? (input.value = '', input.selectedIndex = -1) : option.selected = !0; } else if (null == range) input.classList.remove('ql-active'); else if (input.hasAttribute('value')) { const isActive = formats[format] === input.getAttribute('value') || null != formats[format] && formats[format].toString() === input.getAttribute('value') || null == formats[format] && !input.getAttribute('value'); input.classList.toggle('ql-active', isActive); } else input.classList.toggle('ql-active', null != formats[format]); }); } } function addButton(container, format, value) { const input = document.createElement('button'); input.setAttribute('type', 'button'), input.classList.add(`ql-${format}`), null != value && (input.value = value), container.appendChild(input); } function addControls(container, groups) { Array.isArray(groups[0]) || (groups = [ groups ]), groups.forEach((controls)=>{ const group = document.createElement('span'); group.classList.add('ql-formats'), controls.forEach((control)=>{ if ('string' == typeof control) addButton(group, control); else { const format = Object.keys(control)[0], value = control[format]; Array.isArray(value) ? function(container, format, values) { const input = document.createElement('select'); input.classList.add(`ql-${format}`), values.forEach((value)=>{ const option = document.createElement('option'); !1 !== value ? option.setAttribute('value', value) : option.setAttribute('selected', 'selected'), input.appendChild(option); }), container.appendChild(input); }(group, format, value) : addButton(group, format, value); } }), container.appendChild(group); }); } Toolbar.DEFAULTS = {}, Toolbar.DEFAULTS = { container: null, handlers: { clean () { const range = this.quill.getSelection(); null != range && (0 === range.length ? Object.keys(this.quill.getFormat()).forEach((name)=>{ null != this.quill.scroll.query(name, Scope.INLINE) && this.quill.format(name, !1, Quill.sources.USER); }) : this.quill.removeFormat(range, Quill.sources.USER)); }, direction (value) { const { align } = this.quill.getFormat(); 'rtl' === value && null == align ? this.quill.format('align', 'right', Quill.sources.USER) : value || 'right' !== align || this.quill.format('align', !1, Quill.sources.USER), this.quill.format('direction', value, Quill.sources.USER); }, indent (value) { const range = this.quill.getSelection(), formats = this.quill.getFormat(range), indent = parseInt(formats.indent || 0, 10); if ('+1' === value || '-1' === value) { let modifier = '+1' === value ? 1 : -1; 'rtl' === formats.direction && (modifier *= -1), this.quill.format('indent', indent + modifier, Quill.sources.USER); } }, link (value) { !0 === value && (value = prompt('Enter link URL:')), this.quill.format('link', value, Quill.sources.USER); }, list (value) { const range = this.quill.getSelection(), formats = this.quill.getFormat(range); 'check' === value ? 'checked' === formats.list || 'unchecked' === formats.list ? this.quill.format('list', !1, Quill.sources.USER) : this.quill.format('list', 'unchecked', Quill.sources.USER) : this.quill.format('list', value, Quill.sources.USER); } } }; export { Toolbar as default, addControls };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/41992/1/input.js
JavaScript
export const N = (0, p.default)(e = (0, ft.default)((0, p.default)(r).call(r, ((e, t) => { const r = t.get("in"); return e[r] ?? (e[r] = []), e[r].push(t), e }), {}))).call(e, ((e, t) => (0, h.default)(e).call(e, t)), []);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/41992/1/output.js
JavaScript
export const N = (0, p.default)(e = (0, ft.default)((0, p.default)(r).call(r, (e1, t)=>{ const r1 = t.get("in"); return e1[r1] ?? (e1[r1] = []), e1[r1].push(t), e1; }, {}))).call(e, (e1, t)=>(0, h.default)(e1).call(e1, t), []);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/43052/input.js
JavaScript
use((function (__unused_webpack_module, exports, __webpack_require__) { ! function (e, t) { true ? t(exports, __webpack_require__(7294), __webpack_require__(1321)) : 0 }(this, (function (exports, React) { "use strict"; var index_production = { exports: {} }; (function (module, exports) { var t; t = function (exports) { function inquire(moduleName) { try { var mod = eval("quire".replace(/^/, "re"))(moduleName); if (mod && (mod.length || Object.keys(mod).length)) return mod } catch (e) { } return null } Object.defineProperty(exports, "__esModule", { value: !0 }) }, t(exports) })(index_production, index_production.exports); exports.chunkBlocks = index_production.exports.chunkBlocks, exports.encodeDirectory = index_production.exports.encodeDirectory, exports.encodeFile = index_production.exports.encodeFile, Object.defineProperty(exports, "__esModule", { value: !0 }) })); })); (function checkMangler() { const longName = 1; use(longName) })
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/43052/output.js
JavaScript
use(function(__unused_webpack_module, exports, __webpack_require__) { !function(e, t) { t(exports, __webpack_require__(7294), __webpack_require__(1321)); }(this, function(exports, React) { "use strict"; var index_production = { exports: {} }; (function(module, exports) { var t; t = function(exports) { function inquire(moduleName) { try { var mod = eval("quire".replace(/^/, "re"))(moduleName); if (mod && (mod.length || Object.keys(mod).length)) return mod; } catch (e) {} return null; } Object.defineProperty(exports, "__esModule", { value: !0 }); }, t(exports); })(index_production, index_production.exports); exports.chunkBlocks = index_production.exports.chunkBlocks, exports.encodeDirectory = index_production.exports.encodeDirectory, exports.encodeFile = index_production.exports.encodeFile, Object.defineProperty(exports, "__esModule", { value: !0 }); }); }); (function e() { const e = 1; use(e); });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/43208/static/chunks/pages/index-e1d69965f0f167c9/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[405], { /***/ 4186: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function () { return /* binding */ Home; } /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5893); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7294); /* harmony import */ var _styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7160); /* harmony import */ var _styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var _gmod_binary_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9996); /* harmony import */ var binary_parser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9567); /* provided dependency */ var Buffer = __webpack_require__(1876)["Buffer"]; function Home() { (0, react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { const ipHeader1 = new _gmod_binary_parser__WEBPACK_IMPORTED_MODULE_2__/* .Parser */._().uint8("compressionMethod", { formatter: (b) => { const method = [ "raw" ][b]; if (!method) { // never gets here console.log("in @gmod/binary-parser"); } return method; } }); const ipHeader2 = new binary_parser__WEBPACK_IMPORTED_MODULE_3__/* .Parser */._().uint8("compressionMethod", { formatter: (b) => { const method = [ "raw" ][b]; if (!method) { console.log("in binary-parser"); } return method; } }); console.log({ ipHeader1, ipHeader2 }); // wouldn't actually parse correctly, just shows minification crash const buf = Buffer.from("450002c5939900002c06ef98adc24f6c850186d1", "hex"); console.log(ipHeader2.parse(buf)); console.log(ipHeader1.parse(buf)); }, []); return /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: (_styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4___default().container), children: "hello" }); } /***/ }), }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ __webpack_require__.O(0, [390, 774, 888, 179], function () { return __webpack_exec__(8312); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/43208/static/chunks/pages/index-e1d69965f0f167c9/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 405 ], { /***/ 4186: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__), /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ default: function() { return /* binding */ Home; } }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5893), react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7294), _styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7160), _styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/ __webpack_require__.n(_styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4__), _gmod_binary_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9996), binary_parser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9567), Buffer = __webpack_require__(1876).Buffer; function Home() { return (0, react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{ const ipHeader1 = new _gmod_binary_parser__WEBPACK_IMPORTED_MODULE_2__ /* .Parser */ ._().uint8("compressionMethod", { formatter: (b)=>{ const method = [ "raw" ][b]; return method || // never gets here console.log("in @gmod/binary-parser"), method; } }), ipHeader2 = new binary_parser__WEBPACK_IMPORTED_MODULE_3__ /* .Parser */ ._().uint8("compressionMethod", { formatter: (b)=>{ const method = [ "raw" ][b]; return method || console.log("in binary-parser"), method; } }); console.log({ ipHeader1, ipHeader2 }); // wouldn't actually parse correctly, just shows minification crash const buf = Buffer.from("450002c5939900002c06ef98adc24f6c850186d1", "hex"); console.log(ipHeader2.parse(buf)), console.log(ipHeader1.parse(buf)); }, []), /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: _styles_Home_module_css__WEBPACK_IMPORTED_MODULE_4___default().container, children: "hello" }); } /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 390, 774, 888, 179 ], function() { return __webpack_require__(__webpack_require__.s = 8312); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/46887-2/input.js
JavaScript
var Za = { set: Qi, get: Qg, enforce: function (e1) { return Ri(e1) ? Qg(e1) : Qi(e1, {}); }, getterFor: function (e1) { return function (t) { var n; if (!ha(t) || (n = Qg(t)).type !== e1) throw TypeError("Incompatible receiver, " + e1 + " required"); return n; }; } } export function exposed() { try { var a = eval("quire".replace(/^/, "re"))(c); if (a && (a.length || Object.keys(a).length)) return a; } catch (e1) { } return null; } export default (function (e) { var t = Za.get, n = Za.enforce, r = String(String).split("String"); (e.exports = function (e, t, i, o) { var a = !!o && !!o.unsafe, s = !!o && !!o.enumerable; if (o = !!o && !!o.noTargetGet, "function" == typeof i) { "string" != typeof t || Q(i, "name") || Na(i, "name", t); var u = n(i); u.source || (u.source = r.join("string" == typeof t ? t : "")) } e === y ? s ? e[t] = i : Oi(t, i) : (a ? !o && e[t] && (s = !0) : delete e[t], s ? e[t] = i : Na(e, t, i)) })(Function.prototype, "toString", (function () { return "function" == typeof this && t(this).source || Pi(this) })) })
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/46887-2/output.js
JavaScript
var Za = { set: Qi, get: Qg, enforce: function(e1) { return Ri(e1) ? Qg(e1) : Qi(e1, {}); }, getterFor: function(e1) { return function(t) { var n; if (!ha(t) || (n = Qg(t)).type !== e1) throw TypeError("Incompatible receiver, " + e1 + " required"); return n; }; } }; export function exposed() { try { var a = eval("quire".replace(/^/, "re"))(c); if (a && (a.length || Object.keys(a).length)) return a; } catch (e1) {} return null; } export default function(e) { var t = Za.get, n = Za.enforce, r = String(String).split("String"); (e.exports = function(e, t, i, o) { var a = !!o && !!o.unsafe, s = !!o && !!o.enumerable; if (o = !!o && !!o.noTargetGet, "function" == typeof i) { "string" != typeof t || Q(i, "name") || Na(i, "name", t); var u = n(i); u.source || (u.source = r.join("string" == typeof t ? t : "")); } e === y ? s ? e[t] = i : Oi(t, i) : (a ? !o && e[t] && (s = !0) : delete e[t], s ? e[t] = i : Na(e, t, i)); })(Function.prototype, "toString", function() { return "function" == typeof this && t(this).source || Pi(this); }); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/46887/input.js
JavaScript
export var CSL = {}; /* * String parser for XML inputs */ CSL.parseXml = function (str) { var _pos = 0; var _obj = { children: [] }; var _stack = [_obj.children]; function _listifyString(str) { str = str.split(/(?:\r\n|\n|\r)/).join(" ").replace(/>[ ]+</g, "><").replace(/<\!--.*?-->/g, ""); var lst = str.split("><"); var stylePos = null; for (var i = 0, ilen = lst.length; i < ilen; i++) { if (i > 0) { lst[i] = "<" + lst[i]; } if (i < (lst.length - 1)) { lst[i] = lst[i] + ">"; } if ("number" != typeof stylePos) { if (lst[i].slice(0, 7) === "<style " || lst[i].slice(0, 8) == "<locale ") { stylePos = i; } } } lst = lst.slice(stylePos); // Combine open/close elements for empty terms, // so that they will be passed through correctly // as empty strings. for (var i = lst.length - 2; i > -1; i--) { if (lst[i].slice(1).indexOf("<") === -1) { var stub = lst[i].slice(0, 5); if (lst[i].slice(-2) !== "/>") { if (stub === "<term") { if (lst[i + 1].slice(0, 6) === "</term") { lst[i] = lst[i] + lst[i + 1]; lst = lst.slice(0, i + 1).concat(lst.slice(i + 2)); } } else if (["<sing", "<mult"].indexOf(stub) > -1) { if (lst[i].slice(-2) !== "/>" && lst[i + 1].slice(0, 1) === "<") { lst[i] = lst[i] + lst[i + 1]; lst = lst.slice(0, i + 1).concat(lst.slice(i + 2)); } } } } } return lst; } function _decodeHtmlEntities(str) { return str .split("&amp;").join("&") .split("&quot;").join("\"") .split("&gt;").join(">").split("&lt;").join("<") .replace(/&#([0-9]{1,6});/gi, function (match, numStr) { var num = parseInt(numStr, 10); // read num as normal number return String.fromCharCode(num); }) .replace(/&#x([a-f0-9]{1,6});/gi, function (match, numStr) { var num = parseInt(numStr, 16); // read num as hex return String.fromCharCode(num); }); } function _getAttributes(elem) { var m = elem.match(/([^\'\"= ]+)=(?:\"[^\"]*\"|\'[^\']*\')/g); if (m) { for (var i = 0, ilen = m.length; i < ilen; i++) { m[i] = m[i].replace(/=.*/, ""); } } return m; } function _getAttribute(elem, attr) { var rex = RegExp('^.*[ ]+' + attr + '=(\"(?:[^\"]*)\"|\'(?:[^\']*)\').*$'); var m = elem.match(rex); return m ? m[1].slice(1, -1) : null; } function _getTagName(elem) { var rex = RegExp("^<([^ />]+)"); var m = elem.match(rex); return m ? m[1] : null; } function _castObjectFromOpeningTag(elem) { var obj = {}; obj.name = _getTagName(elem); obj.attrs = {}; var attributes = _getAttributes(elem); if (attributes) { for (var i = 0, ilen = attributes.length; i < ilen; i++) { var attr = { name: attributes[i], value: _getAttribute(elem, attributes[i]) } obj.attrs[attr.name] = _decodeHtmlEntities(attr.value); } } obj.children = []; return obj; } function _extractTextFromCompositeElement(elem) { var m = elem.match(/^.*>([^<]*)<.*$/); return _decodeHtmlEntities(m[1]); } function _appendToChildren(obj) { _stack.slice(-1)[0].push(obj); } function _extendStackWithNewChildren(obj) { _stack.push(obj.children); } function processElement(elem) { var obj; if (elem.slice(1).indexOf('<') > -1) { // withtext var tag = elem.slice(0, elem.indexOf('>') + 1); obj = _castObjectFromOpeningTag(tag); obj.children = [_extractTextFromCompositeElement(elem)]; _appendToChildren(obj); } else if (elem.slice(-2) === '/>') { // singleton obj = _castObjectFromOpeningTag(elem); // Empty term as singleton if (_getTagName(elem) === 'term') { obj.children.push(''); } _appendToChildren(obj); } else if (elem.slice(0, 2) === '</') { // close _stack.pop(); } else { // open obj = _castObjectFromOpeningTag(elem); _appendToChildren(obj) _extendStackWithNewChildren(obj); } } var lst = _listifyString(str); for (var i = 0, ilen = lst.length; i < ilen; i++) { var elem = lst[i]; processElement(elem); } return _obj.children[0]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/46887/output.js
JavaScript
export var CSL = {}; /* * String parser for XML inputs */ CSL.parseXml = function(str) { var _obj_children = [], _stack = [ _obj_children ]; function _decodeHtmlEntities(str) { return str.split("&amp;").join("&").split("&quot;").join("\"").split("&gt;").join(">").split("&lt;").join("<").replace(/&#([0-9]{1,6});/gi, function(match, numStr) { return String.fromCharCode(parseInt(numStr, 10)); }).replace(/&#x([a-f0-9]{1,6});/gi, function(match, numStr) { return String.fromCharCode(parseInt(numStr, 16)); }); } function _getTagName(elem) { var rex = RegExp("^<([^ />]+)"), m = elem.match(rex); return m ? m[1] : null; } function _castObjectFromOpeningTag(elem) { var obj = {}; obj.name = _getTagName(elem), obj.attrs = {}; var attributes = function(elem) { var m = elem.match(/([^\'\"= ]+)=(?:\"[^\"]*\"|\'[^\']*\')/g); if (m) for(var i = 0, ilen = m.length; i < ilen; i++)m[i] = m[i].replace(/=.*/, ""); return m; }(elem); if (attributes) for(var i = 0, ilen = attributes.length; i < ilen; i++){ var attr = { name: attributes[i], value: function(elem, attr) { var rex = RegExp('^.*[ ]+' + attr + '=(\"(?:[^\"]*)\"|\'(?:[^\']*)\').*$'), m = elem.match(rex); return m ? m[1].slice(1, -1) : null; }(elem, attributes[i]) }; obj.attrs[attr.name] = _decodeHtmlEntities(attr.value); } return obj.children = [], obj; } function _appendToChildren(obj) { _stack.slice(-1)[0].push(obj); } for(var lst = function(str) { for(var lst = (str = str.split(/(?:\r\n|\n|\r)/).join(" ").replace(/>[ ]+</g, "><").replace(/<\!--.*?-->/g, "")).split("><"), stylePos = null, i = 0, ilen = lst.length; i < ilen; i++)i > 0 && (lst[i] = "<" + lst[i]), i < lst.length - 1 && (lst[i] = lst[i] + ">"), "number" != typeof stylePos && ("<style " === lst[i].slice(0, 7) || "<locale " == lst[i].slice(0, 8)) && (stylePos = i); lst = lst.slice(stylePos); // Combine open/close elements for empty terms, // so that they will be passed through correctly // as empty strings. for(var i = lst.length - 2; i > -1; i--)if (-1 === lst[i].slice(1).indexOf("<")) { var stub = lst[i].slice(0, 5); "/>" !== lst[i].slice(-2) && ("<term" === stub ? "</term" === lst[i + 1].slice(0, 6) && (lst[i] = lst[i] + lst[i + 1], lst = lst.slice(0, i + 1).concat(lst.slice(i + 2))) : [ "<sing", "<mult" ].indexOf(stub) > -1 && "/>" !== lst[i].slice(-2) && "<" === lst[i + 1].slice(0, 1) && (lst[i] = lst[i] + lst[i + 1], lst = lst.slice(0, i + 1).concat(lst.slice(i + 2)))); } return lst; }(str), i = 0, ilen = lst.length; i < ilen; i++)!function(elem) { var obj, obj1; elem.slice(1).indexOf('<') > -1 ? ((obj = _castObjectFromOpeningTag(elem.slice(0, elem.indexOf('>') + 1))).children = [ _decodeHtmlEntities(elem.match(/^.*>([^<]*)<.*$/)[1]) ], _appendToChildren(obj)) : '/>' === elem.slice(-2) ? (// singleton obj = _castObjectFromOpeningTag(elem), 'term' === _getTagName(elem) && obj.children.push(''), _appendToChildren(obj)) : '</' === elem.slice(0, 2) ? // close _stack.pop() : (_appendToChildren(// open obj = _castObjectFromOpeningTag(elem)), obj1 = obj, _stack.push(obj1.children)); }(lst[i]); return _obj_children[0]; };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/47005/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [502], { /***/ 9145: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "u": function () { return /* binding */ Ne; } /* harmony export */ }); /* unused harmony exports TooltipProvider, TooltipWrapper */ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7294); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5893); var Ke = Object.create; var me = Object.defineProperty; var Ie = Object.getOwnPropertyDescriptor; var Ve = Object.getOwnPropertyNames; var $e = Object.getPrototypeOf, ze = Object.prototype.hasOwnProperty; var je = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports); var Xe = (t, e, n, o) => { if (e && typeof e == "object" || typeof e == "function") for (let l of Ve(e)) !ze.call(t, l) && l !== n && me(t, l, { get: () => e[l], enumerable: !(o = Ie(e, l)) || o.enumerable }); return t }; var he = (t, e, n) => (n = t != null ? Ke($e(t)) : {}, Xe(e || !t || !t.__esModule ? me(n, "default", { }) : n, t)); var Ut = je(() => { }); var ae = he(Ut()); var Ue = () => { }, Yt = Ue; var qt = "DEFAULT_TOOLTIP_ID", Ze = { }, to = { }, ge = (0, react__WEBPACK_IMPORTED_MODULE_0__.createContext)(to); function at(t = qt) { } var Te = he(Ut()); var ao = typeof window != "undefined" ? react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect : react__WEBPACK_IMPORTED_MODULE_0__.useEffect, ve = ao; var Ee = async () => { }; var te = t => ({ }); var ee = function () { }; var oe = function (t) { return t === void 0 && (t = 0), { name: "offset", options: t, } }; var ne = function () { }; function V(t) { } function G(t) { } var Kt = Math.round; function Ce(t) { } function rt(t) { } var Ft; function ke() { if (Ft) return Ft; let t = navigator.userAgentData; return t && Array.isArray(t.brands) ? (Ft = t.brands.map(e => e.brand + "/" + e.version).join(" "), Ft) : navigator.userAgent } function Y(t) { } function ot(t) { } function It(t) { } function re(t) { let e = /firefox/i.test(ke()), n = G(t), o = n.backdropFilter || n.WebkitBackdropFilter; return n.transform !== "none" || n.perspective !== "none" || !!o && o !== "none" || e && n.willChange === "filter" || e && !!n.filter && n.filter !== "none" || ["transform", "perspective"].some(l => n.willChange.includes(l)) || ["paint", "layout", "strict", "content"].some(l => { let r = n.contain; return r != null && r.includes(l) }) } function le(t) { } function Tt(t) { } function nt(t) { } function kt(t) { } function Oe(t) { } function We(t, e) { } function _e(t, e, n) { } function Pe(t, e) { } function To(t, e, n) { } var xo = { getClippingRect: function (t) { let { element: e, boundary: n, rootBoundary: o, strategy: l } = t, r = n === "clippingAncestors" ? function (u, a) { let c = a.get(u); if (c) return c; let d = We(u).filter(w => ot(w) && rt(w) !== "body"), p = null, y = G(u).position === "fixed", g = y ? kt(u) : u; for (; ot(g) && !le(g);) { let w = G(g), T = re(g); w.position === "fixed" ? p = null : (y ? T || p : T || w.position !== "static" || !p || !["absolute", "fixed"].includes(p.position)) ? p = w : d = d.filter(x => x !== g), g = kt(g) } return a.set(u, d), d }(e, this._c) : [].concat(n), i = [...r, o], s = i[0], f = i.reduce(() => { }, _e(e, s, l)); return { width: f.right - f.left, height: f.bottom - f.top, x: f.left, y: f.top } }, convertOffsetParentRelativeRectToViewportRelativeRect: function () { }, isElement: ot, getDimensions: function (t) { return Y(t) ? Ce(t) : t.getBoundingClientRect() }, getOffsetParent: Pe, getDocumentElement: nt, getScale: Tt, async getElementRects(t) { let { reference: e, floating: n, strategy: o } = t, l = this.getOffsetParent || Pe, r = this.getDimensions; return { reference: To(e, await l(n), o), floating: { x: 0, y: 0, ...await r(n) } } }, getClientRects: t => Array.from(t.getClientRects()), isRTL: t => G(t).direction === "rtl" }; var se = (t, e, n) => { let o = new Map, l = { platform: xo, ...n }, r = { ...l.platform, _c: o }; return Ee(t, e, { ...l, platform: r }) }; var ce = async ({ elementReference: t = null, tooltipReference: e = null, tooltipArrowReference: n = null, place: o = "top", offset: l = 10, strategy: r = "absolute", middlewares: i = [oe(Number(l)), ee(), ne({ padding: 5 })] }) => { if (!t) return { tooltipStyles: {}, tooltipArrowStyles: {}, place: o }; if (e === null) return { tooltipStyles: {}, tooltipArrowStyles: {}, place: o }; let s = i; return n ? (s.push(te({ element: n, padding: 5 })), se(t, e, { placement: o, strategy: r, middleware: s }).then(() => { })) : se(t, e, { placement: "bottom", strategy: r, middleware: s }).then(({ x: f, y: u, placement: a }) => ({ tooltipStyles: { left: `${f}px`, top: `${u}px` }, tooltipArrowStyles: {}, place: a })) }; var it = { arrow: "react-tooltip__arrow_KtSkBq", clickable: "react-tooltip__clickable_KtSkBq", dark: "react-tooltip__dark_KtSkBq", error: "react-tooltip__error_KtSkBq", fixed: "react-tooltip__fixed_KtSkBq", info: "react-tooltip__info_KtSkBq", light: "react-tooltip__light_KtSkBq", noArrow: "react-tooltip__no-arrow_KtSkBq", show: "react-tooltip__show_KtSkBq", success: "react-tooltip__success_KtSkBq", tooltip: "react-tooltip__tooltip_KtSkBq", warning: "react-tooltip__warning_KtSkBq" }; var vo = ({ }) => { let E = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null), M = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null), C = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null), S = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null), [H, J] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(i), [Q, ut] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)({}), [pt, st] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)({}), [$, dt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(!1), [Dt, mt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(!1), vt = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null), { anchorRefs: Ht } = at(t), bt = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(!1), [et, Et] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)([]), ct = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(!1), ht = u || f.includes("click"); ve(() => (ct.current = !0, () => { ct.current = !1 }), []), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { if (!$) { let m = setTimeout(() => { mt(!1) }, 150); return () => { clearTimeout(m) } } return () => null }, [$]); let N = m => { ct.current && (m && mt(!0), setTimeout(() => { ct.current && (U == null || U(m), q === void 0 && dt(m)) }, 10)) }; (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { if (q === void 0) return () => null; q && mt(!0); return () => { } }, [q]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { }, [$]); let yt = (m = y) => { }, At = () => { }, Lt = () => { }, gt = ({ }) => { }, wt = m => { if (!m) return; let A = m, L = { x: A.clientX, y: A.clientY }; gt(L), vt.current = L }, pe = m => { At(m), y && yt() }, B = m => { var k; [document.querySelector(`[id='${l}']`), ...et].some(O => O == null ? void 0 : O.contains(m.target)) || (k = E.current) != null && k.contains(m.target) || N(!1) }, I = m => { m.key === "Escape" && N(!1) }, h = Yt(At, 50), D = Yt(Lt, 50); (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { var F, z; let m = new Set(Ht); et.forEach(j => { m.add({ current: j }) }); let A = document.querySelector(`[id='${l}']`); A && m.add({ current: A }), x && window.addEventListener("keydown", I); let L = []; ht ? (window.addEventListener("click", B), L.push({ event: "click", listener: pe })) : (L.push({ event: "mouseenter", listener: h }, { event: "mouseleave", listener: D }, { event: "focus", listener: h }, { event: "blur", listener: D }), g && L.push({ event: "mousemove", listener: wt })); let k = () => { bt.current = !0 }, O = () => { bt.current = !1, Lt() }; return T && !ht && ((F = E.current) == null || F.addEventListener("mouseenter", k), (z = E.current) == null || z.addEventListener("mouseleave", O)), L.forEach(({ event: j, listener: Bt }) => { m.forEach(Xt => { var Ot; (Ot = Xt.current) == null || Ot.addEventListener(j, Bt) }) }), () => { var j, Bt; ht && window.removeEventListener("click", B), x && window.removeEventListener("keydown", I), T && !ht && ((j = E.current) == null || j.removeEventListener("mouseenter", k), (Bt = E.current) == null || Bt.removeEventListener("mouseleave", O)), L.forEach(({ event: Xt, listener: Ot }) => { m.forEach(Fe => { var de; (de = Fe.current) == null || de.removeEventListener(Xt, Ot) }) }) } }, [Dt, Ht, et, x, f]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { let m = r != null ? r : ""; !m && t && (m = `[data-tooltip-id='${t}']`); let A = k => { let O = []; k.forEach(F => { if (F.type === "attributes" && F.attributeName === "data-tooltip-id" && F.target.getAttribute("data-tooltip-id") === t && O.push(F.target), F.type === "childList" && (_ && [...F.removedNodes].some(z => z.contains(_) ? (mt(!1), N(!1), b(null), !0) : !1), !!m)) try { let z = [...F.addedNodes].filter(j => j.nodeType === 1); O.push(...z.filter(j => j.matches(m))), O.push(...z.flatMap(j => [...j.querySelectorAll(m)])) } catch (z) { } }), O.length && Et(F => [...F, ...O]) }, L = new MutationObserver(A); return L.observe(document.body, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["data-tooltip-id"] }), () => { L.disconnect() } }, [t, r, _]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { if (P) { gt(P); return } if (g) { vt.current && gt(vt.current); return } ce({ place: i, offset: s, elementReference: _, tooltipReference: E.current, tooltipArrowReference: M.current, strategy: a, middlewares: c }).then(m => { ct.current && (Object.keys(m.tooltipStyles).length && ut(m.tooltipStyles), Object.keys(m.tooltipArrowStyles).length && st(m.tooltipArrowStyles), J(m.place)) }) }, [$, _, K, i, s, a, P]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { var L; let m = document.querySelector(`[id='${l}']`), A = [...et, m]; (!_ || !A.includes(_)) && b((L = et[0]) != null ? L : m) }, [l, et, _]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => () => { C.current && clearTimeout(C.current), S.current && clearTimeout(S.current) }, []), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { let m = r; if (!m && t && (m = `[data-tooltip-id='${t}']`), !!m) try { let A = Array.from(document.querySelectorAll(m)); Et(A) } catch (A) { Et([]) } }, [t, r]); let Z = K && $ && Object.keys(Q).length > 0; return Dt ? (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(d, { id: t, role: "tooltip", className: (0, ae.default)("react-tooltip", it.tooltip, it[o], e, `react-tooltip__place-${H}`, { [it.show]: Z, [it.fixed]: a === "fixed", [it.clickable]: T }), style: { ...v, ...Q }, ref: E, children: [K, (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(d, { className: (0, ae.default)("react-tooltip-arrow", it.arrow, n, { [it.noArrow]: w }), style: pt, ref: M })] }) : null }, fe = vo; var Ao = ({ content: t }) => (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", { dangerouslySetInnerHTML: { __html: t } }), ue = Ao; var Ro = ({ setIsOpen: _ }) => { let [M, C] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(o), [S, H] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(l), [J, Q] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(u), [ut, pt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(f), [st, $] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(a), [dt, Dt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(T), [mt, Mt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(x), [vt, Ht] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(v), [zt, bt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(c), [et, Et] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(p), [ct, ht] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(g), [N, jt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(null), { } = at(t); (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { }, [o]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { }, [l]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { }, [u]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { }, [yt, At, N, e, n]); let wt = d; return r ? wt = r({ }) : M && (wt = M), S && (wt = (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(ue, { })), (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(fe, { }) }, Ne = Ro; }) } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/47005/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 502 ], { /***/ 9145: /***/ function(m, S, h) { "use strict"; let E, k; /* harmony export */ h.d(S, { /* harmony export */ u: function() { return /* binding */ eu; } }); /* unused harmony exports TooltipProvider, TooltipWrapper */ /* harmony import */ var R, A = h(7294); /* harmony import */ var O = h(5893); var L = Object.create; var j = Object.defineProperty; var B = Object.getOwnPropertyDescriptor; var C = Object.getOwnPropertyNames; var N = Object.getPrototypeOf, $ = Object.prototype.hasOwnProperty; var D = (m, S, h, E)=>{ if (S && "object" == typeof S || "function" == typeof S) for (let k of C(S))$.call(m, k) || k === h || j(m, k, { get: ()=>S[k], enumerable: !(E = B(S, k)) || E.enumerable }); return m; }; var M = (m, S, h)=>(h = null != m ? L(N(m)) : {}, D(!S && m && m.__esModule ? h : j(h, "default", {}), m)); var F = (E = ()=>{}, ()=>(k || E((k = { exports: {} }).exports, k), k.exports)); var I = M(F()); var H = ()=>{}; (0, A.createContext)({}); function V(m = "DEFAULT_TOOLTIP_ID") {} M(F()); var W = "undefined" != typeof window ? A.useLayoutEffect : A.useEffect; var X = async ()=>{}; var Y = (m)=>({}); var z = function() {}; var G = function(m) { return void 0 === m && (m = 0), { name: "offset", options: m }; }; var J = function() {}; function Q(m) {} function Z(m) {} function ee(m) {} function et(m, S) {} var er = { getClippingRect: function(m) { var S, h, E; let { element: k, boundary: A, rootBoundary: O, strategy: L } = m, j = [ ..."clippingAncestors" === A ? function(m, S) { var h, E, k; let A = S.get(m); if (A) return A; let O = (void (h = 0)).filter((m)=>{ var S; return Z(m) && (S = 0, true); }), L = null, j = "fixed" === Q(m).position, B = j ? ee(m) : m; for(; Z(B) && (k = 0, true);){ let m = Q(B), S = function(m) { let S = /firefox/i.test(function() { if (R) return R; let m = navigator.userAgentData; return m && Array.isArray(m.brands) ? R = m.brands.map((m)=>m.brand + "/" + m.version).join(" ") : navigator.userAgent; }()), h = Q(m), E = h.backdropFilter || h.WebkitBackdropFilter; return "none" !== h.transform || "none" !== h.perspective || !!E && "none" !== E || S && "filter" === h.willChange || S && !!h.filter && "none" !== h.filter || [ "transform", "perspective" ].some((m)=>h.willChange.includes(m)) || [ "paint", "layout", "strict", "content" ].some((m)=>{ let S = h.contain; return null != S && S.includes(m); }); }(B); "fixed" === m.position ? L = null : (j ? S || L : S || "static" !== m.position || !L || ![ "absolute", "fixed" ].includes(L.position)) ? L = m : O = O.filter((m)=>m !== B), B = ee(B); } return S.set(m, O), O; }(k, this._c) : [].concat(A), O ], B = j[0], C = j.reduce(()=>{}, (S = 0, h = 0, void (E = 0))); return { width: C.right - C.left, height: C.bottom - C.top, x: C.left, y: C.top }; }, convertOffsetParentRelativeRectToViewportRelativeRect: function() {}, isElement: Z, getDimensions: function(m) { var S, h; return (S = 0), m.getBoundingClientRect(); }, getOffsetParent: et, getDocumentElement: function(m) {}, getScale: function(m) {}, async getElementRects (m) { var S, h, E; let { reference: k, floating: R, strategy: A } = m, O = this.getOffsetParent || et, L = this.getDimensions; return { reference: (S = 0, h = await O(R), void (E = 0)), floating: { x: 0, y: 0, ...await L(R) } }; }, getClientRects: (m)=>Array.from(m.getClientRects()), isRTL: (m)=>"rtl" === Q(m).direction }; var en = (m, S, h)=>{ let E = new Map, k = { platform: er, ...h }, R = { ...k.platform, _c: E }; return X(m, S, { ...k, platform: R }); }; var eo = async ({ elementReference: m = null, tooltipReference: S = null, tooltipArrowReference: h = null, place: E = "top", offset: k = 10, strategy: R = "absolute", middlewares: A = [ G(Number(k)), z(), J({ padding: 5 }) ] })=>{ if (!m) return { tooltipStyles: {}, tooltipArrowStyles: {}, place: E }; if (null === S) return { tooltipStyles: {}, tooltipArrowStyles: {}, place: E }; return h ? (A.push(Y({ element: h, padding: 5 })), en(m, S, { placement: E, strategy: R, middleware: A }).then(()=>{})) : en(m, S, { placement: "bottom", strategy: R, middleware: A }).then(({ x: m, y: S, placement: h })=>({ tooltipStyles: { left: `${m}px`, top: `${S}px` }, tooltipArrowStyles: {}, place: h })); }; var el = { arrow: "react-tooltip__arrow_KtSkBq", clickable: "react-tooltip__clickable_KtSkBq", dark: "react-tooltip__dark_KtSkBq", error: "react-tooltip__error_KtSkBq", fixed: "react-tooltip__fixed_KtSkBq", info: "react-tooltip__info_KtSkBq", light: "react-tooltip__light_KtSkBq", noArrow: "react-tooltip__no-arrow_KtSkBq", show: "react-tooltip__show_KtSkBq", success: "react-tooltip__success_KtSkBq", tooltip: "react-tooltip__tooltip_KtSkBq", warning: "react-tooltip__warning_KtSkBq" }; var ei = ({})=>{ let m = (0, A.useRef)(null), S = (0, A.useRef)(null), h = (0, A.useRef)(null), E = (0, A.useRef)(null), [k, R] = (0, A.useState)(i), [L, j] = (0, A.useState)({}), [B, C] = (0, A.useState)({}), [N, $] = (0, A.useState)(!1), [D, M] = (0, A.useState)(!1), F = (0, A.useRef)(null), { anchorRefs: X } = V(t), Y = (0, A.useRef)(!1), [z, G] = (0, A.useState)([]), J = (0, A.useRef)(!1), Q = u || f.includes("click"); W(()=>(J.current = !0, ()=>{ J.current = !1; }), []), (0, A.useEffect)(()=>{ if (!N) { let m = setTimeout(()=>{ M(!1); }, 150); return ()=>{ clearTimeout(m); }; } return ()=>null; }, [ N ]); let Z = (m)=>{ J.current && (m && M(!0), setTimeout(()=>{ J.current && (null == U || U(m), void 0 === q && $(m)); }, 10)); }; (0, A.useEffect)(()=>{ if (void 0 === q) return ()=>null; q && M(!0); return ()=>{}; }, [ q ]), (0, A.useEffect)(()=>{}, [ N ]); let ee = (m = y)=>{}, et = ()=>{}, er = ()=>{}, en = ({})=>{}, ei = (m)=>{ if (!m) return; let S = { x: m.clientX, y: m.clientY }; en(S), F.current = S; }, ea = (m)=>{ et(m), y && ee(); }, eu = (S)=>{ var h; [ document.querySelector(`[id='${l}']`), ...z ].some((m)=>null == m ? void 0 : m.contains(S.target)) || null != (h = m.current) && h.contains(S.target) || Z(!1); }, es = (m)=>{ "Escape" === m.key && Z(!1); }, ec = H(et, 50), ef = H(er, 50); (0, A.useEffect)(()=>{ var S, h; let E = new Set(X); z.forEach((m)=>{ E.add({ current: m }); }); let k = document.querySelector(`[id='${l}']`); k && E.add({ current: k }), x && window.addEventListener("keydown", es); let R = []; Q ? (window.addEventListener("click", eu), R.push({ event: "click", listener: ea })) : (R.push({ event: "mouseenter", listener: ec }, { event: "mouseleave", listener: ef }, { event: "focus", listener: ec }, { event: "blur", listener: ef }), g && R.push({ event: "mousemove", listener: ei })); let A = ()=>{ Y.current = !0; }, O = ()=>{ Y.current = !1, er(); }; return T && !Q && (null == (S = m.current) || S.addEventListener("mouseenter", A), null == (h = m.current) || h.addEventListener("mouseleave", O)), R.forEach(({ event: m, listener: S })=>{ E.forEach((h)=>{ var E; null == (E = h.current) || E.addEventListener(m, S); }); }), ()=>{ var S, h; Q && window.removeEventListener("click", eu), x && window.removeEventListener("keydown", es), T && !Q && (null == (S = m.current) || S.removeEventListener("mouseenter", A), null == (h = m.current) || h.removeEventListener("mouseleave", O)), R.forEach(({ event: m, listener: S })=>{ E.forEach((h)=>{ var E; null == (E = h.current) || E.removeEventListener(m, S); }); }); }; }, [ D, X, z, x, f ]), (0, A.useEffect)(()=>{ let m = null != r ? r : ""; !m && t && (m = `[data-tooltip-id='${t}']`); let S = new MutationObserver((S)=>{ let h = []; S.forEach((S)=>{ if ("attributes" === S.type && "data-tooltip-id" === S.attributeName && S.target.getAttribute("data-tooltip-id") === t && h.push(S.target), "childList" === S.type && (_ && [ ...S.removedNodes ].some((m)=>m.contains(_) ? (M(!1), Z(!1), b(null), !0) : !1), !!m)) try { let E = [ ...S.addedNodes ].filter((m)=>1 === m.nodeType); h.push(...E.filter((S)=>S.matches(m))), h.push(...E.flatMap((S)=>[ ...S.querySelectorAll(m) ])); } catch (m) {} }), h.length && G((m)=>[ ...m, ...h ]); }); return S.observe(document.body, { childList: !0, subtree: !0, attributes: !0, attributeFilter: [ "data-tooltip-id" ] }), ()=>{ S.disconnect(); }; }, [ t, r, _ ]), (0, A.useEffect)(()=>{ if (P) { en(P); return; } if (g) { F.current && en(F.current); return; } eo({ place: i, offset: s, elementReference: _, tooltipReference: m.current, tooltipArrowReference: S.current, strategy: a, middlewares: c }).then((m)=>{ J.current && (Object.keys(m.tooltipStyles).length && j(m.tooltipStyles), Object.keys(m.tooltipArrowStyles).length && C(m.tooltipArrowStyles), R(m.place)); }); }, [ N, _, K, i, s, a, P ]), (0, A.useEffect)(()=>{ var m; let S = document.querySelector(`[id='${l}']`), h = [ ...z, S ]; _ && h.includes(_) || b(null != (m = z[0]) ? m : S); }, [ l, z, _ ]), (0, A.useEffect)(()=>()=>{ h.current && clearTimeout(h.current), E.current && clearTimeout(E.current); }, []), (0, A.useEffect)(()=>{ let m = r; if (!m && t && (m = `[data-tooltip-id='${t}']`), !!m) try { let S = Array.from(document.querySelectorAll(m)); G(S); } catch (m) { G([]); } }, [ t, r ]); let ep = K && N && Object.keys(L).length > 0; return D ? (0, O.jsxs)(d, { id: t, role: "tooltip", className: (0, I.default)("react-tooltip", el.tooltip, el[o], e, `react-tooltip__place-${k}`, { [el.show]: ep, [el.fixed]: "fixed" === a, [el.clickable]: T }), style: { ...v, ...L }, ref: m, children: [ K, (0, O.jsx)(d, { className: (0, I.default)("react-tooltip-arrow", el.arrow, n, { [el.noArrow]: w }), style: B, ref: S }) ] }) : null; }; var ea = ({ content: m })=>(0, O.jsx)("span", { dangerouslySetInnerHTML: { __html: m } }); var eu = ({ setIsOpen: m })=>{ let [S, h] = (0, A.useState)(o), [E, k] = (0, A.useState)(l), [R, L] = (0, A.useState)(u), [j, B] = (0, A.useState)(f), [C, N] = (0, A.useState)(a), [$, D] = (0, A.useState)(T), [M, F] = (0, A.useState)(x), [I, H] = (0, A.useState)(v), [W, X] = (0, A.useState)(c), [Y, z] = (0, A.useState)(p), [G, J] = (0, A.useState)(g), [Q, Z] = (0, A.useState)(null), {} = V(t); (0, A.useEffect)(()=>{}, [ o ]), (0, A.useEffect)(()=>{}, [ l ]), (0, A.useEffect)(()=>{}, [ u ]), (0, A.useEffect)(()=>{}, [ yt, At, Q, e, n ]); let ee = d; return r && r({}), E && (0, O.jsx)(ea, {}), (0, O.jsx)(ei, {}); }; } } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/54192/1/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [931], { /***/ 821: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { ClientCompoenent: function () { return /* binding */ ClientCompoenent; } }); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/jsx-runtime.js var jsx_runtime = __webpack_require__(7437); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/index.js var react = __webpack_require__(2265);; // CONCATENATED MODULE: ./app/ContextExample.tsx const Context = /*#__PURE__*/ (0, react.createContext)({}); const ContextProvider = (param) => { let { children } = param; return /*#__PURE__*/ (0, jsx_runtime.jsx)(Context.Provider, { value: {}, children: children }); }; const ContextDemo = { Provider: ContextProvider }; ; // CONCATENATED MODULE: ./app/ClientCompoenent.tsx /* __next_internal_client_entry_do_not_use__ ClientCompoenent auto */ const ClientCompoenent = () => { const [count, setCount] = (0, react.useState)(0); return /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)(ContextDemo.Provider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)("input", {}) }), /*#__PURE__*/ (0, jsx_runtime.jsx)("button", { onClick: () => { console.log("click"); setCount(count + 1); }, children: "+1 (rerender)" }) ] }); }; /***/ }), }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ __webpack_require__.O(0, [971, 596, 744], function () { return __webpack_exec__(8835); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/54192/1/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 931 ], { /***/ 821: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { ClientCompoenent: function() { return /* binding */ ClientCompoenent; } }); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/jsx-runtime.js var jsx_runtime = __webpack_require__(7437), react = __webpack_require__(2265); const Context = /*#__PURE__*/ (0, react.createContext)({}), ContextDemo_Provider = (param)=>{ let { children } = param; return /*#__PURE__*/ (0, jsx_runtime.jsx)(Context.Provider, { value: {}, children: children }); }, ClientCompoenent = ()=>{ const [count, setCount] = (0, react.useState)(0); return /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)(ContextDemo_Provider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)("input", {}) }), /*#__PURE__*/ (0, jsx_runtime.jsx)("button", { onClick: ()=>{ console.log("click"), setCount(count + 1); }, children: "+1 (rerender)" }) ] }); }; /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 971, 596, 744 ], function() { return __webpack_require__(__webpack_require__.s = 8835); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/54192/2/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [931], { /***/ 821: /***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { ClientCompoenent: function () { return /* binding */ ClientCompoenent; } }); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/jsx-runtime.js var jsx_runtime = __webpack_require__(7437); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/index.js var react = __webpack_require__(2265);; // CONCATENATED MODULE: ./app/ContextExample.tsx const Context = /*#__PURE__*/ (0, react.createContext)({}); const ContextProvider = (param) => { let { children } = param; return /*#__PURE__*/ (0, jsx_runtime.jsx)(Context.Provider, { value: {}, children: children }); }; ; // CONCATENATED MODULE: ./app/ClientCompoenent.tsx /* __next_internal_client_entry_do_not_use__ ClientCompoenent auto */ const ClientCompoenent = () => { const [count, setCount] = (0, react.useState)(0); return /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)(ContextProvider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)("input", {}) }), /*#__PURE__*/ (0, jsx_runtime.jsx)("button", { onClick: () => { console.log("click"); setCount(count + 1); }, children: "+1 (rerender)" }) ] }); }; /***/ }), }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ __webpack_require__.O(0, [971, 596, 744], function () { return __webpack_exec__(8835); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/54192/2/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 931 ], { /***/ 821: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { ClientCompoenent: function() { return /* binding */ ClientCompoenent; } }); // EXTERNAL MODULE: ./node_modules/next/dist/compiled/react/jsx-runtime.js var jsx_runtime = __webpack_require__(7437), react = __webpack_require__(2265); const Context = /*#__PURE__*/ (0, react.createContext)({}), ContextProvider = (param)=>{ let { children } = param; return /*#__PURE__*/ (0, jsx_runtime.jsx)(Context.Provider, { value: {}, children: children }); }, ClientCompoenent = ()=>{ const [count, setCount] = (0, react.useState)(0); return /*#__PURE__*/ (0, jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [ /*#__PURE__*/ (0, jsx_runtime.jsx)(ContextProvider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)("input", {}) }), /*#__PURE__*/ (0, jsx_runtime.jsx)("button", { onClick: ()=>{ console.log("click"), setCount(count + 1); }, children: "+1 (rerender)" }) ] }); }; /***/ } }, /******/ function(__webpack_require__) { /******/ __webpack_require__.O(0, [ 971, 596, 744 ], function() { return __webpack_require__(__webpack_require__.s = 8835); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/56408/input.js
JavaScript
exports.id = 675; exports.ids = [675]; exports.modules = { /***/ 4622: /***/ (function (__unused_webpack_module, exports, __webpack_require__) { ! function (e, t) { true ? t(exports, __webpack_require__(9885), __webpack_require__(5601)) : 0 }(this, (function (e, t, n) { "use strict"; function r(e) { return e && "object" == typeof e && "default" in e ? e : { default: e } } var o = r(t), i = r(n); function a(e, t) { var n = Object.keys(e); if (Object.getOwnPropertySymbols) { var r = Object.getOwnPropertySymbols(e); t && (r = r.filter((function (t) { return Object.getOwnPropertyDescriptor(e, t).enumerable }))), n.push.apply(n, r) } return n } function c(e) { for (var t = 1; t < arguments.length; t++) { var n = null != arguments[t] ? arguments[t] : {}; t % 2 ? a(Object(n), !0).forEach((function (t) { u(e, t, n[t]) })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : a(Object(n)).forEach((function (t) { Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t)) })) } return e } function u(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } function l(e, t) { if (null == e) return {}; var n, r, o = function (e, t) { if (null == e) return {}; var n, r, o = {}, i = Object.keys(e); for (r = 0; r < i.length; r++) n = i[r], t.indexOf(n) >= 0 || (o[n] = e[n]); return o }(e, t); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(e); for (r = 0; r < i.length; r++) n = i[r], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[n]) } return o } function s(e, t) { return function (e) { if (Array.isArray(e)) return e }(e) || function (e, t) { var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (null == n) return; var r, o, i = [], a = !0, c = !1; try { for (n = n.call(e); !(a = (r = n.next()).done) && (i.push(r.value), !t || i.length !== t); a = !0); } catch (e) { c = !0, o = e } finally { try { a || null == n.return || n.return() } finally { if (c) throw o } } return i }(e, t) || p(e, t) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") }() } function f(e) { return function (e) { if (Array.isArray(e)) return d(e) }(e) || function (e) { if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e) }(e) || p(e) || function () { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") }() } function p(e, t) { if (e) { if ("string" == typeof e) return d(e, t); var n = Object.prototype.toString.call(e).slice(8, -1); return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? d(e, t) : void 0 } } function d(e, t) { (null == t || t > e.length) && (t = e.length); for (var n = 0, r = new Array(t); n < t; n++) r[n] = e[n]; return r } function v(e, t, n, r) { return new (n || (n = Promise))((function (o, i) { function a(e) { try { u(r.next(e)) } catch (e) { i(e) } } function c(e) { try { u(r.throw(e)) } catch (e) { i(e) } } function u(e) { var t; e.done ? o(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(a, c) } u((r = r.apply(e, t || [])).next()) })) } function m(e, t) { var n, r, o, i, a = { label: 0, sent: function () { if (1 & o[0]) throw o[1]; return o[1] }, trys: [], ops: [] }; return i = { next: c(0), throw: c(1), return: c(2) }, "function" == typeof Symbol && (i[Symbol.iterator] = function () { return this }), i; function c(i) { return function (c) { return function (i) { if (n) throw new TypeError("Generator is already executing."); for (; a;) try { if (n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o; switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) { case 0: case 1: o = i; break; case 4: return a.label++, { value: i[1], done: !1 }; case 5: a.label++, r = i[1], i = [0]; continue; case 7: i = a.ops.pop(), a.trys.pop(); continue; default: if (!(o = a.trys, (o = o.length > 0 && o[o.length - 1]) || 6 !== i[0] && 2 !== i[0])) { a = 0; continue } if (3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) { a.label = i[1]; break } if (6 === i[0] && a.label < o[1]) { a.label = o[1], o = i; break } if (o && a.label < o[2]) { a.label = o[2], a.ops.push(i); break } o[2] && a.ops.pop(), a.trys.pop(); continue } i = t.call(e, a) } catch (e) { i = [6, e], r = 0 } finally { n = o = 0 } if (5 & i[0]) throw i[1]; return { value: i[0] ? i[1] : void 0, done: !0 } }([i, c]) } } } function g(e, t) { var n = "function" == typeof Symbol && e[Symbol.iterator]; if (!n) return e; var r, o, i = n.call(e), a = []; try { for (; (void 0 === t || t-- > 0) && !(r = i.next()).done;) a.push(r.value) } catch (e) { o = { error: e } } finally { try { r && !r.done && (n = i.return) && n.call(i) } finally { if (o) throw o.error } } return a } function y(e, t, n) { if (n || 2 === arguments.length) for (var r, o = 0, i = t.length; o < i; o++) !r && o in t || (r || (r = Array.prototype.slice.call(t, 0, o)), r[o] = t[o]); return e.concat(r || Array.prototype.slice.call(t)) } var b = new Map([ ["aac", "audio/aac"], ["abw", "application/x-abiword"], ["arc", "application/x-freearc"], ["avif", "image/avif"], ["avi", "video/x-msvideo"], ["azw", "application/vnd.amazon.ebook"], ["bin", "application/octet-stream"], ["bmp", "image/bmp"], ["bz", "application/x-bzip"], ["bz2", "application/x-bzip2"], ["cda", "application/x-cdf"], ["csh", "application/x-csh"], ["css", "text/css"], ["csv", "text/csv"], ["doc", "application/msword"], ["docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"], ["eot", "application/vnd.ms-fontobject"], ["epub", "application/epub+zip"], ["gz", "application/gzip"], ["gif", "image/gif"], ["heic", "image/heic"], ["heif", "image/heif"], ["htm", "text/html"], ["html", "text/html"], ["ico", "image/vnd.microsoft.icon"], ["ics", "text/calendar"], ["jar", "application/java-archive"], ["jpeg", "image/jpeg"], ["jpg", "image/jpeg"], ["js", "text/javascript"], ["json", "application/json"], ["jsonld", "application/ld+json"], ["mid", "audio/midi"], ["midi", "audio/midi"], ["mjs", "text/javascript"], ["mp3", "audio/mpeg"], ["mp4", "video/mp4"], ["mpeg", "video/mpeg"], ["mpkg", "application/vnd.apple.installer+xml"], ["odp", "application/vnd.oasis.opendocument.presentation"], ["ods", "application/vnd.oasis.opendocument.spreadsheet"], ["odt", "application/vnd.oasis.opendocument.text"], ["oga", "audio/ogg"], ["ogv", "video/ogg"], ["ogx", "application/ogg"], ["opus", "audio/opus"], ["otf", "font/otf"], ["png", "image/png"], ["pdf", "application/pdf"], ["php", "application/x-httpd-php"], ["ppt", "application/vnd.ms-powerpoint"], ["pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"], ["rar", "application/vnd.rar"], ["rtf", "application/rtf"], ["sh", "application/x-sh"], ["svg", "image/svg+xml"], ["swf", "application/x-shockwave-flash"], ["tar", "application/x-tar"], ["tif", "image/tiff"], ["tiff", "image/tiff"], ["ts", "video/mp2t"], ["ttf", "font/ttf"], ["txt", "text/plain"], ["vsd", "application/vnd.visio"], ["wav", "audio/wav"], ["weba", "audio/webm"], ["webm", "video/webm"], ["webp", "image/webp"], ["woff", "font/woff"], ["woff2", "font/woff2"], ["xhtml", "application/xhtml+xml"], ["xls", "application/vnd.ms-excel"], ["xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"], ["xml", "application/xml"], ["xul", "application/vnd.mozilla.xul+xml"], ["zip", "application/zip"], ["7z", "application/x-7z-compressed"], ["mkv", "video/x-matroska"], ["mov", "video/quicktime"], ["msg", "application/vnd.ms-outlook"] ]); function h(e, t) { var n = function (e) { var t = e.name; if (t && -1 !== t.lastIndexOf(".") && !e.type) { var n = t.split(".").pop().toLowerCase(), r = b.get(n); r && Object.defineProperty(e, "type", { value: r, writable: !1, configurable: !1, enumerable: !0 }) } return e }(e); if ("string" != typeof n.path) { var r = e.webkitRelativePath; Object.defineProperty(n, "path", { value: "string" == typeof t ? t : "string" == typeof r && r.length > 0 ? r : e.name, writable: !1, configurable: !1, enumerable: !0 }) } return n } var w = [".DS_Store", "Thumbs.db"]; function D(e) { return "object" == typeof e && null !== e } function x(e) { return O(e.target.files).map((function (e) { return h(e) })) } function F(e) { return v(this, void 0, void 0, (function () { return m(this, (function (t) { switch (t.label) { case 0: return [4, Promise.all(e.map((function (e) { return e.getFile() })))]; case 1: return [2, t.sent().map((function (e) { return h(e) }))] } })) })) } function j(e, t) { return v(this, void 0, void 0, (function () { var n; return m(this, (function (r) { switch (r.label) { case 0: return e.items ? (n = O(e.items).filter((function (e) { return "file" === e.kind })), "drop" !== t ? [2, n] : [4, Promise.all(n.map(E))]) : [3, 2]; case 1: return [2, A(k(r.sent()))]; case 2: return [2, A(O(e.files).map((function (e) { return h(e) })))] } })) })) } function A(e) { return e.filter((function (e) { return -1 === w.indexOf(e.name) })) } function O(e) { if (null === e) return []; for (var t = [], n = 0; n < e.length; n++) { var r = e[n]; t.push(r) } return t } function E(e) { if ("function" != typeof e.webkitGetAsEntry) return P(e); var t = e.webkitGetAsEntry(); return t && t.isDirectory ? C(t) : P(e) } function k(e) { return e.reduce((function (e, t) { return y(y([], g(e), !1), g(Array.isArray(t) ? k(t) : [t]), !1) }), []) } function P(e) { var t = e.getAsFile(); if (!t) return Promise.reject("".concat(e, " is not a File")); var n = h(t); return Promise.resolve(n) } function S(e) { return v(this, void 0, void 0, (function () { return m(this, (function (t) { return [2, e.isDirectory ? C(e) : z(e)] })) })) } function C(e) { var t = e.createReader(); return new Promise((function (e, n) { var r = []; ! function o() { var i = this; t.readEntries((function (t) { return v(i, void 0, void 0, (function () { var i, a, c; return m(this, (function (u) { switch (u.label) { case 0: if (t.length) return [3, 5]; u.label = 1; case 1: return u.trys.push([1, 3, , 4]), [4, Promise.all(r)]; case 2: return i = u.sent(), e(i), [3, 4]; case 3: return a = u.sent(), n(a), [3, 4]; case 4: return [3, 6]; case 5: c = Promise.all(t.map(S)), r.push(c), o(), u.label = 6; case 6: return [2] } })) })) }), (function (e) { n(e) })) }() })) } function z(e) { return v(this, void 0, void 0, (function () { return m(this, (function (t) { return [2, new Promise((function (t, n) { e.file((function (n) { var r = h(n, e.fullPath); t(r) }), (function (e) { n(e) })) }))] })) })) } var R = "file-invalid-type", T = "file-too-large", I = "file-too-small", M = "too-many-files", L = { FileInvalidType: R, FileTooLarge: T, FileTooSmall: I, TooManyFiles: M }, _ = function (e) { e = Array.isArray(e) && 1 === e.length ? e[0] : e; var t = Array.isArray(e) ? "one of ".concat(e.join(", ")) : e; return { code: R, message: "File type must be ".concat(t) } }, B = function (e) { return { code: T, message: "File is larger than ".concat(e, " ").concat(1 === e ? "byte" : "bytes") } }, K = function (e) { return { code: I, message: "File is smaller than ".concat(e, " ").concat(1 === e ? "byte" : "bytes") } }, q = { code: M, message: "Too many files" }; function U(e, t) { var n = "application/x-moz-file" === e.type || function (e, t) { if (e && t) { var n = Array.isArray(t) ? t : t.split(","), r = e.name || "", o = (e.type || "").toLowerCase(), i = o.replace(/\/.*$/, ""); return n.some((function (e) { var t = e.trim().toLowerCase(); return "." === t.charAt(0) ? r.toLowerCase().endsWith(t) : t.endsWith("/*") ? i === t.replace(/\/.*$/, "") : o === t })) } return !0 }(e, t); return [n, n ? null : _(t)] } function W(e, t, n) { if ($(e.size)) if ($(t) && $(n)) { if (e.size > n) return [!1, B(n)]; if (e.size < t) return [!1, K(t)] } else { if ($(t) && e.size < t) return [!1, K(t)]; if ($(n) && e.size > n) return [!1, B(n)] } return [!0, null] } function $(e) { return null != e } function G(e) { var t = e.files, n = e.accept, r = e.minSize, o = e.maxSize, i = e.multiple, a = e.maxFiles, c = e.validator; return !(!i && t.length > 1 || i && a >= 1 && t.length > a) && t.every((function (e) { var t = s(U(e, n), 1)[0], i = s(W(e, r, o), 1)[0], a = c ? c(e) : null; return t && i && !a })) } function H(e) { return "function" == typeof e.isPropagationStopped ? e.isPropagationStopped() : void 0 !== e.cancelBubble && e.cancelBubble } function N(e) { return e.dataTransfer ? Array.prototype.some.call(e.dataTransfer.types, (function (e) { return "Files" === e || "application/x-moz-file" === e })) : !!e.target && !!e.target.files } function Y(e) { e.preventDefault() } function J(e) { return -1 !== e.indexOf("MSIE") || -1 !== e.indexOf("Trident/") } function Q(e) { return -1 !== e.indexOf("Edge/") } function V() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window.navigator.userAgent; return J(e) || Q(e) } function X() { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; return function (e) { for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), o = 1; o < n; o++) r[o - 1] = arguments[o]; return t.some((function (t) { return !H(e) && t && t.apply(void 0, [e].concat(r)), H(e) })) } } function Z() { return "showOpenFilePicker" in window } function ee(e) { return $(e) ? [{ description: "Files", accept: Object.entries(e).filter((function (e) { var t = s(e, 2), n = t[0], r = t[1], o = !0; return oe(n) || (console.warn('Skipped "'.concat(n, '" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')), o = !1), Array.isArray(r) && r.every(ie) || (console.warn('Skipped "'.concat(n, '" because an invalid file extension was provided.')), o = !1), o })).reduce((function (e, t) { var n = s(t, 2), r = n[0], o = n[1]; return c(c({}, e), {}, u({}, r, o)) }), {}) }] : e } function te(e) { if ($(e)) return Object.entries(e).reduce((function (e, t) { var n = s(t, 2), r = n[0], o = n[1]; return [].concat(f(e), [r], f(o)) }), []).filter((function (e) { return oe(e) || ie(e) })).join(",") } function ne(e) { return e instanceof DOMException && ("AbortError" === e.name || e.code === e.ABORT_ERR) } function re(e) { return e instanceof DOMException && ("SecurityError" === e.name || e.code === e.SECURITY_ERR) } function oe(e) { return "audio/*" === e || "video/*" === e || "image/*" === e || "text/*" === e || /\w+\/[-+.\w]+/g.test(e) } function ie(e) { return /^.*\.[\w]+$/.test(e) } var ae = ["children"], ce = ["open"], ue = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"], le = ["refKey", "onChange", "onClick"], se = t.forwardRef((function (e, n) { var r = e.children, i = de(l(e, ae)), a = i.open, u = l(i, ce); return t.useImperativeHandle(n, (function () { return { open: a } }), [a]), o.default.createElement(t.Fragment, null, r(c(c({}, u), {}, { open: a }))) })); se.displayName = "Dropzone"; var fe = { disabled: !1, getFilesFromEvent: function (e) { return v(this, void 0, void 0, (function () { return m(this, (function (t) { return D(e) && D(e.dataTransfer) ? [2, j(e.dataTransfer, e.type)] : function (e) { return D(e) && D(e.target) }(e) ? [2, x(e)] : Array.isArray(e) && e.every((function (e) { return "getFile" in e && "function" == typeof e.getFile })) ? [2, F(e)] : [2, []] })) })) }, maxSize: 1 / 0, minSize: 0, multiple: !0, maxFiles: 0, preventDropOnDocument: !0, noClick: !1, noKeyboard: !1, noDrag: !1, noDragEventsBubbling: !1, validator: null, useFsAccessApi: !0, autoFocus: !1 }; se.defaultProps = fe, se.propTypes = { children: i.default.func, accept: i.default.objectOf(i.default.arrayOf(i.default.string)), multiple: i.default.bool, preventDropOnDocument: i.default.bool, noClick: i.default.bool, noKeyboard: i.default.bool, noDrag: i.default.bool, noDragEventsBubbling: i.default.bool, minSize: i.default.number, maxSize: i.default.number, maxFiles: i.default.number, disabled: i.default.bool, getFilesFromEvent: i.default.func, onFileDialogCancel: i.default.func, onFileDialogOpen: i.default.func, useFsAccessApi: i.default.bool, autoFocus: i.default.bool, onDragEnter: i.default.func, onDragLeave: i.default.func, onDragOver: i.default.func, onDrop: i.default.func, onDropAccepted: i.default.func, onDropRejected: i.default.func, onError: i.default.func, validator: i.default.func }; var pe = { isFocused: !1, isFileDialogActive: !1, isDragActive: !1, isDragAccept: !1, isDragReject: !1, acceptedFiles: [], fileRejections: [] }; function de() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, n = c(c({}, fe), e), r = n.accept, o = n.disabled, i = n.getFilesFromEvent, a = n.maxSize, p = n.minSize, d = n.multiple, v = n.maxFiles, m = n.onDragEnter, g = n.onDragLeave, y = n.onDragOver, b = n.onDrop, h = n.onDropAccepted, w = n.onDropRejected, D = n.onFileDialogCancel, x = n.onFileDialogOpen, F = n.useFsAccessApi, j = n.autoFocus, A = n.preventDropOnDocument, O = n.noClick, E = n.noKeyboard, k = n.noDrag, P = n.noDragEventsBubbling, S = n.onError, C = n.validator, z = t.useMemo((function () { return te(r) }), [r]), R = t.useMemo((function () { return ee(r) }), [r]), T = t.useMemo((function () { return "function" == typeof x ? x : me }), [x]), I = t.useMemo((function () { return "function" == typeof D ? D : me }), [D]), M = t.useRef(null), L = t.useRef(null), _ = t.useReducer(ve, pe), B = s(_, 2), K = B[0], $ = B[1], J = K.isFocused, Q = K.isFileDialogActive, oe = t.useRef("undefined" != typeof window && window.isSecureContext && F && Z()), ie = function () { !oe.current && Q && setTimeout((function () { L.current && (L.current.files.length || ($({ type: "closeDialog" }), I())) }), 300) }; t.useEffect((function () { return window.addEventListener("focus", ie, !1), function () { window.removeEventListener("focus", ie, !1) } }), [L, Q, I, oe]); var ae = t.useRef([]), ce = function (e) { M.current && M.current.contains(e.target) || (e.preventDefault(), ae.current = []) }; t.useEffect((function () { return A && (document.addEventListener("dragover", Y, !1), document.addEventListener("drop", ce, !1)), function () { A && (document.removeEventListener("dragover", Y), document.removeEventListener("drop", ce)) } }), [M, A]), t.useEffect((function () { return !o && j && M.current && M.current.focus(), function () { } }), [M, j, o]); var se = t.useCallback((function (e) { S ? S(e) : console.error(e) }), [S]), de = t.useCallback((function (e) { e.preventDefault(), e.persist(), ke(e), ae.current = [].concat(f(ae.current), [e.target]), N(e) && Promise.resolve(i(e)).then((function (t) { if (!H(e) || P) { var n = t.length, r = n > 0 && G({ files: t, accept: z, minSize: p, maxSize: a, multiple: d, maxFiles: v, validator: C }); $({ isDragAccept: r, isDragReject: n > 0 && !r, isDragActive: !0, type: "setDraggedFiles" }), m && m(e) } })).catch((function (e) { return se(e) })) }), [i, m, se, P, z, p, a, d, v, C]), ge = t.useCallback((function (e) { e.preventDefault(), e.persist(), ke(e); var t = N(e); if (t && e.dataTransfer) try { e.dataTransfer.dropEffect = "copy" } catch (e) { } return t && y && y(e), !1 }), [y, P]), ye = t.useCallback((function (e) { e.preventDefault(), e.persist(), ke(e); var t = ae.current.filter((function (e) { return M.current && M.current.contains(e) })), n = t.indexOf(e.target); - 1 !== n && t.splice(n, 1), ae.current = t, t.length > 0 || ($({ type: "setDraggedFiles", isDragActive: !1, isDragAccept: !1, isDragReject: !1 }), N(e) && g && g(e)) }), [M, g, P]), be = t.useCallback((function (e, t) { var n = [], r = []; e.forEach((function (e) { var t = s(U(e, z), 2), o = t[0], i = t[1], c = s(W(e, p, a), 2), u = c[0], l = c[1], f = C ? C(e) : null; if (o && u && !f) n.push(e); else { var d = [i, l]; f && (d = d.concat(f)), r.push({ file: e, errors: d.filter((function (e) { return e })) }) } })), (!d && n.length > 1 || d && v >= 1 && n.length > v) && (n.forEach((function (e) { r.push({ file: e, errors: [q] }) })), n.splice(0)), $({ acceptedFiles: n, fileRejections: r, type: "setFiles" }), b && b(n, r, t), r.length > 0 && w && w(r, t), n.length > 0 && h && h(n, t) }), [$, d, z, p, a, v, b, h, w, C]), he = t.useCallback((function (e) { e.preventDefault(), e.persist(), ke(e), ae.current = [], N(e) && Promise.resolve(i(e)).then((function (t) { H(e) && !P || be(t, e) })).catch((function (e) { return se(e) })), $({ type: "reset" }) }), [i, be, se, P]), we = t.useCallback((function () { if (oe.current) { $({ type: "openDialog" }), T(); var e = { multiple: d, types: R }; window.showOpenFilePicker(e).then((function (e) { return i(e) })).then((function (e) { be(e, null), $({ type: "closeDialog" }) })).catch((function (e) { ne(e) ? (I(e), $({ type: "closeDialog" })) : re(e) ? (oe.current = !1, L.current ? (L.current.value = null, L.current.click()) : se(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))) : se(e) })) } else L.current && ($({ type: "openDialog" }), T(), L.current.value = null, L.current.click()) }), [$, T, I, F, be, se, R, d]), De = t.useCallback((function (e) { M.current && M.current.isEqualNode(e.target) && (" " !== e.key && "Enter" !== e.key && 32 !== e.keyCode && 13 !== e.keyCode || (e.preventDefault(), we())) }), [M, we]), xe = t.useCallback((function () { $({ type: "focus" }) }), []), Fe = t.useCallback((function () { $({ type: "blur" }) }), []), je = t.useCallback((function () { O || (V() ? setTimeout(we, 0) : we()) }), [O, we]), Ae = function (e) { return o ? null : e }, Oe = function (e) { return E ? null : Ae(e) }, Ee = function (e) { return k ? null : Ae(e) }, ke = function (e) { P && e.stopPropagation() }, Pe = t.useMemo((function () { return function () { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.refKey, n = void 0 === t ? "ref" : t, r = e.role, i = e.onKeyDown, a = e.onFocus, s = e.onBlur, f = e.onClick, p = e.onDragEnter, d = e.onDragOver, v = e.onDragLeave, m = e.onDrop, g = l(e, ue); return c(c(u({ onKeyDown: Oe(X(i, De)), onFocus: Oe(X(a, xe)), onBlur: Oe(X(s, Fe)), onClick: Ae(X(f, je)), onDragEnter: Ee(X(p, de)), onDragOver: Ee(X(d, ge)), onDragLeave: Ee(X(v, ye)), onDrop: Ee(X(m, he)), role: "string" == typeof r && "" !== r ? r : "presentation" }, n, M), o || E ? {} : { tabIndex: 0 }), g) } }), [M, De, xe, Fe, je, de, ge, ye, he, E, k, o]), Se = t.useCallback((function (e) { e.stopPropagation() }), []), Ce = t.useMemo((function () { return function () { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.refKey, n = void 0 === t ? "ref" : t, r = e.onChange, o = e.onClick, i = l(e, le), a = u({ accept: z, multiple: d, type: "file", style: { display: "none" }, onChange: Ae(X(r, he)), onClick: Ae(X(o, Se)), tabIndex: -1 }, n, L); return c(c({}, a), i) } }), [L, r, d, he, o]); return c(c({}, K), {}, { isFocused: J && !o, getRootProps: Pe, getInputProps: Ce, rootRef: M, inputRef: L, open: Ae(we) }) } function ve(e, t) { switch (t.type) { case "focus": return c(c({}, e), {}, { isFocused: !0 }); case "blur": return c(c({}, e), {}, { isFocused: !1 }); case "openDialog": return c(c({}, pe), {}, { isFileDialogActive: !0 }); case "closeDialog": return c(c({}, e), {}, { isFileDialogActive: !1 }); case "setDraggedFiles": return c(c({}, e), {}, { isDragActive: t.isDragActive, isDragAccept: t.isDragAccept, isDragReject: t.isDragReject }); case "setFiles": return c(c({}, e), {}, { acceptedFiles: t.acceptedFiles, fileRejections: t.fileRejections }); case "reset": return c({}, pe); default: return e } } function me() { } e.ErrorCode = L, e.default = se, e.useDropzone = de, Object.defineProperty(e, "__esModule", { value: !0 }) })); /***/ }) };;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/56408/output.js
JavaScript
exports.id = 675; exports.ids = [ 675 ]; exports.modules = { /***/ 4622: /***/ function(e, t, n) { void function(e, t, n) { "use strict"; function r(e) { return e && "object" == typeof e && "default" in e ? e : { default: e }; } var i = r(t), b = r(n); function a(e, t) { var n = Object.keys(e); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(e); t && (i = i.filter(function(t) { return Object.getOwnPropertyDescriptor(e, t).enumerable; })), n.push.apply(n, i); } return n; } function c(e) { for(var t = 1; t < arguments.length; t++){ var n = null != arguments[t] ? arguments[t] : {}; t % 2 ? a(Object(n), !0).forEach(function(t) { u(e, t, n[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : a(Object(n)).forEach(function(t) { Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t)); }); } return e; } function u(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e; } function l(e, t) { if (null == e) return {}; var n, i, b = function(e, t) { if (null == e) return {}; var n, i, b = {}, w = Object.keys(e); for(i = 0; i < w.length; i++)n = w[i], t.indexOf(n) >= 0 || (b[n] = e[n]); return b; }(e, t); if (Object.getOwnPropertySymbols) { var w = Object.getOwnPropertySymbols(e); for(i = 0; i < w.length; i++)n = w[i], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (b[n] = e[n]); } return b; } function s(e, t) { return function(e) { if (Array.isArray(e)) return e; }(e) || function(e, t) { var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (null == n) return; var i, b, w = [], R = !0, T = !1; try { for(n = n.call(e); !(R = (i = n.next()).done) && (w.push(i.value), !t || w.length !== t); R = !0); } catch (e) { T = !0, b = e; } finally{ try { R || null == n.return || n.return(); } finally{ if (T) throw b; } } return w; }(e, t) || p(e, t) || function() { throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } function f(e) { return function(e) { if (Array.isArray(e)) return d(e); }(e) || function(e) { if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e); }(e) || p(e) || function() { throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } function p(e, t) { if (e) { if ("string" == typeof e) return d(e, t); var n = Object.prototype.toString.call(e).slice(8, -1); return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? d(e, t) : void 0; } } function d(e, t) { (null == t || t > e.length) && (t = e.length); for(var n = 0, i = Array(t); n < t; n++)i[n] = e[n]; return i; } function v(e, t, n, i) { return new (n || (n = Promise))(function(b, w) { function a(e) { try { u(i.next(e)); } catch (e) { w(e); } } function c(e) { try { u(i.throw(e)); } catch (e) { w(e); } } function u(e) { var t; e.done ? b(e.value) : (t = e.value, t instanceof n ? t : new n(function(e) { e(t); })).then(a, c); } u((i = i.apply(e, t || [])).next()); }); } function m(e, t) { var n, i, b, w, R = { label: 0, sent: function() { if (1 & b[0]) throw b[1]; return b[1]; }, trys: [], ops: [] }; return w = { next: c(0), throw: c(1), return: c(2) }, "function" == typeof Symbol && (w[Symbol.iterator] = function() { return this; }), w; function c(w) { return function(T) { return function(w) { if (n) throw TypeError("Generator is already executing."); for(; R;)try { if (n = 1, i && (b = 2 & w[0] ? i.return : w[0] ? i.throw || ((b = i.return) && b.call(i), 0) : i.next) && !(b = b.call(i, w[1])).done) return b; switch(i = 0, b && (w = [ 2 & w[0], b.value ]), w[0]){ case 0: case 1: b = w; break; case 4: return R.label++, { value: w[1], done: !1 }; case 5: R.label++, i = w[1], w = [ 0 ]; continue; case 7: w = R.ops.pop(), R.trys.pop(); continue; default: if (b = R.trys, !(b = b.length > 0 && b[b.length - 1]) && (6 === w[0] || 2 === w[0])) { R = 0; continue; } if (3 === w[0] && (!b || w[1] > b[0] && w[1] < b[3])) { R.label = w[1]; break; } if (6 === w[0] && R.label < b[1]) { R.label = b[1], b = w; break; } if (b && R.label < b[2]) { R.label = b[2], R.ops.push(w); break; } b[2] && R.ops.pop(), R.trys.pop(); continue; } w = t.call(e, R); } catch (e) { w = [ 6, e ], i = 0; } finally{ n = b = 0; } if (5 & w[0]) throw w[1]; return { value: w[0] ? w[1] : void 0, done: !0 }; }([ w, T ]); }; } } function g(e, t) { var n = "function" == typeof Symbol && e[Symbol.iterator]; if (!n) return e; var i, b, w = n.call(e), R = []; try { for(; (void 0 === t || t-- > 0) && !(i = w.next()).done;)R.push(i.value); } catch (e) { b = { error: e }; } finally{ try { i && !i.done && (n = w.return) && n.call(w); } finally{ if (b) throw b.error; } } return R; } function y(e, t, n) { if (n || 2 == arguments.length) for(var i, b = 0, w = t.length; b < w; b++)!i && b in t || (i || (i = Array.prototype.slice.call(t, 0, b)), i[b] = t[b]); return e.concat(i || Array.prototype.slice.call(t)); } var w = new Map([ [ "aac", "audio/aac" ], [ "abw", "application/x-abiword" ], [ "arc", "application/x-freearc" ], [ "avif", "image/avif" ], [ "avi", "video/x-msvideo" ], [ "azw", "application/vnd.amazon.ebook" ], [ "bin", "application/octet-stream" ], [ "bmp", "image/bmp" ], [ "bz", "application/x-bzip" ], [ "bz2", "application/x-bzip2" ], [ "cda", "application/x-cdf" ], [ "csh", "application/x-csh" ], [ "css", "text/css" ], [ "csv", "text/csv" ], [ "doc", "application/msword" ], [ "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ], [ "eot", "application/vnd.ms-fontobject" ], [ "epub", "application/epub+zip" ], [ "gz", "application/gzip" ], [ "gif", "image/gif" ], [ "heic", "image/heic" ], [ "heif", "image/heif" ], [ "htm", "text/html" ], [ "html", "text/html" ], [ "ico", "image/vnd.microsoft.icon" ], [ "ics", "text/calendar" ], [ "jar", "application/java-archive" ], [ "jpeg", "image/jpeg" ], [ "jpg", "image/jpeg" ], [ "js", "text/javascript" ], [ "json", "application/json" ], [ "jsonld", "application/ld+json" ], [ "mid", "audio/midi" ], [ "midi", "audio/midi" ], [ "mjs", "text/javascript" ], [ "mp3", "audio/mpeg" ], [ "mp4", "video/mp4" ], [ "mpeg", "video/mpeg" ], [ "mpkg", "application/vnd.apple.installer+xml" ], [ "odp", "application/vnd.oasis.opendocument.presentation" ], [ "ods", "application/vnd.oasis.opendocument.spreadsheet" ], [ "odt", "application/vnd.oasis.opendocument.text" ], [ "oga", "audio/ogg" ], [ "ogv", "video/ogg" ], [ "ogx", "application/ogg" ], [ "opus", "audio/opus" ], [ "otf", "font/otf" ], [ "png", "image/png" ], [ "pdf", "application/pdf" ], [ "php", "application/x-httpd-php" ], [ "ppt", "application/vnd.ms-powerpoint" ], [ "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" ], [ "rar", "application/vnd.rar" ], [ "rtf", "application/rtf" ], [ "sh", "application/x-sh" ], [ "svg", "image/svg+xml" ], [ "swf", "application/x-shockwave-flash" ], [ "tar", "application/x-tar" ], [ "tif", "image/tiff" ], [ "tiff", "image/tiff" ], [ "ts", "video/mp2t" ], [ "ttf", "font/ttf" ], [ "txt", "text/plain" ], [ "vsd", "application/vnd.visio" ], [ "wav", "audio/wav" ], [ "weba", "audio/webm" ], [ "webm", "video/webm" ], [ "webp", "image/webp" ], [ "woff", "font/woff" ], [ "woff2", "font/woff2" ], [ "xhtml", "application/xhtml+xml" ], [ "xls", "application/vnd.ms-excel" ], [ "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ], [ "xml", "application/xml" ], [ "xul", "application/vnd.mozilla.xul+xml" ], [ "zip", "application/zip" ], [ "7z", "application/x-7z-compressed" ], [ "mkv", "video/x-matroska" ], [ "mov", "video/quicktime" ], [ "msg", "application/vnd.ms-outlook" ] ]); function h(e, t) { var n = function(e) { var t = e.name; if (t && -1 !== t.lastIndexOf(".") && !e.type) { var n = t.split(".").pop().toLowerCase(), i = w.get(n); i && Object.defineProperty(e, "type", { value: i, writable: !1, configurable: !1, enumerable: !0 }); } return e; }(e); if ("string" != typeof n.path) { var i = e.webkitRelativePath; Object.defineProperty(n, "path", { value: "string" == typeof t ? t : "string" == typeof i && i.length > 0 ? i : e.name, writable: !1, configurable: !1, enumerable: !0 }); } return n; } var R = [ ".DS_Store", "Thumbs.db" ]; function D(e) { return "object" == typeof e && null !== e; } function x(e) { return O(e.target.files).map(function(e) { return h(e); }); } function F(e) { return v(this, void 0, void 0, function() { return m(this, function(t) { switch(t.label){ case 0: return [ 4, Promise.all(e.map(function(e) { return e.getFile(); })) ]; case 1: return [ 2, t.sent().map(function(e) { return h(e); }) ]; } }); }); } function j(e, t) { return v(this, void 0, void 0, function() { var n; return m(this, function(i) { switch(i.label){ case 0: return e.items ? (n = O(e.items).filter(function(e) { return "file" === e.kind; }), "drop" !== t ? [ 2, n ] : [ 4, Promise.all(n.map(E)) ]) : [ 3, 2 ]; case 1: return [ 2, A(k(i.sent())) ]; case 2: return [ 2, A(O(e.files).map(function(e) { return h(e); })) ]; } }); }); } function A(e) { return e.filter(function(e) { return -1 === R.indexOf(e.name); }); } function O(e) { if (null === e) return []; for(var t = [], n = 0; n < e.length; n++){ var i = e[n]; t.push(i); } return t; } function E(e) { if ("function" != typeof e.webkitGetAsEntry) return P(e); var t = e.webkitGetAsEntry(); return t && t.isDirectory ? C(t) : P(e); } function k(e) { return e.reduce(function(e, t) { return y(y([], g(e), !1), g(Array.isArray(t) ? k(t) : [ t ]), !1); }, []); } function P(e) { var t = e.getAsFile(); if (!t) return Promise.reject("".concat(e, " is not a File")); return Promise.resolve(h(t)); } function S(e) { return v(this, void 0, void 0, function() { return m(this, function(t) { return [ 2, e.isDirectory ? C(e) : z(e) ]; }); }); } function C(e) { var t = e.createReader(); return new Promise(function(e, n) { var i = []; !function o() { var b = this; t.readEntries(function(t) { return v(b, void 0, void 0, function() { var b, w, R; return m(this, function(T) { switch(T.label){ case 0: if (t.length) return [ 3, 5 ]; T.label = 1; case 1: return T.trys.push([ 1, 3, , 4 ]), [ 4, Promise.all(i) ]; case 2: return b = T.sent(), e(b), [ 3, 4 ]; case 3: return w = T.sent(), n(w), [ 3, 4 ]; case 4: return [ 3, 6 ]; case 5: R = Promise.all(t.map(S)), i.push(R), o(), T.label = 6; case 6: return [ 2 ]; } }); }); }, function(e) { n(e); }); }(); }); } function z(e) { return v(this, void 0, void 0, function() { return m(this, function(t) { return [ 2, new Promise(function(t, n) { e.file(function(n) { t(h(n, e.fullPath)); }, function(e) { n(e); }); }) ]; }); }); } var T = "file-invalid-type", I = "file-too-large", M = "file-too-small", L = "too-many-files", _ = function(e) { var t = Array.isArray(e = Array.isArray(e) && 1 === e.length ? e[0] : e) ? "one of ".concat(e.join(", ")) : e; return { code: T, message: "File type must be ".concat(t) }; }, B = function(e) { return { code: I, message: "File is larger than ".concat(e, " ").concat(1 === e ? "byte" : "bytes") }; }, K = function(e) { return { code: M, message: "File is smaller than ".concat(e, " ").concat(1 === e ? "byte" : "bytes") }; }, q = { code: L, message: "Too many files" }; function U(e, t) { var n = "application/x-moz-file" === e.type || function(e, t) { if (e && t) { var n = Array.isArray(t) ? t : t.split(","), i = e.name || "", b = (e.type || "").toLowerCase(), w = b.replace(/\/.*$/, ""); return n.some(function(e) { var t = e.trim().toLowerCase(); return "." === t.charAt(0) ? i.toLowerCase().endsWith(t) : t.endsWith("/*") ? w === t.replace(/\/.*$/, "") : b === t; }); } return !0; }(e, t); return [ n, n ? null : _(t) ]; } function W(e, t, n) { if ($(e.size)) if ($(t) && $(n)) { if (e.size > n) return [ !1, B(n) ]; if (e.size < t) return [ !1, K(t) ]; } else { if ($(t) && e.size < t) return [ !1, K(t) ]; if ($(n) && e.size > n) return [ !1, B(n) ]; } return [ !0, null ]; } function $(e) { return null != e; } function G(e) { var t = e.files, n = e.accept, i = e.minSize, b = e.maxSize, w = e.multiple, R = e.maxFiles, T = e.validator; return !(!w && t.length > 1 || w && R >= 1 && t.length > R) && t.every(function(e) { var t = s(U(e, n), 1)[0], w = s(W(e, i, b), 1)[0], R = T ? T(e) : null; return t && w && !R; }); } function H(e) { return "function" == typeof e.isPropagationStopped ? e.isPropagationStopped() : void 0 !== e.cancelBubble && e.cancelBubble; } function N(e) { return e.dataTransfer ? Array.prototype.some.call(e.dataTransfer.types, function(e) { return "Files" === e || "application/x-moz-file" === e; }) : !!e.target && !!e.target.files; } function Y(e) { e.preventDefault(); } function J(e) { return -1 !== e.indexOf("MSIE") || -1 !== e.indexOf("Trident/"); } function Q(e) { return -1 !== e.indexOf("Edge/"); } function V() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window.navigator.userAgent; return J(e) || Q(e); } function X() { for(var e = arguments.length, t = Array(e), n = 0; n < e; n++)t[n] = arguments[n]; return function(e) { for(var n = arguments.length, i = Array(n > 1 ? n - 1 : 0), b = 1; b < n; b++)i[b - 1] = arguments[b]; return t.some(function(t) { return !H(e) && t && t.apply(void 0, [ e ].concat(i)), H(e); }); }; } function Z() { return "showOpenFilePicker" in window; } function ee(e) { return $(e) ? [ { description: "Files", accept: Object.entries(e).filter(function(e) { var t = s(e, 2), n = t[0], i = t[1], b = !0; return oe(n) || (console.warn('Skipped "'.concat(n, '" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')), b = !1), Array.isArray(i) && i.every(ie) || (console.warn('Skipped "'.concat(n, '" because an invalid file extension was provided.')), b = !1), b; }).reduce(function(e, t) { var n = s(t, 2), i = n[0], b = n[1]; return c(c({}, e), {}, u({}, i, b)); }, {}) } ] : e; } function te(e) { if ($(e)) return Object.entries(e).reduce(function(e, t) { var n = s(t, 2), i = n[0], b = n[1]; return [].concat(f(e), [ i ], f(b)); }, []).filter(function(e) { return oe(e) || ie(e); }).join(","); } function ne(e) { return e instanceof DOMException && ("AbortError" === e.name || e.code === e.ABORT_ERR); } function re(e) { return e instanceof DOMException && ("SecurityError" === e.name || e.code === e.SECURITY_ERR); } function oe(e) { return "audio/*" === e || "video/*" === e || "image/*" === e || "text/*" === e || /\w+\/[-+.\w]+/g.test(e); } function ie(e) { return /^.*\.[\w]+$/.test(e); } var et = [ "children" ], en = [ "open" ], er = [ "refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop" ], eo = [ "refKey", "onChange", "onClick" ], ei = t.forwardRef(function(e, n) { var b = e.children, w = de(l(e, et)), R = w.open, T = l(w, en); return t.useImperativeHandle(n, function() { return { open: R }; }, [ R ]), i.default.createElement(t.Fragment, null, b(c(c({}, T), {}, { open: R }))); }); ei.displayName = "Dropzone"; var ea = { disabled: !1, getFilesFromEvent: function(e) { return v(this, void 0, void 0, function() { return m(this, function(t) { return D(e) && D(e.dataTransfer) ? [ 2, j(e.dataTransfer, e.type) ] : D(e) && D(e.target) ? [ 2, x(e) ] : Array.isArray(e) && e.every(function(e) { return "getFile" in e && "function" == typeof e.getFile; }) ? [ 2, F(e) ] : [ 2, [] ]; }); }); }, maxSize: 1 / 0, minSize: 0, multiple: !0, maxFiles: 0, preventDropOnDocument: !0, noClick: !1, noKeyboard: !1, noDrag: !1, noDragEventsBubbling: !1, validator: null, useFsAccessApi: !0, autoFocus: !1 }; ei.defaultProps = ea, ei.propTypes = { children: b.default.func, accept: b.default.objectOf(b.default.arrayOf(b.default.string)), multiple: b.default.bool, preventDropOnDocument: b.default.bool, noClick: b.default.bool, noKeyboard: b.default.bool, noDrag: b.default.bool, noDragEventsBubbling: b.default.bool, minSize: b.default.number, maxSize: b.default.number, maxFiles: b.default.number, disabled: b.default.bool, getFilesFromEvent: b.default.func, onFileDialogCancel: b.default.func, onFileDialogOpen: b.default.func, useFsAccessApi: b.default.bool, autoFocus: b.default.bool, onDragEnter: b.default.func, onDragLeave: b.default.func, onDragOver: b.default.func, onDrop: b.default.func, onDropAccepted: b.default.func, onDropRejected: b.default.func, onError: b.default.func, validator: b.default.func }; var ec = { isFocused: !1, isFileDialogActive: !1, isDragActive: !1, isDragAccept: !1, isDragReject: !1, acceptedFiles: [], fileRejections: [] }; function de() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, n = c(c({}, ea), e), i = n.accept, b = n.disabled, w = n.getFilesFromEvent, R = n.maxSize, T = n.minSize, I = n.multiple, M = n.maxFiles, L = n.onDragEnter, et = n.onDragLeave, en = n.onDragOver, ei = n.onDrop, eu = n.onDropAccepted, el = n.onDropRejected, es = n.onFileDialogCancel, ef = n.onFileDialogOpen, ep = n.useFsAccessApi, ed = n.autoFocus, ev = n.preventDropOnDocument, em = n.noClick, eg = n.noKeyboard, ey = n.noDrag, eb = n.noDragEventsBubbling, eh = n.onError, eD = n.validator, ew = t.useMemo(function() { return te(i); }, [ i ]), ex = t.useMemo(function() { return ee(i); }, [ i ]), eA = t.useMemo(function() { return "function" == typeof ef ? ef : me; }, [ ef ]), eO = t.useMemo(function() { return "function" == typeof es ? es : me; }, [ es ]), eF = t.useRef(null), ej = t.useRef(null), ek = s(t.useReducer(ve, ec), 2), eE = ek[0], eP = ek[1], eC = eE.isFocused, eS = eE.isFileDialogActive, ez = t.useRef("undefined" != typeof window && window.isSecureContext && ep && Z()), ie = function() { !ez.current && eS && setTimeout(function() { ej.current && (ej.current.files.length || (eP({ type: "closeDialog" }), eO())); }, 300); }; t.useEffect(function() { return window.addEventListener("focus", ie, !1), function() { window.removeEventListener("focus", ie, !1); }; }, [ ej, eS, eO, ez ]); var eR = t.useRef([]), ce = function(e) { eF.current && eF.current.contains(e.target) || (e.preventDefault(), eR.current = []); }; t.useEffect(function() { return ev && (document.addEventListener("dragover", Y, !1), document.addEventListener("drop", ce, !1)), function() { ev && (document.removeEventListener("dragover", Y), document.removeEventListener("drop", ce)); }; }, [ eF, ev ]), t.useEffect(function() { return !b && ed && eF.current && eF.current.focus(), function() {}; }, [ eF, ed, b ]); var eT = t.useCallback(function(e) { eh ? eh(e) : console.error(e); }, [ eh ]), eI = t.useCallback(function(e) { e.preventDefault(), e.persist(), ke(e), eR.current = [].concat(f(eR.current), [ e.target ]), N(e) && Promise.resolve(w(e)).then(function(t) { if (!H(e) || eb) { var n = t.length, i = n > 0 && G({ files: t, accept: ew, minSize: T, maxSize: R, multiple: I, maxFiles: M, validator: eD }); eP({ isDragAccept: i, isDragReject: n > 0 && !i, isDragActive: !0, type: "setDraggedFiles" }), L && L(e); } }).catch(function(e) { return eT(e); }); }, [ w, L, eT, eb, ew, T, R, I, M, eD ]), eM = t.useCallback(function(e) { e.preventDefault(), e.persist(), ke(e); var t = N(e); if (t && e.dataTransfer) try { e.dataTransfer.dropEffect = "copy"; } catch (e) {} return t && en && en(e), !1; }, [ en, eb ]), eL = t.useCallback(function(e) { e.preventDefault(), e.persist(), ke(e); var t = eR.current.filter(function(e) { return eF.current && eF.current.contains(e); }), n = t.indexOf(e.target); -1 !== n && t.splice(n, 1), eR.current = t, t.length > 0 || (eP({ type: "setDraggedFiles", isDragActive: !1, isDragAccept: !1, isDragReject: !1 }), N(e) && et && et(e)); }, [ eF, et, eb ]), e_ = t.useCallback(function(e, t) { var n = [], i = []; e.forEach(function(e) { var t = s(U(e, ew), 2), b = t[0], w = t[1], I = s(W(e, T, R), 2), M = I[0], L = I[1], q = eD ? eD(e) : null; if (b && M && !q) n.push(e); else { var et = [ w, L ]; q && (et = et.concat(q)), i.push({ file: e, errors: et.filter(function(e) { return e; }) }); } }), (!I && n.length > 1 || I && M >= 1 && n.length > M) && (n.forEach(function(e) { i.push({ file: e, errors: [ q ] }); }), n.splice(0)), eP({ acceptedFiles: n, fileRejections: i, type: "setFiles" }), ei && ei(n, i, t), i.length > 0 && el && el(i, t), n.length > 0 && eu && eu(n, t); }, [ eP, I, ew, T, R, M, ei, eu, el, eD ]), eB = t.useCallback(function(e) { e.preventDefault(), e.persist(), ke(e), eR.current = [], N(e) && Promise.resolve(w(e)).then(function(t) { H(e) && !eb || e_(t, e); }).catch(function(e) { return eT(e); }), eP({ type: "reset" }); }, [ w, e_, eT, eb ]), eK = t.useCallback(function() { if (ez.current) { eP({ type: "openDialog" }), eA(); window.showOpenFilePicker({ multiple: I, types: ex }).then(function(e) { return w(e); }).then(function(e) { e_(e, null), eP({ type: "closeDialog" }); }).catch(function(e) { ne(e) ? (eO(e), eP({ type: "closeDialog" })) : re(e) ? (ez.current = !1, ej.current ? (ej.current.value = null, ej.current.click()) : eT(Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))) : eT(e); }); } else ej.current && (eP({ type: "openDialog" }), eA(), ej.current.value = null, ej.current.click()); }, [ eP, eA, eO, ep, e_, eT, ex, I ]), e$ = t.useCallback(function(e) { eF.current && eF.current.isEqualNode(e.target) && (" " !== e.key && "Enter" !== e.key && 32 !== e.keyCode && 13 !== e.keyCode || (e.preventDefault(), eK())); }, [ eF, eK ]), eX = t.useCallback(function() { eP({ type: "focus" }); }, []), eH = t.useCallback(function() { eP({ type: "blur" }); }, []), eN = t.useCallback(function() { em || (V() ? setTimeout(eK, 0) : eK()); }, [ em, eK ]), Ae = function(e) { return b ? null : e; }, Oe = function(e) { return eg ? null : Ae(e); }, Ee = function(e) { return ey ? null : Ae(e); }, ke = function(e) { eb && e.stopPropagation(); }, eU = t.useMemo(function() { return function() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.refKey, n = e.role, i = e.onKeyDown, w = e.onFocus, R = e.onBlur, T = e.onClick, I = e.onDragEnter, M = e.onDragOver, L = e.onDragLeave, q = e.onDrop, et = l(e, er); return c(c(u({ onKeyDown: Oe(X(i, e$)), onFocus: Oe(X(w, eX)), onBlur: Oe(X(R, eH)), onClick: Ae(X(T, eN)), onDragEnter: Ee(X(I, eI)), onDragOver: Ee(X(M, eM)), onDragLeave: Ee(X(L, eL)), onDrop: Ee(X(q, eB)), role: "string" == typeof n && "" !== n ? n : "presentation" }, void 0 === t ? "ref" : t, eF), b || eg ? {} : { tabIndex: 0 }), et); }; }, [ eF, e$, eX, eH, eN, eI, eM, eL, eB, eg, ey, b ]), eW = t.useCallback(function(e) { e.stopPropagation(); }, []), eG = t.useMemo(function() { return function() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.refKey, n = e.onChange, i = e.onClick, b = l(e, eo); return c(c({}, u({ accept: ew, multiple: I, type: "file", style: { display: "none" }, onChange: Ae(X(n, eB)), onClick: Ae(X(i, eW)), tabIndex: -1 }, void 0 === t ? "ref" : t, ej)), b); }; }, [ ej, i, I, eB, b ]); return c(c({}, eE), {}, { isFocused: eC && !b, getRootProps: eU, getInputProps: eG, rootRef: eF, inputRef: ej, open: Ae(eK) }); } function ve(e, t) { switch(t.type){ case "focus": return c(c({}, e), {}, { isFocused: !0 }); case "blur": return c(c({}, e), {}, { isFocused: !1 }); case "openDialog": return c(c({}, ec), {}, { isFileDialogActive: !0 }); case "closeDialog": return c(c({}, e), {}, { isFileDialogActive: !1 }); case "setDraggedFiles": return c(c({}, e), {}, { isDragActive: t.isDragActive, isDragAccept: t.isDragAccept, isDragReject: t.isDragReject }); case "setFiles": return c(c({}, e), {}, { acceptedFiles: t.acceptedFiles, fileRejections: t.fileRejections }); case "reset": return c({}, ec); default: return e; } } function me() {} e.ErrorCode = { FileInvalidType: T, FileTooLarge: I, FileTooSmall: M, TooManyFiles: L }, e.default = ei, e.useDropzone = de, Object.defineProperty(e, "__esModule", { value: !0 }); }(t, n(9885), n(5601)); /***/ } };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/66237/input.js
JavaScript
"use strict"; (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[854], { /***/ 3712: /***/ (function (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ $Q: function () { return /* binding */ C; }, /* harmony export */ Ev: function () { return /* binding */ B; }, /* harmony export */ e_: function () { return /* binding */ I; }, /* harmony export */ jU: function () { return /* binding */ e; } /* harmony export */ }); /* unused harmony exports ACTION_ELEMENTS, SbbScrollHandler, breakpoints, findInput, findReferencedElement, hostContext, isAndroid, isBlink, isBreakpoint, isChromium, isEdge, isFirefox, isIOS, isNextjs, isSafari, isTrident, isWebkit, pageScrollDisabled */ let a; try { a = typeof Intl < "u" && Intl.v8BreakIterator; } catch (e) { a = !1; } const e = () => typeof document == "object" && !!document, l = () => e() && /(edge)/i.test(navigator.userAgent), c = () => e() && /(msie|trident)/i.test(navigator.userAgent), y = () => e() && !!(window.chrome || a) && typeof CSS < "u" && !l() && !c(), g = () => e() && /AppleWebKit/i.test(navigator.userAgent) && !y() && !l() && !c(), w = () => e() && /iPad|iPhone|iPod/.test(navigator.userAgent) && !("MSStream" in window), v = () => e() && /(firefox|minefield)/i.test(navigator.userAgent), A = () => e() && /android/i.test(navigator.userAgent) && !c(), E = () => e() && /safari/i.test(navigator.userAgent) && g(), p = () => !!globalThis.next, S = () => { var t, n; return (n = (t = navigator.userAgentData) == null ? void 0 : t.brands) == null ? void 0 : n.some((o) => o.brand == "Chromium"); }, x = (/* unused pure expression or super */ null && ([ "zero", "micro", "small", "medium", "wide", "large", "ultra" ])); function k(t, n, o) { if (!e()) return !1; const i = getComputedStyle(document.documentElement), s = t ? i.getPropertyValue("--sbb-breakpoint-".concat(t, "-min")) : "", r = n ? "".concat(parseFloat(i.getPropertyValue("--sbb-breakpoint-".concat(n, "-").concat(o != null && o.includeMaxBreakpoint ? "max" : "min"))) - (o != null && o.includeMaxBreakpoint ? 0 : 0.0625), "rem") : "", b = s && "(min-width: ".concat(s, ")"), m = r && "(max-width: ".concat(r, ")"), f = s && r && " and "; return window.matchMedia("".concat(b).concat(f).concat(m)).matches; } function h(t) { if (e()) { if (typeof t == "string") return document.getElementById(t); if (t instanceof window.Element) return t; } else return null; return null; } const I = () => e() && document.documentElement.getAttribute("dir") || "ltr"; function $(t, n) { if (!e()) return null; var _n_parentElement; for (n = (_n_parentElement = n.parentElement) !== null && _n_parentElement !== void 0 ? _n_parentElement : n.getRootNode().host; n && n !== document && n !== window;) { const o = n.closest(t); if (o) return o; n = n.getRootNode().host; } return null; } const M = "a,button,sbb-teaser-hero,sbb-teaser"; function _(t, n) { var o; if (!n) { const i = (o = t.closest) == null ? void 0 : o.call(t, "sbb-form-field"); return i == null ? void 0 : i.querySelector("input"); } return h(n); } function B(t, n, o) { o ? t.setAttribute(n, o) : t.removeAttribute(n); } function u() { return document.body.hasAttribute("data-sbb-scroll-disabled"); } class W { disableScroll() { if (u()) return; this._position = document.body.style.position, this._overflow = document.body.style.overflow, this._marginInlineEnd = document.body.style.marginInlineEnd; const n = window.innerWidth - document.documentElement.clientWidth; document.body.style.overflow = "hidden", document.body.style.position = "relative", document.body.style.marginInlineEnd = "".concat(n, "px"), document.body.style.setProperty("--sbb-scrollbar-width", "".concat(n, "px")), document.body.toggleAttribute("data-sbb-scroll-disabled", !0); } enableScroll() { u() && (document.body.style.position = this._position || "", document.body.style.overflow = this._overflow || "", document.body.style.marginInlineEnd = this._marginInlineEnd || "", document.body.style.setProperty("--sbb-scrollbar-width", "0"), document.body.removeAttribute("data-sbb-scroll-disabled")); } } const d = /* @__PURE__ */ new Map(); function C(t) { if (d.has(t.constructor)) return d.get(t.constructor); const n = // eslint-disable-next-line @typescript-eslint/naming-convention customElements.__definitions; for (const [o, i] of n) if (i.ctor === t.constructor) return d.set(t.constructor, o), o; throw new Error("Given element ".concat(t.constructor.name, " has not been registered yet.")); } /***/ }), }]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/66237/output.js
JavaScript
"use strict"; (self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 854 ], { /***/ 3712: /***/ function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ $Q: function() { return /* binding */ C; }, /* harmony export */ Ev: function() { return /* binding */ B; }, /* harmony export */ e_: function() { return /* binding */ I; }, /* harmony export */ jU: function() { return /* binding */ e; } }); try { "u" > typeof Intl && Intl.v8BreakIterator; } catch (e) {} const e = ()=>"object" == typeof document && !!document, I = ()=>e() && document.documentElement.getAttribute("dir") || "ltr"; function B(t, n, o) { o ? t.setAttribute(n, o) : t.removeAttribute(n); } const d = /* @__PURE__ */ new Map(); function C(t) { if (d.has(t.constructor)) return d.get(t.constructor); for (const [o, i] of customElements.__definitions)if (i.ctor === t.constructor) return d.set(t.constructor, o), o; throw Error("Given element ".concat(t.constructor.name, " has not been registered yet.")); } /***/ } } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/66378/input.js
JavaScript
import { concat, fromString, toString } from "uint8arrays"; import { x25519 } from "@noble/curves/ed25519"; import { varint } from "multiformats"; import { decode, encode } from "multibase"; import { secp256k1 } from "@noble/curves/secp256k1"; import { p256 } from "@noble/curves/p256"; const u8a = { toString, fromString, concat }; export function bytesToBase64url(b) { return u8a.toString(b, 'base64url'); } export function base64ToBytes(s) { const inputBase64Url = s.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); return u8a.fromString(inputBase64Url, 'base64url'); } export function bytesToBase64(b) { return u8a.toString(b, 'base64pad'); } export function base58ToBytes(s) { return u8a.fromString(s, 'base58btc'); } export function bytesToBase58(b) { return u8a.toString(b, 'base58btc'); } export const SUPPORTED_PUBLIC_KEY_TYPES = { ES256: [ 'JsonWebKey2020', 'Multikey', 'EcdsaSecp256r1VerificationKey2019' ], ES256K: [ 'EcdsaSecp256k1VerificationKey2019', /** * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress */ 'EcdsaSecp256k1RecoveryMethod2020', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1VerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1SignatureVerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'EcdsaPublicKeySecp256k1', /** * TODO - support R1 key as well * 'ConditionalProof2022', */ 'JsonWebKey2020', 'Multikey' ], 'ES256K-R': [ 'EcdsaSecp256k1VerificationKey2019', /** * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress */ 'EcdsaSecp256k1RecoveryMethod2020', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1VerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1SignatureVerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'EcdsaPublicKeySecp256k1', 'ConditionalProof2022', 'JsonWebKey2020', 'Multikey' ], Ed25519: [ 'ED25519SignatureVerification', 'Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'JsonWebKey2020', 'Multikey' ], EdDSA: [ 'ED25519SignatureVerification', 'Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'JsonWebKey2020', 'Multikey' ] }; export const VM_TO_KEY_TYPE = { Secp256k1SignatureVerificationKey2018: 'Secp256k1', Secp256k1VerificationKey2018: 'Secp256k1', EcdsaSecp256k1VerificationKey2019: 'Secp256k1', EcdsaPublicKeySecp256k1: 'Secp256k1', EcdsaSecp256k1RecoveryMethod2020: 'Secp256k1', EcdsaSecp256r1VerificationKey2019: 'P-256', Ed25519VerificationKey2018: 'Ed25519', Ed25519VerificationKey2020: 'Ed25519', ED25519SignatureVerification: 'Ed25519', X25519KeyAgreementKey2019: 'X25519', X25519KeyAgreementKey2020: 'X25519', ConditionalProof2022: undefined, JsonWebKey2020: undefined, Multikey: undefined }; // this is from the multicodec table https://github.com/multiformats/multicodec/blob/master/table.csv export const supportedCodecs = { 'ed25519-pub': 0xed, 'x25519-pub': 0xec, 'secp256k1-pub': 0xe7, 'bls12_381-g1-pub': 0xea, 'bls12_381-g2-pub': 0xeb, 'p256-pub': 0x1200 }; export const CODEC_TO_KEY_TYPE = { 'bls12_381-g1-pub': 'Bls12381G1', 'bls12_381-g2-pub': 'Bls12381G2', 'ed25519-pub': 'Ed25519', 'p256-pub': 'P-256', 'secp256k1-pub': 'Secp256k1', 'x25519-pub': 'X25519' }; /** * Extracts the raw byte representation of a public key from a VerificationMethod along with an inferred key type * @param pk a VerificationMethod entry from a DIDDocument * @return an object containing the `keyBytes` of the public key and an inferred `keyType` */ export function extractPublicKeyBytes(pk) { if (pk.publicKeyBase58) { return { keyBytes: base58ToBytes(pk.publicKeyBase58), keyType: VM_TO_KEY_TYPE[pk.type] }; } else if (pk.publicKeyBase64) { return { keyBytes: base64ToBytes(pk.publicKeyBase64), keyType: VM_TO_KEY_TYPE[pk.type] }; } else if (pk.publicKeyHex) { return { keyBytes: hexToBytes(pk.publicKeyHex), keyType: VM_TO_KEY_TYPE[pk.type] }; } else if (pk.publicKeyJwk && pk.publicKeyJwk.crv === 'secp256k1' && pk.publicKeyJwk.x && pk.publicKeyJwk.y) { return { keyBytes: secp256k1.ProjectivePoint.fromAffine({ x: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.x)), y: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.y)) }).toRawBytes(false), keyType: 'Secp256k1' }; } else if (pk.publicKeyJwk && pk.publicKeyJwk.crv === 'P-256' && pk.publicKeyJwk.x && pk.publicKeyJwk.y) { return { keyBytes: p256.ProjectivePoint.fromAffine({ x: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.x)), y: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.y)) }).toRawBytes(false), keyType: 'P-256' }; } else if (pk.publicKeyJwk && pk.publicKeyJwk.kty === 'OKP' && [ 'Ed25519', 'X25519' ].includes(pk.publicKeyJwk.crv ?? '') && pk.publicKeyJwk.x) { return { keyBytes: base64ToBytes(pk.publicKeyJwk.x), keyType: pk.publicKeyJwk.crv }; } else if (pk.publicKeyMultibase) { const { keyBytes, keyType } = multibaseToBytes(pk.publicKeyMultibase); return { keyBytes, keyType: keyType ?? VM_TO_KEY_TYPE[pk.type] }; } return { keyBytes: new Uint8Array() }; } /** * Encodes the given byte array to a multibase string (defaulting to base58btc). * If a codec is provided, the corresponding multicodec prefix will be added. * * @param b - the Uint8Array to be encoded * @param base - the base to use for encoding (defaults to base58btc) * @param codec - the codec to use for encoding (defaults to no codec) * * @returns the multibase encoded string * * @public */ export function bytesToMultibase(b, base = 'base58btc', codec) { if (!codec) { return u8a.toString(encode(base, b), 'utf-8'); } else { const codecCode = typeof codec === 'string' ? supportedCodecs[codec] : codec; const prefixLength = varint.encodingLength(codecCode); const multicodecEncoding = new Uint8Array(prefixLength + b.length); varint.encodeTo(codecCode, multicodecEncoding) // set prefix ; multicodecEncoding.set(b, prefixLength) // add the original bytes ; return u8a.toString(encode(base, multicodecEncoding), 'utf-8'); } } /** * Converts a multibase string to the Uint8Array it represents. * This method will assume the byte array that is multibase encoded is a multicodec and will attempt to decode it. * * @param s - the string to be converted * * @throws if the string is not formatted correctly. * * @public */ export function multibaseToBytes(s) { const bytes = decode(s); // look for known key lengths first // Ed25519/X25519, secp256k1/P256 compressed or not, BLS12-381 G1/G2 compressed if ([ 32, 33, 48, 64, 65, 96 ].includes(bytes.length)) { return { keyBytes: bytes }; } // then assume multicodec, otherwise return the bytes try { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [codec, length] = varint.decode(bytes); const possibleCodec = Object.entries(supportedCodecs).filter(([, code]) => code === codec)?.[0][0] ?? ''; return { keyBytes: bytes.slice(length), keyType: CODEC_TO_KEY_TYPE[possibleCodec] }; } catch (e) { // not a multicodec, return the bytes return { keyBytes: bytes }; } } export function hexToBytes(s, minLength) { let input = s.startsWith('0x') ? s.substring(2) : s; if (input.length % 2 !== 0) { input = `0${input}`; } if (minLength) { const paddedLength = Math.max(input.length, minLength * 2); input = input.padStart(paddedLength, '00'); } return u8a.fromString(input.toLowerCase(), 'base16'); } export function encodeBase64url(s) { return bytesToBase64url(u8a.fromString(s)); } export function decodeBase64url(s) { return u8a.toString(base64ToBytes(s)); } export function bytesToHex(b) { return u8a.toString(b, 'base16'); } export function bytesToBigInt(b) { return BigInt(`0x` + u8a.toString(b, 'base16')); } export function bigintToBytes(n, minLength) { return hexToBytes(n.toString(16), minLength); } export function stringToBytes(s) { return u8a.fromString(s, 'utf-8'); } export function toJose({ r, s, recoveryParam }, recoverable) { const jose = new Uint8Array(recoverable ? 65 : 64); jose.set(u8a.fromString(r, 'base16'), 0); jose.set(u8a.fromString(s, 'base16'), 32); if (recoverable) { if (typeof recoveryParam === 'undefined') { throw new Error('Signer did not return a recoveryParam'); } jose[64] = recoveryParam; } return bytesToBase64url(jose); } export function fromJose(signature) { const signatureBytes = base64ToBytes(signature); if (signatureBytes.length < 64 || signatureBytes.length > 65) { throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`); } const r = bytesToHex(signatureBytes.slice(0, 32)); const s = bytesToHex(signatureBytes.slice(32, 64)); const recoveryParam = signatureBytes.length === 65 ? signatureBytes[64] : undefined; return { r, s, recoveryParam }; } export function toSealed(ciphertext, tag) { return u8a.concat([ base64ToBytes(ciphertext), tag ? base64ToBytes(tag) : new Uint8Array(0) ]); } export function leftpad(data, size = 64) { if (data.length === size) return data; return '0'.repeat(size - data.length) + data; } /** * Generate random x25519 key pair. */ export function generateKeyPair() { const secretKey = x25519.utils.randomPrivateKey(); const publicKey = x25519.getPublicKey(secretKey); return { secretKey: secretKey, publicKey: publicKey }; } /** * Generate private-public x25519 key pair from `seed`. */ export function generateKeyPairFromSeed(seed) { if (seed.length !== 32) { throw new Error(`x25519: seed must be ${32} bytes`); } return { publicKey: x25519.getPublicKey(seed), secretKey: seed }; } export function genX25519EphemeralKeyPair() { const epk = generateKeyPair(); return { publicKeyJWK: { kty: 'OKP', crv: 'X25519', x: bytesToBase64url(epk.publicKey) }, secretKey: epk.secretKey }; } /** * Checks if a variable is defined and not null. * After this check, typescript sees the variable as defined. * * @param arg - The input to be verified * * @returns true if the input variable is defined. */ export function isDefined(arg) { return arg !== null && typeof arg !== 'undefined'; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/66378/output.js
JavaScript
import { concat, fromString, toString } from "uint8arrays"; import { x25519 } from "@noble/curves/ed25519"; import { varint } from "multiformats"; import { decode, encode } from "multibase"; import { secp256k1 } from "@noble/curves/secp256k1"; import { p256 } from "@noble/curves/p256"; const u8a = { toString, fromString, concat }; export function bytesToBase64url(b) { return u8a.toString(b, 'base64url'); } export function base64ToBytes(s) { const inputBase64Url = s.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); return u8a.fromString(inputBase64Url, 'base64url'); } export function bytesToBase64(b) { return u8a.toString(b, 'base64pad'); } export function base58ToBytes(s) { return u8a.fromString(s, 'base58btc'); } export function bytesToBase58(b) { return u8a.toString(b, 'base58btc'); } export const SUPPORTED_PUBLIC_KEY_TYPES = { ES256: [ 'JsonWebKey2020', 'Multikey', 'EcdsaSecp256r1VerificationKey2019' ], ES256K: [ 'EcdsaSecp256k1VerificationKey2019', /** * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress */ 'EcdsaSecp256k1RecoveryMethod2020', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1VerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1SignatureVerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'EcdsaPublicKeySecp256k1', /** * TODO - support R1 key as well * 'ConditionalProof2022', */ 'JsonWebKey2020', 'Multikey' ], 'ES256K-R': [ 'EcdsaSecp256k1VerificationKey2019', /** * Equivalent to EcdsaSecp256k1VerificationKey2019 when key is an ethereumAddress */ 'EcdsaSecp256k1RecoveryMethod2020', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1VerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'Secp256k1SignatureVerificationKey2018', /** * @deprecated, supported for backward compatibility. Equivalent to EcdsaSecp256k1VerificationKey2019 when key is * not an ethereumAddress */ 'EcdsaPublicKeySecp256k1', 'ConditionalProof2022', 'JsonWebKey2020', 'Multikey' ], Ed25519: [ 'ED25519SignatureVerification', 'Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'JsonWebKey2020', 'Multikey' ], EdDSA: [ 'ED25519SignatureVerification', 'Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'JsonWebKey2020', 'Multikey' ] }; export const VM_TO_KEY_TYPE = { Secp256k1SignatureVerificationKey2018: 'Secp256k1', Secp256k1VerificationKey2018: 'Secp256k1', EcdsaSecp256k1VerificationKey2019: 'Secp256k1', EcdsaPublicKeySecp256k1: 'Secp256k1', EcdsaSecp256k1RecoveryMethod2020: 'Secp256k1', EcdsaSecp256r1VerificationKey2019: 'P-256', Ed25519VerificationKey2018: 'Ed25519', Ed25519VerificationKey2020: 'Ed25519', ED25519SignatureVerification: 'Ed25519', X25519KeyAgreementKey2019: 'X25519', X25519KeyAgreementKey2020: 'X25519', ConditionalProof2022: void 0, JsonWebKey2020: void 0, Multikey: void 0 }; // this is from the multicodec table https://github.com/multiformats/multicodec/blob/master/table.csv export const supportedCodecs = { 'ed25519-pub': 0xed, 'x25519-pub': 0xec, 'secp256k1-pub': 0xe7, 'bls12_381-g1-pub': 0xea, 'bls12_381-g2-pub': 0xeb, 'p256-pub': 0x1200 }; export const CODEC_TO_KEY_TYPE = { 'bls12_381-g1-pub': 'Bls12381G1', 'bls12_381-g2-pub': 'Bls12381G2', 'ed25519-pub': 'Ed25519', 'p256-pub': 'P-256', 'secp256k1-pub': 'Secp256k1', 'x25519-pub': 'X25519' }; /** * Extracts the raw byte representation of a public key from a VerificationMethod along with an inferred key type * @param pk a VerificationMethod entry from a DIDDocument * @return an object containing the `keyBytes` of the public key and an inferred `keyType` */ export function extractPublicKeyBytes(pk) { if (pk.publicKeyBase58) return { keyBytes: base58ToBytes(pk.publicKeyBase58), keyType: VM_TO_KEY_TYPE[pk.type] }; if (pk.publicKeyBase64) return { keyBytes: base64ToBytes(pk.publicKeyBase64), keyType: VM_TO_KEY_TYPE[pk.type] }; if (pk.publicKeyHex) return { keyBytes: hexToBytes(pk.publicKeyHex), keyType: VM_TO_KEY_TYPE[pk.type] }; if (pk.publicKeyJwk && 'secp256k1' === pk.publicKeyJwk.crv && pk.publicKeyJwk.x && pk.publicKeyJwk.y) return { keyBytes: secp256k1.ProjectivePoint.fromAffine({ x: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.x)), y: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.y)) }).toRawBytes(!1), keyType: 'Secp256k1' }; if (pk.publicKeyJwk && 'P-256' === pk.publicKeyJwk.crv && pk.publicKeyJwk.x && pk.publicKeyJwk.y) return { keyBytes: p256.ProjectivePoint.fromAffine({ x: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.x)), y: bytesToBigInt(base64ToBytes(pk.publicKeyJwk.y)) }).toRawBytes(!1), keyType: 'P-256' }; if (pk.publicKeyJwk && 'OKP' === pk.publicKeyJwk.kty && [ 'Ed25519', 'X25519' ].includes(pk.publicKeyJwk.crv ?? '') && pk.publicKeyJwk.x) return { keyBytes: base64ToBytes(pk.publicKeyJwk.x), keyType: pk.publicKeyJwk.crv }; if (pk.publicKeyMultibase) { const { keyBytes, keyType } = multibaseToBytes(pk.publicKeyMultibase); return { keyBytes, keyType: keyType ?? VM_TO_KEY_TYPE[pk.type] }; } return { keyBytes: new Uint8Array() }; } /** * Encodes the given byte array to a multibase string (defaulting to base58btc). * If a codec is provided, the corresponding multicodec prefix will be added. * * @param b - the Uint8Array to be encoded * @param base - the base to use for encoding (defaults to base58btc) * @param codec - the codec to use for encoding (defaults to no codec) * * @returns the multibase encoded string * * @public */ export function bytesToMultibase(b, base = 'base58btc', codec) { if (!codec) return u8a.toString(encode(base, b), 'utf-8'); { const codecCode = 'string' == typeof codec ? supportedCodecs[codec] : codec, prefixLength = varint.encodingLength(codecCode), multicodecEncoding = new Uint8Array(prefixLength + b.length); return varint.encodeTo(codecCode, multicodecEncoding) // set prefix , multicodecEncoding.set(b, prefixLength) // add the original bytes , u8a.toString(encode(base, multicodecEncoding), 'utf-8'); } } /** * Converts a multibase string to the Uint8Array it represents. * This method will assume the byte array that is multibase encoded is a multicodec and will attempt to decode it. * * @param s - the string to be converted * * @throws if the string is not formatted correctly. * * @public */ export function multibaseToBytes(s) { const bytes = decode(s); // look for known key lengths first // Ed25519/X25519, secp256k1/P256 compressed or not, BLS12-381 G1/G2 compressed if ([ 32, 33, 48, 64, 65, 96 ].includes(bytes.length)) return { keyBytes: bytes }; // then assume multicodec, otherwise return the bytes try { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [codec, length] = varint.decode(bytes), possibleCodec = Object.entries(supportedCodecs).filter(([, code])=>code === codec)?.[0][0] ?? ''; return { keyBytes: bytes.slice(length), keyType: CODEC_TO_KEY_TYPE[possibleCodec] }; } catch (e) { // not a multicodec, return the bytes return { keyBytes: bytes }; } } export function hexToBytes(s, minLength) { let input = s.startsWith('0x') ? s.substring(2) : s; if (input.length % 2 != 0 && (input = `0${input}`), minLength) { const paddedLength = Math.max(input.length, 2 * minLength); input = input.padStart(paddedLength, '00'); } return u8a.fromString(input.toLowerCase(), 'base16'); } export function encodeBase64url(s) { return bytesToBase64url(u8a.fromString(s)); } export function decodeBase64url(s) { return u8a.toString(base64ToBytes(s)); } export function bytesToHex(b) { return u8a.toString(b, 'base16'); } export function bytesToBigInt(b) { return BigInt("0x" + u8a.toString(b, 'base16')); } export function bigintToBytes(n, minLength) { return hexToBytes(n.toString(16), minLength); } export function stringToBytes(s) { return u8a.fromString(s, 'utf-8'); } export function toJose({ r, s, recoveryParam }, recoverable) { const jose = new Uint8Array(recoverable ? 65 : 64); if (jose.set(u8a.fromString(r, 'base16'), 0), jose.set(u8a.fromString(s, 'base16'), 32), recoverable) { if (void 0 === recoveryParam) throw Error('Signer did not return a recoveryParam'); jose[64] = recoveryParam; } return bytesToBase64url(jose); } export function fromJose(signature) { const signatureBytes = base64ToBytes(signature); if (signatureBytes.length < 64 || signatureBytes.length > 65) throw TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`); return { r: bytesToHex(signatureBytes.slice(0, 32)), s: bytesToHex(signatureBytes.slice(32, 64)), recoveryParam: 65 === signatureBytes.length ? signatureBytes[64] : void 0 }; } export function toSealed(ciphertext, tag) { return u8a.concat([ base64ToBytes(ciphertext), tag ? base64ToBytes(tag) : new Uint8Array(0) ]); } export function leftpad(data, size = 64) { return data.length === size ? data : '0'.repeat(size - data.length) + data; } /** * Generate random x25519 key pair. */ export function generateKeyPair() { const secretKey = x25519.utils.randomPrivateKey(), publicKey = x25519.getPublicKey(secretKey); return { secretKey: secretKey, publicKey: publicKey }; } /** * Generate private-public x25519 key pair from `seed`. */ export function generateKeyPairFromSeed(seed) { if (32 !== seed.length) throw Error("x25519: seed must be 32 bytes"); return { publicKey: x25519.getPublicKey(seed), secretKey: seed }; } export function genX25519EphemeralKeyPair() { const epk = generateKeyPair(); return { publicKeyJWK: { kty: 'OKP', crv: 'X25519', x: bytesToBase64url(epk.publicKey) }, secretKey: epk.secretKey }; } /** * Checks if a variable is defined and not null. * After this check, typescript sees the variable as defined. * * @param arg - The input to be verified * * @returns true if the input variable is defined. */ export function isDefined(arg) { return null != arg; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/asmjs/1/input.js
JavaScript
export function foo(global, env, buffer) { "use asm"; var a = new global.Int8Array(buffer); var b = new global.Int16Array(buffer); var c = new global.Int32Array(buffer); var d = new global.Uint8Array(buffer); var e = new global.Uint16Array(buffer); var f = new global.Uint32Array(buffer); var g = new global.Float32Array(buffer); var h = new global.Float64Array(buffer); var i = env.DYNAMICTOP_PTR | 0; var j = env.tempDoublePtr | 0; var k = env.ABORT | 0; var l = env.STACKTOP | 0; var m = env.STACK_MAX | 0; var n = env.cttz_i8 | 0; var o = env.___dso_handle | 0; var p = 0; var q = 0; var r = 0; var s = 0; var t = global.NaN, u = global.Infinity; var v = 0, w = 0, x = 0, y = 0, z = 0.0; var A = 0; var B = global.Math.floor; var C = global.Math.abs; var D = global.Math.sqrt; var E = global.Math.pow; var F = global.Math.cos; var G = global.Math.sin; var H = global.Math.tan; var I = global.Math.acos; var J = global.Math.asin; var K = global.Math.atan; var L = global.Math.atan2; var M = global.Math.exp; var N = global.Math.log; var O = global.Math.ceil; var P = global.Math.imul; var Q = global.Math.min; var R = global.Math.max; var S = global.Math.clz32; var T = global.Math.fround; var U = env.abort; var V = env.assert; var W = env.enlargeMemory; var X = env.getTotalMemory; var Y = env.abortOnCannotGrowMemory; var Z = env.invoke_viiiii; var _ = env.invoke_vif; var $ = env.invoke_vid; var aa = env.invoke_fiff; var ba = env.invoke_vi; var ca = env.invoke_vii; var da = env.invoke_ii; var ea = env.invoke_viddi; var fa = env.invoke_vidd; var ga = env.invoke_iiii; var ha = env.invoke_diii; var ia = env.invoke_di; var ja = env.invoke_iid; var ka = env.invoke_iii; var la = env.invoke_viiddi; var ma = env.invoke_viiiiii; var na = env.invoke_dii; var oa = env.invoke_i; var pa = env.invoke_iiiiii; var qa = env.invoke_viiid; var ra = env.invoke_viififi; var sa = env.invoke_viii; var ta = env.invoke_v; var ua = env.invoke_viid; var va = env.invoke_idd; var wa = env.invoke_viiii; var xa = env._emscripten_asm_const_iiiii; var ya = env._emscripten_asm_const_iiidddddd; var za = env._emscripten_asm_const_iiiid; var Aa = env.__nbind_reference_external; var Ba = env._emscripten_asm_const_iiiiiiii; var Ca = env._removeAccessorPrefix; var Da = env._typeModule; var Ea = env.__nbind_register_pool; var Fa = env.__decorate; var Ga = env._llvm_stackrestore; var Ha = env.___cxa_atexit; var Ia = env.__extends; var Ja = env.__nbind_get_value_object; var Ka = env.__ZN8facebook4yoga14YGNodeToStringEPNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEP6YGNode14YGPrintOptionsj; var La = env._emscripten_set_main_loop_timing; var Ma = env.__nbind_register_primitive; var Na = env.__nbind_register_type; var Oa = env._emscripten_memcpy_big; var Pa = env.__nbind_register_function; var Qa = env.___setErrNo; var Ra = env.__nbind_register_class; var Sa = env.__nbind_finish; var Ta = env._abort; var Ua = env._nbind_value; var Va = env._llvm_stacksave; var Wa = env.___syscall54; var Xa = env._defineHidden; var Ya = env._emscripten_set_main_loop; var Za = env._emscripten_get_now; var _a = env.__nbind_register_callback_signature; var $a = env._emscripten_asm_const_iiiiii; var ab = env.__nbind_free_external; var bb = env._emscripten_asm_const_iiii; var cb = env._emscripten_asm_const_iiididi; var db = env.___syscall6; var eb = env._atexit; var fb = env.___syscall140; var gb = env.___syscall146; var hb = T(0); const ib = T(0); // EMSCRIPTEN_START_FUNCS function Jb(a) { a = a | 0; var b = 0; b = l; l = (l + a) | 0; l = (l + 15) & -16; return b | 0; } function Kb() { return l | 0; } function Lb(a) { a = a | 0; l = a; } function Mb(a, b) { a = a | 0; b = b | 0; l = a; m = b; } function Nb(a, b) { a = a | 0; b = b | 0; if (!p) { p = a; q = b; } } function Ob(a) { a = a | 0; A = a; } function Pb() { return A | 0; } function Qb() { var b = 0, d = 0; BC(8104, 8, 400) | 0; BC(8504, 408, 540) | 0; b = 9044; d = (b + 44) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); a[9088] = 0; a[9089] = 1; c[2273] = 0; c[2274] = 948; c[2275] = 948; Ha(17, 8104, o | 0) | 0; return; } function Rb(a) { a = a | 0; oc((a + 948) | 0); return; } function Sb(a) { a = T(a); return (((af(a) | 0) & 2147483647) >>> 0 > 2139095040) | 0; } function Tb(a, b, d) { a = a | 0; b = b | 0; d = d | 0; a: do if (!(c[(a + (b << 3) + 4) >> 2] | 0)) { if ((b | 2 | 0) == 3 ? c[(a + 60) >> 2] | 0 : 0) { a = (a + 56) | 0; break; } switch (b | 0) { case 0: case 2: case 4: case 5: { if (c[(a + 52) >> 2] | 0) { a = (a + 48) | 0; break a; } break; } default: { } } if (!(c[(a + 68) >> 2] | 0)) { a = (b | 1 | 0) == 5 ? 948 : d; break; } else { a = (a + 64) | 0; break; } } else a = (a + (b << 3)) | 0; while (0); return a | 0; } function Ub(b) { b = b | 0; var d = 0; d = oB(1e3) | 0; Vb(b, (d | 0) != 0, 2456); c[2276] = (c[2276] | 0) + 1; BC(d | 0, 8104, 1e3) | 0; if (a[(b + 2) >> 0] | 0) { c[(d + 4) >> 2] = 2; c[(d + 12) >> 2] = 4; } c[(d + 976) >> 2] = b; return d | 0; } function Vb(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; f = l; l = (l + 16) | 0; e = f; if (!b) { c[e >> 2] = d; fe(a, 5, 3197, e); } l = f; return; } function Wb() { return Ub(956) | 0; } function Xb(a) { a = a | 0; var b = 0; b = qC(1e3) | 0; Yb(b, a); Vb(c[(a + 976) >> 2] | 0, 1, 2456); c[2276] = (c[2276] | 0) + 1; c[(b + 944) >> 2] = 0; return b | 0; } function Yb(a, b) { a = a | 0; b = b | 0; var d = 0; BC(a | 0, b | 0, 948) | 0; ie((a + 948) | 0, (b + 948) | 0); d = (a + 960) | 0; a = (b + 960) | 0; b = (d + 40) | 0; do { c[d >> 2] = c[a >> 2]; d = (d + 4) | 0; a = (a + 4) | 0; } while ((d | 0) < (b | 0)); return; } function Zb(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0; b = (a + 944) | 0; d = c[b >> 2] | 0; if (d | 0) { _b((d + 948) | 0, a) | 0; c[b >> 2] = 0; } d = $b(a) | 0; if (d | 0) { b = 0; do { c[((ac(a, b) | 0) + 944) >> 2] = 0; b = (b + 1) | 0; } while ((b | 0) != (d | 0)); } d = (a + 948) | 0; e = c[d >> 2] | 0; f = (a + 952) | 0; b = c[f >> 2] | 0; if ((b | 0) != (e | 0)) c[f >> 2] = b + (~(((b + -4 - e) | 0) >>> 2) << 2); bc(d); pB(a); c[2276] = (c[2276] | 0) + -1; return; } function _b(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; e = c[a >> 2] | 0; i = (a + 4) | 0; d = c[i >> 2] | 0; g = d; a: do if ((e | 0) == (d | 0)) { f = e; h = 4; } else { a = e; while (1) { if ((c[a >> 2] | 0) == (b | 0)) { f = a; h = 4; break a; } a = (a + 4) | 0; if ((a | 0) == (d | 0)) { a = 0; break; } } } while (0); if ((h | 0) == 4) if ((f | 0) != (d | 0)) { e = (f + 4) | 0; a = (g - e) | 0; b = a >> 2; if (b) { GC(f | 0, e | 0, a | 0) | 0; d = c[i >> 2] | 0; } a = (f + (b << 2)) | 0; if ((d | 0) == (a | 0)) a = 1; else { c[i >> 2] = d + (~(((d + -4 - a) | 0) >>> 2) << 2); a = 1; } } else a = 0; return a | 0; } function $b(a) { a = a | 0; return (((c[(a + 952) >> 2] | 0) - (c[(a + 948) >> 2] | 0)) >> 2) | 0; } function ac(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[(a + 948) >> 2] | 0; if ((((c[(a + 952) >> 2] | 0) - d) >> 2) >>> 0 > b >>> 0) a = c[(d + (b << 2)) >> 2] | 0; else a = 0; return a | 0; } function bc(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0; e = l; l = (l + 32) | 0; b = e; f = c[a >> 2] | 0; d = ((c[(a + 4) >> 2] | 0) - f) | 0; if ((((c[(a + 8) >> 2] | 0) - f) | 0) >>> 0 > d >>> 0) { f = d >> 2; bf(b, f, f, (a + 8) | 0); cf(a, b); df(b); } l = e; return; } function cc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; k = $b(a) | 0; do if (k | 0) { if ((c[((ac(a, 0) | 0) + 944) >> 2] | 0) == (a | 0)) { if (!(_b((a + 948) | 0, b) | 0)) break; BC((b + 400) | 0, 8504, 540) | 0; c[(b + 944) >> 2] = 0; nc(a); break; } h = c[((c[(a + 976) >> 2] | 0) + 12) >> 2] | 0; i = (a + 948) | 0; j = (h | 0) == 0; d = 0; g = 0; do { e = c[((c[i >> 2] | 0) + (g << 2)) >> 2] | 0; if ((e | 0) == (b | 0)) nc(a); else { f = Xb(e) | 0; c[((c[i >> 2] | 0) + (d << 2)) >> 2] = f; c[(f + 944) >> 2] = a; if (!j) Ib[h & 15](e, f, a, d); d = (d + 1) | 0; } g = (g + 1) | 0; } while ((g | 0) != (k | 0)); if (d >>> 0 < k >>> 0) { j = (a + 948) | 0; i = (a + 952) | 0; h = d; d = c[i >> 2] | 0; do { g = ((c[j >> 2] | 0) + (h << 2)) | 0; e = (g + 4) | 0; f = (d - e) | 0; b = f >> 2; if (!b) f = d; else { GC(g | 0, e | 0, f | 0) | 0; d = c[i >> 2] | 0; f = d; } e = (g + (b << 2)) | 0; if ((f | 0) != (e | 0)) { d = (f + (~(((f + -4 - e) | 0) >>> 2) << 2)) | 0; c[i >> 2] = d; } h = (h + 1) | 0; } while ((h | 0) != (k | 0)); } } while (0); return; } function dc(b) { b = b | 0; var d = 0, e = 0, f = 0, g = 0; ec(b, ($b(b) | 0) == 0, 2491); ec(b, (c[(b + 944) >> 2] | 0) == 0, 2545); d = (b + 948) | 0; e = c[d >> 2] | 0; f = (b + 952) | 0; g = c[f >> 2] | 0; if ((g | 0) != (e | 0)) c[f >> 2] = g + (~(((g + -4 - e) | 0) >>> 2) << 2); bc(d); d = (b + 976) | 0; e = c[d >> 2] | 0; BC(b | 0, 8104, 1e3) | 0; if (a[(e + 2) >> 0] | 0) { c[(b + 4) >> 2] = 2; c[(b + 12) >> 2] = 4; } c[d >> 2] = e; return; } function ec(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; f = l; l = (l + 16) | 0; e = f; if (!b) { c[e >> 2] = d; Vd(a, 5, 3197, e); } l = f; return; } function fc() { return c[2276] | 0; } function gc() { var a = 0; a = oB(20) | 0; hc((a | 0) != 0, 2592); c[2277] = (c[2277] | 0) + 1; c[a >> 2] = c[239]; c[(a + 4) >> 2] = c[240]; c[(a + 8) >> 2] = c[241]; c[(a + 12) >> 2] = c[242]; c[(a + 16) >> 2] = c[243]; return a | 0; } function hc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = l; l = (l + 16) | 0; d = e; if (!a) { c[d >> 2] = b; Vd(0, 5, 3197, d); } l = e; return; } function ic(a) { a = a | 0; pB(a); c[2277] = (c[2277] | 0) + -1; return; } function jc(a, b) { a = a | 0; b = b | 0; var d = 0; if (!b) { d = 0; b = 0; } else { ec(a, ($b(a) | 0) == 0, 2629); d = 1; } c[(a + 964) >> 2] = b; c[(a + 988) >> 2] = d; return; } function kc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; g = (e + 8) | 0; f = (e + 4) | 0; h = e; c[f >> 2] = b; ec(a, (c[(b + 944) >> 2] | 0) == 0, 2709); ec(a, (c[(a + 964) >> 2] | 0) == 0, 2763); lc(a); b = (a + 948) | 0; c[h >> 2] = (c[b >> 2] | 0) + (d << 2); c[g >> 2] = c[h >> 2]; mc(b, g, f) | 0; c[((c[f >> 2] | 0) + 944) >> 2] = a; nc(a); l = e; return; } function lc(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = $b(a) | 0; if (d | 0 ? (c[((ac(a, 0) | 0) + 944) >> 2] | 0) != (a | 0) : 0) { e = c[((c[(a + 976) >> 2] | 0) + 12) >> 2] | 0; f = (a + 948) | 0; g = (e | 0) == 0; b = 0; do { h = c[((c[f >> 2] | 0) + (b << 2)) >> 2] | 0; i = Xb(h) | 0; c[((c[f >> 2] | 0) + (b << 2)) >> 2] = i; c[(i + 944) >> 2] = a; if (!g) Ib[e & 15](h, i, a, b); b = (b + 1) | 0; } while ((b | 0) != (d | 0)); } return; } function mc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0; s = l; l = (l + 64) | 0; n = (s + 52) | 0; i = (s + 48) | 0; o = (s + 28) | 0; p = (s + 24) | 0; q = (s + 20) | 0; r = s; e = c[a >> 2] | 0; g = e; b = (e + ((((c[b >> 2] | 0) - g) >> 2) << 2)) | 0; e = (a + 4) | 0; f = c[e >> 2] | 0; h = (a + 8) | 0; do if (f >>> 0 < (c[h >> 2] | 0) >>> 0) { if ((b | 0) == (f | 0)) { c[b >> 2] = c[d >> 2]; c[e >> 2] = (c[e >> 2] | 0) + 4; break; } ef(a, b, f, (b + 4) | 0); if (b >>> 0 <= d >>> 0) d = (c[e >> 2] | 0) >>> 0 > d >>> 0 ? (d + 4) | 0 : d; c[b >> 2] = c[d >> 2]; } else { e = (((f - g) >> 2) + 1) | 0; f = le(a) | 0; if (f >>> 0 < e >>> 0) jC(a); m = c[a >> 2] | 0; k = ((c[h >> 2] | 0) - m) | 0; g = k >> 1; bf( r, (k >> 2) >>> 0 < (f >>> 1) >>> 0 ? g >>> 0 < e >>> 0 ? e : g : f, (b - m) >> 2, (a + 8) | 0 ); m = (r + 8) | 0; e = c[m >> 2] | 0; g = (r + 12) | 0; k = c[g >> 2] | 0; h = k; j = e; do if ((e | 0) == (k | 0)) { k = (r + 4) | 0; e = c[k >> 2] | 0; t = c[r >> 2] | 0; f = t; if (e >>> 0 <= t >>> 0) { e = (h - f) >> 1; e = (e | 0) == 0 ? 1 : e; bf(o, e, e >>> 2, c[(r + 16) >> 2] | 0); c[p >> 2] = c[k >> 2]; c[q >> 2] = c[m >> 2]; c[i >> 2] = c[p >> 2]; c[n >> 2] = c[q >> 2]; gf(o, i, n); e = c[r >> 2] | 0; c[r >> 2] = c[o >> 2]; c[o >> 2] = e; e = (o + 4) | 0; t = c[k >> 2] | 0; c[k >> 2] = c[e >> 2]; c[e >> 2] = t; e = (o + 8) | 0; t = c[m >> 2] | 0; c[m >> 2] = c[e >> 2]; c[e >> 2] = t; e = (o + 12) | 0; t = c[g >> 2] | 0; c[g >> 2] = c[e >> 2]; c[e >> 2] = t; df(o); e = c[m >> 2] | 0; break; } g = e; h = (((((g - f) >> 2) + 1) | 0) / -2) | 0; i = (e + (h << 2)) | 0; f = (j - g) | 0; g = f >> 2; if (g) { GC(i | 0, e | 0, f | 0) | 0; e = c[k >> 2] | 0; } t = (i + (g << 2)) | 0; c[m >> 2] = t; c[k >> 2] = e + (h << 2); e = t; } while (0); c[e >> 2] = c[d >> 2]; c[m >> 2] = (c[m >> 2] | 0) + 4; b = ff(a, r, b) | 0; df(r); } while (0); l = s; return b | 0; } function nc(b) { b = b | 0; var d = 0; do { d = (b + 984) | 0; if (a[d >> 0] | 0) break; a[d >> 0] = 1; g[(b + 504) >> 2] = T(t); b = c[(b + 944) >> 2] | 0; } while ((b | 0) != 0); return; } function oc(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -4 - e) | 0) >>> 2) << 2); sC(d); } return; } function pc(a) { a = a | 0; return c[(a + 944) >> 2] | 0; } function qc(a) { a = a | 0; ec(a, (c[(a + 964) >> 2] | 0) != 0, 2832); nc(a); return; } function rc(b) { b = b | 0; return ((a[(b + 984) >> 0] | 0) != 0) | 0; } function sc(a, b) { a = a | 0; b = b | 0; if (BB(a, b, 400) | 0) { BC(a | 0, b | 0, 400) | 0; nc(a); } return; } function tc(a) { a = a | 0; var b = ib; b = T(g[(a + 44) >> 2]); a = Sb(b) | 0; return T(a ? T(0.0) : b); } function uc(b) { b = b | 0; var d = ib; d = T(g[(b + 48) >> 2]); if (Sb(d) | 0) d = a[((c[(b + 976) >> 2] | 0) + 2) >> 0] | 0 ? T(1.0) : T(0.0); return T(d); } function vc(a, b) { a = a | 0; b = b | 0; c[(a + 980) >> 2] = b; return; } function wc(a) { a = a | 0; return c[(a + 980) >> 2] | 0; } function xc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 4) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function yc(a) { a = a | 0; return c[(a + 4) >> 2] | 0; } function zc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 8) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ac(a) { a = a | 0; return c[(a + 8) >> 2] | 0; } function Bc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 12) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Cc(a) { a = a | 0; return c[(a + 12) >> 2] | 0; } function Dc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 16) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ec(a) { a = a | 0; return c[(a + 16) >> 2] | 0; } function Fc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 20) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Gc(a) { a = a | 0; return c[(a + 20) >> 2] | 0; } function Hc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 24) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ic(a) { a = a | 0; return c[(a + 24) >> 2] | 0; } function Jc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 28) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Kc(a) { a = a | 0; return c[(a + 28) >> 2] | 0; } function Lc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 32) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Mc(a) { a = a | 0; return c[(a + 32) >> 2] | 0; } function Nc(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 36) | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Oc(a) { a = a | 0; return c[(a + 36) >> 2] | 0; } function Pc(a, b) { a = a | 0; b = T(b); var c = 0; c = (a + 40) | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Qc(a, b) { a = a | 0; b = T(b); var c = 0; c = (a + 44) | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Rc(a, b) { a = a | 0; b = T(b); var c = 0; c = (a + 48) | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Sc(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 52) | 0; f = (a + 56) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function Tc(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = (a + 52) | 0; d = (a + 56) | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function Uc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 52) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function Vc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = (a + 132 + (b << 3)) | 0; b = (a + 132 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Wc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = (a + 132 + (b << 3)) | 0; b = (a + 132 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Xc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = (b + 132 + (d << 3)) | 0; b = c[(e + 4) >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[(d + 4) >> 2] = b; return; } function Yc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = (a + 60 + (b << 3)) | 0; b = (a + 60 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Zc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = (a + 60 + (b << 3)) | 0; b = (a + 60 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function _c(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = (b + 60 + (d << 3)) | 0; b = c[(e + 4) >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[(d + 4) >> 2] = b; return; } function $c(a, b) { a = a | 0; b = b | 0; var d = 0; d = (a + 60 + (b << 3) + 4) | 0; if ((c[d >> 2] | 0) != 3) { g[(a + 60 + (b << 3)) >> 2] = T(t); c[d >> 2] = 3; nc(a); } return; } function ad(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = (a + 204 + (b << 3)) | 0; b = (a + 204 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function bd(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = (a + 204 + (b << 3)) | 0; b = (a + 204 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function cd(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = (b + 204 + (d << 3)) | 0; b = c[(e + 4) >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[(d + 4) >> 2] = b; return; } function dd(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = (a + 276 + (b << 3)) | 0; b = (a + 276 + (b << 3) + 4) | 0; if (!(h | (T(g[f >> 2]) == d) ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function ed(a, b) { a = a | 0; b = b | 0; return T(g[(a + 276 + (b << 3)) >> 2]); } function fd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 348) | 0; f = (a + 352) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function gd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = (a + 348) | 0; d = (a + 352) | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function hd(a) { a = a | 0; var b = 0; b = (a + 352) | 0; if ((c[b >> 2] | 0) != 3) { g[(a + 348) >> 2] = T(t); c[b >> 2] = 3; nc(a); } return; } function id(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 348) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function jd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 356) | 0; f = (a + 360) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function kd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = (a + 356) | 0; d = (a + 360) | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function ld(a) { a = a | 0; var b = 0; b = (a + 360) | 0; if ((c[b >> 2] | 0) != 3) { g[(a + 356) >> 2] = T(t); c[b >> 2] = 3; nc(a); } return; } function md(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 356) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function nd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 364) | 0; f = (a + 368) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function od(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = (a + 364) | 0; f = (a + 368) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function pd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 364) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function qd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 372) | 0; f = (a + 376) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function rd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = (a + 372) | 0; f = (a + 376) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function sd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 372) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function td(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 380) | 0; f = (a + 384) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function ud(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = (a + 380) | 0; f = (a + 384) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function vd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 380) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function wd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = (a + 388) | 0; f = (a + 392) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function xd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = (a + 388) | 0; f = (a + 392) | 0; if (!(h | (T(g[e >> 2]) == b) ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function yd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = (b + 388) | 0; d = c[(e + 4) >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[(b + 4) >> 2] = d; return; } function zd(a, b) { a = a | 0; b = T(b); var c = 0; c = (a + 396) | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Ad(a) { a = a | 0; return T(g[(a + 396) >> 2]); } function Bd(a) { a = a | 0; return T(g[(a + 400) >> 2]); } function Cd(a) { a = a | 0; return T(g[(a + 404) >> 2]); } function Dd(a) { a = a | 0; return T(g[(a + 408) >> 2]); } function Ed(a) { a = a | 0; return T(g[(a + 412) >> 2]); } function Fd(a) { a = a | 0; return T(g[(a + 416) >> 2]); } function Gd(a) { a = a | 0; return T(g[(a + 420) >> 2]); } function Hd(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch (b | 0) { case 0: { b = (c[(a + 496) >> 2] | 0) == 2 ? 5 : 4; break; } case 2: { b = (c[(a + 496) >> 2] | 0) == 2 ? 4 : 5; break; } default: { } } return T(g[(a + 424 + (b << 2)) >> 2]); } function Id(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch (b | 0) { case 0: { b = (c[(a + 496) >> 2] | 0) == 2 ? 5 : 4; break; } case 2: { b = (c[(a + 496) >> 2] | 0) == 2 ? 4 : 5; break; } default: { } } return T(g[(a + 448 + (b << 2)) >> 2]); } function Jd(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch (b | 0) { case 0: { b = (c[(a + 496) >> 2] | 0) == 2 ? 5 : 4; break; } case 2: { b = (c[(a + 496) >> 2] | 0) == 2 ? 4 : 5; break; } default: { } } return T(g[(a + 472 + (b << 2)) >> 2]); } function Kd(a, b) { a = a | 0; b = b | 0; var d = 0, e = ib; d = c[(a + 4) >> 2] | 0; if ((d | 0) == (c[(b + 4) >> 2] | 0)) { if (!d) a = 1; else { e = T(g[a >> 2]); a = T(C(T(e - T(g[b >> 2])))) < T(0.0000999999974); } } else a = 0; return a | 0; } function Ld(a, b) { a = T(a); b = T(b); var c = 0; if (Sb(a) | 0) c = Sb(b) | 0; else c = T(C(T(a - b))) < T(0.0000999999974); return c | 0; } function Md(a, b) { a = a | 0; b = b | 0; Nd(a, b); return; } function Nd(b, d) { b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = (e + 4) | 0; c[f >> 2] = 0; c[(f + 4) >> 2] = 0; c[(f + 8) >> 2] = 0; Ka(f | 0, b | 0, d | 0, 0); Vd(b, 3, (a[(f + 11) >> 0] | 0) < 0 ? c[f >> 2] | 0 : f, e); tC(f); l = e; return; } function Od(a, b, c, d) { a = T(a); b = T(b); c = c | 0; d = d | 0; var e = ib; a = T(a * b); e = T(gC(a, T(1.0))); do if (!(Ld(e, T(0.0)) | 0)) { a = T(a - e); if (Ld(e, T(1.0)) | 0) { a = T(a + T(1.0)); break; } if (c) { a = T(a + T(1.0)); break; } if (!d) { if (e > T(0.5)) e = T(1.0); else { d = Ld(e, T(0.5)) | 0; e = d ? T(1.0) : T(0.0); } a = T(a + e); } } else a = T(a - e); while (0); return T(a / b); } function Pd(a, b, c, d, e, f, h, i, j, k, l, m, n) { a = a | 0; b = T(b); c = c | 0; d = T(d); e = e | 0; f = T(f); h = h | 0; i = T(i); j = T(j); k = T(k); l = T(l); m = T(m); n = n | 0; var o = 0, p = ib, q = ib, r = ib, s = ib, t = ib, u = ib; if ((j < T(0.0)) | (k < T(0.0))) n = 0; else { if ((n | 0) != 0 ? ((p = T(g[(n + 4) >> 2])), p != T(0.0)) : 0) { r = T(Od(b, p, 0, 0)); s = T(Od(d, p, 0, 0)); q = T(Od(f, p, 0, 0)); p = T(Od(i, p, 0, 0)); } else { q = f; r = b; p = i; s = d; } if ((e | 0) == (a | 0)) o = Ld(q, r) | 0; else o = 0; if ((h | 0) == (c | 0)) n = Ld(p, s) | 0; else n = 0; if ( (!o ? ((t = T(b - l)), !(Qd(a, t, j) | 0)) : 0) ? !(Rd(a, t, e, j) | 0) : 0 ) o = Sd(a, t, e, f, j) | 0; else o = 1; if ( (!n ? ((u = T(d - m)), !(Qd(c, u, k) | 0)) : 0) ? !(Rd(c, u, h, k) | 0) : 0 ) n = Sd(c, u, h, i, k) | 0; else n = 1; n = o & n; } return n | 0; } function Qd(a, b, c) { a = a | 0; b = T(b); c = T(c); if ((a | 0) == 1) a = Ld(b, c) | 0; else a = 0; return a | 0; } function Rd(a, b, c, d) { a = a | 0; b = T(b); c = c | 0; d = T(d); if (((a | 0) == 2) & ((c | 0) == 0)) { if (!(b >= d)) a = Ld(b, d) | 0; else a = 1; } else a = 0; return a | 0; } function Sd(a, b, c, d, e) { a = a | 0; b = T(b); c = c | 0; d = T(d); e = T(e); if (((a | 0) == 2) & ((c | 0) == 2) & (d > b)) { if (!(e <= b)) a = Ld(b, e) | 0; else a = 1; } else a = 0; return a | 0; } function Td(b, d, e, f, i, j, k, m, n, o, p) { b = b | 0; d = T(d); e = T(e); f = f | 0; i = i | 0; j = j | 0; k = T(k); m = T(m); n = n | 0; o = o | 0; p = p | 0; var q = 0, r = 0, s = 0, t = 0, u = ib, v = ib, w = 0, x = 0, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = ib, I = ib, J = ib, K = 0.0, L = 0.0; G = l; l = (l + 160) | 0; D = (G + 152) | 0; C = (G + 120) | 0; B = (G + 104) | 0; y = (G + 72) | 0; t = (G + 56) | 0; A = (G + 8) | 0; x = G; z = ((c[2279] | 0) + 1) | 0; c[2279] = z; E = (b + 984) | 0; if ((a[E >> 0] | 0) != 0 ? (c[(b + 512) >> 2] | 0) != (c[2278] | 0) : 0) w = 4; else if ((c[(b + 516) >> 2] | 0) == (f | 0)) F = 0; else w = 4; if ((w | 0) == 4) { c[(b + 520) >> 2] = 0; c[(b + 924) >> 2] = -1; c[(b + 928) >> 2] = -1; g[(b + 932) >> 2] = T(-1.0); g[(b + 936) >> 2] = T(-1.0); F = 1; } a: do if (!(c[(b + 964) >> 2] | 0)) { if (n) { q = (b + 916) | 0; if (!(Ld(T(g[q >> 2]), d) | 0)) { w = 21; break; } if (!(Ld(T(g[(b + 920) >> 2]), e) | 0)) { w = 21; break; } if ((c[(b + 924) >> 2] | 0) != (i | 0)) { w = 21; break; } q = (c[(b + 928) >> 2] | 0) == (j | 0) ? q : 0; w = 22; break; } s = c[(b + 520) >> 2] | 0; if (!s) w = 21; else { r = 0; while (1) { q = (b + 524 + ((r * 24) | 0)) | 0; if ( ( ( Ld(T(g[q >> 2]), d) | 0 ? Ld( T( g[ (b + 524 + ((r * 24) | 0) + 4) >> 2 ] ), e ) | 0 : 0 ) ? (c[(b + 524 + ((r * 24) | 0) + 8) >> 2] | 0) == (i | 0) : 0 ) ? (c[(b + 524 + ((r * 24) | 0) + 12) >> 2] | 0) == (j | 0) : 0 ) { w = 22; break a; } r = (r + 1) | 0; if (r >>> 0 >= s >>> 0) { w = 21; break; } } } } else { u = T(Ud(b, 2, k)); v = T(Ud(b, 0, k)); q = (b + 916) | 0; J = T(g[q >> 2]); I = T(g[(b + 920) >> 2]); H = T(g[(b + 932) >> 2]); if ( !( Pd( i, d, j, e, c[(b + 924) >> 2] | 0, J, c[(b + 928) >> 2] | 0, I, H, T(g[(b + 936) >> 2]), u, v, p ) | 0 ) ) { s = c[(b + 520) >> 2] | 0; if (!s) w = 21; else { r = 0; while (1) { q = (b + 524 + ((r * 24) | 0)) | 0; H = T(g[q >> 2]); I = T(g[(b + 524 + ((r * 24) | 0) + 4) >> 2]); J = T(g[(b + 524 + ((r * 24) | 0) + 16) >> 2]); if ( Pd( i, d, j, e, c[(b + 524 + ((r * 24) | 0) + 8) >> 2] | 0, H, c[(b + 524 + ((r * 24) | 0) + 12) >> 2] | 0, I, J, T(g[(b + 524 + ((r * 24) | 0) + 20) >> 2]), u, v, p ) | 0 ) { w = 22; break a; } r = (r + 1) | 0; if (r >>> 0 >= s >>> 0) { w = 21; break; } } } } else w = 22; } while (0); do if ((w | 0) == 21) { if (!(a[11697] | 0)) { q = 0; w = 31; } else { q = 0; w = 28; } } else if ((w | 0) == 22) { r = (a[11697] | 0) != 0; if (!(((q | 0) != 0) & (F ^ 1))) if (r) { w = 28; break; } else { w = 31; break; } t = (q + 16) | 0; c[(b + 908) >> 2] = c[t >> 2]; s = (q + 20) | 0; c[(b + 912) >> 2] = c[s >> 2]; if (!(((a[11698] | 0) == 0) | (r ^ 1))) { c[x >> 2] = Wd(z) | 0; c[(x + 4) >> 2] = z; Vd(b, 4, 2972, x); r = c[(b + 972) >> 2] | 0; if (r | 0) nb[r & 127](b); i = Xd(i, n) | 0; j = Xd(j, n) | 0; L = +T(g[t >> 2]); K = +T(g[s >> 2]); c[A >> 2] = i; c[(A + 4) >> 2] = j; h[(A + 8) >> 3] = +d; h[(A + 16) >> 3] = +e; h[(A + 24) >> 3] = L; h[(A + 32) >> 3] = K; c[(A + 40) >> 2] = o; Vd(b, 4, 2989, A); } } while (0); if ((w | 0) == 28) { r = Wd(z) | 0; c[t >> 2] = r; c[(t + 4) >> 2] = z; c[(t + 8) >> 2] = F ? 3047 : 11699; Vd(b, 4, 3038, t); r = c[(b + 972) >> 2] | 0; if (r | 0) nb[r & 127](b); A = Xd(i, n) | 0; w = Xd(j, n) | 0; c[y >> 2] = A; c[(y + 4) >> 2] = w; h[(y + 8) >> 3] = +d; h[(y + 16) >> 3] = +e; c[(y + 24) >> 2] = o; Vd(b, 4, 3049, y); w = 31; } if ((w | 0) == 31) { Yd(b, d, e, f, i, j, k, m, n, p); if (a[11697] | 0) { r = c[2279] | 0; A = Wd(r) | 0; c[B >> 2] = A; c[(B + 4) >> 2] = r; c[(B + 8) >> 2] = F ? 3047 : 11699; Vd(b, 4, 3083, B); r = c[(b + 972) >> 2] | 0; if (r | 0) nb[r & 127](b); A = Xd(i, n) | 0; B = Xd(j, n) | 0; K = +T(g[(b + 908) >> 2]); L = +T(g[(b + 912) >> 2]); c[C >> 2] = A; c[(C + 4) >> 2] = B; h[(C + 8) >> 3] = K; h[(C + 16) >> 3] = L; c[(C + 24) >> 2] = o; Vd(b, 4, 3092, C); } c[(b + 516) >> 2] = f; if (!q) { r = (b + 520) | 0; q = c[r >> 2] | 0; if ((q | 0) == 16) { if (a[11697] | 0) Vd(b, 4, 3124, D); c[r >> 2] = 0; q = 0; } if (n) q = (b + 916) | 0; else { c[r >> 2] = q + 1; q = (b + 524 + ((q * 24) | 0)) | 0; } g[q >> 2] = d; g[(q + 4) >> 2] = e; c[(q + 8) >> 2] = i; c[(q + 12) >> 2] = j; c[(q + 16) >> 2] = c[(b + 908) >> 2]; c[(q + 20) >> 2] = c[(b + 912) >> 2]; q = 0; } } if (n) { c[(b + 416) >> 2] = c[(b + 908) >> 2]; c[(b + 420) >> 2] = c[(b + 912) >> 2]; a[(b + 985) >> 0] = 1; a[E >> 0] = 0; } c[2279] = (c[2279] | 0) + -1; c[(b + 512) >> 2] = c[2278]; l = G; return F | ((q | 0) == 0) | 0; } function Ud(a, b, c) { a = a | 0; b = b | 0; c = T(c); var d = ib; d = T(me(a, b, c)); return T(d + T(ne(a, b, c))); } function Vd(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; c[f >> 2] = e; if (!a) e = 0; else e = c[(a + 976) >> 2] | 0; ge(e, a, b, d, f); l = g; return; } function Wd(a) { a = a | 0; return (a >>> 0 > 60 ? 3201 : (3201 + (60 - a)) | 0) | 0; } function Xd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 32) | 0; d = (f + 12) | 0; e = f; c[d >> 2] = c[254]; c[(d + 4) >> 2] = c[255]; c[(d + 8) >> 2] = c[256]; c[e >> 2] = c[257]; c[(e + 4) >> 2] = c[258]; c[(e + 8) >> 2] = c[259]; if ((a | 0) > 2) a = 11699; else a = c[((b ? e : d) + (a << 2)) >> 2] | 0; l = f; return a | 0; } function Yd(b, e, f, h, i, k, m, n, o, p) { b = b | 0; e = T(e); f = T(f); h = h | 0; i = i | 0; k = k | 0; m = T(m); n = T(n); o = o | 0; p = p | 0; var q = 0, r = 0, s = 0, t = 0, u = ib, v = ib, w = ib, x = ib, y = ib, z = ib, A = ib, B = 0, C = 0, D = 0, E = ib, F = ib, G = 0, H = ib, I = 0, J = 0, K = 0, L = 0, M = 0, N = 0, O = 0, P = 0, Q = 0, R = 0, S = 0, U = 0, V = 0, W = 0, X = 0, Y = 0, Z = 0, _ = 0, $ = ib, aa = ib, ba = ib, ca = ib, da = ib, ea = 0, fa = 0, ga = 0, ha = 0, ia = 0, ja = ib, ka = ib, la = ib, ma = ib, na = ib, oa = ib, pa = 0, qa = ib, ra = ib, sa = ib, ta = ib, ua = ib, va = ib, wa = 0, xa = 0, ya = ib, za = ib, Aa = 0, Ba = 0, Ca = 0, Da = 0, Ea = ib, Fa = 0, Ga = 0, Ha = 0, Ia = 0, Ja = 0, Ka = 0, La = 0, Ma = ib, Na = 0, Oa = 0; La = l; l = (l + 16) | 0; ea = (La + 12) | 0; fa = (La + 8) | 0; ga = (La + 4) | 0; ha = La; ec(b, ((i | 0) == 0) | ((Sb(e) | 0) ^ 1), 3326); ec(b, ((k | 0) == 0) | ((Sb(f) | 0) ^ 1), 3406); Ga = qe(b, h) | 0; c[(b + 496) >> 2] = Ga; Ja = re(2, Ga) | 0; Ka = re(0, Ga) | 0; g[(b + 440) >> 2] = T(me(b, Ja, m)); g[(b + 444) >> 2] = T(ne(b, Ja, m)); g[(b + 428) >> 2] = T(me(b, Ka, m)); g[(b + 436) >> 2] = T(ne(b, Ka, m)); g[(b + 464) >> 2] = T(se(b, Ja)); g[(b + 468) >> 2] = T(te(b, Ja)); g[(b + 452) >> 2] = T(se(b, Ka)); g[(b + 460) >> 2] = T(te(b, Ka)); g[(b + 488) >> 2] = T(ue(b, Ja, m)); g[(b + 492) >> 2] = T(ve(b, Ja, m)); g[(b + 476) >> 2] = T(ue(b, Ka, m)); g[(b + 484) >> 2] = T(ve(b, Ka, m)); do if (!(c[(b + 964) >> 2] | 0)) { Ha = (b + 948) | 0; Ia = ((c[(b + 952) >> 2] | 0) - (c[Ha >> 2] | 0)) >> 2; if (!Ia) { xe(b, e, f, i, k, m, n); break; } if (!o ? ye(b, e, f, i, k, m, n) | 0 : 0) break; lc(b); Y = (b + 508) | 0; a[Y >> 0] = 0; Ja = re(c[(b + 4) >> 2] | 0, Ga) | 0; Ka = ze(Ja, Ga) | 0; Fa = oe(Ja) | 0; Z = c[(b + 8) >> 2] | 0; Ba = (b + 28) | 0; _ = (c[Ba >> 2] | 0) != 0; ua = Fa ? m : n; ya = Fa ? n : m; $ = T(Ae(b, Ja, m)); aa = T(Be(b, Ja, m)); u = T(Ae(b, Ka, m)); va = T(Ce(b, Ja, m)); za = T(Ce(b, Ka, m)); D = Fa ? i : k; Aa = Fa ? k : i; Ea = Fa ? va : za; y = Fa ? za : va; ta = T(Ud(b, 2, m)); x = T(Ud(b, 0, m)); v = T(T(be((b + 364) | 0, m)) - Ea); w = T(T(be((b + 380) | 0, m)) - Ea); z = T(T(be((b + 372) | 0, n)) - y); A = T(T(be((b + 388) | 0, n)) - y); ba = Fa ? v : z; ca = Fa ? w : A; ta = T(e - ta); e = T(ta - Ea); if (Sb(e) | 0) Ea = e; else Ea = T(cC(T(eC(e, w)), v)); ra = T(f - x); e = T(ra - y); if (Sb(e) | 0) sa = e; else sa = T(cC(T(eC(e, A)), z)); v = Fa ? Ea : sa; qa = Fa ? sa : Ea; a: do if ((D | 0) == 1) { h = 0; r = 0; while (1) { q = ac(b, r) | 0; if (!h) { if (T(Ee(q)) > T(0.0) ? T(Fe(q)) > T(0.0) : 0) h = q; else h = 0; } else if (De(q) | 0) { t = 0; break a; } r = (r + 1) | 0; if (r >>> 0 >= Ia >>> 0) { t = h; break; } } } else t = 0; while (0); B = (t + 500) | 0; C = (t + 504) | 0; h = 0; q = 0; e = T(0.0); s = 0; do { r = c[((c[Ha >> 2] | 0) + (s << 2)) >> 2] | 0; if ((c[(r + 36) >> 2] | 0) == 1) { Ge(r); a[(r + 985) >> 0] = 1; a[(r + 984) >> 0] = 0; } else { $d(r); if (o) ce(r, qe(r, Ga) | 0, v, qa, Ea); do if ((c[(r + 24) >> 2] | 0) != 1) { if ((r | 0) == (t | 0)) { c[B >> 2] = c[2278]; g[C >> 2] = T(0.0); break; } else { He(b, r, Ea, i, sa, Ea, sa, k, Ga, p); break; } } else { if (q | 0) c[(q + 960) >> 2] = r; c[(r + 960) >> 2] = 0; q = r; h = (h | 0) == 0 ? r : h; } while (0); oa = T(g[(r + 504) >> 2]); e = T(e + T(oa + T(Ud(r, Ja, Ea)))); } s = (s + 1) | 0; } while ((s | 0) != (Ia | 0)); K = e > v; pa = _ & (((D | 0) == 2) & K) ? 1 : D; I = (Aa | 0) == 1; M = I & (o ^ 1); N = (pa | 0) == 1; O = (pa | 0) == 2; P = (976 + (Ja << 2)) | 0; Q = (Aa | 2 | 0) == 2; W = I & (_ ^ 1); R = (1040 + (Ka << 2)) | 0; S = (1040 + (Ja << 2)) | 0; U = (976 + (Ka << 2)) | 0; V = (Aa | 0) != 1; K = _ & (((D | 0) != 0) & K); J = (b + 976) | 0; I = I ^ 1; e = v; G = 0; L = 0; oa = T(0.0); da = T(0.0); while (1) { b: do if (G >>> 0 < Ia >>> 0) { C = c[Ha >> 2] | 0; s = 0; A = T(0.0); z = T(0.0); w = T(0.0); v = T(0.0); r = 0; q = 0; t = G; while (1) { B = c[(C + (t << 2)) >> 2] | 0; if ( (c[(B + 36) >> 2] | 0) != 1 ? ((c[(B + 940) >> 2] = L), (c[(B + 24) >> 2] | 0) != 1) : 0 ) { x = T(Ud(B, Ja, Ea)); X = c[P >> 2] | 0; f = T(be((B + 380 + (X << 3)) | 0, ua)); y = T(g[(B + 504) >> 2]); f = T(eC(f, y)); f = T( cC( T(be((B + 364 + (X << 3)) | 0, ua)), f ) ); if ( _ & ((s | 0) != 0) & (T(x + T(z + f)) > e) ) { k = s; x = A; D = t; break b; } x = T(x + f); f = T(z + x); x = T(A + x); if (De(B) | 0) { w = T(w + T(Ee(B))); v = T(v - T(y * T(Fe(B)))); } if (q | 0) c[(q + 960) >> 2] = B; c[(B + 960) >> 2] = 0; s = (s + 1) | 0; q = B; r = (r | 0) == 0 ? B : r; } else { x = A; f = z; } t = (t + 1) | 0; if (t >>> 0 < Ia >>> 0) { A = x; z = f; } else { k = s; D = t; break; } } } else { k = 0; x = T(0.0); w = T(0.0); v = T(0.0); r = 0; D = G; } while (0); X = (w > T(0.0)) & (w < T(1.0)); E = X ? T(1.0) : w; X = (v > T(0.0)) & (v < T(1.0)); A = X ? T(1.0) : v; do if (!N) { if (!((x < ba) & ((Sb(ba) | 0) ^ 1))) { if (!((x > ca) & ((Sb(ca) | 0) ^ 1))) { if (!(a[((c[J >> 2] | 0) + 3) >> 0] | 0)) { if ( !(E == T(0.0)) ? !(T(Ee(b)) == T(0.0)) : 0 ) { X = 53; break; } e = x; X = 53; } else X = 51; } else { e = ca; X = 51; } } else { e = ba; X = 51; } } else X = 51; while (0); if ((X | 0) == 51) { X = 0; if (Sb(e) | 0) X = 53; else { F = T(e - x); H = e; } } if ((X | 0) == 53) { X = 0; if (x < T(0.0)) { F = T(-x); H = e; } else { F = T(0.0); H = e; } } if (!M ? ((ia = (r | 0) == 0), !ia) : 0) { s = c[P >> 2] | 0; t = F < T(0.0); y = T(F / A); B = F > T(0.0); z = T(F / E); w = T(0.0); x = T(0.0); e = T(0.0); q = r; do { f = T(be((q + 380 + (s << 3)) | 0, ua)); v = T(be((q + 364 + (s << 3)) | 0, ua)); v = T(eC(f, T(cC(v, T(g[(q + 504) >> 2]))))); if (t) { f = T(v * T(Fe(q))); if ( f != T(-0.0) ? ((Ma = T(v - T(y * f))), (ja = T(Ie(q, Ja, Ma, H, Ea))), Ma != ja) : 0 ) { w = T(w - T(ja - v)); e = T(e + f); } } else if ( (B ? ((ka = T(Ee(q))), ka != T(0.0)) : 0) ? ((Ma = T(v + T(z * ka))), (la = T(Ie(q, Ja, Ma, H, Ea))), Ma != la) : 0 ) { w = T(w - T(la - v)); x = T(x - ka); } q = c[(q + 960) >> 2] | 0; } while ((q | 0) != 0); e = T(A + e); v = T(F + w); if (!ia) { y = T(E + x); t = c[P >> 2] | 0; B = v < T(0.0); C = e == T(0.0); z = T(v / e); s = v > T(0.0); y = T(v / y); e = T(0.0); do { Ma = T(be((r + 380 + (t << 3)) | 0, ua)); w = T(be((r + 364 + (t << 3)) | 0, ua)); w = T(eC(Ma, T(cC(w, T(g[(r + 504) >> 2]))))); if (B) { Ma = T(w * T(Fe(r))); v = T(-Ma); if (Ma != T(-0.0)) { Ma = T(z * v); v = T( Ie( r, Ja, T(w + (C ? v : Ma)), H, Ea ) ); } else v = w; } else if ( s ? ((ma = T(Ee(r))), ma != T(0.0)) : 0 ) v = T(Ie(r, Ja, T(w + T(y * ma)), H, Ea)); else v = w; e = T(e - T(v - w)); x = T(Ud(r, Ja, Ea)); f = T(Ud(r, Ka, Ea)); v = T(v + x); g[fa >> 2] = v; c[ha >> 2] = 1; w = T(g[(r + 396) >> 2]); c: do if (Sb(w) | 0) { q = Sb(qa) | 0; do if (!q) { if (K | (ae(r, Ka, qa) | 0 | I)) break; if ((Je(b, r) | 0) != 4) break; if ( (c[ ((Ke(r, Ka) | 0) + 4) >> 2 ] | 0) == 3 ) break; if ( (c[ ((Le(r, Ka) | 0) + 4) >> 2 ] | 0) == 3 ) break; g[ea >> 2] = qa; c[ga >> 2] = 1; break c; } while (0); if (ae(r, Ka, qa) | 0) { q = c[ (r + 992 + (c[U >> 2] << 2)) >> 2 ] | 0; Ma = T(f + T(be(q, qa))); g[ea >> 2] = Ma; q = V & ((c[(q + 4) >> 2] | 0) == 2); c[ga >> 2] = ((Sb(Ma) | 0 | q) ^ 1) & 1; break; } else { g[ea >> 2] = qa; c[ga >> 2] = q ? 0 : 2; break; } } else { Ma = T(v - x); E = T(Ma / w); Ma = T(w * Ma); c[ga >> 2] = 1; g[ea >> 2] = T(f + (Fa ? E : Ma)); } while (0); Me(r, Ja, H, Ea, ha, fa); Me(r, Ka, qa, Ea, ga, ea); do if ( !(ae(r, Ka, qa) | 0) ? (Je(b, r) | 0) == 4 : 0 ) { if ( (c[((Ke(r, Ka) | 0) + 4) >> 2] | 0) == 3 ) { q = 0; break; } q = (c[((Le(r, Ka) | 0) + 4) >> 2] | 0) != 3; } else q = 0; while (0); Ma = T(g[fa >> 2]); E = T(g[ea >> 2]); Na = c[ha >> 2] | 0; Oa = c[ga >> 2] | 0; Td( r, Fa ? Ma : E, Fa ? E : Ma, Ga, Fa ? Na : Oa, Fa ? Oa : Na, Ea, sa, o & (q ^ 1), 3488, p ) | 0; a[Y >> 0] = a[Y >> 0] | a[(r + 508) >> 0]; r = c[(r + 960) >> 2] | 0; } while ((r | 0) != 0); } else e = T(0.0); } else e = T(0.0); e = T(F + e); Oa = (e < T(0.0)) & 1; a[Y >> 0] = Oa | d[Y >> 0]; if (O & (e > T(0.0))) { q = c[P >> 2] | 0; if ( (c[(b + 364 + (q << 3) + 4) >> 2] | 0) != 0 ? ((na = T(be((b + 364 + (q << 3)) | 0, ua))), na >= T(0.0)) : 0 ) v = T(cC(T(0.0), T(na - T(H - e)))); else v = T(0.0); } else v = e; B = G >>> 0 < D >>> 0; if (B) { t = c[Ha >> 2] | 0; s = G; q = 0; do { r = c[(t + (s << 2)) >> 2] | 0; if (!(c[(r + 24) >> 2] | 0)) { q = ((((c[((Ke(r, Ja) | 0) + 4) >> 2] | 0) == 3) & 1) + q) | 0; q = (q + (((c[((Le(r, Ja) | 0) + 4) >> 2] | 0) == 3) & 1)) | 0; } s = (s + 1) | 0; } while ((s | 0) != (D | 0)); if (q) { x = T(0.0); f = T(0.0); } else X = 101; } else X = 101; d: do if ((X | 0) == 101) { X = 0; switch (Z | 0) { case 1: { q = 0; x = T(v * T(0.5)); f = T(0.0); break d; } case 2: { q = 0; x = v; f = T(0.0); break d; } case 3: { if (k >>> 0 <= 1) { q = 0; x = T(0.0); f = T(0.0); break d; } f = T(((k + -1) | 0) >>> 0); q = 0; x = T(0.0); f = T(T(cC(v, T(0.0))) / f); break d; } case 5: { f = T(v / T(((k + 1) | 0) >>> 0)); q = 0; x = f; break d; } case 4: { f = T(v / T(k >>> 0)); q = 0; x = T(f * T(0.5)); break d; } default: { q = 0; x = T(0.0); f = T(0.0); break d; } } } while (0); e = T($ + x); if (B) { w = T(v / T(q | 0)); s = c[Ha >> 2] | 0; r = G; v = T(0.0); do { q = c[(s + (r << 2)) >> 2] | 0; e: do if ((c[(q + 36) >> 2] | 0) != 1) { switch (c[(q + 24) >> 2] | 0) { case 1: { if (Ne(q, Ja) | 0) { if (!o) break e; Ma = T(Oe(q, Ja, H)); Ma = T(Ma + T(se(b, Ja))); Ma = T(Ma + T(me(q, Ja, Ea))); g[ (q + 400 + (c[S >> 2] << 2)) >> 2 ] = Ma; break e; } break; } case 0: { Oa = (c[((Ke(q, Ja) | 0) + 4) >> 2] | 0) == 3; Ma = T(w + e); e = Oa ? Ma : e; if (o) { Oa = (q + 400 + (c[S >> 2] << 2)) | 0; g[Oa >> 2] = T( e + T(g[Oa >> 2]) ); } Oa = (c[((Le(q, Ja) | 0) + 4) >> 2] | 0) == 3; Ma = T(w + e); e = Oa ? Ma : e; if (M) { Ma = T(f + T(Ud(q, Ja, Ea))); v = qa; e = T( e + T( Ma + T( g[ (q + 504) >> 2 ] ) ) ); break e; } else { e = T( e + T(f + T(Pe(q, Ja, Ea))) ); v = T(cC(v, T(Pe(q, Ka, Ea)))); break e; } } default: { } } if (o) { Ma = T(x + T(se(b, Ja))); Oa = (q + 400 + (c[S >> 2] << 2)) | 0; g[Oa >> 2] = T(Ma + T(g[Oa >> 2])); } } while (0); r = (r + 1) | 0; } while ((r | 0) != (D | 0)); } else v = T(0.0); f = T(aa + e); if (Q) x = T(T(Ie(b, Ka, T(za + v), ya, m)) - za); else x = qa; w = T(T(Ie(b, Ka, T(za + (W ? qa : v)), ya, m)) - za); if (B & o) { r = G; do { s = c[((c[Ha >> 2] | 0) + (r << 2)) >> 2] | 0; do if ((c[(s + 36) >> 2] | 0) != 1) { if ((c[(s + 24) >> 2] | 0) == 1) { if (Ne(s, Ka) | 0) { Ma = T(Oe(s, Ka, qa)); Ma = T(Ma + T(se(b, Ka))); Ma = T(Ma + T(me(s, Ka, Ea))); q = c[R >> 2] | 0; g[(s + 400 + (q << 2)) >> 2] = Ma; if (!(Sb(Ma) | 0)) break; } else q = c[R >> 2] | 0; Ma = T(se(b, Ka)); g[(s + 400 + (q << 2)) >> 2] = T( Ma + T(me(s, Ka, Ea)) ); break; } q = Je(b, s) | 0; do if ((q | 0) == 4) { if ( (c[((Ke(s, Ka) | 0) + 4) >> 2] | 0) == 3 ) { X = 139; break; } if ( (c[((Le(s, Ka) | 0) + 4) >> 2] | 0) == 3 ) { X = 139; break; } if (ae(s, Ka, qa) | 0) { e = u; break; } Na = c[ (s + 908 + (c[P >> 2] << 2)) >> 2 ] | 0; c[ea >> 2] = Na; e = T(g[(s + 396) >> 2]); Oa = Sb(e) | 0; v = ((c[j >> 2] = Na), T(g[j >> 2])); if (Oa) e = w; else { F = T(Ud(s, Ka, Ea)); Ma = T(v / e); e = T(e * v); e = T(F + (Fa ? Ma : e)); } g[fa >> 2] = e; g[ea >> 2] = T( T(Ud(s, Ja, Ea)) + v ); c[ga >> 2] = 1; c[ha >> 2] = 1; Me(s, Ja, H, Ea, ga, ea); Me(s, Ka, qa, Ea, ha, fa); e = T(g[ea >> 2]); F = T(g[fa >> 2]); Ma = Fa ? e : F; e = Fa ? F : e; Oa = ((Sb(Ma) | 0) ^ 1) & 1; Td( s, Ma, e, Ga, Oa, ((Sb(e) | 0) ^ 1) & 1, Ea, sa, 1, 3493, p ) | 0; e = u; } else X = 139; while (0); f: do if ((X | 0) == 139) { X = 0; e = T(x - T(Pe(s, Ka, Ea))); do if ( (c[ ((Ke(s, Ka) | 0) + 4) >> 2 ] | 0) == 3 ) { if ( (c[ ((Le(s, Ka) | 0) + 4) >> 2 ] | 0) != 3 ) break; e = T( u + T( cC( T(0.0), T( e * T( 0.5 ) ) ) ) ); break f; } while (0); if ( (c[((Le(s, Ka) | 0) + 4) >> 2] | 0) == 3 ) { e = u; break; } if ( (c[((Ke(s, Ka) | 0) + 4) >> 2] | 0) == 3 ) { e = T(u + T(cC(T(0.0), e))); break; } switch (q | 0) { case 1: { e = u; break f; } case 2: { e = T(u + T(e * T(0.5))); break f; } default: { e = T(u + e); break f; } } } while (0); Ma = T(oa + e); Oa = (s + 400 + (c[R >> 2] << 2)) | 0; g[Oa >> 2] = T(Ma + T(g[Oa >> 2])); } while (0); r = (r + 1) | 0; } while ((r | 0) != (D | 0)); } oa = T(oa + w); da = T(cC(da, f)); k = (L + 1) | 0; if (D >>> 0 >= Ia >>> 0) break; else { e = H; G = D; L = k; } } do if (o) { q = k >>> 0 > 1; if (!q ? !(Qe(b) | 0) : 0) break; if (!(Sb(qa) | 0)) { e = T(qa - oa); g: do switch (c[(b + 12) >> 2] | 0) { case 3: { u = T(u + e); z = T(0.0); break; } case 2: { u = T(u + T(e * T(0.5))); z = T(0.0); break; } case 4: { if (qa > oa) z = T(e / T(k >>> 0)); else z = T(0.0); break; } case 7: if (qa > oa) { u = T(u + T(e / T((k << 1) >>> 0))); z = T(e / T(k >>> 0)); z = q ? z : T(0.0); break g; } else { u = T(u + T(e * T(0.5))); z = T(0.0); break g; } case 6: { z = T(e / T(L >>> 0)); z = (qa > oa) & q ? z : T(0.0); break; } default: z = T(0.0); } while (0); if (k | 0) { B = (1040 + (Ka << 2)) | 0; C = (976 + (Ka << 2)) | 0; t = 0; r = 0; while (1) { h: do if (r >>> 0 < Ia >>> 0) { v = T(0.0); w = T(0.0); e = T(0.0); s = r; while (1) { q = c[ ((c[Ha >> 2] | 0) + (s << 2)) >> 2 ] | 0; do if ( (c[(q + 36) >> 2] | 0) != 1 ? (c[ (q + 24) >> 2 ] | 0) == 0 : 0 ) { if ( (c[(q + 940) >> 2] | 0) != (t | 0) ) break h; if (Re(q, Ka) | 0) { Ma = T( g[ (q + 908 + (c[ C >> 2 ] << 2)) >> 2 ] ); e = T( cC( e, T( Ma + T( Ud( q, Ka, Ea ) ) ) ) ); } if ((Je(b, q) | 0) != 5) break; na = T(Se(q)); na = T( na + T(me(q, 0, Ea)) ); Ma = T( g[(q + 912) >> 2] ); Ma = T( T( Ma + T( Ud( q, 0, Ea ) ) ) - na ); na = T(cC(w, na)); Ma = T(cC(v, Ma)); v = Ma; w = na; e = T( cC(e, T(na + Ma)) ); } while (0); q = (s + 1) | 0; if (q >>> 0 < Ia >>> 0) s = q; else { s = q; break; } } } else { w = T(0.0); e = T(0.0); s = r; } while (0); y = T(z + e); f = u; u = T(u + y); if (r >>> 0 < s >>> 0) { x = T(f + w); q = r; do { r = c[ ((c[Ha >> 2] | 0) + (q << 2)) >> 2 ] | 0; i: do if ( (c[(r + 36) >> 2] | 0) != 1 ? (c[(r + 24) >> 2] | 0) == 0 : 0 ) switch (Je(b, r) | 0) { case 1: { Ma = T( f + T( me( r, Ka, Ea ) ) ); g[ (r + 400 + (c[ B >> 2 ] << 2)) >> 2 ] = Ma; break i; } case 3: { Ma = T( T( u - T( ne( r, Ka, Ea ) ) ) - T( g[ (r + 908 + (c[ C >> 2 ] << 2)) >> 2 ] ) ); g[ (r + 400 + (c[ B >> 2 ] << 2)) >> 2 ] = Ma; break i; } case 2: { Ma = T( f + T( T( y - T( g[ (r + 908 + (c[ C >> 2 ] << 2)) >> 2 ] ) ) * T( 0.5 ) ) ); g[ (r + 400 + (c[ B >> 2 ] << 2)) >> 2 ] = Ma; break i; } case 4: { Ma = T( f + T( me( r, Ka, Ea ) ) ); g[ (r + 400 + (c[ B >> 2 ] << 2)) >> 2 ] = Ma; if ( ae(r, Ka, qa) | 0 ) break i; if (Fa) { v = T( g[ (r + 908) >> 2 ] ); e = T( v + T( Ud( r, Ja, Ea ) ) ); w = y; } else { w = T( g[ (r + 912) >> 2 ] ); w = T( w + T( Ud( r, Ka, Ea ) ) ); e = y; v = T( g[ (r + 908) >> 2 ] ); } if ( Ld(e, v) | 0 ? Ld( w, T( g[ (r + 912) >> 2 ] ) ) | 0 : 0 ) break i; Td( r, e, w, Ga, 1, 1, Ea, sa, 1, 3501, p ) | 0; break i; } case 5: { g[(r + 404) >> 2] = T( T( x - T( Se( r ) ) ) + T( Oe( r, 0, qa ) ) ); break i; } default: break i; } while (0); q = (q + 1) | 0; } while ((q | 0) != (s | 0)); } t = (t + 1) | 0; if ((t | 0) == (k | 0)) break; else r = s; } } } } while (0); g[(b + 908) >> 2] = T(Ie(b, 2, ta, m, m)); g[(b + 912) >> 2] = T(Ie(b, 0, ra, n, m)); if ( (pa | 0) != 0 ? ((wa = c[(b + 32) >> 2] | 0), (xa = (pa | 0) == 2), !(xa & ((wa | 0) != 2))) : 0 ) { if (xa & ((wa | 0) == 2)) { e = T(va + H); e = T(cC(T(eC(e, T(Te(b, Ja, da, ua)))), va)); X = 198; } } else { e = T(Ie(b, Ja, da, ua, m)); X = 198; } if ((X | 0) == 198) g[(b + 908 + (c[(976 + (Ja << 2)) >> 2] << 2)) >> 2] = e; if ( (Aa | 0) != 0 ? ((Ca = c[(b + 32) >> 2] | 0), (Da = (Aa | 0) == 2), !(Da & ((Ca | 0) != 2))) : 0 ) { if (Da & ((Ca | 0) == 2)) { e = T(za + qa); e = T(cC(T(eC(e, T(Te(b, Ka, T(za + oa), ya)))), za)); X = 204; } } else { e = T(Ie(b, Ka, T(za + oa), ya, m)); X = 204; } if ((X | 0) == 204) g[(b + 908 + (c[(976 + (Ka << 2)) >> 2] << 2)) >> 2] = e; if (o) { if ((c[Ba >> 2] | 0) == 2) { r = (976 + (Ka << 2)) | 0; s = (1040 + (Ka << 2)) | 0; q = 0; do { t = ac(b, q) | 0; if (!(c[(t + 24) >> 2] | 0)) { Na = c[r >> 2] | 0; Ma = T(g[(b + 908 + (Na << 2)) >> 2]); Oa = (t + 400 + (c[s >> 2] << 2)) | 0; Ma = T(Ma - T(g[Oa >> 2])); g[Oa >> 2] = T( Ma - T(g[(t + 908 + (Na << 2)) >> 2]) ); } q = (q + 1) | 0; } while ((q | 0) != (Ia | 0)); } if (h | 0) { q = Fa ? pa : i; do { Ue(b, h, Ea, q, sa, Ga, p); h = c[(h + 960) >> 2] | 0; } while ((h | 0) != 0); } q = (Ja | 2 | 0) == 3; r = (Ka | 2 | 0) == 3; if (q | r) { h = 0; do { s = c[((c[Ha >> 2] | 0) + (h << 2)) >> 2] | 0; if ((c[(s + 36) >> 2] | 0) != 1) { if (q) Ve(b, s, Ja); if (r) Ve(b, s, Ka); } h = (h + 1) | 0; } while ((h | 0) != (Ia | 0)); } } } else we(b, e, f, i, k, m, n); while (0); l = La; return; } function Zd(a, b) { a = a | 0; b = T(b); var c = 0; Vb(a, b >= T(0.0), 3147); c = b == T(0.0); g[(a + 4) >> 2] = c ? T(0.0) : b; return; } function _d(b, d, e, f) { b = b | 0; d = T(d); e = T(e); f = f | 0; var h = ib, i = ib, j = 0, k = 0, l = 0; c[2278] = (c[2278] | 0) + 1; $d(b); if (!(ae(b, 2, d) | 0)) { h = T(be((b + 380) | 0, d)); if (!(h >= T(0.0))) { l = ((Sb(d) | 0) ^ 1) & 1; h = d; } else l = 2; } else { h = T(be(c[(b + 992) >> 2] | 0, d)); l = 1; h = T(h + T(Ud(b, 2, d))); } if (!(ae(b, 0, e) | 0)) { i = T(be((b + 388) | 0, e)); if (!(i >= T(0.0))) { k = ((Sb(e) | 0) ^ 1) & 1; i = e; } else k = 2; } else { i = T(be(c[(b + 996) >> 2] | 0, e)); k = 1; i = T(i + T(Ud(b, 0, d))); } j = (b + 976) | 0; if ( Td(b, h, i, f, l, k, d, e, 1, 3189, c[j >> 2] | 0) | 0 ? (ce(b, c[(b + 496) >> 2] | 0, d, e, d), de(b, T(g[((c[j >> 2] | 0) + 4) >> 2]), T(0.0), T(0.0)), a[11696] | 0) : 0 ) Md(b, 7); return; } function $d(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; h = (i + 24) | 0; g = (i + 16) | 0; e = (i + 8) | 0; f = i; d = 0; do { b = (a + 380 + (d << 3)) | 0; if ( !((c[(a + 380 + (d << 3) + 4) >> 2] | 0) != 0 ? ((j = b), (k = c[(j + 4) >> 2] | 0), (m = e), (c[m >> 2] = c[j >> 2]), (c[(m + 4) >> 2] = k), (m = (a + 364 + (d << 3)) | 0), (k = c[(m + 4) >> 2] | 0), (j = f), (c[j >> 2] = c[m >> 2]), (c[(j + 4) >> 2] = k), (c[g >> 2] = c[e >> 2]), (c[(g + 4) >> 2] = c[(e + 4) >> 2]), (c[h >> 2] = c[f >> 2]), (c[(h + 4) >> 2] = c[(f + 4) >> 2]), Kd(g, h) | 0) : 0) ) b = (a + 348 + (d << 3)) | 0; c[(a + 992 + (d << 2)) >> 2] = b; d = (d + 1) | 0; } while ((d | 0) != 2); l = i; return; } function ae(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0; a = c[(a + 992 + (c[(976 + (b << 2)) >> 2] << 2)) >> 2] | 0; switch (c[(a + 4) >> 2] | 0) { case 0: case 3: { a = 0; break; } case 1: { if (T(g[a >> 2]) < T(0.0)) a = 0; else e = 5; break; } case 2: { if (T(g[a >> 2]) < T(0.0)) a = 0; else a = (Sb(d) | 0) ^ 1; break; } default: e = 5; } if ((e | 0) == 5) a = 1; return a | 0; } function be(a, b) { a = a | 0; b = T(b); switch (c[(a + 4) >> 2] | 0) { case 2: { b = T(T(T(g[a >> 2]) * b) / T(100.0)); break; } case 1: { b = T(g[a >> 2]); break; } default: b = T(t); } return T(b); } function ce(a, b, d, e, f) { a = a | 0; b = b | 0; d = T(d); e = T(e); f = T(f); var h = 0, i = ib; b = c[(a + 944) >> 2] | 0 ? b : 1; h = re(c[(a + 4) >> 2] | 0, b) | 0; b = ze(h, b) | 0; d = T($e(a, h, d)); e = T($e(a, b, e)); i = T(d + T(me(a, h, f))); g[(a + 400 + (c[(1040 + (h << 2)) >> 2] << 2)) >> 2] = i; d = T(d + T(ne(a, h, f))); g[(a + 400 + (c[(1e3 + (h << 2)) >> 2] << 2)) >> 2] = d; d = T(e + T(me(a, b, f))); g[(a + 400 + (c[(1040 + (b << 2)) >> 2] << 2)) >> 2] = d; f = T(e + T(ne(a, b, f))); g[(a + 400 + (c[(1e3 + (b << 2)) >> 2] << 2)) >> 2] = f; return; } function de(a, b, d, e) { a = a | 0; b = T(b); d = T(d); e = T(e); var f = 0, h = 0, i = ib, j = ib, k = 0, l = 0, m = ib, n = 0, o = ib, p = ib, q = ib, r = ib; if (!(b == T(0.0))) { f = (a + 400) | 0; r = T(g[f >> 2]); h = (a + 404) | 0; q = T(g[h >> 2]); n = (a + 416) | 0; p = T(g[n >> 2]); l = (a + 420) | 0; i = T(g[l >> 2]); o = T(r + d); m = T(q + e); e = T(o + p); j = T(m + i); k = (c[(a + 988) >> 2] | 0) == 1; g[f >> 2] = T(Od(r, b, 0, k)); g[h >> 2] = T(Od(q, b, 0, k)); d = T(gC(T(p * b), T(1.0))); if (Ld(d, T(0.0)) | 0) h = 0; else h = (Ld(d, T(1.0)) | 0) ^ 1; d = T(gC(T(i * b), T(1.0))); if (Ld(d, T(0.0)) | 0) f = 0; else f = (Ld(d, T(1.0)) | 0) ^ 1; r = T(Od(e, b, k & h, k & (h ^ 1))); g[n >> 2] = T(r - T(Od(o, b, 0, k))); r = T(Od(j, b, k & f, k & (f ^ 1))); g[l >> 2] = T(r - T(Od(m, b, 0, k))); h = ((c[(a + 952) >> 2] | 0) - (c[(a + 948) >> 2] | 0)) >> 2; if (h | 0) { f = 0; do { de(ac(a, f) | 0, b, o, m); f = (f + 1) | 0; } while ((f | 0) != (h | 0)); } } return; } function ee(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; switch (d | 0) { case 5: case 0: { a = CB(c[489] | 0, e, f) | 0; break; } default: a = iC(e, f) | 0; } return a | 0; } function fe(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; f = l; l = (l + 16) | 0; g = f; c[g >> 2] = e; ge(a, 0, b, d, g); l = f; return; } function ge(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; a = a | 0 ? a : 956; Bb[c[(a + 8) >> 2] & 1](a, b, d, e, f) | 0; if ((d | 0) == 5) Ta(); else return; } function he(b, c, d) { b = b | 0; c = c | 0; d = d | 0; a[(b + c) >> 0] = d & 1; return; } function ie(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[(a + 4) >> 2] = 0; c[(a + 8) >> 2] = 0; d = (b + 4) | 0; e = ((c[d >> 2] | 0) - (c[b >> 2] | 0)) >> 2; if (e | 0) { je(a, e); ke(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function je(a, b) { a = a | 0; b = b | 0; var d = 0; if ((le(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[(a + 4) >> 2] = d; c[a >> 2] = d; c[(a + 8) >> 2] = d + (b << 2); return; } } function ke(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = (a + 4) | 0; a = (d - b) | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0) | 0; c[e >> 2] = (c[e >> 2] | 0) + ((a >>> 2) << 2); } return; } function le(a) { a = a | 0; return 1073741823; } function me(a, b, d) { a = a | 0; b = b | 0; d = T(d); if (oe(b) | 0 ? (c[(a + 96) >> 2] | 0) != 0 : 0) a = (a + 92) | 0; else a = Tb((a + 60) | 0, c[(1040 + (b << 2)) >> 2] | 0, 992) | 0; return T(pe(a, d)); } function ne(a, b, d) { a = a | 0; b = b | 0; d = T(d); if (oe(b) | 0 ? (c[(a + 104) >> 2] | 0) != 0 : 0) a = (a + 100) | 0; else a = Tb((a + 60) | 0, c[(1e3 + (b << 2)) >> 2] | 0, 992) | 0; return T(pe(a, d)); } function oe(a) { a = a | 0; return ((a | 1 | 0) == 3) | 0; } function pe(a, b) { a = a | 0; b = T(b); if ((c[(a + 4) >> 2] | 0) == 3) b = T(0.0); else b = T(be(a, b)); return T(b); } function qe(a, b) { a = a | 0; b = b | 0; a = c[a >> 2] | 0; return ((a | 0) == 0 ? ((b | 0) > 1 ? b : 1) : a) | 0; } function re(a, b) { a = a | 0; b = b | 0; var c = 0; a: do if ((b | 0) == 2) { switch (a | 0) { case 2: { a = 3; break a; } case 3: break; default: { c = 4; break a; } } a = 2; } else c = 4; while (0); return a | 0; } function se(a, b) { a = a | 0; b = b | 0; var d = ib; if ( !((oe(b) | 0 ? (c[(a + 312) >> 2] | 0) != 0 : 0) ? ((d = T(g[(a + 308) >> 2])), d >= T(0.0)) : 0) ) d = T( cC( T( g[ (Tb( (a + 276) | 0, c[(1040 + (b << 2)) >> 2] | 0, 992 ) | 0) >> 2 ] ), T(0.0) ) ); return T(d); } function te(a, b) { a = a | 0; b = b | 0; var d = ib; if ( !((oe(b) | 0 ? (c[(a + 320) >> 2] | 0) != 0 : 0) ? ((d = T(g[(a + 316) >> 2])), d >= T(0.0)) : 0) ) d = T( cC( T( g[ (Tb( (a + 276) | 0, c[(1e3 + (b << 2)) >> 2] | 0, 992 ) | 0) >> 2 ] ), T(0.0) ) ); return T(d); } function ue(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; if ( !((oe(b) | 0 ? (c[(a + 240) >> 2] | 0) != 0 : 0) ? ((e = T(be((a + 236) | 0, d))), e >= T(0.0)) : 0) ) e = T( cC( T( be( Tb( (a + 204) | 0, c[(1040 + (b << 2)) >> 2] | 0, 992 ) | 0, d ) ), T(0.0) ) ); return T(e); } function ve(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; if ( !((oe(b) | 0 ? (c[(a + 248) >> 2] | 0) != 0 : 0) ? ((e = T(be((a + 244) | 0, d))), e >= T(0.0)) : 0) ) e = T( cC( T( be( Tb( (a + 204) | 0, c[(1e3 + (b << 2)) >> 2] | 0, 992 ) | 0, d ) ), T(0.0) ) ); return T(e); } function we(a, b, d, e, f, h, i) { a = a | 0; b = T(b); d = T(d); e = e | 0; f = f | 0; h = T(h); i = T(i); var j = ib, k = ib, m = ib, n = ib, o = ib, p = ib, q = 0, r = 0, s = 0; s = l; l = (l + 16) | 0; q = s; r = (a + 964) | 0; ec(a, (c[r >> 2] | 0) != 0, 3519); j = T(Ce(a, 2, b)); k = T(Ce(a, 0, b)); m = T(Ud(a, 2, b)); n = T(Ud(a, 0, b)); if (Sb(b) | 0) o = b; else o = T(cC(T(0.0), T(T(b - m) - j))); if (Sb(d) | 0) p = d; else p = T(cC(T(0.0), T(T(d - n) - k))); if (((e | 0) == 1) & ((f | 0) == 1)) { g[(a + 908) >> 2] = T(Ie(a, 2, T(b - m), h, h)); b = T(Ie(a, 0, T(d - n), i, h)); } else { Db[c[r >> 2] & 1](q, a, o, e, p, f); o = T(j + T(g[q >> 2])); p = T(b - m); g[(a + 908) >> 2] = T(Ie(a, 2, (e | 2 | 0) == 2 ? o : p, h, h)); p = T(k + T(g[(q + 4) >> 2])); b = T(d - n); b = T(Ie(a, 0, (f | 2 | 0) == 2 ? p : b, i, h)); } g[(a + 912) >> 2] = b; l = s; return; } function xe(a, b, c, d, e, f, h) { a = a | 0; b = T(b); c = T(c); d = d | 0; e = e | 0; f = T(f); h = T(h); var i = ib, j = ib, k = ib, l = ib; k = T(Ce(a, 2, f)); i = T(Ce(a, 0, f)); l = T(Ud(a, 2, f)); j = T(Ud(a, 0, f)); b = T(b - l); g[(a + 908) >> 2] = T(Ie(a, 2, (d | 2 | 0) == 2 ? k : b, f, f)); c = T(c - j); g[(a + 912) >> 2] = T(Ie(a, 0, (e | 2 | 0) == 2 ? i : c, h, f)); return; } function ye(a, b, c, d, e, f, h) { a = a | 0; b = T(b); c = T(c); d = d | 0; e = e | 0; f = T(f); h = T(h); var i = 0, j = ib, k = ib; i = (d | 0) == 2; if ( (!((b <= T(0.0)) & i) ? !((c <= T(0.0)) & ((e | 0) == 2)) : 0) ? !(((d | 0) == 1) & ((e | 0) == 1)) : 0 ) a = 0; else { j = T(Ud(a, 0, f)); k = T(Ud(a, 2, f)); i = ((b < T(0.0)) & i) | (Sb(b) | 0); b = T(b - k); g[(a + 908) >> 2] = T(Ie(a, 2, i ? T(0.0) : b, f, f)); b = T(c - j); i = ((c < T(0.0)) & ((e | 0) == 2)) | (Sb(c) | 0); g[(a + 912) >> 2] = T(Ie(a, 0, i ? T(0.0) : b, h, f)); a = 1; } return a | 0; } function ze(a, b) { a = a | 0; b = b | 0; if (We(a) | 0) a = re(2, b) | 0; else a = 0; return a | 0; } function Ae(a, b, c) { a = a | 0; b = b | 0; c = T(c); c = T(ue(a, b, c)); return T(c + T(se(a, b))); } function Be(a, b, c) { a = a | 0; b = b | 0; c = T(c); c = T(ve(a, b, c)); return T(c + T(te(a, b))); } function Ce(a, b, c) { a = a | 0; b = b | 0; c = T(c); var d = ib; d = T(Ae(a, b, c)); return T(d + T(Be(a, b, c))); } function De(a) { a = a | 0; if (!(c[(a + 24) >> 2] | 0)) { if (T(Ee(a)) != T(0.0)) a = 1; else a = T(Fe(a)) != T(0.0); } else a = 0; return a | 0; } function Ee(a) { a = a | 0; var b = ib; if (c[(a + 944) >> 2] | 0) { b = T(g[(a + 44) >> 2]); if (Sb(b) | 0) { b = T(g[(a + 40) >> 2]); a = (b > T(0.0)) & ((Sb(b) | 0) ^ 1); return T(a ? b : T(0.0)); } } else b = T(0.0); return T(b); } function Fe(b) { b = b | 0; var d = ib, e = 0, f = ib; do if (c[(b + 944) >> 2] | 0) { d = T(g[(b + 48) >> 2]); if (Sb(d) | 0) { e = a[((c[(b + 976) >> 2] | 0) + 2) >> 0] | 0; if ( (e << 24) >> 24 == 0 ? ((f = T(g[(b + 40) >> 2])), (f < T(0.0)) & ((Sb(f) | 0) ^ 1)) : 0 ) { d = T(-f); break; } d = (e << 24) >> 24 ? T(1.0) : T(0.0); } } else d = T(0.0); while (0); return T(d); } function Ge(b) { b = b | 0; var d = 0, e = 0; yC((b + 400) | 0, 0, 540) | 0; a[(b + 985) >> 0] = 1; lc(b); e = $b(b) | 0; if (e | 0) { d = (b + 948) | 0; b = 0; do { Ge(c[((c[d >> 2] | 0) + (b << 2)) >> 2] | 0); b = (b + 1) | 0; } while ((b | 0) != (e | 0)); } return; } function He(a, b, d, e, f, h, i, j, k, m) { a = a | 0; b = b | 0; d = T(d); e = e | 0; f = T(f); h = T(h); i = T(i); j = j | 0; k = k | 0; m = m | 0; var n = 0, o = ib, p = 0, q = 0, r = ib, s = ib, u = 0, v = ib, w = 0, x = ib, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; G = l; l = (l + 16) | 0; A = (G + 12) | 0; B = (G + 8) | 0; C = (G + 4) | 0; D = G; F = re(c[(a + 4) >> 2] | 0, k) | 0; y = oe(F) | 0; o = T(be(Xe(b) | 0, y ? h : i)); z = ae(b, 2, h) | 0; E = ae(b, 0, i) | 0; do if (!(Sb(o) | 0) ? !(Sb(y ? d : f) | 0) : 0) { n = (b + 504) | 0; if (!(Sb(T(g[n >> 2])) | 0)) { if (!(Ye(c[(b + 976) >> 2] | 0, 0) | 0)) break; if ((c[(b + 500) >> 2] | 0) == (c[2278] | 0)) break; } g[n >> 2] = T(cC(o, T(Ce(b, F, h)))); } else p = 7; while (0); do if ((p | 0) == 7) { w = y ^ 1; if (!(w | (z ^ 1))) { i = T(be(c[(b + 992) >> 2] | 0, h)); g[(b + 504) >> 2] = T(cC(i, T(Ce(b, 2, h)))); break; } if (!(y | (E ^ 1))) { i = T(be(c[(b + 996) >> 2] | 0, i)); g[(b + 504) >> 2] = T(cC(i, T(Ce(b, 0, h)))); break; } g[A >> 2] = T(t); g[B >> 2] = T(t); c[C >> 2] = 0; c[D >> 2] = 0; v = T(Ud(b, 2, h)); x = T(Ud(b, 0, h)); if (z) { r = T(v + T(be(c[(b + 992) >> 2] | 0, h))); g[A >> 2] = r; c[C >> 2] = 1; q = 1; } else { q = 0; r = T(t); } if (E) { o = T(x + T(be(c[(b + 996) >> 2] | 0, i))); g[B >> 2] = o; c[D >> 2] = 1; n = 1; } else { n = 0; o = T(t); } p = c[(a + 32) >> 2] | 0; if (!(y & ((p | 0) == 2))) { if (Sb(r) | 0 ? !(Sb(d) | 0) : 0) { g[A >> 2] = d; c[C >> 2] = 2; q = 2; r = d; } } else p = 2; if ( (!(((p | 0) == 2) & w) ? Sb(o) | 0 : 0) ? !(Sb(f) | 0) : 0 ) { g[B >> 2] = f; c[D >> 2] = 2; n = 2; o = f; } s = T(g[(b + 396) >> 2]); u = Sb(s) | 0; do if (!u) { if (((q | 0) == 1) & w) { g[B >> 2] = T(T(r - v) / s); c[D >> 2] = 1; n = 1; p = 1; break; } if (y & ((n | 0) == 1)) { g[A >> 2] = T(s * T(o - x)); c[C >> 2] = 1; n = 1; p = 1; } else p = q; } else p = q; while (0); H = Sb(d) | 0; q = (Je(a, b) | 0) != 4; if ( !(y | z | (((e | 0) != 1) | H) | (q | ((p | 0) == 1))) ? ((g[A >> 2] = d), (c[C >> 2] = 1), !u) : 0 ) { g[B >> 2] = T(T(d - v) / s); c[D >> 2] = 1; n = 1; } if ( !( E | w | (((j | 0) != 1) | (Sb(f) | 0)) | (q | ((n | 0) == 1)) ) ? ((g[B >> 2] = f), (c[D >> 2] = 1), !u) : 0 ) { g[A >> 2] = T(s * T(f - x)); c[C >> 2] = 1; } Me(b, 2, h, h, C, A); Me(b, 0, i, h, D, B); d = T(g[A >> 2]); f = T(g[B >> 2]); Td(b, d, f, k, c[C >> 2] | 0, c[D >> 2] | 0, h, i, 0, 3565, m) | 0; i = T(g[(b + 908 + (c[(976 + (F << 2)) >> 2] << 2)) >> 2]); g[(b + 504) >> 2] = T(cC(i, T(Ce(b, F, h)))); } while (0); c[(b + 500) >> 2] = c[2278]; l = G; return; } function Ie(a, b, c, d, e) { a = a | 0; b = b | 0; c = T(c); d = T(d); e = T(e); d = T(Te(a, b, c, d)); return T(cC(d, T(Ce(a, b, e)))); } function Je(a, b) { a = a | 0; b = b | 0; b = (b + 20) | 0; b = c[((c[b >> 2] | 0) == 0 ? (a + 16) | 0 : b) >> 2] | 0; if ((b | 0) == 5 ? We(c[(a + 4) >> 2] | 0) | 0 : 0) b = 1; return b | 0; } function Ke(a, b) { a = a | 0; b = b | 0; if (oe(b) | 0 ? (c[(a + 96) >> 2] | 0) != 0 : 0) b = 4; else b = c[(1040 + (b << 2)) >> 2] | 0; return (a + 60 + (b << 3)) | 0; } function Le(a, b) { a = a | 0; b = b | 0; if (oe(b) | 0 ? (c[(a + 104) >> 2] | 0) != 0 : 0) b = 5; else b = c[(1e3 + (b << 2)) >> 2] | 0; return (a + 60 + (b << 3)) | 0; } function Me(a, b, d, e, f, h) { a = a | 0; b = b | 0; d = T(d); e = T(e); f = f | 0; h = h | 0; d = T(be((a + 380 + (c[(976 + (b << 2)) >> 2] << 3)) | 0, d)); d = T(d + T(Ud(a, b, e))); switch (c[f >> 2] | 0) { case 2: case 1: { f = Sb(d) | 0; e = T(g[h >> 2]); g[h >> 2] = f | (e < d) ? e : d; break; } case 0: { if (!(Sb(d) | 0)) { c[f >> 2] = 2; g[h >> 2] = d; } break; } default: { } } return; } function Ne(a, b) { a = a | 0; b = b | 0; a = (a + 132) | 0; if (oe(b) | 0 ? (c[((Tb(a, 4, 948) | 0) + 4) >> 2] | 0) != 0 : 0) a = 1; else a = (c[((Tb(a, c[(1040 + (b << 2)) >> 2] | 0, 948) | 0) + 4) >> 2] | 0) != 0; return a | 0; } function Oe(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0; a = (a + 132) | 0; if ( oe(b) | 0 ? ((e = Tb(a, 4, 948) | 0), (c[(e + 4) >> 2] | 0) != 0) : 0 ) f = 4; else { e = Tb(a, c[(1040 + (b << 2)) >> 2] | 0, 948) | 0; if (!(c[(e + 4) >> 2] | 0)) d = T(0.0); else f = 4; } if ((f | 0) == 4) d = T(be(e, d)); return T(d); } function Pe(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; e = T(g[(a + 908 + (c[(976 + (b << 2)) >> 2] << 2)) >> 2]); e = T(e + T(me(a, b, d))); return T(e + T(ne(a, b, d))); } function Qe(a) { a = a | 0; var b = 0, d = 0, e = 0; a: do if (!(We(c[(a + 4) >> 2] | 0) | 0)) { if ((c[(a + 16) >> 2] | 0) != 5) { d = $b(a) | 0; if (!d) b = 0; else { b = 0; while (1) { e = ac(a, b) | 0; if ( (c[(e + 24) >> 2] | 0) == 0 ? (c[(e + 20) >> 2] | 0) == 5 : 0 ) { b = 1; break a; } b = (b + 1) | 0; if (b >>> 0 >= d >>> 0) { b = 0; break; } } } } else b = 1; } else b = 0; while (0); return b | 0; } function Re(a, b) { a = a | 0; b = b | 0; var d = ib; d = T(g[(a + 908 + (c[(976 + (b << 2)) >> 2] << 2)) >> 2]); return ((d >= T(0.0)) & ((Sb(d) | 0) ^ 1)) | 0; } function Se(a) { a = a | 0; var b = ib, d = 0, e = 0, f = 0, h = 0, i = 0, j = 0, k = ib; d = c[(a + 968) >> 2] | 0; if (!d) { h = $b(a) | 0; do if (h | 0) { d = 0; f = 0; while (1) { e = ac(a, f) | 0; if (c[(e + 940) >> 2] | 0) { i = 8; break; } if ((c[(e + 24) >> 2] | 0) != 1) { j = (Je(a, e) | 0) == 5; if (j) { d = e; break; } else d = (d | 0) == 0 ? e : d; } f = (f + 1) | 0; if (f >>> 0 >= h >>> 0) { i = 8; break; } } if ((i | 0) == 8) if (!d) break; b = T(Se(d)); return T(b + T(g[(d + 404) >> 2])); } while (0); b = T(g[(a + 912) >> 2]); } else { k = T(g[(a + 908) >> 2]); b = T(g[(a + 912) >> 2]); b = T(mb[d & 0](a, k, b)); ec(a, (Sb(b) | 0) ^ 1, 3573); } return T(b); } function Te(a, b, c, d) { a = a | 0; b = b | 0; c = T(c); d = T(d); var e = ib, f = 0; if (!(We(b) | 0)) { if (oe(b) | 0) { b = 0; f = 3; } else { d = T(t); e = T(t); } } else { b = 1; f = 3; } if ((f | 0) == 3) { e = T(be((a + 364 + (b << 3)) | 0, d)); d = T(be((a + 380 + (b << 3)) | 0, d)); } f = (d < c) & ((d >= T(0.0)) & ((Sb(d) | 0) ^ 1)); c = f ? d : c; f = (e >= T(0.0)) & ((Sb(e) | 0) ^ 1) & (c < e); return T(f ? e : c); } function Ue(a, b, d, e, f, h, i) { a = a | 0; b = b | 0; d = T(d); e = e | 0; f = T(f); h = h | 0; i = i | 0; var j = ib, k = ib, l = 0, m = 0, n = ib, o = ib, p = ib, q = 0, r = 0, s = 0, u = 0, v = ib, w = 0; s = re(c[(a + 4) >> 2] | 0, h) | 0; q = ze(s, h) | 0; r = oe(s) | 0; n = T(Ud(b, 2, d)); o = T(Ud(b, 0, d)); if (!(ae(b, 2, d) | 0)) { if (Ne(b, 2) | 0 ? Ze(b, 2) | 0 : 0) { j = T(g[(a + 908) >> 2]); k = T(se(a, 2)); k = T(j - T(k + T(te(a, 2)))); j = T(Oe(b, 2, d)); j = T(Ie(b, 2, T(k - T(j + T(_e(b, 2, d)))), d, d)); } else j = T(t); } else j = T(n + T(be(c[(b + 992) >> 2] | 0, d))); if (!(ae(b, 0, f) | 0)) { if (Ne(b, 0) | 0 ? Ze(b, 0) | 0 : 0) { k = T(g[(a + 912) >> 2]); v = T(se(a, 0)); v = T(k - T(v + T(te(a, 0)))); k = T(Oe(b, 0, f)); k = T(Ie(b, 0, T(v - T(k + T(_e(b, 0, f)))), f, d)); } else k = T(t); } else k = T(o + T(be(c[(b + 996) >> 2] | 0, f))); l = Sb(j) | 0; m = Sb(k) | 0; do if (l ^ m ? ((p = T(g[(b + 396) >> 2])), !(Sb(p) | 0)) : 0) if (l) { j = T(n + T(T(k - o) * p)); break; } else { v = T(o + T(T(j - n) / p)); k = m ? v : k; break; } while (0); m = Sb(j) | 0; l = Sb(k) | 0; if (m | l) { w = (m ^ 1) & 1; e = (d > T(0.0)) & (((e | 0) != 0) & m); j = r ? j : e ? d : j; Td( b, j, k, h, r ? w : e ? 2 : w, m & (l ^ 1) & 1, j, k, 0, 3623, i ) | 0; j = T(g[(b + 908) >> 2]); j = T(j + T(Ud(b, 2, d))); k = T(g[(b + 912) >> 2]); k = T(k + T(Ud(b, 0, d))); } Td(b, j, k, h, 1, 1, j, k, 1, 3635, i) | 0; if (Ze(b, s) | 0 ? !(Ne(b, s) | 0) : 0) { w = c[(976 + (s << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(v - T(g[(b + 908 + (w << 2)) >> 2])); v = T(v - T(te(a, s))); v = T(v - T(ne(b, s, d))); v = T(v - T(_e(b, s, r ? d : f))); g[(b + 400 + (c[(1040 + (s << 2)) >> 2] << 2)) >> 2] = v; } else u = 21; do if ((u | 0) == 21) { if (!(Ne(b, s) | 0) ? (c[(a + 8) >> 2] | 0) == 1 : 0) { w = c[(976 + (s << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(T(v - T(g[(b + 908 + (w << 2)) >> 2])) * T(0.5)); g[(b + 400 + (c[(1040 + (s << 2)) >> 2] << 2)) >> 2] = v; break; } if (!(Ne(b, s) | 0) ? (c[(a + 8) >> 2] | 0) == 2 : 0) { w = c[(976 + (s << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(v - T(g[(b + 908 + (w << 2)) >> 2])); g[(b + 400 + (c[(1040 + (s << 2)) >> 2] << 2)) >> 2] = v; } } while (0); if (Ze(b, q) | 0 ? !(Ne(b, q) | 0) : 0) { w = c[(976 + (q << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(v - T(g[(b + 908 + (w << 2)) >> 2])); v = T(v - T(te(a, q))); v = T(v - T(ne(b, q, d))); v = T(v - T(_e(b, q, r ? f : d))); g[(b + 400 + (c[(1040 + (q << 2)) >> 2] << 2)) >> 2] = v; } else u = 30; do if ((u | 0) == 30 ? !(Ne(b, q) | 0) : 0) { if ((Je(a, b) | 0) == 2) { w = c[(976 + (q << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(T(v - T(g[(b + 908 + (w << 2)) >> 2])) * T(0.5)); g[(b + 400 + (c[(1040 + (q << 2)) >> 2] << 2)) >> 2] = v; break; } w = (Je(a, b) | 0) == 3; if (w ^ ((c[(a + 28) >> 2] | 0) == 2)) { w = c[(976 + (q << 2)) >> 2] | 0; v = T(g[(a + 908 + (w << 2)) >> 2]); v = T(v - T(g[(b + 908 + (w << 2)) >> 2])); g[(b + 400 + (c[(1040 + (q << 2)) >> 2] << 2)) >> 2] = v; } } while (0); return; } function Ve(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = ib, f = 0; f = c[(976 + (d << 2)) >> 2] | 0; e = T(g[(b + 908 + (f << 2)) >> 2]); e = T(T(g[(a + 908 + (f << 2)) >> 2]) - e); e = T(e - T(g[(b + 400 + (c[(1040 + (d << 2)) >> 2] << 2)) >> 2])); g[(b + 400 + (c[(1e3 + (d << 2)) >> 2] << 2)) >> 2] = e; return; } function We(a) { a = a | 0; return ((a | 1 | 0) == 1) | 0; } function Xe(b) { b = b | 0; var d = ib; switch (c[(b + 56) >> 2] | 0) { case 0: case 3: { d = T(g[(b + 40) >> 2]); if ((d > T(0.0)) & ((Sb(d) | 0) ^ 1)) b = a[((c[(b + 976) >> 2] | 0) + 2) >> 0] | 0 ? 1056 : 992; else b = 1056; break; } default: b = (b + 52) | 0; } return b | 0; } function Ye(b, c) { b = b | 0; c = c | 0; return ((a[(b + c) >> 0] | 0) != 0) | 0; } function Ze(a, b) { a = a | 0; b = b | 0; a = (a + 132) | 0; if (oe(b) | 0 ? (c[((Tb(a, 5, 948) | 0) + 4) >> 2] | 0) != 0 : 0) a = 1; else a = (c[((Tb(a, c[(1e3 + (b << 2)) >> 2] | 0, 948) | 0) + 4) >> 2] | 0) != 0; return a | 0; } function _e(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0; a = (a + 132) | 0; if ( oe(b) | 0 ? ((e = Tb(a, 5, 948) | 0), (c[(e + 4) >> 2] | 0) != 0) : 0 ) f = 4; else { e = Tb(a, c[(1e3 + (b << 2)) >> 2] | 0, 948) | 0; if (!(c[(e + 4) >> 2] | 0)) d = T(0.0); else f = 4; } if ((f | 0) == 4) d = T(be(e, d)); return T(d); } function $e(a, b, c) { a = a | 0; b = b | 0; c = T(c); if (Ne(a, b) | 0) c = T(Oe(a, b, c)); else c = T(-T(_e(a, b, c))); return T(c); } function af(a) { a = T(a); return ((g[j >> 2] = a), c[j >> 2] | 0) | 0; } function bf(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 2)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 2); return; } function cf(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 2)) << 2)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function df(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -4 - b) | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ef(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = (a + 4) | 0; i = c[h >> 2] | 0; f = (i - e) | 0; g = f >> 2; a = (b + (g << 2)) | 0; if (a >>> 0 < d >>> 0) { e = i; do { c[e >> 2] = c[a >> 2]; a = (a + 4) | 0; e = ((c[h >> 2] | 0) + 4) | 0; c[h >> 2] = e; } while (a >>> 0 < d >>> 0); } if (g | 0) GC((i + ((0 - g) << 2)) | 0, b | 0, f | 0) | 0; return; } function ff(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = (b + 4) | 0; j = c[i >> 2] | 0; f = c[a >> 2] | 0; h = d; g = (h - f) | 0; e = (j + ((0 - (g >> 2)) << 2)) | 0; c[i >> 2] = e; if ((g | 0) > 0) BC(e | 0, f | 0, g | 0) | 0; f = (a + 4) | 0; g = (b + 8) | 0; e = ((c[f >> 2] | 0) - h) | 0; if ((e | 0) > 0) { BC(c[g >> 2] | 0, d | 0, e | 0) | 0; c[g >> 2] = (c[g >> 2] | 0) + ((e >>> 2) << 2); } h = c[a >> 2] | 0; c[a >> 2] = c[i >> 2]; c[i >> 2] = h; h = c[f >> 2] | 0; c[f >> 2] = c[g >> 2]; c[g >> 2] = h; h = (a + 8) | 0; d = (b + 12) | 0; a = c[h >> 2] | 0; c[h >> 2] = c[d >> 2]; c[d >> 2] = a; c[b >> 2] = c[i >> 2]; return j | 0; } function gf(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; h = c[b >> 2] | 0; g = c[d >> 2] | 0; if ((h | 0) != (g | 0)) { f = (a + 8) | 0; d = ((((g + -4 - h) | 0) >>> 2) + 1) | 0; a = h; e = c[f >> 2] | 0; do { c[e >> 2] = c[a >> 2]; e = ((c[f >> 2] | 0) + 4) | 0; c[f >> 2] = e; a = (a + 4) | 0; } while ((a | 0) != (g | 0)); c[b >> 2] = h + (d << 2); } return; } function hf() { Qb(); return; } function jf() { var a = 0; a = qC(4) | 0; kf(a); return a | 0; } function kf(a) { a = a | 0; c[a >> 2] = gc() | 0; return; } function lf(a) { a = a | 0; if (a | 0) { mf(a); sC(a); } return; } function mf(a) { a = a | 0; ic(c[a >> 2] | 0); return; } function nf(a, b, d) { a = a | 0; b = b | 0; d = d | 0; he(c[a >> 2] | 0, b, d); return; } function of(a, b) { a = a | 0; b = T(b); Zd(c[a >> 2] | 0, b); return; } function pf(a, b) { a = a | 0; b = b | 0; return Ye(c[a >> 2] | 0, b) | 0; } function qf() { var a = 0; a = qC(8) | 0; rf(a, 0); return a | 0; } function rf(a, b) { a = a | 0; b = b | 0; if (!b) b = Wb() | 0; else b = Ub(c[b >> 2] | 0) | 0; c[a >> 2] = b; c[(a + 4) >> 2] = 0; vc(b, a); return; } function sf(a) { a = a | 0; var b = 0; b = qC(8) | 0; rf(b, a); return b | 0; } function tf(a) { a = a | 0; if (a | 0) { uf(a); sC(a); } return; } function uf(a) { a = a | 0; var b = 0; Zb(c[a >> 2] | 0); b = (a + 4) | 0; a = c[b >> 2] | 0; c[b >> 2] = 0; if (a | 0) { vf(a); sC(a); } return; } function vf(a) { a = a | 0; wf(a); return; } function wf(a) { a = a | 0; a = c[a >> 2] | 0; if (a | 0) ab(a | 0); return; } function xf(a) { a = a | 0; return wc(a) | 0; } function yf(a) { a = a | 0; var b = 0, d = 0; d = (a + 4) | 0; b = c[d >> 2] | 0; c[d >> 2] = 0; if (b | 0) { vf(b); sC(b); } dc(c[a >> 2] | 0); return; } function zf(a, b) { a = a | 0; b = b | 0; sc(c[a >> 2] | 0, c[b >> 2] | 0); return; } function Af(a, b) { a = a | 0; b = b | 0; Hc(c[a >> 2] | 0, b); return; } function Bf(a, b, d) { a = a | 0; b = b | 0; d = +d; Vc(c[a >> 2] | 0, b, T(d)); return; } function Cf(a, b, d) { a = a | 0; b = b | 0; d = +d; Wc(c[a >> 2] | 0, b, T(d)); return; } function Df(a, b) { a = a | 0; b = b | 0; Bc(c[a >> 2] | 0, b); return; } function Ef(a, b) { a = a | 0; b = b | 0; Dc(c[a >> 2] | 0, b); return; } function Ff(a, b) { a = a | 0; b = b | 0; Fc(c[a >> 2] | 0, b); return; } function Gf(a, b) { a = a | 0; b = b | 0; xc(c[a >> 2] | 0, b); return; } function Hf(a, b) { a = a | 0; b = b | 0; Jc(c[a >> 2] | 0, b); return; } function If(a, b) { a = a | 0; b = b | 0; zc(c[a >> 2] | 0, b); return; } function Jf(a, b, d) { a = a | 0; b = b | 0; d = +d; Yc(c[a >> 2] | 0, b, T(d)); return; } function Kf(a, b, d) { a = a | 0; b = b | 0; d = +d; Zc(c[a >> 2] | 0, b, T(d)); return; } function Lf(a, b) { a = a | 0; b = b | 0; $c(c[a >> 2] | 0, b); return; } function Mf(a, b) { a = a | 0; b = b | 0; Lc(c[a >> 2] | 0, b); return; } function Nf(a, b) { a = a | 0; b = b | 0; Nc(c[a >> 2] | 0, b); return; } function Of(a, b) { a = a | 0; b = +b; Pc(c[a >> 2] | 0, T(b)); return; } function Pf(a, b) { a = a | 0; b = +b; Sc(c[a >> 2] | 0, T(b)); return; } function Qf(a, b) { a = a | 0; b = +b; Tc(c[a >> 2] | 0, T(b)); return; } function Rf(a, b) { a = a | 0; b = +b; Qc(c[a >> 2] | 0, T(b)); return; } function Sf(a, b) { a = a | 0; b = +b; Rc(c[a >> 2] | 0, T(b)); return; } function Tf(a, b) { a = a | 0; b = +b; fd(c[a >> 2] | 0, T(b)); return; } function Uf(a, b) { a = a | 0; b = +b; gd(c[a >> 2] | 0, T(b)); return; } function Vf(a) { a = a | 0; hd(c[a >> 2] | 0); return; } function Wf(a, b) { a = a | 0; b = +b; jd(c[a >> 2] | 0, T(b)); return; } function Xf(a, b) { a = a | 0; b = +b; kd(c[a >> 2] | 0, T(b)); return; } function Yf(a) { a = a | 0; ld(c[a >> 2] | 0); return; } function Zf(a, b) { a = a | 0; b = +b; nd(c[a >> 2] | 0, T(b)); return; } function _f(a, b) { a = a | 0; b = +b; od(c[a >> 2] | 0, T(b)); return; } function $f(a, b) { a = a | 0; b = +b; qd(c[a >> 2] | 0, T(b)); return; } function ag(a, b) { a = a | 0; b = +b; rd(c[a >> 2] | 0, T(b)); return; } function bg(a, b) { a = a | 0; b = +b; td(c[a >> 2] | 0, T(b)); return; } function cg(a, b) { a = a | 0; b = +b; ud(c[a >> 2] | 0, T(b)); return; } function dg(a, b) { a = a | 0; b = +b; wd(c[a >> 2] | 0, T(b)); return; } function eg(a, b) { a = a | 0; b = +b; xd(c[a >> 2] | 0, T(b)); return; } function fg(a, b) { a = a | 0; b = +b; zd(c[a >> 2] | 0, T(b)); return; } function gg(a, b, d) { a = a | 0; b = b | 0; d = +d; dd(c[a >> 2] | 0, b, T(d)); return; } function hg(a, b, d) { a = a | 0; b = b | 0; d = +d; ad(c[a >> 2] | 0, b, T(d)); return; } function ig(a, b, d) { a = a | 0; b = b | 0; d = +d; bd(c[a >> 2] | 0, b, T(d)); return; } function jg(a) { a = a | 0; return Ic(c[a >> 2] | 0) | 0; } function kg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = e; Xc(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function lg(a, b) { a = a | 0; b = b | 0; mg(a, c[(b + 4) >> 2] | 0, +T(g[b >> 2])); return; } function mg(a, b, d) { a = a | 0; b = b | 0; d = +d; c[a >> 2] = b; h[(a + 8) >> 3] = d; return; } function ng(a) { a = a | 0; return Cc(c[a >> 2] | 0) | 0; } function og(a) { a = a | 0; return Ec(c[a >> 2] | 0) | 0; } function pg(a) { a = a | 0; return Gc(c[a >> 2] | 0) | 0; } function qg(a) { a = a | 0; return yc(c[a >> 2] | 0) | 0; } function rg(a) { a = a | 0; return Kc(c[a >> 2] | 0) | 0; } function sg(a) { a = a | 0; return Ac(c[a >> 2] | 0) | 0; } function tg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = e; _c(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function ug(a) { a = a | 0; return Mc(c[a >> 2] | 0) | 0; } function vg(a) { a = a | 0; return Oc(c[a >> 2] | 0) | 0; } function wg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; Uc(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function xg(a) { a = a | 0; return +(+T(tc(c[a >> 2] | 0))); } function yg(a) { a = a | 0; return +(+T(uc(c[a >> 2] | 0))); } function zg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; id(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Ag(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; md(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Bg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; pd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Cg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; sd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Dg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; vd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Eg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; yd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Fg(a) { a = a | 0; return +(+T(Ad(c[a >> 2] | 0))); } function Gg(a, b) { a = a | 0; b = b | 0; return +(+T(ed(c[a >> 2] | 0, b))); } function Hg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = e; cd(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function Ig(a, b, d) { a = a | 0; b = b | 0; d = d | 0; kc(c[a >> 2] | 0, c[b >> 2] | 0, d); return; } function Jg(a, b) { a = a | 0; b = b | 0; cc(c[a >> 2] | 0, c[b >> 2] | 0); return; } function Kg(a) { a = a | 0; return $b(c[a >> 2] | 0) | 0; } function Lg(a) { a = a | 0; a = pc(c[a >> 2] | 0) | 0; if (!a) a = 0; else a = xf(a) | 0; return a | 0; } function Mg(a, b) { a = a | 0; b = b | 0; a = ac(c[a >> 2] | 0, b) | 0; if (!a) a = 0; else a = xf(a) | 0; return a | 0; } function Ng(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = qC(4) | 0; Og(e, b); d = (a + 4) | 0; b = c[d >> 2] | 0; c[d >> 2] = e; if (b | 0) { vf(b); sC(b); } jc(c[a >> 2] | 0, 1); return; } function Og(a, b) { a = a | 0; b = b | 0; gh(a, b); return; } function Pg(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = T(c); d = d | 0; e = T(e); f = f | 0; var i = 0, j = 0; i = l; l = (l + 16) | 0; j = i; Qg(j, wc(b) | 0, +c, d, +e, f); g[a >> 2] = T(+h[j >> 3]); g[(a + 4) >> 2] = T(+h[(j + 8) >> 3]); l = i; return; } function Qg(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = +d; e = e | 0; f = +f; g = g | 0; var i = 0, j = 0, k = 0, m = 0, n = 0; i = l; l = (l + 32) | 0; n = (i + 8) | 0; m = (i + 20) | 0; k = i; j = (i + 16) | 0; h[n >> 3] = d; c[m >> 2] = e; h[k >> 3] = f; c[j >> 2] = g; Rg(a, c[(b + 4) >> 2] | 0, n, m, k, j); l = i; return; } function Rg(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var i = 0, j = 0; i = l; l = (l + 16) | 0; j = i; UA(j); b = Sg(b) | 0; Tg(a, b, +h[d >> 3], c[e >> 2] | 0, +h[f >> 3], c[g >> 2] | 0); WA(j); l = i; return; } function Sg(a) { a = a | 0; return c[a >> 2] | 0; } function Tg(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = +c; d = d | 0; e = +e; f = f | 0; var g = 0; g = Vg(Ug() | 0) | 0; c = +Wg(c); d = Xg(d) | 0; e = +Wg(e); Yg(a, cb(0, g | 0, b | 0, +c, d | 0, +e, Xg(f) | 0) | 0); return; } function Ug() { var b = 0; if (!(a[7608] | 0)) { dh(9120); b = 7608; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 9120; } function Vg(a) { a = a | 0; return c[(a + 8) >> 2] | 0; } function Wg(a) { a = +a; return +(+ch(a)); } function Xg(a) { a = a | 0; return bh(a) | 0; } function Yg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 32) | 0; d = f; e = b; if (!(e & 1)) { c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = c[(b + 4) >> 2]; c[(a + 8) >> 2] = c[(b + 8) >> 2]; c[(a + 12) >> 2] = c[(b + 12) >> 2]; } else { Zg(d, 0); Ja(e | 0, d | 0) | 0; _g(a, d); $g(d); } l = f; return; } function Zg(b, d) { b = b | 0; d = d | 0; ah(b, d); c[(b + 8) >> 2] = 0; a[(b + 24) >> 0] = 0; return; } function _g(a, b) { a = a | 0; b = b | 0; b = (b + 8) | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = c[(b + 4) >> 2]; c[(a + 8) >> 2] = c[(b + 8) >> 2]; c[(a + 12) >> 2] = c[(b + 12) >> 2]; return; } function $g(b) { b = b | 0; a[(b + 24) >> 0] = 0; return; } function ah(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function bh(a) { a = a | 0; return a | 0; } function ch(a) { a = +a; return +a; } function dh(a) { a = a | 0; fh(a, eh() | 0, 4); return; } function eh() { return 1064; } function fh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; c[(a + 8) >> 2] = _a(b | 0, (d + 1) | 0) | 0; return; } function gh(a, b) { a = a | 0; b = b | 0; b = c[b >> 2] | 0; c[a >> 2] = b; Aa(b | 0); return; } function hh(a) { a = a | 0; var b = 0, d = 0; d = (a + 4) | 0; b = c[d >> 2] | 0; c[d >> 2] = 0; if (b | 0) { vf(b); sC(b); } jc(c[a >> 2] | 0, 0); return; } function ih(a) { a = a | 0; qc(c[a >> 2] | 0); return; } function jh(a) { a = a | 0; return rc(c[a >> 2] | 0) | 0; } function kh(a, b, d, e) { a = a | 0; b = +b; d = +d; e = e | 0; _d(c[a >> 2] | 0, T(b), T(d), e); return; } function lh(a) { a = a | 0; return +(+T(Bd(c[a >> 2] | 0))); } function mh(a) { a = a | 0; return +(+T(Dd(c[a >> 2] | 0))); } function nh(a) { a = a | 0; return +(+T(Cd(c[a >> 2] | 0))); } function oh(a) { a = a | 0; return +(+T(Ed(c[a >> 2] | 0))); } function ph(a) { a = a | 0; return +(+T(Fd(c[a >> 2] | 0))); } function qh(a) { a = a | 0; return +(+T(Gd(c[a >> 2] | 0))); } function rh(a, b) { a = a | 0; b = b | 0; h[a >> 3] = +T(Bd(c[b >> 2] | 0)); h[(a + 8) >> 3] = +T(Dd(c[b >> 2] | 0)); h[(a + 16) >> 3] = +T(Cd(c[b >> 2] | 0)); h[(a + 24) >> 3] = +T(Ed(c[b >> 2] | 0)); h[(a + 32) >> 3] = +T(Fd(c[b >> 2] | 0)); h[(a + 40) >> 3] = +T(Gd(c[b >> 2] | 0)); return; } function sh(a, b) { a = a | 0; b = b | 0; return +(+T(Hd(c[a >> 2] | 0, b))); } function th(a, b) { a = a | 0; b = b | 0; return +(+T(Id(c[a >> 2] | 0, b))); } function uh(a, b) { a = a | 0; b = b | 0; return +(+T(Jd(c[a >> 2] | 0, b))); } function vh() { return fc() | 0; } function wh() { xh(); yh(); zh(); Ah(); Bh(); Ch(); return; } function xh() { kv(11713, 4938, 1); return; } function yh() { yu(10448); return; } function zh() { eu(10408); return; } function Ah() { vt(10324); return; } function Bh() { or(10096); return; } function Ch() { Dh(9132); return; } function Dh(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0, I = 0, J = 0, K = 0, L = 0, M = 0, N = 0, O = 0, P = 0, Q = 0, R = 0, S = 0, T = 0, U = 0, V = 0, W = 0, X = 0, Y = 0, Z = 0, _ = 0, $ = 0, aa = 0, ba = 0, ca = 0, da = 0, ea = 0, fa = 0, ga = 0, ha = 0, ia = 0, ja = 0, ka = 0, la = 0, ma = 0, na = 0, oa = 0, pa = 0, qa = 0, ra = 0, sa = 0, ta = 0, ua = 0, va = 0, wa = 0, xa = 0, ya = 0, za = 0, Aa = 0, Ba = 0, Ca = 0, Da = 0, Ea = 0, Fa = 0, Ga = 0; b = l; l = (l + 672) | 0; d = (b + 656) | 0; Ga = (b + 648) | 0; Fa = (b + 640) | 0; Ea = (b + 632) | 0; Da = (b + 624) | 0; Ca = (b + 616) | 0; Ba = (b + 608) | 0; Aa = (b + 600) | 0; za = (b + 592) | 0; ya = (b + 584) | 0; xa = (b + 576) | 0; wa = (b + 568) | 0; va = (b + 560) | 0; ua = (b + 552) | 0; ta = (b + 544) | 0; sa = (b + 536) | 0; ra = (b + 528) | 0; qa = (b + 520) | 0; pa = (b + 512) | 0; oa = (b + 504) | 0; na = (b + 496) | 0; ma = (b + 488) | 0; la = (b + 480) | 0; ka = (b + 472) | 0; ja = (b + 464) | 0; ia = (b + 456) | 0; ha = (b + 448) | 0; ga = (b + 440) | 0; fa = (b + 432) | 0; ea = (b + 424) | 0; da = (b + 416) | 0; ca = (b + 408) | 0; ba = (b + 400) | 0; aa = (b + 392) | 0; $ = (b + 384) | 0; _ = (b + 376) | 0; Z = (b + 368) | 0; Y = (b + 360) | 0; X = (b + 352) | 0; W = (b + 344) | 0; V = (b + 336) | 0; U = (b + 328) | 0; T = (b + 320) | 0; S = (b + 312) | 0; R = (b + 304) | 0; Q = (b + 296) | 0; P = (b + 288) | 0; O = (b + 280) | 0; N = (b + 272) | 0; M = (b + 264) | 0; L = (b + 256) | 0; K = (b + 248) | 0; J = (b + 240) | 0; I = (b + 232) | 0; H = (b + 224) | 0; G = (b + 216) | 0; F = (b + 208) | 0; E = (b + 200) | 0; D = (b + 192) | 0; C = (b + 184) | 0; B = (b + 176) | 0; A = (b + 168) | 0; z = (b + 160) | 0; y = (b + 152) | 0; x = (b + 144) | 0; w = (b + 136) | 0; v = (b + 128) | 0; u = (b + 120) | 0; t = (b + 112) | 0; s = (b + 104) | 0; r = (b + 96) | 0; q = (b + 88) | 0; p = (b + 80) | 0; o = (b + 72) | 0; n = (b + 64) | 0; m = (b + 56) | 0; k = (b + 48) | 0; j = (b + 40) | 0; i = (b + 32) | 0; h = (b + 24) | 0; g = (b + 16) | 0; f = (b + 8) | 0; e = b; Eh(a, 3646); Fh(a, 3651, 2) | 0; Gh(a, 3665, 2) | 0; Hh(a, 3682, 18) | 0; c[Ga >> 2] = 19; c[(Ga + 4) >> 2] = 0; c[d >> 2] = c[Ga >> 2]; c[(d + 4) >> 2] = c[(Ga + 4) >> 2]; Ih(a, 3690, d) | 0; c[Fa >> 2] = 1; c[(Fa + 4) >> 2] = 0; c[d >> 2] = c[Fa >> 2]; c[(d + 4) >> 2] = c[(Fa + 4) >> 2]; Jh(a, 3696, d) | 0; c[Ea >> 2] = 2; c[(Ea + 4) >> 2] = 0; c[d >> 2] = c[Ea >> 2]; c[(d + 4) >> 2] = c[(Ea + 4) >> 2]; Kh(a, 3706, d) | 0; c[Da >> 2] = 1; c[(Da + 4) >> 2] = 0; c[d >> 2] = c[Da >> 2]; c[(d + 4) >> 2] = c[(Da + 4) >> 2]; Lh(a, 3722, d) | 0; c[Ca >> 2] = 2; c[(Ca + 4) >> 2] = 0; c[d >> 2] = c[Ca >> 2]; c[(d + 4) >> 2] = c[(Ca + 4) >> 2]; Lh(a, 3734, d) | 0; c[Ba >> 2] = 3; c[(Ba + 4) >> 2] = 0; c[d >> 2] = c[Ba >> 2]; c[(d + 4) >> 2] = c[(Ba + 4) >> 2]; Kh(a, 3753, d) | 0; c[Aa >> 2] = 4; c[(Aa + 4) >> 2] = 0; c[d >> 2] = c[Aa >> 2]; c[(d + 4) >> 2] = c[(Aa + 4) >> 2]; Kh(a, 3769, d) | 0; c[za >> 2] = 5; c[(za + 4) >> 2] = 0; c[d >> 2] = c[za >> 2]; c[(d + 4) >> 2] = c[(za + 4) >> 2]; Kh(a, 3783, d) | 0; c[ya >> 2] = 6; c[(ya + 4) >> 2] = 0; c[d >> 2] = c[ya >> 2]; c[(d + 4) >> 2] = c[(ya + 4) >> 2]; Kh(a, 3796, d) | 0; c[xa >> 2] = 7; c[(xa + 4) >> 2] = 0; c[d >> 2] = c[xa >> 2]; c[(d + 4) >> 2] = c[(xa + 4) >> 2]; Kh(a, 3813, d) | 0; c[wa >> 2] = 8; c[(wa + 4) >> 2] = 0; c[d >> 2] = c[wa >> 2]; c[(d + 4) >> 2] = c[(wa + 4) >> 2]; Kh(a, 3825, d) | 0; c[va >> 2] = 3; c[(va + 4) >> 2] = 0; c[d >> 2] = c[va >> 2]; c[(d + 4) >> 2] = c[(va + 4) >> 2]; Lh(a, 3843, d) | 0; c[ua >> 2] = 4; c[(ua + 4) >> 2] = 0; c[d >> 2] = c[ua >> 2]; c[(d + 4) >> 2] = c[(ua + 4) >> 2]; Lh(a, 3853, d) | 0; c[ta >> 2] = 9; c[(ta + 4) >> 2] = 0; c[d >> 2] = c[ta >> 2]; c[(d + 4) >> 2] = c[(ta + 4) >> 2]; Kh(a, 3870, d) | 0; c[sa >> 2] = 10; c[(sa + 4) >> 2] = 0; c[d >> 2] = c[sa >> 2]; c[(d + 4) >> 2] = c[(sa + 4) >> 2]; Kh(a, 3884, d) | 0; c[ra >> 2] = 11; c[(ra + 4) >> 2] = 0; c[d >> 2] = c[ra >> 2]; c[(d + 4) >> 2] = c[(ra + 4) >> 2]; Kh(a, 3896, d) | 0; c[qa >> 2] = 1; c[(qa + 4) >> 2] = 0; c[d >> 2] = c[qa >> 2]; c[(d + 4) >> 2] = c[(qa + 4) >> 2]; Mh(a, 3907, d) | 0; c[pa >> 2] = 2; c[(pa + 4) >> 2] = 0; c[d >> 2] = c[pa >> 2]; c[(d + 4) >> 2] = c[(pa + 4) >> 2]; Mh(a, 3915, d) | 0; c[oa >> 2] = 3; c[(oa + 4) >> 2] = 0; c[d >> 2] = c[oa >> 2]; c[(d + 4) >> 2] = c[(oa + 4) >> 2]; Mh(a, 3928, d) | 0; c[na >> 2] = 4; c[(na + 4) >> 2] = 0; c[d >> 2] = c[na >> 2]; c[(d + 4) >> 2] = c[(na + 4) >> 2]; Mh(a, 3948, d) | 0; c[ma >> 2] = 5; c[(ma + 4) >> 2] = 0; c[d >> 2] = c[ma >> 2]; c[(d + 4) >> 2] = c[(ma + 4) >> 2]; Mh(a, 3960, d) | 0; c[la >> 2] = 6; c[(la + 4) >> 2] = 0; c[d >> 2] = c[la >> 2]; c[(d + 4) >> 2] = c[(la + 4) >> 2]; Mh(a, 3974, d) | 0; c[ka >> 2] = 7; c[(ka + 4) >> 2] = 0; c[d >> 2] = c[ka >> 2]; c[(d + 4) >> 2] = c[(ka + 4) >> 2]; Mh(a, 3983, d) | 0; c[ja >> 2] = 20; c[(ja + 4) >> 2] = 0; c[d >> 2] = c[ja >> 2]; c[(d + 4) >> 2] = c[(ja + 4) >> 2]; Ih(a, 3999, d) | 0; c[ia >> 2] = 8; c[(ia + 4) >> 2] = 0; c[d >> 2] = c[ia >> 2]; c[(d + 4) >> 2] = c[(ia + 4) >> 2]; Mh(a, 4012, d) | 0; c[ha >> 2] = 9; c[(ha + 4) >> 2] = 0; c[d >> 2] = c[ha >> 2]; c[(d + 4) >> 2] = c[(ha + 4) >> 2]; Mh(a, 4022, d) | 0; c[ga >> 2] = 21; c[(ga + 4) >> 2] = 0; c[d >> 2] = c[ga >> 2]; c[(d + 4) >> 2] = c[(ga + 4) >> 2]; Ih(a, 4039, d) | 0; c[fa >> 2] = 10; c[(fa + 4) >> 2] = 0; c[d >> 2] = c[fa >> 2]; c[(d + 4) >> 2] = c[(fa + 4) >> 2]; Mh(a, 4053, d) | 0; c[ea >> 2] = 11; c[(ea + 4) >> 2] = 0; c[d >> 2] = c[ea >> 2]; c[(d + 4) >> 2] = c[(ea + 4) >> 2]; Mh(a, 4065, d) | 0; c[da >> 2] = 12; c[(da + 4) >> 2] = 0; c[d >> 2] = c[da >> 2]; c[(d + 4) >> 2] = c[(da + 4) >> 2]; Mh(a, 4084, d) | 0; c[ca >> 2] = 13; c[(ca + 4) >> 2] = 0; c[d >> 2] = c[ca >> 2]; c[(d + 4) >> 2] = c[(ca + 4) >> 2]; Mh(a, 4097, d) | 0; c[ba >> 2] = 14; c[(ba + 4) >> 2] = 0; c[d >> 2] = c[ba >> 2]; c[(d + 4) >> 2] = c[(ba + 4) >> 2]; Mh(a, 4117, d) | 0; c[aa >> 2] = 15; c[(aa + 4) >> 2] = 0; c[d >> 2] = c[aa >> 2]; c[(d + 4) >> 2] = c[(aa + 4) >> 2]; Mh(a, 4129, d) | 0; c[$ >> 2] = 16; c[($ + 4) >> 2] = 0; c[d >> 2] = c[$ >> 2]; c[(d + 4) >> 2] = c[($ + 4) >> 2]; Mh(a, 4148, d) | 0; c[_ >> 2] = 17; c[(_ + 4) >> 2] = 0; c[d >> 2] = c[_ >> 2]; c[(d + 4) >> 2] = c[(_ + 4) >> 2]; Mh(a, 4161, d) | 0; c[Z >> 2] = 18; c[(Z + 4) >> 2] = 0; c[d >> 2] = c[Z >> 2]; c[(d + 4) >> 2] = c[(Z + 4) >> 2]; Mh(a, 4181, d) | 0; c[Y >> 2] = 5; c[(Y + 4) >> 2] = 0; c[d >> 2] = c[Y >> 2]; c[(d + 4) >> 2] = c[(Y + 4) >> 2]; Lh(a, 4196, d) | 0; c[X >> 2] = 6; c[(X + 4) >> 2] = 0; c[d >> 2] = c[X >> 2]; c[(d + 4) >> 2] = c[(X + 4) >> 2]; Lh(a, 4206, d) | 0; c[W >> 2] = 7; c[(W + 4) >> 2] = 0; c[d >> 2] = c[W >> 2]; c[(d + 4) >> 2] = c[(W + 4) >> 2]; Lh(a, 4217, d) | 0; c[V >> 2] = 3; c[(V + 4) >> 2] = 0; c[d >> 2] = c[V >> 2]; c[(d + 4) >> 2] = c[(V + 4) >> 2]; Nh(a, 4235, d) | 0; c[U >> 2] = 1; c[(U + 4) >> 2] = 0; c[d >> 2] = c[U >> 2]; c[(d + 4) >> 2] = c[(U + 4) >> 2]; Oh(a, 4251, d) | 0; c[T >> 2] = 4; c[(T + 4) >> 2] = 0; c[d >> 2] = c[T >> 2]; c[(d + 4) >> 2] = c[(T + 4) >> 2]; Nh(a, 4263, d) | 0; c[S >> 2] = 5; c[(S + 4) >> 2] = 0; c[d >> 2] = c[S >> 2]; c[(d + 4) >> 2] = c[(S + 4) >> 2]; Nh(a, 4279, d) | 0; c[R >> 2] = 6; c[(R + 4) >> 2] = 0; c[d >> 2] = c[R >> 2]; c[(d + 4) >> 2] = c[(R + 4) >> 2]; Nh(a, 4293, d) | 0; c[Q >> 2] = 7; c[(Q + 4) >> 2] = 0; c[d >> 2] = c[Q >> 2]; c[(d + 4) >> 2] = c[(Q + 4) >> 2]; Nh(a, 4306, d) | 0; c[P >> 2] = 8; c[(P + 4) >> 2] = 0; c[d >> 2] = c[P >> 2]; c[(d + 4) >> 2] = c[(P + 4) >> 2]; Nh(a, 4323, d) | 0; c[O >> 2] = 9; c[(O + 4) >> 2] = 0; c[d >> 2] = c[O >> 2]; c[(d + 4) >> 2] = c[(O + 4) >> 2]; Nh(a, 4335, d) | 0; c[N >> 2] = 2; c[(N + 4) >> 2] = 0; c[d >> 2] = c[N >> 2]; c[(d + 4) >> 2] = c[(N + 4) >> 2]; Oh(a, 4353, d) | 0; c[M >> 2] = 12; c[(M + 4) >> 2] = 0; c[d >> 2] = c[M >> 2]; c[(d + 4) >> 2] = c[(M + 4) >> 2]; Ph(a, 4363, d) | 0; c[L >> 2] = 1; c[(L + 4) >> 2] = 0; c[d >> 2] = c[L >> 2]; c[(d + 4) >> 2] = c[(L + 4) >> 2]; Qh(a, 4376, d) | 0; c[K >> 2] = 2; c[(K + 4) >> 2] = 0; c[d >> 2] = c[K >> 2]; c[(d + 4) >> 2] = c[(K + 4) >> 2]; Qh(a, 4388, d) | 0; c[J >> 2] = 13; c[(J + 4) >> 2] = 0; c[d >> 2] = c[J >> 2]; c[(d + 4) >> 2] = c[(J + 4) >> 2]; Ph(a, 4402, d) | 0; c[I >> 2] = 14; c[(I + 4) >> 2] = 0; c[d >> 2] = c[I >> 2]; c[(d + 4) >> 2] = c[(I + 4) >> 2]; Ph(a, 4411, d) | 0; c[H >> 2] = 15; c[(H + 4) >> 2] = 0; c[d >> 2] = c[H >> 2]; c[(d + 4) >> 2] = c[(H + 4) >> 2]; Ph(a, 4421, d) | 0; c[G >> 2] = 16; c[(G + 4) >> 2] = 0; c[d >> 2] = c[G >> 2]; c[(d + 4) >> 2] = c[(G + 4) >> 2]; Ph(a, 4433, d) | 0; c[F >> 2] = 17; c[(F + 4) >> 2] = 0; c[d >> 2] = c[F >> 2]; c[(d + 4) >> 2] = c[(F + 4) >> 2]; Ph(a, 4446, d) | 0; c[E >> 2] = 18; c[(E + 4) >> 2] = 0; c[d >> 2] = c[E >> 2]; c[(d + 4) >> 2] = c[(E + 4) >> 2]; Ph(a, 4458, d) | 0; c[D >> 2] = 3; c[(D + 4) >> 2] = 0; c[d >> 2] = c[D >> 2]; c[(d + 4) >> 2] = c[(D + 4) >> 2]; Qh(a, 4471, d) | 0; c[C >> 2] = 1; c[(C + 4) >> 2] = 0; c[d >> 2] = c[C >> 2]; c[(d + 4) >> 2] = c[(C + 4) >> 2]; Rh(a, 4486, d) | 0; c[B >> 2] = 10; c[(B + 4) >> 2] = 0; c[d >> 2] = c[B >> 2]; c[(d + 4) >> 2] = c[(B + 4) >> 2]; Nh(a, 4496, d) | 0; c[A >> 2] = 11; c[(A + 4) >> 2] = 0; c[d >> 2] = c[A >> 2]; c[(d + 4) >> 2] = c[(A + 4) >> 2]; Nh(a, 4508, d) | 0; c[z >> 2] = 3; c[(z + 4) >> 2] = 0; c[d >> 2] = c[z >> 2]; c[(d + 4) >> 2] = c[(z + 4) >> 2]; Oh(a, 4519, d) | 0; c[y >> 2] = 4; c[(y + 4) >> 2] = 0; c[d >> 2] = c[y >> 2]; c[(d + 4) >> 2] = c[(y + 4) >> 2]; Sh(a, 4530, d) | 0; c[x >> 2] = 19; c[(x + 4) >> 2] = 0; c[d >> 2] = c[x >> 2]; c[(d + 4) >> 2] = c[(x + 4) >> 2]; Th(a, 4542, d) | 0; c[w >> 2] = 12; c[(w + 4) >> 2] = 0; c[d >> 2] = c[w >> 2]; c[(d + 4) >> 2] = c[(w + 4) >> 2]; Uh(a, 4554, d) | 0; c[v >> 2] = 13; c[(v + 4) >> 2] = 0; c[d >> 2] = c[v >> 2]; c[(d + 4) >> 2] = c[(v + 4) >> 2]; Vh(a, 4568, d) | 0; c[u >> 2] = 2; c[(u + 4) >> 2] = 0; c[d >> 2] = c[u >> 2]; c[(d + 4) >> 2] = c[(u + 4) >> 2]; Wh(a, 4578, d) | 0; c[t >> 2] = 20; c[(t + 4) >> 2] = 0; c[d >> 2] = c[t >> 2]; c[(d + 4) >> 2] = c[(t + 4) >> 2]; Xh(a, 4587, d) | 0; c[s >> 2] = 22; c[(s + 4) >> 2] = 0; c[d >> 2] = c[s >> 2]; c[(d + 4) >> 2] = c[(s + 4) >> 2]; Ih(a, 4602, d) | 0; c[r >> 2] = 23; c[(r + 4) >> 2] = 0; c[d >> 2] = c[r >> 2]; c[(d + 4) >> 2] = c[(r + 4) >> 2]; Ih(a, 4619, d) | 0; c[q >> 2] = 14; c[(q + 4) >> 2] = 0; c[d >> 2] = c[q >> 2]; c[(d + 4) >> 2] = c[(q + 4) >> 2]; Yh(a, 4629, d) | 0; c[p >> 2] = 1; c[(p + 4) >> 2] = 0; c[d >> 2] = c[p >> 2]; c[(d + 4) >> 2] = c[(p + 4) >> 2]; Zh(a, 4637, d) | 0; c[o >> 2] = 4; c[(o + 4) >> 2] = 0; c[d >> 2] = c[o >> 2]; c[(d + 4) >> 2] = c[(o + 4) >> 2]; Qh(a, 4653, d) | 0; c[n >> 2] = 5; c[(n + 4) >> 2] = 0; c[d >> 2] = c[n >> 2]; c[(d + 4) >> 2] = c[(n + 4) >> 2]; Qh(a, 4669, d) | 0; c[m >> 2] = 6; c[(m + 4) >> 2] = 0; c[d >> 2] = c[m >> 2]; c[(d + 4) >> 2] = c[(m + 4) >> 2]; Qh(a, 4686, d) | 0; c[k >> 2] = 7; c[(k + 4) >> 2] = 0; c[d >> 2] = c[k >> 2]; c[(d + 4) >> 2] = c[(k + 4) >> 2]; Qh(a, 4701, d) | 0; c[j >> 2] = 8; c[(j + 4) >> 2] = 0; c[d >> 2] = c[j >> 2]; c[(d + 4) >> 2] = c[(j + 4) >> 2]; Qh(a, 4719, d) | 0; c[i >> 2] = 9; c[(i + 4) >> 2] = 0; c[d >> 2] = c[i >> 2]; c[(d + 4) >> 2] = c[(i + 4) >> 2]; Qh(a, 4736, d) | 0; c[h >> 2] = 21; c[(h + 4) >> 2] = 0; c[d >> 2] = c[h >> 2]; c[(d + 4) >> 2] = c[(h + 4) >> 2]; _h(a, 4754, d) | 0; c[g >> 2] = 2; c[(g + 4) >> 2] = 0; c[d >> 2] = c[g >> 2]; c[(d + 4) >> 2] = c[(g + 4) >> 2]; Rh(a, 4772, d) | 0; c[f >> 2] = 3; c[(f + 4) >> 2] = 0; c[d >> 2] = c[f >> 2]; c[(d + 4) >> 2] = c[(f + 4) >> 2]; Rh(a, 4790, d) | 0; c[e >> 2] = 4; c[(e + 4) >> 2] = 0; c[d >> 2] = c[e >> 2]; c[(d + 4) >> 2] = c[(e + 4) >> 2]; Rh(a, 4808, d) | 0; l = b; return; } function Eh(a, b) { a = a | 0; b = b | 0; var d = 0; d = dr() | 0; c[a >> 2] = d; er(d, b); Hv(c[a >> 2] | 0); return; } function Fh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Oq(a, ai(b) | 0, c, 0); return a | 0; } function Gh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; tq(a, ai(b) | 0, c, 0); return a | 0; } function Hh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; cq(a, ai(b) | 0, c, 0); return a | 0; } function Ih(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Lp(a, b, f); l = e; return a | 0; } function Jh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; pp(a, b, f); l = e; return a | 0; } function Kh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Yo(a, b, f); l = e; return a | 0; } function Lh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Fo(a, b, f); l = e; return a | 0; } function Mh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; mo(a, b, f); l = e; return a | 0; } function Nh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Un(a, b, f); l = e; return a | 0; } function Oh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Bn(a, b, f); l = e; return a | 0; } function Ph(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Um(a, b, f); l = e; return a | 0; } function Qh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Bm(a, b, f); l = e; return a | 0; } function Rh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; im(a, b, f); l = e; return a | 0; } function Sh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Rl(a, b, f); l = e; return a | 0; } function Th(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; vl(a, b, f); l = e; return a | 0; } function Uh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; bl(a, b, f); l = e; return a | 0; } function Vh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Kk(a, b, f); l = e; return a | 0; } function Wh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; nk(a, b, f); l = e; return a | 0; } function Xh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Rj(a, b, f); l = e; return a | 0; } function Yh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; xj(a, b, f); l = e; return a | 0; } function Zh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; _i(a, b, f); l = e; return a | 0; } function _h(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; $h(a, b, f); l = e; return a | 0; } function $h(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; bi(a, d, f, 1); l = e; return; } function ai(a) { a = a | 0; return a | 0; } function bi(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = ci() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = di(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, ei(g, e) | 0, e); l = f; return; } function ci() { var b = 0, d = 0; if (!(a[7616] | 0)) { qi(9136); Ha(24, 9136, o | 0) | 0; d = 7616; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9136) | 0)) { b = 9136; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); qi(9136); } return 9136; } function di(a) { a = a | 0; return 0; } function ei(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = ci() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; ki(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { li(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function fi(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; h = l; l = (l + 32) | 0; o = (h + 24) | 0; n = (h + 20) | 0; j = (h + 16) | 0; m = (h + 12) | 0; k = (h + 8) | 0; i = (h + 4) | 0; p = h; c[n >> 2] = b; c[j >> 2] = d; c[m >> 2] = e; c[k >> 2] = f; c[i >> 2] = g; g = (a + 28) | 0; c[p >> 2] = c[g >> 2]; c[o >> 2] = c[p >> 2]; gi((a + 24) | 0, o, n, m, k, j, i) | 0; c[g >> 2] = c[c[g >> 2] >> 2]; l = h; return; } function gi(a, b, d, e, f, g, h) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; h = h | 0; a = hi(b) | 0; b = qC(24) | 0; ii( (b + 4) | 0, c[d >> 2] | 0, c[e >> 2] | 0, c[f >> 2] | 0, c[g >> 2] | 0, c[h >> 2] | 0 ); c[b >> 2] = c[a >> 2]; c[a >> 2] = b; return b | 0; } function hi(a) { a = a | 0; return c[a >> 2] | 0; } function ii(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; c[(a + 8) >> 2] = e; c[(a + 12) >> 2] = f; c[(a + 16) >> 2] = g; return; } function ji(a, b) { a = a | 0; b = b | 0; return b | a | 0; } function ki(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function li(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = mi(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; ni( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; ki(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; oi(a, i); pi(i); l = k; return; } } function mi(a) { a = a | 0; return 357913941; } function ni(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function oi(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function pi(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function qi(a) { a = a | 0; ui(a); return; } function ri(a) { a = a | 0; ti((a + 24) | 0); return; } function si(a) { a = a | 0; return c[a >> 2] | 0; } function ti(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function ui(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 3, b, wi() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function vi() { return 9228; } function wi() { return 1140; } function xi(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = zi(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = Ai(b, e) | 0; l = d; return b | 0; } function yi(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; c[(a + 8) >> 2] = e; c[(a + 12) >> 2] = f; c[(a + 16) >> 2] = g; return; } function zi(a) { a = a | 0; return ((c[((ci() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Ai(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 48) | 0; e = f; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; ob[d & 31](e, a); e = Bi(e) | 0; l = f; return e | 0; } function Bi(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = (l + 32) | 0; b = (e + 12) | 0; c = e; d = Di(Ci() | 0) | 0; if (!d) a = Ii(a) | 0; else { Ei(b, d); Fi(c, b); Gi(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function Ci() { var b = 0; if (!(a[7632] | 0)) { Ti(9184); Ha(25, 9184, o | 0) | 0; b = 7632; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 9184; } function Di(a) { a = a | 0; return c[(a + 36) >> 2] | 0; } function Ei(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; c[(a + 4) >> 2] = a; c[(a + 8) >> 2] = 0; return; } function Fi(a, b) { a = a | 0; b = b | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = c[(b + 4) >> 2]; c[(a + 8) >> 2] = 0; return; } function Gi(a, b) { a = a | 0; b = b | 0; Ni( b, a, (a + 8) | 0, (a + 16) | 0, (a + 24) | 0, (a + 32) | 0, (a + 40) | 0 ) | 0; return; } function Hi(a) { a = a | 0; return c[((c[(a + 4) >> 2] | 0) + 8) >> 2] | 0; } function Ii(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; j = l; l = (l + 16) | 0; d = (j + 4) | 0; e = j; f = jy(8) | 0; g = f; h = qC(48) | 0; i = h; b = (i + 48) | 0; do { c[i >> 2] = c[a >> 2]; i = (i + 4) | 0; a = (a + 4) | 0; } while ((i | 0) < (b | 0)); b = (g + 4) | 0; c[b >> 2] = h; i = qC(8) | 0; h = c[b >> 2] | 0; c[e >> 2] = 0; c[d >> 2] = c[e >> 2]; Ji(i, h, d); c[f >> 2] = i; l = j; return g | 0; } function Ji(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[(d + 4) >> 2] = 0; c[(d + 8) >> 2] = 0; c[d >> 2] = 1092; c[(d + 12) >> 2] = b; c[(a + 4) >> 2] = d; return; } function Ki(a) { a = a | 0; kC(a); sC(a); return; } function Li(a) { a = a | 0; a = c[(a + 12) >> 2] | 0; if (a | 0) sC(a); return; } function Mi(a) { a = a | 0; sC(a); return; } function Ni(a, b, d, e, f, g, h) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; h = h | 0; g = Oi(c[a >> 2] | 0, b, d, e, f, g, h) | 0; h = (a + 4) | 0; c[((c[h >> 2] | 0) + 8) >> 2] = g; return c[((c[h >> 2] | 0) + 8) >> 2] | 0; } function Oi(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var i = 0, j = 0; i = l; l = (l + 16) | 0; j = i; UA(j); a = Sg(a) | 0; g = Pi( a, +h[b >> 3], +h[c >> 3], +h[d >> 3], +h[e >> 3], +h[f >> 3], +h[g >> 3] ) | 0; WA(j); l = i; return g | 0; } function Pi(a, b, c, d, e, f, g) { a = a | 0; b = +b; c = +c; d = +d; e = +e; f = +f; g = +g; var h = 0; h = Vg(Qi() | 0) | 0; b = +Wg(b); c = +Wg(c); d = +Wg(d); e = +Wg(e); f = +Wg(f); return ya(0, h | 0, a | 0, +b, +c, +d, +e, +f, +(+Wg(g))) | 0; } function Qi() { var b = 0; if (!(a[7624] | 0)) { Ri(9172); b = 7624; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 9172; } function Ri(a) { a = a | 0; fh(a, Si() | 0, 6); return; } function Si() { return 1112; } function Ti(a) { a = a | 0; Zi(a); return; } function Ui(a) { a = a | 0; Vi((a + 24) | 0); Wi((a + 16) | 0); return; } function Vi(a) { a = a | 0; Yi(a); return; } function Wi(a) { a = a | 0; Xi(a); return; } function Xi(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); } while ((b | 0) != 0); c[a >> 2] = 0; return; } function Yi(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); } while ((b | 0) != 0); c[a >> 2] = 0; return; } function Zi(b) { b = b | 0; var d = 0; c[(b + 16) >> 2] = 0; c[(b + 20) >> 2] = 0; d = (b + 24) | 0; c[d >> 2] = 0; c[(b + 28) >> 2] = d; c[(b + 36) >> 2] = 0; a[(b + 40) >> 0] = 0; a[(b + 41) >> 0] = 0; return; } function _i(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; $i(a, d, f, 0); l = e; return; } function $i(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = aj() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = bj(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, cj(g, e) | 0, e); l = f; return; } function aj() { var b = 0, d = 0; if (!(a[7640] | 0)) { jj(9232); Ha(26, 9232, o | 0) | 0; d = 7640; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9232) | 0)) { b = 9232; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); jj(9232); } return 9232; } function bj(a) { a = a | 0; return 0; } function cj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = aj() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; dj(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { ej(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function dj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function ej(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = fj(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; gj( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; dj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; hj(a, i); ij(i); l = k; return; } } function fj(a) { a = a | 0; return 357913941; } function gj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function hj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ij(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function jj(a) { a = a | 0; mj(a); return; } function kj(a) { a = a | 0; lj((a + 24) | 0); return; } function lj(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function mj(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, nj() | 0, 3); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function nj() { return 1144; } function oj(a, b, d, e, f) { a = a | 0; b = b | 0; d = +d; e = +e; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = (l + 16) | 0; h = (g + 8) | 0; i = g; j = pj(a) | 0; a = c[(j + 4) >> 2] | 0; c[i >> 2] = c[j >> 2]; c[(i + 4) >> 2] = a; c[h >> 2] = c[i >> 2]; c[(h + 4) >> 2] = c[(i + 4) >> 2]; qj(b, h, d, e, f); l = g; return; } function pj(a) { a = a | 0; return ((c[((aj() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function qj(a, b, d, e, f) { a = a | 0; b = b | 0; d = +d; e = +e; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0; k = l; l = (l + 16) | 0; h = (k + 2) | 0; i = (k + 1) | 0; j = k; g = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) g = c[((c[a >> 2] | 0) + g) >> 2] | 0; rj(h, d); d = +sj(h, d); rj(i, e); e = +sj(i, e); tj(j, f); j = uj(j, f) | 0; qb[g & 1](a, d, e, j); l = k; return; } function rj(a, b) { a = a | 0; b = +b; return; } function sj(a, b) { a = a | 0; b = +b; return +(+wj(b)); } function tj(a, b) { a = a | 0; b = b | 0; return; } function uj(a, b) { a = a | 0; b = b | 0; return vj(b) | 0; } function vj(a) { a = a | 0; return a | 0; } function wj(a) { a = +a; return +a; } function xj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; yj(a, d, f, 1); l = e; return; } function yj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = zj() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Aj(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Bj(g, e) | 0, e); l = f; return; } function zj() { var b = 0, d = 0; if (!(a[7648] | 0)) { Ij(9268); Ha(27, 9268, o | 0) | 0; d = 7648; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9268) | 0)) { b = 9268; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Ij(9268); } return 9268; } function Aj(a) { a = a | 0; return 0; } function Bj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = zj() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Cj(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Dj(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Cj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Dj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Ej(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Fj( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Cj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Gj(a, i); Hj(i); l = k; return; } } function Ej(a) { a = a | 0; return 357913941; } function Fj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Gj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Hj(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Ij(a) { a = a | 0; Lj(a); return; } function Jj(a) { a = a | 0; Kj((a + 24) | 0); return; } function Kj(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Lj(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 4, b, Mj() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Mj() { return 1160; } function Nj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = Oj(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = Pj(b, e) | 0; l = d; return b | 0; } function Oj(a) { a = a | 0; return ((c[((zj() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Pj(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; return Qj(pb[d & 31](a) | 0) | 0; } function Qj(a) { a = a | 0; return (a & 1) | 0; } function Rj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Sj(a, d, f, 0); l = e; return; } function Sj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Tj() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Uj(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Vj(g, e) | 0, e); l = f; return; } function Tj() { var b = 0, d = 0; if (!(a[7656] | 0)) { ak(9304); Ha(28, 9304, o | 0) | 0; d = 7656; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9304) | 0)) { b = 9304; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); ak(9304); } return 9304; } function Uj(a) { a = a | 0; return 0; } function Vj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Tj() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Wj(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Xj(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Wj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Xj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Yj(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Zj( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Wj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; _j(a, i); $j(i); l = k; return; } } function Yj(a) { a = a | 0; return 357913941; } function Zj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function _j(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function $j(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ak(a) { a = a | 0; dk(a); return; } function bk(a) { a = a | 0; ck((a + 24) | 0); return; } function ck(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function dk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, ek() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function ek() { return 1164; } function fk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = gk(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; hk(b, f, d); l = e; return; } function gk(a) { a = a | 0; return ((c[((Tj() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function hk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; ik(f, d); d = jk(f, d) | 0; ob[e & 31](a, d); kk(f); l = g; return; } function ik(a, b) { a = a | 0; b = b | 0; lk(a, b); return; } function jk(a, b) { a = a | 0; b = b | 0; return a | 0; } function kk(a) { a = a | 0; vf(a); return; } function lk(a, b) { a = a | 0; b = b | 0; mk(a, b); return; } function mk(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function nk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; ok(a, d, f, 0); l = e; return; } function ok(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = pk() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = qk(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, rk(g, e) | 0, e); l = f; return; } function pk() { var b = 0, d = 0; if (!(a[7664] | 0)) { yk(9340); Ha(29, 9340, o | 0) | 0; d = 7664; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9340) | 0)) { b = 9340; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); yk(9340); } return 9340; } function qk(a) { a = a | 0; return 0; } function rk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = pk() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; sk(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { tk(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function sk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function tk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = uk(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; vk( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; sk(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; wk(a, i); xk(i); l = k; return; } } function uk(a) { a = a | 0; return 357913941; } function vk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function wk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function xk(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function yk(a) { a = a | 0; Bk(a); return; } function zk(a) { a = a | 0; Ak((a + 24) | 0); return; } function Ak(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Bk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 4, b, Ck() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Ck() { return 1180; } function Dk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Ek(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; d = Fk(b, f, d) | 0; l = e; return d | 0; } function Ek(a) { a = a | 0; return ((c[((pk() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Fk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; Gk(f, d); f = Hk(f, d) | 0; f = Ik(wb[e & 15](a, f) | 0) | 0; l = g; return f | 0; } function Gk(a, b) { a = a | 0; b = b | 0; return; } function Hk(a, b) { a = a | 0; b = b | 0; return Jk(b) | 0; } function Ik(a) { a = a | 0; return a | 0; } function Jk(a) { a = a | 0; return a | 0; } function Kk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Lk(a, d, f, 0); l = e; return; } function Lk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Mk() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Nk(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Ok(g, e) | 0, e); l = f; return; } function Mk() { var b = 0, d = 0; if (!(a[7672] | 0)) { Vk(9376); Ha(30, 9376, o | 0) | 0; d = 7672; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9376) | 0)) { b = 9376; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Vk(9376); } return 9376; } function Nk(a) { a = a | 0; return 0; } function Ok(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Mk() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Pk(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Qk(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Pk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Qk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Rk(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Sk( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Pk(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Tk(a, i); Uk(i); l = k; return; } } function Rk(a) { a = a | 0; return 357913941; } function Sk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Tk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Uk(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Vk(a) { a = a | 0; Yk(a); return; } function Wk(a) { a = a | 0; Xk((a + 24) | 0); return; } function Xk(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Yk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Zk() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Zk() { return 1196; } function _k(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = $k(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = al(b, e) | 0; l = d; return b | 0; } function $k(a) { a = a | 0; return ((c[((Mk() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function al(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; return Ik(pb[d & 31](a) | 0) | 0; } function bl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; cl(a, d, f, 1); l = e; return; } function cl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = dl() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = el(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, fl(g, e) | 0, e); l = f; return; } function dl() { var b = 0, d = 0; if (!(a[7680] | 0)) { ml(9412); Ha(31, 9412, o | 0) | 0; d = 7680; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9412) | 0)) { b = 9412; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); ml(9412); } return 9412; } function el(a) { a = a | 0; return 0; } function fl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = dl() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; gl(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { hl(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function gl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function hl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = il(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; jl( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; gl(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; kl(a, i); ll(i); l = k; return; } } function il(a) { a = a | 0; return 357913941; } function jl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function kl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ll(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ml(a) { a = a | 0; pl(a); return; } function nl(a) { a = a | 0; ol((a + 24) | 0); return; } function ol(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function pl(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, ql() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function ql() { return 1200; } function rl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = sl(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = tl(b, e) | 0; l = d; return b | 0; } function sl(a) { a = a | 0; return ((c[((dl() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function tl(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; return ul(pb[d & 31](a) | 0) | 0; } function ul(a) { a = a | 0; return a | 0; } function vl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; wl(a, d, f, 0); l = e; return; } function wl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = xl() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = yl(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, zl(g, e) | 0, e); l = f; return; } function xl() { var b = 0, d = 0; if (!(a[7688] | 0)) { Gl(9448); Ha(32, 9448, o | 0) | 0; d = 7688; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9448) | 0)) { b = 9448; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Gl(9448); } return 9448; } function yl(a) { a = a | 0; return 0; } function zl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = xl() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Al(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Bl(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Al(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Bl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Cl(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Dl( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Al(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; El(a, i); Fl(i); l = k; return; } } function Cl(a) { a = a | 0; return 357913941; } function Dl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function El(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Fl(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Gl(a) { a = a | 0; Jl(a); return; } function Hl(a) { a = a | 0; Il((a + 24) | 0); return; } function Il(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Jl(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, Kl() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Kl() { return 1204; } function Ll(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Ml(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Nl(b, f, d); l = e; return; } function Ml(a) { a = a | 0; return ((c[((xl() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Nl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; Ol(f, d); f = Pl(f, d) | 0; ob[e & 31](a, f); l = g; return; } function Ol(a, b) { a = a | 0; b = b | 0; return; } function Pl(a, b) { a = a | 0; b = b | 0; return Ql(b) | 0; } function Ql(a) { a = a | 0; return a | 0; } function Rl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Sl(a, d, f, 0); l = e; return; } function Sl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Tl() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Ul(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Vl(g, e) | 0, e); l = f; return; } function Tl() { var b = 0, d = 0; if (!(a[7696] | 0)) { am(9484); Ha(33, 9484, o | 0) | 0; d = 7696; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9484) | 0)) { b = 9484; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); am(9484); } return 9484; } function Ul(a) { a = a | 0; return 0; } function Vl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Tl() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Wl(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Xl(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Wl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Xl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Yl(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Zl( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Wl(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; _l(a, i); $l(i); l = k; return; } } function Yl(a) { a = a | 0; return 357913941; } function Zl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function _l(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function $l(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function am(a) { a = a | 0; dm(a); return; } function bm(a) { a = a | 0; cm((a + 24) | 0); return; } function cm(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function dm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, em() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function em() { return 1212; } function fm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; g = (f + 8) | 0; h = f; i = gm(a) | 0; a = c[(i + 4) >> 2] | 0; c[h >> 2] = c[i >> 2]; c[(h + 4) >> 2] = a; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = c[(h + 4) >> 2]; hm(b, g, d, e); l = f; return; } function gm(a) { a = a | 0; return ((c[((Tl() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function hm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; i = l; l = (l + 16) | 0; g = (i + 1) | 0; h = i; f = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) f = c[((c[a >> 2] | 0) + f) >> 2] | 0; Ol(g, d); g = Pl(g, d) | 0; Gk(h, e); h = Hk(h, e) | 0; Eb[f & 15](a, g, h); l = i; return; } function im(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; jm(a, d, f, 1); l = e; return; } function jm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = km() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = lm(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, mm(g, e) | 0, e); l = f; return; } function km() { var b = 0, d = 0; if (!(a[7704] | 0)) { tm(9520); Ha(34, 9520, o | 0) | 0; d = 7704; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9520) | 0)) { b = 9520; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); tm(9520); } return 9520; } function lm(a) { a = a | 0; return 0; } function mm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = km() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; nm(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { om(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function nm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function om(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = pm(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; qm( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; nm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; rm(a, i); sm(i); l = k; return; } } function pm(a) { a = a | 0; return 357913941; } function qm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function rm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function sm(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function tm(a) { a = a | 0; wm(a); return; } function um(a) { a = a | 0; vm((a + 24) | 0); return; } function vm(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function wm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, xm() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function xm() { return 1224; } function ym(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0.0, f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; g = (f + 8) | 0; h = f; i = zm(a) | 0; a = c[(i + 4) >> 2] | 0; c[h >> 2] = c[i >> 2]; c[(h + 4) >> 2] = a; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = c[(h + 4) >> 2]; e = +Am(b, g, d); l = f; return +e; } function zm(a) { a = a | 0; return ((c[((km() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Am(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0.0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; tj(f, d); f = uj(f, d) | 0; h = +ch(+zb[e & 7](a, f)); l = g; return +h; } function Bm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Cm(a, d, f, 1); l = e; return; } function Cm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Dm() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Em(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Fm(g, e) | 0, e); l = f; return; } function Dm() { var b = 0, d = 0; if (!(a[7712] | 0)) { Mm(9556); Ha(35, 9556, o | 0) | 0; d = 7712; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9556) | 0)) { b = 9556; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Mm(9556); } return 9556; } function Em(a) { a = a | 0; return 0; } function Fm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Dm() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Gm(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Hm(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Gm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Hm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Im(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Jm( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Gm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Km(a, i); Lm(i); l = k; return; } } function Im(a) { a = a | 0; return 357913941; } function Jm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Km(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Lm(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Mm(a) { a = a | 0; Pm(a); return; } function Nm(a) { a = a | 0; Om((a + 24) | 0); return; } function Om(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Pm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Qm() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Qm() { return 1232; } function Rm(a, b) { a = a | 0; b = b | 0; var d = 0.0, e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Sm(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; d = +Tm(b, f); l = e; return +d; } function Sm(a) { a = a | 0; return ((c[((Dm() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Tm(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; return +(+ch(+ub[d & 15](a))); } function Um(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Vm(a, d, f, 1); l = e; return; } function Vm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Wm() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Xm(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Ym(g, e) | 0, e); l = f; return; } function Wm() { var b = 0, d = 0; if (!(a[7720] | 0)) { dn(9592); Ha(36, 9592, o | 0) | 0; d = 7720; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9592) | 0)) { b = 9592; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); dn(9592); } return 9592; } function Xm(a) { a = a | 0; return 0; } function Ym(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Wm() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Zm(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { _m(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Zm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function _m(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = $m(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; an( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Zm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; bn(a, i); cn(i); l = k; return; } } function $m(a) { a = a | 0; return 357913941; } function an(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function bn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function cn(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function dn(a) { a = a | 0; gn(a); return; } function en(a) { a = a | 0; fn((a + 24) | 0); return; } function fn(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function gn(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 7, b, hn() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function hn() { return 1276; } function jn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = kn(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = ln(b, e) | 0; l = d; return b | 0; } function kn(a) { a = a | 0; return ((c[((Wm() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function ln(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 16) | 0; e = f; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; ob[d & 31](e, a); e = mn(e) | 0; l = f; return e | 0; } function mn(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = (l + 32) | 0; b = (e + 12) | 0; c = e; d = Di(nn() | 0) | 0; if (!d) a = pn(a) | 0; else { Ei(b, d); Fi(c, b); on(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function nn() { var b = 0; if (!(a[7736] | 0)) { An(9640); Ha(25, 9640, o | 0) | 0; b = 7736; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 9640; } function on(a, b) { a = a | 0; b = b | 0; un(b, a, (a + 8) | 0) | 0; return; } function pn(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = (l + 16) | 0; f = (d + 4) | 0; h = d; e = jy(8) | 0; b = e; i = qC(16) | 0; c[i >> 2] = c[a >> 2]; c[(i + 4) >> 2] = c[(a + 4) >> 2]; c[(i + 8) >> 2] = c[(a + 8) >> 2]; c[(i + 12) >> 2] = c[(a + 12) >> 2]; g = (b + 4) | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; qn(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function qn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[(d + 4) >> 2] = 0; c[(d + 8) >> 2] = 0; c[d >> 2] = 1244; c[(d + 12) >> 2] = b; c[(a + 4) >> 2] = d; return; } function rn(a) { a = a | 0; kC(a); sC(a); return; } function sn(a) { a = a | 0; a = c[(a + 12) >> 2] | 0; if (a | 0) sC(a); return; } function tn(a) { a = a | 0; sC(a); return; } function un(a, b, d) { a = a | 0; b = b | 0; d = d | 0; b = vn(c[a >> 2] | 0, b, d) | 0; d = (a + 4) | 0; c[((c[d >> 2] | 0) + 8) >> 2] = b; return c[((c[d >> 2] | 0) + 8) >> 2] | 0; } function vn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = e; UA(f); a = Sg(a) | 0; d = wn(a, c[b >> 2] | 0, +h[d >> 3]) | 0; WA(f); l = e; return d | 0; } function wn(a, b, c) { a = a | 0; b = b | 0; c = +c; var d = 0; d = Vg(xn() | 0) | 0; b = Xg(b) | 0; return za(0, d | 0, a | 0, b | 0, +(+Wg(c))) | 0; } function xn() { var b = 0; if (!(a[7728] | 0)) { yn(9628); b = 7728; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 9628; } function yn(a) { a = a | 0; fh(a, zn() | 0, 2); return; } function zn() { return 1264; } function An(a) { a = a | 0; Zi(a); return; } function Bn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Cn(a, d, f, 1); l = e; return; } function Cn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Dn() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = En(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Fn(g, e) | 0, e); l = f; return; } function Dn() { var b = 0, d = 0; if (!(a[7744] | 0)) { Mn(9684); Ha(37, 9684, o | 0) | 0; d = 7744; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9684) | 0)) { b = 9684; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Mn(9684); } return 9684; } function En(a) { a = a | 0; return 0; } function Fn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Dn() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Gn(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Hn(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Gn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Hn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = In(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Jn( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Gn(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Kn(a, i); Ln(i); l = k; return; } } function In(a) { a = a | 0; return 357913941; } function Jn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Kn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Ln(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Mn(a) { a = a | 0; Pn(a); return; } function Nn(a) { a = a | 0; On((a + 24) | 0); return; } function On(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Pn(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Qn() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Qn() { return 1280; } function Rn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Sn(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; d = Tn(b, f, d) | 0; l = e; return d | 0; } function Sn(a) { a = a | 0; return ((c[((Dn() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Tn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; h = l; l = (l + 32) | 0; f = h; g = (h + 16) | 0; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; tj(g, d); g = uj(g, d) | 0; Eb[e & 15](f, a, g); g = mn(f) | 0; l = h; return g | 0; } function Un(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Vn(a, d, f, 1); l = e; return; } function Vn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Wn() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Xn(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Yn(g, e) | 0, e); l = f; return; } function Wn() { var b = 0, d = 0; if (!(a[7752] | 0)) { eo(9720); Ha(38, 9720, o | 0) | 0; d = 7752; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9720) | 0)) { b = 9720; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); eo(9720); } return 9720; } function Xn(a) { a = a | 0; return 0; } function Yn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Wn() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Zn(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { _n(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Zn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function _n(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = $n(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; ao( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Zn(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; bo(a, i); co(i); l = k; return; } } function $n(a) { a = a | 0; return 357913941; } function ao(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function bo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function co(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function eo(a) { a = a | 0; ho(a); return; } function fo(a) { a = a | 0; go((a + 24) | 0); return; } function go(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function ho(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, io() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function io() { return 1288; } function jo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = ko(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; b = lo(b, e) | 0; l = d; return b | 0; } function ko(a) { a = a | 0; return ((c[((Wn() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function lo(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; return bh(pb[d & 31](a) | 0) | 0; } function mo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; no(a, d, f, 0); l = e; return; } function no(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = oo() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = po(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, qo(g, e) | 0, e); l = f; return; } function oo() { var b = 0, d = 0; if (!(a[7760] | 0)) { xo(9756); Ha(39, 9756, o | 0) | 0; d = 7760; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9756) | 0)) { b = 9756; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); xo(9756); } return 9756; } function po(a) { a = a | 0; return 0; } function qo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = oo() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; ro(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { so(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function ro(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function so(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = to(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; uo( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; ro(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; vo(a, i); wo(i); l = k; return; } } function to(a) { a = a | 0; return 357913941; } function uo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function vo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function wo(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function xo(a) { a = a | 0; Ao(a); return; } function yo(a) { a = a | 0; zo((a + 24) | 0); return; } function zo(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Ao(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, Bo() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Bo() { return 1292; } function Co(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Do(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Eo(b, f, d); l = e; return; } function Do(a) { a = a | 0; return ((c[((oo() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Eo(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; rj(f, d); d = +sj(f, d); lb[e & 31](a, d); l = g; return; } function Fo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Go(a, d, f, 0); l = e; return; } function Go(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Ho() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Io(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Jo(g, e) | 0, e); l = f; return; } function Ho() { var b = 0, d = 0; if (!(a[7768] | 0)) { Qo(9792); Ha(40, 9792, o | 0) | 0; d = 7768; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9792) | 0)) { b = 9792; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Qo(9792); } return 9792; } function Io(a) { a = a | 0; return 0; } function Jo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Ho() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Ko(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Lo(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Ko(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Lo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Mo(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; No( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Ko(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Oo(a, i); Po(i); l = k; return; } } function Mo(a) { a = a | 0; return 357913941; } function No(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Oo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Po(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Qo(a) { a = a | 0; To(a); return; } function Ro(a) { a = a | 0; So((a + 24) | 0); return; } function So(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function To(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, Uo() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Uo() { return 1300; } function Vo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = +e; var f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; g = (f + 8) | 0; h = f; i = Wo(a) | 0; a = c[(i + 4) >> 2] | 0; c[h >> 2] = c[i >> 2]; c[(h + 4) >> 2] = a; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = c[(h + 4) >> 2]; Xo(b, g, d, e); l = f; return; } function Wo(a) { a = a | 0; return ((c[((Ho() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Xo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = +e; var f = 0, g = 0, h = 0, i = 0; i = l; l = (l + 16) | 0; g = (i + 1) | 0; h = i; f = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) f = c[((c[a >> 2] | 0) + f) >> 2] | 0; tj(g, d); g = uj(g, d) | 0; rj(h, e); e = +sj(h, e); Gb[f & 15](a, g, e); l = i; return; } function Yo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Zo(a, d, f, 0); l = e; return; } function Zo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = _o() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = $o(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, ap(g, e) | 0, e); l = f; return; } function _o() { var b = 0, d = 0; if (!(a[7776] | 0)) { hp(9828); Ha(41, 9828, o | 0) | 0; d = 7776; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9828) | 0)) { b = 9828; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); hp(9828); } return 9828; } function $o(a) { a = a | 0; return 0; } function ap(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = _o() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; bp(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { cp(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function bp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function cp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = dp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; ep( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; bp(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; fp(a, i); gp(i); l = k; return; } } function dp(a) { a = a | 0; return 357913941; } function ep(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function fp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function gp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function hp(a) { a = a | 0; kp(a); return; } function ip(a) { a = a | 0; jp((a + 24) | 0); return; } function jp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function kp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 7, b, lp() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function lp() { return 1312; } function mp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = np(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; op(b, f, d); l = e; return; } function np(a) { a = a | 0; return ((c[((_o() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function op(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; tj(f, d); f = uj(f, d) | 0; ob[e & 31](a, f); l = g; return; } function pp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; qp(a, d, f, 0); l = e; return; } function qp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = rp() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = sp(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, tp(g, e) | 0, e); l = f; return; } function rp() { var b = 0, d = 0; if (!(a[7784] | 0)) { Ap(9864); Ha(42, 9864, o | 0) | 0; d = 7784; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9864) | 0)) { b = 9864; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Ap(9864); } return 9864; } function sp(a) { a = a | 0; return 0; } function tp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = rp() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; up(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { vp(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function up(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function vp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = wp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; xp( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; up(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; yp(a, i); zp(i); l = k; return; } } function wp(a) { a = a | 0; return 357913941; } function xp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function yp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function zp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Ap(a) { a = a | 0; Dp(a); return; } function Bp(a) { a = a | 0; Cp((a + 24) | 0); return; } function Cp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Dp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, Ep() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Ep() { return 1320; } function Fp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Gp(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Hp(b, f, d); l = e; return; } function Gp(a) { a = a | 0; return ((c[((rp() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Hp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; Ip(f, d); f = Jp(f, d) | 0; ob[e & 31](a, f); l = g; return; } function Ip(a, b) { a = a | 0; b = b | 0; return; } function Jp(a, b) { a = a | 0; b = b | 0; return Kp(b) | 0; } function Kp(a) { a = a | 0; return a | 0; } function Lp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Mp(a, d, f, 0); l = e; return; } function Mp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Np() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Op(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Pp(g, e) | 0, e); l = f; return; } function Np() { var b = 0, d = 0; if (!(a[7792] | 0)) { Wp(9900); Ha(43, 9900, o | 0) | 0; d = 7792; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9900) | 0)) { b = 9900; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Wp(9900); } return 9900; } function Op(a) { a = a | 0; return 0; } function Pp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Np() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Qp(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Rp(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Qp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Rp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Sp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Tp( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Qp(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Up(a, i); Vp(i); l = k; return; } } function Sp(a) { a = a | 0; return 357913941; } function Tp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Up(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Vp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Wp(a) { a = a | 0; Zp(a); return; } function Xp(a) { a = a | 0; Yp((a + 24) | 0); return; } function Yp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Zp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 22, b, _p() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function _p() { return 1344; } function $p(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = (l + 16) | 0; e = (d + 8) | 0; f = d; g = aq(a) | 0; a = c[(g + 4) >> 2] | 0; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = a; c[e >> 2] = c[f >> 2]; c[(e + 4) >> 2] = c[(f + 4) >> 2]; bq(b, e); l = d; return; } function aq(a) { a = a | 0; return ((c[((Np() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function bq(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) d = c[((c[a >> 2] | 0) + d) >> 2] | 0; nb[d & 127](a); return; } function cq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = dq() | 0; a = eq(d) | 0; fi(g, b, f, a, fq(d, e) | 0, e); return; } function dq() { var b = 0, d = 0; if (!(a[7800] | 0)) { mq(9936); Ha(44, 9936, o | 0) | 0; d = 7800; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9936) | 0)) { b = 9936; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); mq(9936); } return 9936; } function eq(a) { a = a | 0; return a | 0; } function fq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = dq() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { gq(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { hq(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function gq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function hq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = iq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; jq( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; gq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; kq(a, f); lq(f); l = i; return; } } function iq(a) { a = a | 0; return 536870911; } function jq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function kq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function lq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function mq(a) { a = a | 0; pq(a); return; } function nq(a) { a = a | 0; oq((a + 24) | 0); return; } function oq(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function pq(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 23, b, Kl() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function qq(a, b) { a = a | 0; b = b | 0; sq(c[(rq(a) | 0) >> 2] | 0, b); return; } function rq(a) { a = a | 0; return ((c[((dq() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function sq(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = (l + 16) | 0; d = c; Ol(d, b); b = Pl(d, b) | 0; nb[a & 127](b); l = c; return; } function tq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = uq() | 0; a = vq(d) | 0; fi(g, b, f, a, wq(d, e) | 0, e); return; } function uq() { var b = 0, d = 0; if (!(a[7808] | 0)) { Dq(9972); Ha(45, 9972, o | 0) | 0; d = 7808; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(9972) | 0)) { b = 9972; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Dq(9972); } return 9972; } function vq(a) { a = a | 0; return a | 0; } function wq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = uq() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { xq(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { yq(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function xq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function yq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = zq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Aq( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; xq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Bq(a, f); Cq(f); l = i; return; } } function zq(a) { a = a | 0; return 536870911; } function Aq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Bq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Cq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Dq(a) { a = a | 0; Gq(a); return; } function Eq(a) { a = a | 0; Fq((a + 24) | 0); return; } function Fq(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Gq(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 9, b, Hq() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Hq() { return 1348; } function Iq(a, b) { a = a | 0; b = b | 0; return Kq(c[(Jq(a) | 0) >> 2] | 0, b) | 0; } function Jq(a) { a = a | 0; return ((c[((uq() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function Kq(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = (l + 16) | 0; d = c; Lq(d, b); b = Mq(d, b) | 0; b = Ik(pb[a & 31](b) | 0) | 0; l = c; return b | 0; } function Lq(a, b) { a = a | 0; b = b | 0; return; } function Mq(a, b) { a = a | 0; b = b | 0; return Nq(b) | 0; } function Nq(a) { a = a | 0; return a | 0; } function Oq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Pq() | 0; a = Qq(d) | 0; fi(g, b, f, a, Rq(d, e) | 0, e); return; } function Pq() { var b = 0, d = 0; if (!(a[7816] | 0)) { Yq(10008); Ha(46, 10008, o | 0) | 0; d = 7816; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10008) | 0)) { b = 10008; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Yq(10008); } return 10008; } function Qq(a) { a = a | 0; return a | 0; } function Rq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Pq() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { Sq(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { Tq(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function Sq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function Tq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = Uq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Vq( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; Sq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Wq(a, f); Xq(f); l = i; return; } } function Uq(a) { a = a | 0; return 536870911; } function Vq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Wq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Xq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Yq(a) { a = a | 0; $q(a); return; } function Zq(a) { a = a | 0; _q((a + 24) | 0); return; } function _q(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function $q(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 15, b, Zk() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function ar(a) { a = a | 0; return cr(c[(br(a) | 0) >> 2] | 0) | 0; } function br(a) { a = a | 0; return ((c[((Pq() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function cr(a) { a = a | 0; return Ik(Ab[a & 7]() | 0) | 0; } function dr() { var b = 0; if (!(a[7832] | 0)) { nr(10052); Ha(25, 10052, o | 0) | 0; b = 7832; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10052; } function er(a, b) { a = a | 0; b = b | 0; c[a >> 2] = fr() | 0; c[(a + 4) >> 2] = gr() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = hr() | 0; c[(a + 32) >> 2] = 2; return; } function fr() { return 11709; } function gr() { return 1188; } function hr() { return lr() | 0; } function ir(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { kr(c); sC(c); } } else if (b | 0) { uf(b); sC(b); } return; } function jr(a, b) { a = a | 0; b = b | 0; return (b & a) | 0; } function kr(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function lr() { var b = 0; if (!(a[7824] | 0)) { c[2511] = mr() | 0; c[2512] = 0; b = 7824; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10044; } function mr() { return 0; } function nr(a) { a = a | 0; Zi(a); return; } function or(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0; b = l; l = (l + 32) | 0; d = (b + 24) | 0; g = (b + 16) | 0; f = (b + 8) | 0; e = b; pr(a, 4827); qr(a, 4834, 3) | 0; rr(a, 3682, 47) | 0; c[g >> 2] = 9; c[(g + 4) >> 2] = 0; c[d >> 2] = c[g >> 2]; c[(d + 4) >> 2] = c[(g + 4) >> 2]; sr(a, 4841, d) | 0; c[f >> 2] = 1; c[(f + 4) >> 2] = 0; c[d >> 2] = c[f >> 2]; c[(d + 4) >> 2] = c[(f + 4) >> 2]; tr(a, 4871, d) | 0; c[e >> 2] = 10; c[(e + 4) >> 2] = 0; c[d >> 2] = c[e >> 2]; c[(d + 4) >> 2] = c[(e + 4) >> 2]; ur(a, 4891, d) | 0; l = b; return; } function pr(a, b) { a = a | 0; b = b | 0; var d = 0; d = nt() | 0; c[a >> 2] = d; ot(d, b); Hv(c[a >> 2] | 0); return; } function qr(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Ws(a, ai(b) | 0, c, 0); return a | 0; } function rr(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Es(a, ai(b) | 0, c, 0); return a | 0; } function sr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; is(a, b, f); l = e; return a | 0; } function tr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Or(a, b, f); l = e; return a | 0; } function ur(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = c[(d + 4) >> 2] | 0; c[g >> 2] = c[d >> 2]; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; vr(a, b, f); l = e; return a | 0; } function vr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; wr(a, d, f, 1); l = e; return; } function wr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = xr() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = yr(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, zr(g, e) | 0, e); l = f; return; } function xr() { var b = 0, d = 0; if (!(a[7840] | 0)) { Gr(10100); Ha(48, 10100, o | 0) | 0; d = 7840; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10100) | 0)) { b = 10100; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Gr(10100); } return 10100; } function yr(a) { a = a | 0; return 0; } function zr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = xr() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Ar(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Br(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Ar(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Br(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Cr(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Dr( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Ar(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Er(a, i); Fr(i); l = k; return; } } function Cr(a) { a = a | 0; return 357913941; } function Dr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Er(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Fr(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Gr(a) { a = a | 0; Jr(a); return; } function Hr(a) { a = a | 0; Ir((a + 24) | 0); return; } function Ir(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function Jr(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, Kr() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Kr() { return 1364; } function Lr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = Mr(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; d = Nr(b, f, d) | 0; l = e; return d | 0; } function Mr(a) { a = a | 0; return ((c[((xr() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function Nr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; tj(f, d); f = uj(f, d) | 0; f = Qj(wb[e & 15](a, f) | 0) | 0; l = g; return f | 0; } function Or(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; Pr(a, d, f, 0); l = e; return; } function Pr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = Qr() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = Rr(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, Sr(g, e) | 0, e); l = f; return; } function Qr() { var b = 0, d = 0; if (!(a[7848] | 0)) { Zr(10136); Ha(49, 10136, o | 0) | 0; d = 7848; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10136) | 0)) { b = 10136; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Zr(10136); } return 10136; } function Rr(a) { a = a | 0; return 0; } function Sr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = Qr() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; Tr(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { Ur(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function Tr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function Ur(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = Vr(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; Wr( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; Tr(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Xr(a, i); Yr(i); l = k; return; } } function Vr(a) { a = a | 0; return 357913941; } function Wr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function Xr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Yr(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Zr(a) { a = a | 0; as(a); return; } function _r(a) { a = a | 0; $r((a + 24) | 0); return; } function $r(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function as(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 9, b, bs() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function bs() { return 1372; } function cs(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; h = ds(a) | 0; a = c[(h + 4) >> 2] | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = a; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; es(b, f, d); l = e; return; } function ds(a) { a = a | 0; return ((c[((Qr() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function es(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = ib; g = l; l = (l + 16) | 0; f = g; e = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) e = c[((c[a >> 2] | 0) + e) >> 2] | 0; fs(f, d); h = T(gs(f, d)); kb[e & 1](a, h); l = g; return; } function fs(a, b) { a = a | 0; b = +b; return; } function gs(a, b) { a = a | 0; b = +b; return T(hs(b)); } function hs(a) { a = +a; return T(a); } function is(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 16) | 0; f = (e + 8) | 0; g = e; i = c[d >> 2] | 0; h = c[(d + 4) >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[(g + 4) >> 2] = h; c[f >> 2] = c[g >> 2]; c[(f + 4) >> 2] = c[(g + 4) >> 2]; js(a, d, f, 0); l = e; return; } function js(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = (l + 32) | 0; g = (f + 16) | 0; m = (f + 8) | 0; i = f; k = c[d >> 2] | 0; j = c[(d + 4) >> 2] | 0; h = c[a >> 2] | 0; a = ks() | 0; c[m >> 2] = k; c[(m + 4) >> 2] = j; c[g >> 2] = c[m >> 2]; c[(g + 4) >> 2] = c[(m + 4) >> 2]; d = ls(g) | 0; c[i >> 2] = k; c[(i + 4) >> 2] = j; c[g >> 2] = c[i >> 2]; c[(g + 4) >> 2] = c[(i + 4) >> 2]; fi(h, b, a, d, ms(g, e) | 0, e); l = f; return; } function ks() { var b = 0, d = 0; if (!(a[7856] | 0)) { ts(10172); Ha(50, 10172, o | 0) | 0; d = 7856; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10172) | 0)) { b = 10172; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); ts(10172); } return 10172; } function ls(a) { a = a | 0; return 0; } function ms(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = (l + 32) | 0; f = (m + 24) | 0; h = (m + 16) | 0; i = m; j = (m + 8) | 0; g = c[a >> 2] | 0; e = c[(a + 4) >> 2] | 0; c[i >> 2] = g; c[(i + 4) >> 2] = e; n = ks() | 0; k = (n + 24) | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = (n + 28) | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[(n + 32) >> 2] | 0) >>> 0) { c[h >> 2] = g; c[(h + 4) >> 2] = e; c[f >> 2] = c[h >> 2]; c[(f + 4) >> 2] = c[(h + 4) >> 2]; ns(d, f, a); a = ((c[b >> 2] | 0) + 12) | 0; c[b >> 2] = a; } else { os(k, i, j); a = c[b >> 2] | 0; } l = m; return (((((a - (c[k >> 2] | 0)) | 0) / 12) | 0) + -1) | 0; } function ns(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[(b + 4) >> 2] | 0; c[a >> 2] = c[b >> 2]; c[(a + 4) >> 2] = e; c[(a + 8) >> 2] = d; return; } function os(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = (l + 48) | 0; e = (k + 32) | 0; h = (k + 24) | 0; i = k; j = (a + 4) | 0; f = ((((((c[j >> 2] | 0) - (c[a >> 2] | 0)) | 0) / 12) | 0) + 1) | 0; g = ps(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((((c[(a + 8) >> 2] | 0) - m) | 0) / 12) | 0; n = o << 1; qs( i, o >>> 0 < (g >>> 1) >>> 0 ? (n >>> 0 < f >>> 0 ? f : n) : g, ((((c[j >> 2] | 0) - m) | 0) / 12) | 0, (a + 8) | 0 ); j = (i + 8) | 0; g = c[j >> 2] | 0; f = c[(b + 4) >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[(h + 4) >> 2] = f; c[e >> 2] = c[h >> 2]; c[(e + 4) >> 2] = c[(h + 4) >> 2]; ns(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; rs(a, i); ss(i); l = k; return; } } function ps(a) { a = a | 0; return 357913941; } function qs(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC((b * 12) | 0) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + ((d * 12) | 0)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + ((b * 12) | 0); return; } function rs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + (((((f | 0) / -12) | 0) * 12) | 0)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ss(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + ((~(((((e + -12 - b) | 0) >>> 0) / 12) | 0) * 12) | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ts(a) { a = a | 0; ws(a); return; } function us(a) { a = a | 0; vs((a + 24) | 0); return; } function vs(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + ((~(((((b + -12 - e) | 0) >>> 0) / 12) | 0) * 12) | 0); sC(d); } return; } function ws(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 3, b, xs() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function xs() { return 1380; } function ys(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; g = (f + 8) | 0; h = f; i = zs(a) | 0; a = c[(i + 4) >> 2] | 0; c[h >> 2] = c[i >> 2]; c[(h + 4) >> 2] = a; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = c[(h + 4) >> 2]; As(b, g, d, e); l = f; return; } function zs(a) { a = a | 0; return ((c[((ks() | 0) + 24) >> 2] | 0) + ((a * 12) | 0)) | 0; } function As(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; i = l; l = (l + 16) | 0; g = (i + 1) | 0; h = i; f = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; a = (a + (b >> 1)) | 0; if (b & 1) f = c[((c[a >> 2] | 0) + f) >> 2] | 0; tj(g, d); g = uj(g, d) | 0; Bs(h, e); h = Cs(h, e) | 0; Eb[f & 15](a, g, h); l = i; return; } function Bs(a, b) { a = a | 0; b = b | 0; return; } function Cs(a, b) { a = a | 0; b = b | 0; return Ds(b) | 0; } function Ds(a) { a = a | 0; return ((a | 0) != 0) | 0; } function Es(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Fs() | 0; a = Gs(d) | 0; fi(g, b, f, a, Hs(d, e) | 0, e); return; } function Fs() { var b = 0, d = 0; if (!(a[7864] | 0)) { Os(10208); Ha(51, 10208, o | 0) | 0; d = 7864; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10208) | 0)) { b = 10208; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Os(10208); } return 10208; } function Gs(a) { a = a | 0; return a | 0; } function Hs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Fs() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { Is(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { Js(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function Is(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function Js(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = Ks(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Ls( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; Is(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Ms(a, f); Ns(f); l = i; return; } } function Ks(a) { a = a | 0; return 536870911; } function Ls(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Ms(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Ns(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Os(a) { a = a | 0; Rs(a); return; } function Ps(a) { a = a | 0; Qs((a + 24) | 0); return; } function Qs(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Rs(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 24, b, Ss() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Ss() { return 1392; } function Ts(a, b) { a = a | 0; b = b | 0; Vs(c[(Us(a) | 0) >> 2] | 0, b); return; } function Us(a) { a = a | 0; return ((c[((Fs() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function Vs(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = (l + 16) | 0; d = c; Lq(d, b); b = Mq(d, b) | 0; nb[a & 127](b); l = c; return; } function Ws(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Xs() | 0; a = Ys(d) | 0; fi(g, b, f, a, Zs(d, e) | 0, e); return; } function Xs() { var b = 0, d = 0; if (!(a[7872] | 0)) { et(10244); Ha(52, 10244, o | 0) | 0; d = 7872; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10244) | 0)) { b = 10244; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); et(10244); } return 10244; } function Ys(a) { a = a | 0; return a | 0; } function Zs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Xs() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { _s(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { $s(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function _s(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function $s(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = at(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; bt( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; _s(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; ct(a, f); dt(f); l = i; return; } } function at(a) { a = a | 0; return 536870911; } function bt(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function ct(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function dt(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function et(a) { a = a | 0; ht(a); return; } function ft(a) { a = a | 0; gt((a + 24) | 0); return; } function gt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function ht(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 16, b, it() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function it() { return 1400; } function jt(a) { a = a | 0; return lt(c[(kt(a) | 0) >> 2] | 0) | 0; } function kt(a) { a = a | 0; return ((c[((Xs() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function lt(a) { a = a | 0; return mt(Ab[a & 7]() | 0) | 0; } function mt(a) { a = a | 0; return a | 0; } function nt() { var b = 0; if (!(a[7880] | 0)) { ut(10280); Ha(25, 10280, o | 0) | 0; b = 7880; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10280; } function ot(a, b) { a = a | 0; b = b | 0; c[a >> 2] = pt() | 0; c[(a + 4) >> 2] = qt() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = rt() | 0; c[(a + 32) >> 2] = 4; return; } function pt() { return 11711; } function qt() { return 1356; } function rt() { return lr() | 0; } function st(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { tt(c); sC(c); } } else if (b | 0) { mf(b); sC(b); } return; } function tt(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function ut(a) { a = a | 0; Zi(a); return; } function vt(a) { a = a | 0; wt(a, 4920); xt(a) | 0; yt(a) | 0; return; } function wt(a, b) { a = a | 0; b = b | 0; var d = 0; d = nn() | 0; c[a >> 2] = d; Yt(d, b); Hv(c[a >> 2] | 0); return; } function xt(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Mt() | 0); return a | 0; } function yt(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, zt() | 0); return a | 0; } function zt() { var b = 0; if (!(a[7888] | 0)) { Bt(10328); Ha(53, 10328, o | 0) | 0; b = 7888; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10328) | 0)) Bt(10328); return 10328; } function At(a, b) { a = a | 0; b = b | 0; fi(a, 0, b, 0, 0, 0); return; } function Bt(a) { a = a | 0; Et(a); Gt(a, 10); return; } function Ct(a) { a = a | 0; Dt((a + 24) | 0); return; } function Dt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Et(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 1, b, Jt() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Ft(a, b, c) { a = a | 0; b = b | 0; c = +c; Ht(a, b, c); return; } function Gt(a, b) { a = a | 0; b = b | 0; c[(a + 20) >> 2] = b; return; } function Ht(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, i = 0, j = 0; e = l; l = (l + 16) | 0; g = (e + 8) | 0; j = (e + 13) | 0; f = e; i = (e + 12) | 0; tj(j, b); c[g >> 2] = uj(j, b) | 0; rj(i, d); h[f >> 3] = +sj(i, d); It(a, g, f); l = e; return; } function It(b, d, e) { b = b | 0; d = d | 0; e = e | 0; mg((b + 8) | 0, c[d >> 2] | 0, +h[e >> 3]); a[(b + 24) >> 0] = 1; return; } function Jt() { return 1404; } function Kt(a, b) { a = a | 0; b = +b; return Lt(a, b) | 0; } function Lt(a, b) { a = a | 0; b = +b; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = (l + 16) | 0; g = (e + 4) | 0; h = (e + 8) | 0; i = e; f = jy(8) | 0; d = f; j = qC(16) | 0; tj(g, a); a = uj(g, a) | 0; rj(h, b); mg(j, a, +sj(h, b)); h = (d + 4) | 0; c[h >> 2] = j; a = qC(8) | 0; h = c[h >> 2] | 0; c[i >> 2] = 0; c[g >> 2] = c[i >> 2]; qn(a, h, g); c[f >> 2] = a; l = e; return d | 0; } function Mt() { var b = 0; if (!(a[7896] | 0)) { Nt(10364); Ha(54, 10364, o | 0) | 0; b = 7896; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10364) | 0)) Nt(10364); return 10364; } function Nt(a) { a = a | 0; Qt(a); Gt(a, 55); return; } function Ot(a) { a = a | 0; Pt((a + 24) | 0); return; } function Pt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Qt(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 4, b, Vt() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Rt(a) { a = a | 0; St(a); return; } function St(a) { a = a | 0; Tt(a); return; } function Tt(b) { b = b | 0; Ut((b + 8) | 0); a[(b + 24) >> 0] = 1; return; } function Ut(a) { a = a | 0; c[a >> 2] = 0; h[(a + 8) >> 3] = 0.0; return; } function Vt() { return 1424; } function Wt() { return Xt() | 0; } function Xt() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = (l + 16) | 0; f = (b + 4) | 0; h = b; d = jy(8) | 0; a = d; e = qC(16) | 0; Ut(e); g = (a + 4) | 0; c[g >> 2] = e; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; qn(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function Yt(a, b) { a = a | 0; b = b | 0; c[a >> 2] = Zt() | 0; c[(a + 4) >> 2] = _t() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = $t() | 0; c[(a + 32) >> 2] = 5; return; } function Zt() { return 11710; } function _t() { return 1416; } function $t() { return cu() | 0; } function au(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { bu(c); sC(c); } } else if (b | 0) sC(b); return; } function bu(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function cu() { var b = 0; if (!(a[7904] | 0)) { c[2600] = du() | 0; c[2601] = 0; b = 7904; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10400; } function du() { return c[357] | 0; } function eu(a) { a = a | 0; fu(a, 4926); gu(a) | 0; return; } function fu(a, b) { a = a | 0; b = b | 0; var d = 0; d = Ci() | 0; c[a >> 2] = d; su(d, b); Hv(c[a >> 2] | 0); return; } function gu(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, hu() | 0); return a | 0; } function hu() { var b = 0; if (!(a[7912] | 0)) { iu(10412); Ha(56, 10412, o | 0) | 0; b = 7912; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10412) | 0)) iu(10412); return 10412; } function iu(a) { a = a | 0; lu(a); Gt(a, 57); return; } function ju(a) { a = a | 0; ku((a + 24) | 0); return; } function ku(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function lu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 5, b, pu() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function mu(a) { a = a | 0; nu(a); return; } function nu(a) { a = a | 0; ou(a); return; } function ou(b) { b = b | 0; var d = 0, e = 0; d = (b + 8) | 0; e = (d + 48) | 0; do { c[d >> 2] = 0; d = (d + 4) | 0; } while ((d | 0) < (e | 0)); a[(b + 56) >> 0] = 1; return; } function pu() { return 1432; } function qu() { return ru() | 0; } function ru() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; h = l; l = (l + 16) | 0; a = (h + 4) | 0; b = h; d = jy(8) | 0; e = d; f = qC(48) | 0; g = f; i = (g + 48) | 0; do { c[g >> 2] = 0; g = (g + 4) | 0; } while ((g | 0) < (i | 0)); g = (e + 4) | 0; c[g >> 2] = f; i = qC(8) | 0; g = c[g >> 2] | 0; c[b >> 2] = 0; c[a >> 2] = c[b >> 2]; Ji(i, g, a); c[d >> 2] = i; l = h; return e | 0; } function su(a, b) { a = a | 0; b = b | 0; c[a >> 2] = tu() | 0; c[(a + 4) >> 2] = uu() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = vu() | 0; c[(a + 32) >> 2] = 6; return; } function tu() { return 11704; } function uu() { return 1436; } function vu() { return cu() | 0; } function wu(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { xu(c); sC(c); } } else if (b | 0) sC(b); return; } function xu(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function yu(a) { a = a | 0; zu(a, 4933); Au(a) | 0; Bu(a) | 0; return; } function zu(a, b) { a = a | 0; b = b | 0; var d = 0; d = cv() | 0; c[a >> 2] = d; dv(d, b); Hv(c[a >> 2] | 0); return; } function Au(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Su() | 0); return a | 0; } function Bu(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Cu() | 0); return a | 0; } function Cu() { var b = 0; if (!(a[7920] | 0)) { Du(10452); Ha(58, 10452, o | 0) | 0; b = 7920; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10452) | 0)) Du(10452); return 10452; } function Du(a) { a = a | 0; Gu(a); Gt(a, 1); return; } function Eu(a) { a = a | 0; Fu((a + 24) | 0); return; } function Fu(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Gu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 1, b, Lu() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Hu(a, b, c) { a = a | 0; b = +b; c = +c; Iu(a, b, c); return; } function Iu(a, b, c) { a = a | 0; b = +b; c = +c; var d = 0, e = 0, f = 0, g = 0, i = 0; d = l; l = (l + 32) | 0; f = (d + 8) | 0; i = (d + 17) | 0; e = d; g = (d + 16) | 0; rj(i, b); h[f >> 3] = +sj(i, b); rj(g, c); h[e >> 3] = +sj(g, c); Ju(a, f, e); l = d; return; } function Ju(b, c, d) { b = b | 0; c = c | 0; d = d | 0; Ku((b + 8) | 0, +h[c >> 3], +h[d >> 3]); a[(b + 24) >> 0] = 1; return; } function Ku(a, b, c) { a = a | 0; b = +b; c = +c; h[a >> 3] = b; h[(a + 8) >> 3] = c; return; } function Lu() { return 1472; } function Mu(a, b) { a = +a; b = +b; return Nu(a, b) | 0; } function Nu(a, b) { a = +a; b = +b; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = (l + 16) | 0; h = (e + 4) | 0; i = (e + 8) | 0; j = e; f = jy(8) | 0; d = f; g = qC(16) | 0; rj(h, a); a = +sj(h, a); rj(i, b); Ku(g, a, +sj(i, b)); i = (d + 4) | 0; c[i >> 2] = g; g = qC(8) | 0; i = c[i >> 2] | 0; c[j >> 2] = 0; c[h >> 2] = c[j >> 2]; Ou(g, i, h); c[f >> 2] = g; l = e; return d | 0; } function Ou(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[(d + 4) >> 2] = 0; c[(d + 8) >> 2] = 0; c[d >> 2] = 1452; c[(d + 12) >> 2] = b; c[(a + 4) >> 2] = d; return; } function Pu(a) { a = a | 0; kC(a); sC(a); return; } function Qu(a) { a = a | 0; a = c[(a + 12) >> 2] | 0; if (a | 0) sC(a); return; } function Ru(a) { a = a | 0; sC(a); return; } function Su() { var b = 0; if (!(a[7928] | 0)) { Tu(10488); Ha(59, 10488, o | 0) | 0; b = 7928; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10488) | 0)) Tu(10488); return 10488; } function Tu(a) { a = a | 0; Wu(a); Gt(a, 60); return; } function Uu(a) { a = a | 0; Vu((a + 24) | 0); return; } function Vu(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Wu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 6, b, $u() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Xu(a) { a = a | 0; Yu(a); return; } function Yu(a) { a = a | 0; Zu(a); return; } function Zu(b) { b = b | 0; _u((b + 8) | 0); a[(b + 24) >> 0] = 1; return; } function _u(a) { a = a | 0; c[a >> 2] = 0; c[(a + 4) >> 2] = 0; c[(a + 8) >> 2] = 0; c[(a + 12) >> 2] = 0; return; } function $u() { return 1492; } function av() { return bv() | 0; } function bv() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = (l + 16) | 0; f = (b + 4) | 0; h = b; d = jy(8) | 0; a = d; e = qC(16) | 0; _u(e); g = (a + 4) | 0; c[g >> 2] = e; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Ou(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function cv() { var b = 0; if (!(a[7936] | 0)) { jv(10524); Ha(25, 10524, o | 0) | 0; b = 7936; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10524; } function dv(a, b) { a = a | 0; b = b | 0; c[a >> 2] = ev() | 0; c[(a + 4) >> 2] = fv() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = gv() | 0; c[(a + 32) >> 2] = 7; return; } function ev() { return 11700; } function fv() { return 1484; } function gv() { return cu() | 0; } function hv(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { iv(c); sC(c); } } else if (b | 0) sC(b); return; } function iv(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function jv(a) { a = a | 0; Zi(a); return; } function kv(a, b, c) { a = a | 0; b = b | 0; c = c | 0; a = ai(b) | 0; b = lv(c) | 0; c = mv(c, 0) | 0; Zv(a, b, c, nv() | 0, 0); return; } function lv(a) { a = a | 0; return a | 0; } function mv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = nv() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { vv(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { wv(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function nv() { var b = 0, d = 0; if (!(a[7944] | 0)) { ov(10568); Ha(61, 10568, o | 0) | 0; d = 7944; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10568) | 0)) { b = 10568; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); ov(10568); } return 10568; } function ov(a) { a = a | 0; rv(a); return; } function pv(a) { a = a | 0; qv((a + 24) | 0); return; } function qv(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function rv(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 17, b, ql() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function sv(a) { a = a | 0; return uv(c[(tv(a) | 0) >> 2] | 0) | 0; } function tv(a) { a = a | 0; return ((c[((nv() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function uv(a) { a = a | 0; return ul(Ab[a & 7]() | 0) | 0; } function vv(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function wv(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = xv(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; yv( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; vv(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; zv(a, f); Av(f); l = i; return; } } function xv(a) { a = a | 0; return 536870911; } function yv(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function zv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Av(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Bv() { Cv(); return; } function Cv() { Dv(10604); return; } function Dv(a) { a = a | 0; Ev(a, 4955); return; } function Ev(a, b) { a = a | 0; b = b | 0; var d = 0; d = Fv() | 0; c[a >> 2] = d; Gv(d, b); Hv(c[a >> 2] | 0); return; } function Fv() { var b = 0; if (!(a[7952] | 0)) { Rv(10612); Ha(25, 10612, o | 0) | 0; b = 7952; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10612; } function Gv(a, b) { a = a | 0; b = b | 0; c[a >> 2] = Mv() | 0; c[(a + 4) >> 2] = Nv() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = Ov() | 0; c[(a + 32) >> 2] = 8; return; } function Hv(a) { a = a | 0; var b = 0, d = 0; b = l; l = (l + 16) | 0; d = b; Iv() | 0; c[d >> 2] = a; Jv(10608, d); l = b; return; } function Iv() { if (!(a[11714] | 0)) { c[2652] = 0; Ha(62, 10608, o | 0) | 0; a[11714] = 1; } return 10608; } function Jv(a, b) { a = a | 0; b = b | 0; var d = 0; d = qC(8) | 0; c[(d + 4) >> 2] = c[b >> 2]; c[d >> 2] = c[a >> 2]; c[a >> 2] = d; return; } function Kv(a) { a = a | 0; Lv(a); return; } function Lv(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); } while ((b | 0) != 0); c[a >> 2] = 0; return; } function Mv() { return 11715; } function Nv() { return 1496; } function Ov() { return lr() | 0; } function Pv(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { Qv(c); sC(c); } } else if (b | 0) sC(b); return; } function Qv(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function Rv(a) { a = a | 0; Zi(a); return; } function Sv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; Iv() | 0; d = c[2652] | 0; a: do if (d | 0) { while (1) { e = c[(d + 4) >> 2] | 0; if (e | 0 ? (AB(Tv(e) | 0, a) | 0) == 0 : 0) break; d = c[d >> 2] | 0; if (!d) break a; } Uv(e, b); } while (0); return; } function Tv(a) { a = a | 0; return c[(a + 12) >> 2] | 0; } function Uv(a, b) { a = a | 0; b = b | 0; var d = 0; a = (a + 36) | 0; d = c[a >> 2] | 0; if (d | 0) { vf(d); sC(d); } d = qC(4) | 0; Og(d, b); c[a >> 2] = d; return; } function Vv() { if (!(a[11716] | 0)) { c[2664] = 0; Ha(63, 10656, o | 0) | 0; a[11716] = 1; } return 10656; } function Wv() { var b = 0; if (!(a[11717] | 0)) { Xv(); c[2665] = 1504; a[11717] = 1; b = 1504; } else b = c[2665] | 0; return b | 0; } function Xv() { if (!(a[11740] | 0)) { a[11718] = ji(ji(8, 0) | 0, 0) | 0; a[11719] = ji(ji(0, 0) | 0, 0) | 0; a[11720] = ji(ji(0, 16) | 0, 0) | 0; a[11721] = ji(ji(8, 0) | 0, 0) | 0; a[11722] = ji(ji(0, 0) | 0, 0) | 0; a[11723] = ji(ji(8, 0) | 0, 0) | 0; a[11724] = ji(ji(0, 0) | 0, 0) | 0; a[11725] = ji(ji(8, 0) | 0, 0) | 0; a[11726] = ji(ji(0, 0) | 0, 0) | 0; a[11727] = ji(ji(8, 0) | 0, 0) | 0; a[11728] = ji(ji(0, 0) | 0, 0) | 0; a[11729] = ji(ji(0, 0) | 0, 32) | 0; a[11730] = ji(ji(0, 0) | 0, 32) | 0; a[11740] = 1; } return; } function Yv() { return 1572; } function Zv(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; g = l; l = (l + 32) | 0; m = (g + 16) | 0; k = (g + 12) | 0; j = (g + 8) | 0; i = (g + 4) | 0; h = g; c[m >> 2] = a; c[k >> 2] = b; c[j >> 2] = d; c[i >> 2] = e; c[h >> 2] = f; Vv() | 0; _v(10656, m, k, j, i, h); l = g; return; } function _v(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0; h = qC(24) | 0; ii( (h + 4) | 0, c[b >> 2] | 0, c[d >> 2] | 0, c[e >> 2] | 0, c[f >> 2] | 0, c[g >> 2] | 0 ); c[h >> 2] = c[a >> 2]; c[a >> 2] = h; return; } function $v(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0; u = l; l = (l + 32) | 0; q = (u + 20) | 0; r = (u + 8) | 0; s = (u + 4) | 0; t = u; b = c[b >> 2] | 0; if (b | 0) { p = (q + 4) | 0; j = (q + 8) | 0; k = (r + 4) | 0; m = (r + 8) | 0; n = (r + 8) | 0; o = (q + 8) | 0; do { h = (b + 4) | 0; i = aw(h) | 0; if (i | 0) { f = bw(i) | 0; c[q >> 2] = 0; c[p >> 2] = 0; c[j >> 2] = 0; e = ((cw(i) | 0) + 1) | 0; dw(q, e); if (e | 0) while (1) { e = (e + -1) | 0; OA(r, c[f >> 2] | 0); g = c[p >> 2] | 0; if (g >>> 0 < (c[o >> 2] | 0) >>> 0) { c[g >> 2] = c[r >> 2]; c[p >> 2] = (c[p >> 2] | 0) + 4; } else ew(q, r); if (!e) break; else f = (f + 4) | 0; } e = fw(i) | 0; c[r >> 2] = 0; c[k >> 2] = 0; c[m >> 2] = 0; a: do if (c[e >> 2] | 0) { f = 0; g = 0; while (1) { if ((f | 0) == (g | 0)) gw(r, e); else { c[f >> 2] = c[e >> 2]; c[k >> 2] = (c[k >> 2] | 0) + 4; } e = (e + 4) | 0; if (!(c[e >> 2] | 0)) break a; f = c[k >> 2] | 0; g = c[n >> 2] | 0; } } while (0); c[s >> 2] = hw(h) | 0; c[t >> 2] = si(i) | 0; iw(d, a, s, t, q, r); jw(r); kw(q); } b = c[b >> 2] | 0; } while ((b | 0) != 0); } l = u; return; } function aw(a) { a = a | 0; return c[(a + 12) >> 2] | 0; } function bw(a) { a = a | 0; return c[(a + 12) >> 2] | 0; } function cw(a) { a = a | 0; return c[(a + 16) >> 2] | 0; } function dw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 32) | 0; d = f; e = c[a >> 2] | 0; if ((((c[(a + 8) >> 2] | 0) - e) >> 2) >>> 0 < b >>> 0) { Rw(d, b, ((c[(a + 4) >> 2] | 0) - e) >> 2, (a + 8) | 0); Sw(a, d); Tw(d); } l = f; return; } function ew(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; h = l; l = (l + 32) | 0; d = h; e = (a + 4) | 0; f = ((((c[e >> 2] | 0) - (c[a >> 2] | 0)) >> 2) + 1) | 0; g = Nw(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { i = c[a >> 2] | 0; k = ((c[(a + 8) >> 2] | 0) - i) | 0; j = k >> 1; Rw( d, (k >> 2) >>> 0 < (g >>> 1) >>> 0 ? j >>> 0 < f >>> 0 ? f : j : g, ((c[e >> 2] | 0) - i) >> 2, (a + 8) | 0 ); g = (d + 8) | 0; c[c[g >> 2] >> 2] = c[b >> 2]; c[g >> 2] = (c[g >> 2] | 0) + 4; Sw(a, d); Tw(d); l = h; return; } } function fw(a) { a = a | 0; return c[(a + 8) >> 2] | 0; } function gw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; h = l; l = (l + 32) | 0; d = h; e = (a + 4) | 0; f = ((((c[e >> 2] | 0) - (c[a >> 2] | 0)) >> 2) + 1) | 0; g = Kw(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { i = c[a >> 2] | 0; k = ((c[(a + 8) >> 2] | 0) - i) | 0; j = k >> 1; Ow( d, (k >> 2) >>> 0 < (g >>> 1) >>> 0 ? j >>> 0 < f >>> 0 ? f : j : g, ((c[e >> 2] | 0) - i) >> 2, (a + 8) | 0 ); g = (d + 8) | 0; c[c[g >> 2] >> 2] = c[b >> 2]; c[g >> 2] = (c[g >> 2] | 0) + 4; Pw(a, d); Qw(d); l = h; return; } } function hw(a) { a = a | 0; return c[a >> 2] | 0; } function iw(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; lw(a, b, c, d, e, f); return; } function jw(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -4 - e) | 0) >>> 2) << 2); sC(d); } return; } function kw(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -4 - e) | 0) >>> 2) << 2); sC(d); } return; } function lw(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; h = l; l = (l + 48) | 0; m = (h + 40) | 0; i = (h + 32) | 0; n = (h + 24) | 0; j = (h + 12) | 0; k = h; UA(i); a = Sg(a) | 0; c[n >> 2] = c[b >> 2]; d = c[d >> 2] | 0; e = c[e >> 2] | 0; mw(j, f); nw(k, g); c[m >> 2] = c[n >> 2]; ow(a, m, d, e, j, k); jw(k); kw(j); WA(i); l = h; return; } function mw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[(a + 4) >> 2] = 0; c[(a + 8) >> 2] = 0; d = (b + 4) | 0; e = ((c[d >> 2] | 0) - (c[b >> 2] | 0)) >> 2; if (e | 0) { Lw(a, e); Mw(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function nw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[(a + 4) >> 2] = 0; c[(a + 8) >> 2] = 0; d = (b + 4) | 0; e = ((c[d >> 2] | 0) - (c[b >> 2] | 0)) >> 2; if (e | 0) { Iw(a, e); Jw(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function ow(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; h = l; l = (l + 32) | 0; m = (h + 28) | 0; n = (h + 24) | 0; i = (h + 12) | 0; j = h; k = Vg(pw() | 0) | 0; c[n >> 2] = c[b >> 2]; c[m >> 2] = c[n >> 2]; b = qw(m) | 0; d = rw(d) | 0; e = sw(e) | 0; c[i >> 2] = c[f >> 2]; m = (f + 4) | 0; c[(i + 4) >> 2] = c[m >> 2]; n = (f + 8) | 0; c[(i + 8) >> 2] = c[n >> 2]; c[n >> 2] = 0; c[m >> 2] = 0; c[f >> 2] = 0; f = tw(i) | 0; c[j >> 2] = c[g >> 2]; m = (g + 4) | 0; c[(j + 4) >> 2] = c[m >> 2]; n = (g + 8) | 0; c[(j + 8) >> 2] = c[n >> 2]; c[n >> 2] = 0; c[m >> 2] = 0; c[g >> 2] = 0; Ba(0, k | 0, a | 0, b | 0, d | 0, e | 0, f | 0, uw(j) | 0) | 0; jw(j); kw(i); l = h; return; } function pw() { var b = 0; if (!(a[7968] | 0)) { Gw(10708); b = 7968; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10708; } function qw(a) { a = a | 0; return yw(a) | 0; } function rw(a) { a = a | 0; return ww(a) | 0; } function sw(a) { a = a | 0; return ul(a) | 0; } function tw(a) { a = a | 0; return xw(a) | 0; } function uw(a) { a = a | 0; return vw(a) | 0; } function vw(a) { a = a | 0; var b = 0, d = 0, e = 0; e = ((c[(a + 4) >> 2] | 0) - (c[a >> 2] | 0)) | 0; d = e >> 2; e = jy((e + 4) | 0) | 0; c[e >> 2] = d; if (d | 0) { b = 0; do { c[(e + 4 + (b << 2)) >> 2] = ww(c[((c[a >> 2] | 0) + (b << 2)) >> 2] | 0) | 0; b = (b + 1) | 0; } while ((b | 0) != (d | 0)); } return e | 0; } function ww(a) { a = a | 0; return a | 0; } function xw(a) { a = a | 0; var b = 0, d = 0, e = 0; e = ((c[(a + 4) >> 2] | 0) - (c[a >> 2] | 0)) | 0; d = e >> 2; e = jy((e + 4) | 0) | 0; c[e >> 2] = d; if (d | 0) { b = 0; do { c[(e + 4 + (b << 2)) >> 2] = yw(((c[a >> 2] | 0) + (b << 2)) | 0) | 0; b = (b + 1) | 0; } while ((b | 0) != (d | 0)); } return e | 0; } function yw(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = (l + 32) | 0; b = (e + 12) | 0; c = e; d = Di(zw() | 0) | 0; if (!d) a = Aw(a) | 0; else { Ei(b, d); Fi(c, b); RA(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function zw() { var b = 0; if (!(a[7960] | 0)) { Fw(10664); Ha(25, 10664, o | 0) | 0; b = 7960; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10664; } function Aw(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = (l + 16) | 0; f = (d + 4) | 0; h = d; e = jy(8) | 0; b = e; i = qC(4) | 0; c[i >> 2] = c[a >> 2]; g = (b + 4) | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Bw(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function Bw(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[(d + 4) >> 2] = 0; c[(d + 8) >> 2] = 0; c[d >> 2] = 1656; c[(d + 12) >> 2] = b; c[(a + 4) >> 2] = d; return; } function Cw(a) { a = a | 0; kC(a); sC(a); return; } function Dw(a) { a = a | 0; a = c[(a + 12) >> 2] | 0; if (a | 0) sC(a); return; } function Ew(a) { a = a | 0; sC(a); return; } function Fw(a) { a = a | 0; Zi(a); return; } function Gw(a) { a = a | 0; fh(a, Hw() | 0, 5); return; } function Hw() { return 1676; } function Iw(a, b) { a = a | 0; b = b | 0; var d = 0; if ((Kw(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[(a + 4) >> 2] = d; c[a >> 2] = d; c[(a + 8) >> 2] = d + (b << 2); return; } } function Jw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = (a + 4) | 0; a = (d - b) | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0) | 0; c[e >> 2] = (c[e >> 2] | 0) + ((a >>> 2) << 2); } return; } function Kw(a) { a = a | 0; return 1073741823; } function Lw(a, b) { a = a | 0; b = b | 0; var d = 0; if ((Nw(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[(a + 4) >> 2] = d; c[a >> 2] = d; c[(a + 8) >> 2] = d + (b << 2); return; } } function Mw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = (a + 4) | 0; a = (d - b) | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0) | 0; c[e >> 2] = (c[e >> 2] | 0) + ((a >>> 2) << 2); } return; } function Nw(a) { a = a | 0; return 1073741823; } function Ow(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 2)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 2); return; } function Pw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 2)) << 2)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Qw(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -4 - b) | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Rw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 2)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 2); return; } function Sw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 2)) << 2)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Tw(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -4 - b) | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Uw(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0; r = l; l = (l + 32) | 0; m = (r + 20) | 0; n = (r + 12) | 0; k = (r + 16) | 0; o = (r + 4) | 0; p = r; q = (r + 8) | 0; i = Wv() | 0; g = c[i >> 2] | 0; h = c[g >> 2] | 0; if (h | 0) { j = c[(i + 8) >> 2] | 0; i = c[(i + 4) >> 2] | 0; while (1) { OA(m, h); Vw(a, m, i, j); g = (g + 4) | 0; h = c[g >> 2] | 0; if (!h) break; else { j = (j + 1) | 0; i = (i + 1) | 0; } } } g = Yv() | 0; h = c[g >> 2] | 0; if (h | 0) do { OA(m, h); c[n >> 2] = c[(g + 4) >> 2]; Ww(b, m, n); g = (g + 8) | 0; h = c[g >> 2] | 0; } while ((h | 0) != 0); g = c[(Iv() | 0) >> 2] | 0; if (g | 0) do { b = c[(g + 4) >> 2] | 0; OA(m, c[(Xw(b) | 0) >> 2] | 0); c[n >> 2] = Tv(b) | 0; Yw(d, m, n); g = c[g >> 2] | 0; } while ((g | 0) != 0); OA(k, 0); g = Vv() | 0; c[m >> 2] = c[k >> 2]; $v(m, g, f); g = c[(Iv() | 0) >> 2] | 0; if (g | 0) { a = (m + 4) | 0; b = (m + 8) | 0; d = (m + 8) | 0; do { j = c[(g + 4) >> 2] | 0; OA(n, c[(Xw(j) | 0) >> 2] | 0); _w(o, Zw(j) | 0); h = c[o >> 2] | 0; if (h | 0) { c[m >> 2] = 0; c[a >> 2] = 0; c[b >> 2] = 0; do { OA(p, c[(Xw(c[(h + 4) >> 2] | 0) | 0) >> 2] | 0); i = c[a >> 2] | 0; if (i >>> 0 < (c[d >> 2] | 0) >>> 0) { c[i >> 2] = c[p >> 2]; c[a >> 2] = (c[a >> 2] | 0) + 4; } else ew(m, p); h = c[h >> 2] | 0; } while ((h | 0) != 0); $w(e, n, m); kw(m); } c[q >> 2] = c[n >> 2]; k = ax(j) | 0; c[m >> 2] = c[q >> 2]; $v(m, k, f); Wi(o); g = c[g >> 2] | 0; } while ((g | 0) != 0); } l = r; return; } function Vw(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; ox(a, b, c, d); return; } function Ww(a, b, c) { a = a | 0; b = b | 0; c = c | 0; nx(a, b, c); return; } function Xw(a) { a = a | 0; return a | 0; } function Yw(a, b, c) { a = a | 0; b = b | 0; c = c | 0; ix(a, b, c); return; } function Zw(a) { a = a | 0; return (a + 16) | 0; } function _w(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; g = l; l = (l + 16) | 0; f = (g + 8) | 0; d = g; c[a >> 2] = 0; e = c[b >> 2] | 0; c[f >> 2] = e; c[d >> 2] = a; d = gx(d) | 0; if (e | 0) { e = qC(12) | 0; h = ((hx(f) | 0) + 4) | 0; a = c[(h + 4) >> 2] | 0; b = (e + 4) | 0; c[b >> 2] = c[h >> 2]; c[(b + 4) >> 2] = a; b = c[c[f >> 2] >> 2] | 0; c[f >> 2] = b; if (!b) a = e; else { b = e; while (1) { a = qC(12) | 0; j = ((hx(f) | 0) + 4) | 0; i = c[(j + 4) >> 2] | 0; h = (a + 4) | 0; c[h >> 2] = c[j >> 2]; c[(h + 4) >> 2] = i; c[b >> 2] = a; h = c[c[f >> 2] >> 2] | 0; c[f >> 2] = h; if (!h) break; else b = a; } } c[a >> 2] = c[d >> 2]; c[d >> 2] = e; } l = g; return; } function $w(a, b, c) { a = a | 0; b = b | 0; c = c | 0; bx(a, b, c); return; } function ax(a) { a = a | 0; return (a + 24) | 0; } function bx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 32) | 0; h = (e + 24) | 0; f = (e + 16) | 0; i = (e + 12) | 0; g = e; UA(f); a = Sg(a) | 0; c[i >> 2] = c[b >> 2]; mw(g, d); c[h >> 2] = c[i >> 2]; cx(a, h, g); kw(g); WA(f); l = e; return; } function cx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = (l + 32) | 0; h = (e + 16) | 0; i = (e + 12) | 0; f = e; g = Vg(dx() | 0) | 0; c[i >> 2] = c[b >> 2]; c[h >> 2] = c[i >> 2]; b = qw(h) | 0; c[f >> 2] = c[d >> 2]; h = (d + 4) | 0; c[(f + 4) >> 2] = c[h >> 2]; i = (d + 8) | 0; c[(f + 8) >> 2] = c[i >> 2]; c[i >> 2] = 0; c[h >> 2] = 0; c[d >> 2] = 0; xa(0, g | 0, a | 0, b | 0, tw(f) | 0) | 0; kw(f); l = e; return; } function dx() { var b = 0; if (!(a[7976] | 0)) { ex(10720); b = 7976; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10720; } function ex(a) { a = a | 0; fh(a, fx() | 0, 2); return; } function fx() { return 1732; } function gx(a) { a = a | 0; return c[a >> 2] | 0; } function hx(a) { a = a | 0; return c[a >> 2] | 0; } function ix(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 32) | 0; g = (e + 16) | 0; f = (e + 8) | 0; h = e; UA(f); a = Sg(a) | 0; c[h >> 2] = c[b >> 2]; d = c[d >> 2] | 0; c[g >> 2] = c[h >> 2]; jx(a, g, d); WA(f); l = e; return; } function jx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 16) | 0; g = (e + 4) | 0; h = e; f = Vg(kx() | 0) | 0; c[h >> 2] = c[b >> 2]; c[g >> 2] = c[h >> 2]; b = qw(g) | 0; xa(0, f | 0, a | 0, b | 0, rw(d) | 0) | 0; l = e; return; } function kx() { var b = 0; if (!(a[7984] | 0)) { lx(10732); b = 7984; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10732; } function lx(a) { a = a | 0; fh(a, mx() | 0, 2); return; } function mx() { return 1744; } function nx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = (l + 32) | 0; g = (e + 16) | 0; f = (e + 8) | 0; h = e; UA(f); a = Sg(a) | 0; c[h >> 2] = c[b >> 2]; d = c[d >> 2] | 0; c[g >> 2] = c[h >> 2]; jx(a, g, d); WA(f); l = e; return; } function ox(b, d, e, f) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = (l + 32) | 0; i = (g + 16) | 0; h = (g + 8) | 0; j = g; UA(h); b = Sg(b) | 0; c[j >> 2] = c[d >> 2]; e = a[e >> 0] | 0; f = a[f >> 0] | 0; c[i >> 2] = c[j >> 2]; px(b, i, e, f); WA(h); l = g; return; } function px(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; h = (f + 4) | 0; i = f; g = Vg(qx() | 0) | 0; c[i >> 2] = c[b >> 2]; c[h >> 2] = c[i >> 2]; b = qw(h) | 0; d = rx(d) | 0; $a(0, g | 0, a | 0, b | 0, d | 0, rx(e) | 0) | 0; l = f; return; } function qx() { var b = 0; if (!(a[7992] | 0)) { tx(10744); b = 7992; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10744; } function rx(a) { a = a | 0; return sx(a) | 0; } function sx(a) { a = a | 0; return (a & 255) | 0; } function tx(a) { a = a | 0; fh(a, ux() | 0, 3); return; } function ux() { return 1756; } function vx(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; p = l; l = (l + 32) | 0; j = (p + 8) | 0; k = (p + 4) | 0; m = (p + 20) | 0; n = p; mk(b, 0); f = QA(d) | 0; c[j >> 2] = 0; o = (j + 4) | 0; c[o >> 2] = 0; c[(j + 8) >> 2] = 0; switch ((f << 24) >> 24) { case 0: { a[m >> 0] = 0; wx(k, e, m); xx(b, k) | 0; wf(k); break; } case 8: { o = PA(d) | 0; a[m >> 0] = 8; OA(n, c[(o + 4) >> 2] | 0); yx(k, e, m, n, (o + 8) | 0); xx(b, k) | 0; wf(k); break; } case 9: { h = PA(d) | 0; d = c[(h + 4) >> 2] | 0; if (d | 0) { i = (j + 8) | 0; g = (h + 12) | 0; while (1) { d = (d + -1) | 0; OA(k, c[g >> 2] | 0); f = c[o >> 2] | 0; if (f >>> 0 < (c[i >> 2] | 0) >>> 0) { c[f >> 2] = c[k >> 2]; c[o >> 2] = (c[o >> 2] | 0) + 4; } else ew(j, k); if (!d) break; else g = (g + 4) | 0; } } a[m >> 0] = 9; OA(n, c[(h + 8) >> 2] | 0); zx(k, e, m, n, j); xx(b, k) | 0; wf(k); break; } default: { o = PA(d) | 0; a[m >> 0] = f; OA(n, c[(o + 4) >> 2] | 0); Ax(k, e, m, n); xx(b, k) | 0; wf(k); } } kw(j); l = p; return; } function wx(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0, f = 0; e = l; l = (l + 16) | 0; f = e; UA(f); c = Sg(c) | 0; Ox(b, c, a[d >> 0] | 0); WA(f); l = e; return; } function xx(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[a >> 2] | 0; if (d | 0) ab(d | 0); c[a >> 2] = c[b >> 2]; c[b >> 2] = 0; return a | 0; } function yx(b, d, e, f, g) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0; h = l; l = (l + 32) | 0; j = (h + 16) | 0; i = (h + 8) | 0; k = h; UA(i); d = Sg(d) | 0; e = a[e >> 0] | 0; c[k >> 2] = c[f >> 2]; g = c[g >> 2] | 0; c[j >> 2] = c[k >> 2]; Kx(b, d, e, j, g); WA(i); l = h; return; } function zx(b, d, e, f, g) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0; h = l; l = (l + 32) | 0; k = (h + 24) | 0; i = (h + 16) | 0; m = (h + 12) | 0; j = h; UA(i); d = Sg(d) | 0; e = a[e >> 0] | 0; c[m >> 2] = c[f >> 2]; mw(j, g); c[k >> 2] = c[m >> 2]; Gx(b, d, e, k, j); kw(j); WA(i); l = h; return; } function Ax(b, d, e, f) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = (l + 32) | 0; i = (g + 16) | 0; h = (g + 8) | 0; j = g; UA(h); d = Sg(d) | 0; e = a[e >> 0] | 0; c[j >> 2] = c[f >> 2]; c[i >> 2] = c[j >> 2]; Bx(b, d, e, i); WA(h); l = g; return; } function Bx(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = (l + 16) | 0; g = (f + 4) | 0; i = f; h = Vg(Cx() | 0) | 0; d = rx(d) | 0; c[i >> 2] = c[e >> 2]; c[g >> 2] = c[i >> 2]; Dx(a, xa(0, h | 0, b | 0, d | 0, qw(g) | 0) | 0); l = f; return; } function Cx() { var b = 0; if (!(a[8e3] | 0)) { Ex(10756); b = 8e3; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10756; } function Dx(a, b) { a = a | 0; b = b | 0; mk(a, b); return; } function Ex(a) { a = a | 0; fh(a, Fx() | 0, 2); return; } function Fx() { return 1772; } function Gx(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0; g = l; l = (l + 32) | 0; j = (g + 16) | 0; k = (g + 12) | 0; h = g; i = Vg(Hx() | 0) | 0; d = rx(d) | 0; c[k >> 2] = c[e >> 2]; c[j >> 2] = c[k >> 2]; e = qw(j) | 0; c[h >> 2] = c[f >> 2]; j = (f + 4) | 0; c[(h + 4) >> 2] = c[j >> 2]; k = (f + 8) | 0; c[(h + 8) >> 2] = c[k >> 2]; c[k >> 2] = 0; c[j >> 2] = 0; c[f >> 2] = 0; Dx(a, $a(0, i | 0, b | 0, d | 0, e | 0, tw(h) | 0) | 0); kw(h); l = g; return; } function Hx() { var b = 0; if (!(a[8008] | 0)) { Ix(10768); b = 8008; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10768; } function Ix(a) { a = a | 0; fh(a, Jx() | 0, 3); return; } function Jx() { return 1784; } function Kx(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = (l + 16) | 0; i = (g + 4) | 0; j = g; h = Vg(Lx() | 0) | 0; d = rx(d) | 0; c[j >> 2] = c[e >> 2]; c[i >> 2] = c[j >> 2]; e = qw(i) | 0; Dx(a, $a(0, h | 0, b | 0, d | 0, e | 0, sw(f) | 0) | 0); l = g; return; } function Lx() { var b = 0; if (!(a[8016] | 0)) { Mx(10780); b = 8016; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10780; } function Mx(a) { a = a | 0; fh(a, Nx() | 0, 3); return; } function Nx() { return 1800; } function Ox(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0; d = Vg(Px() | 0) | 0; Dx(a, bb(0, d | 0, b | 0, rx(c) | 0) | 0); return; } function Px() { var b = 0; if (!(a[8024] | 0)) { Qx(10792); b = 8024; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 10792; } function Qx(a) { a = a | 0; fh(a, Rx() | 0, 1); return; } function Rx() { return 1816; } function Sx() { Tx(); Ux(); Vx(); return; } function Tx() { c[2702] = rC(65536) | 0; return; } function Ux() { qy(10856); return; } function Vx() { Wx(10816); return; } function Wx(a) { a = a | 0; Xx(a, 5044); Yx(a) | 0; return; } function Xx(a, b) { a = a | 0; b = b | 0; var d = 0; d = zw() | 0; c[a >> 2] = d; ky(d, b); Hv(c[a >> 2] | 0); return; } function Yx(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Zx() | 0); return a | 0; } function Zx() { var b = 0; if (!(a[8032] | 0)) { _x(10820); Ha(64, 10820, o | 0) | 0; b = 8032; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(10820) | 0)) _x(10820); return 10820; } function _x(a) { a = a | 0; by(a); Gt(a, 25); return; } function $x(a) { a = a | 0; ay((a + 24) | 0); return; } function ay(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function by(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 18, b, gy() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function cy(a, b) { a = a | 0; b = b | 0; dy(a, b); return; } function dy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; d = l; l = (l + 16) | 0; e = d; f = (d + 4) | 0; Gk(f, b); c[e >> 2] = Hk(f, b) | 0; ey(a, e); l = d; return; } function ey(b, d) { b = b | 0; d = d | 0; fy((b + 4) | 0, c[d >> 2] | 0); a[(b + 8) >> 0] = 1; return; } function fy(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function gy() { return 1824; } function hy(a) { a = a | 0; return iy(a) | 0; } function iy(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = (l + 16) | 0; f = (d + 4) | 0; h = d; e = jy(8) | 0; b = e; i = qC(4) | 0; Gk(f, a); fy(i, Hk(f, a) | 0); g = (b + 4) | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Bw(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function jy(a) { a = a | 0; var b = 0, d = 0; a = (a + 7) & -8; if ( a >>> 0 <= 32768 ? ((b = c[2701] | 0), a >>> 0 <= ((65536 - b) | 0) >>> 0) : 0 ) { d = ((c[2702] | 0) + b) | 0; c[2701] = b + a; a = d; } else { a = rC((a + 8) | 0) | 0; c[a >> 2] = c[2703]; c[2703] = a; a = (a + 8) | 0; } return a | 0; } function ky(a, b) { a = a | 0; b = b | 0; c[a >> 2] = ly() | 0; c[(a + 4) >> 2] = my() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = ny() | 0; c[(a + 32) >> 2] = 9; return; } function ly() { return 11744; } function my() { return 1832; } function ny() { return cu() | 0; } function oy(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { py(c); sC(c); } } else if (b | 0) sC(b); return; } function py(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function qy(a) { a = a | 0; ry(a, 5052); sy(a) | 0; ty(a, 5058, 26) | 0; uy(a, 5069, 1) | 0; vy(a, 5077, 10) | 0; wy(a, 5087, 19) | 0; yy(a, 5094, 27) | 0; return; } function ry(a, b) { a = a | 0; b = b | 0; var d = 0; d = GA() | 0; c[a >> 2] = d; HA(d, b); Hv(c[a >> 2] | 0); return; } function sy(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, rA() | 0); return a | 0; } function ty(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Yz(a, ai(b) | 0, c, 0); return a | 0; } function uy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Gz(a, ai(b) | 0, c, 0); return a | 0; } function vy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; hz(a, ai(b) | 0, c, 0); return a | 0; } function wy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Ry(a, ai(b) | 0, c, 0); return a | 0; } function xy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; a: while (1) { d = c[2703] | 0; while (1) { if ((d | 0) == (b | 0)) break a; e = c[d >> 2] | 0; c[2703] = e; if (!d) d = e; else break; } sC(d); } c[2701] = a; return; } function yy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; zy(a, ai(b) | 0, c, 0); return a | 0; } function zy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Ay() | 0; a = By(d) | 0; fi(g, b, f, a, Cy(d, e) | 0, e); return; } function Ay() { var b = 0, d = 0; if (!(a[8040] | 0)) { Jy(10860); Ha(65, 10860, o | 0) | 0; d = 8040; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10860) | 0)) { b = 10860; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Jy(10860); } return 10860; } function By(a) { a = a | 0; return a | 0; } function Cy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Ay() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { Dy(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { Ey(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function Dy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function Ey(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = Fy(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Gy( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; Dy(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Hy(a, f); Iy(f); l = i; return; } } function Fy(a) { a = a | 0; return 536870911; } function Gy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Hy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Iy(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Jy(a) { a = a | 0; My(a); return; } function Ky(a) { a = a | 0; Ly((a + 24) | 0); return; } function Ly(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function My(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 11, b, Ny() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Ny() { return 1840; } function Oy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; Qy(c[(Py(a) | 0) >> 2] | 0, b, d); return; } function Py(a) { a = a | 0; return ((c[((Ay() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function Qy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0, e = 0, f = 0; d = l; l = (l + 16) | 0; f = (d + 1) | 0; e = d; Gk(f, b); b = Hk(f, b) | 0; Gk(e, c); c = Hk(e, c) | 0; ob[a & 31](b, c); l = d; return; } function Ry(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Sy() | 0; a = Ty(d) | 0; fi(g, b, f, a, Uy(d, e) | 0, e); return; } function Sy() { var b = 0, d = 0; if (!(a[8048] | 0)) { $y(10896); Ha(66, 10896, o | 0) | 0; d = 8048; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10896) | 0)) { b = 10896; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); $y(10896); } return 10896; } function Ty(a) { a = a | 0; return a | 0; } function Uy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Sy() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { Vy(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { Wy(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function Vy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function Wy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = Xy(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Yy( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; Vy(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Zy(a, f); _y(f); l = i; return; } } function Xy(a) { a = a | 0; return 536870911; } function Yy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Zy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function _y(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function $y(a) { a = a | 0; cz(a); return; } function az(a) { a = a | 0; bz((a + 24) | 0); return; } function bz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function cz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 11, b, dz() | 0, 1); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function dz() { return 1852; } function ez(a, b) { a = a | 0; b = b | 0; return gz(c[(fz(a) | 0) >> 2] | 0, b) | 0; } function fz(a) { a = a | 0; return ((c[((Sy() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function gz(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = (l + 16) | 0; d = c; Gk(d, b); b = Hk(d, b) | 0; b = ul(pb[a & 31](b) | 0) | 0; l = c; return b | 0; } function hz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = iz() | 0; a = jz(d) | 0; fi(g, b, f, a, kz(d, e) | 0, e); return; } function iz() { var b = 0, d = 0; if (!(a[8056] | 0)) { rz(10932); Ha(67, 10932, o | 0) | 0; d = 8056; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10932) | 0)) { b = 10932; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); rz(10932); } return 10932; } function jz(a) { a = a | 0; return a | 0; } function kz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = iz() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { lz(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { mz(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function lz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function mz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = nz(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; oz( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; lz(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; pz(a, f); qz(f); l = i; return; } } function nz(a) { a = a | 0; return 536870911; } function oz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function pz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function qz(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function rz(a) { a = a | 0; uz(a); return; } function sz(a) { a = a | 0; tz((a + 24) | 0); return; } function tz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function uz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 7, b, vz() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function vz() { return 1860; } function wz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; return yz(c[(xz(a) | 0) >> 2] | 0, b, d) | 0; } function xz(a) { a = a | 0; return ((c[((iz() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function yz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = (l + 32) | 0; h = (e + 12) | 0; g = (e + 8) | 0; i = e; j = (e + 16) | 0; f = (e + 4) | 0; zz(j, b); Az(i, j, b); ik(f, d); d = jk(f, d) | 0; c[h >> 2] = c[i >> 2]; Eb[a & 15](g, h, d); d = Bz(g) | 0; wf(g); kk(f); l = e; return d | 0; } function zz(a, b) { a = a | 0; b = b | 0; return; } function Az(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Cz(a, c); return; } function Bz(a) { a = a | 0; return Sg(a) | 0; } function Cz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = (l + 16) | 0; d = f; e = b; if (!(e & 1)) c[a >> 2] = c[b >> 2]; else { Dz(d, 0); Ja(e | 0, d | 0) | 0; Ez(a, d); Fz(d); } l = f; return; } function Dz(b, d) { b = b | 0; d = d | 0; ah(b, d); c[(b + 4) >> 2] = 0; a[(b + 8) >> 0] = 0; return; } function Ez(a, b) { a = a | 0; b = b | 0; c[a >> 2] = c[(b + 4) >> 2]; return; } function Fz(b) { b = b | 0; a[(b + 8) >> 0] = 0; return; } function Gz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Hz() | 0; a = Iz(d) | 0; fi(g, b, f, a, Jz(d, e) | 0, e); return; } function Hz() { var b = 0, d = 0; if (!(a[8064] | 0)) { Qz(10968); Ha(68, 10968, o | 0) | 0; d = 8064; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(10968) | 0)) { b = 10968; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); Qz(10968); } return 10968; } function Iz(a) { a = a | 0; return a | 0; } function Jz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Hz() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { Kz(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { Lz(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function Kz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function Lz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = Mz(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; Nz( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; Kz(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Oz(a, f); Pz(f); l = i; return; } } function Mz(a) { a = a | 0; return 536870911; } function Nz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function Oz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Pz(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Qz(a) { a = a | 0; Tz(a); return; } function Rz(a) { a = a | 0; Sz((a + 24) | 0); return; } function Sz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function Tz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 1, b, Uz() | 0, 5); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function Uz() { return 1872; } function Vz(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; Xz(c[(Wz(a) | 0) >> 2] | 0, b, d, e, f, g); return; } function Wz(a) { a = a | 0; return ((c[((Hz() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function Xz(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; g = l; l = (l + 32) | 0; h = (g + 16) | 0; i = (g + 12) | 0; j = (g + 8) | 0; k = (g + 4) | 0; m = g; ik(h, b); b = jk(h, b) | 0; ik(i, c); c = jk(i, c) | 0; ik(j, d); d = jk(j, d) | 0; ik(k, e); e = jk(k, e) | 0; ik(m, f); f = jk(m, f) | 0; jb[a & 1](b, c, d, e, f); kk(m); kk(k); kk(j); kk(i); kk(h); l = g; return; } function Yz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Zz() | 0; a = _z(d) | 0; fi(g, b, f, a, $z(d, e) | 0, e); return; } function Zz() { var b = 0, d = 0; if (!(a[8072] | 0)) { gA(11004); Ha(69, 11004, o | 0) | 0; d = 8072; c[d >> 2] = 1; c[(d + 4) >> 2] = 0; } if (!(si(11004) | 0)) { b = 11004; d = (b + 36) | 0; do { c[b >> 2] = 0; b = (b + 4) | 0; } while ((b | 0) < (d | 0)); gA(11004); } return 11004; } function _z(a) { a = a | 0; return a | 0; } function $z(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = (l + 16) | 0; f = i; g = (i + 4) | 0; c[f >> 2] = a; j = Zz() | 0; h = (j + 24) | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = (j + 28) | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[(j + 32) >> 2] | 0) >>> 0) { aA(e, a, b); b = ((c[d >> 2] | 0) + 8) | 0; c[d >> 2] = b; } else { bA(h, f, g); b = c[d >> 2] | 0; } l = i; return (((b - (c[h >> 2] | 0)) >> 3) + -1) | 0; } function aA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[(a + 4) >> 2] = d; return; } function bA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = (l + 32) | 0; f = i; g = (a + 4) | 0; h = ((((c[g >> 2] | 0) - (c[a >> 2] | 0)) >> 3) + 1) | 0; e = cA(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = ((c[(a + 8) >> 2] | 0) - j) | 0; k = m >> 2; dA( f, (m >> 3) >>> 0 < (e >>> 1) >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, ((c[g >> 2] | 0) - j) >> 3, (a + 8) | 0 ); h = (f + 8) | 0; aA(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; eA(a, f); fA(f); l = i; return; } } function cA(a) { a = a | 0; return 536870911; } function dA(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[(a + 12) >> 2] = 0; c[(a + 16) >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0); c[a >> 2] = f; e = (f + (d << 3)) | 0; c[(a + 8) >> 2] = e; c[(a + 4) >> 2] = e; c[(a + 12) >> 2] = f + (b << 3); return; } function eA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = (a + 4) | 0; g = (b + 4) | 0; f = ((c[h >> 2] | 0) - e) | 0; d = ((c[g >> 2] | 0) + ((0 - (f >> 3)) << 3)) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0) | 0; e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = (b + 8) | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = (a + 8) | 0; h = (b + 12) | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function fA(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[(a + 4) >> 2] | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -8 - b) | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function gA(a) { a = a | 0; jA(a); return; } function hA(a) { a = a | 0; iA((a + 24) | 0); return; } function iA(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function jA(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 12, b, kA() | 0, 2); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function kA() { return 1896; } function lA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; nA(c[(mA(a) | 0) >> 2] | 0, b, d); return; } function mA(a) { a = a | 0; return ((c[((Zz() | 0) + 24) >> 2] | 0) + (a << 3)) | 0; } function nA(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0, e = 0, f = 0; d = l; l = (l + 16) | 0; f = (d + 4) | 0; e = d; oA(f, b); b = pA(f, b) | 0; ik(e, c); c = jk(e, c) | 0; ob[a & 31](b, c); kk(e); l = d; return; } function oA(a, b) { a = a | 0; b = b | 0; return; } function pA(a, b) { a = a | 0; b = b | 0; return qA(b) | 0; } function qA(a) { a = a | 0; return a | 0; } function rA() { var b = 0; if (!(a[8080] | 0)) { sA(11040); Ha(70, 11040, o | 0) | 0; b = 8080; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } if (!(si(11040) | 0)) sA(11040); return 11040; } function sA(a) { a = a | 0; vA(a); Gt(a, 71); return; } function tA(a) { a = a | 0; uA((a + 24) | 0); return; } function uA(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = (a + 4) | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -8 - e) | 0) >>> 3) << 3); sC(d); } return; } function vA(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 7, b, zA() | 0, 0); c[(a + 24) >> 2] = 0; c[(a + 28) >> 2] = 0; c[(a + 32) >> 2] = 0; return; } function wA(a) { a = a | 0; xA(a); return; } function xA(a) { a = a | 0; yA(a); return; } function yA(b) { b = b | 0; a[(b + 8) >> 0] = 1; return; } function zA() { return 1936; } function AA() { return BA() | 0; } function BA() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = (l + 16) | 0; f = (b + 4) | 0; h = b; d = jy(8) | 0; a = d; g = (a + 4) | 0; c[g >> 2] = qC(1) | 0; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; CA(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function CA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[(d + 4) >> 2] = 0; c[(d + 8) >> 2] = 0; c[d >> 2] = 1916; c[(d + 12) >> 2] = b; c[(a + 4) >> 2] = d; return; } function DA(a) { a = a | 0; kC(a); sC(a); return; } function EA(a) { a = a | 0; a = c[(a + 12) >> 2] | 0; if (a | 0) sC(a); return; } function FA(a) { a = a | 0; sC(a); return; } function GA() { var b = 0; if (!(a[8088] | 0)) { NA(11076); Ha(25, 11076, o | 0) | 0; b = 8088; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 11076; } function HA(a, b) { a = a | 0; b = b | 0; c[a >> 2] = IA() | 0; c[(a + 4) >> 2] = JA() | 0; c[(a + 12) >> 2] = b; c[(a + 8) >> 2] = KA() | 0; c[(a + 32) >> 2] = 10; return; } function IA() { return 11745; } function JA() { return 1940; } function KA() { return lr() | 0; } function LA(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { MA(c); sC(c); } } else if (b | 0) sC(b); return; } function MA(a) { a = a | 0; a = c[(a + 4) >> 2] | 0; if (a | 0) oC(a); return; } function NA(a) { a = a | 0; Zi(a); return; } function OA(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function PA(a) { a = a | 0; return c[a >> 2] | 0; } function QA(b) { b = b | 0; return a[c[b >> 2] >> 0] | 0; } function RA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; c[e >> 2] = c[a >> 2]; SA(b, e) | 0; l = d; return; } function SA(a, b) { a = a | 0; b = b | 0; var d = 0; d = TA(c[a >> 2] | 0, b) | 0; b = (a + 4) | 0; c[((c[b >> 2] | 0) + 8) >> 2] = d; return c[((c[b >> 2] | 0) + 8) >> 2] | 0; } function TA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = (l + 16) | 0; e = d; UA(e); a = Sg(a) | 0; b = VA(a, c[b >> 2] | 0) | 0; WA(e); l = d; return b | 0; } function UA(a) { a = a | 0; c[a >> 2] = c[2701]; c[(a + 4) >> 2] = c[2703]; return; } function VA(a, b) { a = a | 0; b = b | 0; var c = 0; c = Vg(XA() | 0) | 0; return bb(0, c | 0, a | 0, sw(b) | 0) | 0; } function WA(a) { a = a | 0; xy(c[a >> 2] | 0, c[(a + 4) >> 2] | 0); return; } function XA() { var b = 0; if (!(a[8096] | 0)) { YA(11120); b = 8096; c[b >> 2] = 1; c[(b + 4) >> 2] = 0; } return 11120; } function YA(a) { a = a | 0; fh(a, ZA() | 0, 1); return; } function ZA() { return 1948; } function _A() { $A(); return; } function $A() { var b = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0; s = l; l = (l + 16) | 0; o = (s + 4) | 0; p = s; Ea(65536, 10804, c[2702] | 0, 10812); f = Wv() | 0; e = c[f >> 2] | 0; b = c[e >> 2] | 0; if (b | 0) { g = c[(f + 8) >> 2] | 0; f = c[(f + 4) >> 2] | 0; while (1) { Ma(b | 0, d[f >> 0] | 0 | 0, a[g >> 0] | 0); e = (e + 4) | 0; b = c[e >> 2] | 0; if (!b) break; else { g = (g + 1) | 0; f = (f + 1) | 0; } } } b = Yv() | 0; e = c[b >> 2] | 0; if (e | 0) do { Na(e | 0, c[(b + 4) >> 2] | 0); b = (b + 8) | 0; e = c[b >> 2] | 0; } while ((e | 0) != 0); Na(aB() | 0, 5167); n = Iv() | 0; b = c[n >> 2] | 0; a: do if (b | 0) { do { bB(c[(b + 4) >> 2] | 0); b = c[b >> 2] | 0; } while ((b | 0) != 0); b = c[n >> 2] | 0; if (b | 0) { m = n; do { while (1) { h = b; b = c[b >> 2] | 0; h = c[(h + 4) >> 2] | 0; if (!(cB(h) | 0)) break; c[p >> 2] = m; c[o >> 2] = c[p >> 2]; dB(n, o) | 0; if (!b) break a; } eB(h); m = c[m >> 2] | 0; e = fB(h) | 0; i = Va() | 0; j = l; l = (l + ((((1 * (e << 2)) | 0) + 15) & -16)) | 0; k = l; l = (l + ((((1 * (e << 2)) | 0) + 15) & -16)) | 0; e = c[(Zw(h) | 0) >> 2] | 0; if (e | 0) { f = j; g = k; while (1) { c[f >> 2] = c[(Xw(c[(e + 4) >> 2] | 0) | 0) >> 2]; c[g >> 2] = c[(e + 8) >> 2]; e = c[e >> 2] | 0; if (!e) break; else { f = (f + 4) | 0; g = (g + 4) | 0; } } } t = Xw(h) | 0; e = gB(h) | 0; f = fB(h) | 0; g = hB(h) | 0; Ra(t | 0, e | 0, j | 0, k | 0, f | 0, g | 0, Tv(h) | 0); Ga(i | 0); } while ((b | 0) != 0); } } while (0); b = c[(Vv() | 0) >> 2] | 0; if (b | 0) do { t = (b + 4) | 0; n = aw(t) | 0; h = fw(n) | 0; i = bw(n) | 0; j = ((cw(n) | 0) + 1) | 0; k = iB(n) | 0; m = jB(t) | 0; n = si(n) | 0; o = hw(t) | 0; p = kB(t) | 0; Pa( 0, h | 0, i | 0, j | 0, k | 0, m | 0, n | 0, o | 0, p | 0, lB(t) | 0 ); b = c[b >> 2] | 0; } while ((b | 0) != 0); b = c[(Iv() | 0) >> 2] | 0; b: do if (b | 0) { c: while (1) { e = c[(b + 4) >> 2] | 0; if ( e | 0 ? ((q = c[(Xw(e) | 0) >> 2] | 0), (r = c[(ax(e) | 0) >> 2] | 0), r | 0) : 0 ) { f = r; do { e = (f + 4) | 0; g = aw(e) | 0; d: do if (g | 0) switch (si(g) | 0) { case 0: break c; case 4: case 3: case 2: { k = fw(g) | 0; m = bw(g) | 0; n = ((cw(g) | 0) + 1) | 0; o = iB(g) | 0; p = si(g) | 0; t = hw(e) | 0; Pa( q | 0, k | 0, m | 0, n | 0, o | 0, 0, p | 0, t | 0, kB(e) | 0, lB(e) | 0 ); break d; } case 1: { j = fw(g) | 0; k = bw(g) | 0; m = ((cw(g) | 0) + 1) | 0; n = iB(g) | 0; o = jB(e) | 0; p = si(g) | 0; t = hw(e) | 0; Pa( q | 0, j | 0, k | 0, m | 0, n | 0, o | 0, p | 0, t | 0, kB(e) | 0, lB(e) | 0 ); break d; } case 5: { n = fw(g) | 0; o = bw(g) | 0; p = ((cw(g) | 0) + 1) | 0; t = iB(g) | 0; Pa( q | 0, n | 0, o | 0, p | 0, t | 0, mB(g) | 0, si(g) | 0, 0, 0, 0 ); break d; } default: break d; } while (0); f = c[f >> 2] | 0; } while ((f | 0) != 0); } b = c[b >> 2] | 0; if (!b) break b; } Ta(); } while (0); Sa(); l = s; return; } function aB() { return 11703; } function bB(b) { b = b | 0; a[(b + 40) >> 0] = 0; return; } function cB(b) { b = b | 0; return ((a[(b + 40) >> 0] | 0) != 0) | 0; } function dB(a, b) { a = a | 0; b = b | 0; b = nB(b) | 0; a = c[b >> 2] | 0; c[b >> 2] = c[a >> 2]; sC(a); return c[b >> 2] | 0; } function eB(b) { b = b | 0; a[(b + 40) >> 0] = 1; return; } function fB(a) { a = a | 0; return c[(a + 20) >> 2] | 0; } function gB(a) { a = a | 0; return c[(a + 8) >> 2] | 0; } function hB(a) { a = a | 0; return c[(a + 32) >> 2] | 0; } function iB(a) { a = a | 0; return c[(a + 4) >> 2] | 0; } function jB(a) { a = a | 0; return c[(a + 4) >> 2] | 0; } function kB(a) { a = a | 0; return c[(a + 8) >> 2] | 0; } function lB(a) { a = a | 0; return c[(a + 16) >> 2] | 0; } function mB(a) { a = a | 0; return c[(a + 20) >> 2] | 0; } function nB(a) { a = a | 0; return c[a >> 2] | 0; } function oB(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0; x = l; l = (l + 16) | 0; o = x; do if (a >>> 0 < 245) { k = a >>> 0 < 11 ? 16 : (a + 11) & -8; a = k >>> 3; n = c[2783] | 0; d = n >>> a; if ((d & 3) | 0) { b = (((d & 1) ^ 1) + a) | 0; a = (11172 + ((b << 1) << 2)) | 0; d = (a + 8) | 0; e = c[d >> 2] | 0; f = (e + 8) | 0; g = c[f >> 2] | 0; if ((a | 0) == (g | 0)) c[2783] = n & ~(1 << b); else { c[(g + 12) >> 2] = a; c[d >> 2] = g; } w = b << 3; c[(e + 4) >> 2] = w | 3; w = (e + w + 4) | 0; c[w >> 2] = c[w >> 2] | 1; w = f; l = x; return w | 0; } m = c[2785] | 0; if (k >>> 0 > m >>> 0) { if (d | 0) { b = 2 << a; b = (d << a) & (b | (0 - b)); b = ((b & (0 - b)) + -1) | 0; h = (b >>> 12) & 16; b = b >>> h; d = (b >>> 5) & 8; b = b >>> d; f = (b >>> 2) & 4; b = b >>> f; a = (b >>> 1) & 2; b = b >>> a; e = (b >>> 1) & 1; e = ((d | h | f | a | e) + (b >>> e)) | 0; b = (11172 + ((e << 1) << 2)) | 0; a = (b + 8) | 0; f = c[a >> 2] | 0; h = (f + 8) | 0; d = c[h >> 2] | 0; if ((b | 0) == (d | 0)) { a = n & ~(1 << e); c[2783] = a; } else { c[(d + 12) >> 2] = b; c[a >> 2] = d; a = n; } g = ((e << 3) - k) | 0; c[(f + 4) >> 2] = k | 3; e = (f + k) | 0; c[(e + 4) >> 2] = g | 1; c[(e + g) >> 2] = g; if (m | 0) { f = c[2788] | 0; b = m >>> 3; d = (11172 + ((b << 1) << 2)) | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = (d + 8) | 0; } else { a = (d + 8) | 0; b = c[a >> 2] | 0; } c[a >> 2] = f; c[(b + 12) >> 2] = f; c[(f + 8) >> 2] = b; c[(f + 12) >> 2] = d; } c[2785] = g; c[2788] = e; w = h; l = x; return w | 0; } i = c[2784] | 0; if (i) { d = ((i & (0 - i)) + -1) | 0; h = (d >>> 12) & 16; d = d >>> h; g = (d >>> 5) & 8; d = d >>> g; j = (d >>> 2) & 4; d = d >>> j; e = (d >>> 1) & 2; d = d >>> e; a = (d >>> 1) & 1; a = c[ (11436 + (((g | h | j | e | a) + (d >>> a)) << 2)) >> 2 ] | 0; d = ((c[(a + 4) >> 2] & -8) - k) | 0; e = c[ (a + 16 + ((((c[(a + 16) >> 2] | 0) == 0) & 1) << 2)) >> 2 ] | 0; if (!e) { j = a; g = d; } else { do { h = ((c[(e + 4) >> 2] & -8) - k) | 0; j = h >>> 0 < d >>> 0; d = j ? h : d; a = j ? e : a; e = c[ (e + 16 + ((((c[(e + 16) >> 2] | 0) == 0) & 1) << 2)) >> 2 ] | 0; } while ((e | 0) != 0); j = a; g = d; } h = (j + k) | 0; if (j >>> 0 < h >>> 0) { f = c[(j + 24) >> 2] | 0; b = c[(j + 12) >> 2] | 0; do if ((b | 0) == (j | 0)) { a = (j + 20) | 0; b = c[a >> 2] | 0; if (!b) { a = (j + 16) | 0; b = c[a >> 2] | 0; if (!b) { d = 0; break; } } while (1) { d = (b + 20) | 0; e = c[d >> 2] | 0; if (e | 0) { b = e; a = d; continue; } d = (b + 16) | 0; e = c[d >> 2] | 0; if (!e) break; else { b = e; a = d; } } c[a >> 2] = 0; d = b; } else { d = c[(j + 8) >> 2] | 0; c[(d + 12) >> 2] = b; c[(b + 8) >> 2] = d; d = b; } while (0); do if (f | 0) { b = c[(j + 28) >> 2] | 0; a = (11436 + (b << 2)) | 0; if ((j | 0) == (c[a >> 2] | 0)) { c[a >> 2] = d; if (!d) { c[2784] = i & ~(1 << b); break; } } else { c[ (f + 16 + ((((c[(f + 16) >> 2] | 0) != (j | 0)) & 1) << 2)) >> 2 ] = d; if (!d) break; } c[(d + 24) >> 2] = f; b = c[(j + 16) >> 2] | 0; if (b | 0) { c[(d + 16) >> 2] = b; c[(b + 24) >> 2] = d; } b = c[(j + 20) >> 2] | 0; if (b | 0) { c[(d + 20) >> 2] = b; c[(b + 24) >> 2] = d; } } while (0); if (g >>> 0 < 16) { w = (g + k) | 0; c[(j + 4) >> 2] = w | 3; w = (j + w + 4) | 0; c[w >> 2] = c[w >> 2] | 1; } else { c[(j + 4) >> 2] = k | 3; c[(h + 4) >> 2] = g | 1; c[(h + g) >> 2] = g; if (m | 0) { e = c[2788] | 0; b = m >>> 3; d = (11172 + ((b << 1) << 2)) | 0; b = 1 << b; if (!(n & b)) { c[2783] = n | b; b = d; a = (d + 8) | 0; } else { a = (d + 8) | 0; b = c[a >> 2] | 0; } c[a >> 2] = e; c[(b + 12) >> 2] = e; c[(e + 8) >> 2] = b; c[(e + 12) >> 2] = d; } c[2785] = g; c[2788] = h; } w = (j + 8) | 0; l = x; return w | 0; } else n = k; } else n = k; } else n = k; } else if (a >>> 0 <= 4294967231) { a = (a + 11) | 0; k = a & -8; j = c[2784] | 0; if (j) { e = (0 - k) | 0; a = a >>> 8; if (a) { if (k >>> 0 > 16777215) i = 31; else { n = (((a + 1048320) | 0) >>> 16) & 8; v = a << n; m = (((v + 520192) | 0) >>> 16) & 4; v = v << m; i = (((v + 245760) | 0) >>> 16) & 2; i = (14 - (m | n | i) + ((v << i) >>> 15)) | 0; i = ((k >>> ((i + 7) | 0)) & 1) | (i << 1); } } else i = 0; d = c[(11436 + (i << 2)) >> 2] | 0; a: do if (!d) { d = 0; a = 0; v = 57; } else { a = 0; h = k << ((i | 0) == 31 ? 0 : (25 - (i >>> 1)) | 0); g = 0; while (1) { f = ((c[(d + 4) >> 2] & -8) - k) | 0; if (f >>> 0 < e >>> 0) if (!f) { a = d; e = 0; f = d; v = 61; break a; } else { a = d; e = f; } f = c[(d + 20) >> 2] | 0; d = c[(d + 16 + ((h >>> 31) << 2)) >> 2] | 0; g = ((f | 0) == 0) | ((f | 0) == (d | 0)) ? g : f; f = (d | 0) == 0; if (f) { d = g; v = 57; break; } else h = h << ((f ^ 1) & 1); } } while (0); if ((v | 0) == 57) { if (((d | 0) == 0) & ((a | 0) == 0)) { a = 2 << i; a = j & (a | (0 - a)); if (!a) { n = k; break; } n = ((a & (0 - a)) + -1) | 0; h = (n >>> 12) & 16; n = n >>> h; g = (n >>> 5) & 8; n = n >>> g; i = (n >>> 2) & 4; n = n >>> i; m = (n >>> 1) & 2; n = n >>> m; d = (n >>> 1) & 1; a = 0; d = c[ (11436 + (((g | h | i | m | d) + (n >>> d)) << 2)) >> 2 ] | 0; } if (!d) { i = a; h = e; } else { f = d; v = 61; } } if ((v | 0) == 61) while (1) { v = 0; d = ((c[(f + 4) >> 2] & -8) - k) | 0; n = d >>> 0 < e >>> 0; d = n ? d : e; a = n ? f : a; f = c[ (f + 16 + ((((c[(f + 16) >> 2] | 0) == 0) & 1) << 2)) >> 2 ] | 0; if (!f) { i = a; h = d; break; } else { e = d; v = 61; } } if ( (i | 0) != 0 ? h >>> 0 < (((c[2785] | 0) - k) | 0) >>> 0 : 0 ) { g = (i + k) | 0; if (i >>> 0 >= g >>> 0) { w = 0; l = x; return w | 0; } f = c[(i + 24) >> 2] | 0; b = c[(i + 12) >> 2] | 0; do if ((b | 0) == (i | 0)) { a = (i + 20) | 0; b = c[a >> 2] | 0; if (!b) { a = (i + 16) | 0; b = c[a >> 2] | 0; if (!b) { b = 0; break; } } while (1) { d = (b + 20) | 0; e = c[d >> 2] | 0; if (e | 0) { b = e; a = d; continue; } d = (b + 16) | 0; e = c[d >> 2] | 0; if (!e) break; else { b = e; a = d; } } c[a >> 2] = 0; } else { w = c[(i + 8) >> 2] | 0; c[(w + 12) >> 2] = b; c[(b + 8) >> 2] = w; } while (0); do if (f) { a = c[(i + 28) >> 2] | 0; d = (11436 + (a << 2)) | 0; if ((i | 0) == (c[d >> 2] | 0)) { c[d >> 2] = b; if (!b) { e = j & ~(1 << a); c[2784] = e; break; } } else { c[ (f + 16 + ((((c[(f + 16) >> 2] | 0) != (i | 0)) & 1) << 2)) >> 2 ] = b; if (!b) { e = j; break; } } c[(b + 24) >> 2] = f; a = c[(i + 16) >> 2] | 0; if (a | 0) { c[(b + 16) >> 2] = a; c[(a + 24) >> 2] = b; } a = c[(i + 20) >> 2] | 0; if (a) { c[(b + 20) >> 2] = a; c[(a + 24) >> 2] = b; e = j; } else e = j; } else e = j; while (0); do if (h >>> 0 >= 16) { c[(i + 4) >> 2] = k | 3; c[(g + 4) >> 2] = h | 1; c[(g + h) >> 2] = h; b = h >>> 3; if (h >>> 0 < 256) { d = (11172 + ((b << 1) << 2)) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = (d + 8) | 0; } else { a = (d + 8) | 0; b = c[a >> 2] | 0; } c[a >> 2] = g; c[(b + 12) >> 2] = g; c[(g + 8) >> 2] = b; c[(g + 12) >> 2] = d; break; } b = h >>> 8; if (b) { if (h >>> 0 > 16777215) b = 31; else { v = (((b + 1048320) | 0) >>> 16) & 8; w = b << v; u = (((w + 520192) | 0) >>> 16) & 4; w = w << u; b = (((w + 245760) | 0) >>> 16) & 2; b = (14 - (u | v | b) + ((w << b) >>> 15)) | 0; b = ((h >>> ((b + 7) | 0)) & 1) | (b << 1); } } else b = 0; d = (11436 + (b << 2)) | 0; c[(g + 28) >> 2] = b; a = (g + 16) | 0; c[(a + 4) >> 2] = 0; c[a >> 2] = 0; a = 1 << b; if (!(e & a)) { c[2784] = e | a; c[d >> 2] = g; c[(g + 24) >> 2] = d; c[(g + 12) >> 2] = g; c[(g + 8) >> 2] = g; break; } a = h << ((b | 0) == 31 ? 0 : (25 - (b >>> 1)) | 0); d = c[d >> 2] | 0; while (1) { if ( ((c[(d + 4) >> 2] & -8) | 0) == (h | 0) ) { v = 97; break; } e = (d + 16 + ((a >>> 31) << 2)) | 0; b = c[e >> 2] | 0; if (!b) { v = 96; break; } else { a = a << 1; d = b; } } if ((v | 0) == 96) { c[e >> 2] = g; c[(g + 24) >> 2] = d; c[(g + 12) >> 2] = g; c[(g + 8) >> 2] = g; break; } else if ((v | 0) == 97) { v = (d + 8) | 0; w = c[v >> 2] | 0; c[(w + 12) >> 2] = g; c[v >> 2] = g; c[(g + 8) >> 2] = w; c[(g + 12) >> 2] = d; c[(g + 24) >> 2] = 0; break; } } else { w = (h + k) | 0; c[(i + 4) >> 2] = w | 3; w = (i + w + 4) | 0; c[w >> 2] = c[w >> 2] | 1; } while (0); w = (i + 8) | 0; l = x; return w | 0; } else n = k; } else n = k; } else n = -1; while (0); d = c[2785] | 0; if (d >>> 0 >= n >>> 0) { b = (d - n) | 0; a = c[2788] | 0; if (b >>> 0 > 15) { w = (a + n) | 0; c[2788] = w; c[2785] = b; c[(w + 4) >> 2] = b | 1; c[(w + b) >> 2] = b; c[(a + 4) >> 2] = n | 3; } else { c[2785] = 0; c[2788] = 0; c[(a + 4) >> 2] = d | 3; w = (a + d + 4) | 0; c[w >> 2] = c[w >> 2] | 1; } w = (a + 8) | 0; l = x; return w | 0; } h = c[2786] | 0; if (h >>> 0 > n >>> 0) { u = (h - n) | 0; c[2786] = u; w = c[2789] | 0; v = (w + n) | 0; c[2789] = v; c[(v + 4) >> 2] = u | 1; c[(w + 4) >> 2] = n | 3; w = (w + 8) | 0; l = x; return w | 0; } if (!(c[2901] | 0)) { c[2903] = 4096; c[2902] = 4096; c[2904] = -1; c[2905] = -1; c[2906] = 0; c[2894] = 0; a = (o & -16) ^ 1431655768; c[o >> 2] = a; c[2901] = a; a = 4096; } else a = c[2903] | 0; i = (n + 48) | 0; j = (n + 47) | 0; g = (a + j) | 0; f = (0 - a) | 0; k = g & f; if (k >>> 0 <= n >>> 0) { w = 0; l = x; return w | 0; } a = c[2893] | 0; if ( a | 0 ? ((m = c[2891] | 0), (o = (m + k) | 0), (o >>> 0 <= m >>> 0) | (o >>> 0 > a >>> 0)) : 0 ) { w = 0; l = x; return w | 0; } b: do if (!(c[2894] & 4)) { d = c[2789] | 0; c: do if (d) { e = 11580; while (1) { a = c[e >> 2] | 0; if ( a >>> 0 <= d >>> 0 ? ((r = (e + 4) | 0), ((a + (c[r >> 2] | 0)) | 0) >>> 0 > d >>> 0) : 0 ) break; a = c[(e + 8) >> 2] | 0; if (!a) { v = 118; break c; } else e = a; } b = (g - h) & f; if (b >>> 0 < 2147483647) { a = FC(b | 0) | 0; if ( (a | 0) == (((c[e >> 2] | 0) + (c[r >> 2] | 0)) | 0) ) { if ((a | 0) != (-1 | 0)) { h = b; g = a; v = 135; break b; } } else { e = a; v = 126; } } else b = 0; } else v = 118; while (0); do if ((v | 0) == 118) { d = FC(0) | 0; if ( (d | 0) != (-1 | 0) ? ((b = d), (p = c[2902] | 0), (q = (p + -1) | 0), (b = ((((q & b) | 0) == 0 ? 0 : (((q + b) & (0 - p)) - b) | 0) + k) | 0), (p = c[2891] | 0), (q = (b + p) | 0), (b >>> 0 > n >>> 0) & (b >>> 0 < 2147483647)) : 0 ) { r = c[2893] | 0; if ( r | 0 ? (q >>> 0 <= p >>> 0) | (q >>> 0 > r >>> 0) : 0 ) { b = 0; break; } a = FC(b | 0) | 0; if ((a | 0) == (d | 0)) { h = b; g = d; v = 135; break b; } else { e = a; v = 126; } } else b = 0; } while (0); do if ((v | 0) == 126) { d = (0 - b) | 0; if ( !( (i >>> 0 > b >>> 0) & ((b >>> 0 < 2147483647) & ((e | 0) != (-1 | 0))) ) ) if ((e | 0) == (-1 | 0)) { b = 0; break; } else { h = b; g = e; v = 135; break b; } a = c[2903] | 0; a = (j - b + a) & (0 - a); if (a >>> 0 >= 2147483647) { h = b; g = e; v = 135; break b; } if ((FC(a | 0) | 0) == (-1 | 0)) { FC(d | 0) | 0; b = 0; break; } else { h = (a + b) | 0; g = e; v = 135; break b; } } while (0); c[2894] = c[2894] | 4; v = 133; } else { b = 0; v = 133; } while (0); if ( ((v | 0) == 133 ? k >>> 0 < 2147483647 : 0) ? ((u = FC(k | 0) | 0), (r = FC(0) | 0), (s = (r - u) | 0), (t = s >>> 0 > ((n + 40) | 0) >>> 0), !( ((u | 0) == (-1 | 0)) | (t ^ 1) | (((u >>> 0 < r >>> 0) & (((u | 0) != (-1 | 0)) & ((r | 0) != (-1 | 0)))) ^ 1) )) : 0 ) { h = t ? s : b; g = u; v = 135; } if ((v | 0) == 135) { b = ((c[2891] | 0) + h) | 0; c[2891] = b; if (b >>> 0 > (c[2892] | 0) >>> 0) c[2892] = b; j = c[2789] | 0; do if (j) { b = 11580; while (1) { a = c[b >> 2] | 0; d = (b + 4) | 0; e = c[d >> 2] | 0; if ((g | 0) == ((a + e) | 0)) { v = 145; break; } f = c[(b + 8) >> 2] | 0; if (!f) break; else b = f; } if ( ((v | 0) == 145 ? ((c[(b + 12) >> 2] & 8) | 0) == 0 : 0) ? (j >>> 0 < g >>> 0) & (j >>> 0 >= a >>> 0) : 0 ) { c[d >> 2] = e + h; w = (j + 8) | 0; w = ((w & 7) | 0) == 0 ? 0 : (0 - w) & 7; v = (j + w) | 0; w = ((c[2786] | 0) + (h - w)) | 0; c[2789] = v; c[2786] = w; c[(v + 4) >> 2] = w | 1; c[(v + w + 4) >> 2] = 40; c[2790] = c[2905]; break; } if (g >>> 0 < (c[2787] | 0) >>> 0) c[2787] = g; d = (g + h) | 0; b = 11580; while (1) { if ((c[b >> 2] | 0) == (d | 0)) { v = 153; break; } a = c[(b + 8) >> 2] | 0; if (!a) break; else b = a; } if ( (v | 0) == 153 ? ((c[(b + 12) >> 2] & 8) | 0) == 0 : 0 ) { c[b >> 2] = g; m = (b + 4) | 0; c[m >> 2] = (c[m >> 2] | 0) + h; m = (g + 8) | 0; m = (g + (((m & 7) | 0) == 0 ? 0 : (0 - m) & 7)) | 0; b = (d + 8) | 0; b = (d + (((b & 7) | 0) == 0 ? 0 : (0 - b) & 7)) | 0; k = (m + n) | 0; i = (b - m - n) | 0; c[(m + 4) >> 2] = n | 3; do if ((b | 0) != (j | 0)) { if ((b | 0) == (c[2788] | 0)) { w = ((c[2785] | 0) + i) | 0; c[2785] = w; c[2788] = k; c[(k + 4) >> 2] = w | 1; c[(k + w) >> 2] = w; break; } a = c[(b + 4) >> 2] | 0; if (((a & 3) | 0) == 1) { h = a & -8; e = a >>> 3; d: do if (a >>> 0 < 256) { a = c[(b + 8) >> 2] | 0; d = c[(b + 12) >> 2] | 0; if ((d | 0) == (a | 0)) { c[2783] = c[2783] & ~(1 << e); break; } else { c[(a + 12) >> 2] = d; c[(d + 8) >> 2] = a; break; } } else { g = c[(b + 24) >> 2] | 0; a = c[(b + 12) >> 2] | 0; do if ((a | 0) == (b | 0)) { e = (b + 16) | 0; d = (e + 4) | 0; a = c[d >> 2] | 0; if (!a) { a = c[e >> 2] | 0; if (!a) { a = 0; break; } else d = e; } while (1) { e = (a + 20) | 0; f = c[e >> 2] | 0; if (f | 0) { a = f; d = e; continue; } e = (a + 16) | 0; f = c[e >> 2] | 0; if (!f) break; else { a = f; d = e; } } c[d >> 2] = 0; } else { w = c[(b + 8) >> 2] | 0; c[(w + 12) >> 2] = a; c[(a + 8) >> 2] = w; } while (0); if (!g) break; d = c[(b + 28) >> 2] | 0; e = (11436 + (d << 2)) | 0; do if ( (b | 0) != (c[e >> 2] | 0) ) { c[ (g + 16 + ((((c[ (g + 16) >> 2 ] | 0) != (b | 0)) & 1) << 2)) >> 2 ] = a; if (!a) break d; } else { c[e >> 2] = a; if (a | 0) break; c[2784] = c[2784] & ~(1 << d); break d; } while (0); c[(a + 24) >> 2] = g; d = (b + 16) | 0; e = c[d >> 2] | 0; if (e | 0) { c[(a + 16) >> 2] = e; c[(e + 24) >> 2] = a; } d = c[(d + 4) >> 2] | 0; if (!d) break; c[(a + 20) >> 2] = d; c[(d + 24) >> 2] = a; } while (0); b = (b + h) | 0; f = (h + i) | 0; } else f = i; b = (b + 4) | 0; c[b >> 2] = c[b >> 2] & -2; c[(k + 4) >> 2] = f | 1; c[(k + f) >> 2] = f; b = f >>> 3; if (f >>> 0 < 256) { d = (11172 + ((b << 1) << 2)) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = (d + 8) | 0; } else { a = (d + 8) | 0; b = c[a >> 2] | 0; } c[a >> 2] = k; c[(b + 12) >> 2] = k; c[(k + 8) >> 2] = b; c[(k + 12) >> 2] = d; break; } b = f >>> 8; do if (!b) b = 0; else { if (f >>> 0 > 16777215) { b = 31; break; } v = (((b + 1048320) | 0) >>> 16) & 8; w = b << v; u = (((w + 520192) | 0) >>> 16) & 4; w = w << u; b = (((w + 245760) | 0) >>> 16) & 2; b = (14 - (u | v | b) + ((w << b) >>> 15)) | 0; b = ((f >>> ((b + 7) | 0)) & 1) | (b << 1); } while (0); e = (11436 + (b << 2)) | 0; c[(k + 28) >> 2] = b; a = (k + 16) | 0; c[(a + 4) >> 2] = 0; c[a >> 2] = 0; a = c[2784] | 0; d = 1 << b; if (!(a & d)) { c[2784] = a | d; c[e >> 2] = k; c[(k + 24) >> 2] = e; c[(k + 12) >> 2] = k; c[(k + 8) >> 2] = k; break; } a = f << ((b | 0) == 31 ? 0 : (25 - (b >>> 1)) | 0); d = c[e >> 2] | 0; while (1) { if ( ((c[(d + 4) >> 2] & -8) | 0) == (f | 0) ) { v = 194; break; } e = (d + 16 + ((a >>> 31) << 2)) | 0; b = c[e >> 2] | 0; if (!b) { v = 193; break; } else { a = a << 1; d = b; } } if ((v | 0) == 193) { c[e >> 2] = k; c[(k + 24) >> 2] = d; c[(k + 12) >> 2] = k; c[(k + 8) >> 2] = k; break; } else if ((v | 0) == 194) { v = (d + 8) | 0; w = c[v >> 2] | 0; c[(w + 12) >> 2] = k; c[v >> 2] = k; c[(k + 8) >> 2] = w; c[(k + 12) >> 2] = d; c[(k + 24) >> 2] = 0; break; } } else { w = ((c[2786] | 0) + i) | 0; c[2786] = w; c[2789] = k; c[(k + 4) >> 2] = w | 1; } while (0); w = (m + 8) | 0; l = x; return w | 0; } b = 11580; while (1) { a = c[b >> 2] | 0; if ( a >>> 0 <= j >>> 0 ? ((w = (a + (c[(b + 4) >> 2] | 0)) | 0), w >>> 0 > j >>> 0) : 0 ) break; b = c[(b + 8) >> 2] | 0; } f = (w + -47) | 0; a = (f + 8) | 0; a = (f + (((a & 7) | 0) == 0 ? 0 : (0 - a) & 7)) | 0; f = (j + 16) | 0; a = a >>> 0 < f >>> 0 ? j : a; b = (a + 8) | 0; d = (g + 8) | 0; d = ((d & 7) | 0) == 0 ? 0 : (0 - d) & 7; v = (g + d) | 0; d = (h + -40 - d) | 0; c[2789] = v; c[2786] = d; c[(v + 4) >> 2] = d | 1; c[(v + d + 4) >> 2] = 40; c[2790] = c[2905]; d = (a + 4) | 0; c[d >> 2] = 27; c[b >> 2] = c[2895]; c[(b + 4) >> 2] = c[2896]; c[(b + 8) >> 2] = c[2897]; c[(b + 12) >> 2] = c[2898]; c[2895] = g; c[2896] = h; c[2898] = 0; c[2897] = b; b = (a + 24) | 0; do { v = b; b = (b + 4) | 0; c[b >> 2] = 7; } while (((v + 8) | 0) >>> 0 < w >>> 0); if ((a | 0) != (j | 0)) { g = (a - j) | 0; c[d >> 2] = c[d >> 2] & -2; c[(j + 4) >> 2] = g | 1; c[a >> 2] = g; b = g >>> 3; if (g >>> 0 < 256) { d = (11172 + ((b << 1) << 2)) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = (d + 8) | 0; } else { a = (d + 8) | 0; b = c[a >> 2] | 0; } c[a >> 2] = j; c[(b + 12) >> 2] = j; c[(j + 8) >> 2] = b; c[(j + 12) >> 2] = d; break; } b = g >>> 8; if (b) { if (g >>> 0 > 16777215) d = 31; else { v = (((b + 1048320) | 0) >>> 16) & 8; w = b << v; u = (((w + 520192) | 0) >>> 16) & 4; w = w << u; d = (((w + 245760) | 0) >>> 16) & 2; d = (14 - (u | v | d) + ((w << d) >>> 15)) | 0; d = ((g >>> ((d + 7) | 0)) & 1) | (d << 1); } } else d = 0; e = (11436 + (d << 2)) | 0; c[(j + 28) >> 2] = d; c[(j + 20) >> 2] = 0; c[f >> 2] = 0; b = c[2784] | 0; a = 1 << d; if (!(b & a)) { c[2784] = b | a; c[e >> 2] = j; c[(j + 24) >> 2] = e; c[(j + 12) >> 2] = j; c[(j + 8) >> 2] = j; break; } a = g << ((d | 0) == 31 ? 0 : (25 - (d >>> 1)) | 0); d = c[e >> 2] | 0; while (1) { if (((c[(d + 4) >> 2] & -8) | 0) == (g | 0)) { v = 216; break; } e = (d + 16 + ((a >>> 31) << 2)) | 0; b = c[e >> 2] | 0; if (!b) { v = 215; break; } else { a = a << 1; d = b; } } if ((v | 0) == 215) { c[e >> 2] = j; c[(j + 24) >> 2] = d; c[(j + 12) >> 2] = j; c[(j + 8) >> 2] = j; break; } else if ((v | 0) == 216) { v = (d + 8) | 0; w = c[v >> 2] | 0; c[(w + 12) >> 2] = j; c[v >> 2] = j; c[(j + 8) >> 2] = w; c[(j + 12) >> 2] = d; c[(j + 24) >> 2] = 0; break; } } } else { w = c[2787] | 0; if (((w | 0) == 0) | (g >>> 0 < w >>> 0)) c[2787] = g; c[2895] = g; c[2896] = h; c[2898] = 0; c[2792] = c[2901]; c[2791] = -1; b = 0; do { w = (11172 + ((b << 1) << 2)) | 0; c[(w + 12) >> 2] = w; c[(w + 8) >> 2] = w; b = (b + 1) | 0; } while ((b | 0) != 32); w = (g + 8) | 0; w = ((w & 7) | 0) == 0 ? 0 : (0 - w) & 7; v = (g + w) | 0; w = (h + -40 - w) | 0; c[2789] = v; c[2786] = w; c[(v + 4) >> 2] = w | 1; c[(v + w + 4) >> 2] = 40; c[2790] = c[2905]; } while (0); b = c[2786] | 0; if (b >>> 0 > n >>> 0) { u = (b - n) | 0; c[2786] = u; w = c[2789] | 0; v = (w + n) | 0; c[2789] = v; c[(v + 4) >> 2] = u | 1; c[(w + 4) >> 2] = n | 3; w = (w + 8) | 0; l = x; return w | 0; } } c[(vB() | 0) >> 2] = 12; w = 0; l = x; return w | 0; } function pB(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; if (!a) return; d = (a + -8) | 0; f = c[2787] | 0; a = c[(a + -4) >> 2] | 0; b = a & -8; j = (d + b) | 0; do if (!(a & 1)) { e = c[d >> 2] | 0; if (!(a & 3)) return; h = (d + (0 - e)) | 0; g = (e + b) | 0; if (h >>> 0 < f >>> 0) return; if ((h | 0) == (c[2788] | 0)) { a = (j + 4) | 0; b = c[a >> 2] | 0; if (((b & 3) | 0) != 3) { i = h; b = g; break; } c[2785] = g; c[a >> 2] = b & -2; c[(h + 4) >> 2] = g | 1; c[(h + g) >> 2] = g; return; } d = e >>> 3; if (e >>> 0 < 256) { a = c[(h + 8) >> 2] | 0; b = c[(h + 12) >> 2] | 0; if ((b | 0) == (a | 0)) { c[2783] = c[2783] & ~(1 << d); i = h; b = g; break; } else { c[(a + 12) >> 2] = b; c[(b + 8) >> 2] = a; i = h; b = g; break; } } f = c[(h + 24) >> 2] | 0; a = c[(h + 12) >> 2] | 0; do if ((a | 0) == (h | 0)) { d = (h + 16) | 0; b = (d + 4) | 0; a = c[b >> 2] | 0; if (!a) { a = c[d >> 2] | 0; if (!a) { a = 0; break; } else b = d; } while (1) { d = (a + 20) | 0; e = c[d >> 2] | 0; if (e | 0) { a = e; b = d; continue; } d = (a + 16) | 0; e = c[d >> 2] | 0; if (!e) break; else { a = e; b = d; } } c[b >> 2] = 0; } else { i = c[(h + 8) >> 2] | 0; c[(i + 12) >> 2] = a; c[(a + 8) >> 2] = i; } while (0); if (f) { b = c[(h + 28) >> 2] | 0; d = (11436 + (b << 2)) | 0; if ((h | 0) == (c[d >> 2] | 0)) { c[d >> 2] = a; if (!a) { c[2784] = c[2784] & ~(1 << b); i = h; b = g; break; } } else { c[ (f + 16 + ((((c[(f + 16) >> 2] | 0) != (h | 0)) & 1) << 2)) >> 2 ] = a; if (!a) { i = h; b = g; break; } } c[(a + 24) >> 2] = f; b = (h + 16) | 0; d = c[b >> 2] | 0; if (d | 0) { c[(a + 16) >> 2] = d; c[(d + 24) >> 2] = a; } b = c[(b + 4) >> 2] | 0; if (b) { c[(a + 20) >> 2] = b; c[(b + 24) >> 2] = a; i = h; b = g; } else { i = h; b = g; } } else { i = h; b = g; } } else { i = d; h = d; } while (0); if (h >>> 0 >= j >>> 0) return; a = (j + 4) | 0; e = c[a >> 2] | 0; if (!(e & 1)) return; if (!(e & 2)) { a = c[2788] | 0; if ((j | 0) == (c[2789] | 0)) { j = ((c[2786] | 0) + b) | 0; c[2786] = j; c[2789] = i; c[(i + 4) >> 2] = j | 1; if ((i | 0) != (a | 0)) return; c[2788] = 0; c[2785] = 0; return; } if ((j | 0) == (a | 0)) { j = ((c[2785] | 0) + b) | 0; c[2785] = j; c[2788] = h; c[(i + 4) >> 2] = j | 1; c[(h + j) >> 2] = j; return; } f = ((e & -8) + b) | 0; d = e >>> 3; do if (e >>> 0 < 256) { b = c[(j + 8) >> 2] | 0; a = c[(j + 12) >> 2] | 0; if ((a | 0) == (b | 0)) { c[2783] = c[2783] & ~(1 << d); break; } else { c[(b + 12) >> 2] = a; c[(a + 8) >> 2] = b; break; } } else { g = c[(j + 24) >> 2] | 0; a = c[(j + 12) >> 2] | 0; do if ((a | 0) == (j | 0)) { d = (j + 16) | 0; b = (d + 4) | 0; a = c[b >> 2] | 0; if (!a) { a = c[d >> 2] | 0; if (!a) { d = 0; break; } else b = d; } while (1) { d = (a + 20) | 0; e = c[d >> 2] | 0; if (e | 0) { a = e; b = d; continue; } d = (a + 16) | 0; e = c[d >> 2] | 0; if (!e) break; else { a = e; b = d; } } c[b >> 2] = 0; d = a; } else { d = c[(j + 8) >> 2] | 0; c[(d + 12) >> 2] = a; c[(a + 8) >> 2] = d; d = a; } while (0); if (g | 0) { a = c[(j + 28) >> 2] | 0; b = (11436 + (a << 2)) | 0; if ((j | 0) == (c[b >> 2] | 0)) { c[b >> 2] = d; if (!d) { c[2784] = c[2784] & ~(1 << a); break; } } else { c[ (g + 16 + ((((c[(g + 16) >> 2] | 0) != (j | 0)) & 1) << 2)) >> 2 ] = d; if (!d) break; } c[(d + 24) >> 2] = g; a = (j + 16) | 0; b = c[a >> 2] | 0; if (b | 0) { c[(d + 16) >> 2] = b; c[(b + 24) >> 2] = d; } a = c[(a + 4) >> 2] | 0; if (a | 0) { c[(d + 20) >> 2] = a; c[(a + 24) >> 2] = d; } } } while (0); c[(i + 4) >> 2] = f | 1; c[(h + f) >> 2] = f; if ((i | 0) == (c[2788] | 0)) { c[2785] = f; return; } } else { c[a >> 2] = e & -2; c[(i + 4) >> 2] = b | 1; c[(h + b) >> 2] = b; f = b; } a = f >>> 3; if (f >>> 0 < 256) { d = (11172 + ((a << 1) << 2)) | 0; b = c[2783] | 0; a = 1 << a; if (!(b & a)) { c[2783] = b | a; a = d; b = (d + 8) | 0; } else { b = (d + 8) | 0; a = c[b >> 2] | 0; } c[b >> 2] = i; c[(a + 12) >> 2] = i; c[(i + 8) >> 2] = a; c[(i + 12) >> 2] = d; return; } a = f >>> 8; if (a) { if (f >>> 0 > 16777215) a = 31; else { h = (((a + 1048320) | 0) >>> 16) & 8; j = a << h; g = (((j + 520192) | 0) >>> 16) & 4; j = j << g; a = (((j + 245760) | 0) >>> 16) & 2; a = (14 - (g | h | a) + ((j << a) >>> 15)) | 0; a = ((f >>> ((a + 7) | 0)) & 1) | (a << 1); } } else a = 0; e = (11436 + (a << 2)) | 0; c[(i + 28) >> 2] = a; c[(i + 20) >> 2] = 0; c[(i + 16) >> 2] = 0; b = c[2784] | 0; d = 1 << a; do if (b & d) { b = f << ((a | 0) == 31 ? 0 : (25 - (a >>> 1)) | 0); d = c[e >> 2] | 0; while (1) { if (((c[(d + 4) >> 2] & -8) | 0) == (f | 0)) { a = 73; break; } e = (d + 16 + ((b >>> 31) << 2)) | 0; a = c[e >> 2] | 0; if (!a) { a = 72; break; } else { b = b << 1; d = a; } } if ((a | 0) == 72) { c[e >> 2] = i; c[(i + 24) >> 2] = d; c[(i + 12) >> 2] = i; c[(i + 8) >> 2] = i; break; } else if ((a | 0) == 73) { h = (d + 8) | 0; j = c[h >> 2] | 0; c[(j + 12) >> 2] = i; c[h >> 2] = i; c[(i + 8) >> 2] = j; c[(i + 12) >> 2] = d; c[(i + 24) >> 2] = 0; break; } } else { c[2784] = b | d; c[e >> 2] = i; c[(i + 24) >> 2] = e; c[(i + 12) >> 2] = i; c[(i + 8) >> 2] = i; } while (0); j = ((c[2791] | 0) + -1) | 0; c[2791] = j; if (!j) a = 11588; else return; while (1) { a = c[a >> 2] | 0; if (!a) break; else a = (a + 8) | 0; } c[2791] = -1; return; } function qB() { return 11628; } function rB(a) { a = a | 0; var b = 0, d = 0; b = l; l = (l + 16) | 0; d = b; c[d >> 2] = yB(c[(a + 60) >> 2] | 0) | 0; a = uB(db(6, d | 0) | 0) | 0; l = b; return a | 0; } function sB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; n = l; l = (l + 48) | 0; k = (n + 16) | 0; g = n; f = (n + 32) | 0; i = (a + 28) | 0; e = c[i >> 2] | 0; c[f >> 2] = e; j = (a + 20) | 0; e = ((c[j >> 2] | 0) - e) | 0; c[(f + 4) >> 2] = e; c[(f + 8) >> 2] = b; c[(f + 12) >> 2] = d; e = (e + d) | 0; h = (a + 60) | 0; c[g >> 2] = c[h >> 2]; c[(g + 4) >> 2] = f; c[(g + 8) >> 2] = 2; g = uB(gb(146, g | 0) | 0) | 0; a: do if ((e | 0) != (g | 0)) { b = 2; while (1) { if ((g | 0) < 0) break; e = (e - g) | 0; p = c[(f + 4) >> 2] | 0; o = g >>> 0 > p >>> 0; f = o ? (f + 8) | 0 : f; b = (((o << 31) >> 31) + b) | 0; p = (g - (o ? p : 0)) | 0; c[f >> 2] = (c[f >> 2] | 0) + p; o = (f + 4) | 0; c[o >> 2] = (c[o >> 2] | 0) - p; c[k >> 2] = c[h >> 2]; c[(k + 4) >> 2] = f; c[(k + 8) >> 2] = b; g = uB(gb(146, k | 0) | 0) | 0; if ((e | 0) == (g | 0)) { m = 3; break a; } } c[(a + 16) >> 2] = 0; c[i >> 2] = 0; c[j >> 2] = 0; c[a >> 2] = c[a >> 2] | 32; if ((b | 0) == 2) d = 0; else d = (d - (c[(f + 4) >> 2] | 0)) | 0; } else m = 3; while (0); if ((m | 0) == 3) { p = c[(a + 44) >> 2] | 0; c[(a + 16) >> 2] = p + (c[(a + 48) >> 2] | 0); c[i >> 2] = p; c[j >> 2] = p; } l = n; return d | 0; } function tB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; f = l; l = (l + 32) | 0; g = f; e = (f + 20) | 0; c[g >> 2] = c[(a + 60) >> 2]; c[(g + 4) >> 2] = 0; c[(g + 8) >> 2] = b; c[(g + 12) >> 2] = e; c[(g + 16) >> 2] = d; if ((uB(fb(140, g | 0) | 0) | 0) < 0) { c[e >> 2] = -1; a = -1; } else a = c[e >> 2] | 0; l = f; return a | 0; } function uB(a) { a = a | 0; if (a >>> 0 > 4294963200) { c[(vB() | 0) >> 2] = 0 - a; a = -1; } return a | 0; } function vB() { return ((wB() | 0) + 64) | 0; } function wB() { return xB() | 0; } function xB() { return 2084; } function yB(a) { a = a | 0; return a | 0; } function zB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = (l + 32) | 0; f = g; c[(b + 36) >> 2] = 1; if ( ((c[b >> 2] & 64) | 0) == 0 ? ((c[f >> 2] = c[(b + 60) >> 2]), (c[(f + 4) >> 2] = 21523), (c[(f + 8) >> 2] = g + 16), Wa(54, f | 0) | 0) : 0 ) a[(b + 75) >> 0] = -1; f = sB(b, d, e) | 0; l = g; return f | 0; } function AB(b, c) { b = b | 0; c = c | 0; var d = 0, e = 0; d = a[b >> 0] | 0; e = a[c >> 0] | 0; if ((d << 24) >> 24 == 0 ? 1 : (d << 24) >> 24 != (e << 24) >> 24) b = e; else { do { b = (b + 1) | 0; c = (c + 1) | 0; d = a[b >> 0] | 0; e = a[c >> 0] | 0; } while ( !((d << 24) >> 24 == 0 ? 1 : (d << 24) >> 24 != (e << 24) >> 24) ); b = e; } return ((d & 255) - (b & 255)) | 0; } function BB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0, f = 0; a: do if (!d) b = 0; else { while (1) { e = a[b >> 0] | 0; f = a[c >> 0] | 0; if ((e << 24) >> 24 != (f << 24) >> 24) break; d = (d + -1) | 0; if (!d) { b = 0; break a; } else { b = (b + 1) | 0; c = (c + 1) | 0; } } b = ((e & 255) - (f & 255)) | 0; } while (0); return b | 0; } function CB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0; s = l; l = (l + 224) | 0; n = (s + 120) | 0; o = (s + 80) | 0; q = s; r = (s + 136) | 0; f = o; g = (f + 40) | 0; do { c[f >> 2] = 0; f = (f + 4) | 0; } while ((f | 0) < (g | 0)); c[n >> 2] = c[e >> 2]; if ((DB(0, d, n, q, o) | 0) < 0) e = -1; else { if ((c[(b + 76) >> 2] | 0) > -1) p = EB(b) | 0; else p = 0; e = c[b >> 2] | 0; m = e & 32; if ((a[(b + 74) >> 0] | 0) < 1) c[b >> 2] = e & -33; f = (b + 48) | 0; if (!(c[f >> 2] | 0)) { g = (b + 44) | 0; h = c[g >> 2] | 0; c[g >> 2] = r; i = (b + 28) | 0; c[i >> 2] = r; j = (b + 20) | 0; c[j >> 2] = r; c[f >> 2] = 80; k = (b + 16) | 0; c[k >> 2] = r + 80; e = DB(b, d, n, q, o) | 0; if (h) { sb[c[(b + 36) >> 2] & 7](b, 0, 0) | 0; e = (c[j >> 2] | 0) == 0 ? -1 : e; c[g >> 2] = h; c[f >> 2] = 0; c[k >> 2] = 0; c[i >> 2] = 0; c[j >> 2] = 0; } } else e = DB(b, d, n, q, o) | 0; f = c[b >> 2] | 0; c[b >> 2] = f | m; if (p | 0) FB(b); e = ((f & 32) | 0) == 0 ? e : -1; } l = s; return e | 0; } function DB(d, e, f, g, i) { d = d | 0; e = e | 0; f = f | 0; g = g | 0; i = i | 0; var j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; H = l; l = (l + 64) | 0; D = (H + 16) | 0; E = H; B = (H + 24) | 0; F = (H + 8) | 0; G = (H + 20) | 0; c[D >> 2] = e; x = (d | 0) != 0; y = (B + 40) | 0; z = y; B = (B + 39) | 0; C = (F + 4) | 0; k = 0; j = 0; p = 0; a: while (1) { do if ((j | 0) > -1) if ((k | 0) > ((2147483647 - j) | 0)) { c[(vB() | 0) >> 2] = 75; j = -1; break; } else { j = (k + j) | 0; break; } while (0); k = a[e >> 0] | 0; if (!((k << 24) >> 24)) { w = 87; break; } else m = e; b: while (1) { switch ((k << 24) >> 24) { case 37: { k = m; w = 9; break b; } case 0: { k = m; break b; } default: { } } v = (m + 1) | 0; c[D >> 2] = v; k = a[v >> 0] | 0; m = v; } c: do if ((w | 0) == 9) while (1) { w = 0; if ((a[(m + 1) >> 0] | 0) != 37) break c; k = (k + 1) | 0; m = (m + 2) | 0; c[D >> 2] = m; if ((a[m >> 0] | 0) == 37) w = 9; else break; } while (0); k = (k - e) | 0; if (x) GB(d, e, k); if (k | 0) { e = m; continue; } n = (m + 1) | 0; k = ((a[n >> 0] | 0) + -48) | 0; if (k >>> 0 < 10) { v = (a[(m + 2) >> 0] | 0) == 36; u = v ? k : -1; p = v ? 1 : p; n = v ? (m + 3) | 0 : n; } else u = -1; c[D >> 2] = n; k = a[n >> 0] | 0; m = (((k << 24) >> 24) + -32) | 0; d: do if (m >>> 0 < 32) { o = 0; q = k; while (1) { k = 1 << m; if (!(k & 75913)) { k = q; break d; } o = k | o; n = (n + 1) | 0; c[D >> 2] = n; k = a[n >> 0] | 0; m = (((k << 24) >> 24) + -32) | 0; if (m >>> 0 >= 32) break; else q = k; } } else o = 0; while (0); if ((k << 24) >> 24 == 42) { m = (n + 1) | 0; k = ((a[m >> 0] | 0) + -48) | 0; if (k >>> 0 < 10 ? (a[(n + 2) >> 0] | 0) == 36 : 0) { c[(i + (k << 2)) >> 2] = 10; k = c[(g + (((a[m >> 0] | 0) + -48) << 3)) >> 2] | 0; p = 1; n = (n + 3) | 0; } else { if (p | 0) { j = -1; break; } if (x) { p = ((c[f >> 2] | 0) + (4 - 1)) & ~(4 - 1); k = c[p >> 2] | 0; c[f >> 2] = p + 4; p = 0; n = m; } else { k = 0; p = 0; n = m; } } c[D >> 2] = n; v = (k | 0) < 0; k = v ? (0 - k) | 0 : k; o = v ? o | 8192 : o; } else { k = HB(D) | 0; if ((k | 0) < 0) { j = -1; break; } n = c[D >> 2] | 0; } do if ((a[n >> 0] | 0) == 46) { if ((a[(n + 1) >> 0] | 0) != 42) { c[D >> 2] = n + 1; m = HB(D) | 0; n = c[D >> 2] | 0; break; } q = (n + 2) | 0; m = ((a[q >> 0] | 0) + -48) | 0; if (m >>> 0 < 10 ? (a[(n + 3) >> 0] | 0) == 36 : 0) { c[(i + (m << 2)) >> 2] = 10; m = c[(g + (((a[q >> 0] | 0) + -48) << 3)) >> 2] | 0; n = (n + 4) | 0; c[D >> 2] = n; break; } if (p | 0) { j = -1; break a; } if (x) { v = ((c[f >> 2] | 0) + (4 - 1)) & ~(4 - 1); m = c[v >> 2] | 0; c[f >> 2] = v + 4; } else m = 0; c[D >> 2] = q; n = q; } else m = -1; while (0); t = 0; while (1) { if ((((a[n >> 0] | 0) + -65) | 0) >>> 0 > 57) { j = -1; break a; } v = (n + 1) | 0; c[D >> 2] = v; q = a[((a[n >> 0] | 0) + -65 + (5178 + ((t * 58) | 0))) >> 0] | 0; r = q & 255; if (((r + -1) | 0) >>> 0 < 8) { t = r; n = v; } else break; } if (!((q << 24) >> 24)) { j = -1; break; } s = (u | 0) > -1; do if ((q << 24) >> 24 == 19) { if (s) { j = -1; break a; } else w = 49; } else { if (s) { c[(i + (u << 2)) >> 2] = r; s = (g + (u << 3)) | 0; u = c[(s + 4) >> 2] | 0; w = E; c[w >> 2] = c[s >> 2]; c[(w + 4) >> 2] = u; w = 49; break; } if (!x) { j = 0; break a; } IB(E, r, f); } while (0); if ((w | 0) == 49 ? ((w = 0), !x) : 0) { k = 0; e = v; continue; } n = a[n >> 0] | 0; n = ((t | 0) != 0) & (((n & 15) | 0) == 3) ? n & -33 : n; s = o & -65537; u = ((o & 8192) | 0) == 0 ? o : s; e: do switch (n | 0) { case 110: switch (((t & 255) << 24) >> 24) { case 0: { c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; } case 1: { c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; } case 2: { k = c[E >> 2] | 0; c[k >> 2] = j; c[(k + 4) >> 2] = (((j | 0) < 0) << 31) >> 31; k = 0; e = v; continue a; } case 3: { b[c[E >> 2] >> 1] = j; k = 0; e = v; continue a; } case 4: { a[c[E >> 2] >> 0] = j; k = 0; e = v; continue a; } case 6: { c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; } case 7: { k = c[E >> 2] | 0; c[k >> 2] = j; c[(k + 4) >> 2] = (((j | 0) < 0) << 31) >> 31; k = 0; e = v; continue a; } default: { k = 0; e = v; continue a; } } case 112: { n = 120; m = m >>> 0 > 8 ? m : 8; e = u | 8; w = 61; break; } case 88: case 120: { e = u; w = 61; break; } case 111: { n = E; e = c[n >> 2] | 0; n = c[(n + 4) >> 2] | 0; r = KB(e, n, y) | 0; s = (z - r) | 0; o = 0; q = 5642; m = (((u & 8) | 0) == 0) | ((m | 0) > (s | 0)) ? m : (s + 1) | 0; s = u; w = 67; break; } case 105: case 100: { n = E; e = c[n >> 2] | 0; n = c[(n + 4) >> 2] | 0; if ((n | 0) < 0) { e = wC(0, 0, e | 0, n | 0) | 0; n = A; o = E; c[o >> 2] = e; c[(o + 4) >> 2] = n; o = 1; q = 5642; w = 66; break e; } else { o = (((u & 2049) | 0) != 0) & 1; q = ((u & 2048) | 0) == 0 ? ((u & 1) | 0) == 0 ? 5642 : 5644 : 5643; w = 66; break e; } } case 117: { n = E; o = 0; q = 5642; e = c[n >> 2] | 0; n = c[(n + 4) >> 2] | 0; w = 66; break; } case 99: { a[B >> 0] = c[E >> 2]; e = B; o = 0; q = 5642; r = y; n = 1; m = s; break; } case 109: { n = MB(c[(vB() | 0) >> 2] | 0) | 0; w = 71; break; } case 115: { n = c[E >> 2] | 0; n = n | 0 ? n : 5652; w = 71; break; } case 67: { c[F >> 2] = c[E >> 2]; c[C >> 2] = 0; c[E >> 2] = F; r = -1; n = F; w = 75; break; } case 83: { e = c[E >> 2] | 0; if (!m) { OB(d, 32, k, 0, u); e = 0; w = 84; } else { r = m; n = e; w = 75; } break; } case 65: case 71: case 70: case 69: case 97: case 103: case 102: case 101: { k = QB(d, +h[E >> 3], k, m, u, n) | 0; e = v; continue a; } default: { o = 0; q = 5642; r = y; n = m; m = u; } } while (0); f: do if ((w | 0) == 61) { u = E; t = c[u >> 2] | 0; u = c[(u + 4) >> 2] | 0; r = JB(t, u, y, n & 32) | 0; q = (((e & 8) | 0) == 0) | (((t | 0) == 0) & ((u | 0) == 0)); o = q ? 0 : 2; q = q ? 5642 : (5642 + (n >> 4)) | 0; s = e; e = t; n = u; w = 67; } else if ((w | 0) == 66) { r = LB(e, n, y) | 0; s = u; w = 67; } else if ((w | 0) == 71) { w = 0; u = NB(n, 0, m) | 0; t = (u | 0) == 0; e = n; o = 0; q = 5642; r = t ? (n + m) | 0 : u; n = t ? m : (u - n) | 0; m = s; } else if ((w | 0) == 75) { w = 0; q = n; e = 0; m = 0; while (1) { o = c[q >> 2] | 0; if (!o) break; m = PB(G, o) | 0; if (((m | 0) < 0) | (m >>> 0 > ((r - e) | 0) >>> 0)) break; e = (m + e) | 0; if (r >>> 0 > e >>> 0) q = (q + 4) | 0; else break; } if ((m | 0) < 0) { j = -1; break a; } OB(d, 32, k, e, u); if (!e) { e = 0; w = 84; } else { o = 0; while (1) { m = c[n >> 2] | 0; if (!m) { w = 84; break f; } m = PB(G, m) | 0; o = (m + o) | 0; if ((o | 0) > (e | 0)) { w = 84; break f; } GB(d, G, m); if (o >>> 0 >= e >>> 0) { w = 84; break; } else n = (n + 4) | 0; } } } while (0); if ((w | 0) == 67) { w = 0; n = ((e | 0) != 0) | ((n | 0) != 0); u = ((m | 0) != 0) | n; n = (((n ^ 1) & 1) + (z - r)) | 0; e = u ? r : y; r = y; n = u ? ((m | 0) > (n | 0) ? m : n) : m; m = (m | 0) > -1 ? s & -65537 : s; } else if ((w | 0) == 84) { w = 0; OB(d, 32, k, e, u ^ 8192); k = (k | 0) > (e | 0) ? k : e; e = v; continue; } t = (r - e) | 0; s = (n | 0) < (t | 0) ? t : n; u = (s + o) | 0; k = (k | 0) < (u | 0) ? u : k; OB(d, 32, k, u, m); GB(d, q, o); OB(d, 48, k, u, m ^ 65536); OB(d, 48, s, t, 0); GB(d, e, t); OB(d, 32, k, u, m ^ 8192); e = v; } g: do if ((w | 0) == 87) if (!d) if (!p) j = 0; else { j = 1; while (1) { e = c[(i + (j << 2)) >> 2] | 0; if (!e) break; IB((g + (j << 3)) | 0, e, f); j = (j + 1) | 0; if ((j | 0) >= 10) { j = 1; break g; } } while (1) { if (c[(i + (j << 2)) >> 2] | 0) { j = -1; break g; } j = (j + 1) | 0; if ((j | 0) >= 10) { j = 1; break; } } } while (0); l = H; return j | 0; } function EB(a) { a = a | 0; return 0; } function FB(a) { a = a | 0; return; } function GB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; if (!(c[a >> 2] & 32)) aC(b, d, a) | 0; return; } function HB(b) { b = b | 0; var d = 0, e = 0, f = 0; e = c[b >> 2] | 0; f = ((a[e >> 0] | 0) + -48) | 0; if (f >>> 0 < 10) { d = 0; do { d = (f + ((d * 10) | 0)) | 0; e = (e + 1) | 0; c[b >> 2] = e; f = ((a[e >> 0] | 0) + -48) | 0; } while (f >>> 0 < 10); } else d = 0; return d | 0; } function IB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0.0; a: do if (b >>> 0 <= 20) do switch (b | 0) { case 9: { e = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); b = c[e >> 2] | 0; c[d >> 2] = e + 4; c[a >> 2] = b; break a; } case 10: { e = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); b = c[e >> 2] | 0; c[d >> 2] = e + 4; e = a; c[e >> 2] = b; c[(e + 4) >> 2] = (((b | 0) < 0) << 31) >> 31; break a; } case 11: { e = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); b = c[e >> 2] | 0; c[d >> 2] = e + 4; e = a; c[e >> 2] = b; c[(e + 4) >> 2] = 0; break a; } case 12: { e = ((c[d >> 2] | 0) + (8 - 1)) & ~(8 - 1); b = e; f = c[b >> 2] | 0; b = c[(b + 4) >> 2] | 0; c[d >> 2] = e + 8; e = a; c[e >> 2] = f; c[(e + 4) >> 2] = b; break a; } case 13: { f = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); e = c[f >> 2] | 0; c[d >> 2] = f + 4; e = ((e & 65535) << 16) >> 16; f = a; c[f >> 2] = e; c[(f + 4) >> 2] = (((e | 0) < 0) << 31) >> 31; break a; } case 14: { f = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); e = c[f >> 2] | 0; c[d >> 2] = f + 4; f = a; c[f >> 2] = e & 65535; c[(f + 4) >> 2] = 0; break a; } case 15: { f = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); e = c[f >> 2] | 0; c[d >> 2] = f + 4; e = ((e & 255) << 24) >> 24; f = a; c[f >> 2] = e; c[(f + 4) >> 2] = (((e | 0) < 0) << 31) >> 31; break a; } case 16: { f = ((c[d >> 2] | 0) + (4 - 1)) & ~(4 - 1); e = c[f >> 2] | 0; c[d >> 2] = f + 4; f = a; c[f >> 2] = e & 255; c[(f + 4) >> 2] = 0; break a; } case 17: { f = ((c[d >> 2] | 0) + (8 - 1)) & ~(8 - 1); g = +h[f >> 3]; c[d >> 2] = f + 8; h[a >> 3] = g; break a; } case 18: { f = ((c[d >> 2] | 0) + (8 - 1)) & ~(8 - 1); g = +h[f >> 3]; c[d >> 2] = f + 8; h[a >> 3] = g; break a; } default: break a; } while (0); while (0); return; } function JB(b, c, e, f) { b = b | 0; c = c | 0; e = e | 0; f = f | 0; if (!(((b | 0) == 0) & ((c | 0) == 0))) do { e = (e + -1) | 0; a[e >> 0] = d[(5694 + (b & 15)) >> 0] | 0 | f; b = AC(b | 0, c | 0, 4) | 0; c = A; } while (!(((b | 0) == 0) & ((c | 0) == 0))); return e | 0; } function KB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; if (!(((b | 0) == 0) & ((c | 0) == 0))) do { d = (d + -1) | 0; a[d >> 0] = (b & 7) | 48; b = AC(b | 0, c | 0, 3) | 0; c = A; } while (!(((b | 0) == 0) & ((c | 0) == 0))); return d | 0; } function LB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0; if ((c >>> 0 > 0) | (((c | 0) == 0) & (b >>> 0 > 4294967295))) { while (1) { e = HC(b | 0, c | 0, 10, 0) | 0; d = (d + -1) | 0; a[d >> 0] = (e & 255) | 48; e = b; b = EC(b | 0, c | 0, 10, 0) | 0; if ( !((c >>> 0 > 9) | (((c | 0) == 9) & (e >>> 0 > 4294967295))) ) break; else c = A; } c = b; } else c = b; if (c) while (1) { d = (d + -1) | 0; a[d >> 0] = (c >>> 0) % 10 | 0 | 48; if (c >>> 0 < 10) break; else c = ((c >>> 0) / 10) | 0; } return d | 0; } function MB(a) { a = a | 0; return XB(a, c[((WB() | 0) + 188) >> 2] | 0) | 0; } function NB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = d & 255; f = (e | 0) != 0; a: do if (f & (((b & 3) | 0) != 0)) { g = d & 255; while (1) { if ((a[b >> 0] | 0) == (g << 24) >> 24) { i = 6; break a; } b = (b + 1) | 0; e = (e + -1) | 0; f = (e | 0) != 0; if (!(f & (((b & 3) | 0) != 0))) { i = 5; break; } } } else i = 5; while (0); if ((i | 0) == 5) if (f) i = 6; else e = 0; b: do if ((i | 0) == 6) { g = d & 255; if ((a[b >> 0] | 0) != (g << 24) >> 24) { f = P(h, 16843009) | 0; c: do if (e >>> 0 > 3) while (1) { h = c[b >> 2] ^ f; if ( (((h & -2139062144) ^ -2139062144) & (h + -16843009)) | 0 ) break; b = (b + 4) | 0; e = (e + -4) | 0; if (e >>> 0 <= 3) { i = 11; break c; } } else i = 11; while (0); if ((i | 0) == 11) if (!e) { e = 0; break; } while (1) { if ((a[b >> 0] | 0) == (g << 24) >> 24) break b; b = (b + 1) | 0; e = (e + -1) | 0; if (!e) { e = 0; break; } } } } while (0); return (e | 0 ? b : 0) | 0; } function OB(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = (l + 256) | 0; f = g; if (((c | 0) > (d | 0)) & (((e & 73728) | 0) == 0)) { e = (c - d) | 0; yC(f | 0, b | 0, (e >>> 0 < 256 ? e : 256) | 0) | 0; if (e >>> 0 > 255) { b = (c - d) | 0; do { GB(a, f, 256); e = (e + -256) | 0; } while (e >>> 0 > 255); e = b & 255; } GB(a, f, e); } l = g; return; } function PB(a, b) { a = a | 0; b = b | 0; if (!a) a = 0; else a = UB(a, b, 0) | 0; return a | 0; } function QB(b, e, f, g, h, i) { b = b | 0; e = +e; f = f | 0; g = g | 0; h = h | 0; i = i | 0; var j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0.0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; H = l; l = (l + 560) | 0; m = (H + 8) | 0; u = H; G = (H + 524) | 0; F = G; n = (H + 512) | 0; c[u >> 2] = 0; E = (n + 12) | 0; RB(e) | 0; if ((A | 0) < 0) { e = -e; C = 1; B = 5659; } else { C = (((h & 2049) | 0) != 0) & 1; B = ((h & 2048) | 0) == 0 ? ((h & 1) | 0) == 0 ? 5660 : 5665 : 5662; } RB(e) | 0; D = A & 2146435072; do if ((D >>> 0 < 2146435072) | (((D | 0) == 2146435072) & (0 < 0))) { r = +SB(e, u) * 2.0; j = r != 0.0; if (j) c[u >> 2] = (c[u >> 2] | 0) + -1; w = i | 32; if ((w | 0) == 97) { s = i & 32; q = (s | 0) == 0 ? B : (B + 9) | 0; p = C | 2; j = (12 - g) | 0; do if (!((g >>> 0 > 11) | ((j | 0) == 0))) { e = 8.0; do { j = (j + -1) | 0; e = e * 16.0; } while ((j | 0) != 0); if ((a[q >> 0] | 0) == 45) { e = -(e + (-r - e)); break; } else { e = r + e - e; break; } } else e = r; while (0); k = c[u >> 2] | 0; j = (k | 0) < 0 ? (0 - k) | 0 : k; j = LB(j, (((j | 0) < 0) << 31) >> 31, E) | 0; if ((j | 0) == (E | 0)) { j = (n + 11) | 0; a[j >> 0] = 48; } a[(j + -1) >> 0] = ((k >> 31) & 2) + 43; o = (j + -2) | 0; a[o >> 0] = i + 15; n = (g | 0) < 1; m = ((h & 8) | 0) == 0; j = G; do { D = ~~e; k = (j + 1) | 0; a[j >> 0] = d[(5694 + D) >> 0] | s; e = (e - +(D | 0)) * 16.0; if (((k - F) | 0) == 1 ? !(m & (n & (e == 0.0))) : 0) { a[k >> 0] = 46; j = (j + 2) | 0; } else j = k; } while (e != 0.0); D = (j - F) | 0; F = (E - o) | 0; E = ((g | 0) != 0) & (((D + -2) | 0) < (g | 0)) ? (g + 2) | 0 : D; j = (F + p + E) | 0; OB(b, 32, f, j, h); GB(b, q, p); OB(b, 48, f, j, h ^ 65536); GB(b, G, D); OB(b, 48, (E - D) | 0, 0, 0); GB(b, o, F); OB(b, 32, f, j, h ^ 8192); break; } k = (g | 0) < 0 ? 6 : g; if (j) { j = ((c[u >> 2] | 0) + -28) | 0; c[u >> 2] = j; e = r * 268435456.0; } else { e = r; j = c[u >> 2] | 0; } D = (j | 0) < 0 ? m : (m + 288) | 0; m = D; do { y = ~~e >>> 0; c[m >> 2] = y; m = (m + 4) | 0; e = (e - +(y >>> 0)) * 1.0e9; } while (e != 0.0); if ((j | 0) > 0) { n = D; p = m; while (1) { o = (j | 0) < 29 ? j : 29; j = (p + -4) | 0; if (j >>> 0 >= n >>> 0) { m = 0; do { x = zC(c[j >> 2] | 0, 0, o | 0) | 0; x = xC(x | 0, A | 0, m | 0, 0) | 0; y = A; v = HC(x | 0, y | 0, 1e9, 0) | 0; c[j >> 2] = v; m = EC(x | 0, y | 0, 1e9, 0) | 0; j = (j + -4) | 0; } while (j >>> 0 >= n >>> 0); if (m) { n = (n + -4) | 0; c[n >> 2] = m; } } m = p; while (1) { if (m >>> 0 <= n >>> 0) break; j = (m + -4) | 0; if (!(c[j >> 2] | 0)) m = j; else break; } j = ((c[u >> 2] | 0) - o) | 0; c[u >> 2] = j; if ((j | 0) > 0) p = m; else break; } } else n = D; if ((j | 0) < 0) { g = (((((k + 25) | 0) / 9) | 0) + 1) | 0; t = (w | 0) == 102; do { s = (0 - j) | 0; s = (s | 0) < 9 ? s : 9; if (n >>> 0 < m >>> 0) { o = ((1 << s) + -1) | 0; p = 1e9 >>> s; q = 0; j = n; do { y = c[j >> 2] | 0; c[j >> 2] = (y >>> s) + q; q = P(y & o, p) | 0; j = (j + 4) | 0; } while (j >>> 0 < m >>> 0); j = (c[n >> 2] | 0) == 0 ? (n + 4) | 0 : n; if (!q) { n = j; j = m; } else { c[m >> 2] = q; n = j; j = (m + 4) | 0; } } else { n = (c[n >> 2] | 0) == 0 ? (n + 4) | 0 : n; j = m; } m = t ? D : n; m = (((j - m) >> 2) | 0) > (g | 0) ? (m + (g << 2)) | 0 : j; j = ((c[u >> 2] | 0) + s) | 0; c[u >> 2] = j; } while ((j | 0) < 0); j = n; g = m; } else { j = n; g = m; } y = D; if (j >>> 0 < g >>> 0) { m = (((y - j) >> 2) * 9) | 0; o = c[j >> 2] | 0; if (o >>> 0 >= 10) { n = 10; do { n = (n * 10) | 0; m = (m + 1) | 0; } while (o >>> 0 >= n >>> 0); } } else m = 0; t = (w | 0) == 103; v = (k | 0) != 0; n = (k - ((w | 0) != 102 ? m : 0) + (((v & t) << 31) >> 31)) | 0; if ((n | 0) < ((((((g - y) >> 2) * 9) | 0) + -9) | 0)) { n = (n + 9216) | 0; s = (D + 4 + (((((n | 0) / 9) | 0) + -1024) << 2)) | 0; n = (((n | 0) % 9 | 0) + 1) | 0; if ((n | 0) < 9) { o = 10; do { o = (o * 10) | 0; n = (n + 1) | 0; } while ((n | 0) != 9); } else o = 10; p = c[s >> 2] | 0; q = (p >>> 0) % (o >>> 0) | 0; n = ((s + 4) | 0) == (g | 0); if (!(n & ((q | 0) == 0))) { r = (((((p >>> 0) / (o >>> 0)) | 0) & 1) | 0) == 0 ? 9007199254740992.0 : 9007199254740994.0; x = ((o | 0) / 2) | 0; e = q >>> 0 < x >>> 0 ? 0.5 : n & ((q | 0) == (x | 0)) ? 1.0 : 1.5; if (C) { x = (a[B >> 0] | 0) == 45; e = x ? -e : e; r = x ? -r : r; } n = (p - q) | 0; c[s >> 2] = n; if (r + e != r) { x = (n + o) | 0; c[s >> 2] = x; if (x >>> 0 > 999999999) { m = s; while (1) { n = (m + -4) | 0; c[m >> 2] = 0; if (n >>> 0 < j >>> 0) { j = (j + -4) | 0; c[j >> 2] = 0; } x = ((c[n >> 2] | 0) + 1) | 0; c[n >> 2] = x; if (x >>> 0 > 999999999) m = n; else break; } } else n = s; m = (((y - j) >> 2) * 9) | 0; p = c[j >> 2] | 0; if (p >>> 0 >= 10) { o = 10; do { o = (o * 10) | 0; m = (m + 1) | 0; } while (p >>> 0 >= o >>> 0); } } else n = s; } else n = s; n = (n + 4) | 0; n = g >>> 0 > n >>> 0 ? n : g; x = j; } else { n = g; x = j; } w = n; while (1) { if (w >>> 0 <= x >>> 0) { u = 0; break; } j = (w + -4) | 0; if (!(c[j >> 2] | 0)) w = j; else { u = 1; break; } } g = (0 - m) | 0; do if (t) { j = (((v ^ 1) & 1) + k) | 0; if (((j | 0) > (m | 0)) & ((m | 0) > -5)) { o = (i + -1) | 0; k = (j + -1 - m) | 0; } else { o = (i + -2) | 0; k = (j + -1) | 0; } j = h & 8; if (!j) { if ( u ? ((z = c[(w + -4) >> 2] | 0), (z | 0) != 0) : 0 ) { if (!((z >>> 0) % 10 | 0)) { n = 0; j = 10; do { j = (j * 10) | 0; n = (n + 1) | 0; } while (!((z >>> 0) % (j >>> 0) | 0 | 0)); } else n = 0; } else n = 9; j = (((((w - y) >> 2) * 9) | 0) + -9) | 0; if ((o | 32 | 0) == 102) { s = (j - n) | 0; s = (s | 0) > 0 ? s : 0; k = (k | 0) < (s | 0) ? k : s; s = 0; break; } else { s = (j + m - n) | 0; s = (s | 0) > 0 ? s : 0; k = (k | 0) < (s | 0) ? k : s; s = 0; break; } } else s = j; } else { o = i; s = h & 8; } while (0); t = k | s; p = ((t | 0) != 0) & 1; q = (o | 32 | 0) == 102; if (q) { v = 0; j = (m | 0) > 0 ? m : 0; } else { j = (m | 0) < 0 ? g : m; j = LB(j, (((j | 0) < 0) << 31) >> 31, E) | 0; n = E; if (((n - j) | 0) < 2) do { j = (j + -1) | 0; a[j >> 0] = 48; } while (((n - j) | 0) < 2); a[(j + -1) >> 0] = ((m >> 31) & 2) + 43; j = (j + -2) | 0; a[j >> 0] = o; v = j; j = (n - j) | 0; } j = (C + 1 + k + p + j) | 0; OB(b, 32, f, j, h); GB(b, B, C); OB(b, 48, f, j, h ^ 65536); if (q) { o = x >>> 0 > D >>> 0 ? D : x; s = (G + 9) | 0; p = s; q = (G + 8) | 0; n = o; do { m = LB(c[n >> 2] | 0, 0, s) | 0; if ((n | 0) == (o | 0)) { if ((m | 0) == (s | 0)) { a[q >> 0] = 48; m = q; } } else if (m >>> 0 > G >>> 0) { yC(G | 0, 48, (m - F) | 0) | 0; do m = (m + -1) | 0; while (m >>> 0 > G >>> 0); } GB(b, m, (p - m) | 0); n = (n + 4) | 0; } while (n >>> 0 <= D >>> 0); if (t | 0) GB(b, 5710, 1); if ((n >>> 0 < w >>> 0) & ((k | 0) > 0)) while (1) { m = LB(c[n >> 2] | 0, 0, s) | 0; if (m >>> 0 > G >>> 0) { yC(G | 0, 48, (m - F) | 0) | 0; do m = (m + -1) | 0; while (m >>> 0 > G >>> 0); } GB(b, m, (k | 0) < 9 ? k : 9); n = (n + 4) | 0; m = (k + -9) | 0; if (!((n >>> 0 < w >>> 0) & ((k | 0) > 9))) { k = m; break; } else k = m; } OB(b, 48, (k + 9) | 0, 9, 0); } else { t = u ? w : (x + 4) | 0; if ((k | 0) > -1) { u = (G + 9) | 0; s = (s | 0) == 0; g = u; p = (0 - F) | 0; q = (G + 8) | 0; o = x; do { m = LB(c[o >> 2] | 0, 0, u) | 0; if ((m | 0) == (u | 0)) { a[q >> 0] = 48; m = q; } do if ((o | 0) == (x | 0)) { n = (m + 1) | 0; GB(b, m, 1); if (s & ((k | 0) < 1)) { m = n; break; } GB(b, 5710, 1); m = n; } else { if (m >>> 0 <= G >>> 0) break; yC(G | 0, 48, (m + p) | 0) | 0; do m = (m + -1) | 0; while (m >>> 0 > G >>> 0); } while (0); F = (g - m) | 0; GB(b, m, (k | 0) > (F | 0) ? F : k); k = (k - F) | 0; o = (o + 4) | 0; } while ((o >>> 0 < t >>> 0) & ((k | 0) > -1)); } OB(b, 48, (k + 18) | 0, 18, 0); GB(b, v, (E - v) | 0); } OB(b, 32, f, j, h ^ 8192); } else { G = ((i & 32) | 0) != 0; j = (C + 3) | 0; OB(b, 32, f, j, h & -65537); GB(b, B, C); GB( b, (e != e) | (0.0 != 0.0) ? G ? 5686 : 5690 : G ? 5678 : 5682, 3 ); OB(b, 32, f, j, h ^ 8192); } while (0); l = H; return ((j | 0) < (f | 0) ? f : j) | 0; } function RB(a) { a = +a; var b = 0; h[j >> 3] = a; b = c[j >> 2] | 0; A = c[(j + 4) >> 2] | 0; return b | 0; } function SB(a, b) { a = +a; b = b | 0; return +(+TB(a, b)); } function TB(a, b) { a = +a; b = b | 0; var d = 0, e = 0, f = 0; h[j >> 3] = a; d = c[j >> 2] | 0; e = c[(j + 4) >> 2] | 0; f = AC(d | 0, e | 0, 52) | 0; switch (f & 2047) { case 0: { if (a != 0.0) { a = +TB(a * 18446744073709551616.0, b); d = ((c[b >> 2] | 0) + -64) | 0; } else d = 0; c[b >> 2] = d; break; } case 2047: break; default: { c[b >> 2] = (f & 2047) + -1022; c[j >> 2] = d; c[(j + 4) >> 2] = (e & -2146435073) | 1071644672; a = +h[j >> 3]; } } return +a; } function UB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; do if (b) { if (d >>> 0 < 128) { a[b >> 0] = d; b = 1; break; } if (!(c[c[((VB() | 0) + 188) >> 2] >> 2] | 0)) if (((d & -128) | 0) == 57216) { a[b >> 0] = d; b = 1; break; } else { c[(vB() | 0) >> 2] = 84; b = -1; break; } if (d >>> 0 < 2048) { a[b >> 0] = (d >>> 6) | 192; a[(b + 1) >> 0] = (d & 63) | 128; b = 2; break; } if ((d >>> 0 < 55296) | (((d & -8192) | 0) == 57344)) { a[b >> 0] = (d >>> 12) | 224; a[(b + 1) >> 0] = ((d >>> 6) & 63) | 128; a[(b + 2) >> 0] = (d & 63) | 128; b = 3; break; } if (((d + -65536) | 0) >>> 0 < 1048576) { a[b >> 0] = (d >>> 18) | 240; a[(b + 1) >> 0] = ((d >>> 12) & 63) | 128; a[(b + 2) >> 0] = ((d >>> 6) & 63) | 128; a[(b + 3) >> 0] = (d & 63) | 128; b = 4; break; } else { c[(vB() | 0) >> 2] = 84; b = -1; break; } } else b = 1; while (0); return b | 0; } function VB() { return xB() | 0; } function WB() { return xB() | 0; } function XB(b, e) { b = b | 0; e = e | 0; var f = 0, g = 0; g = 0; while (1) { if ((d[(5712 + g) >> 0] | 0) == (b | 0)) { b = 2; break; } f = (g + 1) | 0; if ((f | 0) == 87) { f = 5800; g = 87; b = 5; break; } else g = f; } if ((b | 0) == 2) if (!g) f = 5800; else { f = 5800; b = 5; } if ((b | 0) == 5) while (1) { do { b = f; f = (f + 1) | 0; } while ((a[b >> 0] | 0) != 0); g = (g + -1) | 0; if (!g) break; else b = 5; } return YB(f, c[(e + 20) >> 2] | 0) | 0; } function YB(a, b) { a = a | 0; b = b | 0; return ZB(a, b) | 0; } function ZB(a, b) { a = a | 0; b = b | 0; if (!b) b = 0; else b = _B(c[b >> 2] | 0, c[(b + 4) >> 2] | 0, a) | 0; return (b | 0 ? b : a) | 0; } function _B(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0; o = ((c[b >> 2] | 0) + 1794895138) | 0; h = $B(c[(b + 8) >> 2] | 0, o) | 0; f = $B(c[(b + 12) >> 2] | 0, o) | 0; g = $B(c[(b + 16) >> 2] | 0, o) | 0; a: do if ( ( h >>> 0 < (d >>> 2) >>> 0 ? ((n = (d - (h << 2)) | 0), (f >>> 0 < n >>> 0) & (g >>> 0 < n >>> 0)) : 0 ) ? (((g | f) & 3) | 0) == 0 : 0 ) { n = f >>> 2; m = g >>> 2; l = 0; while (1) { j = h >>> 1; k = (l + j) | 0; i = k << 1; g = (i + n) | 0; f = $B(c[(b + (g << 2)) >> 2] | 0, o) | 0; g = $B(c[(b + ((g + 1) << 2)) >> 2] | 0, o) | 0; if ( !((g >>> 0 < d >>> 0) & (f >>> 0 < ((d - g) | 0) >>> 0)) ) { f = 0; break a; } if (a[(b + (g + f)) >> 0] | 0) { f = 0; break a; } f = AB(e, (b + g) | 0) | 0; if (!f) break; f = (f | 0) < 0; if ((h | 0) == 1) { f = 0; break a; } else { l = f ? l : k; h = f ? j : (h - j) | 0; } } f = (i + m) | 0; g = $B(c[(b + (f << 2)) >> 2] | 0, o) | 0; f = $B(c[(b + ((f + 1) << 2)) >> 2] | 0, o) | 0; if ((f >>> 0 < d >>> 0) & (g >>> 0 < ((d - f) | 0) >>> 0)) f = (a[(b + (f + g)) >> 0] | 0) == 0 ? (b + f) | 0 : 0; else f = 0; } else f = 0; while (0); return f | 0; } function $B(a, b) { a = a | 0; b = b | 0; var c = 0; c = IC(a | 0) | 0; return ((b | 0) == 0 ? a : c) | 0; } function aC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0; f = (e + 16) | 0; g = c[f >> 2] | 0; if (!g) { if (!(bC(e) | 0)) { g = c[f >> 2] | 0; h = 5; } else f = 0; } else h = 5; a: do if ((h | 0) == 5) { j = (e + 20) | 0; i = c[j >> 2] | 0; f = i; if (((g - i) | 0) >>> 0 < d >>> 0) { f = sb[c[(e + 36) >> 2] & 7](e, b, d) | 0; break; } b: do if ((a[(e + 75) >> 0] | 0) > -1) { i = d; while (1) { if (!i) { h = 0; g = b; break b; } g = (i + -1) | 0; if ((a[(b + g) >> 0] | 0) == 10) break; else i = g; } f = sb[c[(e + 36) >> 2] & 7](e, b, i) | 0; if (f >>> 0 < i >>> 0) break a; h = i; g = (b + i) | 0; d = (d - i) | 0; f = c[j >> 2] | 0; } else { h = 0; g = b; } while (0); BC(f | 0, g | 0, d | 0) | 0; c[j >> 2] = (c[j >> 2] | 0) + d; f = (h + d) | 0; } while (0); return f | 0; } function bC(b) { b = b | 0; var d = 0, e = 0; d = (b + 74) | 0; e = a[d >> 0] | 0; a[d >> 0] = (e + 255) | e; d = c[b >> 2] | 0; if (!(d & 8)) { c[(b + 8) >> 2] = 0; c[(b + 4) >> 2] = 0; e = c[(b + 44) >> 2] | 0; c[(b + 28) >> 2] = e; c[(b + 20) >> 2] = e; c[(b + 16) >> 2] = e + (c[(b + 48) >> 2] | 0); b = 0; } else { c[b >> 2] = d | 32; b = -1; } return b | 0; } function cC(a, b) { a = T(a); b = T(b); var c = 0, d = 0; c = dC(a) | 0; do if ((c & 2147483647) >>> 0 <= 2139095040) { d = dC(b) | 0; if ((d & 2147483647) >>> 0 <= 2139095040) if (((d ^ c) | 0) < 0) { a = (c | 0) < 0 ? b : a; break; } else { a = a < b ? b : a; break; } } else a = b; while (0); return T(a); } function dC(a) { a = T(a); return ((g[j >> 2] = a), c[j >> 2] | 0) | 0; } function eC(a, b) { a = T(a); b = T(b); var c = 0, d = 0; c = fC(a) | 0; do if ((c & 2147483647) >>> 0 <= 2139095040) { d = fC(b) | 0; if ((d & 2147483647) >>> 0 <= 2139095040) if (((d ^ c) | 0) < 0) { a = (c | 0) < 0 ? a : b; break; } else { a = a < b ? a : b; break; } } else a = b; while (0); return T(a); } function fC(a) { a = T(a); return ((g[j >> 2] = a), c[j >> 2] | 0) | 0; } function gC(a, b) { a = T(a); b = T(b); var d = 0, e = 0, f = 0, h = 0, i = 0, k = 0, l = 0, m = 0; h = ((g[j >> 2] = a), c[j >> 2] | 0); k = ((g[j >> 2] = b), c[j >> 2] | 0); d = (h >>> 23) & 255; i = (k >>> 23) & 255; l = h & -2147483648; f = k << 1; a: do if ( (f | 0) != 0 ? !( ((d | 0) == 255) | (((hC(b) | 0) & 2147483647) >>> 0 > 2139095040) ) : 0 ) { e = h << 1; if (e >>> 0 <= f >>> 0) { b = T(a * T(0.0)); return T((e | 0) == (f | 0) ? b : a); } if (!d) { d = h << 9; if ((d | 0) > -1) { e = d; d = 0; do { d = (d + -1) | 0; e = e << 1; } while ((e | 0) > -1); } else d = 0; e = h << (1 - d); } else e = (h & 8388607) | 8388608; if (!i) { h = k << 9; if ((h | 0) > -1) { f = 0; do { f = (f + -1) | 0; h = h << 1; } while ((h | 0) > -1); } else f = 0; i = f; k = k << (1 - f); } else k = (k & 8388607) | 8388608; f = (e - k) | 0; h = (f | 0) > -1; b: do if ((d | 0) > (i | 0)) { while (1) { if (h) if (!f) break; else e = f; e = e << 1; d = (d + -1) | 0; f = (e - k) | 0; h = (f | 0) > -1; if ((d | 0) <= (i | 0)) break b; } b = T(a * T(0.0)); break a; } while (0); if (h) if (!f) { b = T(a * T(0.0)); break; } else e = f; if (e >>> 0 < 8388608) do { e = e << 1; d = (d + -1) | 0; } while (e >>> 0 < 8388608); if ((d | 0) > 0) d = (e + -8388608) | (d << 23); else d = e >>> ((1 - d) | 0); b = ((c[j >> 2] = d | l), T(g[j >> 2])); } else m = 3; while (0); if ((m | 0) == 3) { b = T(a * b); b = T(b / b); } return T(b); } function hC(a) { a = T(a); return ((g[j >> 2] = a), c[j >> 2] | 0) | 0; } function iC(a, b) { a = a | 0; b = b | 0; return CB(c[582] | 0, a, b) | 0; } function jC(a) { a = a | 0; Ta(); } function kC(a) { a = a | 0; return; } function lC(a, b) { a = a | 0; b = b | 0; return 0; } function mC(a) { a = a | 0; if ((nC((a + 4) | 0) | 0) == -1) { nb[c[((c[a >> 2] | 0) + 8) >> 2] & 127](a); a = 1; } else a = 0; return a | 0; } function nC(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; c[a >> 2] = b + -1; return (b + -1) | 0; } function oC(a) { a = a | 0; if (mC(a) | 0) pC(a); return; } function pC(a) { a = a | 0; var b = 0; b = (a + 8) | 0; if (!((c[b >> 2] | 0) != 0 ? (nC(b) | 0) != -1 : 0)) nb[c[((c[a >> 2] | 0) + 16) >> 2] & 127](a); return; } function qC(a) { a = a | 0; var b = 0; b = (a | 0) == 0 ? 1 : a; while (1) { a = oB(b) | 0; if (a | 0) break; a = uC() | 0; if (!a) { a = 0; break; } Fb[a & 0](); } return a | 0; } function rC(a) { a = a | 0; return qC(a) | 0; } function sC(a) { a = a | 0; pB(a); return; } function tC(b) { b = b | 0; if ((a[(b + 11) >> 0] | 0) < 0) sC(c[b >> 2] | 0); return; } function uC() { var a = 0; a = c[2923] | 0; c[2923] = a + 0; return a | 0; } function vC() {} function wC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; d = (b - d - ((c >>> 0 > a >>> 0) | 0)) >>> 0; return ((A = d), ((a - c) >>> 0) | 0) | 0; } function xC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; c = (a + c) >>> 0; return ((A = (b + d + ((c >>> 0 < a >>> 0) | 0)) >>> 0), c | 0) | 0; } function yC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = (b + e) | 0; d = d & 255; if ((e | 0) >= 67) { while (b & 3) { a[b >> 0] = d; b = (b + 1) | 0; } f = (h & -4) | 0; g = (f - 64) | 0; i = d | (d << 8) | (d << 16) | (d << 24); while ((b | 0) <= (g | 0)) { c[b >> 2] = i; c[(b + 4) >> 2] = i; c[(b + 8) >> 2] = i; c[(b + 12) >> 2] = i; c[(b + 16) >> 2] = i; c[(b + 20) >> 2] = i; c[(b + 24) >> 2] = i; c[(b + 28) >> 2] = i; c[(b + 32) >> 2] = i; c[(b + 36) >> 2] = i; c[(b + 40) >> 2] = i; c[(b + 44) >> 2] = i; c[(b + 48) >> 2] = i; c[(b + 52) >> 2] = i; c[(b + 56) >> 2] = i; c[(b + 60) >> 2] = i; b = (b + 64) | 0; } while ((b | 0) < (f | 0)) { c[b >> 2] = i; b = (b + 4) | 0; } } while ((b | 0) < (h | 0)) { a[b >> 0] = d; b = (b + 1) | 0; } return (h - e) | 0; } function zC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; if ((c | 0) < 32) { A = (b << c) | ((a & (((1 << c) - 1) << (32 - c))) >>> (32 - c)); return a << c; } A = a << (c - 32); return 0; } function AC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; if ((c | 0) < 32) { A = b >>> c; return (a >>> c) | ((b & ((1 << c) - 1)) << (32 - c)); } A = 0; return (b >>> (c - 32)) | 0; } function BC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0; if ((e | 0) >= 8192) return Oa(b | 0, d | 0, e | 0) | 0; h = b | 0; g = (b + e) | 0; if ((b & 3) == (d & 3)) { while (b & 3) { if (!e) return h | 0; a[b >> 0] = a[d >> 0] | 0; b = (b + 1) | 0; d = (d + 1) | 0; e = (e - 1) | 0; } e = (g & -4) | 0; f = (e - 64) | 0; while ((b | 0) <= (f | 0)) { c[b >> 2] = c[d >> 2]; c[(b + 4) >> 2] = c[(d + 4) >> 2]; c[(b + 8) >> 2] = c[(d + 8) >> 2]; c[(b + 12) >> 2] = c[(d + 12) >> 2]; c[(b + 16) >> 2] = c[(d + 16) >> 2]; c[(b + 20) >> 2] = c[(d + 20) >> 2]; c[(b + 24) >> 2] = c[(d + 24) >> 2]; c[(b + 28) >> 2] = c[(d + 28) >> 2]; c[(b + 32) >> 2] = c[(d + 32) >> 2]; c[(b + 36) >> 2] = c[(d + 36) >> 2]; c[(b + 40) >> 2] = c[(d + 40) >> 2]; c[(b + 44) >> 2] = c[(d + 44) >> 2]; c[(b + 48) >> 2] = c[(d + 48) >> 2]; c[(b + 52) >> 2] = c[(d + 52) >> 2]; c[(b + 56) >> 2] = c[(d + 56) >> 2]; c[(b + 60) >> 2] = c[(d + 60) >> 2]; b = (b + 64) | 0; d = (d + 64) | 0; } while ((b | 0) < (e | 0)) { c[b >> 2] = c[d >> 2]; b = (b + 4) | 0; d = (d + 4) | 0; } } else { e = (g - 4) | 0; while ((b | 0) < (e | 0)) { a[b >> 0] = a[d >> 0] | 0; a[(b + 1) >> 0] = a[(d + 1) >> 0] | 0; a[(b + 2) >> 0] = a[(d + 2) >> 0] | 0; a[(b + 3) >> 0] = a[(d + 3) >> 0] | 0; b = (b + 4) | 0; d = (d + 4) | 0; } } while ((b | 0) < (g | 0)) { a[b >> 0] = a[d >> 0] | 0; b = (b + 1) | 0; d = (d + 1) | 0; } return h | 0; } function CC(b) { b = b | 0; var c = 0; c = a[(n + (b & 255)) >> 0] | 0; if ((c | 0) < 8) return c | 0; c = a[(n + ((b >> 8) & 255)) >> 0] | 0; if ((c | 0) < 8) return (c + 8) | 0; c = a[(n + ((b >> 16) & 255)) >> 0] | 0; if ((c | 0) < 8) return (c + 16) | 0; return ((a[(n + (b >>> 24)) >> 0] | 0) + 24) | 0; } function DC(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0, p = 0; l = a; j = b; k = j; h = d; n = e; i = n; if (!k) { g = (f | 0) != 0; if (!i) { if (g) { c[f >> 2] = (l >>> 0) % (h >>> 0); c[(f + 4) >> 2] = 0; } n = 0; f = ((l >>> 0) / (h >>> 0)) >>> 0; return ((A = n), f) | 0; } else { if (!g) { n = 0; f = 0; return ((A = n), f) | 0; } c[f >> 2] = a | 0; c[(f + 4) >> 2] = b & 0; n = 0; f = 0; return ((A = n), f) | 0; } } g = (i | 0) == 0; do if (h) { if (!g) { g = ((S(i | 0) | 0) - (S(k | 0) | 0)) | 0; if (g >>> 0 <= 31) { m = (g + 1) | 0; i = (31 - g) | 0; b = (g - 31) >> 31; h = m; a = ((l >>> (m >>> 0)) & b) | (k << i); b = (k >>> (m >>> 0)) & b; g = 0; i = l << i; break; } if (!f) { n = 0; f = 0; return ((A = n), f) | 0; } c[f >> 2] = a | 0; c[(f + 4) >> 2] = j | (b & 0); n = 0; f = 0; return ((A = n), f) | 0; } g = (h - 1) | 0; if ((g & h) | 0) { i = ((S(h | 0) | 0) + 33 - (S(k | 0) | 0)) | 0; p = (64 - i) | 0; m = (32 - i) | 0; j = m >> 31; o = (i - 32) | 0; b = o >> 31; h = i; a = (((m - 1) >> 31) & (k >>> (o >>> 0))) | (((k << m) | (l >>> (i >>> 0))) & b); b = b & (k >>> (i >>> 0)); g = (l << p) & j; i = (((k << p) | (l >>> (o >>> 0))) & j) | ((l << m) & ((i - 33) >> 31)); break; } if (f | 0) { c[f >> 2] = g & l; c[(f + 4) >> 2] = 0; } if ((h | 0) == 1) { o = j | (b & 0); p = a | 0 | 0; return ((A = o), p) | 0; } else { p = CC(h | 0) | 0; o = (k >>> (p >>> 0)) | 0; p = (k << (32 - p)) | (l >>> (p >>> 0)) | 0; return ((A = o), p) | 0; } } else { if (g) { if (f | 0) { c[f >> 2] = (k >>> 0) % (h >>> 0); c[(f + 4) >> 2] = 0; } o = 0; p = ((k >>> 0) / (h >>> 0)) >>> 0; return ((A = o), p) | 0; } if (!l) { if (f | 0) { c[f >> 2] = 0; c[(f + 4) >> 2] = (k >>> 0) % (i >>> 0); } o = 0; p = ((k >>> 0) / (i >>> 0)) >>> 0; return ((A = o), p) | 0; } g = (i - 1) | 0; if (!(g & i)) { if (f | 0) { c[f >> 2] = a | 0; c[(f + 4) >> 2] = (g & k) | (b & 0); } o = 0; p = k >>> ((CC(i | 0) | 0) >>> 0); return ((A = o), p) | 0; } g = ((S(i | 0) | 0) - (S(k | 0) | 0)) | 0; if (g >>> 0 <= 30) { b = (g + 1) | 0; i = (31 - g) | 0; h = b; a = (k << i) | (l >>> (b >>> 0)); b = k >>> (b >>> 0); g = 0; i = l << i; break; } if (!f) { o = 0; p = 0; return ((A = o), p) | 0; } c[f >> 2] = a | 0; c[(f + 4) >> 2] = j | (b & 0); o = 0; p = 0; return ((A = o), p) | 0; } while (0); if (!h) { k = i; j = 0; i = 0; } else { m = d | 0 | 0; l = n | (e & 0); k = xC(m | 0, l | 0, -1, -1) | 0; d = A; j = i; i = 0; do { e = j; j = (g >>> 31) | (j << 1); g = i | (g << 1); e = (a << 1) | (e >>> 31) | 0; n = (a >>> 31) | (b << 1) | 0; wC(k | 0, d | 0, e | 0, n | 0) | 0; p = A; o = (p >> 31) | (((p | 0) < 0 ? -1 : 0) << 1); i = o & 1; a = wC( e | 0, n | 0, (o & m) | 0, (((((p | 0) < 0 ? -1 : 0) >> 31) | (((p | 0) < 0 ? -1 : 0) << 1)) & l) | 0 ) | 0; b = A; h = (h - 1) | 0; } while ((h | 0) != 0); k = j; j = 0; } h = 0; if (f | 0) { c[f >> 2] = a; c[(f + 4) >> 2] = b; } o = ((g | 0) >>> 31) | ((k | h) << 1) | (((h << 1) | (g >>> 31)) & 0) | j; p = (((g << 1) | (0 >>> 31)) & -2) | i; return ((A = o), p) | 0; } function EC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return DC(a, b, c, d, 0) | 0; } function FC(a) { a = a | 0; var b = 0, d = 0; d = ((a + 15) & -16) | 0; b = c[i >> 2] | 0; a = (b + d) | 0; if ((((d | 0) > 0) & ((a | 0) < (b | 0))) | ((a | 0) < 0)) { Y() | 0; Qa(12); return -1; } c[i >> 2] = a; if ((a | 0) > (X() | 0) ? (W() | 0) == 0 : 0) { c[i >> 2] = b; Qa(12); return -1; } return b | 0; } function GC(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0; if (((c | 0) < (b | 0)) & ((b | 0) < ((c + d) | 0))) { e = b; c = (c + d) | 0; b = (b + d) | 0; while ((d | 0) > 0) { b = (b - 1) | 0; c = (c - 1) | 0; d = (d - 1) | 0; a[b >> 0] = a[c >> 0] | 0; } b = e; } else BC(b, c, d) | 0; return b | 0; } function HC(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = (l + 16) | 0; f = g | 0; DC(a, b, d, e, f) | 0; l = g; return ((A = c[(f + 4) >> 2] | 0), c[f >> 2] | 0) | 0; } function IC(a) { a = a | 0; return ( ((a & 255) << 24) | (((a >> 8) & 255) << 16) | (((a >> 16) & 255) << 8) | (a >>> 24) | 0 ); } function JC(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; jb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0); } function KC(a, b, c) { a = a | 0; b = b | 0; c = T(c); kb[a & 1](b | 0, T(c)); } function LC(a, b, c) { a = a | 0; b = b | 0; c = +c; lb[a & 31](b | 0, +c); } function MC(a, b, c, d) { a = a | 0; b = b | 0; c = T(c); d = T(d); return T(mb[a & 0](b | 0, T(c), T(d))); } function NC(a, b) { a = a | 0; b = b | 0; nb[a & 127](b | 0); } function OC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; ob[a & 31](b | 0, c | 0); } function PC(a, b) { a = a | 0; b = b | 0; return pb[a & 31](b | 0) | 0; } function QC(a, b, c, d, e) { a = a | 0; b = b | 0; c = +c; d = +d; e = e | 0; qb[a & 1](b | 0, +c, +d, e | 0); } function RC(a, b, c, d) { a = a | 0; b = b | 0; c = +c; d = +d; rb[a & 1](b | 0, +c, +d); } function SC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return sb[a & 7](b | 0, c | 0, d | 0) | 0; } function TC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return +tb[a & 1](b | 0, c | 0, d | 0); } function UC(a, b) { a = a | 0; b = b | 0; return +ub[a & 15](b | 0); } function VC(a, b, c) { a = a | 0; b = b | 0; c = +c; return vb[a & 1](b | 0, +c) | 0; } function WC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; return wb[a & 15](b | 0, c | 0) | 0; } function XC(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = +d; e = +e; f = f | 0; xb[a & 1](b | 0, c | 0, +d, +e, f | 0); } function YC(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; yb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0, g | 0); } function ZC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; return +zb[a & 7](b | 0, c | 0); } function _C(a) { a = a | 0; return Ab[a & 7]() | 0; } function $C(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; return Bb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0) | 0; } function aD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = +e; Cb[a & 1](b | 0, c | 0, d | 0, +e); } function bD(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = T(d); e = e | 0; f = T(f); g = g | 0; Db[a & 1](b | 0, c | 0, T(d), e | 0, T(f), g | 0); } function cD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; Eb[a & 15](b | 0, c | 0, d | 0); } function dD(a) { a = a | 0; Fb[a & 0](); } function eD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = +d; Gb[a & 15](b | 0, c | 0, +d); } function fD(a, b, c) { a = a | 0; b = +b; c = +c; return Hb[a & 1](+b, +c) | 0; } function gD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; Ib[a & 15](b | 0, c | 0, d | 0, e | 0); } function hD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; U(0); } function iD(a, b) { a = a | 0; b = T(b); U(1); } function jD(a, b) { a = a | 0; b = +b; U(2); } function kD(a, b, c) { a = a | 0; b = T(b); c = T(c); U(3); return ib; } function lD(a) { a = a | 0; U(4); } function mD(a, b) { a = a | 0; b = b | 0; U(5); } function nD(a) { a = a | 0; U(6); return 0; } function oD(a, b, c, d) { a = a | 0; b = +b; c = +c; d = d | 0; U(7); } function pD(a, b, c) { a = a | 0; b = +b; c = +c; U(8); } function qD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(9); return 0; } function rD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(10); return 0.0; } function sD(a) { a = a | 0; U(11); return 0.0; } function tD(a, b) { a = a | 0; b = +b; U(12); return 0; } function uD(a, b) { a = a | 0; b = b | 0; U(13); return 0; } function vD(a, b, c, d, e) { a = a | 0; b = b | 0; c = +c; d = +d; e = e | 0; U(14); } function wD(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; U(15); } function xD(a, b) { a = a | 0; b = b | 0; U(16); return 0.0; } function yD() { U(17); return 0; } function zD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; U(18); return 0; } function AD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = +d; U(19); } function BD(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = T(c); d = d | 0; e = T(e); f = f | 0; U(20); } function CD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(21); } function DD() { U(22); } function ED(a, b, c) { a = a | 0; b = b | 0; c = +c; U(23); } function FD(a, b) { a = +a; b = +b; U(24); return 0; } function GD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; U(25); } // EMSCRIPTEN_END_FUNCS var jb = [hD, Uw]; var kb = [iD, of]; var lb = [ jD, Of, Pf, Qf, Rf, Sf, Tf, Uf, Wf, Xf, Zf, _f, $f, ag, bg, cg, dg, eg, fg, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, ]; var mb = [kD]; var nb = [ lD, kC, Ki, Li, Mi, rn, sn, tn, Pu, Qu, Ru, Cw, Dw, Ew, DA, EA, FA, Rb, tf, yf, Vf, Yf, hh, ih, ri, Ui, kj, Jj, bk, zk, Wk, nl, Hl, bm, um, Nm, en, Nn, fo, yo, Ro, ip, Bp, Xp, nq, Eq, Zq, lf, Hr, _r, us, Ps, ft, Ct, Ot, Rt, ju, mu, Eu, Uu, Xu, pv, Kv, Vi, $x, Ky, az, sz, Rz, hA, tA, wA, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, ]; var ob = [ mD, zf, Af, Df, Ef, Ff, Gf, Hf, If, Lf, Mf, Nf, wg, zg, Ag, Bg, Cg, Dg, Eg, Jg, Ng, rh, $p, qq, Ts, cy, Sv, xy, mD, mD, mD, mD, ]; var pb = [ nD, rB, sf, jg, ng, og, pg, qg, rg, sg, ug, vg, Kg, Lg, jh, ar, jt, sv, hy, jy, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD, ]; var qb = [oD, kh]; var rb = [pD, Hu]; var sb = [qD, sB, tB, zB, Dk, Rn, Lr, wz]; var tb = [rD, ym]; var ub = [sD, xg, yg, Fg, lh, mh, nh, oh, ph, qh, sD, sD, sD, sD, sD, sD]; var vb = [tD, Kt]; var wb = [uD, lC, Mg, xi, Nj, _k, rl, jn, jo, Iq, pf, ez, uD, uD, uD, uD]; var xb = [vD, oj]; var yb = [wD, Vz]; var zb = [xD, Gg, sh, th, uh, Rm, xD, xD]; var Ab = [yD, vh, qf, jf, Wt, qu, av, AA]; var Bb = [zD, ee]; var Cb = [AD, Vo]; var Db = [BD, Pg]; var Eb = [CD, kg, tg, Hg, Ig, fk, Ll, mp, Fp, nf, vx, Oy, lA, CD, CD, CD]; var Fb = [DD]; var Gb = [ED, Bf, Cf, Jf, Kf, gg, hg, ig, Co, cs, Ft, ED, ED, ED, ED, ED]; var Hb = [FD, Mu]; var Ib = [GD, fm, ir, ys, st, au, wu, hv, Pv, oy, LA, GD, GD, GD, GD, GD]; return { _llvm_bswap_i32: IC, dynCall_idd: fD, dynCall_i: _C, _i64Subtract: wC, ___udivdi3: EC, dynCall_vif: KC, setThrew: Nb, dynCall_viii: cD, _bitshift64Lshr: AC, _bitshift64Shl: zC, dynCall_vi: NC, dynCall_viiddi: XC, dynCall_diii: TC, dynCall_iii: WC, _memset: yC, _sbrk: FC, _memcpy: BC, __GLOBAL__sub_I_Yoga_cpp: hf, dynCall_vii: OC, ___uremdi3: HC, dynCall_vid: LC, stackAlloc: Jb, _nbind_init: _A, getTempRet0: Pb, dynCall_di: UC, dynCall_iid: VC, setTempRet0: Ob, _i64Add: xC, dynCall_fiff: MC, dynCall_iiii: SC, _emscripten_get_global_libc: qB, dynCall_viid: eD, dynCall_viiid: aD, dynCall_viififi: bD, dynCall_ii: PC, __GLOBAL__sub_I_Binding_cc: Sx, dynCall_viiii: gD, dynCall_iiiiii: $C, stackSave: Kb, dynCall_viiiii: JC, __GLOBAL__sub_I_nbind_cc: wh, dynCall_vidd: RC, _free: pB, runPostSets: vC, dynCall_viiiiii: YC, establishStackSpace: Mb, _memmove: GC, stackRestore: Lb, _malloc: oB, __GLOBAL__sub_I_common_cc: Bv, dynCall_viddi: QC, dynCall_dii: ZC, dynCall_v: dD, }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/asmjs/1/output.js
JavaScript
export function foo(global, env, buffer) { "use asm"; var a = new global.Int8Array(buffer); var b = new global.Int16Array(buffer); var c = new global.Int32Array(buffer); var d = new global.Uint8Array(buffer); var e = new global.Uint16Array(buffer); var f = new global.Uint32Array(buffer); var g = new global.Float32Array(buffer); var h = new global.Float64Array(buffer); var i = env.DYNAMICTOP_PTR | 0; var j = env.tempDoublePtr | 0; var k = env.ABORT | 0; var l = env.STACKTOP | 0; var m = env.STACK_MAX | 0; var n = env.cttz_i8 | 0; var o = env.___dso_handle | 0; var p = 0; var q = 0; var r = 0; var s = 0; var t = global.NaN, u = global.Infinity; var v = 0, w = 0, x = 0, y = 0, z = 0.0; var A = 0; var B = global.Math.floor; var C = global.Math.abs; var D = global.Math.sqrt; var E = global.Math.pow; var F = global.Math.cos; var G = global.Math.sin; var H = global.Math.tan; var I = global.Math.acos; var J = global.Math.asin; var K = global.Math.atan; var L = global.Math.atan2; var M = global.Math.exp; var N = global.Math.log; var O = global.Math.ceil; var P = global.Math.imul; var Q = global.Math.min; var R = global.Math.max; var S = global.Math.clz32; var T = global.Math.fround; var U = env.abort; var V = env.assert; var W = env.enlargeMemory; var X = env.getTotalMemory; var Y = env.abortOnCannotGrowMemory; var Z = env.invoke_viiiii; var _ = env.invoke_vif; var $ = env.invoke_vid; var aa = env.invoke_fiff; var ba = env.invoke_vi; var ca = env.invoke_vii; var da = env.invoke_ii; var ea = env.invoke_viddi; var fa = env.invoke_vidd; var ga = env.invoke_iiii; var ha = env.invoke_diii; var ia = env.invoke_di; var ja = env.invoke_iid; var ka = env.invoke_iii; var la = env.invoke_viiddi; var ma = env.invoke_viiiiii; var na = env.invoke_dii; var oa = env.invoke_i; var pa = env.invoke_iiiiii; var qa = env.invoke_viiid; var ra = env.invoke_viififi; var sa = env.invoke_viii; var ta = env.invoke_v; var ua = env.invoke_viid; var va = env.invoke_idd; var wa = env.invoke_viiii; var xa = env._emscripten_asm_const_iiiii; var ya = env._emscripten_asm_const_iiidddddd; var za = env._emscripten_asm_const_iiiid; var Aa = env.__nbind_reference_external; var Ba = env._emscripten_asm_const_iiiiiiii; var Ca = env._removeAccessorPrefix; var Da = env._typeModule; var Ea = env.__nbind_register_pool; var Fa = env.__decorate; var Ga = env._llvm_stackrestore; var Ha = env.___cxa_atexit; var Ia = env.__extends; var Ja = env.__nbind_get_value_object; var Ka = env.__ZN8facebook4yoga14YGNodeToStringEPNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEP6YGNode14YGPrintOptionsj; var La = env._emscripten_set_main_loop_timing; var Ma = env.__nbind_register_primitive; var Na = env.__nbind_register_type; var Oa = env._emscripten_memcpy_big; var Pa = env.__nbind_register_function; var Qa = env.___setErrNo; var Ra = env.__nbind_register_class; var Sa = env.__nbind_finish; var Ta = env._abort; var Ua = env._nbind_value; var Va = env._llvm_stacksave; var Wa = env.___syscall54; var Xa = env._defineHidden; var Ya = env._emscripten_set_main_loop; var Za = env._emscripten_get_now; var _a = env.__nbind_register_callback_signature; var $a = env._emscripten_asm_const_iiiiii; var ab = env.__nbind_free_external; var bb = env._emscripten_asm_const_iiii; var cb = env._emscripten_asm_const_iiididi; var db = env.___syscall6; var eb = env._atexit; var fb = env.___syscall140; var gb = env.___syscall146; var hb = T(0); const ib = T(0); // EMSCRIPTEN_START_FUNCS function Jb(a) { a = a | 0; var b = 0; b = l; l = l + a | 0; l = l + 15 & -16; return b | 0; } function Kb() { return l | 0; } function Lb(a) { a = a | 0; l = a; } function Mb(a, b) { a = a | 0; b = b | 0; l = a; m = b; } function Nb(a, b) { a = a | 0; b = b | 0; if (!p) { p = a; q = b; } } function Ob(a) { a = a | 0; A = a; } function Pb() { return A | 0; } function Qb() { var b = 0, d = 0; BC(8104, 8, 400); BC(8504, 408, 540); b = 9044; d = b + 44 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) a[9088] = 0; a[9089] = 1; c[2273] = 0; c[2274] = 948; c[2275] = 948; Ha(17, 8104, o | 0); return; } function Rb(a) { a = a | 0; oc(a + 948 | 0); return; } function Sb(a) { a = T(a); return ((af(a) | 0) & 2147483647) >>> 0 > 2139095040 | 0; } function Tb(a, b, d) { a = a | 0; b = b | 0; d = d | 0; a: do if (!(c[a + (b << 3) + 4 >> 2] | 0)) { if ((b | 2) == 3 ? c[a + 60 >> 2] | 0 : 0) { a = a + 56 | 0; break; } switch(b | 0){ case 0: case 2: case 4: case 5: if (c[a + 52 >> 2] | 0) { a = a + 48 | 0; break a; } break; default: } if (!(c[a + 68 >> 2] | 0)) { a = (b | 1) == 5 ? 948 : d; break; } else { a = a + 64 | 0; break; } } else a = a + (b << 3) | 0; while (0) return a | 0; } function Ub(b) { b = b | 0; var d = 0; d = oB(1e3) | 0; Vb(b, (d | 0) != 0, 2456); c[2276] = (c[2276] | 0) + 1; BC(d | 0, 8104, 1e3); if (a[b + 2 >> 0] | 0) { c[d + 4 >> 2] = 2; c[d + 12 >> 2] = 4; } c[d + 976 >> 2] = b; return d | 0; } function Vb(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; f = l; l = l + 16 | 0; e = f; if (!b) { c[e >> 2] = d; fe(a, 5, 3197, e); } l = f; return; } function Wb() { return Ub(956) | 0; } function Xb(a) { a = a | 0; var b = 0; b = qC(1e3) | 0; Yb(b, a); Vb(c[a + 976 >> 2] | 0, 1, 2456); c[2276] = (c[2276] | 0) + 1; c[b + 944 >> 2] = 0; return b | 0; } function Yb(a, b) { a = a | 0; b = b | 0; var d = 0; BC(a | 0, b | 0, 948); ie(a + 948 | 0, b + 948 | 0); d = a + 960 | 0; a = b + 960 | 0; b = d + 40 | 0; do { c[d >> 2] = c[a >> 2]; d = d + 4 | 0; a = a + 4 | 0; }while ((d | 0) < (b | 0)) return; } function Zb(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0; b = a + 944 | 0; d = c[b >> 2] | 0; if (d | 0) { _b(d + 948 | 0, a); c[b >> 2] = 0; } d = $b(a) | 0; if (d | 0) { b = 0; do { c[(ac(a, b) | 0) + 944 >> 2] = 0; b = b + 1 | 0; }while ((b | 0) != (d | 0)) } d = a + 948 | 0; e = c[d >> 2] | 0; f = a + 952 | 0; b = c[f >> 2] | 0; if ((b | 0) != (e | 0)) c[f >> 2] = b + (~((b + -4 - e | 0) >>> 2) << 2); bc(d); pB(a); c[2276] = (c[2276] | 0) + -1; return; } function _b(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; e = c[a >> 2] | 0; i = a + 4 | 0; d = c[i >> 2] | 0; g = d; a: do if ((e | 0) == (d | 0)) { f = e; h = 4; } else { a = e; while(true){ if ((c[a >> 2] | 0) == (b | 0)) { f = a; h = 4; break a; } a = a + 4 | 0; if ((a | 0) == (d | 0)) { a = 0; break; } } } while (0) if ((h | 0) == 4) { if ((f | 0) != (d | 0)) { e = f + 4 | 0; a = g - e | 0; b = a >> 2; if (b) { GC(f | 0, e | 0, a | 0); d = c[i >> 2] | 0; } a = f + (b << 2) | 0; if ((d | 0) == (a | 0)) a = 1; else { c[i >> 2] = d + (~((d + -4 - a | 0) >>> 2) << 2); a = 1; } } else a = 0; } return a | 0; } function $b(a) { a = a | 0; return (c[a + 952 >> 2] | 0) - (c[a + 948 >> 2] | 0) >> 2 | 0; } function ac(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[a + 948 >> 2] | 0; if ((c[a + 952 >> 2] | 0) - d >> 2 >>> 0 > b >>> 0) a = c[d + (b << 2) >> 2] | 0; else a = 0; return a | 0; } function bc(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0; e = l; l = l + 32 | 0; b = e; f = c[a >> 2] | 0; d = (c[a + 4 >> 2] | 0) - f | 0; if (((c[a + 8 >> 2] | 0) - f | 0) >>> 0 > d >>> 0) { f = d >> 2; bf(b, f, f, a + 8 | 0); cf(a, b); df(b); } l = e; return; } function cc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; k = $b(a) | 0; do if (k | 0) { if ((c[(ac(a, 0) | 0) + 944 >> 2] | 0) == (a | 0)) { if (!(_b(a + 948 | 0, b) | 0)) break; BC(b + 400 | 0, 8504, 540); c[b + 944 >> 2] = 0; nc(a); break; } h = c[(c[a + 976 >> 2] | 0) + 12 >> 2] | 0; i = a + 948 | 0; j = (h | 0) == 0; d = 0; g = 0; do { e = c[(c[i >> 2] | 0) + (g << 2) >> 2] | 0; if ((e | 0) == (b | 0)) nc(a); else { f = Xb(e) | 0; c[(c[i >> 2] | 0) + (d << 2) >> 2] = f; c[f + 944 >> 2] = a; if (!j) Ib[h & 15](e, f, a, d); d = d + 1 | 0; } g = g + 1 | 0; }while ((g | 0) != (k | 0)) if (d >>> 0 < k >>> 0) { j = a + 948 | 0; i = a + 952 | 0; h = d; d = c[i >> 2] | 0; do { g = (c[j >> 2] | 0) + (h << 2) | 0; e = g + 4 | 0; f = d - e | 0; b = f >> 2; if (!b) f = d; else { GC(g | 0, e | 0, f | 0); d = c[i >> 2] | 0; f = d; } e = g + (b << 2) | 0; if ((f | 0) != (e | 0)) { d = f + (~((f + -4 - e | 0) >>> 2) << 2) | 0; c[i >> 2] = d; } h = h + 1 | 0; }while ((h | 0) != (k | 0)) } } while (0) return; } function dc(b) { b = b | 0; var d = 0, e = 0, f = 0, g = 0; ec(b, ($b(b) | 0) == 0, 2491); ec(b, (c[b + 944 >> 2] | 0) == 0, 2545); d = b + 948 | 0; e = c[d >> 2] | 0; f = b + 952 | 0; g = c[f >> 2] | 0; if ((g | 0) != (e | 0)) c[f >> 2] = g + (~((g + -4 - e | 0) >>> 2) << 2); bc(d); d = b + 976 | 0; e = c[d >> 2] | 0; BC(b | 0, 8104, 1e3); if (a[e + 2 >> 0] | 0) { c[b + 4 >> 2] = 2; c[b + 12 >> 2] = 4; } c[d >> 2] = e; return; } function ec(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; f = l; l = l + 16 | 0; e = f; if (!b) { c[e >> 2] = d; Vd(a, 5, 3197, e); } l = f; return; } function fc() { return c[2276] | 0; } function gc() { var a = 0; a = oB(20) | 0; hc((a | 0) != 0, 2592); c[2277] = (c[2277] | 0) + 1; c[a >> 2] = c[239]; c[a + 4 >> 2] = c[240]; c[a + 8 >> 2] = c[241]; c[a + 12 >> 2] = c[242]; c[a + 16 >> 2] = c[243]; return a | 0; } function hc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = l; l = l + 16 | 0; d = e; if (!a) { c[d >> 2] = b; Vd(0, 5, 3197, d); } l = e; return; } function ic(a) { a = a | 0; pB(a); c[2277] = (c[2277] | 0) + -1; return; } function jc(a, b) { a = a | 0; b = b | 0; var d = 0; if (!b) { d = 0; b = 0; } else { ec(a, ($b(a) | 0) == 0, 2629); d = 1; } c[a + 964 >> 2] = b; c[a + 988 >> 2] = d; return; } function kc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; g = e + 8 | 0; f = e + 4 | 0; h = e; c[f >> 2] = b; ec(a, (c[b + 944 >> 2] | 0) == 0, 2709); ec(a, (c[a + 964 >> 2] | 0) == 0, 2763); lc(a); b = a + 948 | 0; c[h >> 2] = (c[b >> 2] | 0) + (d << 2); c[g >> 2] = c[h >> 2]; mc(b, g, f); c[(c[f >> 2] | 0) + 944 >> 2] = a; nc(a); l = e; return; } function lc(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = $b(a) | 0; if (d | 0 ? (c[(ac(a, 0) | 0) + 944 >> 2] | 0) != (a | 0) : 0) { e = c[(c[a + 976 >> 2] | 0) + 12 >> 2] | 0; f = a + 948 | 0; g = (e | 0) == 0; b = 0; do { h = c[(c[f >> 2] | 0) + (b << 2) >> 2] | 0; i = Xb(h) | 0; c[(c[f >> 2] | 0) + (b << 2) >> 2] = i; c[i + 944 >> 2] = a; if (!g) Ib[e & 15](h, i, a, b); b = b + 1 | 0; }while ((b | 0) != (d | 0)) } return; } function mc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0; s = l; l = l + 64 | 0; n = s + 52 | 0; i = s + 48 | 0; o = s + 28 | 0; p = s + 24 | 0; q = s + 20 | 0; r = s; e = c[a >> 2] | 0; g = e; b = e + ((c[b >> 2] | 0) - g >> 2 << 2) | 0; e = a + 4 | 0; f = c[e >> 2] | 0; h = a + 8 | 0; do if (f >>> 0 < (c[h >> 2] | 0) >>> 0) { if ((b | 0) == (f | 0)) { c[b >> 2] = c[d >> 2]; c[e >> 2] = (c[e >> 2] | 0) + 4; break; } ef(a, b, f, b + 4 | 0); if (b >>> 0 <= d >>> 0) d = (c[e >> 2] | 0) >>> 0 > d >>> 0 ? d + 4 | 0 : d; c[b >> 2] = c[d >> 2]; } else { e = (f - g >> 2) + 1 | 0; f = le(a) | 0; if (f >>> 0 < e >>> 0) jC(a); m = c[a >> 2] | 0; k = (c[h >> 2] | 0) - m | 0; g = k >> 1; bf(r, k >> 2 >>> 0 < f >>> 1 >>> 0 ? g >>> 0 < e >>> 0 ? e : g : f, b - m >> 2, a + 8 | 0); m = r + 8 | 0; e = c[m >> 2] | 0; g = r + 12 | 0; k = c[g >> 2] | 0; h = k; j = e; do if ((e | 0) == (k | 0)) { k = r + 4 | 0; e = c[k >> 2] | 0; t = c[r >> 2] | 0; f = t; if (e >>> 0 <= t >>> 0) { e = h - f >> 1; e = (e | 0) == 0 ? 1 : e; bf(o, e, e >>> 2, c[r + 16 >> 2] | 0); c[p >> 2] = c[k >> 2]; c[q >> 2] = c[m >> 2]; c[i >> 2] = c[p >> 2]; c[n >> 2] = c[q >> 2]; gf(o, i, n); e = c[r >> 2] | 0; c[r >> 2] = c[o >> 2]; c[o >> 2] = e; e = o + 4 | 0; t = c[k >> 2] | 0; c[k >> 2] = c[e >> 2]; c[e >> 2] = t; e = o + 8 | 0; t = c[m >> 2] | 0; c[m >> 2] = c[e >> 2]; c[e >> 2] = t; e = o + 12 | 0; t = c[g >> 2] | 0; c[g >> 2] = c[e >> 2]; c[e >> 2] = t; df(o); e = c[m >> 2] | 0; break; } g = e; h = ((g - f >> 2) + 1 | 0) / -2 | 0; i = e + (h << 2) | 0; f = j - g | 0; g = f >> 2; if (g) { GC(i | 0, e | 0, f | 0); e = c[k >> 2] | 0; } t = i + (g << 2) | 0; c[m >> 2] = t; c[k >> 2] = e + (h << 2); e = t; } while (0) c[e >> 2] = c[d >> 2]; c[m >> 2] = (c[m >> 2] | 0) + 4; b = ff(a, r, b) | 0; df(r); } while (0) l = s; return b | 0; } function nc(b) { b = b | 0; var d = 0; do { d = b + 984 | 0; if (a[d >> 0] | 0) break; a[d >> 0] = 1; g[b + 504 >> 2] = T(t); b = c[b + 944 >> 2] | 0; }while ((b | 0) != 0) return; } function oc(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -4 - e | 0) >>> 2) << 2); sC(d); } return; } function pc(a) { a = a | 0; return c[a + 944 >> 2] | 0; } function qc(a) { a = a | 0; ec(a, (c[a + 964 >> 2] | 0) != 0, 2832); nc(a); return; } function rc(b) { b = b | 0; return (a[b + 984 >> 0] | 0) != 0 | 0; } function sc(a, b) { a = a | 0; b = b | 0; if (BB(a, b, 400) | 0) { BC(a | 0, b | 0, 400); nc(a); } return; } function tc(a) { a = a | 0; var b = ib; b = T(g[a + 44 >> 2]); a = Sb(b) | 0; return T(a ? T(0.0) : b); } function uc(b) { b = b | 0; var d = ib; d = T(g[b + 48 >> 2]); if (Sb(d) | 0) d = a[(c[b + 976 >> 2] | 0) + 2 >> 0] | 0 ? T(1.0) : T(0.0); return T(d); } function vc(a, b) { a = a | 0; b = b | 0; c[a + 980 >> 2] = b; return; } function wc(a) { a = a | 0; return c[a + 980 >> 2] | 0; } function xc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 4 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function yc(a) { a = a | 0; return c[a + 4 >> 2] | 0; } function zc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 8 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ac(a) { a = a | 0; return c[a + 8 >> 2] | 0; } function Bc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 12 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Cc(a) { a = a | 0; return c[a + 12 >> 2] | 0; } function Dc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 16 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ec(a) { a = a | 0; return c[a + 16 >> 2] | 0; } function Fc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 20 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Gc(a) { a = a | 0; return c[a + 20 >> 2] | 0; } function Hc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 24 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Ic(a) { a = a | 0; return c[a + 24 >> 2] | 0; } function Jc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 28 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Kc(a) { a = a | 0; return c[a + 28 >> 2] | 0; } function Lc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 32 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Mc(a) { a = a | 0; return c[a + 32 >> 2] | 0; } function Nc(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 36 | 0; if ((c[d >> 2] | 0) != (b | 0)) { c[d >> 2] = b; nc(a); } return; } function Oc(a) { a = a | 0; return c[a + 36 >> 2] | 0; } function Pc(a, b) { a = a | 0; b = T(b); var c = 0; c = a + 40 | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Qc(a, b) { a = a | 0; b = T(b); var c = 0; c = a + 44 | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Rc(a, b) { a = a | 0; b = T(b); var c = 0; c = a + 48 | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Sc(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 52 | 0; f = a + 56 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function Tc(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = a + 52 | 0; d = a + 56 | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function Uc(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 52 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function Vc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = a + 132 + (b << 3) | 0; b = a + 132 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Wc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = a + 132 + (b << 3) | 0; b = a + 132 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Xc(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = b + 132 + (d << 3) | 0; b = c[e + 4 >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[d + 4 >> 2] = b; return; } function Yc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = a + 60 + (b << 3) | 0; b = a + 60 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function Zc(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = a + 60 + (b << 3) | 0; b = a + 60 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function _c(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = b + 60 + (d << 3) | 0; b = c[e + 4 >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[d + 4 >> 2] = b; return; } function $c(a, b) { a = a | 0; b = b | 0; var d = 0; d = a + 60 + (b << 3) + 4 | 0; if ((c[d >> 2] | 0) != 3) { g[a + 60 + (b << 3) >> 2] = T(t); c[d >> 2] = 3; nc(a); } return; } function ad(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = a + 204 + (b << 3) | 0; b = a + 204 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function bd(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = h ? 0 : 2; f = a + 204 + (b << 3) | 0; b = a + 204 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function cd(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = b + 204 + (d << 3) | 0; b = c[e + 4 >> 2] | 0; d = a; c[d >> 2] = c[e >> 2]; c[d + 4 >> 2] = b; return; } function dd(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0, h = 0; h = Sb(d) | 0; e = (h ^ 1) & 1; f = a + 276 + (b << 3) | 0; b = a + 276 + (b << 3) + 4 | 0; if (!(h | T(g[f >> 2]) == d ? (c[b >> 2] | 0) == (e | 0) : 0)) { g[f >> 2] = d; c[b >> 2] = e; nc(a); } return; } function ed(a, b) { a = a | 0; b = b | 0; return T(g[a + 276 + (b << 3) >> 2]); } function fd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 348 | 0; f = a + 352 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function gd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = a + 348 | 0; d = a + 352 | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function hd(a) { a = a | 0; var b = 0; b = a + 352 | 0; if ((c[b >> 2] | 0) != 3) { g[a + 348 >> 2] = T(t); c[b >> 2] = 3; nc(a); } return; } function id(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 348 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function jd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 356 | 0; f = a + 360 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function kd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0; e = a + 356 | 0; d = a + 360 | 0; if (!(!(T(g[e >> 2]) != b) ? (c[d >> 2] | 0) == 2 : 0)) { g[e >> 2] = b; e = Sb(b) | 0; c[d >> 2] = e ? 3 : 2; nc(a); } return; } function ld(a) { a = a | 0; var b = 0; b = a + 360 | 0; if ((c[b >> 2] | 0) != 3) { g[a + 356 >> 2] = T(t); c[b >> 2] = 3; nc(a); } return; } function md(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 356 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function nd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 364 | 0; f = a + 368 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function od(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = a + 364 | 0; f = a + 368 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function pd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 364 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function qd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 372 | 0; f = a + 376 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function rd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = a + 372 | 0; f = a + 376 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function sd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 372 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function td(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 380 | 0; f = a + 384 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function ud(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = a + 380 | 0; f = a + 384 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function vd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 380 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function wd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = (h ^ 1) & 1; e = a + 388 | 0; f = a + 392 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function xd(a, b) { a = a | 0; b = T(b); var d = 0, e = 0, f = 0, h = 0; h = Sb(b) | 0; d = h ? 0 : 2; e = a + 388 | 0; f = a + 392 | 0; if (!(h | T(g[e >> 2]) == b ? (c[f >> 2] | 0) == (d | 0) : 0)) { g[e >> 2] = b; c[f >> 2] = d; nc(a); } return; } function yd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = b + 388 | 0; d = c[e + 4 >> 2] | 0; b = a; c[b >> 2] = c[e >> 2]; c[b + 4 >> 2] = d; return; } function zd(a, b) { a = a | 0; b = T(b); var c = 0; c = a + 396 | 0; if (T(g[c >> 2]) != b) { g[c >> 2] = b; nc(a); } return; } function Ad(a) { a = a | 0; return T(g[a + 396 >> 2]); } function Bd(a) { a = a | 0; return T(g[a + 400 >> 2]); } function Cd(a) { a = a | 0; return T(g[a + 404 >> 2]); } function Dd(a) { a = a | 0; return T(g[a + 408 >> 2]); } function Ed(a) { a = a | 0; return T(g[a + 412 >> 2]); } function Fd(a) { a = a | 0; return T(g[a + 416 >> 2]); } function Gd(a) { a = a | 0; return T(g[a + 420 >> 2]); } function Hd(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch(b | 0){ case 0: b = (c[a + 496 >> 2] | 0) == 2 ? 5 : 4; break; case 2: b = (c[a + 496 >> 2] | 0) == 2 ? 4 : 5; break; default: } return T(g[a + 424 + (b << 2) >> 2]); } function Id(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch(b | 0){ case 0: b = (c[a + 496 >> 2] | 0) == 2 ? 5 : 4; break; case 2: b = (c[a + 496 >> 2] | 0) == 2 ? 4 : 5; break; default: } return T(g[a + 448 + (b << 2) >> 2]); } function Jd(a, b) { a = a | 0; b = b | 0; ec(a, (b | 0) < 6, 2918); switch(b | 0){ case 0: b = (c[a + 496 >> 2] | 0) == 2 ? 5 : 4; break; case 2: b = (c[a + 496 >> 2] | 0) == 2 ? 4 : 5; break; default: } return T(g[a + 472 + (b << 2) >> 2]); } function Kd(a, b) { a = a | 0; b = b | 0; var d = 0, e = ib; d = c[a + 4 >> 2] | 0; if ((d | 0) == (c[b + 4 >> 2] | 0)) { if (!d) a = 1; else { e = T(g[a >> 2]); a = T(C(T(e - T(g[b >> 2])))) < T(0.0000999999974); } } else a = 0; return a | 0; } function Ld(a, b) { a = T(a); b = T(b); var c = 0; if (Sb(a) | 0) c = Sb(b) | 0; else c = T(C(T(a - b))) < T(0.0000999999974); return c | 0; } function Md(a, b) { a = a | 0; b = b | 0; Nd(a, b); return; } function Nd(b, d) { b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e + 4 | 0; c[f >> 2] = 0; c[f + 4 >> 2] = 0; c[f + 8 >> 2] = 0; Ka(f | 0, b | 0, d | 0, 0); Vd(b, 3, (a[f + 11 >> 0] | 0) < 0 ? c[f >> 2] | 0 : f, e); tC(f); l = e; return; } function Od(a, b, c, d) { a = T(a); b = T(b); c = c | 0; d = d | 0; var e = ib; a = T(a * b); e = T(gC(a, T(1.0))); do if (!(Ld(e, T(0.0)) | 0)) { a = T(a - e); if (Ld(e, T(1.0)) | 0) { a = T(a + T(1.0)); break; } if (c) { a = T(a + T(1.0)); break; } if (!d) { if (e > T(0.5)) e = T(1.0); else { d = Ld(e, T(0.5)) | 0; e = d ? T(1.0) : T(0.0); } a = T(a + e); } } else a = T(a - e); while (0) return T(a / b); } function Pd(a, b, c, d, e, f, h, i, j, k, l, m, n) { a = a | 0; b = T(b); c = c | 0; d = T(d); e = e | 0; f = T(f); h = h | 0; i = T(i); j = T(j); k = T(k); l = T(l); m = T(m); n = n | 0; var o = 0, p = ib, q = ib, r = ib, s = ib, t = ib, u = ib; if (j < T(0.0) | k < T(0.0)) n = 0; else { if ((n | 0) != 0 ? (p = T(g[n + 4 >> 2]), p != T(0.0)) : 0) { r = T(Od(b, p, 0, 0)); s = T(Od(d, p, 0, 0)); q = T(Od(f, p, 0, 0)); p = T(Od(i, p, 0, 0)); } else { q = f; r = b; p = i; s = d; } if ((e | 0) == (a | 0)) o = Ld(q, r) | 0; else o = 0; if ((h | 0) == (c | 0)) n = Ld(p, s) | 0; else n = 0; if ((!o ? (t = T(b - l), !(Qd(a, t, j) | 0)) : 0) ? !(Rd(a, t, e, j) | 0) : 0) o = Sd(a, t, e, f, j) | 0; else o = 1; if ((!n ? (u = T(d - m), !(Qd(c, u, k) | 0)) : 0) ? !(Rd(c, u, h, k) | 0) : 0) n = Sd(c, u, h, i, k) | 0; else n = 1; n = o & n; } return n | 0; } function Qd(a, b, c) { a = a | 0; b = T(b); c = T(c); if ((a | 0) == 1) a = Ld(b, c) | 0; else a = 0; return a | 0; } function Rd(a, b, c, d) { a = a | 0; b = T(b); c = c | 0; d = T(d); if ((a | 0) == 2 & (c | 0) == 0) { if (!(b >= d)) a = Ld(b, d) | 0; else a = 1; } else a = 0; return a | 0; } function Sd(a, b, c, d, e) { a = a | 0; b = T(b); c = c | 0; d = T(d); e = T(e); if ((a | 0) == 2 & (c | 0) == 2 & d > b) { if (!(e <= b)) a = Ld(b, e) | 0; else a = 1; } else a = 0; return a | 0; } function Td(b, d, e, f, i, j, k, m, n, o, p) { b = b | 0; d = T(d); e = T(e); f = f | 0; i = i | 0; j = j | 0; k = T(k); m = T(m); n = n | 0; o = o | 0; p = p | 0; var q = 0, r = 0, s = 0, t = 0, u = ib, v = ib, w = 0, x = 0, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = ib, I = ib, J = ib, K = 0.0, L = 0.0; G = l; l = l + 160 | 0; D = G + 152 | 0; C = G + 120 | 0; B = G + 104 | 0; y = G + 72 | 0; t = G + 56 | 0; A = G + 8 | 0; x = G; z = (c[2279] | 0) + 1 | 0; c[2279] = z; E = b + 984 | 0; if ((a[E >> 0] | 0) != 0 ? (c[b + 512 >> 2] | 0) != (c[2278] | 0) : 0) w = 4; else if ((c[b + 516 >> 2] | 0) == (f | 0)) F = 0; else w = 4; if ((w | 0) == 4) { c[b + 520 >> 2] = 0; c[b + 924 >> 2] = -1; c[b + 928 >> 2] = -1; g[b + 932 >> 2] = T(-1); g[b + 936 >> 2] = T(-1); F = 1; } a: do if (!(c[b + 964 >> 2] | 0)) { if (n) { q = b + 916 | 0; if (!(Ld(T(g[q >> 2]), d) | 0)) { w = 21; break; } if (!(Ld(T(g[b + 920 >> 2]), e) | 0)) { w = 21; break; } if ((c[b + 924 >> 2] | 0) != (i | 0)) { w = 21; break; } q = (c[b + 928 >> 2] | 0) == (j | 0) ? q : 0; w = 22; break; } s = c[b + 520 >> 2] | 0; if (!s) w = 21; else { r = 0; while(true){ q = b + 524 + (r * 24 | 0) | 0; if (((Ld(T(g[q >> 2]), d) | 0 ? Ld(T(g[b + 524 + (r * 24 | 0) + 4 >> 2]), e) | 0 : 0) ? (c[b + 524 + (r * 24 | 0) + 8 >> 2] | 0) == (i | 0) : 0) ? (c[b + 524 + (r * 24 | 0) + 12 >> 2] | 0) == (j | 0) : 0) { w = 22; break a; } r = r + 1 | 0; if (r >>> 0 >= s >>> 0) { w = 21; break; } } } } else { u = T(Ud(b, 2, k)); v = T(Ud(b, 0, k)); q = b + 916 | 0; J = T(g[q >> 2]); I = T(g[b + 920 >> 2]); H = T(g[b + 932 >> 2]); if (!(Pd(i, d, j, e, c[b + 924 >> 2] | 0, J, c[b + 928 >> 2] | 0, I, H, T(g[b + 936 >> 2]), u, v, p) | 0)) { s = c[b + 520 >> 2] | 0; if (!s) w = 21; else { r = 0; while(true){ q = b + 524 + (r * 24 | 0) | 0; H = T(g[q >> 2]); I = T(g[b + 524 + (r * 24 | 0) + 4 >> 2]); J = T(g[b + 524 + (r * 24 | 0) + 16 >> 2]); if (Pd(i, d, j, e, c[b + 524 + (r * 24 | 0) + 8 >> 2] | 0, H, c[b + 524 + (r * 24 | 0) + 12 >> 2] | 0, I, J, T(g[b + 524 + (r * 24 | 0) + 20 >> 2]), u, v, p) | 0) { w = 22; break a; } r = r + 1 | 0; if (r >>> 0 >= s >>> 0) { w = 21; break; } } } } else w = 22; } while (0) do if ((w | 0) == 21) { if (!(a[11697] | 0)) { q = 0; w = 31; } else { q = 0; w = 28; } } else if ((w | 0) == 22) { r = (a[11697] | 0) != 0; if (!((q | 0) != 0 & (F ^ 1))) { if (r) { w = 28; break; } else { w = 31; break; } } t = q + 16 | 0; c[b + 908 >> 2] = c[t >> 2]; s = q + 20 | 0; c[b + 912 >> 2] = c[s >> 2]; if (!((a[11698] | 0) == 0 | r ^ 1)) { c[x >> 2] = Wd(z) | 0; c[x + 4 >> 2] = z; Vd(b, 4, 2972, x); r = c[b + 972 >> 2] | 0; if (r | 0) nb[r & 127](b); i = Xd(i, n) | 0; j = Xd(j, n) | 0; L = +T(g[t >> 2]); K = +T(g[s >> 2]); c[A >> 2] = i; c[A + 4 >> 2] = j; h[A + 8 >> 3] = +d; h[A + 16 >> 3] = +e; h[A + 24 >> 3] = L; h[A + 32 >> 3] = K; c[A + 40 >> 2] = o; Vd(b, 4, 2989, A); } } while (0) if ((w | 0) == 28) { r = Wd(z) | 0; c[t >> 2] = r; c[t + 4 >> 2] = z; c[t + 8 >> 2] = F ? 3047 : 11699; Vd(b, 4, 3038, t); r = c[b + 972 >> 2] | 0; if (r | 0) nb[r & 127](b); A = Xd(i, n) | 0; w = Xd(j, n) | 0; c[y >> 2] = A; c[y + 4 >> 2] = w; h[y + 8 >> 3] = +d; h[y + 16 >> 3] = +e; c[y + 24 >> 2] = o; Vd(b, 4, 3049, y); w = 31; } if ((w | 0) == 31) { Yd(b, d, e, f, i, j, k, m, n, p); if (a[11697] | 0) { r = c[2279] | 0; A = Wd(r) | 0; c[B >> 2] = A; c[B + 4 >> 2] = r; c[B + 8 >> 2] = F ? 3047 : 11699; Vd(b, 4, 3083, B); r = c[b + 972 >> 2] | 0; if (r | 0) nb[r & 127](b); A = Xd(i, n) | 0; B = Xd(j, n) | 0; K = +T(g[b + 908 >> 2]); L = +T(g[b + 912 >> 2]); c[C >> 2] = A; c[C + 4 >> 2] = B; h[C + 8 >> 3] = K; h[C + 16 >> 3] = L; c[C + 24 >> 2] = o; Vd(b, 4, 3092, C); } c[b + 516 >> 2] = f; if (!q) { r = b + 520 | 0; q = c[r >> 2] | 0; if ((q | 0) == 16) { if (a[11697] | 0) Vd(b, 4, 3124, D); c[r >> 2] = 0; q = 0; } if (n) q = b + 916 | 0; else { c[r >> 2] = q + 1; q = b + 524 + (q * 24 | 0) | 0; } g[q >> 2] = d; g[q + 4 >> 2] = e; c[q + 8 >> 2] = i; c[q + 12 >> 2] = j; c[q + 16 >> 2] = c[b + 908 >> 2]; c[q + 20 >> 2] = c[b + 912 >> 2]; q = 0; } } if (n) { c[b + 416 >> 2] = c[b + 908 >> 2]; c[b + 420 >> 2] = c[b + 912 >> 2]; a[b + 985 >> 0] = 1; a[E >> 0] = 0; } c[2279] = (c[2279] | 0) + -1; c[b + 512 >> 2] = c[2278]; l = G; return F | (q | 0) == 0 | 0; } function Ud(a, b, c) { a = a | 0; b = b | 0; c = T(c); var d = ib; d = T(me(a, b, c)); return T(d + T(ne(a, b, c))); } function Vd(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = l + 16 | 0; f = g; c[f >> 2] = e; if (!a) e = 0; else e = c[a + 976 >> 2] | 0; ge(e, a, b, d, f); l = g; return; } function Wd(a) { a = a | 0; return (a >>> 0 > 60 ? 3201 : 3201 + (60 - a) | 0) | 0; } function Xd(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 32 | 0; d = f + 12 | 0; e = f; c[d >> 2] = c[254]; c[d + 4 >> 2] = c[255]; c[d + 8 >> 2] = c[256]; c[e >> 2] = c[257]; c[e + 4 >> 2] = c[258]; c[e + 8 >> 2] = c[259]; if ((a | 0) > 2) a = 11699; else a = c[(b ? e : d) + (a << 2) >> 2] | 0; l = f; return a | 0; } function Yd(b, e, f, h, i, k, m, n, o, p) { b = b | 0; e = T(e); f = T(f); h = h | 0; i = i | 0; k = k | 0; m = T(m); n = T(n); o = o | 0; p = p | 0; var q = 0, r = 0, s = 0, t = 0, u = ib, v = ib, w = ib, x = ib, y = ib, z = ib, A = ib, B = 0, C = 0, D = 0, E = ib, F = ib, G = 0, H = ib, I = 0, J = 0, K = 0, L = 0, M = 0, N = 0, O = 0, P = 0, Q = 0, R = 0, S = 0, U = 0, V = 0, W = 0, X = 0, Y = 0, Z = 0, _ = 0, $ = ib, aa = ib, ba = ib, ca = ib, da = ib, ea = 0, fa = 0, ga = 0, ha = 0, ia = 0, ja = ib, ka = ib, la = ib, ma = ib, na = ib, oa = ib, pa = 0, qa = ib, ra = ib, sa = ib, ta = ib, ua = ib, va = ib, wa = 0, xa = 0, ya = ib, za = ib, Aa = 0, Ba = 0, Ca = 0, Da = 0, Ea = ib, Fa = 0, Ga = 0, Ha = 0, Ia = 0, Ja = 0, Ka = 0, La = 0, Ma = ib, Na = 0, Oa = 0; La = l; l = l + 16 | 0; ea = La + 12 | 0; fa = La + 8 | 0; ga = La + 4 | 0; ha = La; ec(b, (i | 0) == 0 | (Sb(e) | 0) ^ 1, 3326); ec(b, (k | 0) == 0 | (Sb(f) | 0) ^ 1, 3406); Ga = qe(b, h) | 0; c[b + 496 >> 2] = Ga; Ja = re(2, Ga) | 0; Ka = re(0, Ga) | 0; g[b + 440 >> 2] = T(me(b, Ja, m)); g[b + 444 >> 2] = T(ne(b, Ja, m)); g[b + 428 >> 2] = T(me(b, Ka, m)); g[b + 436 >> 2] = T(ne(b, Ka, m)); g[b + 464 >> 2] = T(se(b, Ja)); g[b + 468 >> 2] = T(te(b, Ja)); g[b + 452 >> 2] = T(se(b, Ka)); g[b + 460 >> 2] = T(te(b, Ka)); g[b + 488 >> 2] = T(ue(b, Ja, m)); g[b + 492 >> 2] = T(ve(b, Ja, m)); g[b + 476 >> 2] = T(ue(b, Ka, m)); g[b + 484 >> 2] = T(ve(b, Ka, m)); do if (!(c[b + 964 >> 2] | 0)) { Ha = b + 948 | 0; Ia = (c[b + 952 >> 2] | 0) - (c[Ha >> 2] | 0) >> 2; if (!Ia) { xe(b, e, f, i, k, m, n); break; } if (!o ? ye(b, e, f, i, k, m, n) | 0 : 0) break; lc(b); Y = b + 508 | 0; a[Y >> 0] = 0; Ja = re(c[b + 4 >> 2] | 0, Ga) | 0; Ka = ze(Ja, Ga) | 0; Fa = oe(Ja) | 0; Z = c[b + 8 >> 2] | 0; Ba = b + 28 | 0; _ = (c[Ba >> 2] | 0) != 0; ua = Fa ? m : n; ya = Fa ? n : m; $ = T(Ae(b, Ja, m)); aa = T(Be(b, Ja, m)); u = T(Ae(b, Ka, m)); va = T(Ce(b, Ja, m)); za = T(Ce(b, Ka, m)); D = Fa ? i : k; Aa = Fa ? k : i; Ea = Fa ? va : za; y = Fa ? za : va; ta = T(Ud(b, 2, m)); x = T(Ud(b, 0, m)); v = T(T(be(b + 364 | 0, m)) - Ea); w = T(T(be(b + 380 | 0, m)) - Ea); z = T(T(be(b + 372 | 0, n)) - y); A = T(T(be(b + 388 | 0, n)) - y); ba = Fa ? v : z; ca = Fa ? w : A; ta = T(e - ta); e = T(ta - Ea); if (Sb(e) | 0) Ea = e; else Ea = T(cC(T(eC(e, w)), v)); ra = T(f - x); e = T(ra - y); if (Sb(e) | 0) sa = e; else sa = T(cC(T(eC(e, A)), z)); v = Fa ? Ea : sa; qa = Fa ? sa : Ea; a: do if ((D | 0) == 1) { h = 0; r = 0; while(true){ q = ac(b, r) | 0; if (!h) { if (T(Ee(q)) > T(0.0) ? T(Fe(q)) > T(0.0) : 0) h = q; else h = 0; } else if (De(q) | 0) { t = 0; break a; } r = r + 1 | 0; if (r >>> 0 >= Ia >>> 0) { t = h; break; } } } else t = 0; while (0) B = t + 500 | 0; C = t + 504 | 0; h = 0; q = 0; e = T(0.0); s = 0; do { r = c[(c[Ha >> 2] | 0) + (s << 2) >> 2] | 0; if ((c[r + 36 >> 2] | 0) == 1) { Ge(r); a[r + 985 >> 0] = 1; a[r + 984 >> 0] = 0; } else { $d(r); if (o) ce(r, qe(r, Ga) | 0, v, qa, Ea); do if ((c[r + 24 >> 2] | 0) != 1) { if ((r | 0) == (t | 0)) { c[B >> 2] = c[2278]; g[C >> 2] = T(0.0); break; } else { He(b, r, Ea, i, sa, Ea, sa, k, Ga, p); break; } } else { if (q | 0) c[q + 960 >> 2] = r; c[r + 960 >> 2] = 0; q = r; h = (h | 0) == 0 ? r : h; } while (0) oa = T(g[r + 504 >> 2]); e = T(e + T(oa + T(Ud(r, Ja, Ea)))); } s = s + 1 | 0; }while ((s | 0) != (Ia | 0)) K = e > v; pa = _ & ((D | 0) == 2 & K) ? 1 : D; I = (Aa | 0) == 1; M = I & (o ^ 1); N = (pa | 0) == 1; O = (pa | 0) == 2; P = 976 + (Ja << 2) | 0; Q = (Aa | 2) == 2; W = I & (_ ^ 1); R = 1040 + (Ka << 2) | 0; S = 1040 + (Ja << 2) | 0; U = 976 + (Ka << 2) | 0; V = (Aa | 0) != 1; K = _ & ((D | 0) != 0 & K); J = b + 976 | 0; I = I ^ 1; e = v; G = 0; L = 0; oa = T(0.0); da = T(0.0); while(true){ b: do if (G >>> 0 < Ia >>> 0) { C = c[Ha >> 2] | 0; s = 0; A = T(0.0); z = T(0.0); w = T(0.0); v = T(0.0); r = 0; q = 0; t = G; while(true){ B = c[C + (t << 2) >> 2] | 0; if ((c[B + 36 >> 2] | 0) != 1 ? (c[B + 940 >> 2] = L, (c[B + 24 >> 2] | 0) != 1) : 0) { x = T(Ud(B, Ja, Ea)); X = c[P >> 2] | 0; f = T(be(B + 380 + (X << 3) | 0, ua)); y = T(g[B + 504 >> 2]); f = T(eC(f, y)); f = T(cC(T(be(B + 364 + (X << 3) | 0, ua)), f)); if (_ & (s | 0) != 0 & T(x + T(z + f)) > e) { k = s; x = A; D = t; break b; } x = T(x + f); f = T(z + x); x = T(A + x); if (De(B) | 0) { w = T(w + T(Ee(B))); v = T(v - T(y * T(Fe(B)))); } if (q | 0) c[q + 960 >> 2] = B; c[B + 960 >> 2] = 0; s = s + 1 | 0; q = B; r = (r | 0) == 0 ? B : r; } else { x = A; f = z; } t = t + 1 | 0; if (t >>> 0 < Ia >>> 0) { A = x; z = f; } else { k = s; D = t; break; } } } else { k = 0; x = T(0.0); w = T(0.0); v = T(0.0); r = 0; D = G; } while (0) X = w > T(0.0) & w < T(1.0); E = X ? T(1.0) : w; X = v > T(0.0) & v < T(1.0); A = X ? T(1.0) : v; do if (!N) { if (!(x < ba & ((Sb(ba) | 0) ^ 1))) { if (!(x > ca & ((Sb(ca) | 0) ^ 1))) { if (!(a[(c[J >> 2] | 0) + 3 >> 0] | 0)) { if (!(E == T(0.0)) ? !(T(Ee(b)) == T(0.0)) : 0) { X = 53; break; } e = x; X = 53; } else X = 51; } else { e = ca; X = 51; } } else { e = ba; X = 51; } } else X = 51; while (0) if ((X | 0) == 51) { X = 0; if (Sb(e) | 0) X = 53; else { F = T(e - x); H = e; } } if ((X | 0) == 53) { X = 0; if (x < T(0.0)) { F = T(-x); H = e; } else { F = T(0.0); H = e; } } if (!M ? (ia = (r | 0) == 0, !ia) : 0) { s = c[P >> 2] | 0; t = F < T(0.0); y = T(F / A); B = F > T(0.0); z = T(F / E); w = T(0.0); x = T(0.0); e = T(0.0); q = r; do { f = T(be(q + 380 + (s << 3) | 0, ua)); v = T(be(q + 364 + (s << 3) | 0, ua)); v = T(eC(f, T(cC(v, T(g[q + 504 >> 2]))))); if (t) { f = T(v * T(Fe(q))); if (f != T(-0) ? (Ma = T(v - T(y * f)), ja = T(Ie(q, Ja, Ma, H, Ea)), Ma != ja) : 0) { w = T(w - T(ja - v)); e = T(e + f); } } else if ((B ? (ka = T(Ee(q)), ka != T(0.0)) : 0) ? (Ma = T(v + T(z * ka)), la = T(Ie(q, Ja, Ma, H, Ea)), Ma != la) : 0) { w = T(w - T(la - v)); x = T(x - ka); } q = c[q + 960 >> 2] | 0; }while ((q | 0) != 0) e = T(A + e); v = T(F + w); if (!ia) { y = T(E + x); t = c[P >> 2] | 0; B = v < T(0.0); C = e == T(0.0); z = T(v / e); s = v > T(0.0); y = T(v / y); e = T(0.0); do { Ma = T(be(r + 380 + (t << 3) | 0, ua)); w = T(be(r + 364 + (t << 3) | 0, ua)); w = T(eC(Ma, T(cC(w, T(g[r + 504 >> 2]))))); if (B) { Ma = T(w * T(Fe(r))); v = T(-Ma); if (Ma != T(-0)) { Ma = T(z * v); v = T(Ie(r, Ja, T(w + (C ? v : Ma)), H, Ea)); } else v = w; } else if (s ? (ma = T(Ee(r)), ma != T(0.0)) : 0) v = T(Ie(r, Ja, T(w + T(y * ma)), H, Ea)); else v = w; e = T(e - T(v - w)); x = T(Ud(r, Ja, Ea)); f = T(Ud(r, Ka, Ea)); v = T(v + x); g[fa >> 2] = v; c[ha >> 2] = 1; w = T(g[r + 396 >> 2]); c: do if (Sb(w) | 0) { q = Sb(qa) | 0; do if (!q) { if (K | (ae(r, Ka, qa) | 0 | I)) break; if ((Je(b, r) | 0) != 4) break; if ((c[(Ke(r, Ka) | 0) + 4 >> 2] | 0) == 3) break; if ((c[(Le(r, Ka) | 0) + 4 >> 2] | 0) == 3) break; g[ea >> 2] = qa; c[ga >> 2] = 1; break c; } while (0) if (ae(r, Ka, qa) | 0) { q = c[r + 992 + (c[U >> 2] << 2) >> 2] | 0; Ma = T(f + T(be(q, qa))); g[ea >> 2] = Ma; q = V & (c[q + 4 >> 2] | 0) == 2; c[ga >> 2] = ((Sb(Ma) | 0 | q) ^ 1) & 1; break; } else { g[ea >> 2] = qa; c[ga >> 2] = q ? 0 : 2; break; } } else { Ma = T(v - x); E = T(Ma / w); Ma = T(w * Ma); c[ga >> 2] = 1; g[ea >> 2] = T(f + (Fa ? E : Ma)); } while (0) Me(r, Ja, H, Ea, ha, fa); Me(r, Ka, qa, Ea, ga, ea); do if (!(ae(r, Ka, qa) | 0) ? (Je(b, r) | 0) == 4 : 0) { if ((c[(Ke(r, Ka) | 0) + 4 >> 2] | 0) == 3) { q = 0; break; } q = (c[(Le(r, Ka) | 0) + 4 >> 2] | 0) != 3; } else q = 0; while (0) Ma = T(g[fa >> 2]); E = T(g[ea >> 2]); Na = c[ha >> 2] | 0; Oa = c[ga >> 2] | 0; Td(r, Fa ? Ma : E, Fa ? E : Ma, Ga, Fa ? Na : Oa, Fa ? Oa : Na, Ea, sa, o & (q ^ 1), 3488, p); a[Y >> 0] = a[Y >> 0] | a[r + 508 >> 0]; r = c[r + 960 >> 2] | 0; }while ((r | 0) != 0) } else e = T(0.0); } else e = T(0.0); e = T(F + e); Oa = e < T(0.0) & 1; a[Y >> 0] = Oa | d[Y >> 0]; if (O & e > T(0.0)) { q = c[P >> 2] | 0; if ((c[b + 364 + (q << 3) + 4 >> 2] | 0) != 0 ? (na = T(be(b + 364 + (q << 3) | 0, ua)), na >= T(0.0)) : 0) v = T(cC(T(0.0), T(na - T(H - e)))); else v = T(0.0); } else v = e; B = G >>> 0 < D >>> 0; if (B) { t = c[Ha >> 2] | 0; s = G; q = 0; do { r = c[t + (s << 2) >> 2] | 0; if (!(c[r + 24 >> 2] | 0)) { q = ((c[(Ke(r, Ja) | 0) + 4 >> 2] | 0) == 3 & 1) + q | 0; q = q + ((c[(Le(r, Ja) | 0) + 4 >> 2] | 0) == 3 & 1) | 0; } s = s + 1 | 0; }while ((s | 0) != (D | 0)) if (q) { x = T(0.0); f = T(0.0); } else X = 101; } else X = 101; d: if ((X | 0) == 101) { X = 0; switch(Z | 0){ case 1: q = 0; x = T(v * T(0.5)); f = T(0.0); break d; case 2: q = 0; x = v; f = T(0.0); break d; case 3: if (k >>> 0 <= 1) { q = 0; x = T(0.0); f = T(0.0); break d; } f = T((k + -1 | 0) >>> 0); q = 0; x = T(0.0); f = T(T(cC(v, T(0.0))) / f); break d; case 5: f = T(v / T((k + 1 | 0) >>> 0)); q = 0; x = f; break d; case 4: f = T(v / T(k >>> 0)); q = 0; x = T(f * T(0.5)); break d; default: q = 0; x = T(0.0); f = T(0.0); break d; } } e = T($ + x); if (B) { w = T(v / T(q | 0)); s = c[Ha >> 2] | 0; r = G; v = T(0.0); do { q = c[s + (r << 2) >> 2] | 0; e: do if ((c[q + 36 >> 2] | 0) != 1) { switch(c[q + 24 >> 2] | 0){ case 1: if (Ne(q, Ja) | 0) { if (!o) break e; Ma = T(Oe(q, Ja, H)); Ma = T(Ma + T(se(b, Ja))); Ma = T(Ma + T(me(q, Ja, Ea))); g[q + 400 + (c[S >> 2] << 2) >> 2] = Ma; break e; } break; case 0: Oa = (c[(Ke(q, Ja) | 0) + 4 >> 2] | 0) == 3; Ma = T(w + e); e = Oa ? Ma : e; if (o) { Oa = q + 400 + (c[S >> 2] << 2) | 0; g[Oa >> 2] = T(e + T(g[Oa >> 2])); } Oa = (c[(Le(q, Ja) | 0) + 4 >> 2] | 0) == 3; Ma = T(w + e); e = Oa ? Ma : e; if (M) { Ma = T(f + T(Ud(q, Ja, Ea))); v = qa; e = T(e + T(Ma + T(g[q + 504 >> 2]))); break e; } else { e = T(e + T(f + T(Pe(q, Ja, Ea)))); v = T(cC(v, T(Pe(q, Ka, Ea)))); break e; } default: } if (o) { Ma = T(x + T(se(b, Ja))); Oa = q + 400 + (c[S >> 2] << 2) | 0; g[Oa >> 2] = T(Ma + T(g[Oa >> 2])); } } while (0) r = r + 1 | 0; }while ((r | 0) != (D | 0)) } else v = T(0.0); f = T(aa + e); if (Q) x = T(T(Ie(b, Ka, T(za + v), ya, m)) - za); else x = qa; w = T(T(Ie(b, Ka, T(za + (W ? qa : v)), ya, m)) - za); if (B & o) { r = G; do { s = c[(c[Ha >> 2] | 0) + (r << 2) >> 2] | 0; do if ((c[s + 36 >> 2] | 0) != 1) { if ((c[s + 24 >> 2] | 0) == 1) { if (Ne(s, Ka) | 0) { Ma = T(Oe(s, Ka, qa)); Ma = T(Ma + T(se(b, Ka))); Ma = T(Ma + T(me(s, Ka, Ea))); q = c[R >> 2] | 0; g[s + 400 + (q << 2) >> 2] = Ma; if (!(Sb(Ma) | 0)) break; } else q = c[R >> 2] | 0; Ma = T(se(b, Ka)); g[s + 400 + (q << 2) >> 2] = T(Ma + T(me(s, Ka, Ea))); break; } q = Je(b, s) | 0; do if ((q | 0) == 4) { if ((c[(Ke(s, Ka) | 0) + 4 >> 2] | 0) == 3) { X = 139; break; } if ((c[(Le(s, Ka) | 0) + 4 >> 2] | 0) == 3) { X = 139; break; } if (ae(s, Ka, qa) | 0) { e = u; break; } Na = c[s + 908 + (c[P >> 2] << 2) >> 2] | 0; c[ea >> 2] = Na; e = T(g[s + 396 >> 2]); Oa = Sb(e) | 0; v = (c[j >> 2] = Na, T(g[j >> 2])); if (Oa) e = w; else { F = T(Ud(s, Ka, Ea)); Ma = T(v / e); e = T(e * v); e = T(F + (Fa ? Ma : e)); } g[fa >> 2] = e; g[ea >> 2] = T(T(Ud(s, Ja, Ea)) + v); c[ga >> 2] = 1; c[ha >> 2] = 1; Me(s, Ja, H, Ea, ga, ea); Me(s, Ka, qa, Ea, ha, fa); e = T(g[ea >> 2]); F = T(g[fa >> 2]); Ma = Fa ? e : F; e = Fa ? F : e; Oa = ((Sb(Ma) | 0) ^ 1) & 1; Td(s, Ma, e, Ga, Oa, ((Sb(e) | 0) ^ 1) & 1, Ea, sa, 1, 3493, p); e = u; } else X = 139; while (0) f: do if ((X | 0) == 139) { X = 0; e = T(x - T(Pe(s, Ka, Ea))); do if ((c[(Ke(s, Ka) | 0) + 4 >> 2] | 0) == 3) { if ((c[(Le(s, Ka) | 0) + 4 >> 2] | 0) != 3) break; e = T(u + T(cC(T(0.0), T(e * T(0.5))))); break f; } while (0) if ((c[(Le(s, Ka) | 0) + 4 >> 2] | 0) == 3) { e = u; break; } if ((c[(Ke(s, Ka) | 0) + 4 >> 2] | 0) == 3) { e = T(u + T(cC(T(0.0), e))); break; } switch(q | 0){ case 1: e = u; break f; case 2: e = T(u + T(e * T(0.5))); break f; default: e = T(u + e); break f; } } while (0) Ma = T(oa + e); Oa = s + 400 + (c[R >> 2] << 2) | 0; g[Oa >> 2] = T(Ma + T(g[Oa >> 2])); } while (0) r = r + 1 | 0; }while ((r | 0) != (D | 0)) } oa = T(oa + w); da = T(cC(da, f)); k = L + 1 | 0; if (D >>> 0 >= Ia >>> 0) break; else { e = H; G = D; L = k; } } do if (o) { q = k >>> 0 > 1; if (!q ? !(Qe(b) | 0) : 0) break; if (!(Sb(qa) | 0)) { e = T(qa - oa); g: do switch(c[b + 12 >> 2] | 0){ case 3: u = T(u + e); z = T(0.0); break; case 2: u = T(u + T(e * T(0.5))); z = T(0.0); break; case 4: if (qa > oa) z = T(e / T(k >>> 0)); else z = T(0.0); break; case 7: if (qa > oa) { u = T(u + T(e / T(k << 1 >>> 0))); z = T(e / T(k >>> 0)); z = q ? z : T(0.0); break g; } else { u = T(u + T(e * T(0.5))); z = T(0.0); break g; } case 6: z = T(e / T(L >>> 0)); z = qa > oa & q ? z : T(0.0); break; default: z = T(0.0); } while (0) if (k | 0) { B = 1040 + (Ka << 2) | 0; C = 976 + (Ka << 2) | 0; t = 0; r = 0; while(true){ h: do if (r >>> 0 < Ia >>> 0) { v = T(0.0); w = T(0.0); e = T(0.0); s = r; while(true){ q = c[(c[Ha >> 2] | 0) + (s << 2) >> 2] | 0; do if ((c[q + 36 >> 2] | 0) != 1 ? (c[q + 24 >> 2] | 0) == 0 : 0) { if ((c[q + 940 >> 2] | 0) != (t | 0)) break h; if (Re(q, Ka) | 0) { Ma = T(g[q + 908 + (c[C >> 2] << 2) >> 2]); e = T(cC(e, T(Ma + T(Ud(q, Ka, Ea))))); } if ((Je(b, q) | 0) != 5) break; na = T(Se(q)); na = T(na + T(me(q, 0, Ea))); Ma = T(g[q + 912 >> 2]); Ma = T(T(Ma + T(Ud(q, 0, Ea))) - na); na = T(cC(w, na)); Ma = T(cC(v, Ma)); v = Ma; w = na; e = T(cC(e, T(na + Ma))); } while (0) q = s + 1 | 0; if (q >>> 0 < Ia >>> 0) s = q; else { s = q; break; } } } else { w = T(0.0); e = T(0.0); s = r; } while (0) y = T(z + e); f = u; u = T(u + y); if (r >>> 0 < s >>> 0) { x = T(f + w); q = r; do { r = c[(c[Ha >> 2] | 0) + (q << 2) >> 2] | 0; i: if ((c[r + 36 >> 2] | 0) != 1 ? (c[r + 24 >> 2] | 0) == 0 : 0) switch(Je(b, r) | 0){ case 1: Ma = T(f + T(me(r, Ka, Ea))); g[r + 400 + (c[B >> 2] << 2) >> 2] = Ma; break i; case 3: Ma = T(T(u - T(ne(r, Ka, Ea))) - T(g[r + 908 + (c[C >> 2] << 2) >> 2])); g[r + 400 + (c[B >> 2] << 2) >> 2] = Ma; break i; case 2: Ma = T(f + T(T(y - T(g[r + 908 + (c[C >> 2] << 2) >> 2])) * T(0.5))); g[r + 400 + (c[B >> 2] << 2) >> 2] = Ma; break i; case 4: Ma = T(f + T(me(r, Ka, Ea))); g[r + 400 + (c[B >> 2] << 2) >> 2] = Ma; if (ae(r, Ka, qa) | 0) break i; if (Fa) { v = T(g[r + 908 >> 2]); e = T(v + T(Ud(r, Ja, Ea))); w = y; } else { w = T(g[r + 912 >> 2]); w = T(w + T(Ud(r, Ka, Ea))); e = y; v = T(g[r + 908 >> 2]); } if (Ld(e, v) | 0 ? Ld(w, T(g[r + 912 >> 2])) | 0 : 0) break i; Td(r, e, w, Ga, 1, 1, Ea, sa, 1, 3501, p); break i; case 5: g[r + 404 >> 2] = T(T(x - T(Se(r))) + T(Oe(r, 0, qa))); break i; default: break i; } q = q + 1 | 0; }while ((q | 0) != (s | 0)) } t = t + 1 | 0; if ((t | 0) == (k | 0)) break; else r = s; } } } } while (0) g[b + 908 >> 2] = T(Ie(b, 2, ta, m, m)); g[b + 912 >> 2] = T(Ie(b, 0, ra, n, m)); if ((pa | 0) != 0 ? (wa = c[b + 32 >> 2] | 0, xa = (pa | 0) == 2, !(xa & (wa | 0) != 2)) : 0) { if (xa & (wa | 0) == 2) { e = T(va + H); e = T(cC(T(eC(e, T(Te(b, Ja, da, ua)))), va)); X = 198; } } else { e = T(Ie(b, Ja, da, ua, m)); X = 198; } if ((X | 0) == 198) g[b + 908 + (c[976 + (Ja << 2) >> 2] << 2) >> 2] = e; if ((Aa | 0) != 0 ? (Ca = c[b + 32 >> 2] | 0, Da = (Aa | 0) == 2, !(Da & (Ca | 0) != 2)) : 0) { if (Da & (Ca | 0) == 2) { e = T(za + qa); e = T(cC(T(eC(e, T(Te(b, Ka, T(za + oa), ya)))), za)); X = 204; } } else { e = T(Ie(b, Ka, T(za + oa), ya, m)); X = 204; } if ((X | 0) == 204) g[b + 908 + (c[976 + (Ka << 2) >> 2] << 2) >> 2] = e; if (o) { if ((c[Ba >> 2] | 0) == 2) { r = 976 + (Ka << 2) | 0; s = 1040 + (Ka << 2) | 0; q = 0; do { t = ac(b, q) | 0; if (!(c[t + 24 >> 2] | 0)) { Na = c[r >> 2] | 0; Ma = T(g[b + 908 + (Na << 2) >> 2]); Oa = t + 400 + (c[s >> 2] << 2) | 0; Ma = T(Ma - T(g[Oa >> 2])); g[Oa >> 2] = T(Ma - T(g[t + 908 + (Na << 2) >> 2])); } q = q + 1 | 0; }while ((q | 0) != (Ia | 0)) } if (h | 0) { q = Fa ? pa : i; do { Ue(b, h, Ea, q, sa, Ga, p); h = c[h + 960 >> 2] | 0; }while ((h | 0) != 0) } q = (Ja | 2) == 3; r = (Ka | 2) == 3; if (q | r) { h = 0; do { s = c[(c[Ha >> 2] | 0) + (h << 2) >> 2] | 0; if ((c[s + 36 >> 2] | 0) != 1) { if (q) Ve(b, s, Ja); if (r) Ve(b, s, Ka); } h = h + 1 | 0; }while ((h | 0) != (Ia | 0)) } } } else we(b, e, f, i, k, m, n); while (0) l = La; return; } function Zd(a, b) { a = a | 0; b = T(b); var c = 0; Vb(a, b >= T(0.0), 3147); c = b == T(0.0); g[a + 4 >> 2] = c ? T(0.0) : b; return; } function _d(b, d, e, f) { b = b | 0; d = T(d); e = T(e); f = f | 0; var h = ib, i = ib, j = 0, k = 0, l = 0; c[2278] = (c[2278] | 0) + 1; $d(b); if (!(ae(b, 2, d) | 0)) { h = T(be(b + 380 | 0, d)); if (!(h >= T(0.0))) { l = ((Sb(d) | 0) ^ 1) & 1; h = d; } else l = 2; } else { h = T(be(c[b + 992 >> 2] | 0, d)); l = 1; h = T(h + T(Ud(b, 2, d))); } if (!(ae(b, 0, e) | 0)) { i = T(be(b + 388 | 0, e)); if (!(i >= T(0.0))) { k = ((Sb(e) | 0) ^ 1) & 1; i = e; } else k = 2; } else { i = T(be(c[b + 996 >> 2] | 0, e)); k = 1; i = T(i + T(Ud(b, 0, d))); } j = b + 976 | 0; if (Td(b, h, i, f, l, k, d, e, 1, 3189, c[j >> 2] | 0) | 0 ? (ce(b, c[b + 496 >> 2] | 0, d, e, d), de(b, T(g[(c[j >> 2] | 0) + 4 >> 2]), T(0.0), T(0.0)), a[11696] | 0) : 0) Md(b, 7); return; } function $d(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; h = i + 24 | 0; g = i + 16 | 0; e = i + 8 | 0; f = i; d = 0; do { b = a + 380 + (d << 3) | 0; if (!((c[a + 380 + (d << 3) + 4 >> 2] | 0) != 0 ? (j = b, k = c[j + 4 >> 2] | 0, m = e, c[m >> 2] = c[j >> 2], c[m + 4 >> 2] = k, m = a + 364 + (d << 3) | 0, k = c[m + 4 >> 2] | 0, j = f, c[j >> 2] = c[m >> 2], c[j + 4 >> 2] = k, c[g >> 2] = c[e >> 2], c[g + 4 >> 2] = c[e + 4 >> 2], c[h >> 2] = c[f >> 2], c[h + 4 >> 2] = c[f + 4 >> 2], Kd(g, h) | 0) : 0)) b = a + 348 + (d << 3) | 0; c[a + 992 + (d << 2) >> 2] = b; d = d + 1 | 0; }while ((d | 0) != 2) l = i; return; } function ae(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0; a = c[a + 992 + (c[976 + (b << 2) >> 2] << 2) >> 2] | 0; switch(c[a + 4 >> 2] | 0){ case 0: case 3: a = 0; break; case 1: if (T(g[a >> 2]) < T(0.0)) a = 0; else e = 5; break; case 2: if (T(g[a >> 2]) < T(0.0)) a = 0; else a = (Sb(d) | 0) ^ 1; break; default: e = 5; } if ((e | 0) == 5) a = 1; return a | 0; } function be(a, b) { a = a | 0; b = T(b); switch(c[a + 4 >> 2] | 0){ case 2: b = T(T(T(g[a >> 2]) * b) / T(100.0)); break; case 1: b = T(g[a >> 2]); break; default: b = T(t); } return T(b); } function ce(a, b, d, e, f) { a = a | 0; b = b | 0; d = T(d); e = T(e); f = T(f); var h = 0, i = ib; b = c[a + 944 >> 2] | 0 ? b : 1; h = re(c[a + 4 >> 2] | 0, b) | 0; b = ze(h, b) | 0; d = T($e(a, h, d)); e = T($e(a, b, e)); i = T(d + T(me(a, h, f))); g[a + 400 + (c[1040 + (h << 2) >> 2] << 2) >> 2] = i; d = T(d + T(ne(a, h, f))); g[a + 400 + (c[1e3 + (h << 2) >> 2] << 2) >> 2] = d; d = T(e + T(me(a, b, f))); g[a + 400 + (c[1040 + (b << 2) >> 2] << 2) >> 2] = d; f = T(e + T(ne(a, b, f))); g[a + 400 + (c[1e3 + (b << 2) >> 2] << 2) >> 2] = f; return; } function de(a, b, d, e) { a = a | 0; b = T(b); d = T(d); e = T(e); var f = 0, h = 0, i = ib, j = ib, k = 0, l = 0, m = ib, n = 0, o = ib, p = ib, q = ib, r = ib; if (!(b == T(0.0))) { f = a + 400 | 0; r = T(g[f >> 2]); h = a + 404 | 0; q = T(g[h >> 2]); n = a + 416 | 0; p = T(g[n >> 2]); l = a + 420 | 0; i = T(g[l >> 2]); o = T(r + d); m = T(q + e); e = T(o + p); j = T(m + i); k = (c[a + 988 >> 2] | 0) == 1; g[f >> 2] = T(Od(r, b, 0, k)); g[h >> 2] = T(Od(q, b, 0, k)); d = T(gC(T(p * b), T(1.0))); if (Ld(d, T(0.0)) | 0) h = 0; else h = (Ld(d, T(1.0)) | 0) ^ 1; d = T(gC(T(i * b), T(1.0))); if (Ld(d, T(0.0)) | 0) f = 0; else f = (Ld(d, T(1.0)) | 0) ^ 1; r = T(Od(e, b, k & h, k & (h ^ 1))); g[n >> 2] = T(r - T(Od(o, b, 0, k))); r = T(Od(j, b, k & f, k & (f ^ 1))); g[l >> 2] = T(r - T(Od(m, b, 0, k))); h = (c[a + 952 >> 2] | 0) - (c[a + 948 >> 2] | 0) >> 2; if (h | 0) { f = 0; do { de(ac(a, f) | 0, b, o, m); f = f + 1 | 0; }while ((f | 0) != (h | 0)) } } return; } function ee(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; switch(d | 0){ case 5: case 0: a = CB(c[489] | 0, e, f) | 0; break; default: a = iC(e, f) | 0; } return a | 0; } function fe(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; f = l; l = l + 16 | 0; g = f; c[g >> 2] = e; ge(a, 0, b, d, g); l = f; return; } function ge(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; a = a | 0 ? a : 956; Bb[c[a + 8 >> 2] & 1](a, b, d, e, f); if ((d | 0) == 5) Ta(); else return; } function he(b, c, d) { b = b | 0; c = c | 0; d = d | 0; a[b + c >> 0] = d & 1; return; } function ie(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[a + 4 >> 2] = 0; c[a + 8 >> 2] = 0; d = b + 4 | 0; e = (c[d >> 2] | 0) - (c[b >> 2] | 0) >> 2; if (e | 0) { je(a, e); ke(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function je(a, b) { a = a | 0; b = b | 0; var d = 0; if ((le(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[a + 4 >> 2] = d; c[a >> 2] = d; c[a + 8 >> 2] = d + (b << 2); return; } } function ke(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = a + 4 | 0; a = d - b | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0); c[e >> 2] = (c[e >> 2] | 0) + (a >>> 2 << 2); } return; } function le(a) { a = a | 0; return 1073741823; } function me(a, b, d) { a = a | 0; b = b | 0; d = T(d); if (oe(b) | 0 ? (c[a + 96 >> 2] | 0) != 0 : 0) a = a + 92 | 0; else a = Tb(a + 60 | 0, c[1040 + (b << 2) >> 2] | 0, 992) | 0; return T(pe(a, d)); } function ne(a, b, d) { a = a | 0; b = b | 0; d = T(d); if (oe(b) | 0 ? (c[a + 104 >> 2] | 0) != 0 : 0) a = a + 100 | 0; else a = Tb(a + 60 | 0, c[1e3 + (b << 2) >> 2] | 0, 992) | 0; return T(pe(a, d)); } function oe(a) { a = a | 0; return (a | 1) == 3 | 0; } function pe(a, b) { a = a | 0; b = T(b); if ((c[a + 4 >> 2] | 0) == 3) b = T(0.0); else b = T(be(a, b)); return T(b); } function qe(a, b) { a = a | 0; b = b | 0; a = c[a >> 2] | 0; return ((a | 0) == 0 ? (b | 0) > 1 ? b : 1 : a) | 0; } function re(a, b) { a = a | 0; b = b | 0; var c = 0; a: do if ((b | 0) == 2) { switch(a | 0){ case 2: a = 3; break a; case 3: break; default: c = 4; break a; } a = 2; } else c = 4; while (0) return a | 0; } function se(a, b) { a = a | 0; b = b | 0; var d = ib; if (!((oe(b) | 0 ? (c[a + 312 >> 2] | 0) != 0 : 0) ? (d = T(g[a + 308 >> 2]), d >= T(0.0)) : 0)) d = T(cC(T(g[(Tb(a + 276 | 0, c[1040 + (b << 2) >> 2] | 0, 992) | 0) >> 2]), T(0.0))); return T(d); } function te(a, b) { a = a | 0; b = b | 0; var d = ib; if (!((oe(b) | 0 ? (c[a + 320 >> 2] | 0) != 0 : 0) ? (d = T(g[a + 316 >> 2]), d >= T(0.0)) : 0)) d = T(cC(T(g[(Tb(a + 276 | 0, c[1e3 + (b << 2) >> 2] | 0, 992) | 0) >> 2]), T(0.0))); return T(d); } function ue(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; if (!((oe(b) | 0 ? (c[a + 240 >> 2] | 0) != 0 : 0) ? (e = T(be(a + 236 | 0, d)), e >= T(0.0)) : 0)) e = T(cC(T(be(Tb(a + 204 | 0, c[1040 + (b << 2) >> 2] | 0, 992) | 0, d)), T(0.0))); return T(e); } function ve(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; if (!((oe(b) | 0 ? (c[a + 248 >> 2] | 0) != 0 : 0) ? (e = T(be(a + 244 | 0, d)), e >= T(0.0)) : 0)) e = T(cC(T(be(Tb(a + 204 | 0, c[1e3 + (b << 2) >> 2] | 0, 992) | 0, d)), T(0.0))); return T(e); } function we(a, b, d, e, f, h, i) { a = a | 0; b = T(b); d = T(d); e = e | 0; f = f | 0; h = T(h); i = T(i); var j = ib, k = ib, m = ib, n = ib, o = ib, p = ib, q = 0, r = 0, s = 0; s = l; l = l + 16 | 0; q = s; r = a + 964 | 0; ec(a, (c[r >> 2] | 0) != 0, 3519); j = T(Ce(a, 2, b)); k = T(Ce(a, 0, b)); m = T(Ud(a, 2, b)); n = T(Ud(a, 0, b)); if (Sb(b) | 0) o = b; else o = T(cC(T(0.0), T(T(b - m) - j))); if (Sb(d) | 0) p = d; else p = T(cC(T(0.0), T(T(d - n) - k))); if ((e | 0) == 1 & (f | 0) == 1) { g[a + 908 >> 2] = T(Ie(a, 2, T(b - m), h, h)); b = T(Ie(a, 0, T(d - n), i, h)); } else { Db[c[r >> 2] & 1](q, a, o, e, p, f); o = T(j + T(g[q >> 2])); p = T(b - m); g[a + 908 >> 2] = T(Ie(a, 2, (e | 2) == 2 ? o : p, h, h)); p = T(k + T(g[q + 4 >> 2])); b = T(d - n); b = T(Ie(a, 0, (f | 2) == 2 ? p : b, i, h)); } g[a + 912 >> 2] = b; l = s; return; } function xe(a, b, c, d, e, f, h) { a = a | 0; b = T(b); c = T(c); d = d | 0; e = e | 0; f = T(f); h = T(h); var i = ib, j = ib, k = ib, l = ib; k = T(Ce(a, 2, f)); i = T(Ce(a, 0, f)); l = T(Ud(a, 2, f)); j = T(Ud(a, 0, f)); b = T(b - l); g[a + 908 >> 2] = T(Ie(a, 2, (d | 2) == 2 ? k : b, f, f)); c = T(c - j); g[a + 912 >> 2] = T(Ie(a, 0, (e | 2) == 2 ? i : c, h, f)); return; } function ye(a, b, c, d, e, f, h) { a = a | 0; b = T(b); c = T(c); d = d | 0; e = e | 0; f = T(f); h = T(h); var i = 0, j = ib, k = ib; i = (d | 0) == 2; if ((!(b <= T(0.0) & i) ? !(c <= T(0.0) & (e | 0) == 2) : 0) ? !((d | 0) == 1 & (e | 0) == 1) : 0) a = 0; else { j = T(Ud(a, 0, f)); k = T(Ud(a, 2, f)); i = b < T(0.0) & i | (Sb(b) | 0); b = T(b - k); g[a + 908 >> 2] = T(Ie(a, 2, i ? T(0.0) : b, f, f)); b = T(c - j); i = c < T(0.0) & (e | 0) == 2 | (Sb(c) | 0); g[a + 912 >> 2] = T(Ie(a, 0, i ? T(0.0) : b, h, f)); a = 1; } return a | 0; } function ze(a, b) { a = a | 0; b = b | 0; if (We(a) | 0) a = re(2, b) | 0; else a = 0; return a | 0; } function Ae(a, b, c) { a = a | 0; b = b | 0; c = T(c); c = T(ue(a, b, c)); return T(c + T(se(a, b))); } function Be(a, b, c) { a = a | 0; b = b | 0; c = T(c); c = T(ve(a, b, c)); return T(c + T(te(a, b))); } function Ce(a, b, c) { a = a | 0; b = b | 0; c = T(c); var d = ib; d = T(Ae(a, b, c)); return T(d + T(Be(a, b, c))); } function De(a) { a = a | 0; if (!(c[a + 24 >> 2] | 0)) { if (T(Ee(a)) != T(0.0)) a = 1; else a = T(Fe(a)) != T(0.0); } else a = 0; return a | 0; } function Ee(a) { a = a | 0; var b = ib; if (c[a + 944 >> 2] | 0) { b = T(g[a + 44 >> 2]); if (Sb(b) | 0) { b = T(g[a + 40 >> 2]); a = b > T(0.0) & ((Sb(b) | 0) ^ 1); return T(a ? b : T(0.0)); } } else b = T(0.0); return T(b); } function Fe(b) { b = b | 0; var d = ib, e = 0, f = ib; do if (c[b + 944 >> 2] | 0) { d = T(g[b + 48 >> 2]); if (Sb(d) | 0) { e = a[(c[b + 976 >> 2] | 0) + 2 >> 0] | 0; if (e << 24 >> 24 == 0 ? (f = T(g[b + 40 >> 2]), f < T(0.0) & ((Sb(f) | 0) ^ 1)) : 0) { d = T(-f); break; } d = e << 24 >> 24 ? T(1.0) : T(0.0); } } else d = T(0.0); while (0) return T(d); } function Ge(b) { b = b | 0; var d = 0, e = 0; yC(b + 400 | 0, 0, 540); a[b + 985 >> 0] = 1; lc(b); e = $b(b) | 0; if (e | 0) { d = b + 948 | 0; b = 0; do { Ge(c[(c[d >> 2] | 0) + (b << 2) >> 2] | 0); b = b + 1 | 0; }while ((b | 0) != (e | 0)) } return; } function He(a, b, d, e, f, h, i, j, k, m) { a = a | 0; b = b | 0; d = T(d); e = e | 0; f = T(f); h = T(h); i = T(i); j = j | 0; k = k | 0; m = m | 0; var n = 0, o = ib, p = 0, q = 0, r = ib, s = ib, u = 0, v = ib, w = 0, x = ib, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; G = l; l = l + 16 | 0; A = G + 12 | 0; B = G + 8 | 0; C = G + 4 | 0; D = G; F = re(c[a + 4 >> 2] | 0, k) | 0; y = oe(F) | 0; o = T(be(Xe(b) | 0, y ? h : i)); z = ae(b, 2, h) | 0; E = ae(b, 0, i) | 0; do if (!(Sb(o) | 0) ? !(Sb(y ? d : f) | 0) : 0) { n = b + 504 | 0; if (!(Sb(T(g[n >> 2])) | 0)) { if (!(Ye(c[b + 976 >> 2] | 0, 0) | 0)) break; if ((c[b + 500 >> 2] | 0) == (c[2278] | 0)) break; } g[n >> 2] = T(cC(o, T(Ce(b, F, h)))); } else p = 7; while (0) do if ((p | 0) == 7) { w = y ^ 1; if (!(w | z ^ 1)) { i = T(be(c[b + 992 >> 2] | 0, h)); g[b + 504 >> 2] = T(cC(i, T(Ce(b, 2, h)))); break; } if (!(y | E ^ 1)) { i = T(be(c[b + 996 >> 2] | 0, i)); g[b + 504 >> 2] = T(cC(i, T(Ce(b, 0, h)))); break; } g[A >> 2] = T(t); g[B >> 2] = T(t); c[C >> 2] = 0; c[D >> 2] = 0; v = T(Ud(b, 2, h)); x = T(Ud(b, 0, h)); if (z) { r = T(v + T(be(c[b + 992 >> 2] | 0, h))); g[A >> 2] = r; c[C >> 2] = 1; q = 1; } else { q = 0; r = T(t); } if (E) { o = T(x + T(be(c[b + 996 >> 2] | 0, i))); g[B >> 2] = o; c[D >> 2] = 1; n = 1; } else { n = 0; o = T(t); } p = c[a + 32 >> 2] | 0; if (!(y & (p | 0) == 2)) { if (Sb(r) | 0 ? !(Sb(d) | 0) : 0) { g[A >> 2] = d; c[C >> 2] = 2; q = 2; r = d; } } else p = 2; if ((!((p | 0) == 2 & w) ? Sb(o) | 0 : 0) ? !(Sb(f) | 0) : 0) { g[B >> 2] = f; c[D >> 2] = 2; n = 2; o = f; } s = T(g[b + 396 >> 2]); u = Sb(s) | 0; do if (!u) { if ((q | 0) == 1 & w) { g[B >> 2] = T(T(r - v) / s); c[D >> 2] = 1; n = 1; p = 1; break; } if (y & (n | 0) == 1) { g[A >> 2] = T(s * T(o - x)); c[C >> 2] = 1; n = 1; p = 1; } else p = q; } else p = q; while (0) H = Sb(d) | 0; q = (Je(a, b) | 0) != 4; if (!(y | z | ((e | 0) != 1 | H) | (q | (p | 0) == 1)) ? (g[A >> 2] = d, c[C >> 2] = 1, !u) : 0) { g[B >> 2] = T(T(d - v) / s); c[D >> 2] = 1; n = 1; } if (!(E | w | ((j | 0) != 1 | (Sb(f) | 0)) | (q | (n | 0) == 1)) ? (g[B >> 2] = f, c[D >> 2] = 1, !u) : 0) { g[A >> 2] = T(s * T(f - x)); c[C >> 2] = 1; } Me(b, 2, h, h, C, A); Me(b, 0, i, h, D, B); d = T(g[A >> 2]); f = T(g[B >> 2]); Td(b, d, f, k, c[C >> 2] | 0, c[D >> 2] | 0, h, i, 0, 3565, m); i = T(g[b + 908 + (c[976 + (F << 2) >> 2] << 2) >> 2]); g[b + 504 >> 2] = T(cC(i, T(Ce(b, F, h)))); } while (0) c[b + 500 >> 2] = c[2278]; l = G; return; } function Ie(a, b, c, d, e) { a = a | 0; b = b | 0; c = T(c); d = T(d); e = T(e); d = T(Te(a, b, c, d)); return T(cC(d, T(Ce(a, b, e)))); } function Je(a, b) { a = a | 0; b = b | 0; b = b + 20 | 0; b = c[((c[b >> 2] | 0) == 0 ? a + 16 | 0 : b) >> 2] | 0; if ((b | 0) == 5 ? We(c[a + 4 >> 2] | 0) | 0 : 0) b = 1; return b | 0; } function Ke(a, b) { a = a | 0; b = b | 0; if (oe(b) | 0 ? (c[a + 96 >> 2] | 0) != 0 : 0) b = 4; else b = c[1040 + (b << 2) >> 2] | 0; return a + 60 + (b << 3) | 0; } function Le(a, b) { a = a | 0; b = b | 0; if (oe(b) | 0 ? (c[a + 104 >> 2] | 0) != 0 : 0) b = 5; else b = c[1e3 + (b << 2) >> 2] | 0; return a + 60 + (b << 3) | 0; } function Me(a, b, d, e, f, h) { a = a | 0; b = b | 0; d = T(d); e = T(e); f = f | 0; h = h | 0; d = T(be(a + 380 + (c[976 + (b << 2) >> 2] << 3) | 0, d)); d = T(d + T(Ud(a, b, e))); switch(c[f >> 2] | 0){ case 2: case 1: f = Sb(d) | 0; e = T(g[h >> 2]); g[h >> 2] = f | e < d ? e : d; break; case 0: if (!(Sb(d) | 0)) { c[f >> 2] = 2; g[h >> 2] = d; } break; default: } return; } function Ne(a, b) { a = a | 0; b = b | 0; a = a + 132 | 0; if (oe(b) | 0 ? (c[(Tb(a, 4, 948) | 0) + 4 >> 2] | 0) != 0 : 0) a = 1; else a = (c[(Tb(a, c[1040 + (b << 2) >> 2] | 0, 948) | 0) + 4 >> 2] | 0) != 0; return a | 0; } function Oe(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0; a = a + 132 | 0; if (oe(b) | 0 ? (e = Tb(a, 4, 948) | 0, (c[e + 4 >> 2] | 0) != 0) : 0) f = 4; else { e = Tb(a, c[1040 + (b << 2) >> 2] | 0, 948) | 0; if (!(c[e + 4 >> 2] | 0)) d = T(0.0); else f = 4; } if ((f | 0) == 4) d = T(be(e, d)); return T(d); } function Pe(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = ib; e = T(g[a + 908 + (c[976 + (b << 2) >> 2] << 2) >> 2]); e = T(e + T(me(a, b, d))); return T(e + T(ne(a, b, d))); } function Qe(a) { a = a | 0; var b = 0, d = 0, e = 0; a: do if (!(We(c[a + 4 >> 2] | 0) | 0)) { if ((c[a + 16 >> 2] | 0) != 5) { d = $b(a) | 0; if (!d) b = 0; else { b = 0; while(true){ e = ac(a, b) | 0; if ((c[e + 24 >> 2] | 0) == 0 ? (c[e + 20 >> 2] | 0) == 5 : 0) { b = 1; break a; } b = b + 1 | 0; if (b >>> 0 >= d >>> 0) { b = 0; break; } } } } else b = 1; } else b = 0; while (0) return b | 0; } function Re(a, b) { a = a | 0; b = b | 0; var d = ib; d = T(g[a + 908 + (c[976 + (b << 2) >> 2] << 2) >> 2]); return d >= T(0.0) & ((Sb(d) | 0) ^ 1) | 0; } function Se(a) { a = a | 0; var b = ib, d = 0, e = 0, f = 0, h = 0, i = 0, j = 0, k = ib; d = c[a + 968 >> 2] | 0; if (!d) { h = $b(a) | 0; do if (h | 0) { d = 0; f = 0; while(true){ e = ac(a, f) | 0; if (c[e + 940 >> 2] | 0) { i = 8; break; } if ((c[e + 24 >> 2] | 0) != 1) { j = (Je(a, e) | 0) == 5; if (j) { d = e; break; } else d = (d | 0) == 0 ? e : d; } f = f + 1 | 0; if (f >>> 0 >= h >>> 0) { i = 8; break; } } if ((i | 0) == 8) { if (!d) break; } b = T(Se(d)); return T(b + T(g[d + 404 >> 2])); } while (0) b = T(g[a + 912 >> 2]); } else { k = T(g[a + 908 >> 2]); b = T(g[a + 912 >> 2]); b = T(mb[d & 0](a, k, b)); ec(a, (Sb(b) | 0) ^ 1, 3573); } return T(b); } function Te(a, b, c, d) { a = a | 0; b = b | 0; c = T(c); d = T(d); var e = ib, f = 0; if (!(We(b) | 0)) { if (oe(b) | 0) { b = 0; f = 3; } else { d = T(t); e = T(t); } } else { b = 1; f = 3; } if ((f | 0) == 3) { e = T(be(a + 364 + (b << 3) | 0, d)); d = T(be(a + 380 + (b << 3) | 0, d)); } f = d < c & (d >= T(0.0) & ((Sb(d) | 0) ^ 1)); c = f ? d : c; f = e >= T(0.0) & ((Sb(e) | 0) ^ 1) & c < e; return T(f ? e : c); } function Ue(a, b, d, e, f, h, i) { a = a | 0; b = b | 0; d = T(d); e = e | 0; f = T(f); h = h | 0; i = i | 0; var j = ib, k = ib, l = 0, m = 0, n = ib, o = ib, p = ib, q = 0, r = 0, s = 0, u = 0, v = ib, w = 0; s = re(c[a + 4 >> 2] | 0, h) | 0; q = ze(s, h) | 0; r = oe(s) | 0; n = T(Ud(b, 2, d)); o = T(Ud(b, 0, d)); if (!(ae(b, 2, d) | 0)) { if (Ne(b, 2) | 0 ? Ze(b, 2) | 0 : 0) { j = T(g[a + 908 >> 2]); k = T(se(a, 2)); k = T(j - T(k + T(te(a, 2)))); j = T(Oe(b, 2, d)); j = T(Ie(b, 2, T(k - T(j + T(_e(b, 2, d)))), d, d)); } else j = T(t); } else j = T(n + T(be(c[b + 992 >> 2] | 0, d))); if (!(ae(b, 0, f) | 0)) { if (Ne(b, 0) | 0 ? Ze(b, 0) | 0 : 0) { k = T(g[a + 912 >> 2]); v = T(se(a, 0)); v = T(k - T(v + T(te(a, 0)))); k = T(Oe(b, 0, f)); k = T(Ie(b, 0, T(v - T(k + T(_e(b, 0, f)))), f, d)); } else k = T(t); } else k = T(o + T(be(c[b + 996 >> 2] | 0, f))); l = Sb(j) | 0; m = Sb(k) | 0; do if (l ^ m ? (p = T(g[b + 396 >> 2]), !(Sb(p) | 0)) : 0) { if (l) { j = T(n + T(T(k - o) * p)); break; } else { v = T(o + T(T(j - n) / p)); k = m ? v : k; break; } } while (0) m = Sb(j) | 0; l = Sb(k) | 0; if (m | l) { w = (m ^ 1) & 1; e = d > T(0.0) & ((e | 0) != 0 & m); j = r ? j : e ? d : j; Td(b, j, k, h, r ? w : e ? 2 : w, m & (l ^ 1) & 1, j, k, 0, 3623, i); j = T(g[b + 908 >> 2]); j = T(j + T(Ud(b, 2, d))); k = T(g[b + 912 >> 2]); k = T(k + T(Ud(b, 0, d))); } Td(b, j, k, h, 1, 1, j, k, 1, 3635, i); if (Ze(b, s) | 0 ? !(Ne(b, s) | 0) : 0) { w = c[976 + (s << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(v - T(g[b + 908 + (w << 2) >> 2])); v = T(v - T(te(a, s))); v = T(v - T(ne(b, s, d))); v = T(v - T(_e(b, s, r ? d : f))); g[b + 400 + (c[1040 + (s << 2) >> 2] << 2) >> 2] = v; } else u = 21; do if ((u | 0) == 21) { if (!(Ne(b, s) | 0) ? (c[a + 8 >> 2] | 0) == 1 : 0) { w = c[976 + (s << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(T(v - T(g[b + 908 + (w << 2) >> 2])) * T(0.5)); g[b + 400 + (c[1040 + (s << 2) >> 2] << 2) >> 2] = v; break; } if (!(Ne(b, s) | 0) ? (c[a + 8 >> 2] | 0) == 2 : 0) { w = c[976 + (s << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(v - T(g[b + 908 + (w << 2) >> 2])); g[b + 400 + (c[1040 + (s << 2) >> 2] << 2) >> 2] = v; } } while (0) if (Ze(b, q) | 0 ? !(Ne(b, q) | 0) : 0) { w = c[976 + (q << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(v - T(g[b + 908 + (w << 2) >> 2])); v = T(v - T(te(a, q))); v = T(v - T(ne(b, q, d))); v = T(v - T(_e(b, q, r ? f : d))); g[b + 400 + (c[1040 + (q << 2) >> 2] << 2) >> 2] = v; } else u = 30; do if ((u | 0) == 30 ? !(Ne(b, q) | 0) : 0) { if ((Je(a, b) | 0) == 2) { w = c[976 + (q << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(T(v - T(g[b + 908 + (w << 2) >> 2])) * T(0.5)); g[b + 400 + (c[1040 + (q << 2) >> 2] << 2) >> 2] = v; break; } w = (Je(a, b) | 0) == 3; if (w ^ (c[a + 28 >> 2] | 0) == 2) { w = c[976 + (q << 2) >> 2] | 0; v = T(g[a + 908 + (w << 2) >> 2]); v = T(v - T(g[b + 908 + (w << 2) >> 2])); g[b + 400 + (c[1040 + (q << 2) >> 2] << 2) >> 2] = v; } } while (0) return; } function Ve(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = ib, f = 0; f = c[976 + (d << 2) >> 2] | 0; e = T(g[b + 908 + (f << 2) >> 2]); e = T(T(g[a + 908 + (f << 2) >> 2]) - e); e = T(e - T(g[b + 400 + (c[1040 + (d << 2) >> 2] << 2) >> 2])); g[b + 400 + (c[1e3 + (d << 2) >> 2] << 2) >> 2] = e; return; } function We(a) { a = a | 0; return (a | 1) == 1 | 0; } function Xe(b) { b = b | 0; var d = ib; switch(c[b + 56 >> 2] | 0){ case 0: case 3: d = T(g[b + 40 >> 2]); if (d > T(0.0) & ((Sb(d) | 0) ^ 1)) b = a[(c[b + 976 >> 2] | 0) + 2 >> 0] | 0 ? 1056 : 992; else b = 1056; break; default: b = b + 52 | 0; } return b | 0; } function Ye(b, c) { b = b | 0; c = c | 0; return (a[b + c >> 0] | 0) != 0 | 0; } function Ze(a, b) { a = a | 0; b = b | 0; a = a + 132 | 0; if (oe(b) | 0 ? (c[(Tb(a, 5, 948) | 0) + 4 >> 2] | 0) != 0 : 0) a = 1; else a = (c[(Tb(a, c[1e3 + (b << 2) >> 2] | 0, 948) | 0) + 4 >> 2] | 0) != 0; return a | 0; } function _e(a, b, d) { a = a | 0; b = b | 0; d = T(d); var e = 0, f = 0; a = a + 132 | 0; if (oe(b) | 0 ? (e = Tb(a, 5, 948) | 0, (c[e + 4 >> 2] | 0) != 0) : 0) f = 4; else { e = Tb(a, c[1e3 + (b << 2) >> 2] | 0, 948) | 0; if (!(c[e + 4 >> 2] | 0)) d = T(0.0); else f = 4; } if ((f | 0) == 4) d = T(be(e, d)); return T(d); } function $e(a, b, c) { a = a | 0; b = b | 0; c = T(c); if (Ne(a, b) | 0) c = T(Oe(a, b, c)); else c = T(-T(_e(a, b, c))); return T(c); } function af(a) { a = T(a); return (g[j >> 2] = a, c[j >> 2] | 0) | 0; } function bf(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 2) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 2); return; } function cf(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 2) << 2) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function df(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -4 - b | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ef(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = a + 4 | 0; i = c[h >> 2] | 0; f = i - e | 0; g = f >> 2; a = b + (g << 2) | 0; if (a >>> 0 < d >>> 0) { e = i; do { c[e >> 2] = c[a >> 2]; a = a + 4 | 0; e = (c[h >> 2] | 0) + 4 | 0; c[h >> 2] = e; }while (a >>> 0 < d >>> 0) } if (g | 0) GC(i + (0 - g << 2) | 0, b | 0, f | 0); return; } function ff(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = b + 4 | 0; j = c[i >> 2] | 0; f = c[a >> 2] | 0; h = d; g = h - f | 0; e = j + (0 - (g >> 2) << 2) | 0; c[i >> 2] = e; if ((g | 0) > 0) BC(e | 0, f | 0, g | 0); f = a + 4 | 0; g = b + 8 | 0; e = (c[f >> 2] | 0) - h | 0; if ((e | 0) > 0) { BC(c[g >> 2] | 0, d | 0, e | 0); c[g >> 2] = (c[g >> 2] | 0) + (e >>> 2 << 2); } h = c[a >> 2] | 0; c[a >> 2] = c[i >> 2]; c[i >> 2] = h; h = c[f >> 2] | 0; c[f >> 2] = c[g >> 2]; c[g >> 2] = h; h = a + 8 | 0; d = b + 12 | 0; a = c[h >> 2] | 0; c[h >> 2] = c[d >> 2]; c[d >> 2] = a; c[b >> 2] = c[i >> 2]; return j | 0; } function gf(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; h = c[b >> 2] | 0; g = c[d >> 2] | 0; if ((h | 0) != (g | 0)) { f = a + 8 | 0; d = ((g + -4 - h | 0) >>> 2) + 1 | 0; a = h; e = c[f >> 2] | 0; do { c[e >> 2] = c[a >> 2]; e = (c[f >> 2] | 0) + 4 | 0; c[f >> 2] = e; a = a + 4 | 0; }while ((a | 0) != (g | 0)) c[b >> 2] = h + (d << 2); } return; } function hf() { Qb(); return; } function jf() { var a = 0; a = qC(4) | 0; kf(a); return a | 0; } function kf(a) { a = a | 0; c[a >> 2] = gc() | 0; return; } function lf(a) { a = a | 0; if (a | 0) { mf(a); sC(a); } return; } function mf(a) { a = a | 0; ic(c[a >> 2] | 0); return; } function nf(a, b, d) { a = a | 0; b = b | 0; d = d | 0; he(c[a >> 2] | 0, b, d); return; } function of(a, b) { a = a | 0; b = T(b); Zd(c[a >> 2] | 0, b); return; } function pf(a, b) { a = a | 0; b = b | 0; return Ye(c[a >> 2] | 0, b) | 0; } function qf() { var a = 0; a = qC(8) | 0; rf(a, 0); return a | 0; } function rf(a, b) { a = a | 0; b = b | 0; if (!b) b = Wb() | 0; else b = Ub(c[b >> 2] | 0) | 0; c[a >> 2] = b; c[a + 4 >> 2] = 0; vc(b, a); return; } function sf(a) { a = a | 0; var b = 0; b = qC(8) | 0; rf(b, a); return b | 0; } function tf(a) { a = a | 0; if (a | 0) { uf(a); sC(a); } return; } function uf(a) { a = a | 0; var b = 0; Zb(c[a >> 2] | 0); b = a + 4 | 0; a = c[b >> 2] | 0; c[b >> 2] = 0; if (a | 0) { vf(a); sC(a); } return; } function vf(a) { a = a | 0; wf(a); return; } function wf(a) { a = a | 0; a = c[a >> 2] | 0; if (a | 0) ab(a | 0); return; } function xf(a) { a = a | 0; return wc(a) | 0; } function yf(a) { a = a | 0; var b = 0, d = 0; d = a + 4 | 0; b = c[d >> 2] | 0; c[d >> 2] = 0; if (b | 0) { vf(b); sC(b); } dc(c[a >> 2] | 0); return; } function zf(a, b) { a = a | 0; b = b | 0; sc(c[a >> 2] | 0, c[b >> 2] | 0); return; } function Af(a, b) { a = a | 0; b = b | 0; Hc(c[a >> 2] | 0, b); return; } function Bf(a, b, d) { a = a | 0; b = b | 0; d = +d; Vc(c[a >> 2] | 0, b, T(d)); return; } function Cf(a, b, d) { a = a | 0; b = b | 0; d = +d; Wc(c[a >> 2] | 0, b, T(d)); return; } function Df(a, b) { a = a | 0; b = b | 0; Bc(c[a >> 2] | 0, b); return; } function Ef(a, b) { a = a | 0; b = b | 0; Dc(c[a >> 2] | 0, b); return; } function Ff(a, b) { a = a | 0; b = b | 0; Fc(c[a >> 2] | 0, b); return; } function Gf(a, b) { a = a | 0; b = b | 0; xc(c[a >> 2] | 0, b); return; } function Hf(a, b) { a = a | 0; b = b | 0; Jc(c[a >> 2] | 0, b); return; } function If(a, b) { a = a | 0; b = b | 0; zc(c[a >> 2] | 0, b); return; } function Jf(a, b, d) { a = a | 0; b = b | 0; d = +d; Yc(c[a >> 2] | 0, b, T(d)); return; } function Kf(a, b, d) { a = a | 0; b = b | 0; d = +d; Zc(c[a >> 2] | 0, b, T(d)); return; } function Lf(a, b) { a = a | 0; b = b | 0; $c(c[a >> 2] | 0, b); return; } function Mf(a, b) { a = a | 0; b = b | 0; Lc(c[a >> 2] | 0, b); return; } function Nf(a, b) { a = a | 0; b = b | 0; Nc(c[a >> 2] | 0, b); return; } function Of(a, b) { a = a | 0; b = +b; Pc(c[a >> 2] | 0, T(b)); return; } function Pf(a, b) { a = a | 0; b = +b; Sc(c[a >> 2] | 0, T(b)); return; } function Qf(a, b) { a = a | 0; b = +b; Tc(c[a >> 2] | 0, T(b)); return; } function Rf(a, b) { a = a | 0; b = +b; Qc(c[a >> 2] | 0, T(b)); return; } function Sf(a, b) { a = a | 0; b = +b; Rc(c[a >> 2] | 0, T(b)); return; } function Tf(a, b) { a = a | 0; b = +b; fd(c[a >> 2] | 0, T(b)); return; } function Uf(a, b) { a = a | 0; b = +b; gd(c[a >> 2] | 0, T(b)); return; } function Vf(a) { a = a | 0; hd(c[a >> 2] | 0); return; } function Wf(a, b) { a = a | 0; b = +b; jd(c[a >> 2] | 0, T(b)); return; } function Xf(a, b) { a = a | 0; b = +b; kd(c[a >> 2] | 0, T(b)); return; } function Yf(a) { a = a | 0; ld(c[a >> 2] | 0); return; } function Zf(a, b) { a = a | 0; b = +b; nd(c[a >> 2] | 0, T(b)); return; } function _f(a, b) { a = a | 0; b = +b; od(c[a >> 2] | 0, T(b)); return; } function $f(a, b) { a = a | 0; b = +b; qd(c[a >> 2] | 0, T(b)); return; } function ag(a, b) { a = a | 0; b = +b; rd(c[a >> 2] | 0, T(b)); return; } function bg(a, b) { a = a | 0; b = +b; td(c[a >> 2] | 0, T(b)); return; } function cg(a, b) { a = a | 0; b = +b; ud(c[a >> 2] | 0, T(b)); return; } function dg(a, b) { a = a | 0; b = +b; wd(c[a >> 2] | 0, T(b)); return; } function eg(a, b) { a = a | 0; b = +b; xd(c[a >> 2] | 0, T(b)); return; } function fg(a, b) { a = a | 0; b = +b; zd(c[a >> 2] | 0, T(b)); return; } function gg(a, b, d) { a = a | 0; b = b | 0; d = +d; dd(c[a >> 2] | 0, b, T(d)); return; } function hg(a, b, d) { a = a | 0; b = b | 0; d = +d; ad(c[a >> 2] | 0, b, T(d)); return; } function ig(a, b, d) { a = a | 0; b = b | 0; d = +d; bd(c[a >> 2] | 0, b, T(d)); return; } function jg(a) { a = a | 0; return Ic(c[a >> 2] | 0) | 0; } function kg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e; Xc(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function lg(a, b) { a = a | 0; b = b | 0; mg(a, c[b + 4 >> 2] | 0, +T(g[b >> 2])); return; } function mg(a, b, d) { a = a | 0; b = b | 0; d = +d; c[a >> 2] = b; h[a + 8 >> 3] = d; return; } function ng(a) { a = a | 0; return Cc(c[a >> 2] | 0) | 0; } function og(a) { a = a | 0; return Ec(c[a >> 2] | 0) | 0; } function pg(a) { a = a | 0; return Gc(c[a >> 2] | 0) | 0; } function qg(a) { a = a | 0; return yc(c[a >> 2] | 0) | 0; } function rg(a) { a = a | 0; return Kc(c[a >> 2] | 0) | 0; } function sg(a) { a = a | 0; return Ac(c[a >> 2] | 0) | 0; } function tg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e; _c(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function ug(a) { a = a | 0; return Mc(c[a >> 2] | 0) | 0; } function vg(a) { a = a | 0; return Oc(c[a >> 2] | 0) | 0; } function wg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; Uc(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function xg(a) { a = a | 0; return + +T(tc(c[a >> 2] | 0)); } function yg(a) { a = a | 0; return + +T(uc(c[a >> 2] | 0)); } function zg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; id(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Ag(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; md(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Bg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; pd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Cg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; sd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Dg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; vd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Eg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; yd(e, c[b >> 2] | 0); lg(a, e); l = d; return; } function Fg(a) { a = a | 0; return + +T(Ad(c[a >> 2] | 0)); } function Gg(a, b) { a = a | 0; b = b | 0; return + +T(ed(c[a >> 2] | 0, b)); } function Hg(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e; cd(f, c[b >> 2] | 0, d); lg(a, f); l = e; return; } function Ig(a, b, d) { a = a | 0; b = b | 0; d = d | 0; kc(c[a >> 2] | 0, c[b >> 2] | 0, d); return; } function Jg(a, b) { a = a | 0; b = b | 0; cc(c[a >> 2] | 0, c[b >> 2] | 0); return; } function Kg(a) { a = a | 0; return $b(c[a >> 2] | 0) | 0; } function Lg(a) { a = a | 0; a = pc(c[a >> 2] | 0) | 0; if (!a) a = 0; else a = xf(a) | 0; return a | 0; } function Mg(a, b) { a = a | 0; b = b | 0; a = ac(c[a >> 2] | 0, b) | 0; if (!a) a = 0; else a = xf(a) | 0; return a | 0; } function Ng(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; e = qC(4) | 0; Og(e, b); d = a + 4 | 0; b = c[d >> 2] | 0; c[d >> 2] = e; if (b | 0) { vf(b); sC(b); } jc(c[a >> 2] | 0, 1); return; } function Og(a, b) { a = a | 0; b = b | 0; gh(a, b); return; } function Pg(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = T(c); d = d | 0; e = T(e); f = f | 0; var i = 0, j = 0; i = l; l = l + 16 | 0; j = i; Qg(j, wc(b) | 0, +c, d, +e, f); g[a >> 2] = T(+h[j >> 3]); g[a + 4 >> 2] = T(+h[j + 8 >> 3]); l = i; return; } function Qg(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = +d; e = e | 0; f = +f; g = g | 0; var i = 0, j = 0, k = 0, m = 0, n = 0; i = l; l = l + 32 | 0; n = i + 8 | 0; m = i + 20 | 0; k = i; j = i + 16 | 0; h[n >> 3] = d; c[m >> 2] = e; h[k >> 3] = f; c[j >> 2] = g; Rg(a, c[b + 4 >> 2] | 0, n, m, k, j); l = i; return; } function Rg(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var i = 0, j = 0; i = l; l = l + 16 | 0; j = i; UA(j); b = Sg(b) | 0; Tg(a, b, +h[d >> 3], c[e >> 2] | 0, +h[f >> 3], c[g >> 2] | 0); WA(j); l = i; return; } function Sg(a) { a = a | 0; return c[a >> 2] | 0; } function Tg(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = +c; d = d | 0; e = +e; f = f | 0; var g = 0; g = Vg(Ug() | 0) | 0; c = +Wg(c); d = Xg(d) | 0; e = +Wg(e); Yg(a, cb(0, g | 0, b | 0, +c, d | 0, +e, Xg(f) | 0) | 0); return; } function Ug() { var b = 0; if (!(a[7608] | 0)) { dh(9120); b = 7608; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 9120; } function Vg(a) { a = a | 0; return c[a + 8 >> 2] | 0; } function Wg(a) { a = +a; return + +ch(a); } function Xg(a) { a = a | 0; return bh(a) | 0; } function Yg(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 32 | 0; d = f; e = b; if (!(e & 1)) { c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = c[b + 4 >> 2]; c[a + 8 >> 2] = c[b + 8 >> 2]; c[a + 12 >> 2] = c[b + 12 >> 2]; } else { Zg(d, 0); Ja(e | 0, d | 0); _g(a, d); $g(d); } l = f; return; } function Zg(b, d) { b = b | 0; d = d | 0; ah(b, d); c[b + 8 >> 2] = 0; a[b + 24 >> 0] = 0; return; } function _g(a, b) { a = a | 0; b = b | 0; b = b + 8 | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = c[b + 4 >> 2]; c[a + 8 >> 2] = c[b + 8 >> 2]; c[a + 12 >> 2] = c[b + 12 >> 2]; return; } function $g(b) { b = b | 0; a[b + 24 >> 0] = 0; return; } function ah(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function bh(a) { a = a | 0; return a | 0; } function ch(a) { a = +a; return +a; } function dh(a) { a = a | 0; fh(a, eh() | 0, 4); return; } function eh() { return 1064; } function fh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; c[a + 8 >> 2] = _a(b | 0, d + 1 | 0) | 0; return; } function gh(a, b) { a = a | 0; b = b | 0; b = c[b >> 2] | 0; c[a >> 2] = b; Aa(b | 0); return; } function hh(a) { a = a | 0; var b = 0, d = 0; d = a + 4 | 0; b = c[d >> 2] | 0; c[d >> 2] = 0; if (b | 0) { vf(b); sC(b); } jc(c[a >> 2] | 0, 0); return; } function ih(a) { a = a | 0; qc(c[a >> 2] | 0); return; } function jh(a) { a = a | 0; return rc(c[a >> 2] | 0) | 0; } function kh(a, b, d, e) { a = a | 0; b = +b; d = +d; e = e | 0; _d(c[a >> 2] | 0, T(b), T(d), e); return; } function lh(a) { a = a | 0; return + +T(Bd(c[a >> 2] | 0)); } function mh(a) { a = a | 0; return + +T(Dd(c[a >> 2] | 0)); } function nh(a) { a = a | 0; return + +T(Cd(c[a >> 2] | 0)); } function oh(a) { a = a | 0; return + +T(Ed(c[a >> 2] | 0)); } function ph(a) { a = a | 0; return + +T(Fd(c[a >> 2] | 0)); } function qh(a) { a = a | 0; return + +T(Gd(c[a >> 2] | 0)); } function rh(a, b) { a = a | 0; b = b | 0; h[a >> 3] = +T(Bd(c[b >> 2] | 0)); h[a + 8 >> 3] = +T(Dd(c[b >> 2] | 0)); h[a + 16 >> 3] = +T(Cd(c[b >> 2] | 0)); h[a + 24 >> 3] = +T(Ed(c[b >> 2] | 0)); h[a + 32 >> 3] = +T(Fd(c[b >> 2] | 0)); h[a + 40 >> 3] = +T(Gd(c[b >> 2] | 0)); return; } function sh(a, b) { a = a | 0; b = b | 0; return + +T(Hd(c[a >> 2] | 0, b)); } function th(a, b) { a = a | 0; b = b | 0; return + +T(Id(c[a >> 2] | 0, b)); } function uh(a, b) { a = a | 0; b = b | 0; return + +T(Jd(c[a >> 2] | 0, b)); } function vh() { return fc() | 0; } function wh() { xh(); yh(); zh(); Ah(); Bh(); Ch(); return; } function xh() { kv(11713, 4938, 1); return; } function yh() { yu(10448); return; } function zh() { eu(10408); return; } function Ah() { vt(10324); return; } function Bh() { or(10096); return; } function Ch() { Dh(9132); return; } function Dh(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0, I = 0, J = 0, K = 0, L = 0, M = 0, N = 0, O = 0, P = 0, Q = 0, R = 0, S = 0, T = 0, U = 0, V = 0, W = 0, X = 0, Y = 0, Z = 0, _ = 0, $ = 0, aa = 0, ba = 0, ca = 0, da = 0, ea = 0, fa = 0, ga = 0, ha = 0, ia = 0, ja = 0, ka = 0, la = 0, ma = 0, na = 0, oa = 0, pa = 0, qa = 0, ra = 0, sa = 0, ta = 0, ua = 0, va = 0, wa = 0, xa = 0, ya = 0, za = 0, Aa = 0, Ba = 0, Ca = 0, Da = 0, Ea = 0, Fa = 0, Ga = 0; b = l; l = l + 672 | 0; d = b + 656 | 0; Ga = b + 648 | 0; Fa = b + 640 | 0; Ea = b + 632 | 0; Da = b + 624 | 0; Ca = b + 616 | 0; Ba = b + 608 | 0; Aa = b + 600 | 0; za = b + 592 | 0; ya = b + 584 | 0; xa = b + 576 | 0; wa = b + 568 | 0; va = b + 560 | 0; ua = b + 552 | 0; ta = b + 544 | 0; sa = b + 536 | 0; ra = b + 528 | 0; qa = b + 520 | 0; pa = b + 512 | 0; oa = b + 504 | 0; na = b + 496 | 0; ma = b + 488 | 0; la = b + 480 | 0; ka = b + 472 | 0; ja = b + 464 | 0; ia = b + 456 | 0; ha = b + 448 | 0; ga = b + 440 | 0; fa = b + 432 | 0; ea = b + 424 | 0; da = b + 416 | 0; ca = b + 408 | 0; ba = b + 400 | 0; aa = b + 392 | 0; $ = b + 384 | 0; _ = b + 376 | 0; Z = b + 368 | 0; Y = b + 360 | 0; X = b + 352 | 0; W = b + 344 | 0; V = b + 336 | 0; U = b + 328 | 0; T = b + 320 | 0; S = b + 312 | 0; R = b + 304 | 0; Q = b + 296 | 0; P = b + 288 | 0; O = b + 280 | 0; N = b + 272 | 0; M = b + 264 | 0; L = b + 256 | 0; K = b + 248 | 0; J = b + 240 | 0; I = b + 232 | 0; H = b + 224 | 0; G = b + 216 | 0; F = b + 208 | 0; E = b + 200 | 0; D = b + 192 | 0; C = b + 184 | 0; B = b + 176 | 0; A = b + 168 | 0; z = b + 160 | 0; y = b + 152 | 0; x = b + 144 | 0; w = b + 136 | 0; v = b + 128 | 0; u = b + 120 | 0; t = b + 112 | 0; s = b + 104 | 0; r = b + 96 | 0; q = b + 88 | 0; p = b + 80 | 0; o = b + 72 | 0; n = b + 64 | 0; m = b + 56 | 0; k = b + 48 | 0; j = b + 40 | 0; i = b + 32 | 0; h = b + 24 | 0; g = b + 16 | 0; f = b + 8 | 0; e = b; Eh(a, 3646); Fh(a, 3651, 2); Gh(a, 3665, 2); Hh(a, 3682, 18); c[Ga >> 2] = 19; c[Ga + 4 >> 2] = 0; c[d >> 2] = c[Ga >> 2]; c[d + 4 >> 2] = c[Ga + 4 >> 2]; Ih(a, 3690, d); c[Fa >> 2] = 1; c[Fa + 4 >> 2] = 0; c[d >> 2] = c[Fa >> 2]; c[d + 4 >> 2] = c[Fa + 4 >> 2]; Jh(a, 3696, d); c[Ea >> 2] = 2; c[Ea + 4 >> 2] = 0; c[d >> 2] = c[Ea >> 2]; c[d + 4 >> 2] = c[Ea + 4 >> 2]; Kh(a, 3706, d); c[Da >> 2] = 1; c[Da + 4 >> 2] = 0; c[d >> 2] = c[Da >> 2]; c[d + 4 >> 2] = c[Da + 4 >> 2]; Lh(a, 3722, d); c[Ca >> 2] = 2; c[Ca + 4 >> 2] = 0; c[d >> 2] = c[Ca >> 2]; c[d + 4 >> 2] = c[Ca + 4 >> 2]; Lh(a, 3734, d); c[Ba >> 2] = 3; c[Ba + 4 >> 2] = 0; c[d >> 2] = c[Ba >> 2]; c[d + 4 >> 2] = c[Ba + 4 >> 2]; Kh(a, 3753, d); c[Aa >> 2] = 4; c[Aa + 4 >> 2] = 0; c[d >> 2] = c[Aa >> 2]; c[d + 4 >> 2] = c[Aa + 4 >> 2]; Kh(a, 3769, d); c[za >> 2] = 5; c[za + 4 >> 2] = 0; c[d >> 2] = c[za >> 2]; c[d + 4 >> 2] = c[za + 4 >> 2]; Kh(a, 3783, d); c[ya >> 2] = 6; c[ya + 4 >> 2] = 0; c[d >> 2] = c[ya >> 2]; c[d + 4 >> 2] = c[ya + 4 >> 2]; Kh(a, 3796, d); c[xa >> 2] = 7; c[xa + 4 >> 2] = 0; c[d >> 2] = c[xa >> 2]; c[d + 4 >> 2] = c[xa + 4 >> 2]; Kh(a, 3813, d); c[wa >> 2] = 8; c[wa + 4 >> 2] = 0; c[d >> 2] = c[wa >> 2]; c[d + 4 >> 2] = c[wa + 4 >> 2]; Kh(a, 3825, d); c[va >> 2] = 3; c[va + 4 >> 2] = 0; c[d >> 2] = c[va >> 2]; c[d + 4 >> 2] = c[va + 4 >> 2]; Lh(a, 3843, d); c[ua >> 2] = 4; c[ua + 4 >> 2] = 0; c[d >> 2] = c[ua >> 2]; c[d + 4 >> 2] = c[ua + 4 >> 2]; Lh(a, 3853, d); c[ta >> 2] = 9; c[ta + 4 >> 2] = 0; c[d >> 2] = c[ta >> 2]; c[d + 4 >> 2] = c[ta + 4 >> 2]; Kh(a, 3870, d); c[sa >> 2] = 10; c[sa + 4 >> 2] = 0; c[d >> 2] = c[sa >> 2]; c[d + 4 >> 2] = c[sa + 4 >> 2]; Kh(a, 3884, d); c[ra >> 2] = 11; c[ra + 4 >> 2] = 0; c[d >> 2] = c[ra >> 2]; c[d + 4 >> 2] = c[ra + 4 >> 2]; Kh(a, 3896, d); c[qa >> 2] = 1; c[qa + 4 >> 2] = 0; c[d >> 2] = c[qa >> 2]; c[d + 4 >> 2] = c[qa + 4 >> 2]; Mh(a, 3907, d); c[pa >> 2] = 2; c[pa + 4 >> 2] = 0; c[d >> 2] = c[pa >> 2]; c[d + 4 >> 2] = c[pa + 4 >> 2]; Mh(a, 3915, d); c[oa >> 2] = 3; c[oa + 4 >> 2] = 0; c[d >> 2] = c[oa >> 2]; c[d + 4 >> 2] = c[oa + 4 >> 2]; Mh(a, 3928, d); c[na >> 2] = 4; c[na + 4 >> 2] = 0; c[d >> 2] = c[na >> 2]; c[d + 4 >> 2] = c[na + 4 >> 2]; Mh(a, 3948, d); c[ma >> 2] = 5; c[ma + 4 >> 2] = 0; c[d >> 2] = c[ma >> 2]; c[d + 4 >> 2] = c[ma + 4 >> 2]; Mh(a, 3960, d); c[la >> 2] = 6; c[la + 4 >> 2] = 0; c[d >> 2] = c[la >> 2]; c[d + 4 >> 2] = c[la + 4 >> 2]; Mh(a, 3974, d); c[ka >> 2] = 7; c[ka + 4 >> 2] = 0; c[d >> 2] = c[ka >> 2]; c[d + 4 >> 2] = c[ka + 4 >> 2]; Mh(a, 3983, d); c[ja >> 2] = 20; c[ja + 4 >> 2] = 0; c[d >> 2] = c[ja >> 2]; c[d + 4 >> 2] = c[ja + 4 >> 2]; Ih(a, 3999, d); c[ia >> 2] = 8; c[ia + 4 >> 2] = 0; c[d >> 2] = c[ia >> 2]; c[d + 4 >> 2] = c[ia + 4 >> 2]; Mh(a, 4012, d); c[ha >> 2] = 9; c[ha + 4 >> 2] = 0; c[d >> 2] = c[ha >> 2]; c[d + 4 >> 2] = c[ha + 4 >> 2]; Mh(a, 4022, d); c[ga >> 2] = 21; c[ga + 4 >> 2] = 0; c[d >> 2] = c[ga >> 2]; c[d + 4 >> 2] = c[ga + 4 >> 2]; Ih(a, 4039, d); c[fa >> 2] = 10; c[fa + 4 >> 2] = 0; c[d >> 2] = c[fa >> 2]; c[d + 4 >> 2] = c[fa + 4 >> 2]; Mh(a, 4053, d); c[ea >> 2] = 11; c[ea + 4 >> 2] = 0; c[d >> 2] = c[ea >> 2]; c[d + 4 >> 2] = c[ea + 4 >> 2]; Mh(a, 4065, d); c[da >> 2] = 12; c[da + 4 >> 2] = 0; c[d >> 2] = c[da >> 2]; c[d + 4 >> 2] = c[da + 4 >> 2]; Mh(a, 4084, d); c[ca >> 2] = 13; c[ca + 4 >> 2] = 0; c[d >> 2] = c[ca >> 2]; c[d + 4 >> 2] = c[ca + 4 >> 2]; Mh(a, 4097, d); c[ba >> 2] = 14; c[ba + 4 >> 2] = 0; c[d >> 2] = c[ba >> 2]; c[d + 4 >> 2] = c[ba + 4 >> 2]; Mh(a, 4117, d); c[aa >> 2] = 15; c[aa + 4 >> 2] = 0; c[d >> 2] = c[aa >> 2]; c[d + 4 >> 2] = c[aa + 4 >> 2]; Mh(a, 4129, d); c[$ >> 2] = 16; c[$ + 4 >> 2] = 0; c[d >> 2] = c[$ >> 2]; c[d + 4 >> 2] = c[$ + 4 >> 2]; Mh(a, 4148, d); c[_ >> 2] = 17; c[_ + 4 >> 2] = 0; c[d >> 2] = c[_ >> 2]; c[d + 4 >> 2] = c[_ + 4 >> 2]; Mh(a, 4161, d); c[Z >> 2] = 18; c[Z + 4 >> 2] = 0; c[d >> 2] = c[Z >> 2]; c[d + 4 >> 2] = c[Z + 4 >> 2]; Mh(a, 4181, d); c[Y >> 2] = 5; c[Y + 4 >> 2] = 0; c[d >> 2] = c[Y >> 2]; c[d + 4 >> 2] = c[Y + 4 >> 2]; Lh(a, 4196, d); c[X >> 2] = 6; c[X + 4 >> 2] = 0; c[d >> 2] = c[X >> 2]; c[d + 4 >> 2] = c[X + 4 >> 2]; Lh(a, 4206, d); c[W >> 2] = 7; c[W + 4 >> 2] = 0; c[d >> 2] = c[W >> 2]; c[d + 4 >> 2] = c[W + 4 >> 2]; Lh(a, 4217, d); c[V >> 2] = 3; c[V + 4 >> 2] = 0; c[d >> 2] = c[V >> 2]; c[d + 4 >> 2] = c[V + 4 >> 2]; Nh(a, 4235, d); c[U >> 2] = 1; c[U + 4 >> 2] = 0; c[d >> 2] = c[U >> 2]; c[d + 4 >> 2] = c[U + 4 >> 2]; Oh(a, 4251, d); c[T >> 2] = 4; c[T + 4 >> 2] = 0; c[d >> 2] = c[T >> 2]; c[d + 4 >> 2] = c[T + 4 >> 2]; Nh(a, 4263, d); c[S >> 2] = 5; c[S + 4 >> 2] = 0; c[d >> 2] = c[S >> 2]; c[d + 4 >> 2] = c[S + 4 >> 2]; Nh(a, 4279, d); c[R >> 2] = 6; c[R + 4 >> 2] = 0; c[d >> 2] = c[R >> 2]; c[d + 4 >> 2] = c[R + 4 >> 2]; Nh(a, 4293, d); c[Q >> 2] = 7; c[Q + 4 >> 2] = 0; c[d >> 2] = c[Q >> 2]; c[d + 4 >> 2] = c[Q + 4 >> 2]; Nh(a, 4306, d); c[P >> 2] = 8; c[P + 4 >> 2] = 0; c[d >> 2] = c[P >> 2]; c[d + 4 >> 2] = c[P + 4 >> 2]; Nh(a, 4323, d); c[O >> 2] = 9; c[O + 4 >> 2] = 0; c[d >> 2] = c[O >> 2]; c[d + 4 >> 2] = c[O + 4 >> 2]; Nh(a, 4335, d); c[N >> 2] = 2; c[N + 4 >> 2] = 0; c[d >> 2] = c[N >> 2]; c[d + 4 >> 2] = c[N + 4 >> 2]; Oh(a, 4353, d); c[M >> 2] = 12; c[M + 4 >> 2] = 0; c[d >> 2] = c[M >> 2]; c[d + 4 >> 2] = c[M + 4 >> 2]; Ph(a, 4363, d); c[L >> 2] = 1; c[L + 4 >> 2] = 0; c[d >> 2] = c[L >> 2]; c[d + 4 >> 2] = c[L + 4 >> 2]; Qh(a, 4376, d); c[K >> 2] = 2; c[K + 4 >> 2] = 0; c[d >> 2] = c[K >> 2]; c[d + 4 >> 2] = c[K + 4 >> 2]; Qh(a, 4388, d); c[J >> 2] = 13; c[J + 4 >> 2] = 0; c[d >> 2] = c[J >> 2]; c[d + 4 >> 2] = c[J + 4 >> 2]; Ph(a, 4402, d); c[I >> 2] = 14; c[I + 4 >> 2] = 0; c[d >> 2] = c[I >> 2]; c[d + 4 >> 2] = c[I + 4 >> 2]; Ph(a, 4411, d); c[H >> 2] = 15; c[H + 4 >> 2] = 0; c[d >> 2] = c[H >> 2]; c[d + 4 >> 2] = c[H + 4 >> 2]; Ph(a, 4421, d); c[G >> 2] = 16; c[G + 4 >> 2] = 0; c[d >> 2] = c[G >> 2]; c[d + 4 >> 2] = c[G + 4 >> 2]; Ph(a, 4433, d); c[F >> 2] = 17; c[F + 4 >> 2] = 0; c[d >> 2] = c[F >> 2]; c[d + 4 >> 2] = c[F + 4 >> 2]; Ph(a, 4446, d); c[E >> 2] = 18; c[E + 4 >> 2] = 0; c[d >> 2] = c[E >> 2]; c[d + 4 >> 2] = c[E + 4 >> 2]; Ph(a, 4458, d); c[D >> 2] = 3; c[D + 4 >> 2] = 0; c[d >> 2] = c[D >> 2]; c[d + 4 >> 2] = c[D + 4 >> 2]; Qh(a, 4471, d); c[C >> 2] = 1; c[C + 4 >> 2] = 0; c[d >> 2] = c[C >> 2]; c[d + 4 >> 2] = c[C + 4 >> 2]; Rh(a, 4486, d); c[B >> 2] = 10; c[B + 4 >> 2] = 0; c[d >> 2] = c[B >> 2]; c[d + 4 >> 2] = c[B + 4 >> 2]; Nh(a, 4496, d); c[A >> 2] = 11; c[A + 4 >> 2] = 0; c[d >> 2] = c[A >> 2]; c[d + 4 >> 2] = c[A + 4 >> 2]; Nh(a, 4508, d); c[z >> 2] = 3; c[z + 4 >> 2] = 0; c[d >> 2] = c[z >> 2]; c[d + 4 >> 2] = c[z + 4 >> 2]; Oh(a, 4519, d); c[y >> 2] = 4; c[y + 4 >> 2] = 0; c[d >> 2] = c[y >> 2]; c[d + 4 >> 2] = c[y + 4 >> 2]; Sh(a, 4530, d); c[x >> 2] = 19; c[x + 4 >> 2] = 0; c[d >> 2] = c[x >> 2]; c[d + 4 >> 2] = c[x + 4 >> 2]; Th(a, 4542, d); c[w >> 2] = 12; c[w + 4 >> 2] = 0; c[d >> 2] = c[w >> 2]; c[d + 4 >> 2] = c[w + 4 >> 2]; Uh(a, 4554, d); c[v >> 2] = 13; c[v + 4 >> 2] = 0; c[d >> 2] = c[v >> 2]; c[d + 4 >> 2] = c[v + 4 >> 2]; Vh(a, 4568, d); c[u >> 2] = 2; c[u + 4 >> 2] = 0; c[d >> 2] = c[u >> 2]; c[d + 4 >> 2] = c[u + 4 >> 2]; Wh(a, 4578, d); c[t >> 2] = 20; c[t + 4 >> 2] = 0; c[d >> 2] = c[t >> 2]; c[d + 4 >> 2] = c[t + 4 >> 2]; Xh(a, 4587, d); c[s >> 2] = 22; c[s + 4 >> 2] = 0; c[d >> 2] = c[s >> 2]; c[d + 4 >> 2] = c[s + 4 >> 2]; Ih(a, 4602, d); c[r >> 2] = 23; c[r + 4 >> 2] = 0; c[d >> 2] = c[r >> 2]; c[d + 4 >> 2] = c[r + 4 >> 2]; Ih(a, 4619, d); c[q >> 2] = 14; c[q + 4 >> 2] = 0; c[d >> 2] = c[q >> 2]; c[d + 4 >> 2] = c[q + 4 >> 2]; Yh(a, 4629, d); c[p >> 2] = 1; c[p + 4 >> 2] = 0; c[d >> 2] = c[p >> 2]; c[d + 4 >> 2] = c[p + 4 >> 2]; Zh(a, 4637, d); c[o >> 2] = 4; c[o + 4 >> 2] = 0; c[d >> 2] = c[o >> 2]; c[d + 4 >> 2] = c[o + 4 >> 2]; Qh(a, 4653, d); c[n >> 2] = 5; c[n + 4 >> 2] = 0; c[d >> 2] = c[n >> 2]; c[d + 4 >> 2] = c[n + 4 >> 2]; Qh(a, 4669, d); c[m >> 2] = 6; c[m + 4 >> 2] = 0; c[d >> 2] = c[m >> 2]; c[d + 4 >> 2] = c[m + 4 >> 2]; Qh(a, 4686, d); c[k >> 2] = 7; c[k + 4 >> 2] = 0; c[d >> 2] = c[k >> 2]; c[d + 4 >> 2] = c[k + 4 >> 2]; Qh(a, 4701, d); c[j >> 2] = 8; c[j + 4 >> 2] = 0; c[d >> 2] = c[j >> 2]; c[d + 4 >> 2] = c[j + 4 >> 2]; Qh(a, 4719, d); c[i >> 2] = 9; c[i + 4 >> 2] = 0; c[d >> 2] = c[i >> 2]; c[d + 4 >> 2] = c[i + 4 >> 2]; Qh(a, 4736, d); c[h >> 2] = 21; c[h + 4 >> 2] = 0; c[d >> 2] = c[h >> 2]; c[d + 4 >> 2] = c[h + 4 >> 2]; _h(a, 4754, d); c[g >> 2] = 2; c[g + 4 >> 2] = 0; c[d >> 2] = c[g >> 2]; c[d + 4 >> 2] = c[g + 4 >> 2]; Rh(a, 4772, d); c[f >> 2] = 3; c[f + 4 >> 2] = 0; c[d >> 2] = c[f >> 2]; c[d + 4 >> 2] = c[f + 4 >> 2]; Rh(a, 4790, d); c[e >> 2] = 4; c[e + 4 >> 2] = 0; c[d >> 2] = c[e >> 2]; c[d + 4 >> 2] = c[e + 4 >> 2]; Rh(a, 4808, d); l = b; return; } function Eh(a, b) { a = a | 0; b = b | 0; var d = 0; d = dr() | 0; c[a >> 2] = d; er(d, b); Hv(c[a >> 2] | 0); return; } function Fh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Oq(a, ai(b) | 0, c, 0); return a | 0; } function Gh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; tq(a, ai(b) | 0, c, 0); return a | 0; } function Hh(a, b, c) { a = a | 0; b = b | 0; c = c | 0; cq(a, ai(b) | 0, c, 0); return a | 0; } function Ih(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Lp(a, b, f); l = e; return a | 0; } function Jh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; pp(a, b, f); l = e; return a | 0; } function Kh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Yo(a, b, f); l = e; return a | 0; } function Lh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Fo(a, b, f); l = e; return a | 0; } function Mh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; mo(a, b, f); l = e; return a | 0; } function Nh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Un(a, b, f); l = e; return a | 0; } function Oh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Bn(a, b, f); l = e; return a | 0; } function Ph(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Um(a, b, f); l = e; return a | 0; } function Qh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Bm(a, b, f); l = e; return a | 0; } function Rh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; im(a, b, f); l = e; return a | 0; } function Sh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Rl(a, b, f); l = e; return a | 0; } function Th(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; vl(a, b, f); l = e; return a | 0; } function Uh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; bl(a, b, f); l = e; return a | 0; } function Vh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Kk(a, b, f); l = e; return a | 0; } function Wh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; nk(a, b, f); l = e; return a | 0; } function Xh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Rj(a, b, f); l = e; return a | 0; } function Yh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; xj(a, b, f); l = e; return a | 0; } function Zh(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; _i(a, b, f); l = e; return a | 0; } function _h(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; $h(a, b, f); l = e; return a | 0; } function $h(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; bi(a, d, f, 1); l = e; return; } function ai(a) { a = a | 0; return a | 0; } function bi(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = ci() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = di(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, ei(g, e) | 0, e); l = f; return; } function ci() { var b = 0, d = 0; if (!(a[7616] | 0)) { qi(9136); Ha(24, 9136, o | 0); d = 7616; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9136) | 0)) { b = 9136; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) qi(9136); } return 9136; } function di(a) { a = a | 0; return 0; } function ei(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = ci() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; ki(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { li(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function fi(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; h = l; l = l + 32 | 0; o = h + 24 | 0; n = h + 20 | 0; j = h + 16 | 0; m = h + 12 | 0; k = h + 8 | 0; i = h + 4 | 0; p = h; c[n >> 2] = b; c[j >> 2] = d; c[m >> 2] = e; c[k >> 2] = f; c[i >> 2] = g; g = a + 28 | 0; c[p >> 2] = c[g >> 2]; c[o >> 2] = c[p >> 2]; gi(a + 24 | 0, o, n, m, k, j, i); c[g >> 2] = c[c[g >> 2] >> 2]; l = h; return; } function gi(a, b, d, e, f, g, h) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; h = h | 0; a = hi(b) | 0; b = qC(24) | 0; ii(b + 4 | 0, c[d >> 2] | 0, c[e >> 2] | 0, c[f >> 2] | 0, c[g >> 2] | 0, c[h >> 2] | 0); c[b >> 2] = c[a >> 2]; c[a >> 2] = b; return b | 0; } function hi(a) { a = a | 0; return c[a >> 2] | 0; } function ii(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; c[a + 8 >> 2] = e; c[a + 12 >> 2] = f; c[a + 16 >> 2] = g; return; } function ji(a, b) { a = a | 0; b = b | 0; return b | a | 0; } function ki(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function li(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = mi(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; ni(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; ki(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; oi(a, i); pi(i); l = k; return; } } function mi(a) { a = a | 0; return 357913941; } function ni(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function oi(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function pi(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function qi(a) { a = a | 0; ui(a); return; } function ri(a) { a = a | 0; ti(a + 24 | 0); return; } function si(a) { a = a | 0; return c[a >> 2] | 0; } function ti(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function ui(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 3, b, wi() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function vi() { return 9228; } function wi() { return 1140; } function xi(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = zi(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = Ai(b, e) | 0; l = d; return b | 0; } function yi(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; c[a + 8 >> 2] = e; c[a + 12 >> 2] = f; c[a + 16 >> 2] = g; return; } function zi(a) { a = a | 0; return (c[(ci() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Ai(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 48 | 0; e = f; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; ob[d & 31](e, a); e = Bi(e) | 0; l = f; return e | 0; } function Bi(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = l + 32 | 0; b = e + 12 | 0; c = e; d = Di(Ci() | 0) | 0; if (!d) a = Ii(a) | 0; else { Ei(b, d); Fi(c, b); Gi(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function Ci() { var b = 0; if (!(a[7632] | 0)) { Ti(9184); Ha(25, 9184, o | 0); b = 7632; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 9184; } function Di(a) { a = a | 0; return c[a + 36 >> 2] | 0; } function Ei(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; c[a + 4 >> 2] = a; c[a + 8 >> 2] = 0; return; } function Fi(a, b) { a = a | 0; b = b | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = c[b + 4 >> 2]; c[a + 8 >> 2] = 0; return; } function Gi(a, b) { a = a | 0; b = b | 0; Ni(b, a, a + 8 | 0, a + 16 | 0, a + 24 | 0, a + 32 | 0, a + 40 | 0); return; } function Hi(a) { a = a | 0; return c[(c[a + 4 >> 2] | 0) + 8 >> 2] | 0; } function Ii(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; j = l; l = l + 16 | 0; d = j + 4 | 0; e = j; f = jy(8) | 0; g = f; h = qC(48) | 0; i = h; b = i + 48 | 0; do { c[i >> 2] = c[a >> 2]; i = i + 4 | 0; a = a + 4 | 0; }while ((i | 0) < (b | 0)) b = g + 4 | 0; c[b >> 2] = h; i = qC(8) | 0; h = c[b >> 2] | 0; c[e >> 2] = 0; c[d >> 2] = c[e >> 2]; Ji(i, h, d); c[f >> 2] = i; l = j; return g | 0; } function Ji(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[d + 4 >> 2] = 0; c[d + 8 >> 2] = 0; c[d >> 2] = 1092; c[d + 12 >> 2] = b; c[a + 4 >> 2] = d; return; } function Ki(a) { a = a | 0; kC(a); sC(a); return; } function Li(a) { a = a | 0; a = c[a + 12 >> 2] | 0; if (a | 0) sC(a); return; } function Mi(a) { a = a | 0; sC(a); return; } function Ni(a, b, d, e, f, g, h) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; h = h | 0; g = Oi(c[a >> 2] | 0, b, d, e, f, g, h) | 0; h = a + 4 | 0; c[(c[h >> 2] | 0) + 8 >> 2] = g; return c[(c[h >> 2] | 0) + 8 >> 2] | 0; } function Oi(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var i = 0, j = 0; i = l; l = l + 16 | 0; j = i; UA(j); a = Sg(a) | 0; g = Pi(a, +h[b >> 3], +h[c >> 3], +h[d >> 3], +h[e >> 3], +h[f >> 3], +h[g >> 3]) | 0; WA(j); l = i; return g | 0; } function Pi(a, b, c, d, e, f, g) { a = a | 0; b = +b; c = +c; d = +d; e = +e; f = +f; g = +g; var h = 0; h = Vg(Qi() | 0) | 0; b = +Wg(b); c = +Wg(c); d = +Wg(d); e = +Wg(e); f = +Wg(f); return ya(0, h | 0, a | 0, +b, +c, +d, +e, +f, + +Wg(g)) | 0; } function Qi() { var b = 0; if (!(a[7624] | 0)) { Ri(9172); b = 7624; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 9172; } function Ri(a) { a = a | 0; fh(a, Si() | 0, 6); return; } function Si() { return 1112; } function Ti(a) { a = a | 0; Zi(a); return; } function Ui(a) { a = a | 0; Vi(a + 24 | 0); Wi(a + 16 | 0); return; } function Vi(a) { a = a | 0; Yi(a); return; } function Wi(a) { a = a | 0; Xi(a); return; } function Xi(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); }while ((b | 0) != 0) c[a >> 2] = 0; return; } function Yi(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); }while ((b | 0) != 0) c[a >> 2] = 0; return; } function Zi(b) { b = b | 0; var d = 0; c[b + 16 >> 2] = 0; c[b + 20 >> 2] = 0; d = b + 24 | 0; c[d >> 2] = 0; c[b + 28 >> 2] = d; c[b + 36 >> 2] = 0; a[b + 40 >> 0] = 0; a[b + 41 >> 0] = 0; return; } function _i(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; $i(a, d, f, 0); l = e; return; } function $i(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = aj() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = bj(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, cj(g, e) | 0, e); l = f; return; } function aj() { var b = 0, d = 0; if (!(a[7640] | 0)) { jj(9232); Ha(26, 9232, o | 0); d = 7640; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9232) | 0)) { b = 9232; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) jj(9232); } return 9232; } function bj(a) { a = a | 0; return 0; } function cj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = aj() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; dj(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { ej(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function dj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function ej(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = fj(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; gj(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; dj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; hj(a, i); ij(i); l = k; return; } } function fj(a) { a = a | 0; return 357913941; } function gj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function hj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ij(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function jj(a) { a = a | 0; mj(a); return; } function kj(a) { a = a | 0; lj(a + 24 | 0); return; } function lj(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function mj(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, nj() | 0, 3); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function nj() { return 1144; } function oj(a, b, d, e, f) { a = a | 0; b = b | 0; d = +d; e = +e; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = l + 16 | 0; h = g + 8 | 0; i = g; j = pj(a) | 0; a = c[j + 4 >> 2] | 0; c[i >> 2] = c[j >> 2]; c[i + 4 >> 2] = a; c[h >> 2] = c[i >> 2]; c[h + 4 >> 2] = c[i + 4 >> 2]; qj(b, h, d, e, f); l = g; return; } function pj(a) { a = a | 0; return (c[(aj() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function qj(a, b, d, e, f) { a = a | 0; b = b | 0; d = +d; e = +e; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0; k = l; l = l + 16 | 0; h = k + 2 | 0; i = k + 1 | 0; j = k; g = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) g = c[(c[a >> 2] | 0) + g >> 2] | 0; rj(h, d); d = +sj(h, d); rj(i, e); e = +sj(i, e); tj(j, f); j = uj(j, f) | 0; qb[g & 1](a, d, e, j); l = k; return; } function rj(a, b) { a = a | 0; b = +b; return; } function sj(a, b) { a = a | 0; b = +b; return + +wj(b); } function tj(a, b) { a = a | 0; b = b | 0; return; } function uj(a, b) { a = a | 0; b = b | 0; return vj(b) | 0; } function vj(a) { a = a | 0; return a | 0; } function wj(a) { a = +a; return +a; } function xj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; yj(a, d, f, 1); l = e; return; } function yj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = zj() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Aj(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Bj(g, e) | 0, e); l = f; return; } function zj() { var b = 0, d = 0; if (!(a[7648] | 0)) { Ij(9268); Ha(27, 9268, o | 0); d = 7648; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9268) | 0)) { b = 9268; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Ij(9268); } return 9268; } function Aj(a) { a = a | 0; return 0; } function Bj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = zj() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Cj(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Dj(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Cj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Dj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Ej(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Fj(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Cj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Gj(a, i); Hj(i); l = k; return; } } function Ej(a) { a = a | 0; return 357913941; } function Fj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Gj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Hj(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Ij(a) { a = a | 0; Lj(a); return; } function Jj(a) { a = a | 0; Kj(a + 24 | 0); return; } function Kj(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Lj(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 4, b, Mj() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Mj() { return 1160; } function Nj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = Oj(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = Pj(b, e) | 0; l = d; return b | 0; } function Oj(a) { a = a | 0; return (c[(zj() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Pj(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; return Qj(pb[d & 31](a) | 0) | 0; } function Qj(a) { a = a | 0; return a & 1 | 0; } function Rj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Sj(a, d, f, 0); l = e; return; } function Sj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Tj() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Uj(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Vj(g, e) | 0, e); l = f; return; } function Tj() { var b = 0, d = 0; if (!(a[7656] | 0)) { ak(9304); Ha(28, 9304, o | 0); d = 7656; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9304) | 0)) { b = 9304; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) ak(9304); } return 9304; } function Uj(a) { a = a | 0; return 0; } function Vj(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Tj() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Wj(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Xj(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Wj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Xj(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Yj(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Zj(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Wj(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; _j(a, i); $j(i); l = k; return; } } function Yj(a) { a = a | 0; return 357913941; } function Zj(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function _j(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function $j(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ak(a) { a = a | 0; dk(a); return; } function bk(a) { a = a | 0; ck(a + 24 | 0); return; } function ck(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function dk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, ek() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function ek() { return 1164; } function fk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = gk(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; hk(b, f, d); l = e; return; } function gk(a) { a = a | 0; return (c[(Tj() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function hk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; ik(f, d); d = jk(f, d) | 0; ob[e & 31](a, d); kk(f); l = g; return; } function ik(a, b) { a = a | 0; b = b | 0; lk(a, b); return; } function jk(a, b) { a = a | 0; b = b | 0; return a | 0; } function kk(a) { a = a | 0; vf(a); return; } function lk(a, b) { a = a | 0; b = b | 0; mk(a, b); return; } function mk(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function nk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; ok(a, d, f, 0); l = e; return; } function ok(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = pk() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = qk(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, rk(g, e) | 0, e); l = f; return; } function pk() { var b = 0, d = 0; if (!(a[7664] | 0)) { yk(9340); Ha(29, 9340, o | 0); d = 7664; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9340) | 0)) { b = 9340; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) yk(9340); } return 9340; } function qk(a) { a = a | 0; return 0; } function rk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = pk() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; sk(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { tk(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function sk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function tk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = uk(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; vk(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; sk(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; wk(a, i); xk(i); l = k; return; } } function uk(a) { a = a | 0; return 357913941; } function vk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function wk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function xk(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function yk(a) { a = a | 0; Bk(a); return; } function zk(a) { a = a | 0; Ak(a + 24 | 0); return; } function Ak(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Bk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 4, b, Ck() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Ck() { return 1180; } function Dk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Ek(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; d = Fk(b, f, d) | 0; l = e; return d | 0; } function Ek(a) { a = a | 0; return (c[(pk() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Fk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; Gk(f, d); f = Hk(f, d) | 0; f = Ik(wb[e & 15](a, f) | 0) | 0; l = g; return f | 0; } function Gk(a, b) { a = a | 0; b = b | 0; return; } function Hk(a, b) { a = a | 0; b = b | 0; return Jk(b) | 0; } function Ik(a) { a = a | 0; return a | 0; } function Jk(a) { a = a | 0; return a | 0; } function Kk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Lk(a, d, f, 0); l = e; return; } function Lk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Mk() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Nk(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Ok(g, e) | 0, e); l = f; return; } function Mk() { var b = 0, d = 0; if (!(a[7672] | 0)) { Vk(9376); Ha(30, 9376, o | 0); d = 7672; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9376) | 0)) { b = 9376; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Vk(9376); } return 9376; } function Nk(a) { a = a | 0; return 0; } function Ok(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Mk() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Pk(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Qk(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Pk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Qk(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Rk(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Sk(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Pk(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Tk(a, i); Uk(i); l = k; return; } } function Rk(a) { a = a | 0; return 357913941; } function Sk(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Tk(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Uk(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Vk(a) { a = a | 0; Yk(a); return; } function Wk(a) { a = a | 0; Xk(a + 24 | 0); return; } function Xk(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Yk(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Zk() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Zk() { return 1196; } function _k(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = $k(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = al(b, e) | 0; l = d; return b | 0; } function $k(a) { a = a | 0; return (c[(Mk() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function al(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; return Ik(pb[d & 31](a) | 0) | 0; } function bl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; cl(a, d, f, 1); l = e; return; } function cl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = dl() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = el(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, fl(g, e) | 0, e); l = f; return; } function dl() { var b = 0, d = 0; if (!(a[7680] | 0)) { ml(9412); Ha(31, 9412, o | 0); d = 7680; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9412) | 0)) { b = 9412; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) ml(9412); } return 9412; } function el(a) { a = a | 0; return 0; } function fl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = dl() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; gl(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { hl(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function gl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function hl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = il(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; jl(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; gl(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; kl(a, i); ll(i); l = k; return; } } function il(a) { a = a | 0; return 357913941; } function jl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function kl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ll(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ml(a) { a = a | 0; pl(a); return; } function nl(a) { a = a | 0; ol(a + 24 | 0); return; } function ol(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function pl(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, ql() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function ql() { return 1200; } function rl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = sl(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = tl(b, e) | 0; l = d; return b | 0; } function sl(a) { a = a | 0; return (c[(dl() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function tl(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; return ul(pb[d & 31](a) | 0) | 0; } function ul(a) { a = a | 0; return a | 0; } function vl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; wl(a, d, f, 0); l = e; return; } function wl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = xl() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = yl(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, zl(g, e) | 0, e); l = f; return; } function xl() { var b = 0, d = 0; if (!(a[7688] | 0)) { Gl(9448); Ha(32, 9448, o | 0); d = 7688; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9448) | 0)) { b = 9448; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Gl(9448); } return 9448; } function yl(a) { a = a | 0; return 0; } function zl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = xl() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Al(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Bl(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Al(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Bl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Cl(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Dl(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Al(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; El(a, i); Fl(i); l = k; return; } } function Cl(a) { a = a | 0; return 357913941; } function Dl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function El(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Fl(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Gl(a) { a = a | 0; Jl(a); return; } function Hl(a) { a = a | 0; Il(a + 24 | 0); return; } function Il(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Jl(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, Kl() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Kl() { return 1204; } function Ll(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Ml(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Nl(b, f, d); l = e; return; } function Ml(a) { a = a | 0; return (c[(xl() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Nl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; Ol(f, d); f = Pl(f, d) | 0; ob[e & 31](a, f); l = g; return; } function Ol(a, b) { a = a | 0; b = b | 0; return; } function Pl(a, b) { a = a | 0; b = b | 0; return Ql(b) | 0; } function Ql(a) { a = a | 0; return a | 0; } function Rl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Sl(a, d, f, 0); l = e; return; } function Sl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Tl() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Ul(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Vl(g, e) | 0, e); l = f; return; } function Tl() { var b = 0, d = 0; if (!(a[7696] | 0)) { am(9484); Ha(33, 9484, o | 0); d = 7696; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9484) | 0)) { b = 9484; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) am(9484); } return 9484; } function Ul(a) { a = a | 0; return 0; } function Vl(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Tl() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Wl(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Xl(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Wl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Xl(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Yl(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Zl(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Wl(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; _l(a, i); $l(i); l = k; return; } } function Yl(a) { a = a | 0; return 357913941; } function Zl(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function _l(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function $l(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function am(a) { a = a | 0; dm(a); return; } function bm(a) { a = a | 0; cm(a + 24 | 0); return; } function cm(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function dm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, em() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function em() { return 1212; } function fm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; g = f + 8 | 0; h = f; i = gm(a) | 0; a = c[i + 4 >> 2] | 0; c[h >> 2] = c[i >> 2]; c[h + 4 >> 2] = a; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = c[h + 4 >> 2]; hm(b, g, d, e); l = f; return; } function gm(a) { a = a | 0; return (c[(Tl() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function hm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; i = l; l = l + 16 | 0; g = i + 1 | 0; h = i; f = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) f = c[(c[a >> 2] | 0) + f >> 2] | 0; Ol(g, d); g = Pl(g, d) | 0; Gk(h, e); h = Hk(h, e) | 0; Eb[f & 15](a, g, h); l = i; return; } function im(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; jm(a, d, f, 1); l = e; return; } function jm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = km() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = lm(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, mm(g, e) | 0, e); l = f; return; } function km() { var b = 0, d = 0; if (!(a[7704] | 0)) { tm(9520); Ha(34, 9520, o | 0); d = 7704; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9520) | 0)) { b = 9520; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) tm(9520); } return 9520; } function lm(a) { a = a | 0; return 0; } function mm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = km() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; nm(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { om(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function nm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function om(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = pm(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; qm(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; nm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; rm(a, i); sm(i); l = k; return; } } function pm(a) { a = a | 0; return 357913941; } function qm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function rm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function sm(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function tm(a) { a = a | 0; wm(a); return; } function um(a) { a = a | 0; vm(a + 24 | 0); return; } function vm(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function wm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, xm() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function xm() { return 1224; } function ym(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0.0, f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; g = f + 8 | 0; h = f; i = zm(a) | 0; a = c[i + 4 >> 2] | 0; c[h >> 2] = c[i >> 2]; c[h + 4 >> 2] = a; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = c[h + 4 >> 2]; e = +Am(b, g, d); l = f; return +e; } function zm(a) { a = a | 0; return (c[(km() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Am(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0.0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; tj(f, d); f = uj(f, d) | 0; h = +ch(+zb[e & 7](a, f)); l = g; return +h; } function Bm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Cm(a, d, f, 1); l = e; return; } function Cm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Dm() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Em(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Fm(g, e) | 0, e); l = f; return; } function Dm() { var b = 0, d = 0; if (!(a[7712] | 0)) { Mm(9556); Ha(35, 9556, o | 0); d = 7712; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9556) | 0)) { b = 9556; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Mm(9556); } return 9556; } function Em(a) { a = a | 0; return 0; } function Fm(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Dm() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Gm(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Hm(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Gm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Hm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Im(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Jm(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Gm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Km(a, i); Lm(i); l = k; return; } } function Im(a) { a = a | 0; return 357913941; } function Jm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Km(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Lm(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Mm(a) { a = a | 0; Pm(a); return; } function Nm(a) { a = a | 0; Om(a + 24 | 0); return; } function Om(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Pm(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Qm() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Qm() { return 1232; } function Rm(a, b) { a = a | 0; b = b | 0; var d = 0.0, e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Sm(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; d = +Tm(b, f); l = e; return +d; } function Sm(a) { a = a | 0; return (c[(Dm() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Tm(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; return + +ch(+ub[d & 15](a)); } function Um(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Vm(a, d, f, 1); l = e; return; } function Vm(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Wm() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Xm(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Ym(g, e) | 0, e); l = f; return; } function Wm() { var b = 0, d = 0; if (!(a[7720] | 0)) { dn(9592); Ha(36, 9592, o | 0); d = 7720; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9592) | 0)) { b = 9592; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) dn(9592); } return 9592; } function Xm(a) { a = a | 0; return 0; } function Ym(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Wm() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Zm(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { _m(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Zm(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function _m(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = $m(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; an(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Zm(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; bn(a, i); cn(i); l = k; return; } } function $m(a) { a = a | 0; return 357913941; } function an(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function bn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function cn(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function dn(a) { a = a | 0; gn(a); return; } function en(a) { a = a | 0; fn(a + 24 | 0); return; } function fn(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function gn(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 7, b, hn() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function hn() { return 1276; } function jn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = kn(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = ln(b, e) | 0; l = d; return b | 0; } function kn(a) { a = a | 0; return (c[(Wm() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function ln(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 16 | 0; e = f; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; ob[d & 31](e, a); e = mn(e) | 0; l = f; return e | 0; } function mn(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = l + 32 | 0; b = e + 12 | 0; c = e; d = Di(nn() | 0) | 0; if (!d) a = pn(a) | 0; else { Ei(b, d); Fi(c, b); on(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function nn() { var b = 0; if (!(a[7736] | 0)) { An(9640); Ha(25, 9640, o | 0); b = 7736; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 9640; } function on(a, b) { a = a | 0; b = b | 0; un(b, a, a + 8 | 0); return; } function pn(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = l + 16 | 0; f = d + 4 | 0; h = d; e = jy(8) | 0; b = e; i = qC(16) | 0; c[i >> 2] = c[a >> 2]; c[i + 4 >> 2] = c[a + 4 >> 2]; c[i + 8 >> 2] = c[a + 8 >> 2]; c[i + 12 >> 2] = c[a + 12 >> 2]; g = b + 4 | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; qn(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function qn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[d + 4 >> 2] = 0; c[d + 8 >> 2] = 0; c[d >> 2] = 1244; c[d + 12 >> 2] = b; c[a + 4 >> 2] = d; return; } function rn(a) { a = a | 0; kC(a); sC(a); return; } function sn(a) { a = a | 0; a = c[a + 12 >> 2] | 0; if (a | 0) sC(a); return; } function tn(a) { a = a | 0; sC(a); return; } function un(a, b, d) { a = a | 0; b = b | 0; d = d | 0; b = vn(c[a >> 2] | 0, b, d) | 0; d = a + 4 | 0; c[(c[d >> 2] | 0) + 8 >> 2] = b; return c[(c[d >> 2] | 0) + 8 >> 2] | 0; } function vn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e; UA(f); a = Sg(a) | 0; d = wn(a, c[b >> 2] | 0, +h[d >> 3]) | 0; WA(f); l = e; return d | 0; } function wn(a, b, c) { a = a | 0; b = b | 0; c = +c; var d = 0; d = Vg(xn() | 0) | 0; b = Xg(b) | 0; return za(0, d | 0, a | 0, b | 0, + +Wg(c)) | 0; } function xn() { var b = 0; if (!(a[7728] | 0)) { yn(9628); b = 7728; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 9628; } function yn(a) { a = a | 0; fh(a, zn() | 0, 2); return; } function zn() { return 1264; } function An(a) { a = a | 0; Zi(a); return; } function Bn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Cn(a, d, f, 1); l = e; return; } function Cn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Dn() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = En(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Fn(g, e) | 0, e); l = f; return; } function Dn() { var b = 0, d = 0; if (!(a[7744] | 0)) { Mn(9684); Ha(37, 9684, o | 0); d = 7744; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9684) | 0)) { b = 9684; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Mn(9684); } return 9684; } function En(a) { a = a | 0; return 0; } function Fn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Dn() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Gn(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Hn(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Gn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Hn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = In(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Jn(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Gn(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Kn(a, i); Ln(i); l = k; return; } } function In(a) { a = a | 0; return 357913941; } function Jn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Kn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Ln(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Mn(a) { a = a | 0; Pn(a); return; } function Nn(a) { a = a | 0; On(a + 24 | 0); return; } function On(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Pn(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 5, b, Qn() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Qn() { return 1280; } function Rn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Sn(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; d = Tn(b, f, d) | 0; l = e; return d | 0; } function Sn(a) { a = a | 0; return (c[(Dn() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Tn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; h = l; l = l + 32 | 0; f = h; g = h + 16 | 0; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; tj(g, d); g = uj(g, d) | 0; Eb[e & 15](f, a, g); g = mn(f) | 0; l = h; return g | 0; } function Un(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Vn(a, d, f, 1); l = e; return; } function Vn(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Wn() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Xn(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Yn(g, e) | 0, e); l = f; return; } function Wn() { var b = 0, d = 0; if (!(a[7752] | 0)) { eo(9720); Ha(38, 9720, o | 0); d = 7752; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9720) | 0)) { b = 9720; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) eo(9720); } return 9720; } function Xn(a) { a = a | 0; return 0; } function Yn(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Wn() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Zn(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { _n(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Zn(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function _n(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = $n(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; ao(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Zn(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; bo(a, i); co(i); l = k; return; } } function $n(a) { a = a | 0; return 357913941; } function ao(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function bo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function co(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function eo(a) { a = a | 0; ho(a); return; } function fo(a) { a = a | 0; go(a + 24 | 0); return; } function go(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function ho(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, io() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function io() { return 1288; } function jo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = ko(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; b = lo(b, e) | 0; l = d; return b | 0; } function ko(a) { a = a | 0; return (c[(Wn() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function lo(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; return bh(pb[d & 31](a) | 0) | 0; } function mo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; no(a, d, f, 0); l = e; return; } function no(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = oo() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = po(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, qo(g, e) | 0, e); l = f; return; } function oo() { var b = 0, d = 0; if (!(a[7760] | 0)) { xo(9756); Ha(39, 9756, o | 0); d = 7760; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9756) | 0)) { b = 9756; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) xo(9756); } return 9756; } function po(a) { a = a | 0; return 0; } function qo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = oo() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; ro(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { so(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function ro(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function so(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = to(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; uo(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; ro(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; vo(a, i); wo(i); l = k; return; } } function to(a) { a = a | 0; return 357913941; } function uo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function vo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function wo(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function xo(a) { a = a | 0; Ao(a); return; } function yo(a) { a = a | 0; zo(a + 24 | 0); return; } function zo(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Ao(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, Bo() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Bo() { return 1292; } function Co(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Do(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Eo(b, f, d); l = e; return; } function Do(a) { a = a | 0; return (c[(oo() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Eo(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; rj(f, d); d = +sj(f, d); lb[e & 31](a, d); l = g; return; } function Fo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Go(a, d, f, 0); l = e; return; } function Go(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Ho() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Io(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Jo(g, e) | 0, e); l = f; return; } function Ho() { var b = 0, d = 0; if (!(a[7768] | 0)) { Qo(9792); Ha(40, 9792, o | 0); d = 7768; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9792) | 0)) { b = 9792; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Qo(9792); } return 9792; } function Io(a) { a = a | 0; return 0; } function Jo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Ho() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Ko(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Lo(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Ko(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Lo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Mo(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; No(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Ko(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Oo(a, i); Po(i); l = k; return; } } function Mo(a) { a = a | 0; return 357913941; } function No(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Oo(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Po(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Qo(a) { a = a | 0; To(a); return; } function Ro(a) { a = a | 0; So(a + 24 | 0); return; } function So(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function To(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 1, b, Uo() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Uo() { return 1300; } function Vo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = +e; var f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; g = f + 8 | 0; h = f; i = Wo(a) | 0; a = c[i + 4 >> 2] | 0; c[h >> 2] = c[i >> 2]; c[h + 4 >> 2] = a; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = c[h + 4 >> 2]; Xo(b, g, d, e); l = f; return; } function Wo(a) { a = a | 0; return (c[(Ho() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Xo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = +e; var f = 0, g = 0, h = 0, i = 0; i = l; l = l + 16 | 0; g = i + 1 | 0; h = i; f = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) f = c[(c[a >> 2] | 0) + f >> 2] | 0; tj(g, d); g = uj(g, d) | 0; rj(h, e); e = +sj(h, e); Gb[f & 15](a, g, e); l = i; return; } function Yo(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Zo(a, d, f, 0); l = e; return; } function Zo(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = _o() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = $o(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, ap(g, e) | 0, e); l = f; return; } function _o() { var b = 0, d = 0; if (!(a[7776] | 0)) { hp(9828); Ha(41, 9828, o | 0); d = 7776; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9828) | 0)) { b = 9828; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) hp(9828); } return 9828; } function $o(a) { a = a | 0; return 0; } function ap(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = _o() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; bp(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { cp(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function bp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function cp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = dp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; ep(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; bp(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; fp(a, i); gp(i); l = k; return; } } function dp(a) { a = a | 0; return 357913941; } function ep(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function fp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function gp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function hp(a) { a = a | 0; kp(a); return; } function ip(a) { a = a | 0; jp(a + 24 | 0); return; } function jp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function kp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 7, b, lp() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function lp() { return 1312; } function mp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = np(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; op(b, f, d); l = e; return; } function np(a) { a = a | 0; return (c[(_o() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function op(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; tj(f, d); f = uj(f, d) | 0; ob[e & 31](a, f); l = g; return; } function pp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; qp(a, d, f, 0); l = e; return; } function qp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = rp() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = sp(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, tp(g, e) | 0, e); l = f; return; } function rp() { var b = 0, d = 0; if (!(a[7784] | 0)) { Ap(9864); Ha(42, 9864, o | 0); d = 7784; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9864) | 0)) { b = 9864; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Ap(9864); } return 9864; } function sp(a) { a = a | 0; return 0; } function tp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = rp() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; up(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { vp(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function up(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function vp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = wp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; xp(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; up(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; yp(a, i); zp(i); l = k; return; } } function wp(a) { a = a | 0; return 357913941; } function xp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function yp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function zp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Ap(a) { a = a | 0; Dp(a); return; } function Bp(a) { a = a | 0; Cp(a + 24 | 0); return; } function Cp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Dp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 8, b, Ep() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Ep() { return 1320; } function Fp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Gp(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Hp(b, f, d); l = e; return; } function Gp(a) { a = a | 0; return (c[(rp() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Hp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; Ip(f, d); f = Jp(f, d) | 0; ob[e & 31](a, f); l = g; return; } function Ip(a, b) { a = a | 0; b = b | 0; return; } function Jp(a, b) { a = a | 0; b = b | 0; return Kp(b) | 0; } function Kp(a) { a = a | 0; return a | 0; } function Lp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Mp(a, d, f, 0); l = e; return; } function Mp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Np() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Op(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Pp(g, e) | 0, e); l = f; return; } function Np() { var b = 0, d = 0; if (!(a[7792] | 0)) { Wp(9900); Ha(43, 9900, o | 0); d = 7792; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9900) | 0)) { b = 9900; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Wp(9900); } return 9900; } function Op(a) { a = a | 0; return 0; } function Pp(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Np() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Qp(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Rp(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Qp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Rp(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Sp(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Tp(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Qp(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Up(a, i); Vp(i); l = k; return; } } function Sp(a) { a = a | 0; return 357913941; } function Tp(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Up(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Vp(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Wp(a) { a = a | 0; Zp(a); return; } function Xp(a) { a = a | 0; Yp(a + 24 | 0); return; } function Yp(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Zp(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 22, b, _p() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function _p() { return 1344; } function $p(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0; d = l; l = l + 16 | 0; e = d + 8 | 0; f = d; g = aq(a) | 0; a = c[g + 4 >> 2] | 0; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = a; c[e >> 2] = c[f >> 2]; c[e + 4 >> 2] = c[f + 4 >> 2]; bq(b, e); l = d; return; } function aq(a) { a = a | 0; return (c[(Np() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function bq(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) d = c[(c[a >> 2] | 0) + d >> 2] | 0; nb[d & 127](a); return; } function cq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = dq() | 0; a = eq(d) | 0; fi(g, b, f, a, fq(d, e) | 0, e); return; } function dq() { var b = 0, d = 0; if (!(a[7800] | 0)) { mq(9936); Ha(44, 9936, o | 0); d = 7800; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9936) | 0)) { b = 9936; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) mq(9936); } return 9936; } function eq(a) { a = a | 0; return a | 0; } function fq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = dq() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { gq(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { hq(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function gq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function hq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = iq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; jq(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; gq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; kq(a, f); lq(f); l = i; return; } } function iq(a) { a = a | 0; return 536870911; } function jq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function kq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function lq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function mq(a) { a = a | 0; pq(a); return; } function nq(a) { a = a | 0; oq(a + 24 | 0); return; } function oq(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function pq(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 23, b, Kl() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function qq(a, b) { a = a | 0; b = b | 0; sq(c[(rq(a) | 0) >> 2] | 0, b); return; } function rq(a) { a = a | 0; return (c[(dq() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function sq(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = l + 16 | 0; d = c; Ol(d, b); b = Pl(d, b) | 0; nb[a & 127](b); l = c; return; } function tq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = uq() | 0; a = vq(d) | 0; fi(g, b, f, a, wq(d, e) | 0, e); return; } function uq() { var b = 0, d = 0; if (!(a[7808] | 0)) { Dq(9972); Ha(45, 9972, o | 0); d = 7808; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(9972) | 0)) { b = 9972; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Dq(9972); } return 9972; } function vq(a) { a = a | 0; return a | 0; } function wq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = uq() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { xq(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { yq(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function xq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function yq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = zq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Aq(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; xq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Bq(a, f); Cq(f); l = i; return; } } function zq(a) { a = a | 0; return 536870911; } function Aq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Bq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Cq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Dq(a) { a = a | 0; Gq(a); return; } function Eq(a) { a = a | 0; Fq(a + 24 | 0); return; } function Fq(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Gq(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 9, b, Hq() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Hq() { return 1348; } function Iq(a, b) { a = a | 0; b = b | 0; return Kq(c[(Jq(a) | 0) >> 2] | 0, b) | 0; } function Jq(a) { a = a | 0; return (c[(uq() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function Kq(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = l + 16 | 0; d = c; Lq(d, b); b = Mq(d, b) | 0; b = Ik(pb[a & 31](b) | 0) | 0; l = c; return b | 0; } function Lq(a, b) { a = a | 0; b = b | 0; return; } function Mq(a, b) { a = a | 0; b = b | 0; return Nq(b) | 0; } function Nq(a) { a = a | 0; return a | 0; } function Oq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Pq() | 0; a = Qq(d) | 0; fi(g, b, f, a, Rq(d, e) | 0, e); return; } function Pq() { var b = 0, d = 0; if (!(a[7816] | 0)) { Yq(10008); Ha(46, 10008, o | 0); d = 7816; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10008) | 0)) { b = 10008; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Yq(10008); } return 10008; } function Qq(a) { a = a | 0; return a | 0; } function Rq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Pq() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { Sq(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { Tq(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function Sq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function Tq(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = Uq(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Vq(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; Sq(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Wq(a, f); Xq(f); l = i; return; } } function Uq(a) { a = a | 0; return 536870911; } function Vq(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Wq(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Xq(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Yq(a) { a = a | 0; $q(a); return; } function Zq(a) { a = a | 0; _q(a + 24 | 0); return; } function _q(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function $q(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 15, b, Zk() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function ar(a) { a = a | 0; return cr(c[(br(a) | 0) >> 2] | 0) | 0; } function br(a) { a = a | 0; return (c[(Pq() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function cr(a) { a = a | 0; return Ik(Ab[a & 7]() | 0) | 0; } function dr() { var b = 0; if (!(a[7832] | 0)) { nr(10052); Ha(25, 10052, o | 0); b = 7832; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10052; } function er(a, b) { a = a | 0; b = b | 0; c[a >> 2] = fr() | 0; c[a + 4 >> 2] = gr() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = hr() | 0; c[a + 32 >> 2] = 2; return; } function fr() { return 11709; } function gr() { return 1188; } function hr() { return lr() | 0; } function ir(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { kr(c); sC(c); } } else if (b | 0) { uf(b); sC(b); } return; } function jr(a, b) { a = a | 0; b = b | 0; return b & a | 0; } function kr(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function lr() { var b = 0; if (!(a[7824] | 0)) { c[2511] = mr() | 0; c[2512] = 0; b = 7824; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10044; } function mr() { return 0; } function nr(a) { a = a | 0; Zi(a); return; } function or(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0; b = l; l = l + 32 | 0; d = b + 24 | 0; g = b + 16 | 0; f = b + 8 | 0; e = b; pr(a, 4827); qr(a, 4834, 3); rr(a, 3682, 47); c[g >> 2] = 9; c[g + 4 >> 2] = 0; c[d >> 2] = c[g >> 2]; c[d + 4 >> 2] = c[g + 4 >> 2]; sr(a, 4841, d); c[f >> 2] = 1; c[f + 4 >> 2] = 0; c[d >> 2] = c[f >> 2]; c[d + 4 >> 2] = c[f + 4 >> 2]; tr(a, 4871, d); c[e >> 2] = 10; c[e + 4 >> 2] = 0; c[d >> 2] = c[e >> 2]; c[d + 4 >> 2] = c[e + 4 >> 2]; ur(a, 4891, d); l = b; return; } function pr(a, b) { a = a | 0; b = b | 0; var d = 0; d = nt() | 0; c[a >> 2] = d; ot(d, b); Hv(c[a >> 2] | 0); return; } function qr(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Ws(a, ai(b) | 0, c, 0); return a | 0; } function rr(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Es(a, ai(b) | 0, c, 0); return a | 0; } function sr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; is(a, b, f); l = e; return a | 0; } function tr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Or(a, b, f); l = e; return a | 0; } function ur(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = c[d + 4 >> 2] | 0; c[g >> 2] = c[d >> 2]; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; vr(a, b, f); l = e; return a | 0; } function vr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; wr(a, d, f, 1); l = e; return; } function wr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = xr() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = yr(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, zr(g, e) | 0, e); l = f; return; } function xr() { var b = 0, d = 0; if (!(a[7840] | 0)) { Gr(10100); Ha(48, 10100, o | 0); d = 7840; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10100) | 0)) { b = 10100; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Gr(10100); } return 10100; } function yr(a) { a = a | 0; return 0; } function zr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = xr() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Ar(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Br(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Ar(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Br(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Cr(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Dr(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Ar(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Er(a, i); Fr(i); l = k; return; } } function Cr(a) { a = a | 0; return 357913941; } function Dr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Er(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Fr(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Gr(a) { a = a | 0; Jr(a); return; } function Hr(a) { a = a | 0; Ir(a + 24 | 0); return; } function Ir(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function Jr(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 6, b, Kr() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Kr() { return 1364; } function Lr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = Mr(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; d = Nr(b, f, d) | 0; l = e; return d | 0; } function Mr(a) { a = a | 0; return (c[(xr() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function Nr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; tj(f, d); f = uj(f, d) | 0; f = Qj(wb[e & 15](a, f) | 0) | 0; l = g; return f | 0; } function Or(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; Pr(a, d, f, 0); l = e; return; } function Pr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = Qr() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = Rr(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, Sr(g, e) | 0, e); l = f; return; } function Qr() { var b = 0, d = 0; if (!(a[7848] | 0)) { Zr(10136); Ha(49, 10136, o | 0); d = 7848; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10136) | 0)) { b = 10136; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Zr(10136); } return 10136; } function Rr(a) { a = a | 0; return 0; } function Sr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = Qr() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; Tr(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { Ur(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function Tr(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function Ur(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = Vr(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; Wr(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; Tr(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; Xr(a, i); Yr(i); l = k; return; } } function Vr(a) { a = a | 0; return 357913941; } function Wr(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function Xr(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Yr(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Zr(a) { a = a | 0; as(a); return; } function _r(a) { a = a | 0; $r(a + 24 | 0); return; } function $r(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function as(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 9, b, bs() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function bs() { return 1372; } function cs(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; h = ds(a) | 0; a = c[h + 4 >> 2] | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = a; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; es(b, f, d); l = e; return; } function ds(a) { a = a | 0; return (c[(Qr() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function es(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, h = ib; g = l; l = l + 16 | 0; f = g; e = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) e = c[(c[a >> 2] | 0) + e >> 2] | 0; fs(f, d); h = T(gs(f, d)); kb[e & 1](a, h); l = g; return; } function fs(a, b) { a = a | 0; b = +b; return; } function gs(a, b) { a = a | 0; b = +b; return T(hs(b)); } function hs(a) { a = +a; return T(a); } function is(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 16 | 0; f = e + 8 | 0; g = e; i = c[d >> 2] | 0; h = c[d + 4 >> 2] | 0; d = ai(b) | 0; c[g >> 2] = i; c[g + 4 >> 2] = h; c[f >> 2] = c[g >> 2]; c[f + 4 >> 2] = c[g + 4 >> 2]; js(a, d, f, 0); l = e; return; } function js(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; f = l; l = l + 32 | 0; g = f + 16 | 0; m = f + 8 | 0; i = f; k = c[d >> 2] | 0; j = c[d + 4 >> 2] | 0; h = c[a >> 2] | 0; a = ks() | 0; c[m >> 2] = k; c[m + 4 >> 2] = j; c[g >> 2] = c[m >> 2]; c[g + 4 >> 2] = c[m + 4 >> 2]; d = ls(g) | 0; c[i >> 2] = k; c[i + 4 >> 2] = j; c[g >> 2] = c[i >> 2]; c[g + 4 >> 2] = c[i + 4 >> 2]; fi(h, b, a, d, ms(g, e) | 0, e); l = f; return; } function ks() { var b = 0, d = 0; if (!(a[7856] | 0)) { ts(10172); Ha(50, 10172, o | 0); d = 7856; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10172) | 0)) { b = 10172; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) ts(10172); } return 10172; } function ls(a) { a = a | 0; return 0; } function ms(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; m = l; l = l + 32 | 0; f = m + 24 | 0; h = m + 16 | 0; i = m; j = m + 8 | 0; g = c[a >> 2] | 0; e = c[a + 4 >> 2] | 0; c[i >> 2] = g; c[i + 4 >> 2] = e; n = ks() | 0; k = n + 24 | 0; a = ji(b, 4) | 0; c[j >> 2] = a; b = n + 28 | 0; d = c[b >> 2] | 0; if (d >>> 0 < (c[n + 32 >> 2] | 0) >>> 0) { c[h >> 2] = g; c[h + 4 >> 2] = e; c[f >> 2] = c[h >> 2]; c[f + 4 >> 2] = c[h + 4 >> 2]; ns(d, f, a); a = (c[b >> 2] | 0) + 12 | 0; c[b >> 2] = a; } else { os(k, i, j); a = c[b >> 2] | 0; } l = m; return ((a - (c[k >> 2] | 0) | 0) / 12 | 0) + -1 | 0; } function ns(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0; e = c[b + 4 >> 2] | 0; c[a >> 2] = c[b >> 2]; c[a + 4 >> 2] = e; c[a + 8 >> 2] = d; return; } function os(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0; k = l; l = l + 48 | 0; e = k + 32 | 0; h = k + 24 | 0; i = k; j = a + 4 | 0; f = (((c[j >> 2] | 0) - (c[a >> 2] | 0) | 0) / 12 | 0) + 1 | 0; g = ps(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { m = c[a >> 2] | 0; o = ((c[a + 8 >> 2] | 0) - m | 0) / 12 | 0; n = o << 1; qs(i, o >>> 0 < g >>> 1 >>> 0 ? n >>> 0 < f >>> 0 ? f : n : g, ((c[j >> 2] | 0) - m | 0) / 12 | 0, a + 8 | 0); j = i + 8 | 0; g = c[j >> 2] | 0; f = c[b + 4 >> 2] | 0; d = c[d >> 2] | 0; c[h >> 2] = c[b >> 2]; c[h + 4 >> 2] = f; c[e >> 2] = c[h >> 2]; c[e + 4 >> 2] = c[h + 4 >> 2]; ns(g, e, d); c[j >> 2] = (c[j >> 2] | 0) + 12; rs(a, i); ss(i); l = k; return; } } function ps(a) { a = a | 0; return 357913941; } function qs(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 357913941) Ta(); else { f = qC(b * 12 | 0) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d * 12 | 0) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b * 12 | 0); return; } function rs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (((f | 0) / -12 | 0) * 12 | 0) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function ss(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~(((e + -12 - b | 0) >>> 0) / 12 | 0) * 12 | 0); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function ts(a) { a = a | 0; ws(a); return; } function us(a) { a = a | 0; vs(a + 24 | 0); return; } function vs(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~(((b + -12 - e | 0) >>> 0) / 12 | 0) * 12 | 0); sC(d); } return; } function ws(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 2, 3, b, xs() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function xs() { return 1380; } function ys(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; g = f + 8 | 0; h = f; i = zs(a) | 0; a = c[i + 4 >> 2] | 0; c[h >> 2] = c[i >> 2]; c[h + 4 >> 2] = a; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = c[h + 4 >> 2]; As(b, g, d, e); l = f; return; } function zs(a) { a = a | 0; return (c[(ks() | 0) + 24 >> 2] | 0) + (a * 12 | 0) | 0; } function As(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; i = l; l = l + 16 | 0; g = i + 1 | 0; h = i; f = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; a = a + (b >> 1) | 0; if (b & 1) f = c[(c[a >> 2] | 0) + f >> 2] | 0; tj(g, d); g = uj(g, d) | 0; Bs(h, e); h = Cs(h, e) | 0; Eb[f & 15](a, g, h); l = i; return; } function Bs(a, b) { a = a | 0; b = b | 0; return; } function Cs(a, b) { a = a | 0; b = b | 0; return Ds(b) | 0; } function Ds(a) { a = a | 0; return (a | 0) != 0 | 0; } function Es(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Fs() | 0; a = Gs(d) | 0; fi(g, b, f, a, Hs(d, e) | 0, e); return; } function Fs() { var b = 0, d = 0; if (!(a[7864] | 0)) { Os(10208); Ha(51, 10208, o | 0); d = 7864; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10208) | 0)) { b = 10208; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Os(10208); } return 10208; } function Gs(a) { a = a | 0; return a | 0; } function Hs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Fs() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { Is(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { Js(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function Is(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function Js(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = Ks(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Ls(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; Is(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Ms(a, f); Ns(f); l = i; return; } } function Ks(a) { a = a | 0; return 536870911; } function Ls(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Ms(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Ns(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Os(a) { a = a | 0; Rs(a); return; } function Ps(a) { a = a | 0; Qs(a + 24 | 0); return; } function Qs(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Rs(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 24, b, Ss() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Ss() { return 1392; } function Ts(a, b) { a = a | 0; b = b | 0; Vs(c[(Us(a) | 0) >> 2] | 0, b); return; } function Us(a) { a = a | 0; return (c[(Fs() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function Vs(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = l + 16 | 0; d = c; Lq(d, b); b = Mq(d, b) | 0; nb[a & 127](b); l = c; return; } function Ws(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Xs() | 0; a = Ys(d) | 0; fi(g, b, f, a, Zs(d, e) | 0, e); return; } function Xs() { var b = 0, d = 0; if (!(a[7872] | 0)) { et(10244); Ha(52, 10244, o | 0); d = 7872; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10244) | 0)) { b = 10244; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) et(10244); } return 10244; } function Ys(a) { a = a | 0; return a | 0; } function Zs(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Xs() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { _s(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { $s(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function _s(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function $s(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = at(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; bt(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; _s(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; ct(a, f); dt(f); l = i; return; } } function at(a) { a = a | 0; return 536870911; } function bt(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function ct(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function dt(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function et(a) { a = a | 0; ht(a); return; } function ft(a) { a = a | 0; gt(a + 24 | 0); return; } function gt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function ht(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 16, b, it() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function it() { return 1400; } function jt(a) { a = a | 0; return lt(c[(kt(a) | 0) >> 2] | 0) | 0; } function kt(a) { a = a | 0; return (c[(Xs() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function lt(a) { a = a | 0; return mt(Ab[a & 7]() | 0) | 0; } function mt(a) { a = a | 0; return a | 0; } function nt() { var b = 0; if (!(a[7880] | 0)) { ut(10280); Ha(25, 10280, o | 0); b = 7880; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10280; } function ot(a, b) { a = a | 0; b = b | 0; c[a >> 2] = pt() | 0; c[a + 4 >> 2] = qt() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = rt() | 0; c[a + 32 >> 2] = 4; return; } function pt() { return 11711; } function qt() { return 1356; } function rt() { return lr() | 0; } function st(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { tt(c); sC(c); } } else if (b | 0) { mf(b); sC(b); } return; } function tt(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function ut(a) { a = a | 0; Zi(a); return; } function vt(a) { a = a | 0; wt(a, 4920); xt(a); yt(a); return; } function wt(a, b) { a = a | 0; b = b | 0; var d = 0; d = nn() | 0; c[a >> 2] = d; Yt(d, b); Hv(c[a >> 2] | 0); return; } function xt(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Mt() | 0); return a | 0; } function yt(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, zt() | 0); return a | 0; } function zt() { var b = 0; if (!(a[7888] | 0)) { Bt(10328); Ha(53, 10328, o | 0); b = 7888; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10328) | 0)) Bt(10328); return 10328; } function At(a, b) { a = a | 0; b = b | 0; fi(a, 0, b, 0, 0, 0); return; } function Bt(a) { a = a | 0; Et(a); Gt(a, 10); return; } function Ct(a) { a = a | 0; Dt(a + 24 | 0); return; } function Dt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Et(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 1, b, Jt() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Ft(a, b, c) { a = a | 0; b = b | 0; c = +c; Ht(a, b, c); return; } function Gt(a, b) { a = a | 0; b = b | 0; c[a + 20 >> 2] = b; return; } function Ht(a, b, d) { a = a | 0; b = b | 0; d = +d; var e = 0, f = 0, g = 0, i = 0, j = 0; e = l; l = l + 16 | 0; g = e + 8 | 0; j = e + 13 | 0; f = e; i = e + 12 | 0; tj(j, b); c[g >> 2] = uj(j, b) | 0; rj(i, d); h[f >> 3] = +sj(i, d); It(a, g, f); l = e; return; } function It(b, d, e) { b = b | 0; d = d | 0; e = e | 0; mg(b + 8 | 0, c[d >> 2] | 0, +h[e >> 3]); a[b + 24 >> 0] = 1; return; } function Jt() { return 1404; } function Kt(a, b) { a = a | 0; b = +b; return Lt(a, b) | 0; } function Lt(a, b) { a = a | 0; b = +b; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = l + 16 | 0; g = e + 4 | 0; h = e + 8 | 0; i = e; f = jy(8) | 0; d = f; j = qC(16) | 0; tj(g, a); a = uj(g, a) | 0; rj(h, b); mg(j, a, +sj(h, b)); h = d + 4 | 0; c[h >> 2] = j; a = qC(8) | 0; h = c[h >> 2] | 0; c[i >> 2] = 0; c[g >> 2] = c[i >> 2]; qn(a, h, g); c[f >> 2] = a; l = e; return d | 0; } function Mt() { var b = 0; if (!(a[7896] | 0)) { Nt(10364); Ha(54, 10364, o | 0); b = 7896; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10364) | 0)) Nt(10364); return 10364; } function Nt(a) { a = a | 0; Qt(a); Gt(a, 55); return; } function Ot(a) { a = a | 0; Pt(a + 24 | 0); return; } function Pt(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Qt(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 4, b, Vt() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Rt(a) { a = a | 0; St(a); return; } function St(a) { a = a | 0; Tt(a); return; } function Tt(b) { b = b | 0; Ut(b + 8 | 0); a[b + 24 >> 0] = 1; return; } function Ut(a) { a = a | 0; c[a >> 2] = 0; h[a + 8 >> 3] = 0.0; return; } function Vt() { return 1424; } function Wt() { return Xt() | 0; } function Xt() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = l + 16 | 0; f = b + 4 | 0; h = b; d = jy(8) | 0; a = d; e = qC(16) | 0; Ut(e); g = a + 4 | 0; c[g >> 2] = e; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; qn(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function Yt(a, b) { a = a | 0; b = b | 0; c[a >> 2] = Zt() | 0; c[a + 4 >> 2] = _t() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = $t() | 0; c[a + 32 >> 2] = 5; return; } function Zt() { return 11710; } function _t() { return 1416; } function $t() { return cu() | 0; } function au(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { bu(c); sC(c); } } else if (b | 0) sC(b); return; } function bu(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function cu() { var b = 0; if (!(a[7904] | 0)) { c[2600] = du() | 0; c[2601] = 0; b = 7904; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10400; } function du() { return c[357] | 0; } function eu(a) { a = a | 0; fu(a, 4926); gu(a); return; } function fu(a, b) { a = a | 0; b = b | 0; var d = 0; d = Ci() | 0; c[a >> 2] = d; su(d, b); Hv(c[a >> 2] | 0); return; } function gu(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, hu() | 0); return a | 0; } function hu() { var b = 0; if (!(a[7912] | 0)) { iu(10412); Ha(56, 10412, o | 0); b = 7912; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10412) | 0)) iu(10412); return 10412; } function iu(a) { a = a | 0; lu(a); Gt(a, 57); return; } function ju(a) { a = a | 0; ku(a + 24 | 0); return; } function ku(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function lu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 5, b, pu() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function mu(a) { a = a | 0; nu(a); return; } function nu(a) { a = a | 0; ou(a); return; } function ou(b) { b = b | 0; var d = 0, e = 0; d = b + 8 | 0; e = d + 48 | 0; do { c[d >> 2] = 0; d = d + 4 | 0; }while ((d | 0) < (e | 0)) a[b + 56 >> 0] = 1; return; } function pu() { return 1432; } function qu() { return ru() | 0; } function ru() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; h = l; l = l + 16 | 0; a = h + 4 | 0; b = h; d = jy(8) | 0; e = d; f = qC(48) | 0; g = f; i = g + 48 | 0; do { c[g >> 2] = 0; g = g + 4 | 0; }while ((g | 0) < (i | 0)) g = e + 4 | 0; c[g >> 2] = f; i = qC(8) | 0; g = c[g >> 2] | 0; c[b >> 2] = 0; c[a >> 2] = c[b >> 2]; Ji(i, g, a); c[d >> 2] = i; l = h; return e | 0; } function su(a, b) { a = a | 0; b = b | 0; c[a >> 2] = tu() | 0; c[a + 4 >> 2] = uu() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = vu() | 0; c[a + 32 >> 2] = 6; return; } function tu() { return 11704; } function uu() { return 1436; } function vu() { return cu() | 0; } function wu(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { xu(c); sC(c); } } else if (b | 0) sC(b); return; } function xu(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function yu(a) { a = a | 0; zu(a, 4933); Au(a); Bu(a); return; } function zu(a, b) { a = a | 0; b = b | 0; var d = 0; d = cv() | 0; c[a >> 2] = d; dv(d, b); Hv(c[a >> 2] | 0); return; } function Au(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Su() | 0); return a | 0; } function Bu(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Cu() | 0); return a | 0; } function Cu() { var b = 0; if (!(a[7920] | 0)) { Du(10452); Ha(58, 10452, o | 0); b = 7920; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10452) | 0)) Du(10452); return 10452; } function Du(a) { a = a | 0; Gu(a); Gt(a, 1); return; } function Eu(a) { a = a | 0; Fu(a + 24 | 0); return; } function Fu(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Gu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 1, b, Lu() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Hu(a, b, c) { a = a | 0; b = +b; c = +c; Iu(a, b, c); return; } function Iu(a, b, c) { a = a | 0; b = +b; c = +c; var d = 0, e = 0, f = 0, g = 0, i = 0; d = l; l = l + 32 | 0; f = d + 8 | 0; i = d + 17 | 0; e = d; g = d + 16 | 0; rj(i, b); h[f >> 3] = +sj(i, b); rj(g, c); h[e >> 3] = +sj(g, c); Ju(a, f, e); l = d; return; } function Ju(b, c, d) { b = b | 0; c = c | 0; d = d | 0; Ku(b + 8 | 0, +h[c >> 3], +h[d >> 3]); a[b + 24 >> 0] = 1; return; } function Ku(a, b, c) { a = a | 0; b = +b; c = +c; h[a >> 3] = b; h[a + 8 >> 3] = c; return; } function Lu() { return 1472; } function Mu(a, b) { a = +a; b = +b; return Nu(a, b) | 0; } function Nu(a, b) { a = +a; b = +b; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = l + 16 | 0; h = e + 4 | 0; i = e + 8 | 0; j = e; f = jy(8) | 0; d = f; g = qC(16) | 0; rj(h, a); a = +sj(h, a); rj(i, b); Ku(g, a, +sj(i, b)); i = d + 4 | 0; c[i >> 2] = g; g = qC(8) | 0; i = c[i >> 2] | 0; c[j >> 2] = 0; c[h >> 2] = c[j >> 2]; Ou(g, i, h); c[f >> 2] = g; l = e; return d | 0; } function Ou(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[d + 4 >> 2] = 0; c[d + 8 >> 2] = 0; c[d >> 2] = 1452; c[d + 12 >> 2] = b; c[a + 4 >> 2] = d; return; } function Pu(a) { a = a | 0; kC(a); sC(a); return; } function Qu(a) { a = a | 0; a = c[a + 12 >> 2] | 0; if (a | 0) sC(a); return; } function Ru(a) { a = a | 0; sC(a); return; } function Su() { var b = 0; if (!(a[7928] | 0)) { Tu(10488); Ha(59, 10488, o | 0); b = 7928; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10488) | 0)) Tu(10488); return 10488; } function Tu(a) { a = a | 0; Wu(a); Gt(a, 60); return; } function Uu(a) { a = a | 0; Vu(a + 24 | 0); return; } function Vu(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Wu(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 6, b, $u() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Xu(a) { a = a | 0; Yu(a); return; } function Yu(a) { a = a | 0; Zu(a); return; } function Zu(b) { b = b | 0; _u(b + 8 | 0); a[b + 24 >> 0] = 1; return; } function _u(a) { a = a | 0; c[a >> 2] = 0; c[a + 4 >> 2] = 0; c[a + 8 >> 2] = 0; c[a + 12 >> 2] = 0; return; } function $u() { return 1492; } function av() { return bv() | 0; } function bv() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = l + 16 | 0; f = b + 4 | 0; h = b; d = jy(8) | 0; a = d; e = qC(16) | 0; _u(e); g = a + 4 | 0; c[g >> 2] = e; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Ou(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function cv() { var b = 0; if (!(a[7936] | 0)) { jv(10524); Ha(25, 10524, o | 0); b = 7936; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10524; } function dv(a, b) { a = a | 0; b = b | 0; c[a >> 2] = ev() | 0; c[a + 4 >> 2] = fv() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = gv() | 0; c[a + 32 >> 2] = 7; return; } function ev() { return 11700; } function fv() { return 1484; } function gv() { return cu() | 0; } function hv(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { iv(c); sC(c); } } else if (b | 0) sC(b); return; } function iv(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function jv(a) { a = a | 0; Zi(a); return; } function kv(a, b, c) { a = a | 0; b = b | 0; c = c | 0; a = ai(b) | 0; b = lv(c) | 0; c = mv(c, 0) | 0; Zv(a, b, c, nv() | 0, 0); return; } function lv(a) { a = a | 0; return a | 0; } function mv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = nv() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { vv(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { wv(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function nv() { var b = 0, d = 0; if (!(a[7944] | 0)) { ov(10568); Ha(61, 10568, o | 0); d = 7944; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10568) | 0)) { b = 10568; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) ov(10568); } return 10568; } function ov(a) { a = a | 0; rv(a); return; } function pv(a) { a = a | 0; qv(a + 24 | 0); return; } function qv(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function rv(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 17, b, ql() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function sv(a) { a = a | 0; return uv(c[(tv(a) | 0) >> 2] | 0) | 0; } function tv(a) { a = a | 0; return (c[(nv() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function uv(a) { a = a | 0; return ul(Ab[a & 7]() | 0) | 0; } function vv(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function wv(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = xv(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; yv(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; vv(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; zv(a, f); Av(f); l = i; return; } } function xv(a) { a = a | 0; return 536870911; } function yv(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function zv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Av(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Bv() { Cv(); return; } function Cv() { Dv(10604); return; } function Dv(a) { a = a | 0; Ev(a, 4955); return; } function Ev(a, b) { a = a | 0; b = b | 0; var d = 0; d = Fv() | 0; c[a >> 2] = d; Gv(d, b); Hv(c[a >> 2] | 0); return; } function Fv() { var b = 0; if (!(a[7952] | 0)) { Rv(10612); Ha(25, 10612, o | 0); b = 7952; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10612; } function Gv(a, b) { a = a | 0; b = b | 0; c[a >> 2] = Mv() | 0; c[a + 4 >> 2] = Nv() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = Ov() | 0; c[a + 32 >> 2] = 8; return; } function Hv(a) { a = a | 0; var b = 0, d = 0; b = l; l = l + 16 | 0; d = b; Iv(); c[d >> 2] = a; Jv(10608, d); l = b; return; } function Iv() { if (!(a[11714] | 0)) { c[2652] = 0; Ha(62, 10608, o | 0); a[11714] = 1; } return 10608; } function Jv(a, b) { a = a | 0; b = b | 0; var d = 0; d = qC(8) | 0; c[d + 4 >> 2] = c[b >> 2]; c[d >> 2] = c[a >> 2]; c[a >> 2] = d; return; } function Kv(a) { a = a | 0; Lv(a); return; } function Lv(a) { a = a | 0; var b = 0, d = 0; b = c[a >> 2] | 0; if (b | 0) do { d = b; b = c[b >> 2] | 0; sC(d); }while ((b | 0) != 0) c[a >> 2] = 0; return; } function Mv() { return 11715; } function Nv() { return 1496; } function Ov() { return lr() | 0; } function Pv(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { Qv(c); sC(c); } } else if (b | 0) sC(b); return; } function Qv(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function Rv(a) { a = a | 0; Zi(a); return; } function Sv(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; Iv(); d = c[2652] | 0; a: do if (d | 0) { while(true){ e = c[d + 4 >> 2] | 0; if (e | 0 ? (AB(Tv(e) | 0, a) | 0) == 0 : 0) break; d = c[d >> 2] | 0; if (!d) break a; } Uv(e, b); } while (0) return; } function Tv(a) { a = a | 0; return c[a + 12 >> 2] | 0; } function Uv(a, b) { a = a | 0; b = b | 0; var d = 0; a = a + 36 | 0; d = c[a >> 2] | 0; if (d | 0) { vf(d); sC(d); } d = qC(4) | 0; Og(d, b); c[a >> 2] = d; return; } function Vv() { if (!(a[11716] | 0)) { c[2664] = 0; Ha(63, 10656, o | 0); a[11716] = 1; } return 10656; } function Wv() { var b = 0; if (!(a[11717] | 0)) { Xv(); c[2665] = 1504; a[11717] = 1; b = 1504; } else b = c[2665] | 0; return b | 0; } function Xv() { if (!(a[11740] | 0)) { a[11718] = ji(ji(8, 0) | 0, 0) | 0; a[11719] = ji(ji(0, 0) | 0, 0) | 0; a[11720] = ji(ji(0, 16) | 0, 0) | 0; a[11721] = ji(ji(8, 0) | 0, 0) | 0; a[11722] = ji(ji(0, 0) | 0, 0) | 0; a[11723] = ji(ji(8, 0) | 0, 0) | 0; a[11724] = ji(ji(0, 0) | 0, 0) | 0; a[11725] = ji(ji(8, 0) | 0, 0) | 0; a[11726] = ji(ji(0, 0) | 0, 0) | 0; a[11727] = ji(ji(8, 0) | 0, 0) | 0; a[11728] = ji(ji(0, 0) | 0, 0) | 0; a[11729] = ji(ji(0, 0) | 0, 32) | 0; a[11730] = ji(ji(0, 0) | 0, 32) | 0; a[11740] = 1; } return; } function Yv() { return 1572; } function Zv(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; g = l; l = l + 32 | 0; m = g + 16 | 0; k = g + 12 | 0; j = g + 8 | 0; i = g + 4 | 0; h = g; c[m >> 2] = a; c[k >> 2] = b; c[j >> 2] = d; c[i >> 2] = e; c[h >> 2] = f; Vv(); _v(10656, m, k, j, i, h); l = g; return; } function _v(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0; h = qC(24) | 0; ii(h + 4 | 0, c[b >> 2] | 0, c[d >> 2] | 0, c[e >> 2] | 0, c[f >> 2] | 0, c[g >> 2] | 0); c[h >> 2] = c[a >> 2]; c[a >> 2] = h; return; } function $v(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0; u = l; l = l + 32 | 0; q = u + 20 | 0; r = u + 8 | 0; s = u + 4 | 0; t = u; b = c[b >> 2] | 0; if (b | 0) { p = q + 4 | 0; j = q + 8 | 0; k = r + 4 | 0; m = r + 8 | 0; n = r + 8 | 0; o = q + 8 | 0; do { h = b + 4 | 0; i = aw(h) | 0; if (i | 0) { f = bw(i) | 0; c[q >> 2] = 0; c[p >> 2] = 0; c[j >> 2] = 0; e = (cw(i) | 0) + 1 | 0; dw(q, e); if (e | 0) while(true){ e = e + -1 | 0; OA(r, c[f >> 2] | 0); g = c[p >> 2] | 0; if (g >>> 0 < (c[o >> 2] | 0) >>> 0) { c[g >> 2] = c[r >> 2]; c[p >> 2] = (c[p >> 2] | 0) + 4; } else ew(q, r); if (!e) break; else f = f + 4 | 0; } e = fw(i) | 0; c[r >> 2] = 0; c[k >> 2] = 0; c[m >> 2] = 0; a: if (c[e >> 2] | 0) { f = 0; g = 0; while(true){ if ((f | 0) == (g | 0)) gw(r, e); else { c[f >> 2] = c[e >> 2]; c[k >> 2] = (c[k >> 2] | 0) + 4; } e = e + 4 | 0; if (!(c[e >> 2] | 0)) break a; f = c[k >> 2] | 0; g = c[n >> 2] | 0; } } c[s >> 2] = hw(h) | 0; c[t >> 2] = si(i) | 0; iw(d, a, s, t, q, r); jw(r); kw(q); } b = c[b >> 2] | 0; }while ((b | 0) != 0) } l = u; return; } function aw(a) { a = a | 0; return c[a + 12 >> 2] | 0; } function bw(a) { a = a | 0; return c[a + 12 >> 2] | 0; } function cw(a) { a = a | 0; return c[a + 16 >> 2] | 0; } function dw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 32 | 0; d = f; e = c[a >> 2] | 0; if ((c[a + 8 >> 2] | 0) - e >> 2 >>> 0 < b >>> 0) { Rw(d, b, (c[a + 4 >> 2] | 0) - e >> 2, a + 8 | 0); Sw(a, d); Tw(d); } l = f; return; } function ew(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; h = l; l = l + 32 | 0; d = h; e = a + 4 | 0; f = ((c[e >> 2] | 0) - (c[a >> 2] | 0) >> 2) + 1 | 0; g = Nw(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { i = c[a >> 2] | 0; k = (c[a + 8 >> 2] | 0) - i | 0; j = k >> 1; Rw(d, k >> 2 >>> 0 < g >>> 1 >>> 0 ? j >>> 0 < f >>> 0 ? f : j : g, (c[e >> 2] | 0) - i >> 2, a + 8 | 0); g = d + 8 | 0; c[c[g >> 2] >> 2] = c[b >> 2]; c[g >> 2] = (c[g >> 2] | 0) + 4; Sw(a, d); Tw(d); l = h; return; } } function fw(a) { a = a | 0; return c[a + 8 >> 2] | 0; } function gw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0; h = l; l = l + 32 | 0; d = h; e = a + 4 | 0; f = ((c[e >> 2] | 0) - (c[a >> 2] | 0) >> 2) + 1 | 0; g = Kw(a) | 0; if (g >>> 0 < f >>> 0) jC(a); else { i = c[a >> 2] | 0; k = (c[a + 8 >> 2] | 0) - i | 0; j = k >> 1; Ow(d, k >> 2 >>> 0 < g >>> 1 >>> 0 ? j >>> 0 < f >>> 0 ? f : j : g, (c[e >> 2] | 0) - i >> 2, a + 8 | 0); g = d + 8 | 0; c[c[g >> 2] >> 2] = c[b >> 2]; c[g >> 2] = (c[g >> 2] | 0) + 4; Pw(a, d); Qw(d); l = h; return; } } function hw(a) { a = a | 0; return c[a >> 2] | 0; } function iw(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; lw(a, b, c, d, e, f); return; } function jw(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -4 - e | 0) >>> 2) << 2); sC(d); } return; } function kw(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -4 - e | 0) >>> 2) << 2); sC(d); } return; } function lw(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; h = l; l = l + 48 | 0; m = h + 40 | 0; i = h + 32 | 0; n = h + 24 | 0; j = h + 12 | 0; k = h; UA(i); a = Sg(a) | 0; c[n >> 2] = c[b >> 2]; d = c[d >> 2] | 0; e = c[e >> 2] | 0; mw(j, f); nw(k, g); c[m >> 2] = c[n >> 2]; ow(a, m, d, e, j, k); jw(k); kw(j); WA(i); l = h; return; } function mw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[a + 4 >> 2] = 0; c[a + 8 >> 2] = 0; d = b + 4 | 0; e = (c[d >> 2] | 0) - (c[b >> 2] | 0) >> 2; if (e | 0) { Lw(a, e); Mw(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function nw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; c[a >> 2] = 0; c[a + 4 >> 2] = 0; c[a + 8 >> 2] = 0; d = b + 4 | 0; e = (c[d >> 2] | 0) - (c[b >> 2] | 0) >> 2; if (e | 0) { Iw(a, e); Jw(a, c[b >> 2] | 0, c[d >> 2] | 0, e); } return; } function ow(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0, n = 0; h = l; l = l + 32 | 0; m = h + 28 | 0; n = h + 24 | 0; i = h + 12 | 0; j = h; k = Vg(pw() | 0) | 0; c[n >> 2] = c[b >> 2]; c[m >> 2] = c[n >> 2]; b = qw(m) | 0; d = rw(d) | 0; e = sw(e) | 0; c[i >> 2] = c[f >> 2]; m = f + 4 | 0; c[i + 4 >> 2] = c[m >> 2]; n = f + 8 | 0; c[i + 8 >> 2] = c[n >> 2]; c[n >> 2] = 0; c[m >> 2] = 0; c[f >> 2] = 0; f = tw(i) | 0; c[j >> 2] = c[g >> 2]; m = g + 4 | 0; c[j + 4 >> 2] = c[m >> 2]; n = g + 8 | 0; c[j + 8 >> 2] = c[n >> 2]; c[n >> 2] = 0; c[m >> 2] = 0; c[g >> 2] = 0; Ba(0, k | 0, a | 0, b | 0, d | 0, e | 0, f | 0, uw(j) | 0); jw(j); kw(i); l = h; return; } function pw() { var b = 0; if (!(a[7968] | 0)) { Gw(10708); b = 7968; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10708; } function qw(a) { a = a | 0; return yw(a) | 0; } function rw(a) { a = a | 0; return ww(a) | 0; } function sw(a) { a = a | 0; return ul(a) | 0; } function tw(a) { a = a | 0; return xw(a) | 0; } function uw(a) { a = a | 0; return vw(a) | 0; } function vw(a) { a = a | 0; var b = 0, d = 0, e = 0; e = (c[a + 4 >> 2] | 0) - (c[a >> 2] | 0) | 0; d = e >> 2; e = jy(e + 4 | 0) | 0; c[e >> 2] = d; if (d | 0) { b = 0; do { c[e + 4 + (b << 2) >> 2] = ww(c[(c[a >> 2] | 0) + (b << 2) >> 2] | 0) | 0; b = b + 1 | 0; }while ((b | 0) != (d | 0)) } return e | 0; } function ww(a) { a = a | 0; return a | 0; } function xw(a) { a = a | 0; var b = 0, d = 0, e = 0; e = (c[a + 4 >> 2] | 0) - (c[a >> 2] | 0) | 0; d = e >> 2; e = jy(e + 4 | 0) | 0; c[e >> 2] = d; if (d | 0) { b = 0; do { c[e + 4 + (b << 2) >> 2] = yw((c[a >> 2] | 0) + (b << 2) | 0) | 0; b = b + 1 | 0; }while ((b | 0) != (d | 0)) } return e | 0; } function yw(a) { a = a | 0; var b = 0, c = 0, d = 0, e = 0; e = l; l = l + 32 | 0; b = e + 12 | 0; c = e; d = Di(zw() | 0) | 0; if (!d) a = Aw(a) | 0; else { Ei(b, d); Fi(c, b); RA(a, c); a = Hi(b) | 0; } l = e; return a | 0; } function zw() { var b = 0; if (!(a[7960] | 0)) { Fw(10664); Ha(25, 10664, o | 0); b = 7960; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10664; } function Aw(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = l + 16 | 0; f = d + 4 | 0; h = d; e = jy(8) | 0; b = e; i = qC(4) | 0; c[i >> 2] = c[a >> 2]; g = b + 4 | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Bw(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function Bw(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[d + 4 >> 2] = 0; c[d + 8 >> 2] = 0; c[d >> 2] = 1656; c[d + 12 >> 2] = b; c[a + 4 >> 2] = d; return; } function Cw(a) { a = a | 0; kC(a); sC(a); return; } function Dw(a) { a = a | 0; a = c[a + 12 >> 2] | 0; if (a | 0) sC(a); return; } function Ew(a) { a = a | 0; sC(a); return; } function Fw(a) { a = a | 0; Zi(a); return; } function Gw(a) { a = a | 0; fh(a, Hw() | 0, 5); return; } function Hw() { return 1676; } function Iw(a, b) { a = a | 0; b = b | 0; var d = 0; if ((Kw(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[a + 4 >> 2] = d; c[a >> 2] = d; c[a + 8 >> 2] = d + (b << 2); return; } } function Jw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = a + 4 | 0; a = d - b | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0); c[e >> 2] = (c[e >> 2] | 0) + (a >>> 2 << 2); } return; } function Kw(a) { a = a | 0; return 1073741823; } function Lw(a, b) { a = a | 0; b = b | 0; var d = 0; if ((Nw(a) | 0) >>> 0 < b >>> 0) jC(a); if (b >>> 0 > 1073741823) Ta(); else { d = qC(b << 2) | 0; c[a + 4 >> 2] = d; c[a >> 2] = d; c[a + 8 >> 2] = d + (b << 2); return; } } function Mw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; e = a + 4 | 0; a = d - b | 0; if ((a | 0) > 0) { BC(c[e >> 2] | 0, b | 0, a | 0); c[e >> 2] = (c[e >> 2] | 0) + (a >>> 2 << 2); } return; } function Nw(a) { a = a | 0; return 1073741823; } function Ow(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 2) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 2); return; } function Pw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 2) << 2) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Qw(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -4 - b | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Rw(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 1073741823) Ta(); else { f = qC(b << 2) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 2) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 2); return; } function Sw(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 2) << 2) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Tw(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -4 - b | 0) >>> 2) << 2); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Uw(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0; r = l; l = l + 32 | 0; m = r + 20 | 0; n = r + 12 | 0; k = r + 16 | 0; o = r + 4 | 0; p = r; q = r + 8 | 0; i = Wv() | 0; g = c[i >> 2] | 0; h = c[g >> 2] | 0; if (h | 0) { j = c[i + 8 >> 2] | 0; i = c[i + 4 >> 2] | 0; while(true){ OA(m, h); Vw(a, m, i, j); g = g + 4 | 0; h = c[g >> 2] | 0; if (!h) break; else { j = j + 1 | 0; i = i + 1 | 0; } } } g = Yv() | 0; h = c[g >> 2] | 0; if (h | 0) do { OA(m, h); c[n >> 2] = c[g + 4 >> 2]; Ww(b, m, n); g = g + 8 | 0; h = c[g >> 2] | 0; }while ((h | 0) != 0) g = c[(Iv() | 0) >> 2] | 0; if (g | 0) do { b = c[g + 4 >> 2] | 0; OA(m, c[(Xw(b) | 0) >> 2] | 0); c[n >> 2] = Tv(b) | 0; Yw(d, m, n); g = c[g >> 2] | 0; }while ((g | 0) != 0) OA(k, 0); g = Vv() | 0; c[m >> 2] = c[k >> 2]; $v(m, g, f); g = c[(Iv() | 0) >> 2] | 0; if (g | 0) { a = m + 4 | 0; b = m + 8 | 0; d = m + 8 | 0; do { j = c[g + 4 >> 2] | 0; OA(n, c[(Xw(j) | 0) >> 2] | 0); _w(o, Zw(j) | 0); h = c[o >> 2] | 0; if (h | 0) { c[m >> 2] = 0; c[a >> 2] = 0; c[b >> 2] = 0; do { OA(p, c[(Xw(c[h + 4 >> 2] | 0) | 0) >> 2] | 0); i = c[a >> 2] | 0; if (i >>> 0 < (c[d >> 2] | 0) >>> 0) { c[i >> 2] = c[p >> 2]; c[a >> 2] = (c[a >> 2] | 0) + 4; } else ew(m, p); h = c[h >> 2] | 0; }while ((h | 0) != 0) $w(e, n, m); kw(m); } c[q >> 2] = c[n >> 2]; k = ax(j) | 0; c[m >> 2] = c[q >> 2]; $v(m, k, f); Wi(o); g = c[g >> 2] | 0; }while ((g | 0) != 0) } l = r; return; } function Vw(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; ox(a, b, c, d); return; } function Ww(a, b, c) { a = a | 0; b = b | 0; c = c | 0; nx(a, b, c); return; } function Xw(a) { a = a | 0; return a | 0; } function Yw(a, b, c) { a = a | 0; b = b | 0; c = c | 0; ix(a, b, c); return; } function Zw(a) { a = a | 0; return a + 16 | 0; } function _w(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; g = l; l = l + 16 | 0; f = g + 8 | 0; d = g; c[a >> 2] = 0; e = c[b >> 2] | 0; c[f >> 2] = e; c[d >> 2] = a; d = gx(d) | 0; if (e | 0) { e = qC(12) | 0; h = (hx(f) | 0) + 4 | 0; a = c[h + 4 >> 2] | 0; b = e + 4 | 0; c[b >> 2] = c[h >> 2]; c[b + 4 >> 2] = a; b = c[c[f >> 2] >> 2] | 0; c[f >> 2] = b; if (!b) a = e; else { b = e; while(true){ a = qC(12) | 0; j = (hx(f) | 0) + 4 | 0; i = c[j + 4 >> 2] | 0; h = a + 4 | 0; c[h >> 2] = c[j >> 2]; c[h + 4 >> 2] = i; c[b >> 2] = a; h = c[c[f >> 2] >> 2] | 0; c[f >> 2] = h; if (!h) break; else b = a; } } c[a >> 2] = c[d >> 2]; c[d >> 2] = e; } l = g; return; } function $w(a, b, c) { a = a | 0; b = b | 0; c = c | 0; bx(a, b, c); return; } function ax(a) { a = a | 0; return a + 24 | 0; } function bx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 32 | 0; h = e + 24 | 0; f = e + 16 | 0; i = e + 12 | 0; g = e; UA(f); a = Sg(a) | 0; c[i >> 2] = c[b >> 2]; mw(g, d); c[h >> 2] = c[i >> 2]; cx(a, h, g); kw(g); WA(f); l = e; return; } function cx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0; e = l; l = l + 32 | 0; h = e + 16 | 0; i = e + 12 | 0; f = e; g = Vg(dx() | 0) | 0; c[i >> 2] = c[b >> 2]; c[h >> 2] = c[i >> 2]; b = qw(h) | 0; c[f >> 2] = c[d >> 2]; h = d + 4 | 0; c[f + 4 >> 2] = c[h >> 2]; i = d + 8 | 0; c[f + 8 >> 2] = c[i >> 2]; c[i >> 2] = 0; c[h >> 2] = 0; c[d >> 2] = 0; xa(0, g | 0, a | 0, b | 0, tw(f) | 0); kw(f); l = e; return; } function dx() { var b = 0; if (!(a[7976] | 0)) { ex(10720); b = 7976; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10720; } function ex(a) { a = a | 0; fh(a, fx() | 0, 2); return; } function fx() { return 1732; } function gx(a) { a = a | 0; return c[a >> 2] | 0; } function hx(a) { a = a | 0; return c[a >> 2] | 0; } function ix(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 32 | 0; g = e + 16 | 0; f = e + 8 | 0; h = e; UA(f); a = Sg(a) | 0; c[h >> 2] = c[b >> 2]; d = c[d >> 2] | 0; c[g >> 2] = c[h >> 2]; jx(a, g, d); WA(f); l = e; return; } function jx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 16 | 0; g = e + 4 | 0; h = e; f = Vg(kx() | 0) | 0; c[h >> 2] = c[b >> 2]; c[g >> 2] = c[h >> 2]; b = qw(g) | 0; xa(0, f | 0, a | 0, b | 0, rw(d) | 0); l = e; return; } function kx() { var b = 0; if (!(a[7984] | 0)) { lx(10732); b = 7984; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10732; } function lx(a) { a = a | 0; fh(a, mx() | 0, 2); return; } function mx() { return 1744; } function nx(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0; e = l; l = l + 32 | 0; g = e + 16 | 0; f = e + 8 | 0; h = e; UA(f); a = Sg(a) | 0; c[h >> 2] = c[b >> 2]; d = c[d >> 2] | 0; c[g >> 2] = c[h >> 2]; jx(a, g, d); WA(f); l = e; return; } function ox(b, d, e, f) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = l + 32 | 0; i = g + 16 | 0; h = g + 8 | 0; j = g; UA(h); b = Sg(b) | 0; c[j >> 2] = c[d >> 2]; e = a[e >> 0] | 0; f = a[f >> 0] | 0; c[i >> 2] = c[j >> 2]; px(b, i, e, f); WA(h); l = g; return; } function px(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; h = f + 4 | 0; i = f; g = Vg(qx() | 0) | 0; c[i >> 2] = c[b >> 2]; c[h >> 2] = c[i >> 2]; b = qw(h) | 0; d = rx(d) | 0; $a(0, g | 0, a | 0, b | 0, d | 0, rx(e) | 0); l = f; return; } function qx() { var b = 0; if (!(a[7992] | 0)) { tx(10744); b = 7992; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10744; } function rx(a) { a = a | 0; return sx(a) | 0; } function sx(a) { a = a | 0; return a & 255 | 0; } function tx(a) { a = a | 0; fh(a, ux() | 0, 3); return; } function ux() { return 1756; } function vx(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; p = l; l = l + 32 | 0; j = p + 8 | 0; k = p + 4 | 0; m = p + 20 | 0; n = p; mk(b, 0); f = QA(d) | 0; c[j >> 2] = 0; o = j + 4 | 0; c[o >> 2] = 0; c[j + 8 >> 2] = 0; switch(f << 24 >> 24){ case 0: a[m >> 0] = 0; wx(k, e, m); xx(b, k); wf(k); break; case 8: o = PA(d) | 0; a[m >> 0] = 8; OA(n, c[o + 4 >> 2] | 0); yx(k, e, m, n, o + 8 | 0); xx(b, k); wf(k); break; case 9: h = PA(d) | 0; d = c[h + 4 >> 2] | 0; if (d | 0) { i = j + 8 | 0; g = h + 12 | 0; while(true){ d = d + -1 | 0; OA(k, c[g >> 2] | 0); f = c[o >> 2] | 0; if (f >>> 0 < (c[i >> 2] | 0) >>> 0) { c[f >> 2] = c[k >> 2]; c[o >> 2] = (c[o >> 2] | 0) + 4; } else ew(j, k); if (!d) break; else g = g + 4 | 0; } } a[m >> 0] = 9; OA(n, c[h + 8 >> 2] | 0); zx(k, e, m, n, j); xx(b, k); wf(k); break; default: o = PA(d) | 0; a[m >> 0] = f; OA(n, c[o + 4 >> 2] | 0); Ax(k, e, m, n); xx(b, k); wf(k); } kw(j); l = p; return; } function wx(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0, f = 0; e = l; l = l + 16 | 0; f = e; UA(f); c = Sg(c) | 0; Ox(b, c, a[d >> 0] | 0); WA(f); l = e; return; } function xx(a, b) { a = a | 0; b = b | 0; var d = 0; d = c[a >> 2] | 0; if (d | 0) ab(d | 0); c[a >> 2] = c[b >> 2]; c[b >> 2] = 0; return a | 0; } function yx(b, d, e, f, g) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0; h = l; l = l + 32 | 0; j = h + 16 | 0; i = h + 8 | 0; k = h; UA(i); d = Sg(d) | 0; e = a[e >> 0] | 0; c[k >> 2] = c[f >> 2]; g = c[g >> 2] | 0; c[j >> 2] = c[k >> 2]; Kx(b, d, e, j, g); WA(i); l = h; return; } function zx(b, d, e, f, g) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; var h = 0, i = 0, j = 0, k = 0, m = 0; h = l; l = l + 32 | 0; k = h + 24 | 0; i = h + 16 | 0; m = h + 12 | 0; j = h; UA(i); d = Sg(d) | 0; e = a[e >> 0] | 0; c[m >> 2] = c[f >> 2]; mw(j, g); c[k >> 2] = c[m >> 2]; Gx(b, d, e, k, j); kw(j); WA(i); l = h; return; } function Ax(b, d, e, f) { b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = l + 32 | 0; i = g + 16 | 0; h = g + 8 | 0; j = g; UA(h); d = Sg(d) | 0; e = a[e >> 0] | 0; c[j >> 2] = c[f >> 2]; c[i >> 2] = c[j >> 2]; Bx(b, d, e, i); WA(h); l = g; return; } function Bx(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; f = l; l = l + 16 | 0; g = f + 4 | 0; i = f; h = Vg(Cx() | 0) | 0; d = rx(d) | 0; c[i >> 2] = c[e >> 2]; c[g >> 2] = c[i >> 2]; Dx(a, xa(0, h | 0, b | 0, d | 0, qw(g) | 0) | 0); l = f; return; } function Cx() { var b = 0; if (!(a[8e3] | 0)) { Ex(10756); b = 8e3; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10756; } function Dx(a, b) { a = a | 0; b = b | 0; mk(a, b); return; } function Ex(a) { a = a | 0; fh(a, Fx() | 0, 2); return; } function Fx() { return 1772; } function Gx(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0; g = l; l = l + 32 | 0; j = g + 16 | 0; k = g + 12 | 0; h = g; i = Vg(Hx() | 0) | 0; d = rx(d) | 0; c[k >> 2] = c[e >> 2]; c[j >> 2] = c[k >> 2]; e = qw(j) | 0; c[h >> 2] = c[f >> 2]; j = f + 4 | 0; c[h + 4 >> 2] = c[j >> 2]; k = f + 8 | 0; c[h + 8 >> 2] = c[k >> 2]; c[k >> 2] = 0; c[j >> 2] = 0; c[f >> 2] = 0; Dx(a, $a(0, i | 0, b | 0, d | 0, e | 0, tw(h) | 0) | 0); kw(h); l = g; return; } function Hx() { var b = 0; if (!(a[8008] | 0)) { Ix(10768); b = 8008; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10768; } function Ix(a) { a = a | 0; fh(a, Jx() | 0, 3); return; } function Jx() { return 1784; } function Kx(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0; g = l; l = l + 16 | 0; i = g + 4 | 0; j = g; h = Vg(Lx() | 0) | 0; d = rx(d) | 0; c[j >> 2] = c[e >> 2]; c[i >> 2] = c[j >> 2]; e = qw(i) | 0; Dx(a, $a(0, h | 0, b | 0, d | 0, e | 0, sw(f) | 0) | 0); l = g; return; } function Lx() { var b = 0; if (!(a[8016] | 0)) { Mx(10780); b = 8016; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10780; } function Mx(a) { a = a | 0; fh(a, Nx() | 0, 3); return; } function Nx() { return 1800; } function Ox(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0; d = Vg(Px() | 0) | 0; Dx(a, bb(0, d | 0, b | 0, rx(c) | 0) | 0); return; } function Px() { var b = 0; if (!(a[8024] | 0)) { Qx(10792); b = 8024; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 10792; } function Qx(a) { a = a | 0; fh(a, Rx() | 0, 1); return; } function Rx() { return 1816; } function Sx() { Tx(); Ux(); Vx(); return; } function Tx() { c[2702] = rC(65536) | 0; return; } function Ux() { qy(10856); return; } function Vx() { Wx(10816); return; } function Wx(a) { a = a | 0; Xx(a, 5044); Yx(a); return; } function Xx(a, b) { a = a | 0; b = b | 0; var d = 0; d = zw() | 0; c[a >> 2] = d; ky(d, b); Hv(c[a >> 2] | 0); return; } function Yx(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, Zx() | 0); return a | 0; } function Zx() { var b = 0; if (!(a[8032] | 0)) { _x(10820); Ha(64, 10820, o | 0); b = 8032; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(10820) | 0)) _x(10820); return 10820; } function _x(a) { a = a | 0; by(a); Gt(a, 25); return; } function $x(a) { a = a | 0; ay(a + 24 | 0); return; } function ay(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function by(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 18, b, gy() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function cy(a, b) { a = a | 0; b = b | 0; dy(a, b); return; } function dy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; d = l; l = l + 16 | 0; e = d; f = d + 4 | 0; Gk(f, b); c[e >> 2] = Hk(f, b) | 0; ey(a, e); l = d; return; } function ey(b, d) { b = b | 0; d = d | 0; fy(b + 4 | 0, c[d >> 2] | 0); a[b + 8 >> 0] = 1; return; } function fy(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function gy() { return 1824; } function hy(a) { a = a | 0; return iy(a) | 0; } function iy(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; d = l; l = l + 16 | 0; f = d + 4 | 0; h = d; e = jy(8) | 0; b = e; i = qC(4) | 0; Gk(f, a); fy(i, Hk(f, a) | 0); g = b + 4 | 0; c[g >> 2] = i; a = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; Bw(a, g, f); c[e >> 2] = a; l = d; return b | 0; } function jy(a) { a = a | 0; var b = 0, d = 0; a = a + 7 & -8; if (a >>> 0 <= 32768 ? (b = c[2701] | 0, a >>> 0 <= (65536 - b | 0) >>> 0) : 0) { d = (c[2702] | 0) + b | 0; c[2701] = b + a; a = d; } else { a = rC(a + 8 | 0) | 0; c[a >> 2] = c[2703]; c[2703] = a; a = a + 8 | 0; } return a | 0; } function ky(a, b) { a = a | 0; b = b | 0; c[a >> 2] = ly() | 0; c[a + 4 >> 2] = my() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = ny() | 0; c[a + 32 >> 2] = 9; return; } function ly() { return 11744; } function my() { return 1832; } function ny() { return cu() | 0; } function oy(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { py(c); sC(c); } } else if (b | 0) sC(b); return; } function py(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function qy(a) { a = a | 0; ry(a, 5052); sy(a); ty(a, 5058, 26); uy(a, 5069, 1); vy(a, 5077, 10); wy(a, 5087, 19); yy(a, 5094, 27); return; } function ry(a, b) { a = a | 0; b = b | 0; var d = 0; d = GA() | 0; c[a >> 2] = d; HA(d, b); Hv(c[a >> 2] | 0); return; } function sy(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; At(b, rA() | 0); return a | 0; } function ty(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Yz(a, ai(b) | 0, c, 0); return a | 0; } function uy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Gz(a, ai(b) | 0, c, 0); return a | 0; } function vy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; hz(a, ai(b) | 0, c, 0); return a | 0; } function wy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Ry(a, ai(b) | 0, c, 0); return a | 0; } function xy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; a: while(true){ d = c[2703] | 0; while(true){ if ((d | 0) == (b | 0)) break a; e = c[d >> 2] | 0; c[2703] = e; if (!d) d = e; else break; } sC(d); } c[2701] = a; return; } function yy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; zy(a, ai(b) | 0, c, 0); return a | 0; } function zy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Ay() | 0; a = By(d) | 0; fi(g, b, f, a, Cy(d, e) | 0, e); return; } function Ay() { var b = 0, d = 0; if (!(a[8040] | 0)) { Jy(10860); Ha(65, 10860, o | 0); d = 8040; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10860) | 0)) { b = 10860; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Jy(10860); } return 10860; } function By(a) { a = a | 0; return a | 0; } function Cy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Ay() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { Dy(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { Ey(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function Dy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function Ey(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = Fy(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Gy(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; Dy(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Hy(a, f); Iy(f); l = i; return; } } function Fy(a) { a = a | 0; return 536870911; } function Gy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Hy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Iy(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Jy(a) { a = a | 0; My(a); return; } function Ky(a) { a = a | 0; Ly(a + 24 | 0); return; } function Ly(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function My(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 11, b, Ny() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Ny() { return 1840; } function Oy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; Qy(c[(Py(a) | 0) >> 2] | 0, b, d); return; } function Py(a) { a = a | 0; return (c[(Ay() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function Qy(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0, e = 0, f = 0; d = l; l = l + 16 | 0; f = d + 1 | 0; e = d; Gk(f, b); b = Hk(f, b) | 0; Gk(e, c); c = Hk(e, c) | 0; ob[a & 31](b, c); l = d; return; } function Ry(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Sy() | 0; a = Ty(d) | 0; fi(g, b, f, a, Uy(d, e) | 0, e); return; } function Sy() { var b = 0, d = 0; if (!(a[8048] | 0)) { $y(10896); Ha(66, 10896, o | 0); d = 8048; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10896) | 0)) { b = 10896; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) $y(10896); } return 10896; } function Ty(a) { a = a | 0; return a | 0; } function Uy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Sy() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { Vy(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { Wy(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function Vy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function Wy(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = Xy(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Yy(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; Vy(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Zy(a, f); _y(f); l = i; return; } } function Xy(a) { a = a | 0; return 536870911; } function Yy(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Zy(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function _y(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function $y(a) { a = a | 0; cz(a); return; } function az(a) { a = a | 0; bz(a + 24 | 0); return; } function bz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function cz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 11, b, dz() | 0, 1); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function dz() { return 1852; } function ez(a, b) { a = a | 0; b = b | 0; return gz(c[(fz(a) | 0) >> 2] | 0, b) | 0; } function fz(a) { a = a | 0; return (c[(Sy() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function gz(a, b) { a = a | 0; b = b | 0; var c = 0, d = 0; c = l; l = l + 16 | 0; d = c; Gk(d, b); b = Hk(d, b) | 0; b = ul(pb[a & 31](b) | 0) | 0; l = c; return b | 0; } function hz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = iz() | 0; a = jz(d) | 0; fi(g, b, f, a, kz(d, e) | 0, e); return; } function iz() { var b = 0, d = 0; if (!(a[8056] | 0)) { rz(10932); Ha(67, 10932, o | 0); d = 8056; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10932) | 0)) { b = 10932; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) rz(10932); } return 10932; } function jz(a) { a = a | 0; return a | 0; } function kz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = iz() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { lz(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { mz(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function lz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function mz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = nz(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; oz(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; lz(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; pz(a, f); qz(f); l = i; return; } } function nz(a) { a = a | 0; return 536870911; } function oz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function pz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function qz(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function rz(a) { a = a | 0; uz(a); return; } function sz(a) { a = a | 0; tz(a + 24 | 0); return; } function tz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function uz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 7, b, vz() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function vz() { return 1860; } function wz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; return yz(c[(xz(a) | 0) >> 2] | 0, b, d) | 0; } function xz(a) { a = a | 0; return (c[(iz() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function yz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; e = l; l = l + 32 | 0; h = e + 12 | 0; g = e + 8 | 0; i = e; j = e + 16 | 0; f = e + 4 | 0; zz(j, b); Az(i, j, b); ik(f, d); d = jk(f, d) | 0; c[h >> 2] = c[i >> 2]; Eb[a & 15](g, h, d); d = Bz(g) | 0; wf(g); kk(f); l = e; return d | 0; } function zz(a, b) { a = a | 0; b = b | 0; return; } function Az(a, b, c) { a = a | 0; b = b | 0; c = c | 0; Cz(a, c); return; } function Bz(a) { a = a | 0; return Sg(a) | 0; } function Cz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0; f = l; l = l + 16 | 0; d = f; e = b; if (!(e & 1)) c[a >> 2] = c[b >> 2]; else { Dz(d, 0); Ja(e | 0, d | 0); Ez(a, d); Fz(d); } l = f; return; } function Dz(b, d) { b = b | 0; d = d | 0; ah(b, d); c[b + 4 >> 2] = 0; a[b + 8 >> 0] = 0; return; } function Ez(a, b) { a = a | 0; b = b | 0; c[a >> 2] = c[b + 4 >> 2]; return; } function Fz(b) { b = b | 0; a[b + 8 >> 0] = 0; return; } function Gz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Hz() | 0; a = Iz(d) | 0; fi(g, b, f, a, Jz(d, e) | 0, e); return; } function Hz() { var b = 0, d = 0; if (!(a[8064] | 0)) { Qz(10968); Ha(68, 10968, o | 0); d = 8064; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(10968) | 0)) { b = 10968; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) Qz(10968); } return 10968; } function Iz(a) { a = a | 0; return a | 0; } function Jz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Hz() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { Kz(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { Lz(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function Kz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function Lz(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = Mz(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; Nz(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; Kz(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; Oz(a, f); Pz(f); l = i; return; } } function Mz(a) { a = a | 0; return 536870911; } function Nz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function Oz(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function Pz(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function Qz(a) { a = a | 0; Tz(a); return; } function Rz(a) { a = a | 0; Sz(a + 24 | 0); return; } function Sz(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function Tz(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 1, b, Uz() | 0, 5); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function Uz() { return 1872; } function Vz(a, b, d, e, f, g) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; Xz(c[(Wz(a) | 0) >> 2] | 0, b, d, e, f, g); return; } function Wz(a) { a = a | 0; return (c[(Hz() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function Xz(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; g = l; l = l + 32 | 0; h = g + 16 | 0; i = g + 12 | 0; j = g + 8 | 0; k = g + 4 | 0; m = g; ik(h, b); b = jk(h, b) | 0; ik(i, c); c = jk(i, c) | 0; ik(j, d); d = jk(j, d) | 0; ik(k, e); e = jk(k, e) | 0; ik(m, f); f = jk(m, f) | 0; jb[a & 1](b, c, d, e, f); kk(m); kk(k); kk(j); kk(i); kk(h); l = g; return; } function Yz(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = c[a >> 2] | 0; f = Zz() | 0; a = _z(d) | 0; fi(g, b, f, a, $z(d, e) | 0, e); return; } function Zz() { var b = 0, d = 0; if (!(a[8072] | 0)) { gA(11004); Ha(69, 11004, o | 0); d = 8072; c[d >> 2] = 1; c[d + 4 >> 2] = 0; } if (!(si(11004) | 0)) { b = 11004; d = b + 36 | 0; do { c[b >> 2] = 0; b = b + 4 | 0; }while ((b | 0) < (d | 0)) gA(11004); } return 11004; } function _z(a) { a = a | 0; return a | 0; } function $z(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; i = l; l = l + 16 | 0; f = i; g = i + 4 | 0; c[f >> 2] = a; j = Zz() | 0; h = j + 24 | 0; b = ji(b, 4) | 0; c[g >> 2] = b; d = j + 28 | 0; e = c[d >> 2] | 0; if (e >>> 0 < (c[j + 32 >> 2] | 0) >>> 0) { aA(e, a, b); b = (c[d >> 2] | 0) + 8 | 0; c[d >> 2] = b; } else { bA(h, f, g); b = c[d >> 2] | 0; } l = i; return (b - (c[h >> 2] | 0) >> 3) + -1 | 0; } function aA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; c[a + 4 >> 2] = d; return; } function bA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0; i = l; l = l + 32 | 0; f = i; g = a + 4 | 0; h = ((c[g >> 2] | 0) - (c[a >> 2] | 0) >> 3) + 1 | 0; e = cA(a) | 0; if (e >>> 0 < h >>> 0) jC(a); else { j = c[a >> 2] | 0; m = (c[a + 8 >> 2] | 0) - j | 0; k = m >> 2; dA(f, m >> 3 >>> 0 < e >>> 1 >>> 0 ? k >>> 0 < h >>> 0 ? h : k : e, (c[g >> 2] | 0) - j >> 3, a + 8 | 0); h = f + 8 | 0; aA(c[h >> 2] | 0, c[b >> 2] | 0, c[d >> 2] | 0); c[h >> 2] = (c[h >> 2] | 0) + 8; eA(a, f); fA(f); l = i; return; } } function cA(a) { a = a | 0; return 536870911; } function dA(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0; c[a + 12 >> 2] = 0; c[a + 16 >> 2] = e; do if (b) { if (b >>> 0 > 536870911) Ta(); else { f = qC(b << 3) | 0; break; } } else f = 0; while (0) c[a >> 2] = f; e = f + (d << 3) | 0; c[a + 8 >> 2] = e; c[a + 4 >> 2] = e; c[a + 12 >> 2] = f + (b << 3); return; } function eA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0, f = 0, g = 0, h = 0; e = c[a >> 2] | 0; h = a + 4 | 0; g = b + 4 | 0; f = (c[h >> 2] | 0) - e | 0; d = (c[g >> 2] | 0) + (0 - (f >> 3) << 3) | 0; c[g >> 2] = d; if ((f | 0) > 0) { BC(d | 0, e | 0, f | 0); e = g; d = c[g >> 2] | 0; } else e = g; g = c[a >> 2] | 0; c[a >> 2] = d; c[e >> 2] = g; g = b + 8 | 0; f = c[h >> 2] | 0; c[h >> 2] = c[g >> 2]; c[g >> 2] = f; g = a + 8 | 0; h = b + 12 | 0; a = c[g >> 2] | 0; c[g >> 2] = c[h >> 2]; c[h >> 2] = a; c[b >> 2] = c[e >> 2]; return; } function fA(a) { a = a | 0; var b = 0, d = 0, e = 0; b = c[a + 4 >> 2] | 0; d = a + 8 | 0; e = c[d >> 2] | 0; if ((e | 0) != (b | 0)) c[d >> 2] = e + (~((e + -8 - b | 0) >>> 3) << 3); a = c[a >> 2] | 0; if (a | 0) sC(a); return; } function gA(a) { a = a | 0; jA(a); return; } function hA(a) { a = a | 0; iA(a + 24 | 0); return; } function iA(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function jA(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 1, 12, b, kA() | 0, 2); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function kA() { return 1896; } function lA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; nA(c[(mA(a) | 0) >> 2] | 0, b, d); return; } function mA(a) { a = a | 0; return (c[(Zz() | 0) + 24 >> 2] | 0) + (a << 3) | 0; } function nA(a, b, c) { a = a | 0; b = b | 0; c = c | 0; var d = 0, e = 0, f = 0; d = l; l = l + 16 | 0; f = d + 4 | 0; e = d; oA(f, b); b = pA(f, b) | 0; ik(e, c); c = jk(e, c) | 0; ob[a & 31](b, c); kk(e); l = d; return; } function oA(a, b) { a = a | 0; b = b | 0; return; } function pA(a, b) { a = a | 0; b = b | 0; return qA(b) | 0; } function qA(a) { a = a | 0; return a | 0; } function rA() { var b = 0; if (!(a[8080] | 0)) { sA(11040); Ha(70, 11040, o | 0); b = 8080; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } if (!(si(11040) | 0)) sA(11040); return 11040; } function sA(a) { a = a | 0; vA(a); Gt(a, 71); return; } function tA(a) { a = a | 0; uA(a + 24 | 0); return; } function uA(a) { a = a | 0; var b = 0, d = 0, e = 0; d = c[a >> 2] | 0; e = d; if (d | 0) { a = a + 4 | 0; b = c[a >> 2] | 0; if ((b | 0) != (d | 0)) c[a >> 2] = b + (~((b + -8 - e | 0) >>> 3) << 3); sC(d); } return; } function vA(a) { a = a | 0; var b = 0; b = vi() | 0; yi(a, 5, 7, b, zA() | 0, 0); c[a + 24 >> 2] = 0; c[a + 28 >> 2] = 0; c[a + 32 >> 2] = 0; return; } function wA(a) { a = a | 0; xA(a); return; } function xA(a) { a = a | 0; yA(a); return; } function yA(b) { b = b | 0; a[b + 8 >> 0] = 1; return; } function zA() { return 1936; } function AA() { return BA() | 0; } function BA() { var a = 0, b = 0, d = 0, e = 0, f = 0, g = 0, h = 0; b = l; l = l + 16 | 0; f = b + 4 | 0; h = b; d = jy(8) | 0; a = d; g = a + 4 | 0; c[g >> 2] = qC(1) | 0; e = qC(8) | 0; g = c[g >> 2] | 0; c[h >> 2] = 0; c[f >> 2] = c[h >> 2]; CA(e, g, f); c[d >> 2] = e; l = b; return a | 0; } function CA(a, b, d) { a = a | 0; b = b | 0; d = d | 0; c[a >> 2] = b; d = qC(16) | 0; c[d + 4 >> 2] = 0; c[d + 8 >> 2] = 0; c[d >> 2] = 1916; c[d + 12 >> 2] = b; c[a + 4 >> 2] = d; return; } function DA(a) { a = a | 0; kC(a); sC(a); return; } function EA(a) { a = a | 0; a = c[a + 12 >> 2] | 0; if (a | 0) sC(a); return; } function FA(a) { a = a | 0; sC(a); return; } function GA() { var b = 0; if (!(a[8088] | 0)) { NA(11076); Ha(25, 11076, o | 0); b = 8088; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 11076; } function HA(a, b) { a = a | 0; b = b | 0; c[a >> 2] = IA() | 0; c[a + 4 >> 2] = JA() | 0; c[a + 12 >> 2] = b; c[a + 8 >> 2] = KA() | 0; c[a + 32 >> 2] = 10; return; } function IA() { return 11745; } function JA() { return 1940; } function KA() { return lr() | 0; } function LA(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; if ((jr(d, 896) | 0) == 512) { if (c | 0) { MA(c); sC(c); } } else if (b | 0) sC(b); return; } function MA(a) { a = a | 0; a = c[a + 4 >> 2] | 0; if (a | 0) oC(a); return; } function NA(a) { a = a | 0; Zi(a); return; } function OA(a, b) { a = a | 0; b = b | 0; c[a >> 2] = b; return; } function PA(a) { a = a | 0; return c[a >> 2] | 0; } function QA(b) { b = b | 0; return a[c[b >> 2] >> 0] | 0; } function RA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; c[e >> 2] = c[a >> 2]; SA(b, e); l = d; return; } function SA(a, b) { a = a | 0; b = b | 0; var d = 0; d = TA(c[a >> 2] | 0, b) | 0; b = a + 4 | 0; c[(c[b >> 2] | 0) + 8 >> 2] = d; return c[(c[b >> 2] | 0) + 8 >> 2] | 0; } function TA(a, b) { a = a | 0; b = b | 0; var d = 0, e = 0; d = l; l = l + 16 | 0; e = d; UA(e); a = Sg(a) | 0; b = VA(a, c[b >> 2] | 0) | 0; WA(e); l = d; return b | 0; } function UA(a) { a = a | 0; c[a >> 2] = c[2701]; c[a + 4 >> 2] = c[2703]; return; } function VA(a, b) { a = a | 0; b = b | 0; var c = 0; c = Vg(XA() | 0) | 0; return bb(0, c | 0, a | 0, sw(b) | 0) | 0; } function WA(a) { a = a | 0; xy(c[a >> 2] | 0, c[a + 4 >> 2] | 0); return; } function XA() { var b = 0; if (!(a[8096] | 0)) { YA(11120); b = 8096; c[b >> 2] = 1; c[b + 4 >> 2] = 0; } return 11120; } function YA(a) { a = a | 0; fh(a, ZA() | 0, 1); return; } function ZA() { return 1948; } function _A() { $A(); return; } function $A() { var b = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0; s = l; l = l + 16 | 0; o = s + 4 | 0; p = s; Ea(65536, 10804, c[2702] | 0, 10812); f = Wv() | 0; e = c[f >> 2] | 0; b = c[e >> 2] | 0; if (b | 0) { g = c[f + 8 >> 2] | 0; f = c[f + 4 >> 2] | 0; while(true){ Ma(b | 0, d[f >> 0] | 0, a[g >> 0] | 0); e = e + 4 | 0; b = c[e >> 2] | 0; if (!b) break; else { g = g + 1 | 0; f = f + 1 | 0; } } } b = Yv() | 0; e = c[b >> 2] | 0; if (e | 0) do { Na(e | 0, c[b + 4 >> 2] | 0); b = b + 8 | 0; e = c[b >> 2] | 0; }while ((e | 0) != 0) Na(aB() | 0, 5167); n = Iv() | 0; b = c[n >> 2] | 0; a: do if (b | 0) { do { bB(c[b + 4 >> 2] | 0); b = c[b >> 2] | 0; }while ((b | 0) != 0) b = c[n >> 2] | 0; if (b | 0) { m = n; do { while(true){ h = b; b = c[b >> 2] | 0; h = c[h + 4 >> 2] | 0; if (!(cB(h) | 0)) break; c[p >> 2] = m; c[o >> 2] = c[p >> 2]; dB(n, o); if (!b) break a; } eB(h); m = c[m >> 2] | 0; e = fB(h) | 0; i = Va() | 0; j = l; l = l + ((1 * (e << 2) | 0) + 15 & -16) | 0; k = l; l = l + ((1 * (e << 2) | 0) + 15 & -16) | 0; e = c[(Zw(h) | 0) >> 2] | 0; if (e | 0) { f = j; g = k; while(true){ c[f >> 2] = c[(Xw(c[e + 4 >> 2] | 0) | 0) >> 2]; c[g >> 2] = c[e + 8 >> 2]; e = c[e >> 2] | 0; if (!e) break; else { f = f + 4 | 0; g = g + 4 | 0; } } } t = Xw(h) | 0; e = gB(h) | 0; f = fB(h) | 0; g = hB(h) | 0; Ra(t | 0, e | 0, j | 0, k | 0, f | 0, g | 0, Tv(h) | 0); Ga(i | 0); }while ((b | 0) != 0) } } while (0) b = c[(Vv() | 0) >> 2] | 0; if (b | 0) do { t = b + 4 | 0; n = aw(t) | 0; h = fw(n) | 0; i = bw(n) | 0; j = (cw(n) | 0) + 1 | 0; k = iB(n) | 0; m = jB(t) | 0; n = si(n) | 0; o = hw(t) | 0; p = kB(t) | 0; Pa(0, h | 0, i | 0, j | 0, k | 0, m | 0, n | 0, o | 0, p | 0, lB(t) | 0); b = c[b >> 2] | 0; }while ((b | 0) != 0) b = c[(Iv() | 0) >> 2] | 0; b: if (b | 0) { c: while(true){ e = c[b + 4 >> 2] | 0; if (e | 0 ? (q = c[(Xw(e) | 0) >> 2] | 0, r = c[(ax(e) | 0) >> 2] | 0, r | 0) : 0) { f = r; do { e = f + 4 | 0; g = aw(e) | 0; d: if (g | 0) switch(si(g) | 0){ case 0: break c; case 4: case 3: case 2: k = fw(g) | 0; m = bw(g) | 0; n = (cw(g) | 0) + 1 | 0; o = iB(g) | 0; p = si(g) | 0; t = hw(e) | 0; Pa(q | 0, k | 0, m | 0, n | 0, o | 0, 0, p | 0, t | 0, kB(e) | 0, lB(e) | 0); break d; case 1: j = fw(g) | 0; k = bw(g) | 0; m = (cw(g) | 0) + 1 | 0; n = iB(g) | 0; o = jB(e) | 0; p = si(g) | 0; t = hw(e) | 0; Pa(q | 0, j | 0, k | 0, m | 0, n | 0, o | 0, p | 0, t | 0, kB(e) | 0, lB(e) | 0); break d; case 5: n = fw(g) | 0; o = bw(g) | 0; p = (cw(g) | 0) + 1 | 0; t = iB(g) | 0; Pa(q | 0, n | 0, o | 0, p | 0, t | 0, mB(g) | 0, si(g) | 0, 0, 0, 0); break d; default: break d; } f = c[f >> 2] | 0; }while ((f | 0) != 0) } b = c[b >> 2] | 0; if (!b) break b; } Ta(); } Sa(); l = s; return; } function aB() { return 11703; } function bB(b) { b = b | 0; a[b + 40 >> 0] = 0; return; } function cB(b) { b = b | 0; return (a[b + 40 >> 0] | 0) != 0 | 0; } function dB(a, b) { a = a | 0; b = b | 0; b = nB(b) | 0; a = c[b >> 2] | 0; c[b >> 2] = c[a >> 2]; sC(a); return c[b >> 2] | 0; } function eB(b) { b = b | 0; a[b + 40 >> 0] = 1; return; } function fB(a) { a = a | 0; return c[a + 20 >> 2] | 0; } function gB(a) { a = a | 0; return c[a + 8 >> 2] | 0; } function hB(a) { a = a | 0; return c[a + 32 >> 2] | 0; } function iB(a) { a = a | 0; return c[a + 4 >> 2] | 0; } function jB(a) { a = a | 0; return c[a + 4 >> 2] | 0; } function kB(a) { a = a | 0; return c[a + 8 >> 2] | 0; } function lB(a) { a = a | 0; return c[a + 16 >> 2] | 0; } function mB(a) { a = a | 0; return c[a + 20 >> 2] | 0; } function nB(a) { a = a | 0; return c[a >> 2] | 0; } function oB(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0; x = l; l = l + 16 | 0; o = x; do if (a >>> 0 < 245) { k = a >>> 0 < 11 ? 16 : a + 11 & -8; a = k >>> 3; n = c[2783] | 0; d = n >>> a; if (d & 3 | 0) { b = (d & 1 ^ 1) + a | 0; a = 11172 + (b << 1 << 2) | 0; d = a + 8 | 0; e = c[d >> 2] | 0; f = e + 8 | 0; g = c[f >> 2] | 0; if ((a | 0) == (g | 0)) c[2783] = n & ~(1 << b); else { c[g + 12 >> 2] = a; c[d >> 2] = g; } w = b << 3; c[e + 4 >> 2] = w | 3; w = e + w + 4 | 0; c[w >> 2] = c[w >> 2] | 1; w = f; l = x; return w | 0; } m = c[2785] | 0; if (k >>> 0 > m >>> 0) { if (d | 0) { b = 2 << a; b = d << a & (b | 0 - b); b = (b & 0 - b) + -1 | 0; h = b >>> 12 & 16; b = b >>> h; d = b >>> 5 & 8; b = b >>> d; f = b >>> 2 & 4; b = b >>> f; a = b >>> 1 & 2; b = b >>> a; e = b >>> 1 & 1; e = (d | h | f | a | e) + (b >>> e) | 0; b = 11172 + (e << 1 << 2) | 0; a = b + 8 | 0; f = c[a >> 2] | 0; h = f + 8 | 0; d = c[h >> 2] | 0; if ((b | 0) == (d | 0)) { a = n & ~(1 << e); c[2783] = a; } else { c[d + 12 >> 2] = b; c[a >> 2] = d; a = n; } g = (e << 3) - k | 0; c[f + 4 >> 2] = k | 3; e = f + k | 0; c[e + 4 >> 2] = g | 1; c[e + g >> 2] = g; if (m | 0) { f = c[2788] | 0; b = m >>> 3; d = 11172 + (b << 1 << 2) | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = d + 8 | 0; } else { a = d + 8 | 0; b = c[a >> 2] | 0; } c[a >> 2] = f; c[b + 12 >> 2] = f; c[f + 8 >> 2] = b; c[f + 12 >> 2] = d; } c[2785] = g; c[2788] = e; w = h; l = x; return w | 0; } i = c[2784] | 0; if (i) { d = (i & 0 - i) + -1 | 0; h = d >>> 12 & 16; d = d >>> h; g = d >>> 5 & 8; d = d >>> g; j = d >>> 2 & 4; d = d >>> j; e = d >>> 1 & 2; d = d >>> e; a = d >>> 1 & 1; a = c[11436 + ((g | h | j | e | a) + (d >>> a) << 2) >> 2] | 0; d = (c[a + 4 >> 2] & -8) - k | 0; e = c[a + 16 + (((c[a + 16 >> 2] | 0) == 0 & 1) << 2) >> 2] | 0; if (!e) { j = a; g = d; } else { do { h = (c[e + 4 >> 2] & -8) - k | 0; j = h >>> 0 < d >>> 0; d = j ? h : d; a = j ? e : a; e = c[e + 16 + (((c[e + 16 >> 2] | 0) == 0 & 1) << 2) >> 2] | 0; }while ((e | 0) != 0) j = a; g = d; } h = j + k | 0; if (j >>> 0 < h >>> 0) { f = c[j + 24 >> 2] | 0; b = c[j + 12 >> 2] | 0; do if ((b | 0) == (j | 0)) { a = j + 20 | 0; b = c[a >> 2] | 0; if (!b) { a = j + 16 | 0; b = c[a >> 2] | 0; if (!b) { d = 0; break; } } while(true){ d = b + 20 | 0; e = c[d >> 2] | 0; if (e | 0) { b = e; a = d; continue; } d = b + 16 | 0; e = c[d >> 2] | 0; if (!e) break; else { b = e; a = d; } } c[a >> 2] = 0; d = b; } else { d = c[j + 8 >> 2] | 0; c[d + 12 >> 2] = b; c[b + 8 >> 2] = d; d = b; } while (0) do if (f | 0) { b = c[j + 28 >> 2] | 0; a = 11436 + (b << 2) | 0; if ((j | 0) == (c[a >> 2] | 0)) { c[a >> 2] = d; if (!d) { c[2784] = i & ~(1 << b); break; } } else { c[f + 16 + (((c[f + 16 >> 2] | 0) != (j | 0) & 1) << 2) >> 2] = d; if (!d) break; } c[d + 24 >> 2] = f; b = c[j + 16 >> 2] | 0; if (b | 0) { c[d + 16 >> 2] = b; c[b + 24 >> 2] = d; } b = c[j + 20 >> 2] | 0; if (b | 0) { c[d + 20 >> 2] = b; c[b + 24 >> 2] = d; } } while (0) if (g >>> 0 < 16) { w = g + k | 0; c[j + 4 >> 2] = w | 3; w = j + w + 4 | 0; c[w >> 2] = c[w >> 2] | 1; } else { c[j + 4 >> 2] = k | 3; c[h + 4 >> 2] = g | 1; c[h + g >> 2] = g; if (m | 0) { e = c[2788] | 0; b = m >>> 3; d = 11172 + (b << 1 << 2) | 0; b = 1 << b; if (!(n & b)) { c[2783] = n | b; b = d; a = d + 8 | 0; } else { a = d + 8 | 0; b = c[a >> 2] | 0; } c[a >> 2] = e; c[b + 12 >> 2] = e; c[e + 8 >> 2] = b; c[e + 12 >> 2] = d; } c[2785] = g; c[2788] = h; } w = j + 8 | 0; l = x; return w | 0; } else n = k; } else n = k; } else n = k; } else if (a >>> 0 <= 4294967231) { a = a + 11 | 0; k = a & -8; j = c[2784] | 0; if (j) { e = 0 - k | 0; a = a >>> 8; if (a) { if (k >>> 0 > 16777215) i = 31; else { n = (a + 1048320 | 0) >>> 16 & 8; v = a << n; m = (v + 520192 | 0) >>> 16 & 4; v = v << m; i = (v + 245760 | 0) >>> 16 & 2; i = 14 - (m | n | i) + (v << i >>> 15) | 0; i = k >>> (i + 7 | 0) & 1 | i << 1; } } else i = 0; d = c[11436 + (i << 2) >> 2] | 0; a: do if (!d) { d = 0; a = 0; v = 57; } else { a = 0; h = k << ((i | 0) == 31 ? 0 : 25 - (i >>> 1) | 0); g = 0; while(true){ f = (c[d + 4 >> 2] & -8) - k | 0; if (f >>> 0 < e >>> 0) { if (!f) { a = d; e = 0; f = d; v = 61; break a; } else { a = d; e = f; } } f = c[d + 20 >> 2] | 0; d = c[d + 16 + (h >>> 31 << 2) >> 2] | 0; g = (f | 0) == 0 | (f | 0) == (d | 0) ? g : f; f = (d | 0) == 0; if (f) { d = g; v = 57; break; } else h = h << ((f ^ 1) & 1); } } while (0) if ((v | 0) == 57) { if ((d | 0) == 0 & (a | 0) == 0) { a = 2 << i; a = j & (a | 0 - a); if (!a) { n = k; break; } n = (a & 0 - a) + -1 | 0; h = n >>> 12 & 16; n = n >>> h; g = n >>> 5 & 8; n = n >>> g; i = n >>> 2 & 4; n = n >>> i; m = n >>> 1 & 2; n = n >>> m; d = n >>> 1 & 1; a = 0; d = c[11436 + ((g | h | i | m | d) + (n >>> d) << 2) >> 2] | 0; } if (!d) { i = a; h = e; } else { f = d; v = 61; } } if ((v | 0) == 61) while(true){ v = 0; d = (c[f + 4 >> 2] & -8) - k | 0; n = d >>> 0 < e >>> 0; d = n ? d : e; a = n ? f : a; f = c[f + 16 + (((c[f + 16 >> 2] | 0) == 0 & 1) << 2) >> 2] | 0; if (!f) { i = a; h = d; break; } else { e = d; v = 61; } } if ((i | 0) != 0 ? h >>> 0 < ((c[2785] | 0) - k | 0) >>> 0 : 0) { g = i + k | 0; if (i >>> 0 >= g >>> 0) { w = 0; l = x; return w | 0; } f = c[i + 24 >> 2] | 0; b = c[i + 12 >> 2] | 0; do if ((b | 0) == (i | 0)) { a = i + 20 | 0; b = c[a >> 2] | 0; if (!b) { a = i + 16 | 0; b = c[a >> 2] | 0; if (!b) { b = 0; break; } } while(true){ d = b + 20 | 0; e = c[d >> 2] | 0; if (e | 0) { b = e; a = d; continue; } d = b + 16 | 0; e = c[d >> 2] | 0; if (!e) break; else { b = e; a = d; } } c[a >> 2] = 0; } else { w = c[i + 8 >> 2] | 0; c[w + 12 >> 2] = b; c[b + 8 >> 2] = w; } while (0) do if (f) { a = c[i + 28 >> 2] | 0; d = 11436 + (a << 2) | 0; if ((i | 0) == (c[d >> 2] | 0)) { c[d >> 2] = b; if (!b) { e = j & ~(1 << a); c[2784] = e; break; } } else { c[f + 16 + (((c[f + 16 >> 2] | 0) != (i | 0) & 1) << 2) >> 2] = b; if (!b) { e = j; break; } } c[b + 24 >> 2] = f; a = c[i + 16 >> 2] | 0; if (a | 0) { c[b + 16 >> 2] = a; c[a + 24 >> 2] = b; } a = c[i + 20 >> 2] | 0; if (a) { c[b + 20 >> 2] = a; c[a + 24 >> 2] = b; e = j; } else e = j; } else e = j; while (0) do if (h >>> 0 >= 16) { c[i + 4 >> 2] = k | 3; c[g + 4 >> 2] = h | 1; c[g + h >> 2] = h; b = h >>> 3; if (h >>> 0 < 256) { d = 11172 + (b << 1 << 2) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = d + 8 | 0; } else { a = d + 8 | 0; b = c[a >> 2] | 0; } c[a >> 2] = g; c[b + 12 >> 2] = g; c[g + 8 >> 2] = b; c[g + 12 >> 2] = d; break; } b = h >>> 8; if (b) { if (h >>> 0 > 16777215) b = 31; else { v = (b + 1048320 | 0) >>> 16 & 8; w = b << v; u = (w + 520192 | 0) >>> 16 & 4; w = w << u; b = (w + 245760 | 0) >>> 16 & 2; b = 14 - (u | v | b) + (w << b >>> 15) | 0; b = h >>> (b + 7 | 0) & 1 | b << 1; } } else b = 0; d = 11436 + (b << 2) | 0; c[g + 28 >> 2] = b; a = g + 16 | 0; c[a + 4 >> 2] = 0; c[a >> 2] = 0; a = 1 << b; if (!(e & a)) { c[2784] = e | a; c[d >> 2] = g; c[g + 24 >> 2] = d; c[g + 12 >> 2] = g; c[g + 8 >> 2] = g; break; } a = h << ((b | 0) == 31 ? 0 : 25 - (b >>> 1) | 0); d = c[d >> 2] | 0; while(true){ if ((c[d + 4 >> 2] & -8 | 0) == (h | 0)) { v = 97; break; } e = d + 16 + (a >>> 31 << 2) | 0; b = c[e >> 2] | 0; if (!b) { v = 96; break; } else { a = a << 1; d = b; } } if ((v | 0) == 96) { c[e >> 2] = g; c[g + 24 >> 2] = d; c[g + 12 >> 2] = g; c[g + 8 >> 2] = g; break; } else if ((v | 0) == 97) { v = d + 8 | 0; w = c[v >> 2] | 0; c[w + 12 >> 2] = g; c[v >> 2] = g; c[g + 8 >> 2] = w; c[g + 12 >> 2] = d; c[g + 24 >> 2] = 0; break; } } else { w = h + k | 0; c[i + 4 >> 2] = w | 3; w = i + w + 4 | 0; c[w >> 2] = c[w >> 2] | 1; } while (0) w = i + 8 | 0; l = x; return w | 0; } else n = k; } else n = k; } else n = -1; while (0) d = c[2785] | 0; if (d >>> 0 >= n >>> 0) { b = d - n | 0; a = c[2788] | 0; if (b >>> 0 > 15) { w = a + n | 0; c[2788] = w; c[2785] = b; c[w + 4 >> 2] = b | 1; c[w + b >> 2] = b; c[a + 4 >> 2] = n | 3; } else { c[2785] = 0; c[2788] = 0; c[a + 4 >> 2] = d | 3; w = a + d + 4 | 0; c[w >> 2] = c[w >> 2] | 1; } w = a + 8 | 0; l = x; return w | 0; } h = c[2786] | 0; if (h >>> 0 > n >>> 0) { u = h - n | 0; c[2786] = u; w = c[2789] | 0; v = w + n | 0; c[2789] = v; c[v + 4 >> 2] = u | 1; c[w + 4 >> 2] = n | 3; w = w + 8 | 0; l = x; return w | 0; } if (!(c[2901] | 0)) { c[2903] = 4096; c[2902] = 4096; c[2904] = -1; c[2905] = -1; c[2906] = 0; c[2894] = 0; a = o & -16 ^ 1431655768; c[o >> 2] = a; c[2901] = a; a = 4096; } else a = c[2903] | 0; i = n + 48 | 0; j = n + 47 | 0; g = a + j | 0; f = 0 - a | 0; k = g & f; if (k >>> 0 <= n >>> 0) { w = 0; l = x; return w | 0; } a = c[2893] | 0; if (a | 0 ? (m = c[2891] | 0, o = m + k | 0, o >>> 0 <= m >>> 0 | o >>> 0 > a >>> 0) : 0) { w = 0; l = x; return w | 0; } b: do if (!(c[2894] & 4)) { d = c[2789] | 0; c: do if (d) { e = 11580; while(true){ a = c[e >> 2] | 0; if (a >>> 0 <= d >>> 0 ? (r = e + 4 | 0, (a + (c[r >> 2] | 0) | 0) >>> 0 > d >>> 0) : 0) break; a = c[e + 8 >> 2] | 0; if (!a) { v = 118; break c; } else e = a; } b = g - h & f; if (b >>> 0 < 2147483647) { a = FC(b | 0) | 0; if ((a | 0) == ((c[e >> 2] | 0) + (c[r >> 2] | 0) | 0)) { if ((a | 0) != -1) { h = b; g = a; v = 135; break b; } } else { e = a; v = 126; } } else b = 0; } else v = 118; while (0) do if ((v | 0) == 118) { d = FC(0) | 0; if ((d | 0) != -1 ? (b = d, p = c[2902] | 0, q = p + -1 | 0, b = ((q & b | 0) == 0 ? 0 : (q + b & 0 - p) - b | 0) + k | 0, p = c[2891] | 0, q = b + p | 0, b >>> 0 > n >>> 0 & b >>> 0 < 2147483647) : 0) { r = c[2893] | 0; if (r | 0 ? q >>> 0 <= p >>> 0 | q >>> 0 > r >>> 0 : 0) { b = 0; break; } a = FC(b | 0) | 0; if ((a | 0) == (d | 0)) { h = b; g = d; v = 135; break b; } else { e = a; v = 126; } } else b = 0; } while (0) do if ((v | 0) == 126) { d = 0 - b | 0; if (!(i >>> 0 > b >>> 0 & (b >>> 0 < 2147483647 & (e | 0) != -1))) { if ((e | 0) == -1) { b = 0; break; } else { h = b; g = e; v = 135; break b; } } a = c[2903] | 0; a = j - b + a & 0 - a; if (a >>> 0 >= 2147483647) { h = b; g = e; v = 135; break b; } if ((FC(a | 0) | 0) == -1) { FC(d | 0); b = 0; break; } else { h = a + b | 0; g = e; v = 135; break b; } } while (0) c[2894] = c[2894] | 4; v = 133; } else { b = 0; v = 133; } while (0) if (((v | 0) == 133 ? k >>> 0 < 2147483647 : 0) ? (u = FC(k | 0) | 0, r = FC(0) | 0, s = r - u | 0, t = s >>> 0 > (n + 40 | 0) >>> 0, !((u | 0) == -1 | t ^ 1 | u >>> 0 < r >>> 0 & ((u | 0) != -1 & (r | 0) != -1) ^ 1)) : 0) { h = t ? s : b; g = u; v = 135; } if ((v | 0) == 135) { b = (c[2891] | 0) + h | 0; c[2891] = b; if (b >>> 0 > (c[2892] | 0) >>> 0) c[2892] = b; j = c[2789] | 0; do if (j) { b = 11580; while(true){ a = c[b >> 2] | 0; d = b + 4 | 0; e = c[d >> 2] | 0; if ((g | 0) == (a + e | 0)) { v = 145; break; } f = c[b + 8 >> 2] | 0; if (!f) break; else b = f; } if (((v | 0) == 145 ? (c[b + 12 >> 2] & 8 | 0) == 0 : 0) ? j >>> 0 < g >>> 0 & j >>> 0 >= a >>> 0 : 0) { c[d >> 2] = e + h; w = j + 8 | 0; w = (w & 7 | 0) == 0 ? 0 : 0 - w & 7; v = j + w | 0; w = (c[2786] | 0) + (h - w) | 0; c[2789] = v; c[2786] = w; c[v + 4 >> 2] = w | 1; c[v + w + 4 >> 2] = 40; c[2790] = c[2905]; break; } if (g >>> 0 < (c[2787] | 0) >>> 0) c[2787] = g; d = g + h | 0; b = 11580; while(true){ if ((c[b >> 2] | 0) == (d | 0)) { v = 153; break; } a = c[b + 8 >> 2] | 0; if (!a) break; else b = a; } if ((v | 0) == 153 ? (c[b + 12 >> 2] & 8 | 0) == 0 : 0) { c[b >> 2] = g; m = b + 4 | 0; c[m >> 2] = (c[m >> 2] | 0) + h; m = g + 8 | 0; m = g + ((m & 7 | 0) == 0 ? 0 : 0 - m & 7) | 0; b = d + 8 | 0; b = d + ((b & 7 | 0) == 0 ? 0 : 0 - b & 7) | 0; k = m + n | 0; i = b - m - n | 0; c[m + 4 >> 2] = n | 3; do if ((b | 0) != (j | 0)) { if ((b | 0) == (c[2788] | 0)) { w = (c[2785] | 0) + i | 0; c[2785] = w; c[2788] = k; c[k + 4 >> 2] = w | 1; c[k + w >> 2] = w; break; } a = c[b + 4 >> 2] | 0; if ((a & 3 | 0) == 1) { h = a & -8; e = a >>> 3; d: do if (a >>> 0 < 256) { a = c[b + 8 >> 2] | 0; d = c[b + 12 >> 2] | 0; if ((d | 0) == (a | 0)) { c[2783] = c[2783] & ~(1 << e); break; } else { c[a + 12 >> 2] = d; c[d + 8 >> 2] = a; break; } } else { g = c[b + 24 >> 2] | 0; a = c[b + 12 >> 2] | 0; do if ((a | 0) == (b | 0)) { e = b + 16 | 0; d = e + 4 | 0; a = c[d >> 2] | 0; if (!a) { a = c[e >> 2] | 0; if (!a) { a = 0; break; } else d = e; } while(true){ e = a + 20 | 0; f = c[e >> 2] | 0; if (f | 0) { a = f; d = e; continue; } e = a + 16 | 0; f = c[e >> 2] | 0; if (!f) break; else { a = f; d = e; } } c[d >> 2] = 0; } else { w = c[b + 8 >> 2] | 0; c[w + 12 >> 2] = a; c[a + 8 >> 2] = w; } while (0) if (!g) break; d = c[b + 28 >> 2] | 0; e = 11436 + (d << 2) | 0; do if ((b | 0) != (c[e >> 2] | 0)) { c[g + 16 + (((c[g + 16 >> 2] | 0) != (b | 0) & 1) << 2) >> 2] = a; if (!a) break d; } else { c[e >> 2] = a; if (a | 0) break; c[2784] = c[2784] & ~(1 << d); break d; } while (0) c[a + 24 >> 2] = g; d = b + 16 | 0; e = c[d >> 2] | 0; if (e | 0) { c[a + 16 >> 2] = e; c[e + 24 >> 2] = a; } d = c[d + 4 >> 2] | 0; if (!d) break; c[a + 20 >> 2] = d; c[d + 24 >> 2] = a; } while (0) b = b + h | 0; f = h + i | 0; } else f = i; b = b + 4 | 0; c[b >> 2] = c[b >> 2] & -2; c[k + 4 >> 2] = f | 1; c[k + f >> 2] = f; b = f >>> 3; if (f >>> 0 < 256) { d = 11172 + (b << 1 << 2) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = d + 8 | 0; } else { a = d + 8 | 0; b = c[a >> 2] | 0; } c[a >> 2] = k; c[b + 12 >> 2] = k; c[k + 8 >> 2] = b; c[k + 12 >> 2] = d; break; } b = f >>> 8; do if (!b) b = 0; else { if (f >>> 0 > 16777215) { b = 31; break; } v = (b + 1048320 | 0) >>> 16 & 8; w = b << v; u = (w + 520192 | 0) >>> 16 & 4; w = w << u; b = (w + 245760 | 0) >>> 16 & 2; b = 14 - (u | v | b) + (w << b >>> 15) | 0; b = f >>> (b + 7 | 0) & 1 | b << 1; } while (0) e = 11436 + (b << 2) | 0; c[k + 28 >> 2] = b; a = k + 16 | 0; c[a + 4 >> 2] = 0; c[a >> 2] = 0; a = c[2784] | 0; d = 1 << b; if (!(a & d)) { c[2784] = a | d; c[e >> 2] = k; c[k + 24 >> 2] = e; c[k + 12 >> 2] = k; c[k + 8 >> 2] = k; break; } a = f << ((b | 0) == 31 ? 0 : 25 - (b >>> 1) | 0); d = c[e >> 2] | 0; while(true){ if ((c[d + 4 >> 2] & -8 | 0) == (f | 0)) { v = 194; break; } e = d + 16 + (a >>> 31 << 2) | 0; b = c[e >> 2] | 0; if (!b) { v = 193; break; } else { a = a << 1; d = b; } } if ((v | 0) == 193) { c[e >> 2] = k; c[k + 24 >> 2] = d; c[k + 12 >> 2] = k; c[k + 8 >> 2] = k; break; } else if ((v | 0) == 194) { v = d + 8 | 0; w = c[v >> 2] | 0; c[w + 12 >> 2] = k; c[v >> 2] = k; c[k + 8 >> 2] = w; c[k + 12 >> 2] = d; c[k + 24 >> 2] = 0; break; } } else { w = (c[2786] | 0) + i | 0; c[2786] = w; c[2789] = k; c[k + 4 >> 2] = w | 1; } while (0) w = m + 8 | 0; l = x; return w | 0; } b = 11580; while(true){ a = c[b >> 2] | 0; if (a >>> 0 <= j >>> 0 ? (w = a + (c[b + 4 >> 2] | 0) | 0, w >>> 0 > j >>> 0) : 0) break; b = c[b + 8 >> 2] | 0; } f = w + -47 | 0; a = f + 8 | 0; a = f + ((a & 7 | 0) == 0 ? 0 : 0 - a & 7) | 0; f = j + 16 | 0; a = a >>> 0 < f >>> 0 ? j : a; b = a + 8 | 0; d = g + 8 | 0; d = (d & 7 | 0) == 0 ? 0 : 0 - d & 7; v = g + d | 0; d = h + -40 - d | 0; c[2789] = v; c[2786] = d; c[v + 4 >> 2] = d | 1; c[v + d + 4 >> 2] = 40; c[2790] = c[2905]; d = a + 4 | 0; c[d >> 2] = 27; c[b >> 2] = c[2895]; c[b + 4 >> 2] = c[2896]; c[b + 8 >> 2] = c[2897]; c[b + 12 >> 2] = c[2898]; c[2895] = g; c[2896] = h; c[2898] = 0; c[2897] = b; b = a + 24 | 0; do { v = b; b = b + 4 | 0; c[b >> 2] = 7; }while ((v + 8 | 0) >>> 0 < w >>> 0) if ((a | 0) != (j | 0)) { g = a - j | 0; c[d >> 2] = c[d >> 2] & -2; c[j + 4 >> 2] = g | 1; c[a >> 2] = g; b = g >>> 3; if (g >>> 0 < 256) { d = 11172 + (b << 1 << 2) | 0; a = c[2783] | 0; b = 1 << b; if (!(a & b)) { c[2783] = a | b; b = d; a = d + 8 | 0; } else { a = d + 8 | 0; b = c[a >> 2] | 0; } c[a >> 2] = j; c[b + 12 >> 2] = j; c[j + 8 >> 2] = b; c[j + 12 >> 2] = d; break; } b = g >>> 8; if (b) { if (g >>> 0 > 16777215) d = 31; else { v = (b + 1048320 | 0) >>> 16 & 8; w = b << v; u = (w + 520192 | 0) >>> 16 & 4; w = w << u; d = (w + 245760 | 0) >>> 16 & 2; d = 14 - (u | v | d) + (w << d >>> 15) | 0; d = g >>> (d + 7 | 0) & 1 | d << 1; } } else d = 0; e = 11436 + (d << 2) | 0; c[j + 28 >> 2] = d; c[j + 20 >> 2] = 0; c[f >> 2] = 0; b = c[2784] | 0; a = 1 << d; if (!(b & a)) { c[2784] = b | a; c[e >> 2] = j; c[j + 24 >> 2] = e; c[j + 12 >> 2] = j; c[j + 8 >> 2] = j; break; } a = g << ((d | 0) == 31 ? 0 : 25 - (d >>> 1) | 0); d = c[e >> 2] | 0; while(true){ if ((c[d + 4 >> 2] & -8 | 0) == (g | 0)) { v = 216; break; } e = d + 16 + (a >>> 31 << 2) | 0; b = c[e >> 2] | 0; if (!b) { v = 215; break; } else { a = a << 1; d = b; } } if ((v | 0) == 215) { c[e >> 2] = j; c[j + 24 >> 2] = d; c[j + 12 >> 2] = j; c[j + 8 >> 2] = j; break; } else if ((v | 0) == 216) { v = d + 8 | 0; w = c[v >> 2] | 0; c[w + 12 >> 2] = j; c[v >> 2] = j; c[j + 8 >> 2] = w; c[j + 12 >> 2] = d; c[j + 24 >> 2] = 0; break; } } } else { w = c[2787] | 0; if ((w | 0) == 0 | g >>> 0 < w >>> 0) c[2787] = g; c[2895] = g; c[2896] = h; c[2898] = 0; c[2792] = c[2901]; c[2791] = -1; b = 0; do { w = 11172 + (b << 1 << 2) | 0; c[w + 12 >> 2] = w; c[w + 8 >> 2] = w; b = b + 1 | 0; }while ((b | 0) != 32) w = g + 8 | 0; w = (w & 7 | 0) == 0 ? 0 : 0 - w & 7; v = g + w | 0; w = h + -40 - w | 0; c[2789] = v; c[2786] = w; c[v + 4 >> 2] = w | 1; c[v + w + 4 >> 2] = 40; c[2790] = c[2905]; } while (0) b = c[2786] | 0; if (b >>> 0 > n >>> 0) { u = b - n | 0; c[2786] = u; w = c[2789] | 0; v = w + n | 0; c[2789] = v; c[v + 4 >> 2] = u | 1; c[w + 4 >> 2] = n | 3; w = w + 8 | 0; l = x; return w | 0; } } c[(vB() | 0) >> 2] = 12; w = 0; l = x; return w | 0; } function pB(a) { a = a | 0; var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0; if (!a) return; d = a + -8 | 0; f = c[2787] | 0; a = c[a + -4 >> 2] | 0; b = a & -8; j = d + b | 0; do if (!(a & 1)) { e = c[d >> 2] | 0; if (!(a & 3)) return; h = d + (0 - e) | 0; g = e + b | 0; if (h >>> 0 < f >>> 0) return; if ((h | 0) == (c[2788] | 0)) { a = j + 4 | 0; b = c[a >> 2] | 0; if ((b & 3 | 0) != 3) { i = h; b = g; break; } c[2785] = g; c[a >> 2] = b & -2; c[h + 4 >> 2] = g | 1; c[h + g >> 2] = g; return; } d = e >>> 3; if (e >>> 0 < 256) { a = c[h + 8 >> 2] | 0; b = c[h + 12 >> 2] | 0; if ((b | 0) == (a | 0)) { c[2783] = c[2783] & ~(1 << d); i = h; b = g; break; } else { c[a + 12 >> 2] = b; c[b + 8 >> 2] = a; i = h; b = g; break; } } f = c[h + 24 >> 2] | 0; a = c[h + 12 >> 2] | 0; do if ((a | 0) == (h | 0)) { d = h + 16 | 0; b = d + 4 | 0; a = c[b >> 2] | 0; if (!a) { a = c[d >> 2] | 0; if (!a) { a = 0; break; } else b = d; } while(true){ d = a + 20 | 0; e = c[d >> 2] | 0; if (e | 0) { a = e; b = d; continue; } d = a + 16 | 0; e = c[d >> 2] | 0; if (!e) break; else { a = e; b = d; } } c[b >> 2] = 0; } else { i = c[h + 8 >> 2] | 0; c[i + 12 >> 2] = a; c[a + 8 >> 2] = i; } while (0) if (f) { b = c[h + 28 >> 2] | 0; d = 11436 + (b << 2) | 0; if ((h | 0) == (c[d >> 2] | 0)) { c[d >> 2] = a; if (!a) { c[2784] = c[2784] & ~(1 << b); i = h; b = g; break; } } else { c[f + 16 + (((c[f + 16 >> 2] | 0) != (h | 0) & 1) << 2) >> 2] = a; if (!a) { i = h; b = g; break; } } c[a + 24 >> 2] = f; b = h + 16 | 0; d = c[b >> 2] | 0; if (d | 0) { c[a + 16 >> 2] = d; c[d + 24 >> 2] = a; } b = c[b + 4 >> 2] | 0; if (b) { c[a + 20 >> 2] = b; c[b + 24 >> 2] = a; i = h; b = g; } else { i = h; b = g; } } else { i = h; b = g; } } else { i = d; h = d; } while (0) if (h >>> 0 >= j >>> 0) return; a = j + 4 | 0; e = c[a >> 2] | 0; if (!(e & 1)) return; if (!(e & 2)) { a = c[2788] | 0; if ((j | 0) == (c[2789] | 0)) { j = (c[2786] | 0) + b | 0; c[2786] = j; c[2789] = i; c[i + 4 >> 2] = j | 1; if ((i | 0) != (a | 0)) return; c[2788] = 0; c[2785] = 0; return; } if ((j | 0) == (a | 0)) { j = (c[2785] | 0) + b | 0; c[2785] = j; c[2788] = h; c[i + 4 >> 2] = j | 1; c[h + j >> 2] = j; return; } f = (e & -8) + b | 0; d = e >>> 3; do if (e >>> 0 < 256) { b = c[j + 8 >> 2] | 0; a = c[j + 12 >> 2] | 0; if ((a | 0) == (b | 0)) { c[2783] = c[2783] & ~(1 << d); break; } else { c[b + 12 >> 2] = a; c[a + 8 >> 2] = b; break; } } else { g = c[j + 24 >> 2] | 0; a = c[j + 12 >> 2] | 0; do if ((a | 0) == (j | 0)) { d = j + 16 | 0; b = d + 4 | 0; a = c[b >> 2] | 0; if (!a) { a = c[d >> 2] | 0; if (!a) { d = 0; break; } else b = d; } while(true){ d = a + 20 | 0; e = c[d >> 2] | 0; if (e | 0) { a = e; b = d; continue; } d = a + 16 | 0; e = c[d >> 2] | 0; if (!e) break; else { a = e; b = d; } } c[b >> 2] = 0; d = a; } else { d = c[j + 8 >> 2] | 0; c[d + 12 >> 2] = a; c[a + 8 >> 2] = d; d = a; } while (0) if (g | 0) { a = c[j + 28 >> 2] | 0; b = 11436 + (a << 2) | 0; if ((j | 0) == (c[b >> 2] | 0)) { c[b >> 2] = d; if (!d) { c[2784] = c[2784] & ~(1 << a); break; } } else { c[g + 16 + (((c[g + 16 >> 2] | 0) != (j | 0) & 1) << 2) >> 2] = d; if (!d) break; } c[d + 24 >> 2] = g; a = j + 16 | 0; b = c[a >> 2] | 0; if (b | 0) { c[d + 16 >> 2] = b; c[b + 24 >> 2] = d; } a = c[a + 4 >> 2] | 0; if (a | 0) { c[d + 20 >> 2] = a; c[a + 24 >> 2] = d; } } } while (0) c[i + 4 >> 2] = f | 1; c[h + f >> 2] = f; if ((i | 0) == (c[2788] | 0)) { c[2785] = f; return; } } else { c[a >> 2] = e & -2; c[i + 4 >> 2] = b | 1; c[h + b >> 2] = b; f = b; } a = f >>> 3; if (f >>> 0 < 256) { d = 11172 + (a << 1 << 2) | 0; b = c[2783] | 0; a = 1 << a; if (!(b & a)) { c[2783] = b | a; a = d; b = d + 8 | 0; } else { b = d + 8 | 0; a = c[b >> 2] | 0; } c[b >> 2] = i; c[a + 12 >> 2] = i; c[i + 8 >> 2] = a; c[i + 12 >> 2] = d; return; } a = f >>> 8; if (a) { if (f >>> 0 > 16777215) a = 31; else { h = (a + 1048320 | 0) >>> 16 & 8; j = a << h; g = (j + 520192 | 0) >>> 16 & 4; j = j << g; a = (j + 245760 | 0) >>> 16 & 2; a = 14 - (g | h | a) + (j << a >>> 15) | 0; a = f >>> (a + 7 | 0) & 1 | a << 1; } } else a = 0; e = 11436 + (a << 2) | 0; c[i + 28 >> 2] = a; c[i + 20 >> 2] = 0; c[i + 16 >> 2] = 0; b = c[2784] | 0; d = 1 << a; do if (b & d) { b = f << ((a | 0) == 31 ? 0 : 25 - (a >>> 1) | 0); d = c[e >> 2] | 0; while(true){ if ((c[d + 4 >> 2] & -8 | 0) == (f | 0)) { a = 73; break; } e = d + 16 + (b >>> 31 << 2) | 0; a = c[e >> 2] | 0; if (!a) { a = 72; break; } else { b = b << 1; d = a; } } if ((a | 0) == 72) { c[e >> 2] = i; c[i + 24 >> 2] = d; c[i + 12 >> 2] = i; c[i + 8 >> 2] = i; break; } else if ((a | 0) == 73) { h = d + 8 | 0; j = c[h >> 2] | 0; c[j + 12 >> 2] = i; c[h >> 2] = i; c[i + 8 >> 2] = j; c[i + 12 >> 2] = d; c[i + 24 >> 2] = 0; break; } } else { c[2784] = b | d; c[e >> 2] = i; c[i + 24 >> 2] = e; c[i + 12 >> 2] = i; c[i + 8 >> 2] = i; } while (0) j = (c[2791] | 0) + -1 | 0; c[2791] = j; if (!j) a = 11588; else return; while(true){ a = c[a >> 2] | 0; if (!a) break; else a = a + 8 | 0; } c[2791] = -1; return; } function qB() { return 11628; } function rB(a) { a = a | 0; var b = 0, d = 0; b = l; l = l + 16 | 0; d = b; c[d >> 2] = yB(c[a + 60 >> 2] | 0) | 0; a = uB(db(6, d | 0) | 0) | 0; l = b; return a | 0; } function sB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0; n = l; l = l + 48 | 0; k = n + 16 | 0; g = n; f = n + 32 | 0; i = a + 28 | 0; e = c[i >> 2] | 0; c[f >> 2] = e; j = a + 20 | 0; e = (c[j >> 2] | 0) - e | 0; c[f + 4 >> 2] = e; c[f + 8 >> 2] = b; c[f + 12 >> 2] = d; e = e + d | 0; h = a + 60 | 0; c[g >> 2] = c[h >> 2]; c[g + 4 >> 2] = f; c[g + 8 >> 2] = 2; g = uB(gb(146, g | 0) | 0) | 0; a: do if ((e | 0) != (g | 0)) { b = 2; while(true){ if ((g | 0) < 0) break; e = e - g | 0; p = c[f + 4 >> 2] | 0; o = g >>> 0 > p >>> 0; f = o ? f + 8 | 0 : f; b = (o << 31 >> 31) + b | 0; p = g - (o ? p : 0) | 0; c[f >> 2] = (c[f >> 2] | 0) + p; o = f + 4 | 0; c[o >> 2] = (c[o >> 2] | 0) - p; c[k >> 2] = c[h >> 2]; c[k + 4 >> 2] = f; c[k + 8 >> 2] = b; g = uB(gb(146, k | 0) | 0) | 0; if ((e | 0) == (g | 0)) { m = 3; break a; } } c[a + 16 >> 2] = 0; c[i >> 2] = 0; c[j >> 2] = 0; c[a >> 2] = c[a >> 2] | 32; if ((b | 0) == 2) d = 0; else d = d - (c[f + 4 >> 2] | 0) | 0; } else m = 3; while (0) if ((m | 0) == 3) { p = c[a + 44 >> 2] | 0; c[a + 16 >> 2] = p + (c[a + 48 >> 2] | 0); c[i >> 2] = p; c[j >> 2] = p; } l = n; return d | 0; } function tB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0; f = l; l = l + 32 | 0; g = f; e = f + 20 | 0; c[g >> 2] = c[a + 60 >> 2]; c[g + 4 >> 2] = 0; c[g + 8 >> 2] = b; c[g + 12 >> 2] = e; c[g + 16 >> 2] = d; if ((uB(fb(140, g | 0) | 0) | 0) < 0) { c[e >> 2] = -1; a = -1; } else a = c[e >> 2] | 0; l = f; return a | 0; } function uB(a) { a = a | 0; if (a >>> 0 > 4294963200) { c[(vB() | 0) >> 2] = 0 - a; a = -1; } return a | 0; } function vB() { return (wB() | 0) + 64 | 0; } function wB() { return xB() | 0; } function xB() { return 2084; } function yB(a) { a = a | 0; return a | 0; } function zB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = l + 32 | 0; f = g; c[b + 36 >> 2] = 1; if ((c[b >> 2] & 64 | 0) == 0 ? (c[f >> 2] = c[b + 60 >> 2], c[f + 4 >> 2] = 21523, c[f + 8 >> 2] = g + 16, Wa(54, f | 0) | 0) : 0) a[b + 75 >> 0] = -1; f = sB(b, d, e) | 0; l = g; return f | 0; } function AB(b, c) { b = b | 0; c = c | 0; var d = 0, e = 0; d = a[b >> 0] | 0; e = a[c >> 0] | 0; if (d << 24 >> 24 == 0 ? 1 : d << 24 >> 24 != e << 24 >> 24) b = e; else { do { b = b + 1 | 0; c = c + 1 | 0; d = a[b >> 0] | 0; e = a[c >> 0] | 0; }while (!(d << 24 >> 24 == 0 ? 1 : d << 24 >> 24 != e << 24 >> 24)) b = e; } return (d & 255) - (b & 255) | 0; } function BB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0, f = 0; a: do if (!d) b = 0; else { while(true){ e = a[b >> 0] | 0; f = a[c >> 0] | 0; if (e << 24 >> 24 != f << 24 >> 24) break; d = d + -1 | 0; if (!d) { b = 0; break a; } else { b = b + 1 | 0; c = c + 1 | 0; } } b = (e & 255) - (f & 255) | 0; } while (0) return b | 0; } function CB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0; s = l; l = l + 224 | 0; n = s + 120 | 0; o = s + 80 | 0; q = s; r = s + 136 | 0; f = o; g = f + 40 | 0; do { c[f >> 2] = 0; f = f + 4 | 0; }while ((f | 0) < (g | 0)) c[n >> 2] = c[e >> 2]; if ((DB(0, d, n, q, o) | 0) < 0) e = -1; else { if ((c[b + 76 >> 2] | 0) > -1) p = EB(b) | 0; else p = 0; e = c[b >> 2] | 0; m = e & 32; if ((a[b + 74 >> 0] | 0) < 1) c[b >> 2] = e & -33; f = b + 48 | 0; if (!(c[f >> 2] | 0)) { g = b + 44 | 0; h = c[g >> 2] | 0; c[g >> 2] = r; i = b + 28 | 0; c[i >> 2] = r; j = b + 20 | 0; c[j >> 2] = r; c[f >> 2] = 80; k = b + 16 | 0; c[k >> 2] = r + 80; e = DB(b, d, n, q, o) | 0; if (h) { sb[c[b + 36 >> 2] & 7](b, 0, 0); e = (c[j >> 2] | 0) == 0 ? -1 : e; c[g >> 2] = h; c[f >> 2] = 0; c[k >> 2] = 0; c[i >> 2] = 0; c[j >> 2] = 0; } } else e = DB(b, d, n, q, o) | 0; f = c[b >> 2] | 0; c[b >> 2] = f | m; if (p | 0) FB(b); e = (f & 32 | 0) == 0 ? e : -1; } l = s; return e | 0; } function DB(d, e, f, g, i) { d = d | 0; e = e | 0; f = f | 0; g = g | 0; i = i | 0; var j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; H = l; l = l + 64 | 0; D = H + 16 | 0; E = H; B = H + 24 | 0; F = H + 8 | 0; G = H + 20 | 0; c[D >> 2] = e; x = (d | 0) != 0; y = B + 40 | 0; z = y; B = B + 39 | 0; C = F + 4 | 0; k = 0; j = 0; p = 0; a: while(true){ do if ((j | 0) > -1) { if ((k | 0) > (2147483647 - j | 0)) { c[(vB() | 0) >> 2] = 75; j = -1; break; } else { j = k + j | 0; break; } } while (0) k = a[e >> 0] | 0; if (!(k << 24 >> 24)) { w = 87; break; } else m = e; b: while(true){ switch(k << 24 >> 24){ case 37: k = m; w = 9; break b; case 0: k = m; break b; default: } v = m + 1 | 0; c[D >> 2] = v; k = a[v >> 0] | 0; m = v; } c: do if ((w | 0) == 9) while(true){ w = 0; if ((a[m + 1 >> 0] | 0) != 37) break c; k = k + 1 | 0; m = m + 2 | 0; c[D >> 2] = m; if ((a[m >> 0] | 0) == 37) w = 9; else break; } while (0) k = k - e | 0; if (x) GB(d, e, k); if (k | 0) { e = m; continue; } n = m + 1 | 0; k = (a[n >> 0] | 0) + -48 | 0; if (k >>> 0 < 10) { v = (a[m + 2 >> 0] | 0) == 36; u = v ? k : -1; p = v ? 1 : p; n = v ? m + 3 | 0 : n; } else u = -1; c[D >> 2] = n; k = a[n >> 0] | 0; m = (k << 24 >> 24) + -32 | 0; d: do if (m >>> 0 < 32) { o = 0; q = k; while(true){ k = 1 << m; if (!(k & 75913)) { k = q; break d; } o = k | o; n = n + 1 | 0; c[D >> 2] = n; k = a[n >> 0] | 0; m = (k << 24 >> 24) + -32 | 0; if (m >>> 0 >= 32) break; else q = k; } } else o = 0; while (0) if (k << 24 >> 24 == 42) { m = n + 1 | 0; k = (a[m >> 0] | 0) + -48 | 0; if (k >>> 0 < 10 ? (a[n + 2 >> 0] | 0) == 36 : 0) { c[i + (k << 2) >> 2] = 10; k = c[g + ((a[m >> 0] | 0) + -48 << 3) >> 2] | 0; p = 1; n = n + 3 | 0; } else { if (p | 0) { j = -1; break; } if (x) { p = (c[f >> 2] | 0) + 3 & -4; k = c[p >> 2] | 0; c[f >> 2] = p + 4; p = 0; n = m; } else { k = 0; p = 0; n = m; } } c[D >> 2] = n; v = (k | 0) < 0; k = v ? 0 - k | 0 : k; o = v ? o | 8192 : o; } else { k = HB(D) | 0; if ((k | 0) < 0) { j = -1; break; } n = c[D >> 2] | 0; } do if ((a[n >> 0] | 0) == 46) { if ((a[n + 1 >> 0] | 0) != 42) { c[D >> 2] = n + 1; m = HB(D) | 0; n = c[D >> 2] | 0; break; } q = n + 2 | 0; m = (a[q >> 0] | 0) + -48 | 0; if (m >>> 0 < 10 ? (a[n + 3 >> 0] | 0) == 36 : 0) { c[i + (m << 2) >> 2] = 10; m = c[g + ((a[q >> 0] | 0) + -48 << 3) >> 2] | 0; n = n + 4 | 0; c[D >> 2] = n; break; } if (p | 0) { j = -1; break a; } if (x) { v = (c[f >> 2] | 0) + 3 & -4; m = c[v >> 2] | 0; c[f >> 2] = v + 4; } else m = 0; c[D >> 2] = q; n = q; } else m = -1; while (0) t = 0; while(true){ if (((a[n >> 0] | 0) + -65 | 0) >>> 0 > 57) { j = -1; break a; } v = n + 1 | 0; c[D >> 2] = v; q = a[(a[n >> 0] | 0) + -65 + (5178 + (t * 58 | 0)) >> 0] | 0; r = q & 255; if ((r + -1 | 0) >>> 0 < 8) { t = r; n = v; } else break; } if (!(q << 24 >> 24)) { j = -1; break; } s = (u | 0) > -1; do if (q << 24 >> 24 == 19) { if (s) { j = -1; break a; } else w = 49; } else { if (s) { c[i + (u << 2) >> 2] = r; s = g + (u << 3) | 0; u = c[s + 4 >> 2] | 0; w = E; c[w >> 2] = c[s >> 2]; c[w + 4 >> 2] = u; w = 49; break; } if (!x) { j = 0; break a; } IB(E, r, f); } while (0) if ((w | 0) == 49 ? (w = 0, !x) : 0) { k = 0; e = v; continue; } n = a[n >> 0] | 0; n = (t | 0) != 0 & (n & 15 | 0) == 3 ? n & -33 : n; s = o & -65537; u = (o & 8192 | 0) == 0 ? o : s; e: do switch(n | 0){ case 110: switch((t & 255) << 24 >> 24){ case 0: c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; case 1: c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; case 2: k = c[E >> 2] | 0; c[k >> 2] = j; c[k + 4 >> 2] = ((j | 0) < 0) << 31 >> 31; k = 0; e = v; continue a; case 3: b[c[E >> 2] >> 1] = j; k = 0; e = v; continue a; case 4: a[c[E >> 2] >> 0] = j; k = 0; e = v; continue a; case 6: c[c[E >> 2] >> 2] = j; k = 0; e = v; continue a; case 7: k = c[E >> 2] | 0; c[k >> 2] = j; c[k + 4 >> 2] = ((j | 0) < 0) << 31 >> 31; k = 0; e = v; continue a; default: k = 0; e = v; continue a; } case 112: n = 120; m = m >>> 0 > 8 ? m : 8; e = u | 8; w = 61; break; case 88: case 120: e = u; w = 61; break; case 111: n = E; e = c[n >> 2] | 0; n = c[n + 4 >> 2] | 0; r = KB(e, n, y) | 0; s = z - r | 0; o = 0; q = 5642; m = (u & 8 | 0) == 0 | (m | 0) > (s | 0) ? m : s + 1 | 0; s = u; w = 67; break; case 105: case 100: n = E; e = c[n >> 2] | 0; n = c[n + 4 >> 2] | 0; if ((n | 0) < 0) { e = wC(0, 0, e | 0, n | 0) | 0; n = A; o = E; c[o >> 2] = e; c[o + 4 >> 2] = n; o = 1; q = 5642; w = 66; break e; } else { o = (u & 2049 | 0) != 0 & 1; q = (u & 2048 | 0) == 0 ? (u & 1 | 0) == 0 ? 5642 : 5644 : 5643; w = 66; break e; } case 117: n = E; o = 0; q = 5642; e = c[n >> 2] | 0; n = c[n + 4 >> 2] | 0; w = 66; break; case 99: a[B >> 0] = c[E >> 2]; e = B; o = 0; q = 5642; r = y; n = 1; m = s; break; case 109: n = MB(c[(vB() | 0) >> 2] | 0) | 0; w = 71; break; case 115: n = c[E >> 2] | 0; n = n | 0 ? n : 5652; w = 71; break; case 67: c[F >> 2] = c[E >> 2]; c[C >> 2] = 0; c[E >> 2] = F; r = -1; n = F; w = 75; break; case 83: e = c[E >> 2] | 0; if (!m) { OB(d, 32, k, 0, u); e = 0; w = 84; } else { r = m; n = e; w = 75; } break; case 65: case 71: case 70: case 69: case 97: case 103: case 102: case 101: k = QB(d, +h[E >> 3], k, m, u, n) | 0; e = v; continue a; default: o = 0; q = 5642; r = y; n = m; m = u; } while (0) f: do if ((w | 0) == 61) { u = E; t = c[u >> 2] | 0; u = c[u + 4 >> 2] | 0; r = JB(t, u, y, n & 32) | 0; q = (e & 8 | 0) == 0 | (t | 0) == 0 & (u | 0) == 0; o = q ? 0 : 2; q = q ? 5642 : 5642 + (n >> 4) | 0; s = e; e = t; n = u; w = 67; } else if ((w | 0) == 66) { r = LB(e, n, y) | 0; s = u; w = 67; } else if ((w | 0) == 71) { w = 0; u = NB(n, 0, m) | 0; t = (u | 0) == 0; e = n; o = 0; q = 5642; r = t ? n + m | 0 : u; n = t ? m : u - n | 0; m = s; } else if ((w | 0) == 75) { w = 0; q = n; e = 0; m = 0; while(true){ o = c[q >> 2] | 0; if (!o) break; m = PB(G, o) | 0; if ((m | 0) < 0 | m >>> 0 > (r - e | 0) >>> 0) break; e = m + e | 0; if (r >>> 0 > e >>> 0) q = q + 4 | 0; else break; } if ((m | 0) < 0) { j = -1; break a; } OB(d, 32, k, e, u); if (!e) { e = 0; w = 84; } else { o = 0; while(true){ m = c[n >> 2] | 0; if (!m) { w = 84; break f; } m = PB(G, m) | 0; o = m + o | 0; if ((o | 0) > (e | 0)) { w = 84; break f; } GB(d, G, m); if (o >>> 0 >= e >>> 0) { w = 84; break; } else n = n + 4 | 0; } } } while (0) if ((w | 0) == 67) { w = 0; n = (e | 0) != 0 | (n | 0) != 0; u = (m | 0) != 0 | n; n = ((n ^ 1) & 1) + (z - r) | 0; e = u ? r : y; r = y; n = u ? (m | 0) > (n | 0) ? m : n : m; m = (m | 0) > -1 ? s & -65537 : s; } else if ((w | 0) == 84) { w = 0; OB(d, 32, k, e, u ^ 8192); k = (k | 0) > (e | 0) ? k : e; e = v; continue; } t = r - e | 0; s = (n | 0) < (t | 0) ? t : n; u = s + o | 0; k = (k | 0) < (u | 0) ? u : k; OB(d, 32, k, u, m); GB(d, q, o); OB(d, 48, k, u, m ^ 65536); OB(d, 48, s, t, 0); GB(d, e, t); OB(d, 32, k, u, m ^ 8192); e = v; } g: do if ((w | 0) == 87) { if (!d) { if (!p) j = 0; else { j = 1; while(true){ e = c[i + (j << 2) >> 2] | 0; if (!e) break; IB(g + (j << 3) | 0, e, f); j = j + 1 | 0; if ((j | 0) >= 10) { j = 1; break g; } } while(true){ if (c[i + (j << 2) >> 2] | 0) { j = -1; break g; } j = j + 1 | 0; if ((j | 0) >= 10) { j = 1; break; } } } } } while (0) l = H; return j | 0; } function EB(a) { a = a | 0; return 0; } function FB(a) { a = a | 0; return; } function GB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; if (!(c[a >> 2] & 32)) aC(b, d, a); return; } function HB(b) { b = b | 0; var d = 0, e = 0, f = 0; e = c[b >> 2] | 0; f = (a[e >> 0] | 0) + -48 | 0; if (f >>> 0 < 10) { d = 0; do { d = f + (d * 10 | 0) | 0; e = e + 1 | 0; c[b >> 2] = e; f = (a[e >> 0] | 0) + -48 | 0; }while (f >>> 0 < 10) } else d = 0; return d | 0; } function IB(a, b, d) { a = a | 0; b = b | 0; d = d | 0; var e = 0, f = 0, g = 0.0; a: if (b >>> 0 <= 20) switch(b | 0){ case 9: e = (c[d >> 2] | 0) + 3 & -4; b = c[e >> 2] | 0; c[d >> 2] = e + 4; c[a >> 2] = b; break a; case 10: e = (c[d >> 2] | 0) + 3 & -4; b = c[e >> 2] | 0; c[d >> 2] = e + 4; e = a; c[e >> 2] = b; c[e + 4 >> 2] = ((b | 0) < 0) << 31 >> 31; break a; case 11: e = (c[d >> 2] | 0) + 3 & -4; b = c[e >> 2] | 0; c[d >> 2] = e + 4; e = a; c[e >> 2] = b; c[e + 4 >> 2] = 0; break a; case 12: e = (c[d >> 2] | 0) + 7 & -8; b = e; f = c[b >> 2] | 0; b = c[b + 4 >> 2] | 0; c[d >> 2] = e + 8; e = a; c[e >> 2] = f; c[e + 4 >> 2] = b; break a; case 13: f = (c[d >> 2] | 0) + 3 & -4; e = c[f >> 2] | 0; c[d >> 2] = f + 4; e = (e & 65535) << 16 >> 16; f = a; c[f >> 2] = e; c[f + 4 >> 2] = ((e | 0) < 0) << 31 >> 31; break a; case 14: f = (c[d >> 2] | 0) + 3 & -4; e = c[f >> 2] | 0; c[d >> 2] = f + 4; f = a; c[f >> 2] = e & 65535; c[f + 4 >> 2] = 0; break a; case 15: f = (c[d >> 2] | 0) + 3 & -4; e = c[f >> 2] | 0; c[d >> 2] = f + 4; e = (e & 255) << 24 >> 24; f = a; c[f >> 2] = e; c[f + 4 >> 2] = ((e | 0) < 0) << 31 >> 31; break a; case 16: f = (c[d >> 2] | 0) + 3 & -4; e = c[f >> 2] | 0; c[d >> 2] = f + 4; f = a; c[f >> 2] = e & 255; c[f + 4 >> 2] = 0; break a; case 17: f = (c[d >> 2] | 0) + 7 & -8; g = +h[f >> 3]; c[d >> 2] = f + 8; h[a >> 3] = g; break a; case 18: f = (c[d >> 2] | 0) + 7 & -8; g = +h[f >> 3]; c[d >> 2] = f + 8; h[a >> 3] = g; break a; default: break a; } return; } function JB(b, c, e, f) { b = b | 0; c = c | 0; e = e | 0; f = f | 0; if (!((b | 0) == 0 & (c | 0) == 0)) do { e = e + -1 | 0; a[e >> 0] = d[5694 + (b & 15) >> 0] | 0 | f; b = AC(b | 0, c | 0, 4) | 0; c = A; }while (!((b | 0) == 0 & (c | 0) == 0)) return e | 0; } function KB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; if (!((b | 0) == 0 & (c | 0) == 0)) do { d = d + -1 | 0; a[d >> 0] = b & 7 | 48; b = AC(b | 0, c | 0, 3) | 0; c = A; }while (!((b | 0) == 0 & (c | 0) == 0)) return d | 0; } function LB(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0; if (c >>> 0 > 0 | (c | 0) == 0 & b >>> 0 > 4294967295) { while(true){ e = HC(b | 0, c | 0, 10, 0) | 0; d = d + -1 | 0; a[d >> 0] = e & 255 | 48; e = b; b = EC(b | 0, c | 0, 10, 0) | 0; if (!(c >>> 0 > 9 | (c | 0) == 9 & e >>> 0 > 4294967295)) break; else c = A; } c = b; } else c = b; if (c) while(true){ d = d + -1 | 0; a[d >> 0] = (c >>> 0) % 10 | 48; if (c >>> 0 < 10) break; else c = (c >>> 0) / 10 | 0; } return d | 0; } function MB(a) { a = a | 0; return XB(a, c[(WB() | 0) + 188 >> 2] | 0) | 0; } function NB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = d & 255; f = (e | 0) != 0; a: do if (f & (b & 3 | 0) != 0) { g = d & 255; while(true){ if ((a[b >> 0] | 0) == g << 24 >> 24) { i = 6; break a; } b = b + 1 | 0; e = e + -1 | 0; f = (e | 0) != 0; if (!(f & (b & 3 | 0) != 0)) { i = 5; break; } } } else i = 5; while (0) if ((i | 0) == 5) { if (f) i = 6; else e = 0; } b: do if ((i | 0) == 6) { g = d & 255; if ((a[b >> 0] | 0) != g << 24 >> 24) { f = P(h, 16843009) | 0; c: do if (e >>> 0 > 3) while(true){ h = c[b >> 2] ^ f; if ((h & -2139062144 ^ -2139062144) & h + -16843009 | 0) break; b = b + 4 | 0; e = e + -4 | 0; if (e >>> 0 <= 3) { i = 11; break c; } } else i = 11; while (0) if ((i | 0) == 11) { if (!e) { e = 0; break; } } while(true){ if ((a[b >> 0] | 0) == g << 24 >> 24) break b; b = b + 1 | 0; e = e + -1 | 0; if (!e) { e = 0; break; } } } } while (0) return (e | 0 ? b : 0) | 0; } function OB(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = l + 256 | 0; f = g; if ((c | 0) > (d | 0) & (e & 73728 | 0) == 0) { e = c - d | 0; yC(f | 0, b | 0, (e >>> 0 < 256 ? e : 256) | 0); if (e >>> 0 > 255) { b = c - d | 0; do { GB(a, f, 256); e = e + -256 | 0; }while (e >>> 0 > 255) e = b & 255; } GB(a, f, e); } l = g; return; } function PB(a, b) { a = a | 0; b = b | 0; if (!a) a = 0; else a = UB(a, b, 0) | 0; return a | 0; } function QB(b, e, f, g, h, i) { b = b | 0; e = +e; f = f | 0; g = g | 0; h = h | 0; i = i | 0; var j = 0, k = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0.0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0; H = l; l = l + 560 | 0; m = H + 8 | 0; u = H; G = H + 524 | 0; F = G; n = H + 512 | 0; c[u >> 2] = 0; E = n + 12 | 0; RB(e); if ((A | 0) < 0) { e = -e; C = 1; B = 5659; } else { C = (h & 2049 | 0) != 0 & 1; B = (h & 2048 | 0) == 0 ? (h & 1 | 0) == 0 ? 5660 : 5665 : 5662; } RB(e); D = A & 2146435072; do if (D >>> 0 < 2146435072 | (D | 0) == 2146435072 & false) { r = +SB(e, u) * 2.0; j = r != 0.0; if (j) c[u >> 2] = (c[u >> 2] | 0) + -1; w = i | 32; if ((w | 0) == 97) { s = i & 32; q = (s | 0) == 0 ? B : B + 9 | 0; p = C | 2; j = 12 - g | 0; do if (!(g >>> 0 > 11 | (j | 0) == 0)) { e = 8.0; do { j = j + -1 | 0; e = e * 16.0; }while ((j | 0) != 0) if ((a[q >> 0] | 0) == 45) { e = -(e + (-r - e)); break; } else { e = r + e - e; break; } } else e = r; while (0) k = c[u >> 2] | 0; j = (k | 0) < 0 ? 0 - k | 0 : k; j = LB(j, ((j | 0) < 0) << 31 >> 31, E) | 0; if ((j | 0) == (E | 0)) { j = n + 11 | 0; a[j >> 0] = 48; } a[j + -1 >> 0] = (k >> 31 & 2) + 43; o = j + -2 | 0; a[o >> 0] = i + 15; n = (g | 0) < 1; m = (h & 8 | 0) == 0; j = G; do { D = ~~e; k = j + 1 | 0; a[j >> 0] = d[5694 + D >> 0] | s; e = (e - +(D | 0)) * 16.0; if ((k - F | 0) == 1 ? !(m & (n & e == 0.0)) : 0) { a[k >> 0] = 46; j = j + 2 | 0; } else j = k; }while (e != 0.0) D = j - F | 0; F = E - o | 0; E = (g | 0) != 0 & (D + -2 | 0) < (g | 0) ? g + 2 | 0 : D; j = F + p + E | 0; OB(b, 32, f, j, h); GB(b, q, p); OB(b, 48, f, j, h ^ 65536); GB(b, G, D); OB(b, 48, E - D | 0, 0, 0); GB(b, o, F); OB(b, 32, f, j, h ^ 8192); break; } k = (g | 0) < 0 ? 6 : g; if (j) { j = (c[u >> 2] | 0) + -28 | 0; c[u >> 2] = j; e = r * 268435456.0; } else { e = r; j = c[u >> 2] | 0; } D = (j | 0) < 0 ? m : m + 288 | 0; m = D; do { y = ~~e >>> 0; c[m >> 2] = y; m = m + 4 | 0; e = (e - +(y >>> 0)) * 1.0e9; }while (e != 0.0) if ((j | 0) > 0) { n = D; p = m; while(true){ o = (j | 0) < 29 ? j : 29; j = p + -4 | 0; if (j >>> 0 >= n >>> 0) { m = 0; do { x = zC(c[j >> 2] | 0, 0, o | 0) | 0; x = xC(x | 0, A | 0, m | 0, 0) | 0; y = A; v = HC(x | 0, y | 0, 1e9, 0) | 0; c[j >> 2] = v; m = EC(x | 0, y | 0, 1e9, 0) | 0; j = j + -4 | 0; }while (j >>> 0 >= n >>> 0) if (m) { n = n + -4 | 0; c[n >> 2] = m; } } m = p; while(true){ if (m >>> 0 <= n >>> 0) break; j = m + -4 | 0; if (!(c[j >> 2] | 0)) m = j; else break; } j = (c[u >> 2] | 0) - o | 0; c[u >> 2] = j; if ((j | 0) > 0) p = m; else break; } } else n = D; if ((j | 0) < 0) { g = ((k + 25 | 0) / 9 | 0) + 1 | 0; t = (w | 0) == 102; do { s = 0 - j | 0; s = (s | 0) < 9 ? s : 9; if (n >>> 0 < m >>> 0) { o = (1 << s) + -1 | 0; p = 1e9 >>> s; q = 0; j = n; do { y = c[j >> 2] | 0; c[j >> 2] = (y >>> s) + q; q = P(y & o, p) | 0; j = j + 4 | 0; }while (j >>> 0 < m >>> 0) j = (c[n >> 2] | 0) == 0 ? n + 4 | 0 : n; if (!q) { n = j; j = m; } else { c[m >> 2] = q; n = j; j = m + 4 | 0; } } else { n = (c[n >> 2] | 0) == 0 ? n + 4 | 0 : n; j = m; } m = t ? D : n; m = (j - m >> 2 | 0) > (g | 0) ? m + (g << 2) | 0 : j; j = (c[u >> 2] | 0) + s | 0; c[u >> 2] = j; }while ((j | 0) < 0) j = n; g = m; } else { j = n; g = m; } y = D; if (j >>> 0 < g >>> 0) { m = (y - j >> 2) * 9 | 0; o = c[j >> 2] | 0; if (o >>> 0 >= 10) { n = 10; do { n = n * 10 | 0; m = m + 1 | 0; }while (o >>> 0 >= n >>> 0) } } else m = 0; t = (w | 0) == 103; v = (k | 0) != 0; n = k - ((w | 0) != 102 ? m : 0) + ((v & t) << 31 >> 31) | 0; if ((n | 0) < (((g - y >> 2) * 9 | 0) + -9 | 0)) { n = n + 9216 | 0; s = D + 4 + (((n | 0) / 9 | 0) + -1024 << 2) | 0; n = ((n | 0) % 9 | 0) + 1 | 0; if ((n | 0) < 9) { o = 10; do { o = o * 10 | 0; n = n + 1 | 0; }while ((n | 0) != 9) } else o = 10; p = c[s >> 2] | 0; q = (p >>> 0) % (o >>> 0) | 0; n = (s + 4 | 0) == (g | 0); if (!(n & (q | 0) == 0)) { r = (((p >>> 0) / (o >>> 0) | 0) & 1 | 0) == 0 ? 9007199254740992.0 : 9007199254740994.0; x = (o | 0) / 2 | 0; e = q >>> 0 < x >>> 0 ? 0.5 : n & (q | 0) == (x | 0) ? 1.0 : 1.5; if (C) { x = (a[B >> 0] | 0) == 45; e = x ? -e : e; r = x ? -r : r; } n = p - q | 0; c[s >> 2] = n; if (r + e != r) { x = n + o | 0; c[s >> 2] = x; if (x >>> 0 > 999999999) { m = s; while(true){ n = m + -4 | 0; c[m >> 2] = 0; if (n >>> 0 < j >>> 0) { j = j + -4 | 0; c[j >> 2] = 0; } x = (c[n >> 2] | 0) + 1 | 0; c[n >> 2] = x; if (x >>> 0 > 999999999) m = n; else break; } } else n = s; m = (y - j >> 2) * 9 | 0; p = c[j >> 2] | 0; if (p >>> 0 >= 10) { o = 10; do { o = o * 10 | 0; m = m + 1 | 0; }while (p >>> 0 >= o >>> 0) } } else n = s; } else n = s; n = n + 4 | 0; n = g >>> 0 > n >>> 0 ? n : g; x = j; } else { n = g; x = j; } w = n; while(true){ if (w >>> 0 <= x >>> 0) { u = 0; break; } j = w + -4 | 0; if (!(c[j >> 2] | 0)) w = j; else { u = 1; break; } } g = 0 - m | 0; do if (t) { j = ((v ^ 1) & 1) + k | 0; if ((j | 0) > (m | 0) & (m | 0) > -5) { o = i + -1 | 0; k = j + -1 - m | 0; } else { o = i + -2 | 0; k = j + -1 | 0; } j = h & 8; if (!j) { if (u ? (z = c[w + -4 >> 2] | 0, (z | 0) != 0) : 0) { if (!((z >>> 0) % 10 | 0)) { n = 0; j = 10; do { j = j * 10 | 0; n = n + 1 | 0; }while (!((z >>> 0) % (j >>> 0) | 0)) } else n = 0; } else n = 9; j = ((w - y >> 2) * 9 | 0) + -9 | 0; if ((o | 32) == 102) { s = j - n | 0; s = (s | 0) > 0 ? s : 0; k = (k | 0) < (s | 0) ? k : s; s = 0; break; } else { s = j + m - n | 0; s = (s | 0) > 0 ? s : 0; k = (k | 0) < (s | 0) ? k : s; s = 0; break; } } else s = j; } else { o = i; s = h & 8; } while (0) t = k | s; p = (t | 0) != 0 & 1; q = (o | 32) == 102; if (q) { v = 0; j = (m | 0) > 0 ? m : 0; } else { j = (m | 0) < 0 ? g : m; j = LB(j, ((j | 0) < 0) << 31 >> 31, E) | 0; n = E; if ((n - j | 0) < 2) do { j = j + -1 | 0; a[j >> 0] = 48; }while ((n - j | 0) < 2) a[j + -1 >> 0] = (m >> 31 & 2) + 43; j = j + -2 | 0; a[j >> 0] = o; v = j; j = n - j | 0; } j = C + 1 + k + p + j | 0; OB(b, 32, f, j, h); GB(b, B, C); OB(b, 48, f, j, h ^ 65536); if (q) { o = x >>> 0 > D >>> 0 ? D : x; s = G + 9 | 0; p = s; q = G + 8 | 0; n = o; do { m = LB(c[n >> 2] | 0, 0, s) | 0; if ((n | 0) == (o | 0)) { if ((m | 0) == (s | 0)) { a[q >> 0] = 48; m = q; } } else if (m >>> 0 > G >>> 0) { yC(G | 0, 48, m - F | 0); do m = m + -1 | 0; while (m >>> 0 > G >>> 0) } GB(b, m, p - m | 0); n = n + 4 | 0; }while (n >>> 0 <= D >>> 0) if (t | 0) GB(b, 5710, 1); if (n >>> 0 < w >>> 0 & (k | 0) > 0) while(true){ m = LB(c[n >> 2] | 0, 0, s) | 0; if (m >>> 0 > G >>> 0) { yC(G | 0, 48, m - F | 0); do m = m + -1 | 0; while (m >>> 0 > G >>> 0) } GB(b, m, (k | 0) < 9 ? k : 9); n = n + 4 | 0; m = k + -9 | 0; if (!(n >>> 0 < w >>> 0 & (k | 0) > 9)) { k = m; break; } else k = m; } OB(b, 48, k + 9 | 0, 9, 0); } else { t = u ? w : x + 4 | 0; if ((k | 0) > -1) { u = G + 9 | 0; s = (s | 0) == 0; g = u; p = 0 - F | 0; q = G + 8 | 0; o = x; do { m = LB(c[o >> 2] | 0, 0, u) | 0; if ((m | 0) == (u | 0)) { a[q >> 0] = 48; m = q; } do if ((o | 0) == (x | 0)) { n = m + 1 | 0; GB(b, m, 1); if (s & (k | 0) < 1) { m = n; break; } GB(b, 5710, 1); m = n; } else { if (m >>> 0 <= G >>> 0) break; yC(G | 0, 48, m + p | 0); do m = m + -1 | 0; while (m >>> 0 > G >>> 0) } while (0) F = g - m | 0; GB(b, m, (k | 0) > (F | 0) ? F : k); k = k - F | 0; o = o + 4 | 0; }while (o >>> 0 < t >>> 0 & (k | 0) > -1) } OB(b, 48, k + 18 | 0, 18, 0); GB(b, v, E - v | 0); } OB(b, 32, f, j, h ^ 8192); } else { G = (i & 32 | 0) != 0; j = C + 3 | 0; OB(b, 32, f, j, h & -65537); GB(b, B, C); GB(b, e != e | false ? G ? 5686 : 5690 : G ? 5678 : 5682, 3); OB(b, 32, f, j, h ^ 8192); } while (0) l = H; return ((j | 0) < (f | 0) ? f : j) | 0; } function RB(a) { a = +a; var b = 0; h[j >> 3] = a; b = c[j >> 2] | 0; A = c[j + 4 >> 2] | 0; return b | 0; } function SB(a, b) { a = +a; b = b | 0; return + +TB(a, b); } function TB(a, b) { a = +a; b = b | 0; var d = 0, e = 0, f = 0; h[j >> 3] = a; d = c[j >> 2] | 0; e = c[j + 4 >> 2] | 0; f = AC(d | 0, e | 0, 52) | 0; switch(f & 2047){ case 0: if (a != 0.0) { a = +TB(a * 18446744073709551616.0, b); d = (c[b >> 2] | 0) + -64 | 0; } else d = 0; c[b >> 2] = d; break; case 2047: break; default: c[b >> 2] = (f & 2047) + -1022; c[j >> 2] = d; c[j + 4 >> 2] = e & -2146435073 | 1071644672; a = +h[j >> 3]; } return +a; } function UB(b, d, e) { b = b | 0; d = d | 0; e = e | 0; do if (b) { if (d >>> 0 < 128) { a[b >> 0] = d; b = 1; break; } if (!(c[c[(VB() | 0) + 188 >> 2] >> 2] | 0)) { if ((d & -128 | 0) == 57216) { a[b >> 0] = d; b = 1; break; } else { c[(vB() | 0) >> 2] = 84; b = -1; break; } } if (d >>> 0 < 2048) { a[b >> 0] = d >>> 6 | 192; a[b + 1 >> 0] = d & 63 | 128; b = 2; break; } if (d >>> 0 < 55296 | (d & -8192 | 0) == 57344) { a[b >> 0] = d >>> 12 | 224; a[b + 1 >> 0] = d >>> 6 & 63 | 128; a[b + 2 >> 0] = d & 63 | 128; b = 3; break; } if ((d + -65536 | 0) >>> 0 < 1048576) { a[b >> 0] = d >>> 18 | 240; a[b + 1 >> 0] = d >>> 12 & 63 | 128; a[b + 2 >> 0] = d >>> 6 & 63 | 128; a[b + 3 >> 0] = d & 63 | 128; b = 4; break; } else { c[(vB() | 0) >> 2] = 84; b = -1; break; } } else b = 1; while (0) return b | 0; } function VB() { return xB() | 0; } function WB() { return xB() | 0; } function XB(b, e) { b = b | 0; e = e | 0; var f = 0, g = 0; g = 0; while(true){ if ((d[5712 + g >> 0] | 0) == (b | 0)) { b = 2; break; } f = g + 1 | 0; if ((f | 0) == 87) { f = 5800; g = 87; b = 5; break; } else g = f; } if ((b | 0) == 2) { if (!g) f = 5800; else { f = 5800; b = 5; } } if ((b | 0) == 5) while(true){ do { b = f; f = f + 1 | 0; }while ((a[b >> 0] | 0) != 0) g = g + -1 | 0; if (!g) break; else b = 5; } return YB(f, c[e + 20 >> 2] | 0) | 0; } function YB(a, b) { a = a | 0; b = b | 0; return ZB(a, b) | 0; } function ZB(a, b) { a = a | 0; b = b | 0; if (!b) b = 0; else b = _B(c[b >> 2] | 0, c[b + 4 >> 2] | 0, a) | 0; return (b | 0 ? b : a) | 0; } function _B(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0; o = (c[b >> 2] | 0) + 1794895138 | 0; h = $B(c[b + 8 >> 2] | 0, o) | 0; f = $B(c[b + 12 >> 2] | 0, o) | 0; g = $B(c[b + 16 >> 2] | 0, o) | 0; a: do if ((h >>> 0 < d >>> 2 >>> 0 ? (n = d - (h << 2) | 0, f >>> 0 < n >>> 0 & g >>> 0 < n >>> 0) : 0) ? ((g | f) & 3 | 0) == 0 : 0) { n = f >>> 2; m = g >>> 2; l = 0; while(true){ j = h >>> 1; k = l + j | 0; i = k << 1; g = i + n | 0; f = $B(c[b + (g << 2) >> 2] | 0, o) | 0; g = $B(c[b + (g + 1 << 2) >> 2] | 0, o) | 0; if (!(g >>> 0 < d >>> 0 & f >>> 0 < (d - g | 0) >>> 0)) { f = 0; break a; } if (a[b + (g + f) >> 0] | 0) { f = 0; break a; } f = AB(e, b + g | 0) | 0; if (!f) break; f = (f | 0) < 0; if ((h | 0) == 1) { f = 0; break a; } else { l = f ? l : k; h = f ? j : h - j | 0; } } f = i + m | 0; g = $B(c[b + (f << 2) >> 2] | 0, o) | 0; f = $B(c[b + (f + 1 << 2) >> 2] | 0, o) | 0; if (f >>> 0 < d >>> 0 & g >>> 0 < (d - f | 0) >>> 0) f = (a[b + (f + g) >> 0] | 0) == 0 ? b + f | 0 : 0; else f = 0; } else f = 0; while (0) return f | 0; } function $B(a, b) { a = a | 0; b = b | 0; var c = 0; c = IC(a | 0) | 0; return ((b | 0) == 0 ? a : c) | 0; } function aC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0, j = 0; f = e + 16 | 0; g = c[f >> 2] | 0; if (!g) { if (!(bC(e) | 0)) { g = c[f >> 2] | 0; h = 5; } else f = 0; } else h = 5; a: do if ((h | 0) == 5) { j = e + 20 | 0; i = c[j >> 2] | 0; f = i; if ((g - i | 0) >>> 0 < d >>> 0) { f = sb[c[e + 36 >> 2] & 7](e, b, d) | 0; break; } b: do if ((a[e + 75 >> 0] | 0) > -1) { i = d; while(true){ if (!i) { h = 0; g = b; break b; } g = i + -1 | 0; if ((a[b + g >> 0] | 0) == 10) break; else i = g; } f = sb[c[e + 36 >> 2] & 7](e, b, i) | 0; if (f >>> 0 < i >>> 0) break a; h = i; g = b + i | 0; d = d - i | 0; f = c[j >> 2] | 0; } else { h = 0; g = b; } while (0) BC(f | 0, g | 0, d | 0); c[j >> 2] = (c[j >> 2] | 0) + d; f = h + d | 0; } while (0) return f | 0; } function bC(b) { b = b | 0; var d = 0, e = 0; d = b + 74 | 0; e = a[d >> 0] | 0; a[d >> 0] = e + 255 | e; d = c[b >> 2] | 0; if (!(d & 8)) { c[b + 8 >> 2] = 0; c[b + 4 >> 2] = 0; e = c[b + 44 >> 2] | 0; c[b + 28 >> 2] = e; c[b + 20 >> 2] = e; c[b + 16 >> 2] = e + (c[b + 48 >> 2] | 0); b = 0; } else { c[b >> 2] = d | 32; b = -1; } return b | 0; } function cC(a, b) { a = T(a); b = T(b); var c = 0, d = 0; c = dC(a) | 0; do if ((c & 2147483647) >>> 0 <= 2139095040) { d = dC(b) | 0; if ((d & 2147483647) >>> 0 <= 2139095040) { if ((d ^ c | 0) < 0) { a = (c | 0) < 0 ? b : a; break; } else { a = a < b ? b : a; break; } } } else a = b; while (0) return T(a); } function dC(a) { a = T(a); return (g[j >> 2] = a, c[j >> 2] | 0) | 0; } function eC(a, b) { a = T(a); b = T(b); var c = 0, d = 0; c = fC(a) | 0; do if ((c & 2147483647) >>> 0 <= 2139095040) { d = fC(b) | 0; if ((d & 2147483647) >>> 0 <= 2139095040) { if ((d ^ c | 0) < 0) { a = (c | 0) < 0 ? a : b; break; } else { a = a < b ? a : b; break; } } } else a = b; while (0) return T(a); } function fC(a) { a = T(a); return (g[j >> 2] = a, c[j >> 2] | 0) | 0; } function gC(a, b) { a = T(a); b = T(b); var d = 0, e = 0, f = 0, h = 0, i = 0, k = 0, l = 0, m = 0; h = (g[j >> 2] = a, c[j >> 2] | 0); k = (g[j >> 2] = b, c[j >> 2] | 0); d = h >>> 23 & 255; i = k >>> 23 & 255; l = h & -2147483648; f = k << 1; a: do if ((f | 0) != 0 ? !((d | 0) == 255 | ((hC(b) | 0) & 2147483647) >>> 0 > 2139095040) : 0) { e = h << 1; if (e >>> 0 <= f >>> 0) { b = T(a * T(0.0)); return T((e | 0) == (f | 0) ? b : a); } if (!d) { d = h << 9; if ((d | 0) > -1) { e = d; d = 0; do { d = d + -1 | 0; e = e << 1; }while ((e | 0) > -1) } else d = 0; e = h << 1 - d; } else e = h & 8388607 | 8388608; if (!i) { h = k << 9; if ((h | 0) > -1) { f = 0; do { f = f + -1 | 0; h = h << 1; }while ((h | 0) > -1) } else f = 0; i = f; k = k << 1 - f; } else k = k & 8388607 | 8388608; f = e - k | 0; h = (f | 0) > -1; b: do if ((d | 0) > (i | 0)) { while(true){ if (h) { if (!f) break; else e = f; } e = e << 1; d = d + -1 | 0; f = e - k | 0; h = (f | 0) > -1; if ((d | 0) <= (i | 0)) break b; } b = T(a * T(0.0)); break a; } while (0) if (h) { if (!f) { b = T(a * T(0.0)); break; } else e = f; } if (e >>> 0 < 8388608) do { e = e << 1; d = d + -1 | 0; }while (e >>> 0 < 8388608) if ((d | 0) > 0) d = e + -8388608 | d << 23; else d = e >>> (1 - d | 0); b = (c[j >> 2] = d | l, T(g[j >> 2])); } else m = 3; while (0) if ((m | 0) == 3) { b = T(a * b); b = T(b / b); } return T(b); } function hC(a) { a = T(a); return (g[j >> 2] = a, c[j >> 2] | 0) | 0; } function iC(a, b) { a = a | 0; b = b | 0; return CB(c[582] | 0, a, b) | 0; } function jC(a) { a = a | 0; Ta(); } function kC(a) { a = a | 0; return; } function lC(a, b) { a = a | 0; b = b | 0; return 0; } function mC(a) { a = a | 0; if ((nC(a + 4 | 0) | 0) == -1) { nb[c[(c[a >> 2] | 0) + 8 >> 2] & 127](a); a = 1; } else a = 0; return a | 0; } function nC(a) { a = a | 0; var b = 0; b = c[a >> 2] | 0; c[a >> 2] = b + -1; return b + -1 | 0; } function oC(a) { a = a | 0; if (mC(a) | 0) pC(a); return; } function pC(a) { a = a | 0; var b = 0; b = a + 8 | 0; if (!((c[b >> 2] | 0) != 0 ? (nC(b) | 0) != -1 : 0)) nb[c[(c[a >> 2] | 0) + 16 >> 2] & 127](a); return; } function qC(a) { a = a | 0; var b = 0; b = (a | 0) == 0 ? 1 : a; while(true){ a = oB(b) | 0; if (a | 0) break; a = uC() | 0; if (!a) { a = 0; break; } Fb[a & 0](); } return a | 0; } function rC(a) { a = a | 0; return qC(a) | 0; } function sC(a) { a = a | 0; pB(a); return; } function tC(b) { b = b | 0; if ((a[b + 11 >> 0] | 0) < 0) sC(c[b >> 2] | 0); return; } function uC() { var a = 0; a = c[2923] | 0; c[2923] = a + 0; return a | 0; } function vC() {} function wC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; d = b - d - (c >>> 0 > a >>> 0 | 0) >>> 0; return (A = d, a - c >>> 0 | 0) | 0; } function xC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; c = a + c >>> 0; return (A = b + d + (c >>> 0 < a >>> 0 | 0) >>> 0, c | 0) | 0; } function yC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0, i = 0; h = b + e | 0; d = d & 255; if ((e | 0) >= 67) { while(b & 3){ a[b >> 0] = d; b = b + 1 | 0; } f = h & -4 | 0; g = f - 64 | 0; i = d | d << 8 | d << 16 | d << 24; while((b | 0) <= (g | 0)){ c[b >> 2] = i; c[b + 4 >> 2] = i; c[b + 8 >> 2] = i; c[b + 12 >> 2] = i; c[b + 16 >> 2] = i; c[b + 20 >> 2] = i; c[b + 24 >> 2] = i; c[b + 28 >> 2] = i; c[b + 32 >> 2] = i; c[b + 36 >> 2] = i; c[b + 40 >> 2] = i; c[b + 44 >> 2] = i; c[b + 48 >> 2] = i; c[b + 52 >> 2] = i; c[b + 56 >> 2] = i; c[b + 60 >> 2] = i; b = b + 64 | 0; } while((b | 0) < (f | 0)){ c[b >> 2] = i; b = b + 4 | 0; } } while((b | 0) < (h | 0)){ a[b >> 0] = d; b = b + 1 | 0; } return h - e | 0; } function zC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; if ((c | 0) < 32) { A = b << c | (a & (1 << c) - 1 << 32 - c) >>> 32 - c; return a << c; } A = a << c - 32; return 0; } function AC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; if ((c | 0) < 32) { A = b >>> c; return a >>> c | (b & (1 << c) - 1) << 32 - c; } A = 0; return b >>> c - 32 | 0; } function BC(b, d, e) { b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0, h = 0; if ((e | 0) >= 8192) return Oa(b | 0, d | 0, e | 0) | 0; h = b | 0; g = b + e | 0; if ((b & 3) == (d & 3)) { while(b & 3){ if (!e) return h | 0; a[b >> 0] = a[d >> 0] | 0; b = b + 1 | 0; d = d + 1 | 0; e = e - 1 | 0; } e = g & -4 | 0; f = e - 64 | 0; while((b | 0) <= (f | 0)){ c[b >> 2] = c[d >> 2]; c[b + 4 >> 2] = c[d + 4 >> 2]; c[b + 8 >> 2] = c[d + 8 >> 2]; c[b + 12 >> 2] = c[d + 12 >> 2]; c[b + 16 >> 2] = c[d + 16 >> 2]; c[b + 20 >> 2] = c[d + 20 >> 2]; c[b + 24 >> 2] = c[d + 24 >> 2]; c[b + 28 >> 2] = c[d + 28 >> 2]; c[b + 32 >> 2] = c[d + 32 >> 2]; c[b + 36 >> 2] = c[d + 36 >> 2]; c[b + 40 >> 2] = c[d + 40 >> 2]; c[b + 44 >> 2] = c[d + 44 >> 2]; c[b + 48 >> 2] = c[d + 48 >> 2]; c[b + 52 >> 2] = c[d + 52 >> 2]; c[b + 56 >> 2] = c[d + 56 >> 2]; c[b + 60 >> 2] = c[d + 60 >> 2]; b = b + 64 | 0; d = d + 64 | 0; } while((b | 0) < (e | 0)){ c[b >> 2] = c[d >> 2]; b = b + 4 | 0; d = d + 4 | 0; } } else { e = g - 4 | 0; while((b | 0) < (e | 0)){ a[b >> 0] = a[d >> 0] | 0; a[b + 1 >> 0] = a[d + 1 >> 0] | 0; a[b + 2 >> 0] = a[d + 2 >> 0] | 0; a[b + 3 >> 0] = a[d + 3 >> 0] | 0; b = b + 4 | 0; d = d + 4 | 0; } } while((b | 0) < (g | 0)){ a[b >> 0] = a[d >> 0] | 0; b = b + 1 | 0; d = d + 1 | 0; } return h | 0; } function CC(b) { b = b | 0; var c = 0; c = a[n + (b & 255) >> 0] | 0; if ((c | 0) < 8) return c | 0; c = a[n + (b >> 8 & 255) >> 0] | 0; if ((c | 0) < 8) return c + 8 | 0; c = a[n + (b >> 16 & 255) >> 0] | 0; if ((c | 0) < 8) return c + 16 | 0; return (a[n + (b >>> 24) >> 0] | 0) + 24 | 0; } function DC(a, b, d, e, f) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; f = f | 0; var g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0, p = 0; l = a; j = b; k = j; h = d; n = e; i = n; if (!k) { g = (f | 0) != 0; if (!i) { if (g) { c[f >> 2] = (l >>> 0) % (h >>> 0); c[f + 4 >> 2] = 0; } n = 0; f = (l >>> 0) / (h >>> 0) >>> 0; return (A = n, f) | 0; } else { if (!g) { n = 0; f = 0; return (A = n, f) | 0; } c[f >> 2] = a | 0; c[f + 4 >> 2] = b & 0; n = 0; f = 0; return (A = n, f) | 0; } } g = (i | 0) == 0; do if (h) { if (!g) { g = (S(i | 0) | 0) - (S(k | 0) | 0) | 0; if (g >>> 0 <= 31) { m = g + 1 | 0; i = 31 - g | 0; b = g - 31 >> 31; h = m; a = l >>> (m >>> 0) & b | k << i; b = k >>> (m >>> 0) & b; g = 0; i = l << i; break; } if (!f) { n = 0; f = 0; return (A = n, f) | 0; } c[f >> 2] = a | 0; c[f + 4 >> 2] = j | b & 0; n = 0; f = 0; return (A = n, f) | 0; } g = h - 1 | 0; if (g & h | 0) { i = (S(h | 0) | 0) + 33 - (S(k | 0) | 0) | 0; p = 64 - i | 0; m = 32 - i | 0; j = m >> 31; o = i - 32 | 0; b = o >> 31; h = i; a = m - 1 >> 31 & k >>> (o >>> 0) | (k << m | l >>> (i >>> 0)) & b; b = b & k >>> (i >>> 0); g = l << p & j; i = (k << p | l >>> (o >>> 0)) & j | l << m & i - 33 >> 31; break; } if (f | 0) { c[f >> 2] = g & l; c[f + 4 >> 2] = 0; } if ((h | 0) == 1) { o = j | b & 0; p = a | 0; return (A = o, p) | 0; } else { p = CC(h | 0) | 0; o = k >>> (p >>> 0) | 0; p = k << 32 - p | l >>> (p >>> 0) | 0; return (A = o, p) | 0; } } else { if (g) { if (f | 0) { c[f >> 2] = (k >>> 0) % (h >>> 0); c[f + 4 >> 2] = 0; } o = 0; p = (k >>> 0) / (h >>> 0) >>> 0; return (A = o, p) | 0; } if (!l) { if (f | 0) { c[f >> 2] = 0; c[f + 4 >> 2] = (k >>> 0) % (i >>> 0); } o = 0; p = (k >>> 0) / (i >>> 0) >>> 0; return (A = o, p) | 0; } g = i - 1 | 0; if (!(g & i)) { if (f | 0) { c[f >> 2] = a | 0; c[f + 4 >> 2] = g & k | b & 0; } o = 0; p = k >>> ((CC(i | 0) | 0) >>> 0); return (A = o, p) | 0; } g = (S(i | 0) | 0) - (S(k | 0) | 0) | 0; if (g >>> 0 <= 30) { b = g + 1 | 0; i = 31 - g | 0; h = b; a = k << i | l >>> (b >>> 0); b = k >>> (b >>> 0); g = 0; i = l << i; break; } if (!f) { o = 0; p = 0; return (A = o, p) | 0; } c[f >> 2] = a | 0; c[f + 4 >> 2] = j | b & 0; o = 0; p = 0; return (A = o, p) | 0; } while (0) if (!h) { k = i; j = 0; i = 0; } else { m = d | 0; l = n | e & 0; k = xC(m | 0, l | 0, -1, -1) | 0; d = A; j = i; i = 0; do { e = j; j = g >>> 31 | j << 1; g = i | g << 1; e = a << 1 | e >>> 31 | 0; n = a >>> 31 | b << 1 | 0; wC(k | 0, d | 0, e | 0, n | 0); p = A; o = p >> 31 | ((p | 0) < 0 ? -1 : 0) << 1; i = o & 1; a = wC(e | 0, n | 0, o & m | 0, (((p | 0) < 0 ? -1 : 0) >> 31 | ((p | 0) < 0 ? -1 : 0) << 1) & l | 0) | 0; b = A; h = h - 1 | 0; }while ((h | 0) != 0) k = j; j = 0; } h = 0; if (f | 0) { c[f >> 2] = a; c[f + 4 >> 2] = b; } o = (g | 0) >>> 31 | (k | h) << 1 | (h << 1 | g >>> 31) & 0 | j; p = (g << 1 | 0) & -2 | i; return (A = o, p) | 0; } function EC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return DC(a, b, c, d, 0) | 0; } function FC(a) { a = a | 0; var b = 0, d = 0; d = a + 15 & -16 | 0; b = c[i >> 2] | 0; a = b + d | 0; if ((d | 0) > 0 & (a | 0) < (b | 0) | (a | 0) < 0) { Y(); Qa(12); return -1; } c[i >> 2] = a; if ((a | 0) > (X() | 0) ? (W() | 0) == 0 : 0) { c[i >> 2] = b; Qa(12); return -1; } return b | 0; } function GC(b, c, d) { b = b | 0; c = c | 0; d = d | 0; var e = 0; if ((c | 0) < (b | 0) & (b | 0) < (c + d | 0)) { e = b; c = c + d | 0; b = b + d | 0; while((d | 0) > 0){ b = b - 1 | 0; c = c - 1 | 0; d = d - 1 | 0; a[b >> 0] = a[c >> 0] | 0; } b = e; } else BC(b, c, d); return b | 0; } function HC(a, b, d, e) { a = a | 0; b = b | 0; d = d | 0; e = e | 0; var f = 0, g = 0; g = l; l = l + 16 | 0; f = g | 0; DC(a, b, d, e, f); l = g; return (A = c[f + 4 >> 2] | 0, c[f >> 2] | 0) | 0; } function IC(a) { a = a | 0; return (a & 255) << 24 | (a >> 8 & 255) << 16 | (a >> 16 & 255) << 8 | a >>> 24 | 0; } function JC(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; jb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0); } function KC(a, b, c) { a = a | 0; b = b | 0; c = T(c); kb[a & 1](b | 0, T(c)); } function LC(a, b, c) { a = a | 0; b = b | 0; c = +c; lb[a & 31](b | 0, +c); } function MC(a, b, c, d) { a = a | 0; b = b | 0; c = T(c); d = T(d); return T(mb[a & 0](b | 0, T(c), T(d))); } function NC(a, b) { a = a | 0; b = b | 0; nb[a & 127](b | 0); } function OC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; ob[a & 31](b | 0, c | 0); } function PC(a, b) { a = a | 0; b = b | 0; return pb[a & 31](b | 0) | 0; } function QC(a, b, c, d, e) { a = a | 0; b = b | 0; c = +c; d = +d; e = e | 0; qb[a & 1](b | 0, +c, +d, e | 0); } function RC(a, b, c, d) { a = a | 0; b = b | 0; c = +c; d = +d; rb[a & 1](b | 0, +c, +d); } function SC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return sb[a & 7](b | 0, c | 0, d | 0) | 0; } function TC(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; return +tb[a & 1](b | 0, c | 0, d | 0); } function UC(a, b) { a = a | 0; b = b | 0; return +ub[a & 15](b | 0); } function VC(a, b, c) { a = a | 0; b = b | 0; c = +c; return vb[a & 1](b | 0, +c) | 0; } function WC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; return wb[a & 15](b | 0, c | 0) | 0; } function XC(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = +d; e = +e; f = f | 0; xb[a & 1](b | 0, c | 0, +d, +e, f | 0); } function YC(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; g = g | 0; yb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0, g | 0); } function ZC(a, b, c) { a = a | 0; b = b | 0; c = c | 0; return +zb[a & 7](b | 0, c | 0); } function _C(a) { a = a | 0; return Ab[a & 7]() | 0; } function $C(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; return Bb[a & 1](b | 0, c | 0, d | 0, e | 0, f | 0) | 0; } function aD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = +e; Cb[a & 1](b | 0, c | 0, d | 0, +e); } function bD(a, b, c, d, e, f, g) { a = a | 0; b = b | 0; c = c | 0; d = T(d); e = e | 0; f = T(f); g = g | 0; Db[a & 1](b | 0, c | 0, T(d), e | 0, T(f), g | 0); } function cD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; Eb[a & 15](b | 0, c | 0, d | 0); } function dD(a) { a = a | 0; Fb[a & 0](); } function eD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = +d; Gb[a & 15](b | 0, c | 0, +d); } function fD(a, b, c) { a = a | 0; b = +b; c = +c; return Hb[a & 1](+b, +c) | 0; } function gD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; Ib[a & 15](b | 0, c | 0, d | 0, e | 0); } function hD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; U(0); } function iD(a, b) { a = a | 0; b = T(b); U(1); } function jD(a, b) { a = a | 0; b = +b; U(2); } function kD(a, b, c) { a = a | 0; b = T(b); c = T(c); U(3); return ib; } function lD(a) { a = a | 0; U(4); } function mD(a, b) { a = a | 0; b = b | 0; U(5); } function nD(a) { a = a | 0; U(6); return 0; } function oD(a, b, c, d) { a = a | 0; b = +b; c = +c; d = d | 0; U(7); } function pD(a, b, c) { a = a | 0; b = +b; c = +c; U(8); } function qD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(9); return 0; } function rD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(10); return 0.0; } function sD(a) { a = a | 0; U(11); return 0.0; } function tD(a, b) { a = a | 0; b = +b; U(12); return 0; } function uD(a, b) { a = a | 0; b = b | 0; U(13); return 0; } function vD(a, b, c, d, e) { a = a | 0; b = b | 0; c = +c; d = +d; e = e | 0; U(14); } function wD(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; f = f | 0; U(15); } function xD(a, b) { a = a | 0; b = b | 0; U(16); return 0.0; } function yD() { U(17); return 0; } function zD(a, b, c, d, e) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; e = e | 0; U(18); return 0; } function AD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = +d; U(19); } function BD(a, b, c, d, e, f) { a = a | 0; b = b | 0; c = T(c); d = d | 0; e = T(e); f = f | 0; U(20); } function CD(a, b, c) { a = a | 0; b = b | 0; c = c | 0; U(21); } function DD() { U(22); } function ED(a, b, c) { a = a | 0; b = b | 0; c = +c; U(23); } function FD(a, b) { a = +a; b = +b; U(24); return 0; } function GD(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; U(25); } // EMSCRIPTEN_END_FUNCS var jb = [ hD, Uw ]; var kb = [ iD, of ]; var lb = [ jD, Of, Pf, Qf, Rf, Sf, Tf, Uf, Wf, Xf, Zf, _f, $f, ag, bg, cg, dg, eg, fg, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD, jD ]; var mb = [ kD ]; var nb = [ lD, kC, Ki, Li, Mi, rn, sn, tn, Pu, Qu, Ru, Cw, Dw, Ew, DA, EA, FA, Rb, tf, yf, Vf, Yf, hh, ih, ri, Ui, kj, Jj, bk, zk, Wk, nl, Hl, bm, um, Nm, en, Nn, fo, yo, Ro, ip, Bp, Xp, nq, Eq, Zq, lf, Hr, _r, us, Ps, ft, Ct, Ot, Rt, ju, mu, Eu, Uu, Xu, pv, Kv, Vi, $x, Ky, az, sz, Rz, hA, tA, wA, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD, lD ]; var ob = [ mD, zf, Af, Df, Ef, Ff, Gf, Hf, If, Lf, Mf, Nf, wg, zg, Ag, Bg, Cg, Dg, Eg, Jg, Ng, rh, $p, qq, Ts, cy, Sv, xy, mD, mD, mD, mD ]; var pb = [ nD, rB, sf, jg, ng, og, pg, qg, rg, sg, ug, vg, Kg, Lg, jh, ar, jt, sv, hy, jy, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD, nD ]; var qb = [ oD, kh ]; var rb = [ pD, Hu ]; var sb = [ qD, sB, tB, zB, Dk, Rn, Lr, wz ]; var tb = [ rD, ym ]; var ub = [ sD, xg, yg, Fg, lh, mh, nh, oh, ph, qh, sD, sD, sD, sD, sD, sD ]; var vb = [ tD, Kt ]; var wb = [ uD, lC, Mg, xi, Nj, _k, rl, jn, jo, Iq, pf, ez, uD, uD, uD, uD ]; var xb = [ vD, oj ]; var yb = [ wD, Vz ]; var zb = [ xD, Gg, sh, th, uh, Rm, xD, xD ]; var Ab = [ yD, vh, qf, jf, Wt, qu, av, AA ]; var Bb = [ zD, ee ]; var Cb = [ AD, Vo ]; var Db = [ BD, Pg ]; var Eb = [ CD, kg, tg, Hg, Ig, fk, Ll, mp, Fp, nf, vx, Oy, lA, CD, CD, CD ]; var Fb = [ DD ]; var Gb = [ ED, Bf, Cf, Jf, Kf, gg, hg, ig, Co, cs, Ft, ED, ED, ED, ED, ED ]; var Hb = [ FD, Mu ]; var Ib = [ GD, fm, ir, ys, st, au, wu, hv, Pv, oy, LA, GD, GD, GD, GD, GD ]; return { _llvm_bswap_i32: IC, dynCall_idd: fD, dynCall_i: _C, _i64Subtract: wC, ___udivdi3: EC, dynCall_vif: KC, setThrew: Nb, dynCall_viii: cD, _bitshift64Lshr: AC, _bitshift64Shl: zC, dynCall_vi: NC, dynCall_viiddi: XC, dynCall_diii: TC, dynCall_iii: WC, _memset: yC, _sbrk: FC, _memcpy: BC, __GLOBAL__sub_I_Yoga_cpp: hf, dynCall_vii: OC, ___uremdi3: HC, dynCall_vid: LC, stackAlloc: Jb, _nbind_init: _A, getTempRet0: Pb, dynCall_di: UC, dynCall_iid: VC, setTempRet0: Ob, _i64Add: xC, dynCall_fiff: MC, dynCall_iiii: SC, _emscripten_get_global_libc: qB, dynCall_viid: eD, dynCall_viiid: aD, dynCall_viififi: bD, dynCall_ii: PC, __GLOBAL__sub_I_Binding_cc: Sx, dynCall_viiii: gD, dynCall_iiiiii: $C, stackSave: Kb, dynCall_viiiii: JC, __GLOBAL__sub_I_nbind_cc: wh, dynCall_vidd: RC, _free: pB, runPostSets: vC, dynCall_viiiiii: YC, establishStackSpace: Mb, _memmove: GC, stackRestore: Lb, _malloc: oB, __GLOBAL__sub_I_common_cc: Bv, dynCall_viddi: QC, dynCall_dii: ZC, dynCall_v: dD }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/brotli-decompress/static/chunks/545-ff8f898b276d138f/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[545], { /***/ 966: /***/ (function (__unused_webpack_module, exports) { function HuffmanCode(bits, value) { this.bits = bits; /* number of bits used for this symbol */ this.value = value; /* symbol value or table offset */ } exports.h = HuffmanCode; var MAX_LENGTH = 15; /* Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the bit-wise reversal of the len least significant bits of key. */ function GetNextKey(key, len) { var step = 1 << (len - 1); while (key & step) { step >>= 1; } return (key & (step - 1)) + step; } /* Stores code in table[0], table[step], table[2*step], ..., table[end] */ /* Assumes that end is an integer multiple of step */ function ReplicateValue(table, i, step, end, code) { do { end -= step; table[i + end] = new HuffmanCode(code.bits, code.value); } while (end > 0); } /* Returns the table width of the next 2nd level table. count is the histogram of bit lengths for the remaining symbols, len is the code length of the next processed symbol */ function NextTableBitSize(count, len, root_bits) { var left = 1 << (len - root_bits); while (len < MAX_LENGTH) { left -= count[len]; if (left <= 0) break; ++len; left <<= 1; } return len - root_bits; } exports.g = function (root_table, table, root_bits, code_lengths, code_lengths_size) { var start_table = table; var code; /* current table entry */ var len; /* current code length */ var symbol; /* symbol index in original or sorted table */ var key; /* reversed prefix code */ var step; /* step size to replicate values in current table */ var low; /* low bits for current root entry */ var mask; /* mask for low bits */ var table_bits; /* key length of current table */ var table_size; /* size of current table */ var total_size; /* sum of root table size and 2nd level table sizes */ var sorted; /* symbols sorted by code length */ var count = new Int32Array(MAX_LENGTH + 1); /* number of codes of each length */ var offset = new Int32Array(MAX_LENGTH + 1); /* offsets in sorted table for each length */ sorted = new Int32Array(code_lengths_size); /* build histogram of code lengths */ for (symbol = 0; symbol < code_lengths_size; symbol++) { count[code_lengths[symbol]]++; } /* generate offsets into sorted symbol table by code length */ offset[1] = 0; for (len = 1; len < MAX_LENGTH; len++) { offset[len + 1] = offset[len] + count[len]; } /* sort symbols by length, by symbol order within each length */ for (symbol = 0; symbol < code_lengths_size; symbol++) { if (code_lengths[symbol] !== 0) { sorted[offset[code_lengths[symbol]]++] = symbol; } } table_bits = root_bits; table_size = 1 << table_bits; total_size = table_size; /* special case code with only one value */ if (offset[MAX_LENGTH] === 1) { for (key = 0; key < total_size; ++key) { root_table[table + key] = new HuffmanCode(0, sorted[0] & 0xffff); } return total_size; } /* fill in root table */ key = 0; symbol = 0; for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) { for (; count[len] > 0; --count[len]) { code = new HuffmanCode(len & 0xff, sorted[symbol++] & 0xffff); ReplicateValue(root_table, table + key, step, table_size, code); key = GetNextKey(key, len); } } /* fill in 2nd level tables and add pointers to root table */ mask = total_size - 1; low = -1; for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) { for (; count[len] > 0; --count[len]) { if ((key & mask) !== low) { table += table_size; table_bits = NextTableBitSize(count, len, root_bits); table_size = 1 << table_bits; total_size += table_size; low = key & mask; root_table[start_table + low] = new HuffmanCode((table_bits + root_bits) & 0xff, ((table - start_table) - low) & 0xffff); } code = new HuffmanCode((len - root_bits) & 0xff, sorted[symbol++] & 0xffff); ReplicateValue(root_table, table + (key >> root_bits), step, table_size, code); key = GetNextKey(key, len); } } return total_size; } /***/ }), }]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/brotli-decompress/static/chunks/545-ff8f898b276d138f/output.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [ 545 ], { /***/ 966: /***/ function(__unused_webpack_module, exports) { function HuffmanCode(bits, value) { this.bits = bits; /* number of bits used for this symbol */ this.value = value; /* symbol value or table offset */ } exports.h = HuffmanCode; /* Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the bit-wise reversal of the len least significant bits of key. */ function GetNextKey(key, len) { var step = 1 << len - 1; while(key & step){ step >>= 1; } return (key & step - 1) + step; } /* Stores code in table[0], table[step], table[2*step], ..., table[end] */ /* Assumes that end is an integer multiple of step */ function ReplicateValue(table, i, step, end, code) { do { end -= step; table[i + end] = new HuffmanCode(code.bits, code.value); }while (end > 0) } exports.g = function(root_table, table, root_bits, code_lengths, code_lengths_size) { var start_table = table; var code; /* current table entry */ var len; /* current code length */ var symbol; /* symbol index in original or sorted table */ var key; /* reversed prefix code */ var step; /* step size to replicate values in current table */ var low; /* low bits for current root entry */ var mask; /* mask for low bits */ var table_bits; /* key length of current table */ var table_size; /* size of current table */ var total_size; /* sum of root table size and 2nd level table sizes */ var sorted; /* symbols sorted by code length */ var count = new Int32Array(16); /* number of codes of each length */ var offset = new Int32Array(16); /* offsets in sorted table for each length */ sorted = new Int32Array(code_lengths_size); /* build histogram of code lengths */ for(symbol = 0; symbol < code_lengths_size; symbol++)count[code_lengths[symbol]]++; /* generate offsets into sorted symbol table by code length */ offset[1] = 0; for(len = 1; len < 15; len++)offset[len + 1] = offset[len] + count[len]; /* sort symbols by length, by symbol order within each length */ for(symbol = 0; symbol < code_lengths_size; symbol++)if (0 !== code_lengths[symbol]) sorted[offset[code_lengths[symbol]]++] = symbol; table_bits = root_bits; table_size = 1 << table_bits; total_size = table_size; /* special case code with only one value */ if (1 === offset[15]) { for(key = 0; key < total_size; ++key)root_table[table + key] = new HuffmanCode(0, 0xffff & sorted[0]); return total_size; } /* fill in root table */ key = 0; symbol = 0; for(len = 1, step = 2; len <= root_bits; ++len, step <<= 1){ for(; count[len] > 0; --count[len]){ code = new HuffmanCode(0xff & len, 0xffff & sorted[symbol++]); ReplicateValue(root_table, table + key, step, table_size, code); key = GetNextKey(key, len); } } /* fill in 2nd level tables and add pointers to root table */ mask = total_size - 1; low = -1; for(len = root_bits + 1, step = 2; len <= 15; ++len, step <<= 1){ for(; count[len] > 0; --count[len]){ if ((key & mask) !== low) { table += table_size; table_bits = /* Returns the table width of the next 2nd level table. count is the histogram of bit lengths for the remaining symbols, len is the code length of the next processed symbol */ function(count, len, root_bits) { var left = 1 << len - root_bits; while(len < 15){ left -= count[len]; if (left <= 0) break; ++len; left <<= 1; } return len - root_bits; }(count, len, root_bits); table_size = 1 << table_bits; total_size += table_size; low = key & mask; root_table[start_table + low] = new HuffmanCode(table_bits + root_bits & 0xff, table - start_table - low & 0xffff); } code = new HuffmanCode(len - root_bits & 0xff, 0xffff & sorted[symbol++]); ReplicateValue(root_table, table + (key >> root_bits), step, table_size, code); key = GetNextKey(key, len); } } return total_size; }; /***/ } } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/chakra/input.js
JavaScript
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([ [888], { /***/ 2260: /***/ function ( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function () { return /* binding */ _app; }, }); // CONCATENATED MODULE: ./node_modules/@swc/helpers/src/_define_property.mjs function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true, }); } else { obj[key] = value; } return obj; } // CONCATENATED MODULE: ./node_modules/@swc/helpers/src/_object_spread.mjs function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === "function") { ownKeys = ownKeys.concat( Object.getOwnPropertySymbols(source).filter( function (sym) { return Object.getOwnPropertyDescriptor( source, sym ).enumerable; } ) ); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(5893); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(7294); // EXTERNAL MODULE: ./node_modules/@emotion/react/dist/emotion-react.browser.esm.js var emotion_react_browser_esm = __webpack_require__(917); // CONCATENATED MODULE: ./node_modules/@chakra-ui/css-reset/dist/chakra-ui-css-reset.esm.js var CSSReset = function CSSReset() { return /*#__PURE__*/ react.createElement( emotion_react_browser_esm /* Global */.xB, { styles: '\n html {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n font-family: system-ui, sans-serif;\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n -moz-osx-font-smoothing: grayscale;\n touch-action: manipulation;\n }\n\n body {\n position: relative;\n min-height: 100%;\n font-feature-settings: \'kern\';\n }\n\n *,\n *::before,\n *::after {\n border-width: 0;\n border-style: solid;\n box-sizing: border-box;\n }\n\n main {\n display: block;\n }\n\n hr {\n border-top-width: 1px;\n box-sizing: content-box;\n height: 0;\n overflow: visible;\n }\n\n pre,\n code,\n kbd,\n samp {\n font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 1em;\n }\n\n a {\n background-color: transparent;\n color: inherit;\n text-decoration: inherit;\n }\n\n abbr[title] {\n border-bottom: none;\n text-decoration: underline;\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n\n b,\n strong {\n font-weight: bold;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n img {\n border-style: none;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n line-height: 1.15;\n margin: 0;\n }\n\n button,\n input {\n overflow: visible;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button::-moz-focus-inner,\n [type="button"]::-moz-focus-inner,\n [type="reset"]::-moz-focus-inner,\n [type="submit"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n fieldset {\n padding: 0.35em 0.75em 0.625em;\n }\n\n legend {\n box-sizing: border-box;\n color: inherit;\n display: table;\n max-width: 100%;\n padding: 0;\n white-space: normal;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n textarea {\n overflow: auto;\n }\n\n [type="checkbox"],\n [type="radio"] {\n box-sizing: border-box;\n padding: 0;\n }\n\n [type="number"]::-webkit-inner-spin-button,\n [type="number"]::-webkit-outer-spin-button {\n -webkit-appearance: none !important;\n }\n\n input[type="number"] {\n -moz-appearance: textfield;\n }\n\n [type="search"] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n [type="search"]::-webkit-search-decoration {\n -webkit-appearance: none !important;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n details {\n display: block;\n }\n\n summary {\n display: list-item;\n }\n\n template {\n display: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n body,\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n button {\n background: transparent;\n padding: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n ol,\n ul {\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n button,\n [role="button"] {\n cursor: pointer;\n }\n\n button::-moz-focus-inner {\n border: 0 !important;\n }\n\n table {\n border-collapse: collapse;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n padding: 0;\n line-height: inherit;\n color: inherit;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [data-js-focus-visible] :focus:not([data-focus-visible-added]):not([data-focus-visible-disabled]) {\n outline: none;\n box-shadow: none;\n }\n\n select::-ms-expand {\n display: none;\n }\n ', } ); }; var CSSReset$1 = CSSReset; // EXTERNAL MODULE: ./node_modules/@chakra-ui/utils/dist/chakra-ui-utils.esm.js + 3 modules var chakra_ui_utils_esm = __webpack_require__(5031); // EXTERNAL MODULE: ./node_modules/@chakra-ui/react-utils/dist/chakra-ui-react-utils.esm.js var chakra_ui_react_utils_esm = __webpack_require__(6450); // EXTERNAL MODULE: ./node_modules/@chakra-ui/hooks/dist/chakra-ui-hooks.esm.js var chakra_ui_hooks_esm = __webpack_require__(7375); // EXTERNAL MODULE: ./node_modules/@chakra-ui/hooks/dist/use-animation-state-5054a9f7.esm.js var use_animation_state_5054a9f7_esm = __webpack_require__(4697); // EXTERNAL MODULE: ./node_modules/react-dom/index.js var react_dom = __webpack_require__(3935); // CONCATENATED MODULE: ./node_modules/@chakra-ui/portal/dist/chakra-ui-portal.esm.js var _createContext$1 = (0, chakra_ui_react_utils_esm /* createContext */.kr)({ strict: false, name: "PortalManagerContext", }), PortalManagerContextProvider = _createContext$1[0], usePortalManager = _createContext$1[1]; function PortalManager(props) { var children = props.children, zIndex = props.zIndex; return /*#__PURE__*/ react.createElement( PortalManagerContextProvider, { value: { zIndex: zIndex, }, }, children ); } if (chakra_ui_utils_esm /* __DEV__ */.Ts) { PortalManager.displayName = "PortalManager"; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var _excluded = ["containerRef"]; var _createContext = (0, chakra_ui_react_utils_esm /* createContext */.kr)({ strict: false, name: "PortalContext", }), PortalContextProvider = _createContext[0], usePortalContext = _createContext[1]; var PORTAL_CLASSNAME = "chakra-portal"; var PORTAL_SELECTOR = ".chakra-portal"; var Container = function Container(props) { return /*#__PURE__*/ react.createElement( "div", { className: "chakra-portal-zIndex", style: { position: "absolute", zIndex: props.zIndex, top: 0, left: 0, right: 0, // NB: Don't add `bottom: 0`, it makes the entire app unusable // @see https://github.com/chakra-ui/chakra-ui/issues/3201 }, }, props.children ); }; /** * Portal that uses `document.body` as container */ var DefaultPortal = function DefaultPortal(props) { var appendToParentPortal = props.appendToParentPortal, children = props.children; var tempNode = react.useRef(null); var portal = react.useRef(null); var forceUpdate = (0, chakra_ui_hooks_esm /* useForceUpdate */.NW)(); var parentPortal = usePortalContext(); var manager = usePortalManager(); (0, use_animation_state_5054a9f7_esm.a)(function () { if (!tempNode.current) return; var doc = tempNode.current.ownerDocument; var host = appendToParentPortal ? parentPortal != null ? parentPortal : doc.body : doc.body; if (!host) return; portal.current = doc.createElement("div"); portal.current.className = PORTAL_CLASSNAME; host.appendChild(portal.current); forceUpdate(); var portalNode = portal.current; return function () { if (host.contains(portalNode)) { host.removeChild(portalNode); } }; }, []); var _children = manager != null && manager.zIndex ? /*#__PURE__*/ react.createElement( Container, { zIndex: manager == null ? void 0 : manager.zIndex, }, children ) : children; return portal.current ? /*#__PURE__*/ (0, react_dom.createPortal)( /*#__PURE__*/ react.createElement( PortalContextProvider, { value: portal.current, }, _children ), portal.current ) : /*#__PURE__*/ react.createElement("span", { ref: tempNode, }); }; /** * Portal that uses a custom container */ var ContainerPortal = function ContainerPortal(props) { var children = props.children, containerRef = props.containerRef, appendToParentPortal = props.appendToParentPortal; var containerEl = containerRef.current; var host = containerEl != null ? containerEl : chakra_ui_utils_esm /* isBrowser */.jU ? document.body : undefined; var portal = react.useMemo( function () { var node = containerEl == null ? void 0 : containerEl.ownerDocument.createElement( "div" ); if (node) node.className = PORTAL_CLASSNAME; return node; }, [containerEl] ); var forceUpdate = (0, chakra_ui_hooks_esm /* useForceUpdate */.NW)(); (0, use_animation_state_5054a9f7_esm.a)(function () { forceUpdate(); }, []); (0, use_animation_state_5054a9f7_esm.a)( function () { if (!portal || !host) return; host.appendChild(portal); return function () { host.removeChild(portal); }; }, [portal, host] ); if (host && portal) { return /*#__PURE__*/ (0, react_dom.createPortal)( /*#__PURE__*/ react.createElement( PortalContextProvider, { value: appendToParentPortal ? portal : null, }, children ), portal ); } return null; }; /** * Portal * * Declarative component used to render children into a DOM node * that exists outside the DOM hierarchy of the parent component. * * @see Docs https://chakra-ui.com/portal */ function Portal(props) { var containerRef = props.containerRef, rest = _objectWithoutPropertiesLoose(props, _excluded); return containerRef ? /*#__PURE__*/ react.createElement( ContainerPortal, _extends( { containerRef: containerRef, }, rest ) ) : /*#__PURE__*/ react.createElement(DefaultPortal, rest); } Portal.defaultProps = { appendToParentPortal: true, }; Portal.className = PORTAL_CLASSNAME; Portal.selector = PORTAL_SELECTOR; if (chakra_ui_utils_esm /* __DEV__ */.Ts) { Portal.displayName = "Portal"; } // EXTERNAL MODULE: ./node_modules/@chakra-ui/system/dist/chakra-ui-system.esm.js + 3 modules var chakra_ui_system_esm = __webpack_require__(2846); // EXTERNAL MODULE: ./node_modules/@chakra-ui/color-mode/dist/chakra-ui-color-mode.esm.js var chakra_ui_color_mode_esm = __webpack_require__(949); // CONCATENATED MODULE: ./node_modules/@chakra-ui/react-env/dist/chakra-ui-react-env.esm.js var doc = { body: { classList: { add: function add() { }, remove: function remove() { }, }, }, addEventListener: function addEventListener() { }, removeEventListener: function removeEventListener() { }, activeElement: { blur: function blur() { }, nodeName: "", }, querySelector: function querySelector() { return null; }, querySelectorAll: function querySelectorAll() { return []; }, getElementById: function getElementById() { return null; }, createEvent: function createEvent() { return { initEvent: function initEvent() { }, }; }, createElement: function createElement() { return { children: [], childNodes: [], style: {}, setAttribute: function setAttribute() { }, getElementsByTagName: function getElementsByTagName() { return []; }, }; }, }; var ssrDocument = doc; var noop = function noop() { }; var win = { document: ssrDocument, navigator: { userAgent: "", }, CustomEvent: function CustomEvent() { return this; }, addEventListener: noop, removeEventListener: noop, getComputedStyle: function getComputedStyle() { return { getPropertyValue: function getPropertyValue() { return ""; }, }; }, matchMedia: function matchMedia() { return { matches: false, addListener: noop, removeListener: noop, }; }, requestAnimationFrame: function requestAnimationFrame( callback ) { if (typeof setTimeout === "undefined") { callback(); return null; } return setTimeout(callback, 0); }, cancelAnimationFrame: function cancelAnimationFrame(id) { if (typeof setTimeout === "undefined") return; clearTimeout(id); }, setTimeout: function setTimeout() { return 0; }, clearTimeout: noop, setInterval: function setInterval() { return 0; }, clearInterval: noop, }; var ssrWindow = win; var mockEnv = { window: ssrWindow, document: ssrDocument, }; var defaultEnv = chakra_ui_utils_esm /* isBrowser */.jU ? { window: window, document: document, } : mockEnv; var EnvironmentContext = /*#__PURE__*/ (0, react.createContext)( defaultEnv ); if (chakra_ui_utils_esm /* __DEV__ */.Ts) { EnvironmentContext.displayName = "EnvironmentContext"; } function useEnvironment() { return useContext(EnvironmentContext); } function EnvironmentProvider(props) { var children = props.children, environmentProp = props.environment; var _useState = (0, react.useState)(null), node = _useState[0], setNode = _useState[1]; var context = (0, react.useMemo)( function () { var _ref; var doc = node == null ? void 0 : node.ownerDocument; var win = node == null ? void 0 : node.ownerDocument.defaultView; var nodeEnv = doc ? { document: doc, window: win, } : undefined; var env = (_ref = environmentProp != null ? environmentProp : nodeEnv) != null ? _ref : defaultEnv; return env; }, [node, environmentProp] ); return /*#__PURE__*/ react.createElement( EnvironmentContext.Provider, { value: context, }, children, /*#__PURE__*/ react.createElement("span", { hidden: true, className: "chakra-env", ref: function ref(el) { (0, react.startTransition)(function () { if (el) setNode(el); }); }, }) ); } if (chakra_ui_utils_esm /* __DEV__ */.Ts) { EnvironmentProvider.displayName = "EnvironmentProvider"; } // CONCATENATED MODULE: ./node_modules/@chakra-ui/provider/dist/chakra-ui-provider.esm.js /** * The global provider that must be added to make all Chakra components * work correctly */ var chakra_ui_provider_esm_ChakraProvider = function ChakraProvider( props ) { var children = props.children, colorModeManager = props.colorModeManager, portalZIndex = props.portalZIndex, _props$resetCSS = props.resetCSS, resetCSS = _props$resetCSS === void 0 ? true : _props$resetCSS, _props$theme = props.theme, theme = _props$theme === void 0 ? {} : _props$theme, environment = props.environment, cssVarsRoot = props.cssVarsRoot; var _children = /*#__PURE__*/ react.createElement( EnvironmentProvider, { environment: environment, }, children ); return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* ThemeProvider */.f6, { theme: theme, cssVarsRoot: cssVarsRoot, }, /*#__PURE__*/ react.createElement( chakra_ui_color_mode_esm /* ColorModeProvider */.SG, { colorModeManager: colorModeManager, options: theme.config, }, resetCSS && /*#__PURE__*/ react.createElement(CSSReset$1, null), /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* GlobalStyle */.ZL, null ), portalZIndex ? /*#__PURE__*/ react.createElement( PortalManager, { zIndex: portalZIndex, }, _children ) : _children ) ); }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/spacing/dist/chakra-ui-theme-foundations-spacing.esm.js var spacing = { px: "1px", 0.5: "0.125rem", 1: "0.25rem", 1.5: "0.375rem", 2: "0.5rem", 2.5: "0.625rem", 3: "0.75rem", 3.5: "0.875rem", 4: "1rem", 5: "1.25rem", 6: "1.5rem", 7: "1.75rem", 8: "2rem", 9: "2.25rem", 10: "2.5rem", 12: "3rem", 14: "3.5rem", 16: "4rem", 20: "5rem", 24: "6rem", 28: "7rem", 32: "8rem", 36: "9rem", 40: "10rem", 44: "11rem", 48: "12rem", 52: "13rem", 56: "14rem", 60: "15rem", 64: "16rem", 72: "18rem", 80: "20rem", 96: "24rem", }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/dist/sizes-501602a9.esm.js function sizes_501602a9_esm_extends() { sizes_501602a9_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return sizes_501602a9_esm_extends.apply(this, arguments); } var largeSizes = { max: "max-content", min: "min-content", full: "100%", "3xs": "14rem", "2xs": "16rem", xs: "20rem", sm: "24rem", md: "28rem", lg: "32rem", xl: "36rem", "2xl": "42rem", "3xl": "48rem", "4xl": "56rem", "5xl": "64rem", "6xl": "72rem", "7xl": "80rem", "8xl": "90rem", }; var container = { sm: "640px", md: "768px", lg: "1024px", xl: "1280px", }; var sizes = sizes_501602a9_esm_extends({}, spacing, largeSizes, { container: container, }); // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/util.js /** * Take input from [0, n] and return it as [0, 1] * @hidden */ function bound01(n, max) { if (isOnePointZero(n)) { n = "100%"; } var isPercent = isPercentage(n); n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n))); // Automatically convert percentage into number if (isPercent) { n = parseInt(String(n * max), 10) / 100; } // Handle floating point rounding errors if (Math.abs(n - max) < 0.000001) { return 1; } // Convert into [0, 1] range if it isn't already if (max === 360) { // If n is a hue given in degrees, // wrap around out-of-range values into [0, 360] range // then convert into [0, 1]. n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max)); } else { // If n not a hue given in degrees // Convert into [0, 1] range if it isn't already. n = (n % max) / parseFloat(String(max)); } return n; } /** * Force a number between 0 and 1 * @hidden */ function clamp01(val) { return Math.min(1, Math.max(0, val)); } /** * Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 * <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> * @hidden */ function isOnePointZero(n) { return ( typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1 ); } /** * Check to see if string passed in is a percentage * @hidden */ function isPercentage(n) { return typeof n === "string" && n.indexOf("%") !== -1; } /** * Return a valid alpha value [0,1] with all invalid values being set to 1 * @hidden */ function boundAlpha(a) { a = parseFloat(a); if (isNaN(a) || a < 0 || a > 1) { a = 1; } return a; } /** * Replace a decimal with it's percentage value * @hidden */ function convertToPercentage(n) { if (n <= 1) { return "".concat(Number(n) * 100, "%"); } return n; } /** * Force a hex value to have 2 characters * @hidden */ function util_pad2(c) { return c.length === 1 ? "0" + c : String(c); } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/conversion.js // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> /** * Handle bounds / percentage checking to conform to CSS color spec * <http://www.w3.org/TR/css3-color/> * *Assumes:* r, g, b in [0, 255] or [0, 1] * *Returns:* { r, g, b } in [0, 255] */ function rgbToRgb(r, g, b) { return { r: bound01(r, 255) * 255, g: bound01(g, 255) * 255, b: bound01(b, 255) * 255, }; } /** * Converts an RGB color value to HSL. * *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] * *Returns:* { h, s, l } in [0,1] */ function rgbToHsl(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h = 0; var s = 0; var l = (max + min) / 2; if (max === min) { s = 0; h = 0; // achromatic } else { var d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; default: break; } h /= 6; } return { h: h, s: s, l: l }; } function hue2rgb(p, q, t) { if (t < 0) { t += 1; } if (t > 1) { t -= 1; } if (t < 1 / 6) { return p + (q - p) * (6 * t); } if (t < 1 / 2) { return q; } if (t < 2 / 3) { return p + (q - p) * (2 / 3 - t) * 6; } return p; } /** * Converts an HSL color value to RGB. * * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] * *Returns:* { r, g, b } in the set [0, 255] */ function hslToRgb(h, s, l) { var r; var g; var b; h = bound01(h, 360); s = bound01(s, 100); l = bound01(l, 100); if (s === 0) { // achromatic g = l; b = l; r = l; } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1 / 3); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1 / 3); } return { r: r * 255, g: g * 255, b: b * 255 }; } /** * Converts an RGB color value to HSV * * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] * *Returns:* { h, s, v } in [0,1] */ function rgbToHsv(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h = 0; var v = max; var d = max - min; var s = max === 0 ? 0 : d / max; if (max === min) { h = 0; // achromatic } else { switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; default: break; } h /= 6; } return { h: h, s: s, v: v }; } /** * Converts an HSV color value to RGB. * * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] * *Returns:* { r, g, b } in the set [0, 255] */ function hsvToRgb(h, s, v) { h = bound01(h, 360) * 6; s = bound01(s, 100); v = bound01(v, 100); var i = Math.floor(h); var f = h - i; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var mod = i % 6; var r = [v, q, p, p, t, v][mod]; var g = [t, v, v, q, p, p][mod]; var b = [p, p, t, v, v, q][mod]; return { r: r * 255, g: g * 255, b: b * 255 }; } /** * Converts an RGB color to hex * * Assumes r, g, and b are contained in the set [0, 255] * Returns a 3 or 6 character hex */ function rgbToHex(r, g, b, allow3Char) { var hex = [ util_pad2(Math.round(r).toString(16)), util_pad2(Math.round(g).toString(16)), util_pad2(Math.round(b).toString(16)), ]; // Return a 3 character hex if possible if ( allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) ) { return ( hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) ); } return hex.join(""); } /** * Converts an RGBA color plus alpha transparency to hex * * Assumes r, g, b are contained in the set [0, 255] and * a in [0, 1]. Returns a 4 or 8 character rgba hex */ // eslint-disable-next-line max-params function rgbaToHex(r, g, b, a, allow4Char) { var hex = [ util_pad2(Math.round(r).toString(16)), util_pad2(Math.round(g).toString(16)), util_pad2(Math.round(b).toString(16)), util_pad2(convertDecimalToHex(a)), ]; // Return a 4 character hex if possible if ( allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1)) ) { return ( hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0) ); } return hex.join(""); } /** * Converts an RGBA color to an ARGB Hex8 string * Rarely used, but required for "toFilter()" */ function rgbaToArgbHex(r, g, b, a) { var hex = [ pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), ]; return hex.join(""); } /** Converts a decimal to a hex value */ function convertDecimalToHex(d) { return Math.round(parseFloat(d) * 255).toString(16); } /** Converts a hex value to a decimal */ function convertHexToDecimal(h) { return parseIntFromHex(h) / 255; } /** Parse a base-16 hex value into a base-10 integer */ function parseIntFromHex(val) { return parseInt(val, 16); } function numberInputToObject(color) { return { r: color >> 16, g: (color & 0xff00) >> 8, b: color & 0xff, }; } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/css-color-names.js // https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json /** * @hidden */ var names = { aliceblue: "#f0f8ff", antiquewhite: "#faebd7", aqua: "#00ffff", aquamarine: "#7fffd4", azure: "#f0ffff", beige: "#f5f5dc", bisque: "#ffe4c4", black: "#000000", blanchedalmond: "#ffebcd", blue: "#0000ff", blueviolet: "#8a2be2", brown: "#a52a2a", burlywood: "#deb887", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", cornflowerblue: "#6495ed", cornsilk: "#fff8dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkseagreen: "#8fbc8f", darkslateblue: "#483d8b", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", darkturquoise: "#00ced1", darkviolet: "#9400d3", deeppink: "#ff1493", deepskyblue: "#00bfff", dimgray: "#696969", dimgrey: "#696969", dodgerblue: "#1e90ff", firebrick: "#b22222", floralwhite: "#fffaf0", forestgreen: "#228b22", fuchsia: "#ff00ff", gainsboro: "#dcdcdc", ghostwhite: "#f8f8ff", goldenrod: "#daa520", gold: "#ffd700", gray: "#808080", green: "#008000", greenyellow: "#adff2f", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", indianred: "#cd5c5c", indigo: "#4b0082", ivory: "#fffff0", khaki: "#f0e68c", lavenderblush: "#fff0f5", lavender: "#e6e6fa", lawngreen: "#7cfc00", lemonchiffon: "#fffacd", lightblue: "#add8e6", lightcoral: "#f08080", lightcyan: "#e0ffff", lightgoldenrodyellow: "#fafad2", lightgray: "#d3d3d3", lightgreen: "#90ee90", lightgrey: "#d3d3d3", lightpink: "#ffb6c1", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", lightskyblue: "#87cefa", lightslategray: "#778899", lightslategrey: "#778899", lightsteelblue: "#b0c4de", lightyellow: "#ffffe0", lime: "#00ff00", limegreen: "#32cd32", linen: "#faf0e6", magenta: "#ff00ff", maroon: "#800000", mediumaquamarine: "#66cdaa", mediumblue: "#0000cd", mediumorchid: "#ba55d3", mediumpurple: "#9370db", mediumseagreen: "#3cb371", mediumslateblue: "#7b68ee", mediumspringgreen: "#00fa9a", mediumturquoise: "#48d1cc", mediumvioletred: "#c71585", midnightblue: "#191970", mintcream: "#f5fffa", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", navajowhite: "#ffdead", navy: "#000080", oldlace: "#fdf5e6", olive: "#808000", olivedrab: "#6b8e23", orange: "#ffa500", orangered: "#ff4500", orchid: "#da70d6", palegoldenrod: "#eee8aa", palegreen: "#98fb98", paleturquoise: "#afeeee", palevioletred: "#db7093", papayawhip: "#ffefd5", peachpuff: "#ffdab9", peru: "#cd853f", pink: "#ffc0cb", plum: "#dda0dd", powderblue: "#b0e0e6", purple: "#800080", rebeccapurple: "#663399", red: "#ff0000", rosybrown: "#bc8f8f", royalblue: "#4169e1", saddlebrown: "#8b4513", salmon: "#fa8072", sandybrown: "#f4a460", seagreen: "#2e8b57", seashell: "#fff5ee", sienna: "#a0522d", silver: "#c0c0c0", skyblue: "#87ceeb", slateblue: "#6a5acd", slategray: "#708090", slategrey: "#708090", snow: "#fffafa", springgreen: "#00ff7f", steelblue: "#4682b4", tan: "#d2b48c", teal: "#008080", thistle: "#d8bfd8", tomato: "#ff6347", turquoise: "#40e0d0", violet: "#ee82ee", wheat: "#f5deb3", white: "#ffffff", whitesmoke: "#f5f5f5", yellow: "#ffff00", yellowgreen: "#9acd32", }; // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/format-input.js /** * Given a string or object, convert that input to RGB * * Possible string inputs: * ``` * "red" * "#f00" or "f00" * "#ff0000" or "ff0000" * "#ff000000" or "ff000000" * "rgb 255 0 0" or "rgb (255, 0, 0)" * "rgb 1.0 0 0" or "rgb (1, 0, 0)" * "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" * "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" * "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" * "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" * "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" * ``` */ function inputToRGB(color) { var rgb = { r: 0, g: 0, b: 0 }; var a = 1; var s = null; var v = null; var l = null; var ok = false; var format = false; if (typeof color === "string") { color = stringInputToObject(color); } if (typeof color === "object") { if ( isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b) ) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; } else if ( isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v) ) { s = convertToPercentage(color.s); v = convertToPercentage(color.v); rgb = hsvToRgb(color.h, s, v); ok = true; format = "hsv"; } else if ( isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l) ) { s = convertToPercentage(color.s); l = convertToPercentage(color.l); rgb = hslToRgb(color.h, s, l); ok = true; format = "hsl"; } if (Object.prototype.hasOwnProperty.call(color, "a")) { a = color.a; } } a = boundAlpha(a); return { ok: ok, format: color.format || format, r: Math.min(255, Math.max(rgb.r, 0)), g: Math.min(255, Math.max(rgb.g, 0)), b: Math.min(255, Math.max(rgb.b, 0)), a: a, }; } // <http://www.w3.org/TR/css3-values/#integers> var CSS_INTEGER = "[-\\+]?\\d+%?"; // <http://www.w3.org/TR/css3-values/#number-value> var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. var CSS_UNIT = "(?:" .concat(CSS_NUMBER, ")|(?:") .concat(CSS_INTEGER, ")"); // Actual matching. // Parentheses and commas are optional, but not required. // Whitespace can take the place of commas or opening paren var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" .concat(CSS_UNIT, ")[,|\\s]+(") .concat(CSS_UNIT, ")[,|\\s]+(") .concat(CSS_UNIT, ")\\s*\\)?"); var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" .concat(CSS_UNIT, ")[,|\\s]+(") .concat(CSS_UNIT, ")[,|\\s]+(") .concat(CSS_UNIT, ")[,|\\s]+(") .concat(CSS_UNIT, ")\\s*\\)?"); var matchers = { CSS_UNIT: new RegExp(CSS_UNIT), rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, }; /** * Permissive string parsing. Take in a number of formats, and output an object * based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` */ function stringInputToObject(color) { color = color.trim().toLowerCase(); if (color.length === 0) { return false; } var named = false; if (names[color]) { color = names[color]; named = true; } else if (color === "transparent") { return { r: 0, g: 0, b: 0, a: 0, format: "name" }; } // Try to match string input using regular expressions. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] // Just return an object and let the conversion functions handle that. // This way the result will be the same whether the tinycolor is initialized with string or object. var match = matchers.rgb.exec(color); if (match) { return { r: match[1], g: match[2], b: match[3] }; } match = matchers.rgba.exec(color); if (match) { return { r: match[1], g: match[2], b: match[3], a: match[4], }; } match = matchers.hsl.exec(color); if (match) { return { h: match[1], s: match[2], l: match[3] }; } match = matchers.hsla.exec(color); if (match) { return { h: match[1], s: match[2], l: match[3], a: match[4], }; } match = matchers.hsv.exec(color); if (match) { return { h: match[1], s: match[2], v: match[3] }; } match = matchers.hsva.exec(color); if (match) { return { h: match[1], s: match[2], v: match[3], a: match[4], }; } match = matchers.hex8.exec(color); if (match) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), a: convertHexToDecimal(match[4]), format: named ? "name" : "hex8", }; } match = matchers.hex6.exec(color); if (match) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), format: named ? "name" : "hex", }; } match = matchers.hex4.exec(color); if (match) { return { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), a: convertHexToDecimal(match[4] + match[4]), format: named ? "name" : "hex8", }; } match = matchers.hex3.exec(color); if (match) { return { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), format: named ? "name" : "hex", }; } return false; } /** * Check to see if it looks like a CSS unit * (see `matchers` above for definition). */ function isValidCSSUnit(color) { return Boolean(matchers.CSS_UNIT.exec(String(color))); } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/index.js var module_TinyColor = /** @class */ (function () { function TinyColor(color, opts) { if (color === void 0) { color = ""; } if (opts === void 0) { opts = {}; } var _a; // If input is already a tinycolor, return itself if (color instanceof TinyColor) { // eslint-disable-next-line no-constructor-return return color; } if (typeof color === "number") { color = numberInputToObject(color); } this.originalInput = color; var rgb = inputToRGB(color); this.originalInput = color; this.r = rgb.r; this.g = rgb.g; this.b = rgb.b; this.a = rgb.a; this.roundA = Math.round(100 * this.a) / 100; this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format; this.gradientType = opts.gradientType; // Don't let the range of [0,255] come back in [0,1]. // Potentially lose a little bit of precision here, but will fix issues where // .5 gets interpreted as half of the total, instead of half of 1 // If it was supposed to be 128, this was already taken care of by `inputToRgb` if (this.r < 1) { this.r = Math.round(this.r); } if (this.g < 1) { this.g = Math.round(this.g); } if (this.b < 1) { this.b = Math.round(this.b); } this.isValid = rgb.ok; } TinyColor.prototype.isDark = function () { return this.getBrightness() < 128; }; TinyColor.prototype.isLight = function () { return !this.isDark(); }; /** * Returns the perceived brightness of the color, from 0-255. */ TinyColor.prototype.getBrightness = function () { // http://www.w3.org/TR/AERT#color-contrast var rgb = this.toRgb(); return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; }; /** * Returns the perceived luminance of a color, from 0-1. */ TinyColor.prototype.getLuminance = function () { // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef var rgb = this.toRgb(); var R; var G; var B; var RsRGB = rgb.r / 255; var GsRGB = rgb.g / 255; var BsRGB = rgb.b / 255; if (RsRGB <= 0.03928) { R = RsRGB / 12.92; } else { // eslint-disable-next-line prefer-exponentiation-operator R = Math.pow((RsRGB + 0.055) / 1.055, 2.4); } if (GsRGB <= 0.03928) { G = GsRGB / 12.92; } else { // eslint-disable-next-line prefer-exponentiation-operator G = Math.pow((GsRGB + 0.055) / 1.055, 2.4); } if (BsRGB <= 0.03928) { B = BsRGB / 12.92; } else { // eslint-disable-next-line prefer-exponentiation-operator B = Math.pow((BsRGB + 0.055) / 1.055, 2.4); } return 0.2126 * R + 0.7152 * G + 0.0722 * B; }; /** * Returns the alpha value of a color, from 0-1. */ TinyColor.prototype.getAlpha = function () { return this.a; }; /** * Sets the alpha value on the current color. * * @param alpha - The new alpha value. The accepted range is 0-1. */ TinyColor.prototype.setAlpha = function (alpha) { this.a = boundAlpha(alpha); this.roundA = Math.round(100 * this.a) / 100; return this; }; /** * Returns the object as a HSVA object. */ TinyColor.prototype.toHsv = function () { var hsv = rgbToHsv(this.r, this.g, this.b); return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a }; }; /** * Returns the hsva values interpolated into a string with the following format: * "hsva(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toHsvString = function () { var hsv = rgbToHsv(this.r, this.g, this.b); var h = Math.round(hsv.h * 360); var s = Math.round(hsv.s * 100); var v = Math.round(hsv.v * 100); return this.a === 1 ? "hsv(" .concat(h, ", ") .concat(s, "%, ") .concat(v, "%)") : "hsva(" .concat(h, ", ") .concat(s, "%, ") .concat(v, "%, ") .concat(this.roundA, ")"); }; /** * Returns the object as a HSLA object. */ TinyColor.prototype.toHsl = function () { var hsl = rgbToHsl(this.r, this.g, this.b); return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a }; }; /** * Returns the hsla values interpolated into a string with the following format: * "hsla(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toHslString = function () { var hsl = rgbToHsl(this.r, this.g, this.b); var h = Math.round(hsl.h * 360); var s = Math.round(hsl.s * 100); var l = Math.round(hsl.l * 100); return this.a === 1 ? "hsl(" .concat(h, ", ") .concat(s, "%, ") .concat(l, "%)") : "hsla(" .concat(h, ", ") .concat(s, "%, ") .concat(l, "%, ") .concat(this.roundA, ")"); }; /** * Returns the hex value of the color. * @param allow3Char will shorten hex value to 3 char if possible */ TinyColor.prototype.toHex = function (allow3Char) { if (allow3Char === void 0) { allow3Char = false; } return rgbToHex(this.r, this.g, this.b, allow3Char); }; /** * Returns the hex value of the color -with a # appened. * @param allow3Char will shorten hex value to 3 char if possible */ TinyColor.prototype.toHexString = function (allow3Char) { if (allow3Char === void 0) { allow3Char = false; } return "#" + this.toHex(allow3Char); }; /** * Returns the hex 8 value of the color. * @param allow4Char will shorten hex value to 4 char if possible */ TinyColor.prototype.toHex8 = function (allow4Char) { if (allow4Char === void 0) { allow4Char = false; } return rgbaToHex( this.r, this.g, this.b, this.a, allow4Char ); }; /** * Returns the hex 8 value of the color -with a # appened. * @param allow4Char will shorten hex value to 4 char if possible */ TinyColor.prototype.toHex8String = function (allow4Char) { if (allow4Char === void 0) { allow4Char = false; } return "#" + this.toHex8(allow4Char); }; /** * Returns the object as a RGBA object. */ TinyColor.prototype.toRgb = function () { return { r: Math.round(this.r), g: Math.round(this.g), b: Math.round(this.b), a: this.a, }; }; /** * Returns the RGBA values interpolated into a string with the following format: * "RGBA(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toRgbString = function () { var r = Math.round(this.r); var g = Math.round(this.g); var b = Math.round(this.b); return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(" .concat(r, ", ") .concat(g, ", ") .concat(b, ", ") .concat(this.roundA, ")"); }; /** * Returns the object as a RGBA object. */ TinyColor.prototype.toPercentageRgb = function () { var fmt = function (x) { return "".concat( Math.round(bound01(x, 255) * 100), "%" ); }; return { r: fmt(this.r), g: fmt(this.g), b: fmt(this.b), a: this.a, }; }; /** * Returns the RGBA relative values interpolated into a string */ TinyColor.prototype.toPercentageRgbString = function () { var rnd = function (x) { return Math.round(bound01(x, 255) * 100); }; return this.a === 1 ? "rgb(" .concat(rnd(this.r), "%, ") .concat(rnd(this.g), "%, ") .concat(rnd(this.b), "%)") : "rgba(" .concat(rnd(this.r), "%, ") .concat(rnd(this.g), "%, ") .concat(rnd(this.b), "%, ") .concat(this.roundA, ")"); }; /** * The 'real' name of the color -if there is one. */ TinyColor.prototype.toName = function () { if (this.a === 0) { return "transparent"; } if (this.a < 1) { return false; } var hex = "#" + rgbToHex(this.r, this.g, this.b, false); for ( var _i = 0, _a = Object.entries(names); _i < _a.length; _i++ ) { var _b = _a[_i], key = _b[0], value = _b[1]; if (hex === value) { return key; } } return false; }; TinyColor.prototype.toString = function (format) { var formatSet = Boolean(format); format = format !== null && format !== void 0 ? format : this.format; var formattedString = false; var hasAlpha = this.a < 1 && this.a >= 0; var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith("hex") || format === "name"); if (needsAlphaFormat) { // Special case for "transparent", all other non-alpha formats // will return rgba when there is transparency. if (format === "name" && this.a === 0) { return this.toName(); } return this.toRgbString(); } if (format === "rgb") { formattedString = this.toRgbString(); } if (format === "prgb") { formattedString = this.toPercentageRgbString(); } if (format === "hex" || format === "hex6") { formattedString = this.toHexString(); } if (format === "hex3") { formattedString = this.toHexString(true); } if (format === "hex4") { formattedString = this.toHex8String(true); } if (format === "hex8") { formattedString = this.toHex8String(); } if (format === "name") { formattedString = this.toName(); } if (format === "hsl") { formattedString = this.toHslString(); } if (format === "hsv") { formattedString = this.toHsvString(); } return formattedString || this.toHexString(); }; TinyColor.prototype.toNumber = function () { return ( (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b) ); }; TinyColor.prototype.clone = function () { return new TinyColor(this.toString()); }; /** * Lighten the color a given amount. Providing 100 will always return white. * @param amount - valid between 1-100 */ TinyColor.prototype.lighten = function (amount) { if (amount === void 0) { amount = 10; } var hsl = this.toHsl(); hsl.l += amount / 100; hsl.l = clamp01(hsl.l); return new TinyColor(hsl); }; /** * Brighten the color a given amount, from 0 to 100. * @param amount - valid between 1-100 */ TinyColor.prototype.brighten = function (amount) { if (amount === void 0) { amount = 10; } var rgb = this.toRgb(); rgb.r = Math.max( 0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))) ); rgb.g = Math.max( 0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))) ); rgb.b = Math.max( 0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))) ); return new TinyColor(rgb); }; /** * Darken the color a given amount, from 0 to 100. * Providing 100 will always return black. * @param amount - valid between 1-100 */ TinyColor.prototype.darken = function (amount) { if (amount === void 0) { amount = 10; } var hsl = this.toHsl(); hsl.l -= amount / 100; hsl.l = clamp01(hsl.l); return new TinyColor(hsl); }; /** * Mix the color with pure white, from 0 to 100. * Providing 0 will do nothing, providing 100 will always return white. * @param amount - valid between 1-100 */ TinyColor.prototype.tint = function (amount) { if (amount === void 0) { amount = 10; } return this.mix("white", amount); }; /** * Mix the color with pure black, from 0 to 100. * Providing 0 will do nothing, providing 100 will always return black. * @param amount - valid between 1-100 */ TinyColor.prototype.shade = function (amount) { if (amount === void 0) { amount = 10; } return this.mix("black", amount); }; /** * Desaturate the color a given amount, from 0 to 100. * Providing 100 will is the same as calling greyscale * @param amount - valid between 1-100 */ TinyColor.prototype.desaturate = function (amount) { if (amount === void 0) { amount = 10; } var hsl = this.toHsl(); hsl.s -= amount / 100; hsl.s = clamp01(hsl.s); return new TinyColor(hsl); }; /** * Saturate the color a given amount, from 0 to 100. * @param amount - valid between 1-100 */ TinyColor.prototype.saturate = function (amount) { if (amount === void 0) { amount = 10; } var hsl = this.toHsl(); hsl.s += amount / 100; hsl.s = clamp01(hsl.s); return new TinyColor(hsl); }; /** * Completely desaturates a color into greyscale. * Same as calling `desaturate(100)` */ TinyColor.prototype.greyscale = function () { return this.desaturate(100); }; /** * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. * Values outside of this range will be wrapped into this range. */ TinyColor.prototype.spin = function (amount) { var hsl = this.toHsl(); var hue = (hsl.h + amount) % 360; hsl.h = hue < 0 ? 360 + hue : hue; return new TinyColor(hsl); }; /** * Mix the current color a given amount with another color, from 0 to 100. * 0 means no mixing (return current color). */ TinyColor.prototype.mix = function (color, amount) { if (amount === void 0) { amount = 50; } var rgb1 = this.toRgb(); var rgb2 = new TinyColor(color).toRgb(); var p = amount / 100; var rgba = { r: (rgb2.r - rgb1.r) * p + rgb1.r, g: (rgb2.g - rgb1.g) * p + rgb1.g, b: (rgb2.b - rgb1.b) * p + rgb1.b, a: (rgb2.a - rgb1.a) * p + rgb1.a, }; return new TinyColor(rgba); }; TinyColor.prototype.analogous = function (results, slices) { if (results === void 0) { results = 6; } if (slices === void 0) { slices = 30; } var hsl = this.toHsl(); var part = 360 / slices; var ret = [this]; for ( hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results; ) { hsl.h = (hsl.h + part) % 360; ret.push(new TinyColor(hsl)); } return ret; }; /** * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js */ TinyColor.prototype.complement = function () { var hsl = this.toHsl(); hsl.h = (hsl.h + 180) % 360; return new TinyColor(hsl); }; TinyColor.prototype.monochromatic = function (results) { if (results === void 0) { results = 6; } var hsv = this.toHsv(); var h = hsv.h; var s = hsv.s; var v = hsv.v; var res = []; var modification = 1 / results; while (results--) { res.push(new TinyColor({ h: h, s: s, v: v })); v = (v + modification) % 1; } return res; }; TinyColor.prototype.splitcomplement = function () { var hsl = this.toHsl(); var h = hsl.h; return [ this, new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l, }), new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l, }), ]; }; /** * Compute how the color would appear on a background */ TinyColor.prototype.onBackground = function (background) { var fg = this.toRgb(); var bg = new TinyColor(background).toRgb(); return new TinyColor({ r: bg.r + (fg.r - bg.r) * fg.a, g: bg.g + (fg.g - bg.g) * fg.a, b: bg.b + (fg.b - bg.b) * fg.a, }); }; /** * Alias for `polyad(3)` */ TinyColor.prototype.triad = function () { return this.polyad(3); }; /** * Alias for `polyad(4)` */ TinyColor.prototype.tetrad = function () { return this.polyad(4); }; /** * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...) * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc... */ TinyColor.prototype.polyad = function (n) { var hsl = this.toHsl(); var h = hsl.h; var result = [this]; var increment = 360 / n; for (var i = 1; i < n; i++) { result.push( new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l, }) ); } return result; }; /** * compare color vs current color */ TinyColor.prototype.equals = function (color) { return ( this.toRgbString() === new TinyColor(color).toRgbString() ); }; return TinyColor; })(); // kept for backwards compatability with v1 function tinycolor(color, opts) { if (color === void 0) { color = ""; } if (opts === void 0) { opts = {}; } return new module_TinyColor(color, opts); } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/random.js // randomColor by David Merfield under the CC0 license // https://github.com/davidmerfield/randomColor/ function random(options) { if (options === void 0) { options = {}; } // Check if we need to generate multiple colors if (options.count !== undefined && options.count !== null) { var totalColors = options.count; var colors = []; options.count = undefined; while (totalColors > colors.length) { // Since we're generating multiple colors, // incremement the seed. Otherwise we'd just // generate the same color each time... options.count = null; if (options.seed) { options.seed += 1; } colors.push(random(options)); } options.count = totalColors; return colors; } // First we pick a hue (H) var h = pickHue(options.hue, options.seed); // Then use H to determine saturation (S) var s = pickSaturation(h, options); // Then use S and H to determine brightness (B). var v = pickBrightness(h, s, options); var res = { h: h, s: s, v: v }; if (options.alpha !== undefined) { res.a = options.alpha; } // Then we return the HSB color in the desired format return new module_TinyColor(res); } function pickHue(hue, seed) { var hueRange = getHueRange(hue); var res = randomWithin(hueRange, seed); // Instead of storing red as two seperate ranges, // we group them, using negative numbers if (res < 0) { res = 360 + res; } return res; } function pickSaturation(hue, options) { if (options.hue === "monochrome") { return 0; } if (options.luminosity === "random") { return randomWithin([0, 100], options.seed); } var saturationRange = getColorInfo(hue).saturationRange; var sMin = saturationRange[0]; var sMax = saturationRange[1]; switch (options.luminosity) { case "bright": sMin = 55; break; case "dark": sMin = sMax - 10; break; case "light": sMax = 55; break; default: break; } return randomWithin([sMin, sMax], options.seed); } function pickBrightness(H, S, options) { var bMin = getMinimumBrightness(H, S); var bMax = 100; switch (options.luminosity) { case "dark": bMax = bMin + 20; break; case "light": bMin = (bMax + bMin) / 2; break; case "random": bMin = 0; bMax = 100; break; default: break; } return randomWithin([bMin, bMax], options.seed); } function getMinimumBrightness(H, S) { var lowerBounds = getColorInfo(H).lowerBounds; for (var i = 0; i < lowerBounds.length - 1; i++) { var s1 = lowerBounds[i][0]; var v1 = lowerBounds[i][1]; var s2 = lowerBounds[i + 1][0]; var v2 = lowerBounds[i + 1][1]; if (S >= s1 && S <= s2) { var m = (v2 - v1) / (s2 - s1); var b = v1 - m * s1; return m * S + b; } } return 0; } function getHueRange(colorInput) { var num = parseInt(colorInput, 10); if (!Number.isNaN(num) && num < 360 && num > 0) { return [num, num]; } if (typeof colorInput === "string") { var namedColor = bounds.find(function (n) { return n.name === colorInput; }); if (namedColor) { var color = defineColor(namedColor); if (color.hueRange) { return color.hueRange; } } var parsed = new module_TinyColor(colorInput); if (parsed.isValid) { var hue = parsed.toHsv().h; return [hue, hue]; } } return [0, 360]; } function getColorInfo(hue) { // Maps red colors to make picking hue easier if (hue >= 334 && hue <= 360) { hue -= 360; } for ( var _i = 0, bounds_1 = bounds; _i < bounds_1.length; _i++ ) { var bound = bounds_1[_i]; var color = defineColor(bound); if ( color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1] ) { return color; } } throw Error("Color not found"); } function randomWithin(range, seed) { if (seed === undefined) { return Math.floor( range[0] + Math.random() * (range[1] + 1 - range[0]) ); } // Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/ var max = range[1] || 1; var min = range[0] || 0; seed = (seed * 9301 + 49297) % 233280; var rnd = seed / 233280.0; return Math.floor(min + rnd * (max - min)); } function defineColor(bound) { var sMin = bound.lowerBounds[0][0]; var sMax = bound.lowerBounds[bound.lowerBounds.length - 1][0]; var bMin = bound.lowerBounds[bound.lowerBounds.length - 1][1]; var bMax = bound.lowerBounds[0][1]; return { name: bound.name, hueRange: bound.hueRange, lowerBounds: bound.lowerBounds, saturationRange: [sMin, sMax], brightnessRange: [bMin, bMax], }; } /** * @hidden */ var bounds = [ { name: "monochrome", hueRange: null, lowerBounds: [ [0, 0], [100, 0], ], }, { name: "red", hueRange: [-26, 18], lowerBounds: [ [20, 100], [30, 92], [40, 89], [50, 85], [60, 78], [70, 70], [80, 60], [90, 55], [100, 50], ], }, { name: "orange", hueRange: [19, 46], lowerBounds: [ [20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70], ], }, { name: "yellow", hueRange: [47, 62], lowerBounds: [ [25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75], ], }, { name: "green", hueRange: [63, 178], lowerBounds: [ [30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40], ], }, { name: "blue", hueRange: [179, 257], lowerBounds: [ [20, 100], [30, 86], [40, 80], [50, 74], [60, 60], [70, 52], [80, 44], [90, 39], [100, 35], ], }, { name: "purple", hueRange: [258, 282], lowerBounds: [ [20, 100], [30, 87], [40, 79], [50, 70], [60, 65], [70, 59], [80, 52], [90, 45], [100, 42], ], }, { name: "pink", hueRange: [283, 334], lowerBounds: [ [20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73], ], }, ]; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme-tools/dist/chakra-ui-theme-tools.esm.js /** * Get the color raw value from theme * @param theme - the theme object * @param color - the color path ("green.200") * @param fallback - the fallback color * * @deprecated This will be removed in the next major release. */ var getColor = function getColor(theme, color, fallback) { var hex = (0, chakra_ui_utils_esm /* memoizedGet */.Wf)( theme, "colors." + color, color ); var _TinyColor = new module_TinyColor(hex), isValid = _TinyColor.isValid; return isValid ? hex : fallback; }; /** * Determines if the tone of given color is "light" or "dark" * @param color - the color in hex, rgb, or hsl * * @deprecated This will be removed in the next major release. */ var tone = function tone(color) { return function (theme) { var hex = getColor(theme, color); var isDark = new module_TinyColor(hex).isDark(); return isDark ? "dark" : "light"; }; }; /** * Determines if a color tone is "dark" * @param color - the color in hex, rgb, or hsl * * @deprecated This will be removed in the next major release. */ var isDark = function isDark(color) { return function (theme) { return tone(color)(theme) === "dark"; }; }; /** * Determines if a color tone is "light" * @param color - the color in hex, rgb, or hsl * * @deprecated This will be removed in the next major release. */ var isLight = function isLight(color) { return function (theme) { return tone(color)(theme) === "light"; }; }; /** * Make a color transparent * @param color - the color in hex, rgb, or hsl * @param opacity - the amount of opacity the color should have (0-1) * * @deprecated This will be removed in the next major release. */ var transparentize = function transparentize(color, opacity) { return function (theme) { var raw = getColor(theme, color); return new module_TinyColor(raw) .setAlpha(opacity) .toRgbString(); }; }; /** * Add white to a color * @param color - the color in hex, rgb, or hsl * @param amount - the amount white to add (0-100) * * @deprecated This will be removed in the next major release. */ var whiten = function whiten(color, amount) { return function (theme) { var raw = getColor(theme, color); return new TinyColor(raw).mix("#fff", amount).toHexString(); }; }; /** * Add black to a color * @param color - the color in hex, rgb, or hsl * @param amount - the amount black to add (0-100) * * @deprecated This will be removed in the next major release. */ var blacken = function blacken(color, amount) { return function (theme) { var raw = getColor(theme, color); return new TinyColor(raw).mix("#000", amount).toHexString(); }; }; /** * Darken a specified color * @param color - the color in hex, rgb, or hsl * @param amount - the amount to darken (0-100) * * @deprecated This will be removed in the next major release. */ var darken = function darken(color, amount) { return function (theme) { var raw = getColor(theme, color); return new TinyColor(raw).darken(amount).toHexString(); }; }; /** * Lighten a specified color * @param color - the color in hex, rgb, or hsl * @param amount - the amount to lighten (0-100) * * @deprecated This will be removed in the next major release. */ var lighten = function lighten(color, amount) { return function (theme) { return new TinyColor(getColor(theme, color)) .lighten(amount) .toHexString(); }; }; /** * Checks the contract ratio of between 2 colors, * based on the Web Content Accessibility Guidelines (Version 2.0). * * @param fg - the foreground or text color * @param bg - the background color * * @deprecated This will be removed in the next major release. */ var contrast = function contrast(fg, bg) { return function (theme) { return readability( getColor(theme, bg), getColor(theme, fg) ); }; }; /** * Checks if a color meets the Web Content Accessibility * Guidelines (Version 2.0) for contrast ratio. * * @param textColor - the foreground or text color * @param bgColor - the background color * @param options * * @deprecated This will be removed in the next major release. */ var isAccessible = function isAccessible( textColor, bgColor, options ) { return function (theme) { return isReadable( getColor(theme, bgColor), getColor(theme, textColor), options ); }; }; /** * * @deprecated This will be removed in the next major release. */ var complementary = function complementary(color) { return function (theme) { return new TinyColor(getColor(theme, color)) .complement() .toHexString(); }; }; function generateStripe(size, color) { if (size === void 0) { size = "1rem"; } if (color === void 0) { color = "rgba(255, 255, 255, 0.15)"; } return { backgroundImage: "linear-gradient(\n 45deg,\n " + color + " 25%,\n transparent 25%,\n transparent 50%,\n " + color + " 50%,\n " + color + " 75%,\n transparent 75%,\n transparent\n )", backgroundSize: size + " " + size, }; } function randomColor(opts) { var fallback = random().toHexString(); if ( !opts || (0, chakra_ui_utils_esm /* isEmptyObject */.Qr)(opts) ) { return fallback; } if (opts.string && opts.colors) { return randomColorFromList(opts.string, opts.colors); } if (opts.string && !opts.colors) { return randomColorFromString(opts.string); } if (opts.colors && !opts.string) { return randomFromList(opts.colors); } return fallback; } function randomColorFromString(str) { var hash = 0; if (str.length === 0) return hash.toString(); for (var i = 0; i < str.length; i += 1) { hash = str.charCodeAt(i) + ((hash << 5) - hash); hash = hash & hash; } var color = "#"; for (var j = 0; j < 3; j += 1) { var value = (hash >> (j * 8)) & 255; color += ("00" + value.toString(16)).substr(-2); } return color; } function randomColorFromList(str, list) { var index = 0; if (str.length === 0) return list[0]; for (var i = 0; i < str.length; i += 1) { index = str.charCodeAt(i) + ((index << 5) - index); index = index & index; } index = ((index % list.length) + list.length) % list.length; return list[index]; } function randomFromList(list) { return list[Math.floor(Math.random() * list.length)]; } function mode(light, dark) { return function (props) { return props.colorMode === "dark" ? dark : light; }; } function orient(options) { var orientation = options.orientation, vertical = options.vertical, horizontal = options.horizontal; if (!orientation) return {}; return orientation === "vertical" ? vertical : horizontal; } function chakra_ui_theme_tools_esm_extends() { chakra_ui_theme_tools_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return chakra_ui_theme_tools_esm_extends.apply(this, arguments); } var createBreakpoints = function createBreakpoints(config) { (0, chakra_ui_utils_esm /* warn */.ZK)({ condition: true, message: [ "[chakra-ui]: createBreakpoints(...) will be deprecated pretty soon", "simply pass the breakpoints as an object. Remove the createBreakpoint(..) call", ].join(""), }); return chakra_ui_theme_tools_esm_extends( { base: "0em", }, config ); }; function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false, }); return Constructor; } /** * Used to define the anatomy/parts of a component in a way that provides * a consistent API for `className`, css selector and `theming`. */ var Anatomy = /*#__PURE__*/ (function () { function Anatomy(name) { var _this = this; this.map = {}; this.called = false; this.assert = function () { if (!_this.called) { _this.called = true; return; } throw new Error( "[anatomy] .part(...) should only be called once. Did you mean to use .extend(...) ?" ); }; this.parts = function () { _this.assert(); for ( var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++ ) { values[_key] = arguments[_key]; } for ( var _i = 0, _values = values; _i < _values.length; _i++ ) { var part = _values[_i]; _this.map[part] = _this.toPart(part); } return _this; }; this.extend = function () { for ( var _len2 = arguments.length, parts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++ ) { parts[_key2] = arguments[_key2]; } for ( var _i2 = 0, _parts = parts; _i2 < _parts.length; _i2++ ) { var part = _parts[_i2]; if (part in _this.map) continue; _this.map[part] = _this.toPart(part); } return _this; }; this.toPart = function (part) { var el = ["container", "root"].includes( part != null ? part : "" ) ? [_this.name] : [_this.name, part]; var attr = el.filter(Boolean).join("__"); var className = "chakra-" + attr; var partObj = { className: className, selector: "." + className, toString: function toString() { return part; }, }; return partObj; }; this.__type = {}; } /** * Prevents user from calling `.parts` multiple times. * It should only be called once. */ _createClass(Anatomy, [ { key: "selectors", get: /** * Get all selectors for the component anatomy */ function get() { var value = (0, chakra_ui_utils_esm /* fromEntries */.sq)( Object.entries(this.map).map(function ( _ref ) { var key = _ref[0], part = _ref[1]; return [key, part.selector]; }) ); return value; }, /** * Get all classNames for the component anatomy */ }, { key: "classNames", get: function get() { var value = (0, chakra_ui_utils_esm /* fromEntries */.sq)( Object.entries(this.map).map(function (_ref2) { var key = _ref2[0], part = _ref2[1]; return [key, part.className]; }) ); return value; }, /** * Get all parts as array of string */ }, { key: "keys", get: function get() { return Object.keys(this.map); }, /** * Creates the part object for the given part */ }, ]); return Anatomy; })(); function anatomy(name) { return new Anatomy(name); } function toRef(operand) { if ( (0, chakra_ui_utils_esm /* isObject */.Kn)(operand) && operand.reference ) { return operand.reference; } return String(operand); } var toExpr = function toExpr(operator) { for ( var _len = arguments.length, operands = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++ ) { operands[_key - 1] = arguments[_key]; } return operands .map(toRef) .join(" " + operator + " ") .replace(/calc/g, ""); }; var _add = function add() { for ( var _len2 = arguments.length, operands = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++ ) { operands[_key2] = arguments[_key2]; } return ( "calc(" + toExpr.apply(void 0, ["+"].concat(operands)) + ")" ); }; var _subtract = function subtract() { for ( var _len3 = arguments.length, operands = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++ ) { operands[_key3] = arguments[_key3]; } return ( "calc(" + toExpr.apply(void 0, ["-"].concat(operands)) + ")" ); }; var _multiply = function multiply() { for ( var _len4 = arguments.length, operands = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++ ) { operands[_key4] = arguments[_key4]; } return ( "calc(" + toExpr.apply(void 0, ["*"].concat(operands)) + ")" ); }; var _divide = function divide() { for ( var _len5 = arguments.length, operands = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++ ) { operands[_key5] = arguments[_key5]; } return ( "calc(" + toExpr.apply(void 0, ["/"].concat(operands)) + ")" ); }; var _negate = function negate(x) { var value = toRef(x); if (value != null && !Number.isNaN(parseFloat(value))) { return String(value).startsWith("-") ? String(value).slice(1) : "-" + value; } return _multiply(value, -1); }; var calc = Object.assign( function (x) { return { add: function add() { for ( var _len6 = arguments.length, operands = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++ ) { operands[_key6] = arguments[_key6]; } return calc( _add.apply(void 0, [x].concat(operands)) ); }, subtract: function subtract() { for ( var _len7 = arguments.length, operands = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++ ) { operands[_key7] = arguments[_key7]; } return calc( _subtract.apply(void 0, [x].concat(operands)) ); }, multiply: function multiply() { for ( var _len8 = arguments.length, operands = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++ ) { operands[_key8] = arguments[_key8]; } return calc( _multiply.apply(void 0, [x].concat(operands)) ); }, divide: function divide() { for ( var _len9 = arguments.length, operands = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++ ) { operands[_key9] = arguments[_key9]; } return calc( _divide.apply(void 0, [x].concat(operands)) ); }, negate: function negate() { return calc(_negate(x)); }, toString: function toString() { return x.toString(); }, }; }, { add: _add, subtract: _subtract, multiply: _multiply, divide: _divide, negate: _negate, } ); function isDecimal(value) { return !Number.isInteger(parseFloat(value.toString())); } function replaceWhiteSpace(value, replaceValue) { if (replaceValue === void 0) { replaceValue = "-"; } return value.replace(/\s+/g, replaceValue); } function chakra_ui_theme_tools_esm_escape(value) { var valueStr = replaceWhiteSpace(value.toString()); if (valueStr.includes("\\.")) return value; return isDecimal(value) ? valueStr.replace(".", "\\.") : value; } function addPrefix(value, prefix) { if (prefix === void 0) { prefix = ""; } return [prefix, chakra_ui_theme_tools_esm_escape(value)] .filter(Boolean) .join("-"); } function toVarRef(name, fallback) { return ( "var(" + chakra_ui_theme_tools_esm_escape(name) + (fallback ? ", " + fallback : "") + ")" ); } function toVar(value, prefix) { if (prefix === void 0) { prefix = ""; } return "--" + addPrefix(value, prefix); } function cssVar(name, options) { var cssVariable = toVar( name, options == null ? void 0 : options.prefix ); return { variable: cssVariable, reference: toVarRef( cssVariable, getFallback(options == null ? void 0 : options.fallback) ), }; } function getFallback(fallback) { if (typeof fallback === "string") return fallback; return fallback == null ? void 0 : fallback.reference; } // CONCATENATED MODULE: ./node_modules/@chakra-ui/anatomy/dist/chakra-ui-anatomy.esm.js /** * **Accordion anatomy** * - Root: the root container of the accordion * - Container: the accordion item contains the button and panel * - Button: the button is the trigger for the panel * - Panel: the panel is the content of the accordion item * - Icon: the expanded/collapsed icon */ var accordionAnatomy = anatomy("accordion") .parts("root", "container", "button", "panel") .extend("icon"); /** * **Alert anatomy** * - Title: the alert's title * - Description: the alert's description * - Icon: the alert's icon */ var alertAnatomy = anatomy("alert") .parts("title", "description", "container") .extend("icon", "spinner"); /** * **Avatar anatomy** * - Container: the container for the avatar * - Label: the avatar initials text * - Excess Label: the label or text that represents excess avatar count. * Typically used in avatar groups. * - Group: the container for the avatar group */ var avatarAnatomy = anatomy("avatar") .parts("label", "badge", "container") .extend("excessLabel", "group"); /** * **Breadcrumb anatomy** * - Item: the container for a breadcrumb item * - Link: the element that represents the breadcrumb link * - Container: the container for the breadcrumb items * - Separator: the separator between breadcrumb items */ var breadcrumbAnatomy = anatomy("breadcrumb") .parts("link", "item", "container") .extend("separator"); var buttonAnatomy = anatomy("button").parts(); var checkboxAnatomy = anatomy("checkbox") .parts("control", "icon", "container") .extend("label"); var circularProgressAnatomy = anatomy("progress") .parts("track", "filledTrack") .extend("label"); var drawerAnatomy = anatomy("drawer") .parts("overlay", "dialogContainer", "dialog") .extend("header", "closeButton", "body", "footer"); var editableAnatomy = anatomy("editable").parts( "preview", "input", "textarea" ); var formAnatomy = anatomy("form").parts( "container", "requiredIndicator", "helperText" ); var formErrorAnatomy = anatomy("formError").parts("text", "icon"); var inputAnatomy = anatomy("input").parts( "addon", "field", "element" ); var listAnatomy = anatomy("list").parts( "container", "item", "icon" ); var menuAnatomy = anatomy("menu") .parts("button", "list", "item") .extend("groupTitle", "command", "divider"); var modalAnatomy = anatomy("modal") .parts("overlay", "dialogContainer", "dialog") .extend("header", "closeButton", "body", "footer"); var numberInputAnatomy = anatomy("numberinput").parts( "root", "field", "stepperGroup", "stepper" ); var pinInputAnatomy = anatomy("pininput").parts("field"); var popoverAnatomy = anatomy("popover") .parts("content", "header", "body", "footer") .extend("popper", "arrow", "closeButton"); var progressAnatomy = anatomy("progress").parts( "label", "filledTrack", "track" ); var radioAnatomy = anatomy("radio").parts( "container", "control", "label" ); var selectAnatomy = anatomy("select").parts("field", "icon"); var sliderAnatomy = anatomy("slider").parts( "container", "track", "thumb", "filledTrack" ); var statAnatomy = anatomy("stat").parts( "container", "label", "helpText", "number", "icon" ); var switchAnatomy = anatomy("switch").parts( "container", "track", "thumb" ); var tableAnatomy = anatomy("table").parts( "table", "thead", "tbody", "tr", "th", "td", "tfoot", "caption" ); var tabsAnatomy = anatomy("tabs").parts( "root", "tab", "tablist", "tabpanel", "tabpanels", "indicator" ); /** * **Tag anatomy** * - Container: the container for the tag * - Label: the text content of the tag * - closeButton: the close button for the tag */ var tagAnatomy = anatomy("tag").parts( "container", "label", "closeButton" ); // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/typography/dist/chakra-ui-theme-foundations-typography.esm.js var typography = { letterSpacings: { tighter: "-0.05em", tight: "-0.025em", normal: "0", wide: "0.025em", wider: "0.05em", widest: "0.1em", }, lineHeights: { normal: "normal", none: 1, shorter: 1.25, short: 1.375, base: 1.5, tall: 1.625, taller: "2", 3: ".75rem", 4: "1rem", 5: "1.25rem", 6: "1.5rem", 7: "1.75rem", 8: "2rem", 9: "2.25rem", 10: "2.5rem", }, fontWeights: { hairline: 100, thin: 200, light: 300, normal: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900, }, fonts: { heading: '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"', body: '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"', mono: 'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace', }, fontSizes: { xs: "0.75rem", sm: "0.875rem", md: "1rem", lg: "1.125rem", xl: "1.25rem", "2xl": "1.5rem", "3xl": "1.875rem", "4xl": "2.25rem", "5xl": "3rem", "6xl": "3.75rem", "7xl": "4.5rem", "8xl": "6rem", "9xl": "8rem", }, }; // EXTERNAL MODULE: ./node_modules/lodash.mergewith/index.js var lodash_mergewith = __webpack_require__(8554); var lodash_mergewith_default = /*#__PURE__*/ __webpack_require__.n(lodash_mergewith); // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/components/dist/chakra-ui-theme-components.esm.js var baseStyleContainer$4 = { borderTopWidth: "1px", borderColor: "inherit", _last: { borderBottomWidth: "1px", }, }; var baseStyleButton$1 = { transitionProperty: "common", transitionDuration: "normal", fontSize: "1rem", _focusVisible: { boxShadow: "outline", }, _hover: { bg: "blackAlpha.50", }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, px: 4, py: 2, }; var baseStylePanel = { pt: 2, px: 4, pb: 5, }; var baseStyleIcon$5 = { fontSize: "1.25em", }; var baseStyle$D = { root: {}, container: baseStyleContainer$4, button: baseStyleButton$1, panel: baseStylePanel, icon: baseStyleIcon$5, }; var Accordion = { parts: accordionAnatomy.keys, baseStyle: baseStyle$D, }; var baseStyle$C = { container: { px: 4, py: 3, }, title: { fontWeight: "bold", lineHeight: 6, marginEnd: 2, }, description: { lineHeight: 6, }, icon: { flexShrink: 0, marginEnd: 3, w: 5, h: 6, }, spinner: { flexShrink: 0, marginEnd: 3, w: 5, h: 5, }, }; function getBg(props) { var theme = props.theme, c = props.colorScheme; var lightBg = getColor(theme, c + ".100", c); var darkBg = transparentize(c + ".200", 0.16)(theme); return mode(lightBg, darkBg)(props); } var variantSubtle$1 = function variantSubtle(props) { var c = props.colorScheme; return { container: { bg: getBg(props), }, icon: { color: mode(c + ".500", c + ".200")(props), }, spinner: { color: mode(c + ".500", c + ".200")(props), }, }; }; var variantLeftAccent = function variantLeftAccent(props) { var c = props.colorScheme; return { container: { paddingStart: 3, borderStartWidth: "4px", borderStartColor: mode(c + ".500", c + ".200")(props), bg: getBg(props), }, icon: { color: mode(c + ".500", c + ".200")(props), }, spinner: { color: mode(c + ".500", c + ".200")(props), }, }; }; var variantTopAccent = function variantTopAccent(props) { var c = props.colorScheme; return { container: { pt: 2, borderTopWidth: "4px", borderTopColor: mode(c + ".500", c + ".200")(props), bg: getBg(props), }, icon: { color: mode(c + ".500", c + ".200")(props), }, spinner: { color: mode(c + ".500", c + ".200")(props), }, }; }; var variantSolid$3 = function variantSolid(props) { var c = props.colorScheme; return { container: { bg: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props), }, }; }; var variants$b = { subtle: variantSubtle$1, "left-accent": variantLeftAccent, "top-accent": variantTopAccent, solid: variantSolid$3, }; var defaultProps$n = { variant: "subtle", colorScheme: "blue", }; var Alert = { parts: alertAnatomy.keys, baseStyle: baseStyle$C, variants: variants$b, defaultProps: defaultProps$n, }; var baseStyleBadge = function baseStyleBadge(props) { return { transform: "translate(25%, 25%)", borderRadius: "full", border: "0.2em solid", borderColor: mode("white", "gray.800")(props), }; }; var baseStyleExcessLabel = function baseStyleExcessLabel(props) { return { bg: mode("gray.200", "whiteAlpha.400")(props), }; }; var baseStyleContainer$3 = function baseStyleContainer(props) { var name = props.name, theme = props.theme; var bg = name ? randomColor({ string: name, }) : "gray.400"; var isBgDark = isDark(bg)(theme); var color = "white"; if (!isBgDark) color = "gray.800"; var borderColor = mode("white", "gray.800")(props); return { bg: bg, color: color, borderColor: borderColor, verticalAlign: "top", }; }; var baseStyle$B = function baseStyle(props) { return { badge: baseStyleBadge(props), excessLabel: baseStyleExcessLabel(props), container: baseStyleContainer$3(props), }; }; function getSize$3(size) { var themeSize = size !== "100%" ? sizes[size] : undefined; return { container: { width: size, height: size, fontSize: "calc(" + (themeSize != null ? themeSize : size) + " / 2.5)", }, excessLabel: { width: size, height: size, }, label: { fontSize: "calc(" + (themeSize != null ? themeSize : size) + " / 2.5)", lineHeight: size !== "100%" ? themeSize != null ? themeSize : size : undefined, }, }; } var sizes$k = { "2xs": getSize$3(4), xs: getSize$3(6), sm: getSize$3(8), md: getSize$3(12), lg: getSize$3(16), xl: getSize$3(24), "2xl": getSize$3(32), full: getSize$3("100%"), }; var defaultProps$m = { size: "md", }; var Avatar = { parts: avatarAnatomy.keys, baseStyle: baseStyle$B, sizes: sizes$k, defaultProps: defaultProps$m, }; var baseStyle$A = { px: 1, textTransform: "uppercase", fontSize: "xs", borderRadius: "sm", fontWeight: "bold", }; var variantSolid$2 = function variantSolid(props) { var c = props.colorScheme, theme = props.theme; var dark = transparentize(c + ".500", 0.6)(theme); return { bg: mode(c + ".500", dark)(props), color: mode("white", "whiteAlpha.800")(props), }; }; var variantSubtle = function variantSubtle(props) { var c = props.colorScheme, theme = props.theme; var darkBg = transparentize(c + ".200", 0.16)(theme); return { bg: mode(c + ".100", darkBg)(props), color: mode(c + ".800", c + ".200")(props), }; }; var variantOutline$2 = function variantOutline(props) { var c = props.colorScheme, theme = props.theme; var darkColor = transparentize(c + ".200", 0.8)(theme); var lightColor = getColor(theme, c + ".500"); var color = mode(lightColor, darkColor)(props); return { color: color, boxShadow: "inset 0 0 0px 1px " + color, }; }; var variants$a = { solid: variantSolid$2, subtle: variantSubtle, outline: variantOutline$2, }; var defaultProps$l = { variant: "subtle", colorScheme: "gray", }; var Badge = { baseStyle: baseStyle$A, variants: variants$a, defaultProps: defaultProps$l, }; var baseStyleLink = { transitionProperty: "common", transitionDuration: "fast", transitionTimingFunction: "ease-out", cursor: "pointer", textDecoration: "none", outline: "none", color: "inherit", _hover: { textDecoration: "underline", }, _focusVisible: { boxShadow: "outline", }, }; var baseStyle$z = { link: baseStyleLink, }; var Breadcrumb = { parts: breadcrumbAnatomy.keys, baseStyle: baseStyle$z, }; var baseStyle$y = { lineHeight: "1.2", borderRadius: "md", fontWeight: "semibold", transitionProperty: "common", transitionDuration: "normal", _focusVisible: { boxShadow: "outline", }, _disabled: { opacity: 0.4, cursor: "not-allowed", boxShadow: "none", }, _hover: { _disabled: { bg: "initial", }, }, }; var variantGhost = function variantGhost(props) { var c = props.colorScheme, theme = props.theme; if (c === "gray") { return { color: mode("inherit", "whiteAlpha.900")(props), _hover: { bg: mode("gray.100", "whiteAlpha.200")(props), }, _active: { bg: mode("gray.200", "whiteAlpha.300")(props), }, }; } var darkHoverBg = transparentize(c + ".200", 0.12)(theme); var darkActiveBg = transparentize(c + ".200", 0.24)(theme); return { color: mode(c + ".600", c + ".200")(props), bg: "transparent", _hover: { bg: mode(c + ".50", darkHoverBg)(props), }, _active: { bg: mode(c + ".100", darkActiveBg)(props), }, }; }; var variantOutline$1 = function variantOutline(props) { var c = props.colorScheme; var borderColor = mode("gray.200", "whiteAlpha.300")(props); return sizes_501602a9_esm_extends( { border: "1px solid", borderColor: c === "gray" ? borderColor : "currentColor", ".chakra-button__group[data-attached] > &:not(:last-of-type)": { marginEnd: "-1px", }, }, variantGhost(props) ); }; /** Accessible color overrides for less accessible colors. */ var accessibleColorMap = { yellow: { bg: "yellow.400", color: "black", hoverBg: "yellow.500", activeBg: "yellow.600", }, cyan: { bg: "cyan.400", color: "black", hoverBg: "cyan.500", activeBg: "cyan.600", }, }; var variantSolid$1 = function variantSolid(props) { var _accessibleColorMap$c; var c = props.colorScheme; if (c === "gray") { var _bg = mode("gray.100", "whiteAlpha.200")(props); return { bg: _bg, _hover: { bg: mode("gray.200", "whiteAlpha.300")(props), _disabled: { bg: _bg, }, }, _active: { bg: mode("gray.300", "whiteAlpha.400")(props), }, }; } var _ref = (_accessibleColorMap$c = accessibleColorMap[c]) != null ? _accessibleColorMap$c : {}, _ref$bg = _ref.bg, bg = _ref$bg === void 0 ? c + ".500" : _ref$bg, _ref$color = _ref.color, color = _ref$color === void 0 ? "white" : _ref$color, _ref$hoverBg = _ref.hoverBg, hoverBg = _ref$hoverBg === void 0 ? c + ".600" : _ref$hoverBg, _ref$activeBg = _ref.activeBg, activeBg = _ref$activeBg === void 0 ? c + ".700" : _ref$activeBg; var background = mode(bg, c + ".200")(props); return { bg: background, color: mode(color, "gray.800")(props), _hover: { bg: mode(hoverBg, c + ".300")(props), _disabled: { bg: background, }, }, _active: { bg: mode(activeBg, c + ".400")(props), }, }; }; var variantLink = function variantLink(props) { var c = props.colorScheme; return { padding: 0, height: "auto", lineHeight: "normal", verticalAlign: "baseline", color: mode(c + ".500", c + ".200")(props), _hover: { textDecoration: "underline", _disabled: { textDecoration: "none", }, }, _active: { color: mode(c + ".700", c + ".500")(props), }, }; }; var variantUnstyled$2 = { bg: "none", color: "inherit", display: "inline", lineHeight: "inherit", m: 0, p: 0, }; var variants$9 = { ghost: variantGhost, outline: variantOutline$1, solid: variantSolid$1, link: variantLink, unstyled: variantUnstyled$2, }; var sizes$j = { lg: { h: 12, minW: 12, fontSize: "lg", px: 6, }, md: { h: 10, minW: 10, fontSize: "md", px: 4, }, sm: { h: 8, minW: 8, fontSize: "sm", px: 3, }, xs: { h: 6, minW: 6, fontSize: "xs", px: 2, }, }; var defaultProps$k = { variant: "solid", size: "md", colorScheme: "gray", }; var Button = { baseStyle: baseStyle$y, variants: variants$9, sizes: sizes$j, defaultProps: defaultProps$k, }; var baseStyleControl$1 = function baseStyleControl(props) { var c = props.colorScheme; return { w: "100%", transitionProperty: "box-shadow", transitionDuration: "normal", border: "2px solid", borderRadius: "sm", borderColor: "inherit", color: "white", _checked: { bg: mode(c + ".500", c + ".200")(props), borderColor: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props), _hover: { bg: mode(c + ".600", c + ".300")(props), borderColor: mode(c + ".600", c + ".300")(props), }, _disabled: { borderColor: mode("gray.200", "transparent")(props), bg: mode("gray.200", "whiteAlpha.300")(props), color: mode("gray.500", "whiteAlpha.500")(props), }, }, _indeterminate: { bg: mode(c + ".500", c + ".200")(props), borderColor: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props), }, _disabled: { bg: mode("gray.100", "whiteAlpha.100")(props), borderColor: mode("gray.100", "transparent")(props), }, _focusVisible: { boxShadow: "outline", }, _invalid: { borderColor: mode("red.500", "red.300")(props), }, }; }; var baseStyleContainer$2 = { _disabled: { cursor: "not-allowed", }, }; var baseStyleLabel$3 = { userSelect: "none", _disabled: { opacity: 0.4, }, }; var baseStyleIcon$4 = { transitionProperty: "transform", transitionDuration: "normal", }; var baseStyle$x = function baseStyle(props) { return { icon: baseStyleIcon$4, container: baseStyleContainer$2, control: baseStyleControl$1(props), label: baseStyleLabel$3, }; }; var sizes$i = { sm: { control: { h: 3, w: 3, }, label: { fontSize: "sm", }, icon: { fontSize: "0.45rem", }, }, md: { control: { w: 4, h: 4, }, label: { fontSize: "md", }, icon: { fontSize: "0.625rem", }, }, lg: { control: { w: 5, h: 5, }, label: { fontSize: "lg", }, icon: { fontSize: "0.625rem", }, }, }; var defaultProps$j = { size: "md", colorScheme: "blue", }; var Checkbox = { parts: checkboxAnatomy.keys, baseStyle: baseStyle$x, sizes: sizes$i, defaultProps: defaultProps$j, }; var _lg$1, _md$1, _sm$1; var $size$1 = cssVar("close-button-size"); var baseStyle$w = function baseStyle(props) { var hoverBg = mode("blackAlpha.100", "whiteAlpha.100")(props); var activeBg = mode("blackAlpha.200", "whiteAlpha.200")(props); return { w: [$size$1.reference], h: [$size$1.reference], borderRadius: "md", transitionProperty: "common", transitionDuration: "normal", _disabled: { opacity: 0.4, cursor: "not-allowed", boxShadow: "none", }, _hover: { bg: hoverBg, }, _active: { bg: activeBg, }, _focusVisible: { boxShadow: "outline", }, }; }; var sizes$h = { lg: ((_lg$1 = {}), (_lg$1[$size$1.variable] = "40px"), (_lg$1.fontSize = "16px"), _lg$1), md: ((_md$1 = {}), (_md$1[$size$1.variable] = "32px"), (_md$1.fontSize = "12px"), _md$1), sm: ((_sm$1 = {}), (_sm$1[$size$1.variable] = "24px"), (_sm$1.fontSize = "10px"), _sm$1), }; var defaultProps$i = { size: "md", }; var CloseButton = { baseStyle: baseStyle$w, sizes: sizes$h, defaultProps: defaultProps$i, }; var variants$8 = Badge.variants, defaultProps$h = Badge.defaultProps; var baseStyle$v = { fontFamily: "mono", fontSize: "sm", px: "0.2em", borderRadius: "sm", }; var Code = { baseStyle: baseStyle$v, variants: variants$8, defaultProps: defaultProps$h, }; var baseStyle$u = { w: "100%", mx: "auto", maxW: "60ch", px: "1rem", }; var chakra_ui_theme_components_esm_Container = { baseStyle: baseStyle$u, }; var baseStyle$t = { opacity: 0.6, borderColor: "inherit", }; var variantSolid = { borderStyle: "solid", }; var variantDashed = { borderStyle: "dashed", }; var variants$7 = { solid: variantSolid, dashed: variantDashed, }; var defaultProps$g = { variant: "solid", }; var Divider = { baseStyle: baseStyle$t, variants: variants$7, defaultProps: defaultProps$g, }; /** * Since the `maxWidth` prop references theme.sizes internally, * we can leverage that to size our modals. */ function getSize$2(value) { if (value === "full") { return { dialog: { maxW: "100vw", h: "100vh", }, }; } return { dialog: { maxW: value, }, }; } var baseStyleOverlay$1 = { bg: "blackAlpha.600", zIndex: "overlay", }; var baseStyleDialogContainer$1 = { display: "flex", zIndex: "modal", justifyContent: "center", }; var baseStyleDialog$1 = function baseStyleDialog(props) { var isFullHeight = props.isFullHeight; return sizes_501602a9_esm_extends( {}, isFullHeight && { height: "100vh", }, { zIndex: "modal", maxH: "100vh", bg: mode("white", "gray.700")(props), color: "inherit", boxShadow: mode("lg", "dark-lg")(props), } ); }; var baseStyleHeader$2 = { px: 6, py: 4, fontSize: "xl", fontWeight: "semibold", }; var baseStyleCloseButton$3 = { position: "absolute", top: 2, insetEnd: 3, }; var baseStyleBody$2 = { px: 6, py: 2, flex: 1, overflow: "auto", }; var baseStyleFooter$2 = { px: 6, py: 4, }; var baseStyle$s = function baseStyle(props) { return { overlay: baseStyleOverlay$1, dialogContainer: baseStyleDialogContainer$1, dialog: baseStyleDialog$1(props), header: baseStyleHeader$2, closeButton: baseStyleCloseButton$3, body: baseStyleBody$2, footer: baseStyleFooter$2, }; }; var sizes$g = { xs: getSize$2("xs"), sm: getSize$2("md"), md: getSize$2("lg"), lg: getSize$2("2xl"), xl: getSize$2("4xl"), full: getSize$2("full"), }; var defaultProps$f = { size: "xs", }; var Drawer = { parts: drawerAnatomy.keys, baseStyle: baseStyle$s, sizes: sizes$g, defaultProps: defaultProps$f, }; var baseStylePreview = { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal", }; var baseStyleInput = { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal", width: "full", _focusVisible: { boxShadow: "outline", }, _placeholder: { opacity: 0.6, }, }; var baseStyleTextarea = { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal", width: "full", _focusVisible: { boxShadow: "outline", }, _placeholder: { opacity: 0.6, }, }; var baseStyle$r = { preview: baseStylePreview, input: baseStyleInput, textarea: baseStyleTextarea, }; var Editable = { parts: editableAnatomy.keys, baseStyle: baseStyle$r, }; var baseStyleRequiredIndicator = function baseStyleRequiredIndicator(props) { return { marginStart: 1, color: mode("red.500", "red.300")(props), }; }; var baseStyleHelperText = function baseStyleHelperText(props) { return { mt: 2, color: mode("gray.500", "whiteAlpha.600")(props), lineHeight: "normal", fontSize: "sm", }; }; var baseStyle$q = function baseStyle(props) { return { container: { width: "100%", position: "relative", }, requiredIndicator: baseStyleRequiredIndicator(props), helperText: baseStyleHelperText(props), }; }; var Form = { parts: formAnatomy.keys, baseStyle: baseStyle$q, }; var baseStyleText = function baseStyleText(props) { return { color: mode("red.500", "red.300")(props), mt: 2, fontSize: "sm", lineHeight: "normal", }; }; var baseStyleIcon$3 = function baseStyleIcon(props) { return { marginEnd: "0.5em", color: mode("red.500", "red.300")(props), }; }; var baseStyle$p = function baseStyle(props) { return { text: baseStyleText(props), icon: baseStyleIcon$3(props), }; }; var FormError = { parts: formErrorAnatomy.keys, baseStyle: baseStyle$p, }; var baseStyle$o = { fontSize: "md", marginEnd: 3, mb: 2, fontWeight: "medium", transitionProperty: "common", transitionDuration: "normal", opacity: 1, _disabled: { opacity: 0.4, }, }; var FormLabel = { baseStyle: baseStyle$o, }; var baseStyle$n = { fontFamily: "heading", fontWeight: "bold", }; var sizes$f = { "4xl": { fontSize: ["6xl", null, "7xl"], lineHeight: 1, }, "3xl": { fontSize: ["5xl", null, "6xl"], lineHeight: 1, }, "2xl": { fontSize: ["4xl", null, "5xl"], lineHeight: [1.2, null, 1], }, xl: { fontSize: ["3xl", null, "4xl"], lineHeight: [1.33, null, 1.2], }, lg: { fontSize: ["2xl", null, "3xl"], lineHeight: [1.33, null, 1.2], }, md: { fontSize: "xl", lineHeight: 1.2, }, sm: { fontSize: "md", lineHeight: 1.2, }, xs: { fontSize: "sm", lineHeight: 1.2, }, }; var defaultProps$e = { size: "xl", }; var Heading = { baseStyle: baseStyle$n, sizes: sizes$f, defaultProps: defaultProps$e, }; var baseStyle$m = { field: { width: "100%", minWidth: 0, outline: 0, position: "relative", appearance: "none", transitionProperty: "common", transitionDuration: "normal", }, }; var size = { lg: { fontSize: "lg", px: 4, h: 12, borderRadius: "md", }, md: { fontSize: "md", px: 4, h: 10, borderRadius: "md", }, sm: { fontSize: "sm", px: 3, h: 8, borderRadius: "sm", }, xs: { fontSize: "xs", px: 2, h: 6, borderRadius: "sm", }, }; var sizes$e = { lg: { field: size.lg, addon: size.lg, }, md: { field: size.md, addon: size.md, }, sm: { field: size.sm, addon: size.sm, }, xs: { field: size.xs, addon: size.xs, }, }; function getDefaults(props) { var fc = props.focusBorderColor, ec = props.errorBorderColor; return { focusBorderColor: fc || mode("blue.500", "blue.300")(props), errorBorderColor: ec || mode("red.500", "red.300")(props), }; } var variantOutline = function variantOutline(props) { var theme = props.theme; var _getDefaults = getDefaults(props), fc = _getDefaults.focusBorderColor, ec = _getDefaults.errorBorderColor; return { field: { border: "1px solid", borderColor: "inherit", bg: "inherit", _hover: { borderColor: mode( "gray.300", "whiteAlpha.400" )(props), }, _readOnly: { boxShadow: "none !important", userSelect: "all", }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, _invalid: { borderColor: getColor(theme, ec), boxShadow: "0 0 0 1px " + getColor(theme, ec), }, _focusVisible: { zIndex: 1, borderColor: getColor(theme, fc), boxShadow: "0 0 0 1px " + getColor(theme, fc), }, }, addon: { border: "1px solid", borderColor: mode("inherit", "whiteAlpha.50")(props), bg: mode("gray.100", "whiteAlpha.300")(props), }, }; }; var variantFilled = function variantFilled(props) { var theme = props.theme; var _getDefaults2 = getDefaults(props), fc = _getDefaults2.focusBorderColor, ec = _getDefaults2.errorBorderColor; return { field: { border: "2px solid", borderColor: "transparent", bg: mode("gray.100", "whiteAlpha.50")(props), _hover: { bg: mode("gray.200", "whiteAlpha.100")(props), }, _readOnly: { boxShadow: "none !important", userSelect: "all", }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, _invalid: { borderColor: getColor(theme, ec), }, _focusVisible: { bg: "transparent", borderColor: getColor(theme, fc), }, }, addon: { border: "2px solid", borderColor: "transparent", bg: mode("gray.100", "whiteAlpha.50")(props), }, }; }; var variantFlushed = function variantFlushed(props) { var theme = props.theme; var _getDefaults3 = getDefaults(props), fc = _getDefaults3.focusBorderColor, ec = _getDefaults3.errorBorderColor; return { field: { borderBottom: "1px solid", borderColor: "inherit", borderRadius: 0, px: 0, bg: "transparent", _readOnly: { boxShadow: "none !important", userSelect: "all", }, _invalid: { borderColor: getColor(theme, ec), boxShadow: "0px 1px 0px 0px " + getColor(theme, ec), }, _focusVisible: { borderColor: getColor(theme, fc), boxShadow: "0px 1px 0px 0px " + getColor(theme, fc), }, }, addon: { borderBottom: "2px solid", borderColor: "inherit", borderRadius: 0, px: 0, bg: "transparent", }, }; }; var variantUnstyled$1 = { field: { bg: "transparent", px: 0, height: "auto", }, addon: { bg: "transparent", px: 0, height: "auto", }, }; var variants$6 = { outline: variantOutline, filled: variantFilled, flushed: variantFlushed, unstyled: variantUnstyled$1, }; var defaultProps$d = { size: "md", variant: "outline", }; var Input = { parts: inputAnatomy.keys, baseStyle: baseStyle$m, sizes: sizes$e, variants: variants$6, defaultProps: defaultProps$d, }; var baseStyle$l = function baseStyle(props) { return { bg: mode("gray.100", "whiteAlpha")(props), borderRadius: "md", borderWidth: "1px", borderBottomWidth: "3px", fontSize: "0.8em", fontWeight: "bold", lineHeight: "normal", px: "0.4em", whiteSpace: "nowrap", }; }; var Kbd = { baseStyle: baseStyle$l, }; var baseStyle$k = { transitionProperty: "common", transitionDuration: "fast", transitionTimingFunction: "ease-out", cursor: "pointer", textDecoration: "none", outline: "none", color: "inherit", _hover: { textDecoration: "underline", }, _focusVisible: { boxShadow: "outline", }, }; var Link = { baseStyle: baseStyle$k, }; var baseStyleIcon$2 = { marginEnd: "0.5rem", display: "inline", verticalAlign: "text-bottom", }; var baseStyle$j = { container: {}, item: {}, icon: baseStyleIcon$2, }; var List = { parts: listAnatomy.keys, baseStyle: baseStyle$j, }; var baseStyleList = function baseStyleList(props) { return { bg: mode("#fff", "gray.700")(props), boxShadow: mode("sm", "dark-lg")(props), color: "inherit", minW: "3xs", py: "2", zIndex: 1, borderRadius: "md", borderWidth: "1px", }; }; var baseStyleItem = function baseStyleItem(props) { return { py: "0.4rem", px: "0.8rem", transitionProperty: "background", transitionDuration: "ultra-fast", transitionTimingFunction: "ease-in", _focus: { bg: mode("gray.100", "whiteAlpha.100")(props), }, _active: { bg: mode("gray.200", "whiteAlpha.200")(props), }, _expanded: { bg: mode("gray.100", "whiteAlpha.100")(props), }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, }; }; var baseStyleGroupTitle = { mx: 4, my: 2, fontWeight: "semibold", fontSize: "sm", }; var baseStyleCommand = { opacity: 0.6, }; var baseStyleDivider = { border: 0, borderBottom: "1px solid", borderColor: "inherit", my: "0.5rem", opacity: 0.6, }; var baseStyleButton = { transitionProperty: "common", transitionDuration: "normal", }; var baseStyle$i = function baseStyle(props) { return { button: baseStyleButton, list: baseStyleList(props), item: baseStyleItem(props), groupTitle: baseStyleGroupTitle, command: baseStyleCommand, divider: baseStyleDivider, }; }; var Menu = { parts: menuAnatomy.keys, baseStyle: baseStyle$i, }; var baseStyleOverlay = { bg: "blackAlpha.600", zIndex: "modal", }; var baseStyleDialogContainer = function baseStyleDialogContainer( props ) { var isCentered = props.isCentered, scrollBehavior = props.scrollBehavior; return { display: "flex", zIndex: "modal", justifyContent: "center", alignItems: isCentered ? "center" : "flex-start", overflow: scrollBehavior === "inside" ? "hidden" : "auto", }; }; var baseStyleDialog = function baseStyleDialog(props) { var scrollBehavior = props.scrollBehavior; return { borderRadius: "md", bg: mode("white", "gray.700")(props), color: "inherit", my: "3.75rem", zIndex: "modal", maxH: scrollBehavior === "inside" ? "calc(100% - 7.5rem)" : undefined, boxShadow: mode("lg", "dark-lg")(props), }; }; var baseStyleHeader$1 = { px: 6, py: 4, fontSize: "xl", fontWeight: "semibold", }; var baseStyleCloseButton$2 = { position: "absolute", top: 2, insetEnd: 3, }; var baseStyleBody$1 = function baseStyleBody(props) { var scrollBehavior = props.scrollBehavior; return { px: 6, py: 2, flex: 1, overflow: scrollBehavior === "inside" ? "auto" : undefined, }; }; var baseStyleFooter$1 = { px: 6, py: 4, }; var baseStyle$h = function baseStyle(props) { return { overlay: baseStyleOverlay, dialogContainer: baseStyleDialogContainer(props), dialog: baseStyleDialog(props), header: baseStyleHeader$1, closeButton: baseStyleCloseButton$2, body: baseStyleBody$1(props), footer: baseStyleFooter$1, }; }; /** * Since the `maxWidth` prop references theme.sizes internally, * we can leverage that to size our modals. */ function getSize$1(value) { if (value === "full") { return { dialog: { maxW: "100vw", minH: "100vh", "@supports(min-height: -webkit-fill-available)": { minH: "-webkit-fill-available", }, my: 0, }, }; } return { dialog: { maxW: value, }, }; } var sizes$d = { xs: getSize$1("xs"), sm: getSize$1("sm"), md: getSize$1("md"), lg: getSize$1("lg"), xl: getSize$1("xl"), "2xl": getSize$1("2xl"), "3xl": getSize$1("3xl"), "4xl": getSize$1("4xl"), "5xl": getSize$1("5xl"), "6xl": getSize$1("6xl"), full: getSize$1("full"), }; var defaultProps$c = { size: "md", }; var Modal = { parts: modalAnatomy.keys, baseStyle: baseStyle$h, sizes: sizes$d, defaultProps: defaultProps$c, }; var _baseStyleRoot, _Input$baseStyle$fiel, _Input$baseStyle; var variants$5 = Input.variants, defaultProps$b = Input.defaultProps; var $stepperWidth = cssVar("number-input-stepper-width"); var $inputPadding = cssVar("number-input-input-padding"); var inputPaddingValue = calc($stepperWidth) .add("0.5rem") .toString(); var baseStyleRoot$1 = ((_baseStyleRoot = {}), (_baseStyleRoot[$stepperWidth.variable] = "24px"), (_baseStyleRoot[$inputPadding.variable] = inputPaddingValue), _baseStyleRoot); var baseStyleField$1 = (_Input$baseStyle$fiel = (_Input$baseStyle = Input.baseStyle) == null ? void 0 : _Input$baseStyle.field) != null ? _Input$baseStyle$fiel : {}; var baseStyleStepperGroup = { width: [$stepperWidth.reference], }; var baseStyleStepper = function baseStyleStepper(props) { return { borderStart: "1px solid", borderStartColor: mode("inherit", "whiteAlpha.300")(props), color: mode("inherit", "whiteAlpha.800")(props), _active: { bg: mode("gray.200", "whiteAlpha.300")(props), }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, }; }; var baseStyle$g = function baseStyle(props) { return { root: baseStyleRoot$1, field: baseStyleField$1, stepperGroup: baseStyleStepperGroup, stepper: baseStyleStepper(props), }; }; function getSize(size) { var _sizeStyle$field$font, _sizeStyle$field; var sizeStyle = Input.sizes[size]; var radius = { lg: "md", md: "md", sm: "sm", xs: "sm", }; var _fontSize = (_sizeStyle$field$font = (_sizeStyle$field = sizeStyle.field) == null ? void 0 : _sizeStyle$field.fontSize) != null ? _sizeStyle$field$font : "md"; var fontSize = typography.fontSizes[_fontSize]; return { field: sizes_501602a9_esm_extends({}, sizeStyle.field, { paddingInlineEnd: $inputPadding.reference, verticalAlign: "top", }), stepper: { fontSize: calc(fontSize).multiply(0.75).toString(), _first: { borderTopEndRadius: radius[size], }, _last: { borderBottomEndRadius: radius[size], mt: "-1px", borderTopWidth: 1, }, }, }; } var sizes$c = { xs: getSize("xs"), sm: getSize("sm"), md: getSize("md"), lg: getSize("lg"), }; var NumberInput = { parts: numberInputAnatomy.keys, baseStyle: baseStyle$g, sizes: sizes$c, variants: variants$5, defaultProps: defaultProps$b, }; var _Input$variants$unsty$1; var baseStyle$f = sizes_501602a9_esm_extends( {}, Input.baseStyle.field, { textAlign: "center", } ); var sizes$b = { lg: { fontSize: "lg", w: 12, h: 12, borderRadius: "md", }, md: { fontSize: "md", w: 10, h: 10, borderRadius: "md", }, sm: { fontSize: "sm", w: 8, h: 8, borderRadius: "sm", }, xs: { fontSize: "xs", w: 6, h: 6, borderRadius: "sm", }, }; var variants$4 = { outline: function outline(props) { var _Input$variants$outli; return (_Input$variants$outli = Input.variants.outline(props).field) != null ? _Input$variants$outli : {}; }, flushed: function flushed(props) { var _Input$variants$flush; return (_Input$variants$flush = Input.variants.flushed(props).field) != null ? _Input$variants$flush : {}; }, filled: function filled(props) { var _Input$variants$fille; return (_Input$variants$fille = Input.variants.filled(props).field) != null ? _Input$variants$fille : {}; }, unstyled: (_Input$variants$unsty$1 = Input.variants.unstyled.field) != null ? _Input$variants$unsty$1 : {}, }; var defaultProps$a = Input.defaultProps; var PinInput = { baseStyle: baseStyle$f, sizes: sizes$b, variants: variants$4, defaultProps: defaultProps$a, }; var $popperBg = cssVar("popper-bg"); var $arrowBg$1 = cssVar("popper-arrow-bg"); var $arrowShadowColor = cssVar("popper-arrow-shadow-color"); var baseStylePopper = { zIndex: 10, }; var baseStyleContent = function baseStyleContent(props) { var _ref; var bg = mode("white", "gray.700")(props); var shadowColor = mode("gray.200", "whiteAlpha.300")(props); return ( (_ref = {}), (_ref[$popperBg.variable] = "colors." + bg), (_ref.bg = $popperBg.reference), (_ref[$arrowBg$1.variable] = $popperBg.reference), (_ref[$arrowShadowColor.variable] = "colors." + shadowColor), (_ref.width = "xs"), (_ref.border = "1px solid"), (_ref.borderColor = "inherit"), (_ref.borderRadius = "md"), (_ref.boxShadow = "sm"), (_ref.zIndex = "inherit"), (_ref._focusVisible = { outline: 0, boxShadow: "outline", }), _ref ); }; var baseStyleHeader = { px: 3, py: 2, borderBottomWidth: "1px", }; var baseStyleBody = { px: 3, py: 2, }; var baseStyleFooter = { px: 3, py: 2, borderTopWidth: "1px", }; var baseStyleCloseButton$1 = { position: "absolute", borderRadius: "md", top: 1, insetEnd: 2, padding: 2, }; var baseStyle$e = function baseStyle(props) { return { popper: baseStylePopper, content: baseStyleContent(props), header: baseStyleHeader, body: baseStyleBody, footer: baseStyleFooter, arrow: {}, closeButton: baseStyleCloseButton$1, }; }; var Popover = { parts: popoverAnatomy.keys, baseStyle: baseStyle$e, }; function filledStyle(props) { var c = props.colorScheme, t = props.theme, isIndeterminate = props.isIndeterminate, hasStripe = props.hasStripe; var stripeStyle = mode( generateStripe(), generateStripe("1rem", "rgba(0,0,0,0.1)") )(props); var bgColor = mode(c + ".500", c + ".200")(props); var gradient = "linear-gradient(\n to right,\n transparent 0%,\n " + getColor(t, bgColor) + " 50%,\n transparent 100%\n )"; var addStripe = !isIndeterminate && hasStripe; return sizes_501602a9_esm_extends( {}, addStripe && stripeStyle, isIndeterminate ? { bgImage: gradient, } : { bgColor: bgColor, } ); } var baseStyleLabel$2 = { lineHeight: "1", fontSize: "0.25em", fontWeight: "bold", color: "white", }; var baseStyleTrack$2 = function baseStyleTrack(props) { return { bg: mode("gray.100", "whiteAlpha.300")(props), }; }; var baseStyleFilledTrack$1 = function baseStyleFilledTrack(props) { return sizes_501602a9_esm_extends( { transitionProperty: "common", transitionDuration: "slow", }, filledStyle(props) ); }; var baseStyle$d = function baseStyle(props) { return { label: baseStyleLabel$2, filledTrack: baseStyleFilledTrack$1(props), track: baseStyleTrack$2(props), }; }; var sizes$a = { xs: { track: { h: "0.25rem", }, }, sm: { track: { h: "0.5rem", }, }, md: { track: { h: "0.75rem", }, }, lg: { track: { h: "1rem", }, }, }; var defaultProps$9 = { size: "md", colorScheme: "blue", }; var Progress = { parts: progressAnatomy.keys, sizes: sizes$a, baseStyle: baseStyle$d, defaultProps: defaultProps$9, }; var baseStyleControl = function baseStyleControl(props) { var _Checkbox$baseStyle = Checkbox.baseStyle(props), _Checkbox$baseStyle$c = _Checkbox$baseStyle.control, control = _Checkbox$baseStyle$c === void 0 ? {} : _Checkbox$baseStyle$c; return sizes_501602a9_esm_extends({}, control, { borderRadius: "full", _checked: sizes_501602a9_esm_extends( {}, control["_checked"], { _before: { content: '""', display: "inline-block", pos: "relative", w: "50%", h: "50%", borderRadius: "50%", bg: "currentColor", }, } ), }); }; var baseStyle$c = function baseStyle(props) { return { label: Checkbox.baseStyle(props).label, container: Checkbox.baseStyle(props).container, control: baseStyleControl(props), }; }; var sizes$9 = { md: { control: { w: 4, h: 4, }, label: { fontSize: "md", }, }, lg: { control: { w: 5, h: 5, }, label: { fontSize: "lg", }, }, sm: { control: { width: 3, height: 3, }, label: { fontSize: "sm", }, }, }; var defaultProps$8 = { size: "md", colorScheme: "blue", }; var Radio = { parts: radioAnatomy.keys, baseStyle: baseStyle$c, sizes: sizes$9, defaultProps: defaultProps$8, }; var baseStyleField = function baseStyleField(props) { return sizes_501602a9_esm_extends({}, Input.baseStyle.field, { bg: mode("white", "gray.700")(props), appearance: "none", paddingBottom: "1px", lineHeight: "normal", "> option, > optgroup": { bg: mode("white", "gray.700")(props), }, }); }; var baseStyleIcon$1 = { width: "1.5rem", height: "100%", insetEnd: "0.5rem", position: "relative", color: "currentColor", fontSize: "1.25rem", _disabled: { opacity: 0.5, }, }; var baseStyle$b = function baseStyle(props) { return { field: baseStyleField(props), icon: baseStyleIcon$1, }; }; var iconSpacing = { paddingInlineEnd: "2rem", }; var sizes$8 = lodash_mergewith_default()({}, Input.sizes, { lg: { field: iconSpacing, }, md: { field: iconSpacing, }, sm: { field: iconSpacing, }, xs: { field: iconSpacing, icon: { insetEnd: "0.25rem", }, }, }); var Select = { parts: selectAnatomy.keys, baseStyle: baseStyle$b, sizes: sizes$8, variants: Input.variants, defaultProps: Input.defaultProps, }; var fade = function fade(startColor, endColor) { return (0, emotion_react_browser_esm /* keyframes */.F4)({ from: { borderColor: startColor, background: startColor, }, to: { borderColor: endColor, background: endColor, }, }); }; var baseStyle$a = function baseStyle(props) { var defaultStartColor = mode("gray.100", "gray.800")(props); var defaultEndColor = mode("gray.400", "gray.600")(props); var _props$startColor = props.startColor, startColor = _props$startColor === void 0 ? defaultStartColor : _props$startColor, _props$endColor = props.endColor, endColor = _props$endColor === void 0 ? defaultEndColor : _props$endColor, speed = props.speed, theme = props.theme; var start = getColor(theme, startColor); var end = getColor(theme, endColor); return { opacity: 0.7, borderRadius: "2px", borderColor: start, background: end, animation: speed + "s linear infinite alternate " + fade(start, end), }; }; var Skeleton = { baseStyle: baseStyle$a, }; var baseStyle$9 = function baseStyle(props) { return { borderRadius: "md", fontWeight: "semibold", _focusVisible: { boxShadow: "outline", padding: "1rem", position: "fixed", top: "1.5rem", insetStart: "1.5rem", bg: mode("white", "gray.700")(props), }, }; }; var SkipLink = { baseStyle: baseStyle$9, }; function thumbOrientation(props) { return orient({ orientation: props.orientation, vertical: { left: "50%", transform: "translateX(-50%)", _active: { transform: "translateX(-50%) scale(1.15)", }, }, horizontal: { top: "50%", transform: "translateY(-50%)", _active: { transform: "translateY(-50%) scale(1.15)", }, }, }); } var baseStyleContainer$1 = function baseStyleContainer(props) { var orientation = props.orientation; return sizes_501602a9_esm_extends( { display: "inline-block", position: "relative", cursor: "pointer", _disabled: { opacity: 0.6, cursor: "default", pointerEvents: "none", }, }, orient({ orientation: orientation, vertical: { h: "100%", }, horizontal: { w: "100%", }, }) ); }; var baseStyleTrack$1 = function baseStyleTrack(props) { return { overflow: "hidden", borderRadius: "sm", bg: mode("gray.200", "whiteAlpha.200")(props), _disabled: { bg: mode("gray.300", "whiteAlpha.300")(props), }, }; }; var baseStyleThumb$1 = function baseStyleThumb(props) { return sizes_501602a9_esm_extends( { display: "flex", alignItems: "center", justifyContent: "center", position: "absolute", outline: 0, zIndex: 1, borderRadius: "full", bg: "white", boxShadow: "base", border: "1px solid", borderColor: "transparent", transitionProperty: "transform", transitionDuration: "normal", _focusVisible: { boxShadow: "outline", }, _disabled: { bg: "gray.300", }, }, thumbOrientation(props) ); }; var baseStyleFilledTrack = function baseStyleFilledTrack(props) { var c = props.colorScheme; return { width: "inherit", height: "inherit", bg: mode(c + ".500", c + ".200")(props), }; }; var baseStyle$8 = function baseStyle(props) { return { container: baseStyleContainer$1(props), track: baseStyleTrack$1(props), thumb: baseStyleThumb$1(props), filledTrack: baseStyleFilledTrack(props), }; }; var sizeLg = function sizeLg(props) { return { thumb: { w: "16px", h: "16px", }, track: orient({ orientation: props.orientation, horizontal: { h: "4px", }, vertical: { w: "4px", }, }), }; }; var sizeMd = function sizeMd(props) { return { thumb: { w: "14px", h: "14px", }, track: orient({ orientation: props.orientation, horizontal: { h: "4px", }, vertical: { w: "4px", }, }), }; }; var sizeSm = function sizeSm(props) { return { thumb: { w: "10px", h: "10px", }, track: orient({ orientation: props.orientation, horizontal: { h: "2px", }, vertical: { w: "2px", }, }), }; }; var sizes$7 = { lg: sizeLg, md: sizeMd, sm: sizeSm, }; var defaultProps$7 = { size: "md", colorScheme: "blue", }; var Slider = { parts: sliderAnatomy.keys, sizes: sizes$7, baseStyle: baseStyle$8, defaultProps: defaultProps$7, }; var _xs, _sm, _md, _lg, _xl; var $size = cssVar("spinner-size"); var baseStyle$7 = { width: [$size.reference], height: [$size.reference], }; var sizes$6 = { xs: ((_xs = {}), (_xs[$size.variable] = "0.75rem"), _xs), sm: ((_sm = {}), (_sm[$size.variable] = "1rem"), _sm), md: ((_md = {}), (_md[$size.variable] = "1.5rem"), _md), lg: ((_lg = {}), (_lg[$size.variable] = "2rem"), _lg), xl: ((_xl = {}), (_xl[$size.variable] = "3rem"), _xl), }; var defaultProps$6 = { size: "md", }; var Spinner = { baseStyle: baseStyle$7, sizes: sizes$6, defaultProps: defaultProps$6, }; var baseStyleLabel$1 = { fontWeight: "medium", }; var baseStyleHelpText = { opacity: 0.8, marginBottom: 2, }; var baseStyleNumber = { verticalAlign: "baseline", fontWeight: "semibold", }; var baseStyleIcon = { marginEnd: 1, w: "14px", h: "14px", verticalAlign: "middle", }; var baseStyle$6 = { container: {}, label: baseStyleLabel$1, helpText: baseStyleHelpText, number: baseStyleNumber, icon: baseStyleIcon, }; var sizes$5 = { md: { label: { fontSize: "sm", }, helpText: { fontSize: "sm", }, number: { fontSize: "2xl", }, }, }; var defaultProps$5 = { size: "md", }; var Stat = { parts: statAnatomy.keys, baseStyle: baseStyle$6, sizes: sizes$5, defaultProps: defaultProps$5, }; var _container2, _container3, _container4; var $width = cssVar("switch-track-width"); var $height = cssVar("switch-track-height"); var $diff = cssVar("switch-track-diff"); var diffValue = calc.subtract($width, $height); var $translateX = cssVar("switch-thumb-x"); var baseStyleTrack = function baseStyleTrack(props) { var c = props.colorScheme; return { borderRadius: "full", p: "2px", width: [$width.reference], height: [$height.reference], transitionProperty: "common", transitionDuration: "fast", bg: mode("gray.300", "whiteAlpha.400")(props), _focusVisible: { boxShadow: "outline", }, _disabled: { opacity: 0.4, cursor: "not-allowed", }, _checked: { bg: mode(c + ".500", c + ".200")(props), }, }; }; var baseStyleThumb = { bg: "white", transitionProperty: "transform", transitionDuration: "normal", borderRadius: "inherit", width: [$height.reference], height: [$height.reference], _checked: { transform: "translateX(" + $translateX.reference + ")", }, }; var baseStyle$5 = function baseStyle(props) { var _rtl, _container; return { container: ((_container = {}), (_container[$diff.variable] = diffValue), (_container[$translateX.variable] = $diff.reference), (_container._rtl = ((_rtl = {}), (_rtl[$translateX.variable] = calc($diff) .negate() .toString()), _rtl)), _container), track: baseStyleTrack(props), thumb: baseStyleThumb, }; }; var sizes$4 = { sm: { container: ((_container2 = {}), (_container2[$width.variable] = "1.375rem"), (_container2[$height.variable] = "0.75rem"), _container2), }, md: { container: ((_container3 = {}), (_container3[$width.variable] = "1.875rem"), (_container3[$height.variable] = "1rem"), _container3), }, lg: { container: ((_container4 = {}), (_container4[$width.variable] = "2.875rem"), (_container4[$height.variable] = "1.5rem"), _container4), }, }; var defaultProps$4 = { size: "md", colorScheme: "blue", }; var Switch = { parts: switchAnatomy.keys, baseStyle: baseStyle$5, sizes: sizes$4, defaultProps: defaultProps$4, }; var baseStyle$4 = { table: { fontVariantNumeric: "lining-nums tabular-nums", borderCollapse: "collapse", width: "full", }, th: { fontFamily: "heading", fontWeight: "bold", textTransform: "uppercase", letterSpacing: "wider", textAlign: "start", }, td: { textAlign: "start", }, caption: { mt: 4, fontFamily: "heading", textAlign: "center", fontWeight: "medium", }, }; var numericStyles = { "&[data-is-numeric=true]": { textAlign: "end", }, }; var variantSimple = function variantSimple(props) { var c = props.colorScheme; return { th: sizes_501602a9_esm_extends( { color: mode("gray.600", "gray.400")(props), borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props), }, numericStyles ), td: sizes_501602a9_esm_extends( { borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props), }, numericStyles ), caption: { color: mode("gray.600", "gray.100")(props), }, tfoot: { tr: { "&:last-of-type": { th: { borderBottomWidth: 0, }, }, }, }, }; }; var variantStripe = function variantStripe(props) { var c = props.colorScheme; return { th: sizes_501602a9_esm_extends( { color: mode("gray.600", "gray.400")(props), borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props), }, numericStyles ), td: sizes_501602a9_esm_extends( { borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props), }, numericStyles ), caption: { color: mode("gray.600", "gray.100")(props), }, tbody: { tr: { "&:nth-of-type(odd)": { "th, td": { borderBottomWidth: "1px", borderColor: mode( c + ".100", c + ".700" )(props), }, td: { background: mode( c + ".100", c + ".700" )(props), }, }, }, }, tfoot: { tr: { "&:last-of-type": { th: { borderBottomWidth: 0, }, }, }, }, }; }; var variants$3 = { simple: variantSimple, striped: variantStripe, unstyled: {}, }; var sizes$3 = { sm: { th: { px: "4", py: "1", lineHeight: "4", fontSize: "xs", }, td: { px: "4", py: "2", fontSize: "sm", lineHeight: "4", }, caption: { px: "4", py: "2", fontSize: "xs", }, }, md: { th: { px: "6", py: "3", lineHeight: "4", fontSize: "xs", }, td: { px: "6", py: "4", lineHeight: "5", }, caption: { px: "6", py: "2", fontSize: "sm", }, }, lg: { th: { px: "8", py: "4", lineHeight: "5", fontSize: "sm", }, td: { px: "8", py: "5", lineHeight: "6", }, caption: { px: "6", py: "2", fontSize: "md", }, }, }; var defaultProps$3 = { variant: "simple", size: "md", colorScheme: "gray", }; var Table = { parts: tableAnatomy.keys, baseStyle: baseStyle$4, variants: variants$3, sizes: sizes$3, defaultProps: defaultProps$3, }; var baseStyleRoot = function baseStyleRoot(props) { var orientation = props.orientation; return { display: orientation === "vertical" ? "flex" : "block", }; }; var baseStyleTab = function baseStyleTab(props) { var isFitted = props.isFitted; return { flex: isFitted ? 1 : undefined, transitionProperty: "common", transitionDuration: "normal", _focusVisible: { zIndex: 1, boxShadow: "outline", }, _disabled: { cursor: "not-allowed", opacity: 0.4, }, }; }; var baseStyleTablist = function baseStyleTablist(props) { var _props$align = props.align, align = _props$align === void 0 ? "start" : _props$align, orientation = props.orientation; var alignments = { end: "flex-end", center: "center", start: "flex-start", }; return { justifyContent: alignments[align], flexDirection: orientation === "vertical" ? "column" : "row", }; }; var baseStyleTabpanel = { p: 4, }; var baseStyle$3 = function baseStyle(props) { return { root: baseStyleRoot(props), tab: baseStyleTab(props), tablist: baseStyleTablist(props), tabpanel: baseStyleTabpanel, }; }; var sizes$2 = { sm: { tab: { py: 1, px: 4, fontSize: "sm", }, }, md: { tab: { fontSize: "md", py: 2, px: 4, }, }, lg: { tab: { fontSize: "lg", py: 3, px: 4, }, }, }; var variantLine = function variantLine(props) { var _tablist, _tab; var c = props.colorScheme, orientation = props.orientation; var isVertical = orientation === "vertical"; var borderProp = orientation === "vertical" ? "borderStart" : "borderBottom"; var marginProp = isVertical ? "marginStart" : "marginBottom"; return { tablist: ((_tablist = {}), (_tablist[borderProp] = "2px solid"), (_tablist.borderColor = "inherit"), _tablist), tab: ((_tab = {}), (_tab[borderProp] = "2px solid"), (_tab.borderColor = "transparent"), (_tab[marginProp] = "-2px"), (_tab._selected = { color: mode(c + ".600", c + ".300")(props), borderColor: "currentColor", }), (_tab._active = { bg: mode("gray.200", "whiteAlpha.300")(props), }), (_tab._disabled = { _active: { bg: "none", }, }), _tab), }; }; var variantEnclosed = function variantEnclosed(props) { var c = props.colorScheme; return { tab: { borderTopRadius: "md", border: "1px solid", borderColor: "transparent", mb: "-1px", _selected: { color: mode(c + ".600", c + ".300")(props), borderColor: "inherit", borderBottomColor: mode("white", "gray.800")(props), }, }, tablist: { mb: "-1px", borderBottom: "1px solid", borderColor: "inherit", }, }; }; var variantEnclosedColored = function variantEnclosedColored( props ) { var c = props.colorScheme; return { tab: { border: "1px solid", borderColor: "inherit", bg: mode("gray.50", "whiteAlpha.50")(props), mb: "-1px", _notLast: { marginEnd: "-1px", }, _selected: { bg: mode("#fff", "gray.800")(props), color: mode(c + ".600", c + ".300")(props), borderColor: "inherit", borderTopColor: "currentColor", borderBottomColor: "transparent", }, }, tablist: { mb: "-1px", borderBottom: "1px solid", borderColor: "inherit", }, }; }; var variantSoftRounded = function variantSoftRounded(props) { var c = props.colorScheme, theme = props.theme; return { tab: { borderRadius: "full", fontWeight: "semibold", color: "gray.600", _selected: { color: getColor(theme, c + ".700"), bg: getColor(theme, c + ".100"), }, }, }; }; var variantSolidRounded = function variantSolidRounded(props) { var c = props.colorScheme; return { tab: { borderRadius: "full", fontWeight: "semibold", color: mode("gray.600", "inherit")(props), _selected: { color: mode("#fff", "gray.800")(props), bg: mode(c + ".600", c + ".300")(props), }, }, }; }; var variantUnstyled = {}; var variants$2 = { line: variantLine, enclosed: variantEnclosed, "enclosed-colored": variantEnclosedColored, "soft-rounded": variantSoftRounded, "solid-rounded": variantSolidRounded, unstyled: variantUnstyled, }; var defaultProps$2 = { size: "md", variant: "line", colorScheme: "blue", }; var Tabs = { parts: tabsAnatomy.keys, baseStyle: baseStyle$3, sizes: sizes$2, variants: variants$2, defaultProps: defaultProps$2, }; var baseStyleContainer = { fontWeight: "medium", lineHeight: 1.2, outline: 0, borderRadius: "md", _focusVisible: { boxShadow: "outline", }, }; var baseStyleLabel = { lineHeight: 1.2, overflow: "visible", }; var baseStyleCloseButton = { fontSize: "18px", w: "1.25rem", h: "1.25rem", transitionProperty: "common", transitionDuration: "normal", borderRadius: "full", marginStart: "0.375rem", marginEnd: "-1", opacity: 0.5, _disabled: { opacity: 0.4, }, _focusVisible: { boxShadow: "outline", bg: "rgba(0, 0, 0, 0.14)", }, _hover: { opacity: 0.8, }, _active: { opacity: 1, }, }; var baseStyle$2 = { container: baseStyleContainer, label: baseStyleLabel, closeButton: baseStyleCloseButton, }; var sizes$1 = { sm: { container: { minH: "1.25rem", minW: "1.25rem", fontSize: "xs", px: 2, }, closeButton: { marginEnd: "-2px", marginStart: "0.35rem", }, }, md: { container: { minH: "1.5rem", minW: "1.5rem", fontSize: "sm", px: 2, }, }, lg: { container: { minH: 8, minW: 8, fontSize: "md", px: 3, }, }, }; var variants$1 = { subtle: function subtle(props) { return { container: Badge.variants.subtle(props), }; }, solid: function solid(props) { return { container: Badge.variants.solid(props), }; }, outline: function outline(props) { return { container: Badge.variants.outline(props), }; }, }; var defaultProps$1 = { size: "md", variant: "subtle", colorScheme: "gray", }; var Tag = { parts: tagAnatomy.keys, variants: variants$1, baseStyle: baseStyle$2, sizes: sizes$1, defaultProps: defaultProps$1, }; var _Input$variants$unsty, _Input$sizes$xs$field, _Input$sizes$sm$field, _Input$sizes$md$field, _Input$sizes$lg$field; var baseStyle$1 = sizes_501602a9_esm_extends( {}, Input.baseStyle.field, { paddingY: "8px", minHeight: "80px", lineHeight: "short", verticalAlign: "top", } ); var variants = { outline: function outline(props) { var _Input$variants$outli; return (_Input$variants$outli = Input.variants.outline(props).field) != null ? _Input$variants$outli : {}; }, flushed: function flushed(props) { var _Input$variants$flush; return (_Input$variants$flush = Input.variants.flushed(props).field) != null ? _Input$variants$flush : {}; }, filled: function filled(props) { var _Input$variants$fille; return (_Input$variants$fille = Input.variants.filled(props).field) != null ? _Input$variants$fille : {}; }, unstyled: (_Input$variants$unsty = Input.variants.unstyled.field) != null ? _Input$variants$unsty : {}, }; var chakra_ui_theme_components_esm_sizes = { xs: (_Input$sizes$xs$field = Input.sizes.xs.field) != null ? _Input$sizes$xs$field : {}, sm: (_Input$sizes$sm$field = Input.sizes.sm.field) != null ? _Input$sizes$sm$field : {}, md: (_Input$sizes$md$field = Input.sizes.md.field) != null ? _Input$sizes$md$field : {}, lg: (_Input$sizes$lg$field = Input.sizes.lg.field) != null ? _Input$sizes$lg$field : {}, }; var defaultProps = { size: "md", variant: "outline", }; var Textarea = { baseStyle: baseStyle$1, sizes: chakra_ui_theme_components_esm_sizes, variants: variants, defaultProps: defaultProps, }; var $bg = cssVar("tooltip-bg"); var $arrowBg = cssVar("popper-arrow-bg"); var baseStyle = function baseStyle(props) { var _ref; var bg = mode("gray.700", "gray.300")(props); return ( (_ref = {}), (_ref[$bg.variable] = "colors." + bg), (_ref.px = "8px"), (_ref.py = "2px"), (_ref.bg = [$bg.reference]), (_ref[$arrowBg.variable] = [$bg.reference]), (_ref.color = mode("whiteAlpha.900", "gray.900")(props)), (_ref.borderRadius = "sm"), (_ref.fontWeight = "medium"), (_ref.fontSize = "sm"), (_ref.boxShadow = "md"), (_ref.maxW = "320px"), (_ref.zIndex = "tooltip"), _ref ); }; var Tooltip = { baseStyle: baseStyle, }; var components = { Accordion: Accordion, Alert: Alert, Avatar: Avatar, Badge: Badge, Breadcrumb: Breadcrumb, Button: Button, Checkbox: Checkbox, CloseButton: CloseButton, Code: Code, Container: chakra_ui_theme_components_esm_Container, Divider: Divider, Drawer: Drawer, Editable: Editable, Form: Form, FormError: FormError, FormLabel: FormLabel, Heading: Heading, Input: Input, Kbd: Kbd, Link: Link, List: List, Menu: Menu, Modal: Modal, NumberInput: NumberInput, PinInput: PinInput, Popover: Popover, Progress: Progress, Radio: Radio, Select: Select, Skeleton: Skeleton, SkipLink: SkipLink, Slider: Slider, Spinner: Spinner, Stat: Stat, Switch: Switch, Table: Table, Tabs: Tabs, Tag: Tag, Textarea: Textarea, Tooltip: Tooltip, }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/borders/dist/chakra-ui-theme-foundations-borders.esm.js var borders = { none: 0, "1px": "1px solid", "2px": "2px solid", "4px": "4px solid", "8px": "8px solid", }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/breakpoints/dist/chakra-ui-theme-foundations-breakpoints.esm.js /** * Breakpoints for responsive design */ var breakpoints = createBreakpoints({ sm: "30em", md: "48em", lg: "62em", xl: "80em", "2xl": "96em", }); // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/colors/dist/chakra-ui-theme-foundations-colors.esm.js var colors = { transparent: "transparent", current: "currentColor", black: "#000000", white: "#FFFFFF", whiteAlpha: { 50: "rgba(255, 255, 255, 0.04)", 100: "rgba(255, 255, 255, 0.06)", 200: "rgba(255, 255, 255, 0.08)", 300: "rgba(255, 255, 255, 0.16)", 400: "rgba(255, 255, 255, 0.24)", 500: "rgba(255, 255, 255, 0.36)", 600: "rgba(255, 255, 255, 0.48)", 700: "rgba(255, 255, 255, 0.64)", 800: "rgba(255, 255, 255, 0.80)", 900: "rgba(255, 255, 255, 0.92)", }, blackAlpha: { 50: "rgba(0, 0, 0, 0.04)", 100: "rgba(0, 0, 0, 0.06)", 200: "rgba(0, 0, 0, 0.08)", 300: "rgba(0, 0, 0, 0.16)", 400: "rgba(0, 0, 0, 0.24)", 500: "rgba(0, 0, 0, 0.36)", 600: "rgba(0, 0, 0, 0.48)", 700: "rgba(0, 0, 0, 0.64)", 800: "rgba(0, 0, 0, 0.80)", 900: "rgba(0, 0, 0, 0.92)", }, gray: { 50: "#F7FAFC", 100: "#EDF2F7", 200: "#E2E8F0", 300: "#CBD5E0", 400: "#A0AEC0", 500: "#718096", 600: "#4A5568", 700: "#2D3748", 800: "#1A202C", 900: "#171923", }, red: { 50: "#FFF5F5", 100: "#FED7D7", 200: "#FEB2B2", 300: "#FC8181", 400: "#F56565", 500: "#E53E3E", 600: "#C53030", 700: "#9B2C2C", 800: "#822727", 900: "#63171B", }, orange: { 50: "#FFFAF0", 100: "#FEEBC8", 200: "#FBD38D", 300: "#F6AD55", 400: "#ED8936", 500: "#DD6B20", 600: "#C05621", 700: "#9C4221", 800: "#7B341E", 900: "#652B19", }, yellow: { 50: "#FFFFF0", 100: "#FEFCBF", 200: "#FAF089", 300: "#F6E05E", 400: "#ECC94B", 500: "#D69E2E", 600: "#B7791F", 700: "#975A16", 800: "#744210", 900: "#5F370E", }, green: { 50: "#F0FFF4", 100: "#C6F6D5", 200: "#9AE6B4", 300: "#68D391", 400: "#48BB78", 500: "#38A169", 600: "#2F855A", 700: "#276749", 800: "#22543D", 900: "#1C4532", }, teal: { 50: "#E6FFFA", 100: "#B2F5EA", 200: "#81E6D9", 300: "#4FD1C5", 400: "#38B2AC", 500: "#319795", 600: "#2C7A7B", 700: "#285E61", 800: "#234E52", 900: "#1D4044", }, blue: { 50: "#ebf8ff", 100: "#bee3f8", 200: "#90cdf4", 300: "#63b3ed", 400: "#4299e1", 500: "#3182ce", 600: "#2b6cb0", 700: "#2c5282", 800: "#2a4365", 900: "#1A365D", }, cyan: { 50: "#EDFDFD", 100: "#C4F1F9", 200: "#9DECF9", 300: "#76E4F7", 400: "#0BC5EA", 500: "#00B5D8", 600: "#00A3C4", 700: "#0987A0", 800: "#086F83", 900: "#065666", }, purple: { 50: "#FAF5FF", 100: "#E9D8FD", 200: "#D6BCFA", 300: "#B794F4", 400: "#9F7AEA", 500: "#805AD5", 600: "#6B46C1", 700: "#553C9A", 800: "#44337A", 900: "#322659", }, pink: { 50: "#FFF5F7", 100: "#FED7E2", 200: "#FBB6CE", 300: "#F687B3", 400: "#ED64A6", 500: "#D53F8C", 600: "#B83280", 700: "#97266D", 800: "#702459", 900: "#521B41", }, linkedin: { 50: "#E8F4F9", 100: "#CFEDFB", 200: "#9BDAF3", 300: "#68C7EC", 400: "#34B3E4", 500: "#00A0DC", 600: "#008CC9", 700: "#0077B5", 800: "#005E93", 900: "#004471", }, facebook: { 50: "#E8F4F9", 100: "#D9DEE9", 200: "#B7C2DA", 300: "#6482C0", 400: "#4267B2", 500: "#385898", 600: "#314E89", 700: "#29487D", 800: "#223B67", 900: "#1E355B", }, messenger: { 50: "#D0E6FF", 100: "#B9DAFF", 200: "#A2CDFF", 300: "#7AB8FF", 400: "#2E90FF", 500: "#0078FF", 600: "#0063D1", 700: "#0052AC", 800: "#003C7E", 900: "#002C5C", }, whatsapp: { 50: "#dffeec", 100: "#b9f5d0", 200: "#90edb3", 300: "#65e495", 400: "#3cdd78", 500: "#22c35e", 600: "#179848", 700: "#0c6c33", 800: "#01421c", 900: "#001803", }, twitter: { 50: "#E5F4FD", 100: "#C8E9FB", 200: "#A8DCFA", 300: "#83CDF7", 400: "#57BBF5", 500: "#1DA1F2", 600: "#1A94DA", 700: "#1681BF", 800: "#136B9E", 900: "#0D4D71", }, telegram: { 50: "#E3F2F9", 100: "#C5E4F3", 200: "#A2D4EC", 300: "#7AC1E4", 400: "#47A9DA", 500: "#0088CC", 600: "#007AB8", 700: "#006BA1", 800: "#005885", 900: "#003F5E", }, }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/radius/dist/chakra-ui-theme-foundations-radius.esm.js var radii = { none: "0", sm: "0.125rem", base: "0.25rem", md: "0.375rem", lg: "0.5rem", xl: "0.75rem", "2xl": "1rem", "3xl": "1.5rem", full: "9999px", }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/shadows/dist/chakra-ui-theme-foundations-shadows.esm.js var shadows = { xs: "0 0 0 1px rgba(0, 0, 0, 0.05)", sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)", base: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)", md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)", lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)", xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)", "2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)", outline: "0 0 0 3px rgba(66, 153, 225, 0.6)", inner: "inset 0 2px 4px 0 rgba(0,0,0,0.06)", none: "none", "dark-lg": "rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 5px 10px, rgba(0, 0, 0, 0.4) 0px 15px 40px", }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/transition/dist/chakra-ui-theme-foundations-transition.esm.js var transitionProperty = { common: "background-color, border-color, color, fill, stroke, opacity, box-shadow, transform", colors: "background-color, border-color, color, fill, stroke", dimensions: "width, height", position: "left, right, top, bottom", background: "background-color, background-image, background-position", }; var transitionTimingFunction = { "ease-in": "cubic-bezier(0.4, 0, 1, 1)", "ease-out": "cubic-bezier(0, 0, 0.2, 1)", "ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)", }; var transitionDuration = { "ultra-fast": "50ms", faster: "100ms", fast: "150ms", normal: "200ms", slow: "300ms", slower: "400ms", "ultra-slow": "500ms", }; var transition = { property: transitionProperty, easing: transitionTimingFunction, duration: transitionDuration, }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/z-index/dist/chakra-ui-theme-foundations-z-index.esm.js var zIndices = { hide: -1, auto: "auto", base: 0, docked: 10, dropdown: 1000, sticky: 1100, banner: 1200, overlay: 1300, modal: 1400, popover: 1500, skipLink: 1600, toast: 1700, tooltip: 1800, }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/blur/dist/chakra-ui-theme-foundations-blur.esm.js var chakra_ui_theme_foundations_blur_esm_blur = { none: 0, sm: "4px", base: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px", }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/dist/chakra-ui-theme-foundations.esm.js var foundations = sizes_501602a9_esm_extends( { breakpoints: breakpoints, zIndices: zIndices, radii: radii, blur: chakra_ui_theme_foundations_blur_esm_blur, colors: colors, }, typography, { sizes: sizes, shadows: shadows, space: spacing, borders: borders, transition: transition, } ); // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/dist/chakra-ui-theme.esm.js var semanticTokens = { colors: { "chakra-body-text": { _light: "gray.800", _dark: "whiteAlpha.900", }, "chakra-body-bg": { _light: "white", _dark: "gray.800", }, "chakra-border-color": { _light: "gray.200", _dark: "whiteAlpha.300", }, "chakra-placeholder-color": { _light: "gray.500", _dark: "whiteAlpha.400", }, }, }; var styles = { global: { body: { fontFamily: "body", color: "chakra-body-text", bg: "chakra-body-bg", transitionProperty: "background-color", transitionDuration: "normal", lineHeight: "base", }, "*::placeholder": { color: "chakra-placeholder-color", }, "*, *::before, &::after": { borderColor: "chakra-border-color", wordWrap: "break-word", }, }, }; var styles$1 = styles; var requiredChakraThemeKeys = /* unused pure expression or super */ null && [ "borders", "breakpoints", "colors", "components", "config", "direction", "fonts", "fontSizes", "fontWeights", "letterSpacings", "lineHeights", "radii", "shadows", "sizes", "space", "styles", "transition", "zIndices", ]; function chakra_ui_theme_esm_isChakraTheme(unit) { if (!isObject(unit)) { return false; } return requiredChakraThemeKeys.every(function (propertyName) { return Object.prototype.hasOwnProperty.call( unit, propertyName ); }); } var direction = "ltr"; var config = { useSystemColorMode: false, initialColorMode: "light", cssVarPrefix: "chakra", }; var theme = sizes_501602a9_esm_extends( { semanticTokens: semanticTokens, direction: direction, }, foundations, { components: components, styles: styles$1, config: config, } ); // EXTERNAL MODULE: ./node_modules/@chakra-ui/visually-hidden/dist/chakra-ui-visually-hidden.esm.js var chakra_ui_visually_hidden_esm = __webpack_require__(1358); // CONCATENATED MODULE: ./node_modules/@chakra-ui/spinner/dist/chakra-ui-spinner.esm.js function chakra_ui_spinner_esm_extends() { chakra_ui_spinner_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return chakra_ui_spinner_esm_extends.apply(this, arguments); } function chakra_ui_spinner_esm_objectWithoutPropertiesLoose( source, excluded ) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var chakra_ui_spinner_esm_excluded = [ "label", "thickness", "speed", "emptyColor", "className", ]; var spin = (0, emotion_react_browser_esm /* keyframes */.F4)({ "0%": { transform: "rotate(0deg)", }, "100%": { transform: "rotate(360deg)", }, }); /** * Spinner is used to indicate the loading state of a page or a component, * It renders a `div` by default. * * @see Docs https://chakra-ui.com/spinner */ var chakra_ui_spinner_esm_Spinner = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */.Gp)(function (props, ref) { var styles = (0, chakra_ui_system_esm /* useStyleConfig */.mq)( "Spinner", props ); var _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */.Lr)(props), _omitThemingProps$lab = _omitThemingProps.label, label = _omitThemingProps$lab === void 0 ? "Loading..." : _omitThemingProps$lab, _omitThemingProps$thi = _omitThemingProps.thickness, thickness = _omitThemingProps$thi === void 0 ? "2px" : _omitThemingProps$thi, _omitThemingProps$spe = _omitThemingProps.speed, speed = _omitThemingProps$spe === void 0 ? "0.45s" : _omitThemingProps$spe, _omitThemingProps$emp = _omitThemingProps.emptyColor, emptyColor = _omitThemingProps$emp === void 0 ? "transparent" : _omitThemingProps$emp, className = _omitThemingProps.className, rest = chakra_ui_spinner_esm_objectWithoutPropertiesLoose( _omitThemingProps, chakra_ui_spinner_esm_excluded ); var _className = (0, chakra_ui_utils_esm.cx)( "chakra-spinner", className ); var spinnerStyles = chakra_ui_spinner_esm_extends( { display: "inline-block", borderColor: "currentColor", borderStyle: "solid", borderRadius: "99999px", borderWidth: thickness, borderBottomColor: emptyColor, borderLeftColor: emptyColor, animation: spin + " " + speed + " linear infinite", }, styles ); return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, chakra_ui_spinner_esm_extends( { ref: ref, __css: spinnerStyles, className: _className, }, rest ), label && /*#__PURE__*/ react.createElement( chakra_ui_visually_hidden_esm /* VisuallyHidden */.TX, null, label ) ); }); if (chakra_ui_utils_esm /* __DEV__ */.Ts) { chakra_ui_spinner_esm_Spinner.displayName = "Spinner"; } // EXTERNAL MODULE: ./node_modules/@chakra-ui/icon/dist/chakra-ui-icon.esm.js var chakra_ui_icon_esm = __webpack_require__(894); // CONCATENATED MODULE: ./node_modules/@chakra-ui/alert/dist/chakra-ui-alert.esm.js function chakra_ui_alert_esm_extends() { chakra_ui_alert_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return chakra_ui_alert_esm_extends.apply(this, arguments); } function chakra_ui_alert_esm_objectWithoutPropertiesLoose( source, excluded ) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var CheckIcon = function CheckIcon(props) { return /*#__PURE__*/ react.createElement( chakra_ui_icon_esm /* Icon */.JO, chakra_ui_alert_esm_extends( { viewBox: "0 0 24 24", }, props ), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M12,0A12,12,0,1,0,24,12,12.014,12.014,0,0,0,12,0Zm6.927,8.2-6.845,9.289a1.011,1.011,0,0,1-1.43.188L5.764,13.769a1,1,0,1,1,1.25-1.562l4.076,3.261,6.227-8.451A1,1,0,1,1,18.927,8.2Z", }) ); }; var InfoIcon = function InfoIcon(props) { return /*#__PURE__*/ react.createElement( chakra_ui_icon_esm /* Icon */.JO, chakra_ui_alert_esm_extends( { viewBox: "0 0 24 24", }, props ), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M12,0A12,12,0,1,0,24,12,12.013,12.013,0,0,0,12,0Zm.25,5a1.5,1.5,0,1,1-1.5,1.5A1.5,1.5,0,0,1,12.25,5ZM14.5,18.5h-4a1,1,0,0,1,0-2h.75a.25.25,0,0,0,.25-.25v-4.5a.25.25,0,0,0-.25-.25H10.5a1,1,0,0,1,0-2h1a2,2,0,0,1,2,2v4.75a.25.25,0,0,0,.25.25h.75a1,1,0,1,1,0,2Z", }) ); }; var WarningIcon = function WarningIcon(props) { return /*#__PURE__*/ react.createElement( chakra_ui_icon_esm /* Icon */.JO, chakra_ui_alert_esm_extends( { viewBox: "0 0 24 24", }, props ), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z", }) ); }; var chakra_ui_alert_esm_excluded = ["status"]; var _createStylesContext = (0, chakra_ui_system_esm /* createStylesContext */.eC)("Alert"), StylesProvider = _createStylesContext[0], useStyles = _createStylesContext[1]; var STATUSES = { info: { icon: InfoIcon, colorScheme: "blue", }, warning: { icon: WarningIcon, colorScheme: "orange", }, success: { icon: CheckIcon, colorScheme: "green", }, error: { icon: WarningIcon, colorScheme: "red", }, loading: { icon: chakra_ui_spinner_esm_Spinner, colorScheme: "blue", }, }; var chakra_ui_alert_esm_createContext = (0, chakra_ui_react_utils_esm /* createContext */.kr)({ name: "AlertContext", errorMessage: "useAlertContext: `context` is undefined. Seems you forgot to wrap alert components in `<Alert />`", }), AlertProvider = chakra_ui_alert_esm_createContext[0], useAlertContext = chakra_ui_alert_esm_createContext[1]; /** * Alert is used to communicate the state or status of a * page, feature or action */ var chakra_ui_alert_esm_Alert = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */.Gp)(function (props, ref) { var _props$colorScheme; var _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */.Lr)(props), _omitThemingProps$sta = _omitThemingProps.status, status = _omitThemingProps$sta === void 0 ? "info" : _omitThemingProps$sta, rest = chakra_ui_alert_esm_objectWithoutPropertiesLoose( _omitThemingProps, chakra_ui_alert_esm_excluded ); var colorScheme = (_props$colorScheme = props.colorScheme) != null ? _props$colorScheme : STATUSES[status].colorScheme; var styles = (0, chakra_ui_system_esm /* useMultiStyleConfig */.jC)( "Alert", chakra_ui_alert_esm_extends({}, props, { colorScheme: colorScheme, }) ); var alertStyles = chakra_ui_alert_esm_extends( { width: "100%", display: "flex", alignItems: "center", position: "relative", overflow: "hidden", }, styles.container ); return /*#__PURE__*/ react.createElement( AlertProvider, { value: { status: status, }, }, /*#__PURE__*/ react.createElement( StylesProvider, { value: styles, }, /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, chakra_ui_alert_esm_extends( { role: "alert", ref: ref, }, rest, { className: (0, chakra_ui_utils_esm.cx)( "chakra-alert", props.className ), __css: alertStyles, } ) ) ) ); }); var AlertTitle = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */.Gp)(function (props, ref) { var styles = useStyles(); return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, chakra_ui_alert_esm_extends( { ref: ref, }, props, { className: (0, chakra_ui_utils_esm.cx)( "chakra-alert__title", props.className ), __css: styles.title, } ) ); }); var AlertDescription = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */.Gp)(function (props, ref) { var styles = useStyles(); var descriptionStyles = chakra_ui_alert_esm_extends( { display: "inline", }, styles.description ); return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, chakra_ui_alert_esm_extends( { ref: ref, }, props, { className: (0, chakra_ui_utils_esm.cx)( "chakra-alert__desc", props.className ), __css: descriptionStyles, } ) ); }); var AlertIcon = function AlertIcon(props) { var _useAlertContext = useAlertContext(), status = _useAlertContext.status; var BaseIcon = STATUSES[status].icon; var styles = useStyles(); var css = status === "loading" ? styles.spinner : styles.icon; return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.span */.m$.span, chakra_ui_alert_esm_extends( { display: "inherit", }, props, { className: (0, chakra_ui_utils_esm.cx)( "chakra-alert__icon", props.className ), __css: css, } ), props.children || /*#__PURE__*/ react.createElement(BaseIcon, { h: "100%", w: "100%", }) ); }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/close-button/dist/chakra-ui-close-button.esm.js function chakra_ui_close_button_esm_objectWithoutPropertiesLoose( source, excluded ) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function chakra_ui_close_button_esm_extends() { chakra_ui_close_button_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return chakra_ui_close_button_esm_extends.apply( this, arguments ); } var chakra_ui_close_button_esm_excluded = [ "children", "isDisabled", "__css", ]; var CloseIcon = function CloseIcon(props) { return /*#__PURE__*/ react.createElement( chakra_ui_icon_esm /* Icon */.JO, chakra_ui_close_button_esm_extends( { focusable: "false", "aria-hidden": true, }, props ), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z", }) ); }; /** * A button with a close icon. * * It is used to handle the close functionality in feedback and overlay components * like Alerts, Toasts, Drawers and Modals. */ var chakra_ui_close_button_esm_CloseButton = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */.Gp)(function (props, ref) { var styles = (0, chakra_ui_system_esm /* useStyleConfig */.mq)( "CloseButton", props ); var _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */.Lr)(props), children = _omitThemingProps.children, isDisabled = _omitThemingProps.isDisabled, __css = _omitThemingProps.__css, rest = chakra_ui_close_button_esm_objectWithoutPropertiesLoose( _omitThemingProps, chakra_ui_close_button_esm_excluded ); var baseStyle = { outline: 0, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, }; return /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.button */.m$.button, chakra_ui_close_button_esm_extends( { type: "button", "aria-label": "Close", ref: ref, disabled: isDisabled, __css: chakra_ui_close_button_esm_extends( {}, baseStyle, styles, __css ), }, rest ), children || /*#__PURE__*/ react.createElement(CloseIcon, { width: "1em", height: "1em", }) ); }); if (chakra_ui_utils_esm /* __DEV__ */.Ts) { chakra_ui_close_button_esm_CloseButton.displayName = "CloseButton"; } // EXTERNAL MODULE: ./node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs var use_presence = __webpack_require__(5947); // EXTERNAL MODULE: ./node_modules/framer-motion/dist/es/render/dom/motion.mjs + 169 modules var motion = __webpack_require__(8970); // EXTERNAL MODULE: ./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs + 3 modules var AnimatePresence = __webpack_require__(1190); // CONCATENATED MODULE: ./node_modules/@chakra-ui/toast/dist/chakra-ui-toast.esm.js function chakra_ui_toast_esm_extends() { chakra_ui_toast_esm_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if ( Object.prototype.hasOwnProperty.call( source, key ) ) { target[key] = source[key]; } } } return target; }; return chakra_ui_toast_esm_extends.apply(this, arguments); } function getToastPlacement(position, dir) { var _logical$dir; var computedPosition = position != null ? position : "bottom"; var logicals = { "top-start": { ltr: "top-left", rtl: "top-right", }, "top-end": { ltr: "top-right", rtl: "top-left", }, "bottom-start": { ltr: "bottom-left", rtl: "bottom-right", }, "bottom-end": { ltr: "bottom-right", rtl: "bottom-left", }, }; var logical = logicals[computedPosition]; return (_logical$dir = logical == null ? void 0 : logical[dir]) != null ? _logical$dir : computedPosition; } /** * Given an array of toasts for a specific position. * It returns the toast that matches the `id` passed */ /** * Given the toast manager state, finds the toast that matches * the id and return its position and index */ function findToast(toasts, id) { var position = getToastPosition(toasts, id); var index = position ? toasts[position].findIndex(function (toast) { return toast.id === id; }) : -1; return { position: position, index: index, }; } /** * Given the toast manager state, finds the position of the toast that * matches the `id` */ var getToastPosition = function getToastPosition(toasts, id) { var _Object$values$flat$f; return (_Object$values$flat$f = Object.values(toasts) .flat() .find(function (toast) { return toast.id === id; })) == null ? void 0 : _Object$values$flat$f.position; }; /** * Gets the styles to be applied to a toast's container * based on its position in the manager */ function getToastStyle(position) { var isRighty = position.includes("right"); var isLefty = position.includes("left"); var alignItems = "center"; if (isRighty) alignItems = "flex-end"; if (isLefty) alignItems = "flex-start"; return { display: "flex", flexDirection: "column", alignItems: alignItems, }; } /** * Compute the style of a toast based on its position */ function getToastListStyle(position) { var isTopOrBottom = position === "top" || position === "bottom"; var margin = isTopOrBottom ? "0 auto" : undefined; var top = position.includes("top") ? "env(safe-area-inset-top, 0px)" : undefined; var bottom = position.includes("bottom") ? "env(safe-area-inset-bottom, 0px)" : undefined; var right = !position.includes("left") ? "env(safe-area-inset-right, 0px)" : undefined; var left = !position.includes("right") ? "env(safe-area-inset-left, 0px)" : undefined; return { position: "fixed", zIndex: 5500, pointerEvents: "none", display: "flex", flexDirection: "column", margin: margin, top: top, bottom: bottom, right: right, left: left, }; } var initialState = { top: [], "top-left": [], "top-right": [], "bottom-left": [], bottom: [], "bottom-right": [], }; /** * Store to track all the toast across all positions */ var toastStore = createStore(initialState); function createStore(initialState) { var state = initialState; var listeners = new Set(); var setState = function setState(setStateFn) { state = setStateFn(state); listeners.forEach(function (l) { return l(); }); }; return { getState: function getState() { return state; }, subscribe: function subscribe(listener) { listeners.add(listener); return function () { // Delete all toasts on unmount setState(function () { return initialState; }); listeners["delete"](listener); }; }, /** * Delete a toast record at its position */ removeToast: function removeToast(id, position) { setState(function (prevState) { var _extends2; return chakra_ui_toast_esm_extends( {}, prevState, ((_extends2 = {}), (_extends2[position] = prevState[ position ].filter(function (toast) { return toast.id != id; })), _extends2) ); }); }, notify: function notify(message, options) { var toast = createToast(message, options); var position = toast.position, id = toast.id; setState(function (prevToasts) { var _prevToasts$position, _prevToasts$position2, _extends3; var isTop = position.includes("top"); /** * - If the toast is positioned at the top edges, the * recent toast stacks on top of the other toasts. * * - If the toast is positioned at the bottom edges, the recent * toast stacks below the other toasts. */ var toasts = isTop ? [toast].concat( (_prevToasts$position = prevToasts[position]) != null ? _prevToasts$position : [] ) : [].concat( (_prevToasts$position2 = prevToasts[position]) != null ? _prevToasts$position2 : [], [toast] ); return chakra_ui_toast_esm_extends( {}, prevToasts, ((_extends3 = {}), (_extends3[position] = toasts), _extends3) ); }); return id; }, update: function update(id, options) { if (!id) return; setState(function (prevState) { var nextState = chakra_ui_toast_esm_extends( {}, prevState ); var _findToast = findToast(nextState, id), position = _findToast.position, index = _findToast.index; if (position && index !== -1) { nextState[position][index] = chakra_ui_toast_esm_extends( {}, nextState[position][index], options, { message: createRenderToast(options), } ); } return nextState; }); }, closeAll: function closeAll(_temp) { var _ref = _temp === void 0 ? {} : _temp, positions = _ref.positions; // only one setState here for perf reasons // instead of spamming this.closeToast setState(function (prev) { var allPositions = [ "bottom", "bottom-right", "bottom-left", "top", "top-left", "top-right", ]; var positionsToClose = positions != null ? positions : allPositions; return positionsToClose.reduce(function ( acc, position ) { acc[position] = prev[position].map(function ( toast ) { return chakra_ui_toast_esm_extends( {}, toast, { requestClose: true, } ); }); return acc; }, chakra_ui_toast_esm_extends({}, prev)); }); }, close: function close(id) { setState(function (prevState) { var _extends4; var position = getToastPosition(prevState, id); if (!position) return prevState; return chakra_ui_toast_esm_extends( {}, prevState, ((_extends4 = {}), (_extends4[position] = prevState[position].map( function (toast) { // id may be string or number // eslint-disable-next-line eqeqeq if (toast.id == id) { return chakra_ui_toast_esm_extends( {}, toast, { requestClose: true, } ); } return toast; } )), _extends4) ); }); }, isActive: function isActive(id) { return Boolean( findToast(toastStore.getState(), id).position ); }, }; } /** * Static id counter to create unique ids * for each toast */ var counter = 0; /** * Create properties for a new toast */ function createToast(message, options) { var _options$id, _options$position; if (options === void 0) { options = {}; } counter += 1; var id = (_options$id = options.id) != null ? _options$id : counter; var position = (_options$position = options.position) != null ? _options$position : "bottom"; return { id: id, message: message, position: position, duration: options.duration, onCloseComplete: options.onCloseComplete, onRequestRemove: function onRequestRemove() { return toastStore.removeToast(String(id), position); }, status: options.status, requestClose: false, containerStyle: options.containerStyle, }; } var Toast = function Toast(props) { var status = props.status, _props$variant = props.variant, variant = _props$variant === void 0 ? "solid" : _props$variant, id = props.id, title = props.title, isClosable = props.isClosable, onClose = props.onClose, description = props.description, icon = props.icon; var alertTitleId = typeof id !== "undefined" ? "toast-" + id + "-title" : undefined; return /*#__PURE__*/ react.createElement( chakra_ui_alert_esm_Alert, { status: status, variant: variant, id: String(id), alignItems: "start", borderRadius: "md", boxShadow: "lg", paddingEnd: 8, textAlign: "start", width: "auto", "aria-labelledby": alertTitleId, }, /*#__PURE__*/ react.createElement(AlertIcon, null, icon), /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, { flex: "1", maxWidth: "100%", }, title && /*#__PURE__*/ react.createElement( AlertTitle, { id: alertTitleId, }, title ), description && /*#__PURE__*/ react.createElement( AlertDescription, { display: "block", }, description ) ), isClosable && /*#__PURE__*/ react.createElement( chakra_ui_close_button_esm_CloseButton, { size: "sm", onClick: onClose, position: "absolute", insetEnd: 1, top: 1, } ) ); }; function createRenderToast(options) { if (options === void 0) { options = {}; } var _options = options, render = _options.render, _options$toastCompone = _options.toastComponent, ToastComponent = _options$toastCompone === void 0 ? Toast : _options$toastCompone; var renderToast = function renderToast(props) { if ((0, chakra_ui_utils_esm /* isFunction */.mf)(render)) { return render(props); } return /*#__PURE__*/ react.createElement( ToastComponent, chakra_ui_toast_esm_extends({}, props, options) ); }; return renderToast; } function createToastFn(dir, defaultOptions) { var normalizeToastOptions = function normalizeToastOptions( options ) { var _options$position; return chakra_ui_toast_esm_extends( {}, defaultOptions, options, { position: getToastPlacement( (_options$position = options == null ? void 0 : options.position) != null ? _options$position : defaultOptions == null ? void 0 : defaultOptions.position, dir ), } ); }; var toast = function toast(options) { var normalizedToastOptions = normalizeToastOptions(options); var Message = createRenderToast(normalizedToastOptions); return toastStore.notify(Message, normalizedToastOptions); }; toast.update = function (id, options) { toastStore.update(id, normalizeToastOptions(options)); }; toast.promise = function (promise, options) { var id = toast( chakra_ui_toast_esm_extends({}, options.loading, { status: "loading", duration: null, }) ); promise .then(function (data) { return toast.update( id, chakra_ui_toast_esm_extends( { status: "success", duration: 5000, }, runIfFn(options.success, data) ) ); }) ["catch"](function (error) { return toast.update( id, chakra_ui_toast_esm_extends( { status: "error", duration: 5000, }, runIfFn(options.error, error) ) ); }); }; toast.closeAll = toastStore.closeAll; toast.close = toastStore.close; toast.isActive = toastStore.isActive; return toast; } /** * React hook used to create a function that can be used * to show toasts in an application. */ function useToast(defaultOptions) { var _useChakra = useChakra(), theme = _useChakra.theme; return React.useMemo( function () { return createToastFn(theme.direction, defaultOptions); }, [defaultOptions, theme.direction] ); } var toastMotionVariants = { initial: function initial(props) { var _ref; var position = props.position; var dir = ["top", "bottom"].includes(position) ? "y" : "x"; var factor = ["top-right", "bottom-right"].includes( position ) ? 1 : -1; if (position === "bottom") factor = 1; return ( (_ref = { opacity: 0, }), (_ref[dir] = factor * 24), _ref ); }, animate: { opacity: 1, y: 0, x: 0, scale: 1, transition: { duration: 0.4, ease: [0.4, 0, 0.2, 1], }, }, exit: { opacity: 0, scale: 0.85, transition: { duration: 0.2, ease: [0.4, 0, 1, 1], }, }, }; var ToastComponent = /*#__PURE__*/ react.memo(function (props) { var id = props.id, message = props.message, onCloseComplete = props.onCloseComplete, onRequestRemove = props.onRequestRemove, _props$requestClose = props.requestClose, requestClose = _props$requestClose === void 0 ? false : _props$requestClose, _props$position = props.position, position = _props$position === void 0 ? "bottom" : _props$position, _props$duration = props.duration, duration = _props$duration === void 0 ? 5000 : _props$duration, containerStyle = props.containerStyle, _props$motionVariants = props.motionVariants, motionVariants = _props$motionVariants === void 0 ? toastMotionVariants : _props$motionVariants, _props$toastSpacing = props.toastSpacing, toastSpacing = _props$toastSpacing === void 0 ? "0.5rem" : _props$toastSpacing; var _React$useState = react.useState(duration), delay = _React$useState[0], setDelay = _React$useState[1]; var isPresent = (0, use_presence /* useIsPresent */.hO)(); (0, chakra_ui_hooks_esm /* useUpdateEffect */.rf)( function () { if (!isPresent) { onCloseComplete == null ? void 0 : onCloseComplete(); } }, [isPresent] ); (0, chakra_ui_hooks_esm /* useUpdateEffect */.rf)( function () { setDelay(duration); }, [duration] ); var onMouseEnter = function onMouseEnter() { return setDelay(null); }; var onMouseLeave = function onMouseLeave() { return setDelay(duration); }; var close = function close() { if (isPresent) onRequestRemove(); }; react.useEffect( function () { if (isPresent && requestClose) { onRequestRemove(); } }, [isPresent, requestClose, onRequestRemove] ); (0, chakra_ui_hooks_esm /* useTimeout */.KS)(close, delay); var containerStyles = react.useMemo( function () { return chakra_ui_toast_esm_extends( { pointerEvents: "auto", maxWidth: 560, minWidth: 300, margin: toastSpacing, }, containerStyle ); }, [containerStyle, toastSpacing] ); var toastStyle = react.useMemo( function () { return getToastStyle(position); }, [position] ); return /*#__PURE__*/ react.createElement( motion /* motion.li */.E.li, { layout: true, className: "chakra-toast", variants: motionVariants, initial: "initial", animate: "animate", exit: "exit", onHoverStart: onMouseEnter, onHoverEnd: onMouseLeave, custom: { position: position, }, style: toastStyle, }, /*#__PURE__*/ react.createElement( chakra_ui_system_esm /* chakra.div */.m$.div, { role: "status", "aria-atomic": "true", className: "chakra-toast__inner", __css: containerStyles, }, (0, chakra_ui_utils_esm /* runIfFn */.Pu)(message, { id: id, onClose: close, }) ) ); }); if (chakra_ui_utils_esm /* __DEV__ */.Ts) { ToastComponent.displayName = "ToastComponent"; } /** * Manages the creation, and removal of toasts * across all corners ("top", "bottom", etc.) */ var ToastProvider = function ToastProvider(props) { var state = react.useSyncExternalStore( toastStore.subscribe, toastStore.getState, toastStore.getState ); var children = props.children, motionVariants = props.motionVariants, _props$component = props.component, Component = _props$component === void 0 ? ToastComponent : _props$component, portalProps = props.portalProps; var toastList = (0, chakra_ui_utils_esm /* objectKeys */.Yd)( state ).map(function (position) { var toasts = state[position]; return /*#__PURE__*/ react.createElement( "ul", { role: "region", "aria-live": "polite", key: position, id: "chakra-toast-manager-" + position, style: getToastListStyle(position), }, /*#__PURE__*/ react.createElement( AnimatePresence /* AnimatePresence */.M, { initial: false, }, toasts.map(function (toast) { return /*#__PURE__*/ react.createElement( Component, chakra_ui_toast_esm_extends( { key: toast.id, motionVariants: motionVariants, }, toast ) ); }) ) ); }); return /*#__PURE__*/ react.createElement( react.Fragment, null, children, /*#__PURE__*/ react.createElement( Portal, portalProps, toastList ) ); }; var defaults = { duration: 5000, variant: "solid", }; var defaultStandaloneParam = { theme: theme, colorMode: "light", toggleColorMode: chakra_ui_utils_esm /* noop */.ZT, setColorMode: chakra_ui_utils_esm /* noop */.ZT, defaultOptions: defaults, }; /** * Create a toast */ function createStandaloneToast(_temp) { var _ref = _temp === void 0 ? defaultStandaloneParam : _temp, _ref$theme = _ref.theme, theme = _ref$theme === void 0 ? defaultStandaloneParam.theme : _ref$theme, _ref$colorMode = _ref.colorMode, colorMode = _ref$colorMode === void 0 ? defaultStandaloneParam.colorMode : _ref$colorMode, _ref$toggleColorMode = _ref.toggleColorMode, toggleColorMode = _ref$toggleColorMode === void 0 ? defaultStandaloneParam.toggleColorMode : _ref$toggleColorMode, _ref$setColorMode = _ref.setColorMode, setColorMode = _ref$setColorMode === void 0 ? defaultStandaloneParam.setColorMode : _ref$setColorMode, _ref$defaultOptions = _ref.defaultOptions, defaultOptions = _ref$defaultOptions === void 0 ? defaultStandaloneParam.defaultOptions : _ref$defaultOptions, motionVariants = _ref.motionVariants, toastSpacing = _ref.toastSpacing, component = _ref.component; var colorModeContextValue = { colorMode: colorMode, setColorMode: setColorMode, toggleColorMode: toggleColorMode, }; var ToastContainer = function ToastContainer() { return /*#__PURE__*/ React.createElement( ThemeProvider, { theme: theme, }, /*#__PURE__*/ React.createElement( ColorModeContext.Provider, { value: colorModeContextValue, }, /*#__PURE__*/ React.createElement(ToastProvider, { defaultOptions: defaultOptions, motionVariants: motionVariants, toastSpacing: toastSpacing, component: component, }) ) ); }; return { ToastContainer: ToastContainer, toast: createToastFn(theme.direction, defaultOptions), }; } // CONCATENATED MODULE: ./node_modules/@chakra-ui/react/dist/chakra-ui-react.esm.js function chakra_ui_react_esm_objectWithoutPropertiesLoose( source, excluded ) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var chakra_ui_react_esm_excluded = ["children", "toastOptions"]; var ChakraProvider = function ChakraProvider(_ref) { var children = _ref.children, toastOptions = _ref.toastOptions, restProps = chakra_ui_react_esm_objectWithoutPropertiesLoose( _ref, chakra_ui_react_esm_excluded ); return /*#__PURE__*/ react.createElement( chakra_ui_provider_esm_ChakraProvider, restProps, children, /*#__PURE__*/ react.createElement( ToastProvider, toastOptions ) ); }; ChakraProvider.defaultProps = { theme: theme, }; /** * NOTE: This got too complex to manage, and it's not worth the extra complexity. * We'll re-evaluate this API in the future releases. * * Function to override or customize the Chakra UI theme conveniently. * First extension overrides the baseTheme and following extensions override the preceding extensions. * * @example: * import { theme as baseTheme, extendTheme, withDefaultColorScheme } from '@chakra-ui/react' * * const customTheme = extendTheme( * { * colors: { * brand: { * 500: "#b4d455", * }, * }, * }, * withDefaultColorScheme({ colorScheme: "red" }), * baseTheme // optional * ) */ function extendTheme() { for ( var _len = arguments.length, extensions = new Array(_len), _key = 0; _key < _len; _key++ ) { extensions[_key] = arguments[_key]; } var overrides = [].concat(extensions); var baseTheme = extensions[extensions.length - 1]; if ( isChakraTheme(baseTheme) && // this ensures backward compatibility // previously only `extendTheme(override, baseTheme?)` was allowed overrides.length > 1 ) { overrides = overrides.slice(0, overrides.length - 1); } else { baseTheme = theme$1; } return pipe.apply( void 0, overrides.map(function (extension) { return function (prevTheme) { return isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension); }; }) )(baseTheme); } function mergeThemeOverride() { for ( var _len2 = arguments.length, overrides = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++ ) { overrides[_key2] = arguments[_key2]; } return mergeWith.apply( void 0, [{}].concat(overrides, [mergeThemeCustomizer]) ); } function mergeThemeCustomizer(source, override, key, object) { if ( (isFunction(source) || isFunction(override)) && Object.prototype.hasOwnProperty.call(object, key) ) { return function () { var sourceValue = isFunction(source) ? source.apply(void 0, arguments) : source; var overrideValue = isFunction(override) ? override.apply(void 0, arguments) : override; return mergeWith( {}, sourceValue, overrideValue, mergeThemeCustomizer ); }; } // fallback to default behaviour return undefined; } function withDefaultColorScheme(_ref) { var colorScheme = _ref.colorScheme, components = _ref.components; return function (theme) { var names = Object.keys(theme.components || {}); if (Array.isArray(components)) { names = components; } else if (isObject(components)) { names = Object.keys(components); } return mergeThemeOverride(theme, { components: fromEntries( names.map(function (componentName) { var withColorScheme = { defaultProps: { colorScheme: colorScheme, }, }; return [componentName, withColorScheme]; }) ), }); }; } function withDefaultSize(_ref) { var size = _ref.size, components = _ref.components; return function (theme) { var names = Object.keys(theme.components || {}); if (Array.isArray(components)) { names = components; } else if (isObject(components)) { names = Object.keys(components); } return mergeThemeOverride(theme, { components: fromEntries( names.map(function (componentName) { var withSize = { defaultProps: { size: size, }, }; return [componentName, withSize]; }) ), }); }; } function withDefaultVariant(_ref) { var variant = _ref.variant, components = _ref.components; return function (theme) { var names = Object.keys(theme.components || {}); if (Array.isArray(components)) { names = components; } else if (isObject(components)) { names = Object.keys(components); } return mergeThemeOverride(theme, { components: fromEntries( names.map(function (componentName) { var withVariant = { defaultProps: { variant: variant, }, }; return [componentName, withVariant]; }) ), }); }; } function withDefaultProps(_ref) { var _ref$defaultProps = _ref.defaultProps, colorScheme = _ref$defaultProps.colorScheme, variant = _ref$defaultProps.variant, size = _ref$defaultProps.size, components = _ref.components; var identity = function identity(t) { return t; }; var fns = [ colorScheme ? withDefaultColorScheme({ colorScheme: colorScheme, components: components, }) : identity, size ? withDefaultSize({ size: size, components: components, }) : identity, variant ? withDefaultVariant({ variant: variant, components: components, }) : identity, ]; return function (theme) { return mergeThemeOverride(pipe.apply(void 0, fns)(theme)); }; } // CONCATENATED MODULE: ./pages/_app.jsx function MyApp(param) { var Component = param.Component, pageProps = param.pageProps; return /*#__PURE__*/ (0, jsx_runtime.jsx)(ChakraProvider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)( Component, _objectSpread({}, pageProps) ), }); } /* harmony default export */ var _app = MyApp; /***/ }, }, /******/ function (__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function (moduleId) { return __webpack_require__((__webpack_require__.s = moduleId)); }; /******/ __webpack_require__.O(0, [774, 179], function () { return __webpack_exec__(3837), __webpack_exec__(387); }); /******/ var __webpack_exports__ = __webpack_require__.O(); /******/ _N_E = __webpack_exports__; /******/ }, ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/chakra/output.js
JavaScript
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([ [ 888 ], { /***/ 2260: /***/ function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__), // EXPORTS __webpack_require__.d(__webpack_exports__, { default: function() { return /* binding */ _app; } }); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var initialState, state, listeners, setState, _lg$1, _md$1, _sm$1, _baseStyleRoot, _Input$baseStyle$fiel, _Input$baseStyle, _Input$variants$unsty$1, _xs, _sm, _md, _lg, _xl, _container2, _container3, _container4, _Input$variants$unsty, _Input$sizes$xs$field, _Input$sizes$sm$field, _Input$sizes$md$field, _Input$sizes$lg$field, jsx_runtime = __webpack_require__(5893), react = __webpack_require__(7294), emotion_react_browser_esm = __webpack_require__(917), CSSReset$1 = function() { return /*#__PURE__*/ react.createElement(emotion_react_browser_esm /* Global */ .xB, { styles: '\n html {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n font-family: system-ui, sans-serif;\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n -moz-osx-font-smoothing: grayscale;\n touch-action: manipulation;\n }\n\n body {\n position: relative;\n min-height: 100%;\n font-feature-settings: \'kern\';\n }\n\n *,\n *::before,\n *::after {\n border-width: 0;\n border-style: solid;\n box-sizing: border-box;\n }\n\n main {\n display: block;\n }\n\n hr {\n border-top-width: 1px;\n box-sizing: content-box;\n height: 0;\n overflow: visible;\n }\n\n pre,\n code,\n kbd,\n samp {\n font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 1em;\n }\n\n a {\n background-color: transparent;\n color: inherit;\n text-decoration: inherit;\n }\n\n abbr[title] {\n border-bottom: none;\n text-decoration: underline;\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n\n b,\n strong {\n font-weight: bold;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n img {\n border-style: none;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n line-height: 1.15;\n margin: 0;\n }\n\n button,\n input {\n overflow: visible;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button::-moz-focus-inner,\n [type="button"]::-moz-focus-inner,\n [type="reset"]::-moz-focus-inner,\n [type="submit"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n fieldset {\n padding: 0.35em 0.75em 0.625em;\n }\n\n legend {\n box-sizing: border-box;\n color: inherit;\n display: table;\n max-width: 100%;\n padding: 0;\n white-space: normal;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n textarea {\n overflow: auto;\n }\n\n [type="checkbox"],\n [type="radio"] {\n box-sizing: border-box;\n padding: 0;\n }\n\n [type="number"]::-webkit-inner-spin-button,\n [type="number"]::-webkit-outer-spin-button {\n -webkit-appearance: none !important;\n }\n\n input[type="number"] {\n -moz-appearance: textfield;\n }\n\n [type="search"] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n [type="search"]::-webkit-search-decoration {\n -webkit-appearance: none !important;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n details {\n display: block;\n }\n\n summary {\n display: list-item;\n }\n\n template {\n display: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n body,\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n button {\n background: transparent;\n padding: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n ol,\n ul {\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n button,\n [role="button"] {\n cursor: pointer;\n }\n\n button::-moz-focus-inner {\n border: 0 !important;\n }\n\n table {\n border-collapse: collapse;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n padding: 0;\n line-height: inherit;\n color: inherit;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [data-js-focus-visible] :focus:not([data-focus-visible-added]):not([data-focus-visible-disabled]) {\n outline: none;\n box-shadow: none;\n }\n\n select::-ms-expand {\n display: none;\n }\n ' }); }, chakra_ui_utils_esm = __webpack_require__(5031), chakra_ui_react_utils_esm = __webpack_require__(6450), chakra_ui_hooks_esm = __webpack_require__(7375), use_animation_state_5054a9f7_esm = __webpack_require__(4697), react_dom = __webpack_require__(3935), _createContext$1 = (0, chakra_ui_react_utils_esm /* createContext */ .kr)({ strict: !1, name: "PortalManagerContext" }), PortalManagerContextProvider = _createContext$1[0], usePortalManager = _createContext$1[1]; function PortalManager(props) { var children = props.children, zIndex = props.zIndex; return /*#__PURE__*/ react.createElement(PortalManagerContextProvider, { value: { zIndex: zIndex } }, children); } function _extends() { return (_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } chakra_ui_utils_esm /* __DEV__ */ .Ts && (PortalManager.displayName = "PortalManager"); var _excluded = [ "containerRef" ], _createContext = (0, chakra_ui_react_utils_esm /* createContext */ .kr)({ strict: !1, name: "PortalContext" }), PortalContextProvider = _createContext[0], usePortalContext = _createContext[1], PORTAL_CLASSNAME = "chakra-portal", Container = function(props) { return /*#__PURE__*/ react.createElement("div", { className: "chakra-portal-zIndex", style: { position: "absolute", zIndex: props.zIndex, top: 0, left: 0, right: 0 } }, props.children); }, DefaultPortal = function(props) { var appendToParentPortal = props.appendToParentPortal, children = props.children, tempNode = react.useRef(null), portal = react.useRef(null), forceUpdate = (0, chakra_ui_hooks_esm /* useForceUpdate */ .NW)(), parentPortal = usePortalContext(), manager = usePortalManager(); (0, use_animation_state_5054a9f7_esm.a)(function() { if (tempNode.current) { var doc = tempNode.current.ownerDocument, host = appendToParentPortal && null != parentPortal ? parentPortal : doc.body; if (host) { portal.current = doc.createElement("div"), portal.current.className = PORTAL_CLASSNAME, host.appendChild(portal.current), forceUpdate(); var portalNode = portal.current; return function() { host.contains(portalNode) && host.removeChild(portalNode); }; } } }, []); var _children = null != manager && manager.zIndex ? /*#__PURE__*/ react.createElement(Container, { zIndex: null == manager ? void 0 : manager.zIndex }, children) : children; return portal.current ? /*#__PURE__*/ (0, react_dom.createPortal)(/*#__PURE__*/ react.createElement(PortalContextProvider, { value: portal.current }, _children), portal.current) : /*#__PURE__*/ react.createElement("span", { ref: tempNode }); }, ContainerPortal = function(props) { var children = props.children, containerRef = props.containerRef, appendToParentPortal = props.appendToParentPortal, containerEl = containerRef.current, host = null != containerEl ? containerEl : chakra_ui_utils_esm /* isBrowser */ .jU ? document.body : void 0, portal = react.useMemo(function() { var node = null == containerEl ? void 0 : containerEl.ownerDocument.createElement("div"); return node && (node.className = PORTAL_CLASSNAME), node; }, [ containerEl ]), forceUpdate = (0, chakra_ui_hooks_esm /* useForceUpdate */ .NW)(); return ((0, use_animation_state_5054a9f7_esm.a)(function() { forceUpdate(); }, []), (0, use_animation_state_5054a9f7_esm.a)(function() { if (portal && host) return host.appendChild(portal), function() { host.removeChild(portal); }; }, [ portal, host ]), host && portal) ? /*#__PURE__*/ (0, react_dom.createPortal)(/*#__PURE__*/ react.createElement(PortalContextProvider, { value: appendToParentPortal ? portal : null }, children), portal) : null; }; /** * Portal * * Declarative component used to render children into a DOM node * that exists outside the DOM hierarchy of the parent component. * * @see Docs https://chakra-ui.com/portal */ function Portal(props) { var containerRef = props.containerRef, rest = function(source, excluded) { if (null == source) return {}; var key, i, target = {}, sourceKeys = Object.keys(source); for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); return target; }(props, _excluded); return containerRef ? /*#__PURE__*/ react.createElement(ContainerPortal, _extends({ containerRef: containerRef }, rest)) : /*#__PURE__*/ react.createElement(DefaultPortal, rest); } Portal.defaultProps = { appendToParentPortal: !0 }, Portal.className = PORTAL_CLASSNAME, Portal.selector = ".chakra-portal", chakra_ui_utils_esm /* __DEV__ */ .Ts && (Portal.displayName = "Portal"); // EXTERNAL MODULE: ./node_modules/@chakra-ui/system/dist/chakra-ui-system.esm.js + 3 modules var chakra_ui_system_esm = __webpack_require__(2846), chakra_ui_color_mode_esm = __webpack_require__(949), ssrDocument = { body: { classList: { add: function() {}, remove: function() {} } }, addEventListener: function() {}, removeEventListener: function() {}, activeElement: { blur: function() {}, nodeName: "" }, querySelector: function() { return null; }, querySelectorAll: function() { return []; }, getElementById: function() { return null; }, createEvent: function() { return { initEvent: function() {} }; }, createElement: function() { return { children: [], childNodes: [], style: {}, setAttribute: function() {}, getElementsByTagName: function() { return []; } }; } }, noop = function() {}, defaultEnv = chakra_ui_utils_esm /* isBrowser */ .jU ? { window: window, document: document } : { window: { document: ssrDocument, navigator: { userAgent: "" }, CustomEvent: function() { return this; }, addEventListener: noop, removeEventListener: noop, getComputedStyle: function() { return { getPropertyValue: function() { return ""; } }; }, matchMedia: function() { return { matches: !1, addListener: noop, removeListener: noop }; }, requestAnimationFrame: function(callback) { return "undefined" == typeof setTimeout ? (callback(), null) : setTimeout(callback, 0); }, cancelAnimationFrame: function(id) { "undefined" != typeof setTimeout && clearTimeout(id); }, setTimeout: function() { return 0; }, clearTimeout: noop, setInterval: function() { return 0; }, clearInterval: noop }, document: ssrDocument }, EnvironmentContext = /*#__PURE__*/ (0, react.createContext)(defaultEnv); function EnvironmentProvider(props) { var children = props.children, environmentProp = props.environment, _useState = (0, react.useState)(null), node = _useState[0], setNode = _useState[1], context = (0, react.useMemo)(function() { var _ref, doc = null == node ? void 0 : node.ownerDocument, win = null == node ? void 0 : node.ownerDocument.defaultView; return null != (_ref = null != environmentProp ? environmentProp : doc ? { document: doc, window: win } : void 0) ? _ref : defaultEnv; }, [ node, environmentProp ]); return /*#__PURE__*/ react.createElement(EnvironmentContext.Provider, { value: context }, children, /*#__PURE__*/ react.createElement("span", { hidden: !0, className: "chakra-env", ref: function(el) { (0, react.startTransition)(function() { el && setNode(el); }); } })); } chakra_ui_utils_esm /* __DEV__ */ .Ts && (EnvironmentContext.displayName = "EnvironmentContext"), chakra_ui_utils_esm /* __DEV__ */ .Ts && (EnvironmentProvider.displayName = "EnvironmentProvider"); /** * The global provider that must be added to make all Chakra components * work correctly */ var chakra_ui_provider_esm_ChakraProvider = function(props) { var children = props.children, colorModeManager = props.colorModeManager, portalZIndex = props.portalZIndex, _props$resetCSS = props.resetCSS, _props$theme = props.theme, theme = void 0 === _props$theme ? {} : _props$theme, environment = props.environment, cssVarsRoot = props.cssVarsRoot, _children = /*#__PURE__*/ react.createElement(EnvironmentProvider, { environment: environment }, children); return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* ThemeProvider */ .f6, { theme: theme, cssVarsRoot: cssVarsRoot }, /*#__PURE__*/ react.createElement(chakra_ui_color_mode_esm /* ColorModeProvider */ .SG, { colorModeManager: colorModeManager, options: theme.config }, (void 0 === _props$resetCSS || _props$resetCSS) && /*#__PURE__*/ react.createElement(CSSReset$1, null), /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* GlobalStyle */ .ZL, null), portalZIndex ? /*#__PURE__*/ react.createElement(PortalManager, { zIndex: portalZIndex }, _children) : _children)); }, spacing = { px: "1px", 0.5: "0.125rem", 1: "0.25rem", 1.5: "0.375rem", 2: "0.5rem", 2.5: "0.625rem", 3: "0.75rem", 3.5: "0.875rem", 4: "1rem", 5: "1.25rem", 6: "1.5rem", 7: "1.75rem", 8: "2rem", 9: "2.25rem", 10: "2.5rem", 12: "3rem", 14: "3.5rem", 16: "4rem", 20: "5rem", 24: "6rem", 28: "7rem", 32: "8rem", 36: "9rem", 40: "10rem", 44: "11rem", 48: "12rem", 52: "13rem", 56: "14rem", 60: "15rem", 64: "16rem", 72: "18rem", 80: "20rem", 96: "24rem" }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme/foundations/spacing/dist/chakra-ui-theme-foundations-spacing.esm.js function sizes_501602a9_esm_extends() { return (sizes_501602a9_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } var sizes = sizes_501602a9_esm_extends({}, spacing, { max: "max-content", min: "min-content", full: "100%", "3xs": "14rem", "2xs": "16rem", xs: "20rem", sm: "24rem", md: "28rem", lg: "32rem", xl: "36rem", "2xl": "42rem", "3xl": "48rem", "4xl": "56rem", "5xl": "64rem", "6xl": "72rem", "7xl": "80rem", "8xl": "90rem" }, { container: { sm: "640px", md: "768px", lg: "1024px", xl: "1280px" } }); // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/util.js /** * Take input from [0, n] and return it as [0, 1] * @hidden */ function bound01(n, max) { "string" == typeof (n1 = n) && -1 !== n1.indexOf(".") && 1 === parseFloat(n1) && (n = "100%"); var n1, n2, isPercent = "string" == typeof (n2 = n) && -1 !== n2.indexOf("%"); return(// Handle floating point rounding errors (n = 360 === max ? n : Math.min(max, Math.max(0, parseFloat(n))), isPercent && (n = parseInt(String(n * max), 10) / 100), 0.000001 > Math.abs(n - max)) ? 1 : // If n is a hue given in degrees, // wrap around out-of-range values into [0, 360] range // then convert into [0, 1]. n = 360 === max ? (n < 0 ? n % max + max : n % max) / parseFloat(String(max)) : n % max / parseFloat(String(max))); } /** * Force a number between 0 and 1 * @hidden */ function clamp01(val) { return Math.min(1, Math.max(0, val)); } /** * Return a valid alpha value [0,1] with all invalid values being set to 1 * @hidden */ function boundAlpha(a) { return (isNaN(a = parseFloat(a)) || a < 0 || a > 1) && (a = 1), a; } /** * Replace a decimal with it's percentage value * @hidden */ function convertToPercentage(n) { return n <= 1 ? "".concat(100 * Number(n), "%") : n; } /** * Force a hex value to have 2 characters * @hidden */ function util_pad2(c) { return 1 === c.length ? "0" + c : String(c); } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/conversion.js /** * Converts an RGB color value to HSL. * *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] * *Returns:* { h, s, l } in [0,1] */ function rgbToHsl(r, g, b) { var max = Math.max(r = bound01(r, 255), g = bound01(g, 255), b = bound01(b, 255)), min = Math.min(r, g, b), h = 0, s = 0, l = (max + min) / 2; if (max === min) s = 0, h = 0; else { var d = max - min; switch(s = l > 0.5 ? d / (2 - max - min) : d / (max + min), max){ case r: h = (g - b) / d + 6 * (g < b); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; } h /= 6; } return { h: h, s: s, l: l }; } function hue2rgb(p, q, t) { return (t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6) ? p + 6 * t * (q - p) : t < 0.5 ? q : t < 2 / 3 ? p + (q - p) * (2 / 3 - t) * 6 : p; } /** * Converts an RGB color value to HSV * * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] * *Returns:* { h, s, v } in [0,1] */ function rgbToHsv(r, g, b) { var max = Math.max(r = bound01(r, 255), g = bound01(g, 255), b = bound01(b, 255)), min = Math.min(r, g, b), h = 0, d = max - min; if (max === min) h = 0; // achromatic else { switch(max){ case r: h = (g - b) / d + 6 * (g < b); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; } h /= 6; } return { h: h, s: 0 === max ? 0 : d / max, v: max }; } /** * Converts an RGB color to hex * * Assumes r, g, and b are contained in the set [0, 255] * Returns a 3 or 6 character hex */ function rgbToHex(r, g, b, allow3Char) { var hex = [ util_pad2(Math.round(r).toString(16)), util_pad2(Math.round(g).toString(16)), util_pad2(Math.round(b).toString(16)) ]; return(// Return a 3 character hex if possible allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) ? hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) : hex.join("")); } /** Parse a base-16 hex value into a base-10 integer */ function parseIntFromHex(val) { return parseInt(val, 16); } // https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json /** * @hidden */ var names = { aliceblue: "#f0f8ff", antiquewhite: "#faebd7", aqua: "#00ffff", aquamarine: "#7fffd4", azure: "#f0ffff", beige: "#f5f5dc", bisque: "#ffe4c4", black: "#000000", blanchedalmond: "#ffebcd", blue: "#0000ff", blueviolet: "#8a2be2", brown: "#a52a2a", burlywood: "#deb887", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", cornflowerblue: "#6495ed", cornsilk: "#fff8dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkseagreen: "#8fbc8f", darkslateblue: "#483d8b", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", darkturquoise: "#00ced1", darkviolet: "#9400d3", deeppink: "#ff1493", deepskyblue: "#00bfff", dimgray: "#696969", dimgrey: "#696969", dodgerblue: "#1e90ff", firebrick: "#b22222", floralwhite: "#fffaf0", forestgreen: "#228b22", fuchsia: "#ff00ff", gainsboro: "#dcdcdc", ghostwhite: "#f8f8ff", goldenrod: "#daa520", gold: "#ffd700", gray: "#808080", green: "#008000", greenyellow: "#adff2f", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", indianred: "#cd5c5c", indigo: "#4b0082", ivory: "#fffff0", khaki: "#f0e68c", lavenderblush: "#fff0f5", lavender: "#e6e6fa", lawngreen: "#7cfc00", lemonchiffon: "#fffacd", lightblue: "#add8e6", lightcoral: "#f08080", lightcyan: "#e0ffff", lightgoldenrodyellow: "#fafad2", lightgray: "#d3d3d3", lightgreen: "#90ee90", lightgrey: "#d3d3d3", lightpink: "#ffb6c1", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", lightskyblue: "#87cefa", lightslategray: "#778899", lightslategrey: "#778899", lightsteelblue: "#b0c4de", lightyellow: "#ffffe0", lime: "#00ff00", limegreen: "#32cd32", linen: "#faf0e6", magenta: "#ff00ff", maroon: "#800000", mediumaquamarine: "#66cdaa", mediumblue: "#0000cd", mediumorchid: "#ba55d3", mediumpurple: "#9370db", mediumseagreen: "#3cb371", mediumslateblue: "#7b68ee", mediumspringgreen: "#00fa9a", mediumturquoise: "#48d1cc", mediumvioletred: "#c71585", midnightblue: "#191970", mintcream: "#f5fffa", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", navajowhite: "#ffdead", navy: "#000080", oldlace: "#fdf5e6", olive: "#808000", olivedrab: "#6b8e23", orange: "#ffa500", orangered: "#ff4500", orchid: "#da70d6", palegoldenrod: "#eee8aa", palegreen: "#98fb98", paleturquoise: "#afeeee", palevioletred: "#db7093", papayawhip: "#ffefd5", peachpuff: "#ffdab9", peru: "#cd853f", pink: "#ffc0cb", plum: "#dda0dd", powderblue: "#b0e0e6", purple: "#800080", rebeccapurple: "#663399", red: "#ff0000", rosybrown: "#bc8f8f", royalblue: "#4169e1", saddlebrown: "#8b4513", salmon: "#fa8072", sandybrown: "#f4a460", seagreen: "#2e8b57", seashell: "#fff5ee", sienna: "#a0522d", silver: "#c0c0c0", skyblue: "#87ceeb", slateblue: "#6a5acd", slategray: "#708090", slategrey: "#708090", snow: "#fffafa", springgreen: "#00ff7f", steelblue: "#4682b4", tan: "#d2b48c", teal: "#008080", thistle: "#d8bfd8", tomato: "#ff6347", turquoise: "#40e0d0", violet: "#ee82ee", wheat: "#f5deb3", white: "#ffffff", whitesmoke: "#f5f5f5", yellow: "#ffff00", yellowgreen: "#9acd32" }, CSS_UNIT = "(?:".concat("[-\\+]?\\d*\\.\\d+%?", ")|(?:").concat("[-\\+]?\\d+%?", ")"), PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), matchers = { CSS_UNIT: new RegExp(CSS_UNIT), rgb: RegExp("rgb" + PERMISSIVE_MATCH3), rgba: RegExp("rgba" + PERMISSIVE_MATCH4), hsl: RegExp("hsl" + PERMISSIVE_MATCH3), hsla: RegExp("hsla" + PERMISSIVE_MATCH4), hsv: RegExp("hsv" + PERMISSIVE_MATCH3), hsva: RegExp("hsva" + PERMISSIVE_MATCH4), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ }; // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/format-input.js /** * Check to see if it looks like a CSS unit * (see `matchers` above for definition). */ function isValidCSSUnit(color) { return !!matchers.CSS_UNIT.exec(String(color)); } // CONCATENATED MODULE: ./node_modules/@ctrl/tinycolor/dist/module/index.js var module_TinyColor = /** @class */ function() { function TinyColor(color, opts) { // If input is already a tinycolor, return itself if (void 0 === color && (color = ""), void 0 === opts && (opts = {}), color instanceof TinyColor) // eslint-disable-next-line no-constructor-return return color; "number" == typeof color && (color = { r: (color1 = color) >> 16, g: (0xff00 & color1) >> 8, b: 0xff & color1 }), this.originalInput = color; var color1, color2, r, g, b, h, s, v, i, f, p, q, t, mod, rgb, a, s1, v1, l, ok, format, _a, rgb1 = (rgb = { r: 0, g: 0, b: 0 }, a = 1, s1 = null, v1 = null, l = null, ok = !1, format = !1, "string" == typeof (color2 = color) && (color2 = /** * Permissive string parsing. Take in a number of formats, and output an object * based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` */ function(color) { if (0 === (color = color.trim().toLowerCase()).length) return !1; var named = !1; if (names[color]) color = names[color], named = !0; else if ("transparent" === color) return { r: 0, g: 0, b: 0, a: 0, format: "name" }; // Try to match string input using regular expressions. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] // Just return an object and let the conversion functions handle that. // This way the result will be the same whether the tinycolor is initialized with string or object. var match = matchers.rgb.exec(color); return match ? { r: match[1], g: match[2], b: match[3] } : (match = matchers.rgba.exec(color)) ? { r: match[1], g: match[2], b: match[3], a: match[4] } : (match = matchers.hsl.exec(color)) ? { h: match[1], s: match[2], l: match[3] } : (match = matchers.hsla.exec(color)) ? { h: match[1], s: match[2], l: match[3], a: match[4] } : (match = matchers.hsv.exec(color)) ? { h: match[1], s: match[2], v: match[3] } : (match = matchers.hsva.exec(color)) ? { h: match[1], s: match[2], v: match[3], a: match[4] } : (match = matchers.hex8.exec(color)) ? { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), a: parseIntFromHex(match[4]) / 255, format: named ? "name" : "hex8" } : (match = matchers.hex6.exec(color)) ? { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), format: named ? "name" : "hex" } : (match = matchers.hex4.exec(color)) ? { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), a: parseIntFromHex(match[4] + match[4]) / 255, format: named ? "name" : "hex8" } : !!(match = matchers.hex3.exec(color)) && { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), format: named ? "name" : "hex" }; }(color2)), "object" == typeof color2 && (isValidCSSUnit(color2.r) && isValidCSSUnit(color2.g) && isValidCSSUnit(color2.b) ? (r = color2.r, g = color2.g, b = color2.b, rgb = { r: 255 * bound01(r, 255), g: 255 * bound01(g, 255), b: 255 * bound01(b, 255) }, ok = !0, format = "%" === String(color2.r).substr(-1) ? "prgb" : "rgb") : isValidCSSUnit(color2.h) && isValidCSSUnit(color2.s) && isValidCSSUnit(color2.v) ? (s1 = convertToPercentage(color2.s), v1 = convertToPercentage(color2.v), h = color2.h, s = s1, v = v1, h = 6 * bound01(h, 360), s = bound01(s, 100), v = bound01(v, 100), i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), rgb = { r: 255 * [ v, q, p, p, t, v ][mod = i % 6], g: 255 * [ t, v, v, q, p, p ][mod], b: 255 * [ p, p, t, v, v, q ][mod] }, ok = !0, format = "hsv") : isValidCSSUnit(color2.h) && isValidCSSUnit(color2.s) && isValidCSSUnit(color2.l) && (s1 = convertToPercentage(color2.s), l = convertToPercentage(color2.l), rgb = /** * Converts an HSL color value to RGB. * * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] * *Returns:* { r, g, b } in the set [0, 255] */ function(h, s, l) { if (h = bound01(h, 360), s = bound01(s, 100), l = bound01(l, 100), 0 === s) // achromatic g = l, b = l, r = l; else { var r, g, b, q = l < 0.5 ? l * (1 + s) : l + s - l * s, p = 2 * l - q; r = hue2rgb(p, q, h + 1 / 3), g = hue2rgb(p, q, h), b = hue2rgb(p, q, h - 1 / 3); } return { r: 255 * r, g: 255 * g, b: 255 * b }; }(color2.h, s1, l), ok = !0, format = "hsl"), Object.prototype.hasOwnProperty.call(color2, "a") && (a = color2.a)), a = boundAlpha(a), { ok: ok, format: color2.format || format, r: Math.min(255, Math.max(rgb.r, 0)), g: Math.min(255, Math.max(rgb.g, 0)), b: Math.min(255, Math.max(rgb.b, 0)), a: a }); this.originalInput = color, this.r = rgb1.r, this.g = rgb1.g, this.b = rgb1.b, this.a = rgb1.a, this.roundA = Math.round(100 * this.a) / 100, this.format = null !== (_a = opts.format) && void 0 !== _a ? _a : rgb1.format, this.gradientType = opts.gradientType, this.r < 1 && (this.r = Math.round(this.r)), this.g < 1 && (this.g = Math.round(this.g)), this.b < 1 && (this.b = Math.round(this.b)), this.isValid = rgb1.ok; } return TinyColor.prototype.isDark = function() { return 128 > this.getBrightness(); }, TinyColor.prototype.isLight = function() { return !this.isDark(); }, /** * Returns the perceived brightness of the color, from 0-255. */ TinyColor.prototype.getBrightness = function() { // http://www.w3.org/TR/AERT#color-contrast var rgb = this.toRgb(); return (299 * rgb.r + 587 * rgb.g + 114 * rgb.b) / 1000; }, /** * Returns the perceived luminance of a color, from 0-1. */ TinyColor.prototype.getLuminance = function() { // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef var rgb = this.toRgb(), RsRGB = rgb.r / 255, GsRGB = rgb.g / 255, BsRGB = rgb.b / 255; return 0.2126 * (RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4)) + 0.7152 * (GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4)) + 0.0722 * (BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4)); }, /** * Returns the alpha value of a color, from 0-1. */ TinyColor.prototype.getAlpha = function() { return this.a; }, /** * Sets the alpha value on the current color. * * @param alpha - The new alpha value. The accepted range is 0-1. */ TinyColor.prototype.setAlpha = function(alpha) { return this.a = boundAlpha(alpha), this.roundA = Math.round(100 * this.a) / 100, this; }, /** * Returns the object as a HSVA object. */ TinyColor.prototype.toHsv = function() { var hsv = rgbToHsv(this.r, this.g, this.b); return { h: 360 * hsv.h, s: hsv.s, v: hsv.v, a: this.a }; }, /** * Returns the hsva values interpolated into a string with the following format: * "hsva(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toHsvString = function() { var hsv = rgbToHsv(this.r, this.g, this.b), h = Math.round(360 * hsv.h), s = Math.round(100 * hsv.s), v = Math.round(100 * hsv.v); return 1 === this.a ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")"); }, /** * Returns the object as a HSLA object. */ TinyColor.prototype.toHsl = function() { var hsl = rgbToHsl(this.r, this.g, this.b); return { h: 360 * hsl.h, s: hsl.s, l: hsl.l, a: this.a }; }, /** * Returns the hsla values interpolated into a string with the following format: * "hsla(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toHslString = function() { var hsl = rgbToHsl(this.r, this.g, this.b), h = Math.round(360 * hsl.h), s = Math.round(100 * hsl.s), l = Math.round(100 * hsl.l); return 1 === this.a ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")"); }, /** * Returns the hex value of the color. * @param allow3Char will shorten hex value to 3 char if possible */ TinyColor.prototype.toHex = function(allow3Char) { return void 0 === allow3Char && (allow3Char = !1), rgbToHex(this.r, this.g, this.b, allow3Char); }, /** * Returns the hex value of the color -with a # appened. * @param allow3Char will shorten hex value to 3 char if possible */ TinyColor.prototype.toHexString = function(allow3Char) { return void 0 === allow3Char && (allow3Char = !1), "#" + this.toHex(allow3Char); }, /** * Returns the hex 8 value of the color. * @param allow4Char will shorten hex value to 4 char if possible */ TinyColor.prototype.toHex8 = function(allow4Char) { var r, g, b, a, allow4Char1, hex; return void 0 === allow4Char && (allow4Char = !1), r = this.r, g = this.g, b = this.b, a = this.a, allow4Char1 = allow4Char, hex = [ util_pad2(Math.round(r).toString(16)), util_pad2(Math.round(g).toString(16)), util_pad2(Math.round(b).toString(16)), util_pad2(Math.round(255 * parseFloat(a)).toString(16)) ], // Return a 4 character hex if possible allow4Char1 && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1)) ? hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0) : hex.join(""); }, /** * Returns the hex 8 value of the color -with a # appened. * @param allow4Char will shorten hex value to 4 char if possible */ TinyColor.prototype.toHex8String = function(allow4Char) { return void 0 === allow4Char && (allow4Char = !1), "#" + this.toHex8(allow4Char); }, /** * Returns the object as a RGBA object. */ TinyColor.prototype.toRgb = function() { return { r: Math.round(this.r), g: Math.round(this.g), b: Math.round(this.b), a: this.a }; }, /** * Returns the RGBA values interpolated into a string with the following format: * "RGBA(xxx, xxx, xxx, xx)". */ TinyColor.prototype.toRgbString = function() { var r = Math.round(this.r), g = Math.round(this.g), b = Math.round(this.b); return 1 === this.a ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")"); }, /** * Returns the object as a RGBA object. */ TinyColor.prototype.toPercentageRgb = function() { var fmt = function(x) { return "".concat(Math.round(100 * bound01(x, 255)), "%"); }; return { r: fmt(this.r), g: fmt(this.g), b: fmt(this.b), a: this.a }; }, /** * Returns the RGBA relative values interpolated into a string */ TinyColor.prototype.toPercentageRgbString = function() { var rnd = function(x) { return Math.round(100 * bound01(x, 255)); }; return 1 === this.a ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)") : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")"); }, /** * The 'real' name of the color -if there is one. */ TinyColor.prototype.toName = function() { if (0 === this.a) return "transparent"; if (this.a < 1) return !1; for(var hex = "#" + rgbToHex(this.r, this.g, this.b, !1), _i = 0, _a = Object.entries(names); _i < _a.length; _i++){ var _b = _a[_i], key = _b[0]; if (hex === _b[1]) return key; } return !1; }, TinyColor.prototype.toString = function(format) { var formatSet = !!format; format = null != format ? format : this.format; var formattedString = !1, hasAlpha = this.a < 1 && this.a >= 0; return !formatSet && hasAlpha && (format.startsWith("hex") || "name" === format) ? // Special case for "transparent", all other non-alpha formats // will return rgba when there is transparency. "name" === format && 0 === this.a ? this.toName() : this.toRgbString() : ("rgb" === format && (formattedString = this.toRgbString()), "prgb" === format && (formattedString = this.toPercentageRgbString()), ("hex" === format || "hex6" === format) && (formattedString = this.toHexString()), "hex3" === format && (formattedString = this.toHexString(!0)), "hex4" === format && (formattedString = this.toHex8String(!0)), "hex8" === format && (formattedString = this.toHex8String()), "name" === format && (formattedString = this.toName()), "hsl" === format && (formattedString = this.toHslString()), "hsv" === format && (formattedString = this.toHsvString()), formattedString || this.toHexString()); }, TinyColor.prototype.toNumber = function() { return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b); }, TinyColor.prototype.clone = function() { return new TinyColor(this.toString()); }, /** * Lighten the color a given amount. Providing 100 will always return white. * @param amount - valid between 1-100 */ TinyColor.prototype.lighten = function(amount) { void 0 === amount && (amount = 10); var hsl = this.toHsl(); return hsl.l += amount / 100, hsl.l = clamp01(hsl.l), new TinyColor(hsl); }, /** * Brighten the color a given amount, from 0 to 100. * @param amount - valid between 1-100 */ TinyColor.prototype.brighten = function(amount) { void 0 === amount && (amount = 10); var rgb = this.toRgb(); return rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(-(amount / 100 * 255)))), rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(-(amount / 100 * 255)))), rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(-(amount / 100 * 255)))), new TinyColor(rgb); }, /** * Darken the color a given amount, from 0 to 100. * Providing 100 will always return black. * @param amount - valid between 1-100 */ TinyColor.prototype.darken = function(amount) { void 0 === amount && (amount = 10); var hsl = this.toHsl(); return hsl.l -= amount / 100, hsl.l = clamp01(hsl.l), new TinyColor(hsl); }, /** * Mix the color with pure white, from 0 to 100. * Providing 0 will do nothing, providing 100 will always return white. * @param amount - valid between 1-100 */ TinyColor.prototype.tint = function(amount) { return void 0 === amount && (amount = 10), this.mix("white", amount); }, /** * Mix the color with pure black, from 0 to 100. * Providing 0 will do nothing, providing 100 will always return black. * @param amount - valid between 1-100 */ TinyColor.prototype.shade = function(amount) { return void 0 === amount && (amount = 10), this.mix("black", amount); }, /** * Desaturate the color a given amount, from 0 to 100. * Providing 100 will is the same as calling greyscale * @param amount - valid between 1-100 */ TinyColor.prototype.desaturate = function(amount) { void 0 === amount && (amount = 10); var hsl = this.toHsl(); return hsl.s -= amount / 100, hsl.s = clamp01(hsl.s), new TinyColor(hsl); }, /** * Saturate the color a given amount, from 0 to 100. * @param amount - valid between 1-100 */ TinyColor.prototype.saturate = function(amount) { void 0 === amount && (amount = 10); var hsl = this.toHsl(); return hsl.s += amount / 100, hsl.s = clamp01(hsl.s), new TinyColor(hsl); }, /** * Completely desaturates a color into greyscale. * Same as calling `desaturate(100)` */ TinyColor.prototype.greyscale = function() { return this.desaturate(100); }, /** * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. * Values outside of this range will be wrapped into this range. */ TinyColor.prototype.spin = function(amount) { var hsl = this.toHsl(), hue = (hsl.h + amount) % 360; return hsl.h = hue < 0 ? 360 + hue : hue, new TinyColor(hsl); }, /** * Mix the current color a given amount with another color, from 0 to 100. * 0 means no mixing (return current color). */ TinyColor.prototype.mix = function(color, amount) { void 0 === amount && (amount = 50); var rgb1 = this.toRgb(), rgb2 = new TinyColor(color).toRgb(), p = amount / 100; return new TinyColor({ r: (rgb2.r - rgb1.r) * p + rgb1.r, g: (rgb2.g - rgb1.g) * p + rgb1.g, b: (rgb2.b - rgb1.b) * p + rgb1.b, a: (rgb2.a - rgb1.a) * p + rgb1.a }); }, TinyColor.prototype.analogous = function(results, slices) { void 0 === results && (results = 6), void 0 === slices && (slices = 30); var hsl = this.toHsl(), part = 360 / slices, ret = [ this ]; for(hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;)hsl.h = (hsl.h + part) % 360, ret.push(new TinyColor(hsl)); return ret; }, /** * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js */ TinyColor.prototype.complement = function() { var hsl = this.toHsl(); return hsl.h = (hsl.h + 180) % 360, new TinyColor(hsl); }, TinyColor.prototype.monochromatic = function(results) { void 0 === results && (results = 6); for(var hsv = this.toHsv(), h = hsv.h, s = hsv.s, v = hsv.v, res = [], modification = 1 / results; results--;)res.push(new TinyColor({ h: h, s: s, v: v })), v = (v + modification) % 1; return res; }, TinyColor.prototype.splitcomplement = function() { var hsl = this.toHsl(), h = hsl.h; return [ this, new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }), new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }) ]; }, /** * Compute how the color would appear on a background */ TinyColor.prototype.onBackground = function(background) { var fg = this.toRgb(), bg = new TinyColor(background).toRgb(); return new TinyColor({ r: bg.r + (fg.r - bg.r) * fg.a, g: bg.g + (fg.g - bg.g) * fg.a, b: bg.b + (fg.b - bg.b) * fg.a }); }, /** * Alias for `polyad(3)` */ TinyColor.prototype.triad = function() { return this.polyad(3); }, /** * Alias for `polyad(4)` */ TinyColor.prototype.tetrad = function() { return this.polyad(4); }, /** * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...) * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc... */ TinyColor.prototype.polyad = function(n) { for(var hsl = this.toHsl(), h = hsl.h, result = [ this ], increment = 360 / n, i = 1; i < n; i++)result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l })); return result; }, /** * compare color vs current color */ TinyColor.prototype.equals = function(color) { return this.toRgbString() === new TinyColor(color).toRgbString(); }, TinyColor; }(); function getColorInfo(hue) { // Maps red colors to make picking hue easier hue >= 334 && hue <= 360 && (hue -= 360); for(var _i = 0; _i < bounds.length; _i++){ var color = defineColor(bounds[_i]); if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) return color; } throw Error("Color not found"); } function randomWithin(range, seed) { if (void 0 === seed) return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0])); // Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/ var max = range[1] || 1, min = range[0] || 0; return Math.floor(min + (seed = (9301 * seed + 49297) % 233280) / 233280.0 * (max - min)); } function defineColor(bound) { var sMin = bound.lowerBounds[0][0], sMax = bound.lowerBounds[bound.lowerBounds.length - 1][0], bMin = bound.lowerBounds[bound.lowerBounds.length - 1][1], bMax = bound.lowerBounds[0][1]; return { name: bound.name, hueRange: bound.hueRange, lowerBounds: bound.lowerBounds, saturationRange: [ sMin, sMax ], brightnessRange: [ bMin, bMax ] }; } /** * @hidden */ var bounds = [ { name: "monochrome", hueRange: null, lowerBounds: [ [ 0, 0 ], [ 100, 0 ] ] }, { name: "red", hueRange: [ -26, 18 ], lowerBounds: [ [ 20, 100 ], [ 30, 92 ], [ 40, 89 ], [ 50, 85 ], [ 60, 78 ], [ 70, 70 ], [ 80, 60 ], [ 90, 55 ], [ 100, 50 ] ] }, { name: "orange", hueRange: [ 19, 46 ], lowerBounds: [ [ 20, 100 ], [ 30, 93 ], [ 40, 88 ], [ 50, 86 ], [ 60, 85 ], [ 70, 70 ], [ 100, 70 ] ] }, { name: "yellow", hueRange: [ 47, 62 ], lowerBounds: [ [ 25, 100 ], [ 40, 94 ], [ 50, 89 ], [ 60, 86 ], [ 70, 84 ], [ 80, 82 ], [ 90, 80 ], [ 100, 75 ] ] }, { name: "green", hueRange: [ 63, 178 ], lowerBounds: [ [ 30, 100 ], [ 40, 90 ], [ 50, 85 ], [ 60, 81 ], [ 70, 74 ], [ 80, 64 ], [ 90, 50 ], [ 100, 40 ] ] }, { name: "blue", hueRange: [ 179, 257 ], lowerBounds: [ [ 20, 100 ], [ 30, 86 ], [ 40, 80 ], [ 50, 74 ], [ 60, 60 ], [ 70, 52 ], [ 80, 44 ], [ 90, 39 ], [ 100, 35 ] ] }, { name: "purple", hueRange: [ 258, 282 ], lowerBounds: [ [ 20, 100 ], [ 30, 87 ], [ 40, 79 ], [ 50, 70 ], [ 60, 65 ], [ 70, 59 ], [ 80, 52 ], [ 90, 45 ], [ 100, 42 ] ] }, { name: "pink", hueRange: [ 283, 334 ], lowerBounds: [ [ 20, 100 ], [ 30, 90 ], [ 40, 86 ], [ 60, 84 ], [ 80, 80 ], [ 90, 75 ], [ 100, 73 ] ] } ], getColor = function(theme, color, fallback) { var hex = (0, chakra_ui_utils_esm /* memoizedGet */ .Wf)(theme, "colors." + color, color); return new module_TinyColor(hex).isValid ? hex : fallback; }, transparentize = function(color, opacity) { return function(theme) { return new module_TinyColor(getColor(theme, color)).setAlpha(opacity).toRgbString(); }; }; // CONCATENATED MODULE: ./node_modules/@chakra-ui/theme-tools/dist/chakra-ui-theme-tools.esm.js function generateStripe(size, color) { return void 0 === size && (size = "1rem"), void 0 === color && (color = "rgba(255, 255, 255, 0.15)"), { backgroundImage: "linear-gradient(\n 45deg,\n " + color + " 25%,\n transparent 25%,\n transparent 50%,\n " + color + " 50%,\n " + color + " 75%,\n transparent 75%,\n transparent\n )", backgroundSize: size + " " + size }; } function mode(light, dark) { return function(props) { return "dark" === props.colorMode ? dark : light; }; } function orient(options) { var orientation = options.orientation, vertical = options.vertical, horizontal = options.horizontal; return orientation ? "vertical" === orientation ? vertical : horizontal : {}; } function chakra_ui_theme_tools_esm_extends() { return (chakra_ui_theme_tools_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } /** * Used to define the anatomy/parts of a component in a way that provides * a consistent API for `className`, css selector and `theming`. */ var Anatomy = /*#__PURE__*/ function() { var protoProps; function Anatomy(name) { var _this = this; this.map = {}, this.called = !1, this.assert = function() { if (!_this.called) { _this.called = !0; return; } throw Error("[anatomy] .part(...) should only be called once. Did you mean to use .extend(...) ?"); }, this.parts = function() { _this.assert(); for(var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++)values[_key] = arguments[_key]; for(var _i = 0; _i < values.length; _i++){ var part = values[_i]; _this.map[part] = _this.toPart(part); } return _this; }, this.extend = function() { for(var _len2 = arguments.length, parts = Array(_len2), _key2 = 0; _key2 < _len2; _key2++)parts[_key2] = arguments[_key2]; for(var _i2 = 0; _i2 < parts.length; _i2++){ var part = parts[_i2]; part in _this.map || (_this.map[part] = _this.toPart(part)); } return _this; }, this.toPart = function(part) { var className = "chakra-" + ([ "container", "root" ].includes(null != part ? part : "") ? [ _this.name ] : [ _this.name, part ]).filter(Boolean).join("__"); return { className: className, selector: "." + className, toString: function() { return part; } }; }, this.__type = {}; } return protoProps = [ { key: "selectors", get: /** * Get all selectors for the component anatomy */ function() { return (0, chakra_ui_utils_esm /* fromEntries */ .sq)(Object.entries(this.map).map(function(_ref) { return [ _ref[0], _ref[1].selector ]; })); } }, { key: "classNames", get: function() { return (0, chakra_ui_utils_esm /* fromEntries */ .sq)(Object.entries(this.map).map(function(_ref2) { return [ _ref2[0], _ref2[1].className ]; })); } }, { key: "keys", get: function() { return Object.keys(this.map); } } ], function(target, props) { for(var i = 0; i < props.length; i++){ var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } }(Anatomy.prototype, protoProps), Object.defineProperty(Anatomy, "prototype", { writable: !1 }), Anatomy; }(); function anatomy(name) { return new Anatomy(name); } function toRef(operand) { return (0, chakra_ui_utils_esm /* isObject */ .Kn)(operand) && operand.reference ? operand.reference : String(operand); } var toExpr = function(operator) { for(var _len = arguments.length, operands = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)operands[_key - 1] = arguments[_key]; return operands.map(toRef).join(" " + operator + " ").replace(/calc/g, ""); }, _add = function() { for(var _len2 = arguments.length, operands = Array(_len2), _key2 = 0; _key2 < _len2; _key2++)operands[_key2] = arguments[_key2]; return "calc(" + toExpr.apply(void 0, [ "+" ].concat(operands)) + ")"; }, _subtract = function() { for(var _len3 = arguments.length, operands = Array(_len3), _key3 = 0; _key3 < _len3; _key3++)operands[_key3] = arguments[_key3]; return "calc(" + toExpr.apply(void 0, [ "-" ].concat(operands)) + ")"; }, _multiply = function() { for(var _len4 = arguments.length, operands = Array(_len4), _key4 = 0; _key4 < _len4; _key4++)operands[_key4] = arguments[_key4]; return "calc(" + toExpr.apply(void 0, [ "*" ].concat(operands)) + ")"; }, _divide = function() { for(var _len5 = arguments.length, operands = Array(_len5), _key5 = 0; _key5 < _len5; _key5++)operands[_key5] = arguments[_key5]; return "calc(" + toExpr.apply(void 0, [ "/" ].concat(operands)) + ")"; }, _negate = function(x) { var value = toRef(x); return null == value || Number.isNaN(parseFloat(value)) ? _multiply(value, -1) : String(value).startsWith("-") ? String(value).slice(1) : "-" + value; }, calc = Object.assign(function(x) { return { add: function() { for(var _len6 = arguments.length, operands = Array(_len6), _key6 = 0; _key6 < _len6; _key6++)operands[_key6] = arguments[_key6]; return calc(_add.apply(void 0, [ x ].concat(operands))); }, subtract: function() { for(var _len7 = arguments.length, operands = Array(_len7), _key7 = 0; _key7 < _len7; _key7++)operands[_key7] = arguments[_key7]; return calc(_subtract.apply(void 0, [ x ].concat(operands))); }, multiply: function() { for(var _len8 = arguments.length, operands = Array(_len8), _key8 = 0; _key8 < _len8; _key8++)operands[_key8] = arguments[_key8]; return calc(_multiply.apply(void 0, [ x ].concat(operands))); }, divide: function() { for(var _len9 = arguments.length, operands = Array(_len9), _key9 = 0; _key9 < _len9; _key9++)operands[_key9] = arguments[_key9]; return calc(_divide.apply(void 0, [ x ].concat(operands))); }, negate: function() { return calc(_negate(x)); }, toString: function() { return x.toString(); } }; }, { add: _add, subtract: _subtract, multiply: _multiply, divide: _divide, negate: _negate }); function chakra_ui_theme_tools_esm_escape(value) { var value1, replaceValue, valueStr = (value1 = value.toString(), void 0 === replaceValue && (replaceValue = "-"), value1.replace(/\s+/g, replaceValue)); return valueStr.includes("\\.") ? value : Number.isInteger(parseFloat(value.toString())) ? value : valueStr.replace(".", "\\."); } function cssVar(name, options) { var fallback, prefix, prefix1, fallback1, cssVariable = (void 0 === (prefix = null == options ? void 0 : options.prefix) && (prefix = ""), "--" + (void 0 === (prefix1 = prefix) && (prefix1 = ""), [ prefix1, chakra_ui_theme_tools_esm_escape(name) ].filter(Boolean).join("-"))); return { variable: cssVariable, reference: (fallback1 = "string" == typeof (fallback = null == options ? void 0 : options.fallback) ? fallback : null == fallback ? void 0 : fallback.reference, "var(" + chakra_ui_theme_tools_esm_escape(cssVariable) + (fallback1 ? ", " + fallback1 : "") + ")") }; } /** * **Accordion anatomy** * - Root: the root container of the accordion * - Container: the accordion item contains the button and panel * - Button: the button is the trigger for the panel * - Panel: the panel is the content of the accordion item * - Icon: the expanded/collapsed icon */ var accordionAnatomy = anatomy("accordion").parts("root", "container", "button", "panel").extend("icon"), alertAnatomy = anatomy("alert").parts("title", "description", "container").extend("icon", "spinner"), avatarAnatomy = anatomy("avatar").parts("label", "badge", "container").extend("excessLabel", "group"), breadcrumbAnatomy = anatomy("breadcrumb").parts("link", "item", "container").extend("separator"); anatomy("button").parts(); var checkboxAnatomy = anatomy("checkbox").parts("control", "icon", "container").extend("label"); anatomy("progress").parts("track", "filledTrack").extend("label"); var drawerAnatomy = anatomy("drawer").parts("overlay", "dialogContainer", "dialog").extend("header", "closeButton", "body", "footer"), editableAnatomy = anatomy("editable").parts("preview", "input", "textarea"), formAnatomy = anatomy("form").parts("container", "requiredIndicator", "helperText"), formErrorAnatomy = anatomy("formError").parts("text", "icon"), inputAnatomy = anatomy("input").parts("addon", "field", "element"), listAnatomy = anatomy("list").parts("container", "item", "icon"), menuAnatomy = anatomy("menu").parts("button", "list", "item").extend("groupTitle", "command", "divider"), modalAnatomy = anatomy("modal").parts("overlay", "dialogContainer", "dialog").extend("header", "closeButton", "body", "footer"), numberInputAnatomy = anatomy("numberinput").parts("root", "field", "stepperGroup", "stepper"); anatomy("pininput").parts("field"); var popoverAnatomy = anatomy("popover").parts("content", "header", "body", "footer").extend("popper", "arrow", "closeButton"), progressAnatomy = anatomy("progress").parts("label", "filledTrack", "track"), radioAnatomy = anatomy("radio").parts("container", "control", "label"), selectAnatomy = anatomy("select").parts("field", "icon"), sliderAnatomy = anatomy("slider").parts("container", "track", "thumb", "filledTrack"), statAnatomy = anatomy("stat").parts("container", "label", "helpText", "number", "icon"), switchAnatomy = anatomy("switch").parts("container", "track", "thumb"), tableAnatomy = anatomy("table").parts("table", "thead", "tbody", "tr", "th", "td", "tfoot", "caption"), tabsAnatomy = anatomy("tabs").parts("root", "tab", "tablist", "tabpanel", "tabpanels", "indicator"), tagAnatomy = anatomy("tag").parts("container", "label", "closeButton"), typography = { letterSpacings: { tighter: "-0.05em", tight: "-0.025em", normal: "0", wide: "0.025em", wider: "0.05em", widest: "0.1em" }, lineHeights: { normal: "normal", none: 1, shorter: 1.25, short: 1.375, base: 1.5, tall: 1.625, taller: "2", 3: ".75rem", 4: "1rem", 5: "1.25rem", 6: "1.5rem", 7: "1.75rem", 8: "2rem", 9: "2.25rem", 10: "2.5rem" }, fontWeights: { hairline: 100, thin: 200, light: 300, normal: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900 }, fonts: { heading: '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"', body: '-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"', mono: 'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace' }, fontSizes: { xs: "0.75rem", sm: "0.875rem", md: "1rem", lg: "1.125rem", xl: "1.25rem", "2xl": "1.5rem", "3xl": "1.875rem", "4xl": "2.25rem", "5xl": "3rem", "6xl": "3.75rem", "7xl": "4.5rem", "8xl": "6rem", "9xl": "8rem" } }, lodash_mergewith = __webpack_require__(8554), lodash_mergewith_default = /*#__PURE__*/ __webpack_require__.n(lodash_mergewith), Accordion = { parts: accordionAnatomy.keys, baseStyle: { root: {}, container: { borderTopWidth: "1px", borderColor: "inherit", _last: { borderBottomWidth: "1px" } }, button: { transitionProperty: "common", transitionDuration: "normal", fontSize: "1rem", _focusVisible: { boxShadow: "outline" }, _hover: { bg: "blackAlpha.50" }, _disabled: { opacity: 0.4, cursor: "not-allowed" }, px: 4, py: 2 }, panel: { pt: 2, px: 4, pb: 5 }, icon: { fontSize: "1.25em" } } }; function getBg(props) { var theme = props.theme, c = props.colorScheme; return mode(getColor(theme, c + ".100", c), transparentize(c + ".200", 0.16)(theme))(props); } var Alert = { parts: alertAnatomy.keys, baseStyle: { container: { px: 4, py: 3 }, title: { fontWeight: "bold", lineHeight: 6, marginEnd: 2 }, description: { lineHeight: 6 }, icon: { flexShrink: 0, marginEnd: 3, w: 5, h: 6 }, spinner: { flexShrink: 0, marginEnd: 3, w: 5, h: 5 } }, variants: { subtle: function(props) { var c = props.colorScheme; return { container: { bg: getBg(props) }, icon: { color: mode(c + ".500", c + ".200")(props) }, spinner: { color: mode(c + ".500", c + ".200")(props) } }; }, "left-accent": function(props) { var c = props.colorScheme; return { container: { paddingStart: 3, borderStartWidth: "4px", borderStartColor: mode(c + ".500", c + ".200")(props), bg: getBg(props) }, icon: { color: mode(c + ".500", c + ".200")(props) }, spinner: { color: mode(c + ".500", c + ".200")(props) } }; }, "top-accent": function(props) { var c = props.colorScheme; return { container: { pt: 2, borderTopWidth: "4px", borderTopColor: mode(c + ".500", c + ".200")(props), bg: getBg(props) }, icon: { color: mode(c + ".500", c + ".200")(props) }, spinner: { color: mode(c + ".500", c + ".200")(props) } }; }, solid: function(props) { var c = props.colorScheme; return { container: { bg: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props) } }; } }, defaultProps: { variant: "subtle", colorScheme: "blue" } }, baseStyleContainer$3 = function(props) { var list, opts, fallback, name = props.name, theme = props.theme, bg = name ? (opts = { string: name }, fallback = // randomColor by David Merfield under the CC0 license // https://github.com/davidmerfield/randomColor/ (function random(options) { // Check if we need to generate multiple colors if (void 0 === options && (options = {}), void 0 !== options.count && null !== options.count) { var hue, seed, res, totalColors = options.count, colors = []; for(options.count = void 0; totalColors > colors.length;)// Since we're generating multiple colors, // incremement the seed. Otherwise we'd just // generate the same color each time... options.count = null, options.seed && (options.seed += 1), colors.push(random(options)); return options.count = totalColors, colors; } // First we pick a hue (H) var h = (hue = options.hue, seed = options.seed, (res = randomWithin(function(colorInput) { var num = parseInt(colorInput, 10); if (!Number.isNaN(num) && num < 360 && num > 0) return [ num, num ]; if ("string" == typeof colorInput) { var namedColor = bounds.find(function(n) { return n.name === colorInput; }); if (namedColor) { var color = defineColor(namedColor); if (color.hueRange) return color.hueRange; } var parsed = new module_TinyColor(colorInput); if (parsed.isValid) { var hue = parsed.toHsv().h; return [ hue, hue ]; } } return [ 0, 360 ]; }(hue), seed)) < 0 && (res = 360 + res), res), s = function(hue, options) { if ("monochrome" === options.hue) return 0; if ("random" === options.luminosity) return randomWithin([ 0, 100 ], options.seed); var saturationRange = getColorInfo(hue).saturationRange, sMin = saturationRange[0], sMax = saturationRange[1]; switch(options.luminosity){ case "bright": sMin = 55; break; case "dark": sMin = sMax - 10; break; case "light": sMax = 55; } return randomWithin([ sMin, sMax ], options.seed); }(h, options), v = function(H, S, options) { var bMin = function(H, S) { for(var lowerBounds = getColorInfo(H).lowerBounds, i = 0; i < lowerBounds.length - 1; i++){ var s1 = lowerBounds[i][0], v1 = lowerBounds[i][1], s2 = lowerBounds[i + 1][0], v2 = lowerBounds[i + 1][1]; if (S >= s1 && S <= s2) { var m = (v2 - v1) / (s2 - s1), b = v1 - m * s1; return m * S + b; } } return 0; }(H, S), bMax = 100; switch(options.luminosity){ case "dark": bMax = bMin + 20; break; case "light": bMin = (bMax + bMin) / 2; break; case "random": bMin = 0, bMax = 100; } return randomWithin([ bMin, bMax ], options.seed); }(h, s, options), res1 = { h: h, s: s, v: v }; // Then we return the HSB color in the desired format return void 0 !== options.alpha && (res1.a = options.alpha), new module_TinyColor(res1); })().toHexString(), !opts || (0, chakra_ui_utils_esm /* isEmptyObject */ .Qr)(opts) ? fallback : opts.string && opts.colors ? function(str, list) { var index = 0; if (0 === str.length) return list[0]; for(var i = 0; i < str.length; i += 1)index = str.charCodeAt(i) + ((index << 5) - index), index &= index; return index = (index % list.length + list.length) % list.length, list[index]; }(opts.string, opts.colors) : opts.string && !opts.colors ? function(str) { var hash = 0; if (0 === str.length) return hash.toString(); for(var i = 0; i < str.length; i += 1)hash = str.charCodeAt(i) + ((hash << 5) - hash), hash &= hash; for(var color = "#", j = 0; j < 3; j += 1)color += ("00" + (hash >> 8 * j & 255).toString(16)).substr(-2); return color; }(opts.string) : opts.colors && !opts.string ? (list = opts.colors)[Math.floor(Math.random() * list.length)] : fallback) : "gray.400", isBgDark = "dark" == (new module_TinyColor(getColor(theme, bg)).isDark() ? "dark" : "light"), color = "white"; return isBgDark || (color = "gray.800"), { bg: bg, color: color, borderColor: mode("white", "gray.800")(props), verticalAlign: "top" }; }; function getSize$3(size) { var themeSize = "100%" !== size ? sizes[size] : void 0; return { container: { width: size, height: size, fontSize: "calc(" + (null != themeSize ? themeSize : size) + " / 2.5)" }, excessLabel: { width: size, height: size }, label: { fontSize: "calc(" + (null != themeSize ? themeSize : size) + " / 2.5)", lineHeight: "100%" !== size ? null != themeSize ? themeSize : size : void 0 } }; } var sizes$k = { "2xs": getSize$3(4), xs: getSize$3(6), sm: getSize$3(8), md: getSize$3(12), lg: getSize$3(16), xl: getSize$3(24), "2xl": getSize$3(32), full: getSize$3("100%") }, Avatar = { parts: avatarAnatomy.keys, baseStyle: function(props) { return { badge: { transform: "translate(25%, 25%)", borderRadius: "full", border: "0.2em solid", borderColor: mode("white", "gray.800")(props) }, excessLabel: { bg: mode("gray.200", "whiteAlpha.400")(props) }, container: baseStyleContainer$3(props) }; }, sizes: sizes$k, defaultProps: { size: "md" } }, Badge = { baseStyle: { px: 1, textTransform: "uppercase", fontSize: "xs", borderRadius: "sm", fontWeight: "bold" }, variants: { solid: function(props) { var c = props.colorScheme, theme = props.theme, dark = transparentize(c + ".500", 0.6)(theme); return { bg: mode(c + ".500", dark)(props), color: mode("white", "whiteAlpha.800")(props) }; }, subtle: function(props) { var c = props.colorScheme, theme = props.theme, darkBg = transparentize(c + ".200", 0.16)(theme); return { bg: mode(c + ".100", darkBg)(props), color: mode(c + ".800", c + ".200")(props) }; }, outline: function(props) { var c = props.colorScheme, theme = props.theme, darkColor = transparentize(c + ".200", 0.8)(theme), color = mode(getColor(theme, c + ".500"), darkColor)(props); return { color: color, boxShadow: "inset 0 0 0px 1px " + color }; } }, defaultProps: { variant: "subtle", colorScheme: "gray" } }, Breadcrumb = { parts: breadcrumbAnatomy.keys, baseStyle: { link: { transitionProperty: "common", transitionDuration: "fast", transitionTimingFunction: "ease-out", cursor: "pointer", textDecoration: "none", outline: "none", color: "inherit", _hover: { textDecoration: "underline" }, _focusVisible: { boxShadow: "outline" } } } }, variantGhost = function(props) { var c = props.colorScheme, theme = props.theme; if ("gray" === c) return { color: mode("inherit", "whiteAlpha.900")(props), _hover: { bg: mode("gray.100", "whiteAlpha.200")(props) }, _active: { bg: mode("gray.200", "whiteAlpha.300")(props) } }; var darkHoverBg = transparentize(c + ".200", 0.12)(theme), darkActiveBg = transparentize(c + ".200", 0.24)(theme); return { color: mode(c + ".600", c + ".200")(props), bg: "transparent", _hover: { bg: mode(c + ".50", darkHoverBg)(props) }, _active: { bg: mode(c + ".100", darkActiveBg)(props) } }; }, accessibleColorMap = { yellow: { bg: "yellow.400", color: "black", hoverBg: "yellow.500", activeBg: "yellow.600" }, cyan: { bg: "cyan.400", color: "black", hoverBg: "cyan.500", activeBg: "cyan.600" } }, baseStyleControl$1 = function(props) { var c = props.colorScheme; return { w: "100%", transitionProperty: "box-shadow", transitionDuration: "normal", border: "2px solid", borderRadius: "sm", borderColor: "inherit", color: "white", _checked: { bg: mode(c + ".500", c + ".200")(props), borderColor: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props), _hover: { bg: mode(c + ".600", c + ".300")(props), borderColor: mode(c + ".600", c + ".300")(props) }, _disabled: { borderColor: mode("gray.200", "transparent")(props), bg: mode("gray.200", "whiteAlpha.300")(props), color: mode("gray.500", "whiteAlpha.500")(props) } }, _indeterminate: { bg: mode(c + ".500", c + ".200")(props), borderColor: mode(c + ".500", c + ".200")(props), color: mode("white", "gray.900")(props) }, _disabled: { bg: mode("gray.100", "whiteAlpha.100")(props), borderColor: mode("gray.100", "transparent")(props) }, _focusVisible: { boxShadow: "outline" }, _invalid: { borderColor: mode("red.500", "red.300")(props) } }; }, baseStyleContainer$2 = { _disabled: { cursor: "not-allowed" } }, baseStyleLabel$3 = { userSelect: "none", _disabled: { opacity: 0.4 } }, baseStyleIcon$4 = { transitionProperty: "transform", transitionDuration: "normal" }, Checkbox = { parts: checkboxAnatomy.keys, baseStyle: function(props) { return { icon: baseStyleIcon$4, container: baseStyleContainer$2, control: baseStyleControl$1(props), label: baseStyleLabel$3 }; }, sizes: { sm: { control: { h: 3, w: 3 }, label: { fontSize: "sm" }, icon: { fontSize: "0.45rem" } }, md: { control: { w: 4, h: 4 }, label: { fontSize: "md" }, icon: { fontSize: "0.625rem" } }, lg: { control: { w: 5, h: 5 }, label: { fontSize: "lg" }, icon: { fontSize: "0.625rem" } } }, defaultProps: { size: "md", colorScheme: "blue" } }, $size$1 = cssVar("close-button-size"), sizes$h = { lg: ((_lg$1 = {})[$size$1.variable] = "40px", _lg$1.fontSize = "16px", _lg$1), md: ((_md$1 = {})[$size$1.variable] = "32px", _md$1.fontSize = "12px", _md$1), sm: ((_sm$1 = {})[$size$1.variable] = "24px", _sm$1.fontSize = "10px", _sm$1) }, variants$8 = Badge.variants, defaultProps$h = Badge.defaultProps; /** * Since the `maxWidth` prop references theme.sizes internally, * we can leverage that to size our modals. */ function getSize$2(value) { return "full" === value ? { dialog: { maxW: "100vw", h: "100vh" } } : { dialog: { maxW: value } }; } var baseStyleOverlay$1 = { bg: "blackAlpha.600", zIndex: "overlay" }, baseStyleDialogContainer$1 = { display: "flex", zIndex: "modal", justifyContent: "center" }, baseStyleDialog$1 = function(props) { var isFullHeight = props.isFullHeight; return sizes_501602a9_esm_extends({}, isFullHeight && { height: "100vh" }, { zIndex: "modal", maxH: "100vh", bg: mode("white", "gray.700")(props), color: "inherit", boxShadow: mode("lg", "dark-lg")(props) }); }, baseStyleHeader$2 = { px: 6, py: 4, fontSize: "xl", fontWeight: "semibold" }, baseStyleCloseButton$3 = { position: "absolute", top: 2, insetEnd: 3 }, baseStyleBody$2 = { px: 6, py: 2, flex: 1, overflow: "auto" }, baseStyleFooter$2 = { px: 6, py: 4 }, sizes$g = { xs: getSize$2("xs"), sm: getSize$2("md"), md: getSize$2("lg"), lg: getSize$2("2xl"), xl: getSize$2("4xl"), full: getSize$2("full") }, Drawer = { parts: drawerAnatomy.keys, baseStyle: function(props) { return { overlay: baseStyleOverlay$1, dialogContainer: baseStyleDialogContainer$1, dialog: baseStyleDialog$1(props), header: baseStyleHeader$2, closeButton: baseStyleCloseButton$3, body: baseStyleBody$2, footer: baseStyleFooter$2 }; }, sizes: sizes$g, defaultProps: { size: "xs" } }, Editable = { parts: editableAnatomy.keys, baseStyle: { preview: { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal" }, input: { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal", width: "full", _focusVisible: { boxShadow: "outline" }, _placeholder: { opacity: 0.6 } }, textarea: { borderRadius: "md", py: "3px", transitionProperty: "common", transitionDuration: "normal", width: "full", _focusVisible: { boxShadow: "outline" }, _placeholder: { opacity: 0.6 } } } }, Form = { parts: formAnatomy.keys, baseStyle: function(props) { return { container: { width: "100%", position: "relative" }, requiredIndicator: { marginStart: 1, color: mode("red.500", "red.300")(props) }, helperText: { mt: 2, color: mode("gray.500", "whiteAlpha.600")(props), lineHeight: "normal", fontSize: "sm" } }; } }, FormError = { parts: formErrorAnatomy.keys, baseStyle: function(props) { return { text: { color: mode("red.500", "red.300")(props), mt: 2, fontSize: "sm", lineHeight: "normal" }, icon: { marginEnd: "0.5em", color: mode("red.500", "red.300")(props) } }; } }, size_lg = { fontSize: "lg", px: 4, h: 12, borderRadius: "md" }, size_md = { fontSize: "md", px: 4, h: 10, borderRadius: "md" }, size_sm = { fontSize: "sm", px: 3, h: 8, borderRadius: "sm" }, size_xs = { fontSize: "xs", px: 2, h: 6, borderRadius: "sm" }; function getDefaults(props) { var fc = props.focusBorderColor, ec = props.errorBorderColor; return { focusBorderColor: fc || mode("blue.500", "blue.300")(props), errorBorderColor: ec || mode("red.500", "red.300")(props) }; } var Input = { parts: inputAnatomy.keys, baseStyle: { field: { width: "100%", minWidth: 0, outline: 0, position: "relative", appearance: "none", transitionProperty: "common", transitionDuration: "normal" } }, sizes: { lg: { field: size_lg, addon: size_lg }, md: { field: size_md, addon: size_md }, sm: { field: size_sm, addon: size_sm }, xs: { field: size_xs, addon: size_xs } }, variants: { outline: function(props) { var theme = props.theme, _getDefaults = getDefaults(props), fc = _getDefaults.focusBorderColor, ec = _getDefaults.errorBorderColor; return { field: { border: "1px solid", borderColor: "inherit", bg: "inherit", _hover: { borderColor: mode("gray.300", "whiteAlpha.400")(props) }, _readOnly: { boxShadow: "none !important", userSelect: "all" }, _disabled: { opacity: 0.4, cursor: "not-allowed" }, _invalid: { borderColor: getColor(theme, ec), boxShadow: "0 0 0 1px " + getColor(theme, ec) }, _focusVisible: { zIndex: 1, borderColor: getColor(theme, fc), boxShadow: "0 0 0 1px " + getColor(theme, fc) } }, addon: { border: "1px solid", borderColor: mode("inherit", "whiteAlpha.50")(props), bg: mode("gray.100", "whiteAlpha.300")(props) } }; }, filled: function(props) { var theme = props.theme, _getDefaults2 = getDefaults(props), fc = _getDefaults2.focusBorderColor, ec = _getDefaults2.errorBorderColor; return { field: { border: "2px solid", borderColor: "transparent", bg: mode("gray.100", "whiteAlpha.50")(props), _hover: { bg: mode("gray.200", "whiteAlpha.100")(props) }, _readOnly: { boxShadow: "none !important", userSelect: "all" }, _disabled: { opacity: 0.4, cursor: "not-allowed" }, _invalid: { borderColor: getColor(theme, ec) }, _focusVisible: { bg: "transparent", borderColor: getColor(theme, fc) } }, addon: { border: "2px solid", borderColor: "transparent", bg: mode("gray.100", "whiteAlpha.50")(props) } }; }, flushed: function(props) { var theme = props.theme, _getDefaults3 = getDefaults(props), fc = _getDefaults3.focusBorderColor, ec = _getDefaults3.errorBorderColor; return { field: { borderBottom: "1px solid", borderColor: "inherit", borderRadius: 0, px: 0, bg: "transparent", _readOnly: { boxShadow: "none !important", userSelect: "all" }, _invalid: { borderColor: getColor(theme, ec), boxShadow: "0px 1px 0px 0px " + getColor(theme, ec) }, _focusVisible: { borderColor: getColor(theme, fc), boxShadow: "0px 1px 0px 0px " + getColor(theme, fc) } }, addon: { borderBottom: "2px solid", borderColor: "inherit", borderRadius: 0, px: 0, bg: "transparent" } }; }, unstyled: { field: { bg: "transparent", px: 0, height: "auto" }, addon: { bg: "transparent", px: 0, height: "auto" } } }, defaultProps: { size: "md", variant: "outline" } }, List = { parts: listAnatomy.keys, baseStyle: { container: {}, item: {}, icon: { marginEnd: "0.5rem", display: "inline", verticalAlign: "text-bottom" } } }, baseStyleGroupTitle = { mx: 4, my: 2, fontWeight: "semibold", fontSize: "sm" }, baseStyleCommand = { opacity: 0.6 }, baseStyleDivider = { border: 0, borderBottom: "1px solid", borderColor: "inherit", my: "0.5rem", opacity: 0.6 }, baseStyleButton = { transitionProperty: "common", transitionDuration: "normal" }, Menu = { parts: menuAnatomy.keys, baseStyle: function(props) { return { button: baseStyleButton, list: { bg: mode("#fff", "gray.700")(props), boxShadow: mode("sm", "dark-lg")(props), color: "inherit", minW: "3xs", py: "2", zIndex: 1, borderRadius: "md", borderWidth: "1px" }, item: { py: "0.4rem", px: "0.8rem", transitionProperty: "background", transitionDuration: "ultra-fast", transitionTimingFunction: "ease-in", _focus: { bg: mode("gray.100", "whiteAlpha.100")(props) }, _active: { bg: mode("gray.200", "whiteAlpha.200")(props) }, _expanded: { bg: mode("gray.100", "whiteAlpha.100")(props) }, _disabled: { opacity: 0.4, cursor: "not-allowed" } }, groupTitle: baseStyleGroupTitle, command: baseStyleCommand, divider: baseStyleDivider }; } }, baseStyleOverlay = { bg: "blackAlpha.600", zIndex: "modal" }, baseStyleDialog = function(props) { var scrollBehavior = props.scrollBehavior; return { borderRadius: "md", bg: mode("white", "gray.700")(props), color: "inherit", my: "3.75rem", zIndex: "modal", maxH: "inside" === scrollBehavior ? "calc(100% - 7.5rem)" : void 0, boxShadow: mode("lg", "dark-lg")(props) }; }, baseStyleHeader$1 = { px: 6, py: 4, fontSize: "xl", fontWeight: "semibold" }, baseStyleCloseButton$2 = { position: "absolute", top: 2, insetEnd: 3 }, baseStyleFooter$1 = { px: 6, py: 4 }; /** * Since the `maxWidth` prop references theme.sizes internally, * we can leverage that to size our modals. */ function getSize$1(value) { return "full" === value ? { dialog: { maxW: "100vw", minH: "100vh", "@supports(min-height: -webkit-fill-available)": { minH: "-webkit-fill-available" }, my: 0 } } : { dialog: { maxW: value } }; } var sizes$d = { xs: getSize$1("xs"), sm: getSize$1("sm"), md: getSize$1("md"), lg: getSize$1("lg"), xl: getSize$1("xl"), "2xl": getSize$1("2xl"), "3xl": getSize$1("3xl"), "4xl": getSize$1("4xl"), "5xl": getSize$1("5xl"), "6xl": getSize$1("6xl"), full: getSize$1("full") }, Modal = { parts: modalAnatomy.keys, baseStyle: function(props) { return { overlay: baseStyleOverlay, dialogContainer: { display: "flex", zIndex: "modal", justifyContent: "center", alignItems: props.isCentered ? "center" : "flex-start", overflow: "inside" === props.scrollBehavior ? "hidden" : "auto" }, dialog: baseStyleDialog(props), header: baseStyleHeader$1, closeButton: baseStyleCloseButton$2, body: { px: 6, py: 2, flex: 1, overflow: "inside" === props.scrollBehavior ? "auto" : void 0 }, footer: baseStyleFooter$1 }; }, sizes: sizes$d, defaultProps: { size: "md" } }, variants$5 = Input.variants, defaultProps$b = Input.defaultProps, $stepperWidth = cssVar("number-input-stepper-width"), $inputPadding = cssVar("number-input-input-padding"), inputPaddingValue = calc($stepperWidth).add("0.5rem").toString(), baseStyleRoot$1 = ((_baseStyleRoot = {})[$stepperWidth.variable] = "24px", _baseStyleRoot[$inputPadding.variable] = inputPaddingValue, _baseStyleRoot), baseStyleField$1 = null != (_Input$baseStyle$fiel = null == (_Input$baseStyle = Input.baseStyle) ? void 0 : _Input$baseStyle.field) ? _Input$baseStyle$fiel : {}, baseStyleStepperGroup = { width: [ $stepperWidth.reference ] }; function getSize(size) { var _sizeStyle$field$font, _sizeStyle$field, sizeStyle = Input.sizes[size], radius = { lg: "md", md: "md", sm: "sm", xs: "sm" }, _fontSize = null != (_sizeStyle$field$font = null == (_sizeStyle$field = sizeStyle.field) ? void 0 : _sizeStyle$field.fontSize) ? _sizeStyle$field$font : "md", fontSize = typography.fontSizes[_fontSize]; return { field: sizes_501602a9_esm_extends({}, sizeStyle.field, { paddingInlineEnd: $inputPadding.reference, verticalAlign: "top" }), stepper: { fontSize: calc(fontSize).multiply(0.75).toString(), _first: { borderTopEndRadius: radius[size] }, _last: { borderBottomEndRadius: radius[size], mt: "-1px", borderTopWidth: 1 } } }; } var sizes$c = { xs: getSize("xs"), sm: getSize("sm"), md: getSize("md"), lg: getSize("lg") }, NumberInput = { parts: numberInputAnatomy.keys, baseStyle: function(props) { return { root: baseStyleRoot$1, field: baseStyleField$1, stepperGroup: baseStyleStepperGroup, stepper: { borderStart: "1px solid", borderStartColor: mode("inherit", "whiteAlpha.300")(props), color: mode("inherit", "whiteAlpha.800")(props), _active: { bg: mode("gray.200", "whiteAlpha.300")(props) }, _disabled: { opacity: 0.4, cursor: "not-allowed" } } }; }, sizes: sizes$c, variants: variants$5, defaultProps: defaultProps$b }, baseStyle$f = sizes_501602a9_esm_extends({}, Input.baseStyle.field, { textAlign: "center" }), variants$4 = { outline: function(props) { var _Input$variants$outli; return null != (_Input$variants$outli = Input.variants.outline(props).field) ? _Input$variants$outli : {}; }, flushed: function(props) { var _Input$variants$flush; return null != (_Input$variants$flush = Input.variants.flushed(props).field) ? _Input$variants$flush : {}; }, filled: function(props) { var _Input$variants$fille; return null != (_Input$variants$fille = Input.variants.filled(props).field) ? _Input$variants$fille : {}; }, unstyled: null != (_Input$variants$unsty$1 = Input.variants.unstyled.field) ? _Input$variants$unsty$1 : {} }, defaultProps$a = Input.defaultProps, $popperBg = cssVar("popper-bg"), $arrowBg$1 = cssVar("popper-arrow-bg"), $arrowShadowColor = cssVar("popper-arrow-shadow-color"), baseStylePopper = { zIndex: 10 }, baseStyleContent = function(props) { var _ref, bg = mode("white", "gray.700")(props), shadowColor = mode("gray.200", "whiteAlpha.300")(props); return (_ref = {})[$popperBg.variable] = "colors." + bg, _ref.bg = $popperBg.reference, _ref[$arrowBg$1.variable] = $popperBg.reference, _ref[$arrowShadowColor.variable] = "colors." + shadowColor, _ref.width = "xs", _ref.border = "1px solid", _ref.borderColor = "inherit", _ref.borderRadius = "md", _ref.boxShadow = "sm", _ref.zIndex = "inherit", _ref._focusVisible = { outline: 0, boxShadow: "outline" }, _ref; }, baseStyleHeader = { px: 3, py: 2, borderBottomWidth: "1px" }, baseStyleBody = { px: 3, py: 2 }, baseStyleFooter = { px: 3, py: 2, borderTopWidth: "1px" }, baseStyleCloseButton$1 = { position: "absolute", borderRadius: "md", top: 1, insetEnd: 2, padding: 2 }, Popover = { parts: popoverAnatomy.keys, baseStyle: function(props) { return { popper: baseStylePopper, content: baseStyleContent(props), header: baseStyleHeader, body: baseStyleBody, footer: baseStyleFooter, arrow: {}, closeButton: baseStyleCloseButton$1 }; } }, baseStyleLabel$2 = { lineHeight: "1", fontSize: "0.25em", fontWeight: "bold", color: "white" }, baseStyleFilledTrack$1 = function(props) { var c, t, isIndeterminate, hasStripe, stripeStyle, bgColor, gradient; return sizes_501602a9_esm_extends({ transitionProperty: "common", transitionDuration: "slow" }, (c = props.colorScheme, t = props.theme, isIndeterminate = props.isIndeterminate, hasStripe = props.hasStripe, stripeStyle = mode(generateStripe(), generateStripe("1rem", "rgba(0,0,0,0.1)"))(props), gradient = "linear-gradient(\n to right,\n transparent 0%,\n " + getColor(t, bgColor = mode(c + ".500", c + ".200")(props)) + " 50%,\n transparent 100%\n )", sizes_501602a9_esm_extends({}, !isIndeterminate && hasStripe && stripeStyle, isIndeterminate ? { bgImage: gradient } : { bgColor: bgColor }))); }, Progress = { parts: progressAnatomy.keys, sizes: { xs: { track: { h: "0.25rem" } }, sm: { track: { h: "0.5rem" } }, md: { track: { h: "0.75rem" } }, lg: { track: { h: "1rem" } } }, baseStyle: function(props) { return { label: baseStyleLabel$2, filledTrack: baseStyleFilledTrack$1(props), track: { bg: mode("gray.100", "whiteAlpha.300")(props) } }; }, defaultProps: { size: "md", colorScheme: "blue" } }, baseStyleControl = function(props) { var _Checkbox$baseStyle$c = Checkbox.baseStyle(props).control, control = void 0 === _Checkbox$baseStyle$c ? {} : _Checkbox$baseStyle$c; return sizes_501602a9_esm_extends({}, control, { borderRadius: "full", _checked: sizes_501602a9_esm_extends({}, control._checked, { _before: { content: '""', display: "inline-block", pos: "relative", w: "50%", h: "50%", borderRadius: "50%", bg: "currentColor" } }) }); }, Radio = { parts: radioAnatomy.keys, baseStyle: function(props) { return { label: Checkbox.baseStyle(props).label, container: Checkbox.baseStyle(props).container, control: baseStyleControl(props) }; }, sizes: { md: { control: { w: 4, h: 4 }, label: { fontSize: "md" } }, lg: { control: { w: 5, h: 5 }, label: { fontSize: "lg" } }, sm: { control: { width: 3, height: 3 }, label: { fontSize: "sm" } } }, defaultProps: { size: "md", colorScheme: "blue" } }, baseStyleIcon$1 = { width: "1.5rem", height: "100%", insetEnd: "0.5rem", position: "relative", color: "currentColor", fontSize: "1.25rem", _disabled: { opacity: 0.5 } }, iconSpacing = { paddingInlineEnd: "2rem" }, sizes$8 = lodash_mergewith_default()({}, Input.sizes, { lg: { field: iconSpacing }, md: { field: iconSpacing }, sm: { field: iconSpacing }, xs: { field: iconSpacing, icon: { insetEnd: "0.25rem" } } }), Select = { parts: selectAnatomy.keys, baseStyle: function(props) { return { field: sizes_501602a9_esm_extends({}, Input.baseStyle.field, { bg: mode("white", "gray.700")(props), appearance: "none", paddingBottom: "1px", lineHeight: "normal", "> option, > optgroup": { bg: mode("white", "gray.700")(props) } }), icon: baseStyleIcon$1 }; }, sizes: sizes$8, variants: Input.variants, defaultProps: Input.defaultProps }, baseStyleContainer$1 = function(props) { var orientation = props.orientation; return sizes_501602a9_esm_extends({ display: "inline-block", position: "relative", cursor: "pointer", _disabled: { opacity: 0.6, cursor: "default", pointerEvents: "none" } }, orient({ orientation: orientation, vertical: { h: "100%" }, horizontal: { w: "100%" } })); }, baseStyleFilledTrack = function(props) { var c = props.colorScheme; return { width: "inherit", height: "inherit", bg: mode(c + ".500", c + ".200")(props) }; }, Slider = { parts: sliderAnatomy.keys, sizes: { lg: function(props) { return { thumb: { w: "16px", h: "16px" }, track: orient({ orientation: props.orientation, horizontal: { h: "4px" }, vertical: { w: "4px" } }) }; }, md: function(props) { return { thumb: { w: "14px", h: "14px" }, track: orient({ orientation: props.orientation, horizontal: { h: "4px" }, vertical: { w: "4px" } }) }; }, sm: function(props) { return { thumb: { w: "10px", h: "10px" }, track: orient({ orientation: props.orientation, horizontal: { h: "2px" }, vertical: { w: "2px" } }) }; } }, baseStyle: function(props) { return { container: baseStyleContainer$1(props), track: { overflow: "hidden", borderRadius: "sm", bg: mode("gray.200", "whiteAlpha.200")(props), _disabled: { bg: mode("gray.300", "whiteAlpha.300")(props) } }, thumb: sizes_501602a9_esm_extends({ display: "flex", alignItems: "center", justifyContent: "center", position: "absolute", outline: 0, zIndex: 1, borderRadius: "full", bg: "white", boxShadow: "base", border: "1px solid", borderColor: "transparent", transitionProperty: "transform", transitionDuration: "normal", _focusVisible: { boxShadow: "outline" }, _disabled: { bg: "gray.300" } }, orient({ orientation: props.orientation, vertical: { left: "50%", transform: "translateX(-50%)", _active: { transform: "translateX(-50%) scale(1.15)" } }, horizontal: { top: "50%", transform: "translateY(-50%)", _active: { transform: "translateY(-50%) scale(1.15)" } } })), filledTrack: baseStyleFilledTrack(props) }; }, defaultProps: { size: "md", colorScheme: "blue" } }, $size = cssVar("spinner-size"), baseStyle$7 = { width: [ $size.reference ], height: [ $size.reference ] }, sizes$6 = { xs: ((_xs = {})[$size.variable] = "0.75rem", _xs), sm: ((_sm = {})[$size.variable] = "1rem", _sm), md: ((_md = {})[$size.variable] = "1.5rem", _md), lg: ((_lg = {})[$size.variable] = "2rem", _lg), xl: ((_xl = {})[$size.variable] = "3rem", _xl) }, Stat = { parts: statAnatomy.keys, baseStyle: { container: {}, label: { fontWeight: "medium" }, helpText: { opacity: 0.8, marginBottom: 2 }, number: { verticalAlign: "baseline", fontWeight: "semibold" }, icon: { marginEnd: 1, w: "14px", h: "14px", verticalAlign: "middle" } }, sizes: { md: { label: { fontSize: "sm" }, helpText: { fontSize: "sm" }, number: { fontSize: "2xl" } } }, defaultProps: { size: "md" } }, $width = cssVar("switch-track-width"), $height = cssVar("switch-track-height"), $diff = cssVar("switch-track-diff"), diffValue = calc.subtract($width, $height), $translateX = cssVar("switch-thumb-x"), baseStyleTrack = function(props) { var c = props.colorScheme; return { borderRadius: "full", p: "2px", width: [ $width.reference ], height: [ $height.reference ], transitionProperty: "common", transitionDuration: "fast", bg: mode("gray.300", "whiteAlpha.400")(props), _focusVisible: { boxShadow: "outline" }, _disabled: { opacity: 0.4, cursor: "not-allowed" }, _checked: { bg: mode(c + ".500", c + ".200")(props) } }; }, baseStyleThumb = { bg: "white", transitionProperty: "transform", transitionDuration: "normal", borderRadius: "inherit", width: [ $height.reference ], height: [ $height.reference ], _checked: { transform: "translateX(" + $translateX.reference + ")" } }, sizes$4 = { sm: { container: ((_container2 = {})[$width.variable] = "1.375rem", _container2[$height.variable] = "0.75rem", _container2) }, md: { container: ((_container3 = {})[$width.variable] = "1.875rem", _container3[$height.variable] = "1rem", _container3) }, lg: { container: ((_container4 = {})[$width.variable] = "2.875rem", _container4[$height.variable] = "1.5rem", _container4) } }, Switch = { parts: switchAnatomy.keys, baseStyle: function(props) { var _rtl, _container; return { container: ((_container = {})[$diff.variable] = diffValue, _container[$translateX.variable] = $diff.reference, (_rtl = {})[$translateX.variable] = calc($diff).negate().toString(), _container._rtl = _rtl, _container), track: baseStyleTrack(props), thumb: baseStyleThumb }; }, sizes: sizes$4, defaultProps: { size: "md", colorScheme: "blue" } }, numericStyles = { "&[data-is-numeric=true]": { textAlign: "end" } }, Table = { parts: tableAnatomy.keys, baseStyle: { table: { fontVariantNumeric: "lining-nums tabular-nums", borderCollapse: "collapse", width: "full" }, th: { fontFamily: "heading", fontWeight: "bold", textTransform: "uppercase", letterSpacing: "wider", textAlign: "start" }, td: { textAlign: "start" }, caption: { mt: 4, fontFamily: "heading", textAlign: "center", fontWeight: "medium" } }, variants: { simple: function(props) { var c = props.colorScheme; return { th: sizes_501602a9_esm_extends({ color: mode("gray.600", "gray.400")(props), borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props) }, numericStyles), td: sizes_501602a9_esm_extends({ borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props) }, numericStyles), caption: { color: mode("gray.600", "gray.100")(props) }, tfoot: { tr: { "&:last-of-type": { th: { borderBottomWidth: 0 } } } } }; }, striped: function(props) { var c = props.colorScheme; return { th: sizes_501602a9_esm_extends({ color: mode("gray.600", "gray.400")(props), borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props) }, numericStyles), td: sizes_501602a9_esm_extends({ borderBottom: "1px", borderColor: mode(c + ".100", c + ".700")(props) }, numericStyles), caption: { color: mode("gray.600", "gray.100")(props) }, tbody: { tr: { "&:nth-of-type(odd)": { "th, td": { borderBottomWidth: "1px", borderColor: mode(c + ".100", c + ".700")(props) }, td: { background: mode(c + ".100", c + ".700")(props) } } } }, tfoot: { tr: { "&:last-of-type": { th: { borderBottomWidth: 0 } } } } }; }, unstyled: {} }, sizes: { sm: { th: { px: "4", py: "1", lineHeight: "4", fontSize: "xs" }, td: { px: "4", py: "2", fontSize: "sm", lineHeight: "4" }, caption: { px: "4", py: "2", fontSize: "xs" } }, md: { th: { px: "6", py: "3", lineHeight: "4", fontSize: "xs" }, td: { px: "6", py: "4", lineHeight: "5" }, caption: { px: "6", py: "2", fontSize: "sm" } }, lg: { th: { px: "8", py: "4", lineHeight: "5", fontSize: "sm" }, td: { px: "8", py: "5", lineHeight: "6" }, caption: { px: "6", py: "2", fontSize: "md" } } }, defaultProps: { variant: "simple", size: "md", colorScheme: "gray" } }, baseStyleTablist = function(props) { var _props$align = props.align; return { justifyContent: ({ end: "flex-end", center: "center", start: "flex-start" })[void 0 === _props$align ? "start" : _props$align], flexDirection: "vertical" === props.orientation ? "column" : "row" }; }, baseStyleTabpanel = { p: 4 }, Tabs = { parts: tabsAnatomy.keys, baseStyle: function(props) { return { root: { display: "vertical" === props.orientation ? "flex" : "block" }, tab: { flex: props.isFitted ? 1 : void 0, transitionProperty: "common", transitionDuration: "normal", _focusVisible: { zIndex: 1, boxShadow: "outline" }, _disabled: { cursor: "not-allowed", opacity: 0.4 } }, tablist: baseStyleTablist(props), tabpanel: baseStyleTabpanel }; }, sizes: { sm: { tab: { py: 1, px: 4, fontSize: "sm" } }, md: { tab: { fontSize: "md", py: 2, px: 4 } }, lg: { tab: { fontSize: "lg", py: 3, px: 4 } } }, variants: { line: function(props) { var _tablist, _tab, c = props.colorScheme, orientation = props.orientation, borderProp = "vertical" === orientation ? "borderStart" : "borderBottom"; return { tablist: ((_tablist = {})[borderProp] = "2px solid", _tablist.borderColor = "inherit", _tablist), tab: ((_tab = {})[borderProp] = "2px solid", _tab.borderColor = "transparent", _tab["vertical" === orientation ? "marginStart" : "marginBottom"] = "-2px", _tab._selected = { color: mode(c + ".600", c + ".300")(props), borderColor: "currentColor" }, _tab._active = { bg: mode("gray.200", "whiteAlpha.300")(props) }, _tab._disabled = { _active: { bg: "none" } }, _tab) }; }, enclosed: function(props) { var c = props.colorScheme; return { tab: { borderTopRadius: "md", border: "1px solid", borderColor: "transparent", mb: "-1px", _selected: { color: mode(c + ".600", c + ".300")(props), borderColor: "inherit", borderBottomColor: mode("white", "gray.800")(props) } }, tablist: { mb: "-1px", borderBottom: "1px solid", borderColor: "inherit" } }; }, "enclosed-colored": function(props) { var c = props.colorScheme; return { tab: { border: "1px solid", borderColor: "inherit", bg: mode("gray.50", "whiteAlpha.50")(props), mb: "-1px", _notLast: { marginEnd: "-1px" }, _selected: { bg: mode("#fff", "gray.800")(props), color: mode(c + ".600", c + ".300")(props), borderColor: "inherit", borderTopColor: "currentColor", borderBottomColor: "transparent" } }, tablist: { mb: "-1px", borderBottom: "1px solid", borderColor: "inherit" } }; }, "soft-rounded": function(props) { var c = props.colorScheme, theme = props.theme; return { tab: { borderRadius: "full", fontWeight: "semibold", color: "gray.600", _selected: { color: getColor(theme, c + ".700"), bg: getColor(theme, c + ".100") } } }; }, "solid-rounded": function(props) { var c = props.colorScheme; return { tab: { borderRadius: "full", fontWeight: "semibold", color: mode("gray.600", "inherit")(props), _selected: { color: mode("#fff", "gray.800")(props), bg: mode(c + ".600", c + ".300")(props) } } }; }, unstyled: {} }, defaultProps: { size: "md", variant: "line", colorScheme: "blue" } }, Tag = { parts: tagAnatomy.keys, variants: { subtle: function(props) { return { container: Badge.variants.subtle(props) }; }, solid: function(props) { return { container: Badge.variants.solid(props) }; }, outline: function(props) { return { container: Badge.variants.outline(props) }; } }, baseStyle: { container: { fontWeight: "medium", lineHeight: 1.2, outline: 0, borderRadius: "md", _focusVisible: { boxShadow: "outline" } }, label: { lineHeight: 1.2, overflow: "visible" }, closeButton: { fontSize: "18px", w: "1.25rem", h: "1.25rem", transitionProperty: "common", transitionDuration: "normal", borderRadius: "full", marginStart: "0.375rem", marginEnd: "-1", opacity: 0.5, _disabled: { opacity: 0.4 }, _focusVisible: { boxShadow: "outline", bg: "rgba(0, 0, 0, 0.14)" }, _hover: { opacity: 0.8 }, _active: { opacity: 1 } } }, sizes: { sm: { container: { minH: "1.25rem", minW: "1.25rem", fontSize: "xs", px: 2 }, closeButton: { marginEnd: "-2px", marginStart: "0.35rem" } }, md: { container: { minH: "1.5rem", minW: "1.5rem", fontSize: "sm", px: 2 } }, lg: { container: { minH: 8, minW: 8, fontSize: "md", px: 3 } } }, defaultProps: { size: "md", variant: "subtle", colorScheme: "gray" } }, baseStyle$1 = sizes_501602a9_esm_extends({}, Input.baseStyle.field, { paddingY: "8px", minHeight: "80px", lineHeight: "short", verticalAlign: "top" }), variants = { outline: function(props) { var _Input$variants$outli; return null != (_Input$variants$outli = Input.variants.outline(props).field) ? _Input$variants$outli : {}; }, flushed: function(props) { var _Input$variants$flush; return null != (_Input$variants$flush = Input.variants.flushed(props).field) ? _Input$variants$flush : {}; }, filled: function(props) { var _Input$variants$fille; return null != (_Input$variants$fille = Input.variants.filled(props).field) ? _Input$variants$fille : {}; }, unstyled: null != (_Input$variants$unsty = Input.variants.unstyled.field) ? _Input$variants$unsty : {} }, chakra_ui_theme_components_esm_sizes = { xs: null != (_Input$sizes$xs$field = Input.sizes.xs.field) ? _Input$sizes$xs$field : {}, sm: null != (_Input$sizes$sm$field = Input.sizes.sm.field) ? _Input$sizes$sm$field : {}, md: null != (_Input$sizes$md$field = Input.sizes.md.field) ? _Input$sizes$md$field : {}, lg: null != (_Input$sizes$lg$field = Input.sizes.lg.field) ? _Input$sizes$lg$field : {} }, $bg = cssVar("tooltip-bg"), $arrowBg = cssVar("popper-arrow-bg"), breakpoints = ((0, chakra_ui_utils_esm /* warn */ .ZK)({ condition: !0, message: "[chakra-ui]: createBreakpoints(...) will be deprecated pretty soonsimply pass the breakpoints as an object. Remove the createBreakpoint(..) call" }), chakra_ui_theme_tools_esm_extends({ base: "0em" }, { sm: "30em", md: "48em", lg: "62em", xl: "80em", "2xl": "96em" })), foundations = sizes_501602a9_esm_extends({ breakpoints: breakpoints, zIndices: { hide: -1, auto: "auto", base: 0, docked: 10, dropdown: 1000, sticky: 1100, banner: 1200, overlay: 1300, modal: 1400, popover: 1500, skipLink: 1600, toast: 1700, tooltip: 1800 }, radii: { none: "0", sm: "0.125rem", base: "0.25rem", md: "0.375rem", lg: "0.5rem", xl: "0.75rem", "2xl": "1rem", "3xl": "1.5rem", full: "9999px" }, blur: { none: 0, sm: "4px", base: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" }, colors: { transparent: "transparent", current: "currentColor", black: "#000000", white: "#FFFFFF", whiteAlpha: { 50: "rgba(255, 255, 255, 0.04)", 100: "rgba(255, 255, 255, 0.06)", 200: "rgba(255, 255, 255, 0.08)", 300: "rgba(255, 255, 255, 0.16)", 400: "rgba(255, 255, 255, 0.24)", 500: "rgba(255, 255, 255, 0.36)", 600: "rgba(255, 255, 255, 0.48)", 700: "rgba(255, 255, 255, 0.64)", 800: "rgba(255, 255, 255, 0.80)", 900: "rgba(255, 255, 255, 0.92)" }, blackAlpha: { 50: "rgba(0, 0, 0, 0.04)", 100: "rgba(0, 0, 0, 0.06)", 200: "rgba(0, 0, 0, 0.08)", 300: "rgba(0, 0, 0, 0.16)", 400: "rgba(0, 0, 0, 0.24)", 500: "rgba(0, 0, 0, 0.36)", 600: "rgba(0, 0, 0, 0.48)", 700: "rgba(0, 0, 0, 0.64)", 800: "rgba(0, 0, 0, 0.80)", 900: "rgba(0, 0, 0, 0.92)" }, gray: { 50: "#F7FAFC", 100: "#EDF2F7", 200: "#E2E8F0", 300: "#CBD5E0", 400: "#A0AEC0", 500: "#718096", 600: "#4A5568", 700: "#2D3748", 800: "#1A202C", 900: "#171923" }, red: { 50: "#FFF5F5", 100: "#FED7D7", 200: "#FEB2B2", 300: "#FC8181", 400: "#F56565", 500: "#E53E3E", 600: "#C53030", 700: "#9B2C2C", 800: "#822727", 900: "#63171B" }, orange: { 50: "#FFFAF0", 100: "#FEEBC8", 200: "#FBD38D", 300: "#F6AD55", 400: "#ED8936", 500: "#DD6B20", 600: "#C05621", 700: "#9C4221", 800: "#7B341E", 900: "#652B19" }, yellow: { 50: "#FFFFF0", 100: "#FEFCBF", 200: "#FAF089", 300: "#F6E05E", 400: "#ECC94B", 500: "#D69E2E", 600: "#B7791F", 700: "#975A16", 800: "#744210", 900: "#5F370E" }, green: { 50: "#F0FFF4", 100: "#C6F6D5", 200: "#9AE6B4", 300: "#68D391", 400: "#48BB78", 500: "#38A169", 600: "#2F855A", 700: "#276749", 800: "#22543D", 900: "#1C4532" }, teal: { 50: "#E6FFFA", 100: "#B2F5EA", 200: "#81E6D9", 300: "#4FD1C5", 400: "#38B2AC", 500: "#319795", 600: "#2C7A7B", 700: "#285E61", 800: "#234E52", 900: "#1D4044" }, blue: { 50: "#ebf8ff", 100: "#bee3f8", 200: "#90cdf4", 300: "#63b3ed", 400: "#4299e1", 500: "#3182ce", 600: "#2b6cb0", 700: "#2c5282", 800: "#2a4365", 900: "#1A365D" }, cyan: { 50: "#EDFDFD", 100: "#C4F1F9", 200: "#9DECF9", 300: "#76E4F7", 400: "#0BC5EA", 500: "#00B5D8", 600: "#00A3C4", 700: "#0987A0", 800: "#086F83", 900: "#065666" }, purple: { 50: "#FAF5FF", 100: "#E9D8FD", 200: "#D6BCFA", 300: "#B794F4", 400: "#9F7AEA", 500: "#805AD5", 600: "#6B46C1", 700: "#553C9A", 800: "#44337A", 900: "#322659" }, pink: { 50: "#FFF5F7", 100: "#FED7E2", 200: "#FBB6CE", 300: "#F687B3", 400: "#ED64A6", 500: "#D53F8C", 600: "#B83280", 700: "#97266D", 800: "#702459", 900: "#521B41" }, linkedin: { 50: "#E8F4F9", 100: "#CFEDFB", 200: "#9BDAF3", 300: "#68C7EC", 400: "#34B3E4", 500: "#00A0DC", 600: "#008CC9", 700: "#0077B5", 800: "#005E93", 900: "#004471" }, facebook: { 50: "#E8F4F9", 100: "#D9DEE9", 200: "#B7C2DA", 300: "#6482C0", 400: "#4267B2", 500: "#385898", 600: "#314E89", 700: "#29487D", 800: "#223B67", 900: "#1E355B" }, messenger: { 50: "#D0E6FF", 100: "#B9DAFF", 200: "#A2CDFF", 300: "#7AB8FF", 400: "#2E90FF", 500: "#0078FF", 600: "#0063D1", 700: "#0052AC", 800: "#003C7E", 900: "#002C5C" }, whatsapp: { 50: "#dffeec", 100: "#b9f5d0", 200: "#90edb3", 300: "#65e495", 400: "#3cdd78", 500: "#22c35e", 600: "#179848", 700: "#0c6c33", 800: "#01421c", 900: "#001803" }, twitter: { 50: "#E5F4FD", 100: "#C8E9FB", 200: "#A8DCFA", 300: "#83CDF7", 400: "#57BBF5", 500: "#1DA1F2", 600: "#1A94DA", 700: "#1681BF", 800: "#136B9E", 900: "#0D4D71" }, telegram: { 50: "#E3F2F9", 100: "#C5E4F3", 200: "#A2D4EC", 300: "#7AC1E4", 400: "#47A9DA", 500: "#0088CC", 600: "#007AB8", 700: "#006BA1", 800: "#005885", 900: "#003F5E" } } }, typography, { sizes: sizes, shadows: { xs: "0 0 0 1px rgba(0, 0, 0, 0.05)", sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)", base: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)", md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)", lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)", xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)", "2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)", outline: "0 0 0 3px rgba(66, 153, 225, 0.6)", inner: "inset 0 2px 4px 0 rgba(0,0,0,0.06)", none: "none", "dark-lg": "rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 5px 10px, rgba(0, 0, 0, 0.4) 0px 15px 40px" }, space: spacing, borders: { none: 0, "1px": "1px solid", "2px": "2px solid", "4px": "4px solid", "8px": "8px solid" }, transition: { property: { common: "background-color, border-color, color, fill, stroke, opacity, box-shadow, transform", colors: "background-color, border-color, color, fill, stroke", dimensions: "width, height", position: "left, right, top, bottom", background: "background-color, background-image, background-position" }, easing: { "ease-in": "cubic-bezier(0.4, 0, 1, 1)", "ease-out": "cubic-bezier(0, 0, 0.2, 1)", "ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)" }, duration: { "ultra-fast": "50ms", faster: "100ms", fast: "150ms", normal: "200ms", slow: "300ms", slower: "400ms", "ultra-slow": "500ms" } } }), theme = sizes_501602a9_esm_extends({ semanticTokens: { colors: { "chakra-body-text": { _light: "gray.800", _dark: "whiteAlpha.900" }, "chakra-body-bg": { _light: "white", _dark: "gray.800" }, "chakra-border-color": { _light: "gray.200", _dark: "whiteAlpha.300" }, "chakra-placeholder-color": { _light: "gray.500", _dark: "whiteAlpha.400" } } }, direction: "ltr" }, foundations, { components: { Accordion: Accordion, Alert: Alert, Avatar: Avatar, Badge: Badge, Breadcrumb: Breadcrumb, Button: { baseStyle: { lineHeight: "1.2", borderRadius: "md", fontWeight: "semibold", transitionProperty: "common", transitionDuration: "normal", _focusVisible: { boxShadow: "outline" }, _disabled: { opacity: 0.4, cursor: "not-allowed", boxShadow: "none" }, _hover: { _disabled: { bg: "initial" } } }, variants: { ghost: variantGhost, outline: function(props) { var c = props.colorScheme, borderColor = mode("gray.200", "whiteAlpha.300")(props); return sizes_501602a9_esm_extends({ border: "1px solid", borderColor: "gray" === c ? borderColor : "currentColor", ".chakra-button__group[data-attached] > &:not(:last-of-type)": { marginEnd: "-1px" } }, variantGhost(props)); }, solid: function(props) { var _accessibleColorMap$c, c = props.colorScheme; if ("gray" === c) { var _bg = mode("gray.100", "whiteAlpha.200")(props); return { bg: _bg, _hover: { bg: mode("gray.200", "whiteAlpha.300")(props), _disabled: { bg: _bg } }, _active: { bg: mode("gray.300", "whiteAlpha.400")(props) } }; } var _ref = null != (_accessibleColorMap$c = accessibleColorMap[c]) ? _accessibleColorMap$c : {}, _ref$bg = _ref.bg, _ref$color = _ref.color, _ref$hoverBg = _ref.hoverBg, _ref$activeBg = _ref.activeBg, background = mode(void 0 === _ref$bg ? c + ".500" : _ref$bg, c + ".200")(props); return { bg: background, color: mode(void 0 === _ref$color ? "white" : _ref$color, "gray.800")(props), _hover: { bg: mode(void 0 === _ref$hoverBg ? c + ".600" : _ref$hoverBg, c + ".300")(props), _disabled: { bg: background } }, _active: { bg: mode(void 0 === _ref$activeBg ? c + ".700" : _ref$activeBg, c + ".400")(props) } }; }, link: function(props) { var c = props.colorScheme; return { padding: 0, height: "auto", lineHeight: "normal", verticalAlign: "baseline", color: mode(c + ".500", c + ".200")(props), _hover: { textDecoration: "underline", _disabled: { textDecoration: "none" } }, _active: { color: mode(c + ".700", c + ".500")(props) } }; }, unstyled: { bg: "none", color: "inherit", display: "inline", lineHeight: "inherit", m: 0, p: 0 } }, sizes: { lg: { h: 12, minW: 12, fontSize: "lg", px: 6 }, md: { h: 10, minW: 10, fontSize: "md", px: 4 }, sm: { h: 8, minW: 8, fontSize: "sm", px: 3 }, xs: { h: 6, minW: 6, fontSize: "xs", px: 2 } }, defaultProps: { variant: "solid", size: "md", colorScheme: "gray" } }, Checkbox: Checkbox, CloseButton: { baseStyle: function(props) { var hoverBg = mode("blackAlpha.100", "whiteAlpha.100")(props), activeBg = mode("blackAlpha.200", "whiteAlpha.200")(props); return { w: [ $size$1.reference ], h: [ $size$1.reference ], borderRadius: "md", transitionProperty: "common", transitionDuration: "normal", _disabled: { opacity: 0.4, cursor: "not-allowed", boxShadow: "none" }, _hover: { bg: hoverBg }, _active: { bg: activeBg }, _focusVisible: { boxShadow: "outline" } }; }, sizes: sizes$h, defaultProps: { size: "md" } }, Code: { baseStyle: { fontFamily: "mono", fontSize: "sm", px: "0.2em", borderRadius: "sm" }, variants: variants$8, defaultProps: defaultProps$h }, Container: { baseStyle: { w: "100%", mx: "auto", maxW: "60ch", px: "1rem" } }, Divider: { baseStyle: { opacity: 0.6, borderColor: "inherit" }, variants: { solid: { borderStyle: "solid" }, dashed: { borderStyle: "dashed" } }, defaultProps: { variant: "solid" } }, Drawer: Drawer, Editable: Editable, Form: Form, FormError: FormError, FormLabel: { baseStyle: { fontSize: "md", marginEnd: 3, mb: 2, fontWeight: "medium", transitionProperty: "common", transitionDuration: "normal", opacity: 1, _disabled: { opacity: 0.4 } } }, Heading: { baseStyle: { fontFamily: "heading", fontWeight: "bold" }, sizes: { "4xl": { fontSize: [ "6xl", null, "7xl" ], lineHeight: 1 }, "3xl": { fontSize: [ "5xl", null, "6xl" ], lineHeight: 1 }, "2xl": { fontSize: [ "4xl", null, "5xl" ], lineHeight: [ 1.2, null, 1 ] }, xl: { fontSize: [ "3xl", null, "4xl" ], lineHeight: [ 1.33, null, 1.2 ] }, lg: { fontSize: [ "2xl", null, "3xl" ], lineHeight: [ 1.33, null, 1.2 ] }, md: { fontSize: "xl", lineHeight: 1.2 }, sm: { fontSize: "md", lineHeight: 1.2 }, xs: { fontSize: "sm", lineHeight: 1.2 } }, defaultProps: { size: "xl" } }, Input: Input, Kbd: { baseStyle: function(props) { return { bg: mode("gray.100", "whiteAlpha")(props), borderRadius: "md", borderWidth: "1px", borderBottomWidth: "3px", fontSize: "0.8em", fontWeight: "bold", lineHeight: "normal", px: "0.4em", whiteSpace: "nowrap" }; } }, Link: { baseStyle: { transitionProperty: "common", transitionDuration: "fast", transitionTimingFunction: "ease-out", cursor: "pointer", textDecoration: "none", outline: "none", color: "inherit", _hover: { textDecoration: "underline" }, _focusVisible: { boxShadow: "outline" } } }, List: List, Menu: Menu, Modal: Modal, NumberInput: NumberInput, PinInput: { baseStyle: baseStyle$f, sizes: { lg: { fontSize: "lg", w: 12, h: 12, borderRadius: "md" }, md: { fontSize: "md", w: 10, h: 10, borderRadius: "md" }, sm: { fontSize: "sm", w: 8, h: 8, borderRadius: "sm" }, xs: { fontSize: "xs", w: 6, h: 6, borderRadius: "sm" } }, variants: variants$4, defaultProps: defaultProps$a }, Popover: Popover, Progress: Progress, Radio: Radio, Select: Select, Skeleton: { baseStyle: function(props) { var defaultStartColor = mode("gray.100", "gray.800")(props), defaultEndColor = mode("gray.400", "gray.600")(props), _props$startColor = props.startColor, _props$endColor = props.endColor, speed = props.speed, theme = props.theme, start = getColor(theme, void 0 === _props$startColor ? defaultStartColor : _props$startColor), end = getColor(theme, void 0 === _props$endColor ? defaultEndColor : _props$endColor); return { opacity: 0.7, borderRadius: "2px", borderColor: start, background: end, animation: speed + "s linear infinite alternate " + (0, emotion_react_browser_esm /* keyframes */ .F4)({ from: { borderColor: start, background: start }, to: { borderColor: end, background: end } }) }; } }, SkipLink: { baseStyle: function(props) { return { borderRadius: "md", fontWeight: "semibold", _focusVisible: { boxShadow: "outline", padding: "1rem", position: "fixed", top: "1.5rem", insetStart: "1.5rem", bg: mode("white", "gray.700")(props) } }; } }, Slider: Slider, Spinner: { baseStyle: baseStyle$7, sizes: sizes$6, defaultProps: { size: "md" } }, Stat: Stat, Switch: Switch, Table: Table, Tabs: Tabs, Tag: Tag, Textarea: { baseStyle: baseStyle$1, sizes: chakra_ui_theme_components_esm_sizes, variants: variants, defaultProps: { size: "md", variant: "outline" } }, Tooltip: { baseStyle: function(props) { var _ref, bg = mode("gray.700", "gray.300")(props); return (_ref = {})[$bg.variable] = "colors." + bg, _ref.px = "8px", _ref.py = "2px", _ref.bg = [ $bg.reference ], _ref[$arrowBg.variable] = [ $bg.reference ], _ref.color = mode("whiteAlpha.900", "gray.900")(props), _ref.borderRadius = "sm", _ref.fontWeight = "medium", _ref.fontSize = "sm", _ref.boxShadow = "md", _ref.maxW = "320px", _ref.zIndex = "tooltip", _ref; } } }, styles: { global: { body: { fontFamily: "body", color: "chakra-body-text", bg: "chakra-body-bg", transitionProperty: "background-color", transitionDuration: "normal", lineHeight: "base" }, "*::placeholder": { color: "chakra-placeholder-color" }, "*, *::before, &::after": { borderColor: "chakra-border-color", wordWrap: "break-word" } } }, config: { useSystemColorMode: !1, initialColorMode: "light", cssVarPrefix: "chakra" } }), chakra_ui_visually_hidden_esm = __webpack_require__(1358); function chakra_ui_spinner_esm_extends() { return (chakra_ui_spinner_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } var chakra_ui_spinner_esm_excluded = [ "label", "thickness", "speed", "emptyColor", "className" ], spin = (0, emotion_react_browser_esm /* keyframes */ .F4)({ "0%": { transform: "rotate(0deg)" }, "100%": { transform: "rotate(360deg)" } }), chakra_ui_spinner_esm_Spinner = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */ .Gp)(function(props, ref) { var styles = (0, chakra_ui_system_esm /* useStyleConfig */ .mq)("Spinner", props), _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */ .Lr)(props), _omitThemingProps$lab = _omitThemingProps.label, label = void 0 === _omitThemingProps$lab ? "Loading..." : _omitThemingProps$lab, _omitThemingProps$thi = _omitThemingProps.thickness, _omitThemingProps$spe = _omitThemingProps.speed, _omitThemingProps$emp = _omitThemingProps.emptyColor, emptyColor = void 0 === _omitThemingProps$emp ? "transparent" : _omitThemingProps$emp, className = _omitThemingProps.className, rest = function(source, excluded) { if (null == source) return {}; var key, i, target = {}, sourceKeys = Object.keys(source); for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); return target; }(_omitThemingProps, chakra_ui_spinner_esm_excluded), _className = (0, chakra_ui_utils_esm.cx)("chakra-spinner", className), spinnerStyles = chakra_ui_spinner_esm_extends({ display: "inline-block", borderColor: "currentColor", borderStyle: "solid", borderRadius: "99999px", borderWidth: void 0 === _omitThemingProps$thi ? "2px" : _omitThemingProps$thi, borderBottomColor: emptyColor, borderLeftColor: emptyColor, animation: spin + " " + (void 0 === _omitThemingProps$spe ? "0.45s" : _omitThemingProps$spe) + " linear infinite" }, styles); return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, chakra_ui_spinner_esm_extends({ ref: ref, __css: spinnerStyles, className: _className }, rest), label && /*#__PURE__*/ react.createElement(chakra_ui_visually_hidden_esm /* VisuallyHidden */ .TX, null, label)); }); chakra_ui_utils_esm /* __DEV__ */ .Ts && (chakra_ui_spinner_esm_Spinner.displayName = "Spinner"); // EXTERNAL MODULE: ./node_modules/@chakra-ui/icon/dist/chakra-ui-icon.esm.js var chakra_ui_icon_esm = __webpack_require__(894); // CONCATENATED MODULE: ./node_modules/@chakra-ui/alert/dist/chakra-ui-alert.esm.js function chakra_ui_alert_esm_extends() { return (chakra_ui_alert_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } var WarningIcon = function(props) { return /*#__PURE__*/ react.createElement(chakra_ui_icon_esm /* Icon */ .JO, chakra_ui_alert_esm_extends({ viewBox: "0 0 24 24" }, props), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z" })); }, chakra_ui_alert_esm_excluded = [ "status" ], _createStylesContext = (0, chakra_ui_system_esm /* createStylesContext */ .eC)("Alert"), StylesProvider = _createStylesContext[0], useStyles = _createStylesContext[1], STATUSES = { info: { icon: function(props) { return /*#__PURE__*/ react.createElement(chakra_ui_icon_esm /* Icon */ .JO, chakra_ui_alert_esm_extends({ viewBox: "0 0 24 24" }, props), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M12,0A12,12,0,1,0,24,12,12.013,12.013,0,0,0,12,0Zm.25,5a1.5,1.5,0,1,1-1.5,1.5A1.5,1.5,0,0,1,12.25,5ZM14.5,18.5h-4a1,1,0,0,1,0-2h.75a.25.25,0,0,0,.25-.25v-4.5a.25.25,0,0,0-.25-.25H10.5a1,1,0,0,1,0-2h1a2,2,0,0,1,2,2v4.75a.25.25,0,0,0,.25.25h.75a1,1,0,1,1,0,2Z" })); }, colorScheme: "blue" }, warning: { icon: WarningIcon, colorScheme: "orange" }, success: { icon: function(props) { return /*#__PURE__*/ react.createElement(chakra_ui_icon_esm /* Icon */ .JO, chakra_ui_alert_esm_extends({ viewBox: "0 0 24 24" }, props), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M12,0A12,12,0,1,0,24,12,12.014,12.014,0,0,0,12,0Zm6.927,8.2-6.845,9.289a1.011,1.011,0,0,1-1.43.188L5.764,13.769a1,1,0,1,1,1.25-1.562l4.076,3.261,6.227-8.451A1,1,0,1,1,18.927,8.2Z" })); }, colorScheme: "green" }, error: { icon: WarningIcon, colorScheme: "red" }, loading: { icon: chakra_ui_spinner_esm_Spinner, colorScheme: "blue" } }, chakra_ui_alert_esm_createContext = (0, chakra_ui_react_utils_esm /* createContext */ .kr)({ name: "AlertContext", errorMessage: "useAlertContext: `context` is undefined. Seems you forgot to wrap alert components in `<Alert />`" }), AlertProvider = chakra_ui_alert_esm_createContext[0], useAlertContext = chakra_ui_alert_esm_createContext[1], chakra_ui_alert_esm_Alert = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */ .Gp)(function(props, ref) { var _props$colorScheme, _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */ .Lr)(props), _omitThemingProps$sta = _omitThemingProps.status, status = void 0 === _omitThemingProps$sta ? "info" : _omitThemingProps$sta, rest = function(source, excluded) { if (null == source) return {}; var key, i, target = {}, sourceKeys = Object.keys(source); for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); return target; }(_omitThemingProps, chakra_ui_alert_esm_excluded), colorScheme = null != (_props$colorScheme = props.colorScheme) ? _props$colorScheme : STATUSES[status].colorScheme, styles = (0, chakra_ui_system_esm /* useMultiStyleConfig */ .jC)("Alert", chakra_ui_alert_esm_extends({}, props, { colorScheme: colorScheme })), alertStyles = chakra_ui_alert_esm_extends({ width: "100%", display: "flex", alignItems: "center", position: "relative", overflow: "hidden" }, styles.container); return /*#__PURE__*/ react.createElement(AlertProvider, { value: { status: status } }, /*#__PURE__*/ react.createElement(StylesProvider, { value: styles }, /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, chakra_ui_alert_esm_extends({ role: "alert", ref: ref }, rest, { className: (0, chakra_ui_utils_esm.cx)("chakra-alert", props.className), __css: alertStyles })))); }), AlertTitle = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */ .Gp)(function(props, ref) { var styles = useStyles(); return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, chakra_ui_alert_esm_extends({ ref: ref }, props, { className: (0, chakra_ui_utils_esm.cx)("chakra-alert__title", props.className), __css: styles.title })); }), AlertDescription = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */ .Gp)(function(props, ref) { var styles = useStyles(), descriptionStyles = chakra_ui_alert_esm_extends({ display: "inline" }, styles.description); return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, chakra_ui_alert_esm_extends({ ref: ref }, props, { className: (0, chakra_ui_utils_esm.cx)("chakra-alert__desc", props.className), __css: descriptionStyles })); }), AlertIcon = function(props) { var status = useAlertContext().status, BaseIcon = STATUSES[status].icon, styles = useStyles(), css = "loading" === status ? styles.spinner : styles.icon; return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.span */ .m$.span, chakra_ui_alert_esm_extends({ display: "inherit" }, props, { className: (0, chakra_ui_utils_esm.cx)("chakra-alert__icon", props.className), __css: css }), props.children || /*#__PURE__*/ react.createElement(BaseIcon, { h: "100%", w: "100%" })); }; function chakra_ui_close_button_esm_extends() { return (chakra_ui_close_button_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } var chakra_ui_close_button_esm_excluded = [ "children", "isDisabled", "__css" ], CloseIcon = function(props) { return /*#__PURE__*/ react.createElement(chakra_ui_icon_esm /* Icon */ .JO, chakra_ui_close_button_esm_extends({ focusable: "false", "aria-hidden": !0 }, props), /*#__PURE__*/ react.createElement("path", { fill: "currentColor", d: "M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z" })); }, chakra_ui_close_button_esm_CloseButton = /*#__PURE__*/ (0, chakra_ui_system_esm /* forwardRef */ .Gp)(function(props, ref) { var styles = (0, chakra_ui_system_esm /* useStyleConfig */ .mq)("CloseButton", props), _omitThemingProps = (0, chakra_ui_system_esm /* omitThemingProps */ .Lr)(props), children = _omitThemingProps.children, isDisabled = _omitThemingProps.isDisabled, __css = _omitThemingProps.__css, rest = function(source, excluded) { if (null == source) return {}; var key, i, target = {}, sourceKeys = Object.keys(source); for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); return target; }(_omitThemingProps, chakra_ui_close_button_esm_excluded); return /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.button */ .m$.button, chakra_ui_close_button_esm_extends({ type: "button", "aria-label": "Close", ref: ref, disabled: isDisabled, __css: chakra_ui_close_button_esm_extends({}, { outline: 0, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, styles, __css) }, rest), children || /*#__PURE__*/ react.createElement(CloseIcon, { width: "1em", height: "1em" })); }); chakra_ui_utils_esm /* __DEV__ */ .Ts && (chakra_ui_close_button_esm_CloseButton.displayName = "CloseButton"); // EXTERNAL MODULE: ./node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs var use_presence = __webpack_require__(5947), motion = __webpack_require__(8970), AnimatePresence = __webpack_require__(1190); function chakra_ui_toast_esm_extends() { return (chakra_ui_toast_esm_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); } return target; }).apply(this, arguments); } /** * Given an array of toasts for a specific position. * It returns the toast that matches the `id` passed */ /** * Given the toast manager state, finds the toast that matches * the id and return its position and index */ function findToast(toasts, id) { var position = getToastPosition(toasts, id), index = position ? toasts[position].findIndex(function(toast) { return toast.id === id; }) : -1; return { position: position, index: index }; } /** * Given the toast manager state, finds the position of the toast that * matches the `id` */ var getToastPosition = function(toasts, id) { var _Object$values$flat$f; return null == (_Object$values$flat$f = Object.values(toasts).flat().find(function(toast) { return toast.id === id; })) ? void 0 : _Object$values$flat$f.position; }, toastStore = (state = initialState = { top: [], "top-left": [], "top-right": [], "bottom-left": [], bottom: [], "bottom-right": [] }, listeners = new Set(), setState = function(setStateFn) { state = setStateFn(state), listeners.forEach(function(l) { return l(); }); }, { getState: function() { return state; }, subscribe: function(listener) { return listeners.add(listener), function() { // Delete all toasts on unmount setState(function() { return initialState; }), listeners.delete(listener); }; }, /** * Delete a toast record at its position */ removeToast: function(id, position) { setState(function(prevState) { var _extends2; return chakra_ui_toast_esm_extends({}, prevState, ((_extends2 = {})[position] = prevState[position].filter(function(toast) { return toast.id != id; }), _extends2)); }); }, notify: function(message, options) { var options1, _options$id, _options$position, id, position, toast = (void 0 === (options1 = options) && (options1 = {}), counter += 1, { id: id = null != (_options$id = options1.id) ? _options$id : counter, message: message, position: position = null != (_options$position = options1.position) ? _options$position : "bottom", duration: options1.duration, onCloseComplete: options1.onCloseComplete, onRequestRemove: function() { return toastStore.removeToast(String(id), position); }, status: options1.status, requestClose: !1, containerStyle: options1.containerStyle }), position1 = toast.position, id1 = toast.id; return setState(function(prevToasts) { /** * - If the toast is positioned at the top edges, the * recent toast stacks on top of the other toasts. * * - If the toast is positioned at the bottom edges, the recent * toast stacks below the other toasts. */ var _prevToasts$position, _prevToasts$position2, _extends3, toasts = position1.includes("top") ? [ toast ].concat(null != (_prevToasts$position = prevToasts[position1]) ? _prevToasts$position : []) : [].concat(null != (_prevToasts$position2 = prevToasts[position1]) ? _prevToasts$position2 : [], [ toast ]); return chakra_ui_toast_esm_extends({}, prevToasts, ((_extends3 = {})[position1] = toasts, _extends3)); }), id1; }, update: function(id, options) { id && setState(function(prevState) { var options1, _options, render, _options$toastCompone, ToastComponent, nextState = chakra_ui_toast_esm_extends({}, prevState), _findToast = findToast(nextState, id), position = _findToast.position, index = _findToast.index; return position && -1 !== index && (nextState[position][index] = chakra_ui_toast_esm_extends({}, nextState[position][index], options, { message: (void 0 === (options1 = options) && (options1 = {}), render = (_options = options1).render, ToastComponent = void 0 === (_options$toastCompone = _options.toastComponent) ? Toast : _options$toastCompone, function(props) { return (0, chakra_ui_utils_esm /* isFunction */ .mf)(render) ? render(props) : /*#__PURE__*/ react.createElement(ToastComponent, chakra_ui_toast_esm_extends({}, props, options1)); }) })), nextState; }); }, closeAll: function(_temp) { var positions = (void 0 === _temp ? {} : _temp).positions; // only one setState here for perf reasons // instead of spamming this.closeToast setState(function(prev) { return (null != positions ? positions : [ "bottom", "bottom-right", "bottom-left", "top", "top-left", "top-right" ]).reduce(function(acc, position) { return acc[position] = prev[position].map(function(toast) { return chakra_ui_toast_esm_extends({}, toast, { requestClose: !0 }); }), acc; }, chakra_ui_toast_esm_extends({}, prev)); }); }, close: function(id) { setState(function(prevState) { var _extends4, position = getToastPosition(prevState, id); return position ? chakra_ui_toast_esm_extends({}, prevState, ((_extends4 = {})[position] = prevState[position].map(function(toast) { return(// id may be string or number // eslint-disable-next-line eqeqeq toast.id == id ? chakra_ui_toast_esm_extends({}, toast, { requestClose: !0 }) : toast); }), _extends4)) : prevState; }); }, isActive: function(id) { return !!findToast(toastStore.getState(), id).position; } }), counter = 0, Toast = function(props) { var status = props.status, _props$variant = props.variant, id = props.id, title = props.title, isClosable = props.isClosable, onClose = props.onClose, description = props.description, icon = props.icon, alertTitleId = void 0 !== id ? "toast-" + id + "-title" : void 0; return /*#__PURE__*/ react.createElement(chakra_ui_alert_esm_Alert, { status: status, variant: void 0 === _props$variant ? "solid" : _props$variant, id: String(id), alignItems: "start", borderRadius: "md", boxShadow: "lg", paddingEnd: 8, textAlign: "start", width: "auto", "aria-labelledby": alertTitleId }, /*#__PURE__*/ react.createElement(AlertIcon, null, icon), /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, { flex: "1", maxWidth: "100%" }, title && /*#__PURE__*/ react.createElement(AlertTitle, { id: alertTitleId }, title), description && /*#__PURE__*/ react.createElement(AlertDescription, { display: "block" }, description)), isClosable && /*#__PURE__*/ react.createElement(chakra_ui_close_button_esm_CloseButton, { size: "sm", onClick: onClose, position: "absolute", insetEnd: 1, top: 1 })); }, toastMotionVariants = { initial: function(props) { var _ref, position = props.position, dir = [ "top", "bottom" ].includes(position) ? "y" : "x", factor = [ "top-right", "bottom-right" ].includes(position) ? 1 : -1; return "bottom" === position && (factor = 1), (_ref = { opacity: 0 })[dir] = 24 * factor, _ref; }, animate: { opacity: 1, y: 0, x: 0, scale: 1, transition: { duration: 0.4, ease: [ 0.4, 0, 0.2, 1 ] } }, exit: { opacity: 0, scale: 0.85, transition: { duration: 0.2, ease: [ 0.4, 0, 1, 1 ] } } }, ToastComponent = /*#__PURE__*/ react.memo(function(props) { var id = props.id, message = props.message, onCloseComplete = props.onCloseComplete, onRequestRemove = props.onRequestRemove, _props$requestClose = props.requestClose, requestClose = void 0 !== _props$requestClose && _props$requestClose, _props$position = props.position, position = void 0 === _props$position ? "bottom" : _props$position, _props$duration = props.duration, duration = void 0 === _props$duration ? 5000 : _props$duration, containerStyle = props.containerStyle, _props$motionVariants = props.motionVariants, _props$toastSpacing = props.toastSpacing, toastSpacing = void 0 === _props$toastSpacing ? "0.5rem" : _props$toastSpacing, _React$useState = react.useState(duration), delay = _React$useState[0], setDelay = _React$useState[1], isPresent = (0, use_presence /* useIsPresent */ .hO)(); (0, chakra_ui_hooks_esm /* useUpdateEffect */ .rf)(function() { isPresent || null == onCloseComplete || onCloseComplete(); }, [ isPresent ]), (0, chakra_ui_hooks_esm /* useUpdateEffect */ .rf)(function() { setDelay(duration); }, [ duration ]); var close = function() { isPresent && onRequestRemove(); }; react.useEffect(function() { isPresent && requestClose && onRequestRemove(); }, [ isPresent, requestClose, onRequestRemove ]), (0, chakra_ui_hooks_esm /* useTimeout */ .KS)(close, delay); var containerStyles = react.useMemo(function() { return chakra_ui_toast_esm_extends({ pointerEvents: "auto", maxWidth: 560, minWidth: 300, margin: toastSpacing }, containerStyle); }, [ containerStyle, toastSpacing ]), toastStyle = react.useMemo(function() { var isRighty, isLefty, alignItems; return isRighty = position.includes("right"), isLefty = position.includes("left"), alignItems = "center", isRighty && (alignItems = "flex-end"), isLefty && (alignItems = "flex-start"), { display: "flex", flexDirection: "column", alignItems: alignItems }; }, [ position ]); return /*#__PURE__*/ react.createElement(motion /* motion.li */ .E.li, { layout: !0, className: "chakra-toast", variants: void 0 === _props$motionVariants ? toastMotionVariants : _props$motionVariants, initial: "initial", animate: "animate", exit: "exit", onHoverStart: function() { return setDelay(null); }, onHoverEnd: function() { return setDelay(duration); }, custom: { position: position }, style: toastStyle }, /*#__PURE__*/ react.createElement(chakra_ui_system_esm /* chakra.div */ .m$.div, { role: "status", "aria-atomic": "true", className: "chakra-toast__inner", __css: containerStyles }, (0, chakra_ui_utils_esm /* runIfFn */ .Pu)(message, { id: id, onClose: close }))); }); chakra_ui_utils_esm /* __DEV__ */ .Ts && (ToastComponent.displayName = "ToastComponent"); /** * Manages the creation, and removal of toasts * across all corners ("top", "bottom", etc.) */ var ToastProvider = function(props) { var state = react.useSyncExternalStore(toastStore.subscribe, toastStore.getState, toastStore.getState), children = props.children, motionVariants = props.motionVariants, _props$component = props.component, Component = void 0 === _props$component ? ToastComponent : _props$component, portalProps = props.portalProps, toastList = (0, chakra_ui_utils_esm /* objectKeys */ .Yd)(state).map(function(position) { var toasts = state[position]; return /*#__PURE__*/ react.createElement("ul", { role: "region", "aria-live": "polite", key: position, id: "chakra-toast-manager-" + position, style: { position: "fixed", zIndex: 5500, pointerEvents: "none", display: "flex", flexDirection: "column", margin: "top" === position || "bottom" === position ? "0 auto" : void 0, top: position.includes("top") ? "env(safe-area-inset-top, 0px)" : void 0, bottom: position.includes("bottom") ? "env(safe-area-inset-bottom, 0px)" : void 0, right: position.includes("left") ? void 0 : "env(safe-area-inset-right, 0px)", left: position.includes("right") ? void 0 : "env(safe-area-inset-left, 0px)" } }, /*#__PURE__*/ react.createElement(AnimatePresence /* AnimatePresence */ .M, { initial: !1 }, toasts.map(function(toast) { return /*#__PURE__*/ react.createElement(Component, chakra_ui_toast_esm_extends({ key: toast.id, motionVariants: motionVariants }, toast)); }))); }); return /*#__PURE__*/ react.createElement(react.Fragment, null, children, /*#__PURE__*/ react.createElement(Portal, portalProps, toastList)); }; chakra_ui_utils_esm /* noop */ .ZT, chakra_ui_utils_esm /* noop */ .ZT; var chakra_ui_react_esm_excluded = [ "children", "toastOptions" ], ChakraProvider = function(_ref) { var children = _ref.children, toastOptions = _ref.toastOptions, restProps = function(source, excluded) { if (null == source) return {}; var key, i, target = {}, sourceKeys = Object.keys(source); for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]); return target; }(_ref, chakra_ui_react_esm_excluded); return /*#__PURE__*/ react.createElement(chakra_ui_provider_esm_ChakraProvider, restProps, children, /*#__PURE__*/ react.createElement(ToastProvider, toastOptions)); }; ChakraProvider.defaultProps = { theme: theme }; /* harmony default export */ var _app = function(param) { var Component = param.Component, pageProps = param.pageProps; return /*#__PURE__*/ (0, jsx_runtime.jsx)(ChakraProvider, { children: /*#__PURE__*/ (0, jsx_runtime.jsx)(Component, function(target) { for(var i = 1; i < arguments.length; i++){ var source = null != arguments[i] ? arguments[i] : {}, ownKeys = Object.keys(source); "function" == typeof Object.getOwnPropertySymbols && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; }))), ownKeys.forEach(function(key) { var value; value = source[key], key in target ? Object.defineProperty(target, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }) : target[key] = value; }); } return target; }({}, pageProps)) }); }; /***/ } }, /******/ function(__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }; /******/ __webpack_require__.O(0, [ 774, 179 ], function() { return __webpack_exec__(3837), __webpack_exec__(387); }), /******/ _N_E = __webpack_require__.O(); /******/ } ]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/cryptojs/input.js
JavaScript
export default (function (module, exports, __webpack_require__) { return (function (root, factory) { if (true) { // CommonJS module.exports = exports = factory(__webpack_require__(8249)); } else { } }(this, function (CryptoJS) { (function (Math) { // Shortcuts var C = CryptoJS; var C_lib = C.lib; var WordArray = C_lib.WordArray; var Hasher = C_lib.Hasher; var C_algo = C.algo; // Initialization and round constants tables var H = []; var K = []; // Compute constants (function () { function isPrime(n) { var sqrtN = Math.sqrt(n); for (var factor = 2; factor <= sqrtN; factor++) { if (!(n % factor)) { return false; } } return true; } function getFractionalBits(n) { return ((n - (n | 0)) * 0x100000000) | 0; } var n = 2; var nPrime = 0; while (nPrime < 64) { if (isPrime(n)) { if (nPrime < 8) { H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); } K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); nPrime++; } n++; } }()); // Reusable object var W = []; /** * SHA-256 hash algorithm. */ var SHA256 = C_algo.SHA256 = Hasher.extend({ _doReset: function () { this._hash = new WordArray.init(H.slice(0)); }, _doProcessBlock: function (M, offset) { // Shortcut var H = this._hash.words; // Working variables var a = H[0]; var b = H[1]; var c = H[2]; var d = H[3]; var e = H[4]; var f = H[5]; var g = H[6]; var h = H[7]; // Computation for (var i = 0; i < 64; i++) { if (i < 16) { W[i] = M[offset + i] | 0; } else { var gamma0x = W[i - 15]; var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ ((gamma0x << 14) | (gamma0x >>> 18)) ^ (gamma0x >>> 3); var gamma1x = W[i - 2]; var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ ((gamma1x << 13) | (gamma1x >>> 19)) ^ (gamma1x >>> 10); W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; } var ch = (e & f) ^ (~e & g); var maj = (a & b) ^ (a & c) ^ (b & c); var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); var t1 = h + sigma1 + ch + K[i] + W[i]; var t2 = sigma0 + maj; h = g; g = f; f = e; e = (d + t1) | 0; d = c; c = b; b = a; a = (t1 + t2) | 0; } // Intermediate hash value H[0] = (H[0] + a) | 0; H[1] = (H[1] + b) | 0; H[2] = (H[2] + c) | 0; H[3] = (H[3] + d) | 0; H[4] = (H[4] + e) | 0; H[5] = (H[5] + f) | 0; H[6] = (H[6] + g) | 0; H[7] = (H[7] + h) | 0; }, _doFinalize: function () { // Shortcuts var data = this._data; var dataWords = data.words; var nBitsTotal = this._nDataBytes * 8; var nBitsLeft = data.sigBytes * 8; // Add padding dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; data.sigBytes = dataWords.length * 4; // Hash final blocks this._process(); // Return final computed hash return this._hash; }, clone: function () { var clone = Hasher.clone.call(this); clone._hash = this._hash.clone(); return clone; } }); /** * Shortcut function to the hasher's object interface. * * @param {WordArray|string} message The message to hash. * * @return {WordArray} The hash. * * @static * * @example * * var hash = CryptoJS.SHA256('message'); * var hash = CryptoJS.SHA256(wordArray); */ C.SHA256 = Hasher._createHelper(SHA256); /** * Shortcut function to the HMAC's object interface. * * @param {WordArray|string} message The message to hash. * @param {WordArray|string} key The secret key. * * @return {WordArray} The HMAC. * * @static * * @example * * var hmac = CryptoJS.HmacSHA256(message, key); */ C.HmacSHA256 = Hasher._createHmacHelper(SHA256); }(Math)); return CryptoJS.SHA256; })); /***/ })
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/cryptojs/output.js
JavaScript
export default function(r, t, e) { var n, o, s, a, i, h, c, l, f, u; n = e(8249), o = Math, a = (s = n.lib).WordArray, i = s.Hasher, h = n.algo, c = [], l = [], // Compute constants function() { function r(r) { return (r - (0 | r)) * 0x100000000 | 0; } for(var t = 2, e = 0; e < 64;)(function(r) { for(var t = o.sqrt(r), e = 2; e <= t; e++)if (!(r % e)) return !1; return !0; })(t) && (e < 8 && (c[e] = r(o.pow(t, 0.5))), l[e] = r(o.pow(t, 1 / 3)), e++), t++; }(), f = [], u = h.SHA256 = i.extend({ _doReset: function() { this._hash = new a.init(c.slice(0)); }, _doProcessBlock: function(r, t) { // Computation for(var e = this._hash.words, n = e[0], o = e[1], s = e[2], a = e[3], i = e[4], h = e[5], c = e[6], u = e[7], _ = 0; _ < 64; _++){ if (_ < 16) f[_] = 0 | r[t + _]; else { var d = f[_ - 15], H = (d << 25 | d >>> 7) ^ (d << 14 | d >>> 18) ^ d >>> 3, v = f[_ - 2], p = (v << 15 | v >>> 17) ^ (v << 13 | v >>> 19) ^ v >>> 10; f[_] = H + f[_ - 7] + p + f[_ - 16]; } var w = i & h ^ ~i & c, x = n & o ^ n & s ^ o & s, A = (n << 30 | n >>> 2) ^ (n << 19 | n >>> 13) ^ (n << 10 | n >>> 22), g = u + ((i << 26 | i >>> 6) ^ (i << 21 | i >>> 11) ^ (i << 7 | i >>> 25)) + w + l[_] + f[_], y = A + x; u = c, c = h, h = i, i = a + g | 0, a = s, s = o, o = n, n = g + y | 0; } // Intermediate hash value e[0] = e[0] + n | 0, e[1] = e[1] + o | 0, e[2] = e[2] + s | 0, e[3] = e[3] + a | 0, e[4] = e[4] + i | 0, e[5] = e[5] + h | 0, e[6] = e[6] + c | 0, e[7] = e[7] + u | 0; }, _doFinalize: function() { // Shortcuts var r = this._data, t = r.words, e = 8 * this._nDataBytes, n = 8 * r.sigBytes; // Return final computed hash return(// Add padding t[n >>> 5] |= 0x80 << 24 - n % 32, t[(n + 64 >>> 9 << 4) + 14] = o.floor(e / 0x100000000), t[(n + 64 >>> 9 << 4) + 15] = e, r.sigBytes = 4 * t.length, // Hash final blocks this._process(), this._hash); }, clone: function() { var r = i.clone.call(this); return r._hash = this._hash.clone(), r; } }), /** * Shortcut function to the hasher's object interface. * * @param {WordArray|string} message The message to hash. * * @return {WordArray} The hash. * * @static * * @example * * var hash = CryptoJS.SHA256('message'); * var hash = CryptoJS.SHA256(wordArray); */ n.SHA256 = i._createHelper(u), /** * Shortcut function to the HMAC's object interface. * * @param {WordArray|string} message The message to hash. * @param {WordArray|string} key The secret key. * * @return {WordArray} The HMAC. * * @static * * @example * * var hmac = CryptoJS.HmacSHA256(message, key); */ n.HmacSHA256 = i._createHmacHelper(u), // CommonJS r.exports = n.SHA256; /***/ }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/exceljs/input.js
JavaScript
export default function (t, e, r) { "use strict"; function n(t) { return (n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t })(t) } function i(t, e) { for (var r = 0; r < e.length; r++) { var n = e[r]; n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) } } function o(t, e) { return (o = Object.setPrototypeOf || function (t, e) { return t.__proto__ = e, t })(t, e) } function a(t) { var e = function () { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], (function () { }))), !0 } catch (t) { return !1 } }(); return function () { var r, n = u(t); if (e) { var i = u(this).constructor; r = Reflect.construct(n, arguments, i) } else r = n.apply(this, arguments); return s(this, r) } } function s(t, e) { return !e || "object" !== n(e) && "function" != typeof e ? function (t) { if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t }(t) : e } function u(t) { return (u = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t) })(t) } var c = function (t) { ! function (t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), e && o(t, e) }(u, t); var e, r, n, s = a(u); function u(t) { var e; return function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") }(this, u), (e = s.call(this))._model = t, e } return e = u, (r = [{ key: "render", value: function (t, e, r) { (e === r[2] || "x:SizeWithCells" === this.tag && e === r[1]) && t.leafNode(this.tag) } }, { key: "parseOpen", value: function (t) { switch (t.name) { case this.tag: return this.model = {}, this.model[this.tag] = !0, !0; default: return !1 } } }, { key: "parseText", value: function () { } }, { key: "parseClose", value: function () { return !1 } }, { key: "tag", get: function () { return this._model && this._model.tag } }]) && i(e.prototype, r), n && i(e, n), u }(t("../../base-xform")); e.exports = c }, { "../../base-xform": 31 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/exceljs/output.js
JavaScript
module.exports = (function t(e, r, c) { function i(l, p) { if (!r[l]) { if (!e[l]) { if (f) return f(l, !0); var y = Error("Cannot find module '" + l + "'"); throw y.code = "MODULE_NOT_FOUND", y; } var h = r[l] = { exports: {} }; e[l][0].call(h.exports, function(r) { return i(e[l][1][r] || r); }, h, h.exports, t, e, r, c); } return r[l].exports; } for(var f = void 0, l = 0; l < c.length; l++)i(c[l]); return i; })({ 40: [ function(e, r, c) { "use strict"; function n(e) { return (n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { return typeof e; } : function(e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; })(e); } function i(e, r) { for(var c = 0; c < r.length; c++){ var f = r[c]; f.enumerable = f.enumerable || !1, f.configurable = !0, "value" in f && (f.writable = !0), Object.defineProperty(e, f.key, f); } } function o(e, r) { return (o = Object.setPrototypeOf || function(e, r) { return e.__proto__ = r, e; })(e, r); } function a(e) { var r = function() { if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0; } catch (e) { return !1; } }(); return function() { var c, f = u(e); if (r) { var l = u(this).constructor; c = Reflect.construct(f, arguments, l); } else c = f.apply(this, arguments); return s(this, c); }; } function s(e, r) { return r && ("object" === n(r) || "function" == typeof r) ? r : function(e) { if (void 0 === e) throw ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }(e); } function u(e) { return (u = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) { return e.__proto__ || Object.getPrototypeOf(e); })(e); } var f = function(e) { !function(e, r) { if ("function" != typeof r && null !== r) throw TypeError("Super expression must either be null or a function"); e.prototype = Object.create(r && r.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), r && o(e, r); }(u, e); var r, c, f = a(u); function u(e) { var r; return function(e, r) { if (!(e instanceof r)) throw TypeError("Cannot call a class as a function"); }(this, u), (r = f.call(this))._model = e, r; } return i((r = u).prototype, [ { key: "render", value: function(e, r, c) { (r === c[2] || "x:SizeWithCells" === this.tag && r === c[1]) && e.leafNode(this.tag); } }, { key: "parseOpen", value: function(e) { return e.name === this.tag && (this.model = {}, this.model[this.tag] = !0, !0); } }, { key: "parseText", value: function() {} }, { key: "parseClose", value: function() { return !1; } }, { key: "tag", get: function() { return this._model && this._model.tag; } } ]), c && i(r, c), u; }(e("../../base-xform")); r.exports = f; }, { "../../base-xform": 31 } ] }, {}, [ 15 ])(15);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feeback-plotly/1/input.js
JavaScript
export function log2(v) { var r, shift; r = (v > 0xffff) << 4; v >>>= r; shift = (v > 0xff) << 3; v >>>= shift; r |= shift; shift = (v > 0xf) << 2; v >>>= shift; r |= shift; shift = (v > 0x3) << 1; v >>>= shift; r |= shift; return r | (v >> 1); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feeback-plotly/1/output.js
JavaScript
export function log2(v) { var r, shift; return r = (v > 0xffff) << 4, v >>>= r, shift = (v > 0xff) << 3, v >>>= shift, r |= shift, shift = (v > 0xf) << 2, v >>>= shift, r |= shift, shift = (v > 0x3) << 1, v >>>= shift, (r |= shift) | v >> 1; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feedback-1/reduced/1/input.js
JavaScript
export function getInsertStringLength(a, e, t, i) { var r = a.mask, o = a.maskChar, n = t.split(""), s = i; return ( n.every(function (e) { for (; (n = e), isPermanentCharacter(a, (t = i)) && n !== r[t]; ) if (++i >= r.length) return !1; var t, n; return ( (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length ); }), i - s ); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feedback-1/reduced/1/output.js
JavaScript
export function getInsertStringLength(a, e, t, i) { var r = a.mask, o = a.maskChar, n = t.split(""), s = i; return n.every(function(e) { for(var t; isPermanentCharacter(a, t = i) && e !== r[t];)if (++i >= r.length) return !1; return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length; }), i - s; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/input.js
JavaScript
// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // This is CodeMirror (https://codemirror.net), a code editor // implemented in JavaScript on top of the browser's DOM. // // You can find some technical background for some of the code below // at http://marijnhaverbeke.nl/blog/#cm-internals . (function (global, factory) { typeof exports === "object" && typeof module !== "undefined" ? (module.exports = factory()) : typeof define === "function" && define.amd ? define(factory) : ((global = global || self), (global.CodeMirror = factory())); })(this, function () { "use strict"; // Kludges for bugs and behavior differences that can't be feature // detected are enabled based on userAgent etc sniffing. var userAgent = navigator.userAgent; var platform = navigator.platform; var gecko = /gecko\/\d/i.test(userAgent); var ie_upto10 = /MSIE \d/.test(userAgent); var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); var edge = /Edge\/(\d+)/.exec(userAgent); var ie = ie_upto10 || ie_11up || edge; var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]); var webkit = !edge && /WebKit\//.test(userAgent); var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); var chrome = !edge && /Chrome\//.test(userAgent); var presto = /Opera\//.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var phantom = /PhantomJS/.test(userAgent); var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2); var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); var mac = ios || /Mac/.test(platform); var chromeOS = /\bCrOS\b/.test(userAgent); var windows = /win/i.test(platform); var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); if (presto_version) { presto_version = Number(presto_version[1]); } if (presto_version && presto_version >= 15) { presto = false; webkit = true; } // Some browsers use the wrong event properties to signal cmd/ctrl on OS X var flipCtrlCmd = mac && (qtwebkit || (presto && (presto_version == null || presto_version < 12.11))); var captureRightClick = gecko || (ie && ie_version >= 9); function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); } var rmClass = function (node, cls) { var current = node.className; var match = classTest(cls).exec(current); if (match) { var after = current.slice(match.index + match[0].length); node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); } }; function removeChildren(e) { for (var count = e.childNodes.length; count > 0; --count) { e.removeChild(e.firstChild); } return e; } function removeChildrenAndAdd(parent, e) { return removeChildren(parent).appendChild(e); } function elt(tag, content, className, style) { var e = document.createElement(tag); if (className) { e.className = className; } if (style) { e.style.cssText = style; } if (typeof content == "string") { e.appendChild(document.createTextNode(content)); } else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } } return e; } // wrapper for elt, which removes the elt from the accessibility tree function eltP(tag, content, className, style) { var e = elt(tag, content, className, style); e.setAttribute("role", "presentation"); return e; } var range; if (document.createRange) { range = function (node, start, end, endNode) { var r = document.createRange(); r.setEnd(endNode || node, end); r.setStart(node, start); return r; }; } else { range = function (node, start, end) { var r = document.body.createTextRange(); try { r.moveToElementText(node.parentNode); } catch (e) { return r; } r.collapse(true); r.moveEnd("character", end); r.moveStart("character", start); return r; }; } function contains(parent, child) { if (child.nodeType == 3) { // Android browser always returns false when child is a textnode child = child.parentNode; } if (parent.contains) { return parent.contains(child); } do { if (child.nodeType == 11) { child = child.host; } if (child == parent) { return true; } } while ((child = child.parentNode)); } function activeElt() { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. var activeElement; try { activeElement = document.activeElement; } catch (e) { activeElement = document.body || null; } while ( activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement ) { activeElement = activeElement.shadowRoot.activeElement; } return activeElement; } function addClass(node, cls) { var current = node.className; if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; } } function joinClasses(a, b) { var as = a.split(" "); for (var i = 0; i < as.length; i++) { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } } return b; } var selectInput = function (node) { node.select(); }; if (ios) { // Mobile Safari apparently has a bug where select() is broken. selectInput = function (node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; } else if (ie) { // Suppress mysterious IE10 errors selectInput = function (node) { try { node.select(); } catch (_e) {} }; } function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function () { return f.apply(null, args); }; } function copyObj(obj, target, overwrite) { if (!target) { target = {}; } for (var prop in obj) { if ( obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)) ) { target[prop] = obj[prop]; } } return target; } // Counts the column offset in a string, taking tabs into account. // Used mostly to find indentation. function countColumn(string, end, tabSize, startIndex, startValue) { if (end == null) { end = string.search(/[^\s\u00a0]/); if (end == -1) { end = string.length; } } for (var i = startIndex || 0, n = startValue || 0; ; ) { var nextTab = string.indexOf("\t", i); if (nextTab < 0 || nextTab >= end) { return n + (end - i); } n += nextTab - i; n += tabSize - (n % tabSize); i = nextTab + 1; } } var Delayed = function () { this.id = null; this.f = null; this.time = 0; this.handler = bind(this.onTimeout, this); }; Delayed.prototype.onTimeout = function (self) { self.id = 0; if (self.time <= +new Date()) { self.f(); } else { setTimeout(self.handler, self.time - +new Date()); } }; Delayed.prototype.set = function (ms, f) { this.f = f; var time = +new Date() + ms; if (!this.id || time < this.time) { clearTimeout(this.id); this.id = setTimeout(this.handler, ms); this.time = time; } }; function indexOf(array, elt) { for (var i = 0; i < array.length; ++i) { if (array[i] == elt) { return i; } } return -1; } // Number of pixels added to scroller and sizer to hide scrollbar var scrollerGap = 50; // Returned or thrown by various protocols to signal 'I'm not // handling this'. var Pass = { toString: function () { return "CodeMirror.Pass"; }, }; // Reused option objects for setSelection & friends var sel_dontScroll = { scroll: false }, sel_mouse = { origin: "*mouse" }, sel_move = { origin: "+move" }; // The inverse of countColumn -- find the offset that corresponds to // a particular column. function findColumn(string, goal, tabSize) { for (var pos = 0, col = 0; ; ) { var nextTab = string.indexOf("\t", pos); if (nextTab == -1) { nextTab = string.length; } var skipped = nextTab - pos; if (nextTab == string.length || col + skipped >= goal) { return pos + Math.min(skipped, goal - col); } col += nextTab - pos; col += tabSize - (col % tabSize); pos = nextTab + 1; if (col >= goal) { return pos; } } } var spaceStrs = [""]; function spaceStr(n) { while (spaceStrs.length <= n) { spaceStrs.push(lst(spaceStrs) + " "); } return spaceStrs[n]; } function lst(arr) { return arr[arr.length - 1]; } function map(array, f) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); } return out; } function insertSorted(array, value, score) { var pos = 0, priority = score(value); while (pos < array.length && score(array[pos]) <= priority) { pos++; } array.splice(pos, 0, value); } function nothing() {} function createObj(base, props) { var inst; if (Object.create) { inst = Object.create(base); } else { nothing.prototype = base; inst = new nothing(); } if (props) { copyObj(props, inst); } return inst; } var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function isWordCharBasic(ch) { return ( /\w/.test(ch) || (ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))) ); } function isWordChar(ch, helper) { if (!helper) { return isWordCharBasic(ch); } if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true; } return helper.test(ch); } function isEmpty(obj) { for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false; } } return true; } // Extending unicode characters. A series of a non-extending char + // any number of extending chars is treated as a single unit as far // as editing and measuring is concerned. This is not fully correct, // since some scripts/fonts/browsers also treat other configurations // of code points as a group. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); } // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range. function skipExtendingChars(str, pos, dir) { while ( (dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos)) ) { pos += dir; } return pos; } // Returns the value from the range [`from`; `to`] that satisfies // `pred` and is closest to `from`. Assumes that at least `to` // satisfies `pred`. Supports `from` being greater than `to`. function findFirst(pred, from, to) { // At any point we are certain `to` satisfies `pred`, don't know // whether `from` does. var dir = from > to ? -1 : 1; for (;;) { if (from == to) { return from; } var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); if (mid == from) { return pred(mid) ? from : to; } if (pred(mid)) { to = mid; } else { from = mid + dir; } } } // BIDI HELPERS function iterateBidiSections(order, from, to, f) { if (!order) { return f(from, to, "ltr", 0); } var found = false; for (var i = 0; i < order.length; ++i) { var part = order[i]; if ( (part.from < to && part.to > from) || (from == to && part.to == from) ) { f( Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i ); found = true; } } if (!found) { f(from, to, "ltr"); } } var bidiOther = null; function getBidiPartAt(order, ch, sticky) { var found; bidiOther = null; for (var i = 0; i < order.length; ++i) { var cur = order[i]; if (cur.from < ch && cur.to > ch) { return i; } if (cur.to == ch) { if (cur.from != cur.to && sticky == "before") { found = i; } else { bidiOther = i; } } if (cur.from == ch) { if (cur.from != cur.to && sticky != "before") { found = i; } else { bidiOther = i; } } } return found != null ? found : bidiOther; } // Bidirectional ordering algorithm // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm // that this (partially) implements. // One-char codes used for character types: // L (L): Left-to-Right // R (R): Right-to-Left // r (AL): Right-to-Left Arabic // 1 (EN): European Number // + (ES): European Number Separator // % (ET): European Number Terminator // n (AN): Arabic Number // , (CS): Common Number Separator // m (NSM): Non-Spacing Mark // b (BN): Boundary Neutral // s (B): Paragraph Separator // t (S): Segment Separator // w (WS): Whitespace // N (ON): Other Neutrals // Returns null if characters are ordered as they appear // (left-to-right), or an array of sections ({from, to, level} // objects) in the order in which they occur visually. var bidiOrdering = (function () { // Character types for codepoints 0 to 0xff var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; // Character types for codepoints 0x600 to 0x6f9 var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"; function charType(code) { if (code <= 0xf7) { return lowTypes.charAt(code); } else if (0x590 <= code && code <= 0x5f4) { return "R"; } else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600); } else if (0x6ee <= code && code <= 0x8ac) { return "r"; } else if (0x2000 <= code && code <= 0x200b) { return "w"; } else if (code == 0x200c) { return "b"; } else { return "L"; } } var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; function BidiSpan(level, from, to) { this.level = level; this.from = from; this.to = to; } return function (str, direction) { var outerType = direction == "ltr" ? "L" : "R"; if (str.length == 0 || (direction == "ltr" && !bidiRE.test(str))) { return false; } var len = str.length, types = []; for (var i = 0; i < len; ++i) { types.push(charType(str.charCodeAt(i))); } // W1. Examine each non-spacing mark (NSM) in the level run, and // change the type of the NSM to the type of the previous // character. If the NSM is at the start of the level run, it will // get the type of sor. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) { var type = types[i$1]; if (type == "m") { types[i$1] = prev; } else { prev = type; } } // W2. Search backwards from each instance of a European number // until the first strong type (R, L, AL, or sor) is found. If an // AL is found, change the type of the European number to Arabic // number. // W3. Change all ALs to R. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) { var type$1 = types[i$2]; if (type$1 == "1" && cur == "r") { types[i$2] = "n"; } else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } } } // W4. A single European separator between two European numbers // changes to a European number. A single common separator between // two numbers of the same type changes to that type. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) { var type$2 = types[i$3]; if (type$2 == "+" && prev$1 == "1" && types[i$3 + 1] == "1") { types[i$3] = "1"; } else if ( type$2 == "," && prev$1 == types[i$3 + 1] && (prev$1 == "1" || prev$1 == "n") ) { types[i$3] = prev$1; } prev$1 = type$2; } // W5. A sequence of European terminators adjacent to European // numbers changes to all European numbers. // W6. Otherwise, separators and terminators change to Other // Neutral. for (var i$4 = 0; i$4 < len; ++i$4) { var type$3 = types[i$4]; if (type$3 == ",") { types[i$4] = "N"; } else if (type$3 == "%") { var end = void 0; for ( end = i$4 + 1; end < len && types[end] == "%"; ++end ) {} var replace = (i$4 && types[i$4 - 1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; for (var j = i$4; j < end; ++j) { types[j] = replace; } i$4 = end - 1; } } // W7. Search backwards from each instance of a European number // until the first strong type (R, L, or sor) is found. If an L is // found, then change the type of the European number to L. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) { var type$4 = types[i$5]; if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; } else if (isStrong.test(type$4)) { cur$1 = type$4; } } // N1. A sequence of neutrals takes the direction of the // surrounding strong text if the text on both sides has the same // direction. European and Arabic numbers act as if they were R in // terms of their influence on neutrals. Start-of-level-run (sor) // and end-of-level-run (eor) are used at level run boundaries. // N2. Any remaining neutrals take the embedding direction. for (var i$6 = 0; i$6 < len; ++i$6) { if (isNeutral.test(types[i$6])) { var end$1 = void 0; for ( end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1 ) {} var before = (i$6 ? types[i$6 - 1] : outerType) == "L"; var after = (end$1 < len ? types[end$1] : outerType) == "L"; var replace$1 = before == after ? (before ? "L" : "R") : outerType; for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; } i$6 = end$1 - 1; } } // Here we depart from the documented algorithm, in order to avoid // building up an actual levels array. Since there are only three // levels (0, 1, 2) in an implementation that doesn't take // explicit embedding into account, we can build up the order on // the fly, without following the level-based algorithm. var order = [], m; for (var i$7 = 0; i$7 < len; ) { if (countsAsLeft.test(types[i$7])) { var start = i$7; for ( ++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7 ) {} order.push(new BidiSpan(0, start, i$7)); } else { var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0; for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {} for (var j$2 = pos; j$2 < i$7; ) { if (countsAsNum.test(types[j$2])) { if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; } var nstart = j$2; for ( ++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2 ) {} order.splice(at, 0, new BidiSpan(2, nstart, j$2)); at += isRTL; pos = j$2; } else { ++j$2; } } if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); } } } if (direction == "ltr") { if (order[0].level == 1 && (m = str.match(/^\s+/))) { order[0].from = m[0].length; order.unshift(new BidiSpan(0, 0, m[0].length)); } if (lst(order).level == 1 && (m = str.match(/\s+$/))) { lst(order).to -= m[0].length; order.push(new BidiSpan(0, len - m[0].length, len)); } } return direction == "rtl" ? order.reverse() : order; }; })(); // Get the bidi ordering for the given line (and cache it). Returns // false for lines that are fully left-to-right, and an array of // BidiSpan objects otherwise. function getOrder(line, direction) { var order = line.order; if (order == null) { order = line.order = bidiOrdering(line.text, direction); } return order; } // EVENT HANDLING // Lightweight event framework. on/off also work on DOM nodes, // registering native DOM handlers. var noHandlers = []; var on = function (emitter, type, f) { if (emitter.addEventListener) { emitter.addEventListener(type, f, false); } else if (emitter.attachEvent) { emitter.attachEvent("on" + type, f); } else { var map = emitter._handlers || (emitter._handlers = {}); map[type] = (map[type] || noHandlers).concat(f); } }; function getHandlers(emitter, type) { return (emitter._handlers && emitter._handlers[type]) || noHandlers; } function off(emitter, type, f) { if (emitter.removeEventListener) { emitter.removeEventListener(type, f, false); } else if (emitter.detachEvent) { emitter.detachEvent("on" + type, f); } else { var map = emitter._handlers, arr = map && map[type]; if (arr) { var index = indexOf(arr, f); if (index > -1) { map[type] = arr .slice(0, index) .concat(arr.slice(index + 1)); } } } } function signal(emitter, type /*, values...*/) { var handlers = getHandlers(emitter, type); if (!handlers.length) { return; } var args = Array.prototype.slice.call(arguments, 2); for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); } } // The DOM events that CodeMirror handles can be overridden by // registering a (non-DOM) handler on the editor for the event name, // and preventDefault-ing the event in that handler. function signalDOMEvent(cm, e, override) { if (typeof e == "string") { e = { type: e, preventDefault: function () { this.defaultPrevented = true; }, }; } signal(cm, override || e.type, cm, e); return e_defaultPrevented(e) || e.codemirrorIgnore; } function signalCursorActivity(cm) { var arr = cm._handlers && cm._handlers.cursorActivity; if (!arr) { return; } var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1) { set.push(arr[i]); } } } function hasHandler(emitter, type) { return getHandlers(emitter, type).length > 0; } // Add on and off methods to a constructor's prototype, to make // registering events on such objects more convenient. function eventMixin(ctor) { ctor.prototype.on = function (type, f) { on(this, type, f); }; ctor.prototype.off = function (type, f) { off(this, type, f); }; } // Due to the fact that we still support jurassic IE versions, some // compatibility wrappers are needed. function e_preventDefault(e) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } function e_stopPropagation(e) { if (e.stopPropagation) { e.stopPropagation(); } else { e.cancelBubble = true; } } function e_defaultPrevented(e) { return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; } function e_stop(e) { e_preventDefault(e); e_stopPropagation(e); } function e_target(e) { return e.target || e.srcElement; } function e_button(e) { var b = e.which; if (b == null) { if (e.button & 1) { b = 1; } else if (e.button & 2) { b = 3; } else if (e.button & 4) { b = 2; } } if (mac && e.ctrlKey && b == 1) { b = 3; } return b; } // Detect drag-and-drop var dragAndDrop = (function () { // There is *some* kind of drag-and-drop support in IE6-8, but I // couldn't get it to work yet. if (ie && ie_version < 9) { return false; } var div = elt("div"); return "draggable" in div || "dragDrop" in div; })(); var zwspSupported; function zeroWidthElement(measure) { if (zwspSupported == null) { var test = elt("span", "\u200b"); removeChildrenAndAdd( measure, elt("span", [test, document.createTextNode("x")]) ); if (measure.firstChild.offsetHeight != 0) { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); } } var node = zwspSupported ? elt("span", "\u200b") : elt( "span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px" ); node.setAttribute("cm-text", ""); return node; } // Feature-detect IE's crummy client rect reporting for bidi text var badBidiRects; function hasBadBidiRects(measure) { if (badBidiRects != null) { return badBidiRects; } var txt = removeChildrenAndAdd( measure, document.createTextNode("A\u062eA") ); var r0 = range(txt, 0, 1).getBoundingClientRect(); var r1 = range(txt, 1, 2).getBoundingClientRect(); removeChildren(measure); if (!r0 || r0.left == r0.right) { return false; } // Safari returns null in some cases (#2780) return (badBidiRects = r1.right - r0.right < 3); } // See if "".split is the broken IE version, if so, provide an // alternative way to split lines. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) { var pos = 0, result = [], l = string.length; while (pos <= l) { var nl = string.indexOf("\n", pos); if (nl == -1) { nl = string.length; } var line = string.slice( pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl ); var rt = line.indexOf("\r"); if (rt != -1) { result.push(line.slice(0, rt)); pos += rt + 1; } else { result.push(line); pos = nl + 1; } } return result; } : function (string) { return string.split(/\r\n?|\n/); }; var hasSelection = window.getSelection ? function (te) { try { return te.selectionStart != te.selectionEnd; } catch (e) { return false; } } : function (te) { var range; try { range = te.ownerDocument.selection.createRange(); } catch (e) {} if (!range || range.parentElement() != te) { return false; } return range.compareEndPoints("StartToEnd", range) != 0; }; var hasCopyEvent = (function () { var e = elt("div"); if ("oncopy" in e) { return true; } e.setAttribute("oncopy", "return;"); return typeof e.oncopy == "function"; })(); var badZoomedRects = null; function hasBadZoomedRects(measure) { if (badZoomedRects != null) { return badZoomedRects; } var node = removeChildrenAndAdd(measure, elt("span", "x")); var normal = node.getBoundingClientRect(); var fromRange = range(node, 0, 1).getBoundingClientRect(); return (badZoomedRects = Math.abs(normal.left - fromRange.left) > 1); } // Known modes, by name and by MIME var modes = {}, mimeModes = {}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) function defineMode(name, mode) { if (arguments.length > 2) { mode.dependencies = Array.prototype.slice.call(arguments, 2); } modes[name] = mode; } function defineMIME(mime, spec) { mimeModes[mime] = spec; } // Given a MIME type, a {name, ...options} config object, or a name // string, return a mode config object. function resolveMode(spec) { if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { spec = mimeModes[spec]; } else if ( spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name) ) { var found = mimeModes[spec.name]; if (typeof found == "string") { found = { name: found }; } spec = createObj(found, spec); spec.name = found.name; } else if ( typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec) ) { return resolveMode("application/xml"); } else if ( typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec) ) { return resolveMode("application/json"); } if (typeof spec == "string") { return { name: spec }; } else { return spec || { name: "null" }; } } // Given a mode spec (anything that resolveMode accepts), find and // initialize an actual mode object. function getMode(options, spec) { spec = resolveMode(spec); var mfactory = modes[spec.name]; if (!mfactory) { return getMode(options, "text/plain"); } var modeObj = mfactory(options, spec); if (modeExtensions.hasOwnProperty(spec.name)) { var exts = modeExtensions[spec.name]; for (var prop in exts) { if (!exts.hasOwnProperty(prop)) { continue; } if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } modeObj[prop] = exts[prop]; } } modeObj.name = spec.name; if (spec.helperType) { modeObj.helperType = spec.helperType; } if (spec.modeProps) { for (var prop$1 in spec.modeProps) { modeObj[prop$1] = spec.modeProps[prop$1]; } } return modeObj; } // This can be used to attach properties to mode objects from // outside the actual mode definition. var modeExtensions = {}; function extendMode(mode, properties) { var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); copyObj(properties, exts); } function copyState(mode, state) { if (state === true) { return state; } if (mode.copyState) { return mode.copyState(state); } var nstate = {}; for (var n in state) { var val = state[n]; if (val instanceof Array) { val = val.concat([]); } nstate[n] = val; } return nstate; } // Given a mode and a state (for that mode), find the inner mode and // state at the position that the state refers to. function innerMode(mode, state) { var info; while (mode.innerMode) { info = mode.innerMode(state); if (!info || info.mode == mode) { break; } state = info.state; mode = info.mode; } return info || { mode: mode, state: state }; } function startState(mode, a1, a2) { return mode.startState ? mode.startState(a1, a2) : true; } // STRING STREAM // Fed to the mode parsers, provides helper functions to make // parsers more succinct. var StringStream = function (string, tabSize, lineOracle) { this.pos = this.start = 0; this.string = string; this.tabSize = tabSize || 8; this.lastColumnPos = this.lastColumnValue = 0; this.lineStart = 0; this.lineOracle = lineOracle; }; StringStream.prototype.eol = function () { return this.pos >= this.string.length; }; StringStream.prototype.sol = function () { return this.pos == this.lineStart; }; StringStream.prototype.peek = function () { return this.string.charAt(this.pos) || undefined; }; StringStream.prototype.next = function () { if (this.pos < this.string.length) { return this.string.charAt(this.pos++); } }; StringStream.prototype.eat = function (match) { var ch = this.string.charAt(this.pos); var ok; if (typeof match == "string") { ok = ch == match; } else { ok = ch && (match.test ? match.test(ch) : match(ch)); } if (ok) { ++this.pos; return ch; } }; StringStream.prototype.eatWhile = function (match) { var start = this.pos; while (this.eat(match)) {} return this.pos > start; }; StringStream.prototype.eatSpace = function () { var start = this.pos; while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } return this.pos > start; }; StringStream.prototype.skipToEnd = function () { this.pos = this.string.length; }; StringStream.prototype.skipTo = function (ch) { var found = this.string.indexOf(ch, this.pos); if (found > -1) { this.pos = found; return true; } }; StringStream.prototype.backUp = function (n) { this.pos -= n; }; StringStream.prototype.column = function () { if (this.lastColumnPos < this.start) { this.lastColumnValue = countColumn( this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue ); this.lastColumnPos = this.start; } return ( this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) ); }; StringStream.prototype.indentation = function () { return ( countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) ); }; StringStream.prototype.match = function ( pattern, consume, caseInsensitive ) { if (typeof pattern == "string") { var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; var substr = this.string.substr(this.pos, pattern.length); if (cased(substr) == cased(pattern)) { if (consume !== false) { this.pos += pattern.length; } return true; } } else { var match = this.string.slice(this.pos).match(pattern); if (match && match.index > 0) { return null; } if (match && consume !== false) { this.pos += match[0].length; } return match; } }; StringStream.prototype.current = function () { return this.string.slice(this.start, this.pos); }; StringStream.prototype.hideFirstChars = function (n, inner) { this.lineStart += n; try { return inner(); } finally { this.lineStart -= n; } }; StringStream.prototype.lookAhead = function (n) { var oracle = this.lineOracle; return oracle && oracle.lookAhead(n); }; StringStream.prototype.baseToken = function () { var oracle = this.lineOracle; return oracle && oracle.baseToken(this.pos); }; // Find the line object corresponding to the given line number. function getLine(doc, n) { n -= doc.first; if (n < 0 || n >= doc.size) { throw new Error( "There is no line " + (n + doc.first) + " in the document." ); } var chunk = doc; while (!chunk.lines) { for (var i = 0; ; ++i) { var child = chunk.children[i], sz = child.chunkSize(); if (n < sz) { chunk = child; break; } n -= sz; } } return chunk.lines[n]; } // Get the part of a document between two positions, as an array of // strings. function getBetween(doc, start, end) { var out = [], n = start.line; doc.iter(start.line, end.line + 1, function (line) { var text = line.text; if (n == end.line) { text = text.slice(0, end.ch); } if (n == start.line) { text = text.slice(start.ch); } out.push(text); ++n; }); return out; } // Get the lines between from and to, as array of strings. function getLines(doc, from, to) { var out = []; doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value return out; } // Update the height of a line, propagating the height change // upwards to parent nodes. function updateLineHeight(line, height) { var diff = height - line.height; if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } } } // Given a line object, find its line number by walking up through // its parent links. function lineNo(line) { if (line.parent == null) { return null; } var cur = line.parent, no = indexOf(cur.lines, line); for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { for (var i = 0; ; ++i) { if (chunk.children[i] == cur) { break; } no += chunk.children[i].chunkSize(); } } return no + cur.first; } // Find the line at the given vertical position, using the height // information in the document tree. function lineAtHeight(chunk, h) { var n = chunk.first; outer: do { for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) { var child = chunk.children[i$1], ch = child.height; if (h < ch) { chunk = child; continue outer; } h -= ch; n += child.chunkSize(); } return n; } while (!chunk.lines); var i = 0; for (; i < chunk.lines.length; ++i) { var line = chunk.lines[i], lh = line.height; if (h < lh) { break; } h -= lh; } return n + i; } function isLine(doc, l) { return l >= doc.first && l < doc.first + doc.size; } function lineNumberFor(options, i) { return String(options.lineNumberFormatter(i + options.firstLineNumber)); } // A Pos instance represents a position within the text. function Pos(line, ch, sticky) { if (sticky === void 0) sticky = null; if (!(this instanceof Pos)) { return new Pos(line, ch, sticky); } this.line = line; this.ch = ch; this.sticky = sticky; } // Compare two positions, return 0 if they are the same, a negative // number when a is less, and a positive number otherwise. function cmp(a, b) { return a.line - b.line || a.ch - b.ch; } function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0; } function copyPos(x) { return Pos(x.line, x.ch); } function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; } function minPos(a, b) { return cmp(a, b) < 0 ? a : b; } // Most of the external API clips given positions to make sure they // actually exist within the document. function clipLine(doc, n) { return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1)); } function clipPos(doc, pos) { if (pos.line < doc.first) { return Pos(doc.first, 0); } var last = doc.first + doc.size - 1; if (pos.line > last) { return Pos(last, getLine(doc, last).text.length); } return clipToLen(pos, getLine(doc, pos.line).text.length); } function clipToLen(pos, linelen) { var ch = pos.ch; if (ch == null || ch > linelen) { return Pos(pos.line, linelen); } else if (ch < 0) { return Pos(pos.line, 0); } else { return pos; } } function clipPosArray(doc, array) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); } return out; } var SavedContext = function (state, lookAhead) { this.state = state; this.lookAhead = lookAhead; }; var Context = function (doc, state, line, lookAhead) { this.state = state; this.doc = doc; this.line = line; this.maxLookAhead = lookAhead || 0; this.baseTokens = null; this.baseTokenPos = 1; }; Context.prototype.lookAhead = function (n) { var line = this.doc.getLine(this.line + n); if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; } return line; }; Context.prototype.baseToken = function (n) { if (!this.baseTokens) { return null; } while (this.baseTokens[this.baseTokenPos] <= n) { this.baseTokenPos += 2; } var type = this.baseTokens[this.baseTokenPos + 1]; return { type: type && type.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - n, }; }; Context.prototype.nextLine = function () { this.line++; if (this.maxLookAhead > 0) { this.maxLookAhead--; } }; Context.fromSaved = function (doc, saved, line) { if (saved instanceof SavedContext) { return new Context( doc, copyState(doc.mode, saved.state), line, saved.lookAhead ); } else { return new Context(doc, copyState(doc.mode, saved), line); } }; Context.prototype.save = function (copy) { var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state; }; // Compute a style array (an array starting with a mode generation // -- for invalidation -- followed by pairs of end positions and // style strings), which is used to highlight the tokens on the // line. function highlightLine(cm, line, context, forceToEnd) { // A styles array always starts with a number identifying the // mode/overlays that it is based on (for easy invalidation). var st = [cm.state.modeGen], lineClasses = {}; // Compute the base array of styles runMode( cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); }, lineClasses, forceToEnd ); var state = context.state; // Run overlays, adjust style array. var loop = function (o) { context.baseTokens = st; var overlay = cm.state.overlays[o], i = 1, at = 0; context.state = true; runMode( cm, line.text, overlay.mode, context, function (end, style) { var start = i; // Ensure there's a token end at the current position, and that i points at it while (at < end) { var i_end = st[i]; if (i_end > end) { st.splice(i, 1, end, st[i + 1], i_end); } i += 2; at = Math.min(end, i_end); } if (!style) { return; } if (overlay.opaque) { st.splice(start, i - start, end, "overlay " + style); i = start + 2; } else { for (; start < i; start += 2) { var cur = st[start + 1]; st[start + 1] = (cur ? cur + " " : "") + "overlay " + style; } } }, lineClasses ); context.state = state; context.baseTokens = null; context.baseTokenPos = 1; }; for (var o = 0; o < cm.state.overlays.length; ++o) loop(o); return { styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null, }; } function getLineStyles(cm, line, updateFrontier) { if (!line.styles || line.styles[0] != cm.state.modeGen) { var context = getContextBefore(cm, lineNo(line)); var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state); var result = highlightLine(cm, line, context); if (resetState) { context.state = resetState; } line.stateAfter = context.save(!resetState); line.styles = result.styles; if (result.classes) { line.styleClasses = result.classes; } else if (line.styleClasses) { line.styleClasses = null; } if (updateFrontier === cm.doc.highlightFrontier) { cm.doc.modeFrontier = Math.max( cm.doc.modeFrontier, ++cm.doc.highlightFrontier ); } } return line.styles; } function getContextBefore(cm, n, precise) { var doc = cm.doc, display = cm.display; if (!doc.mode.startState) { return new Context(doc, true, n); } var start = findStartLine(cm, n, precise); var saved = start > doc.first && getLine(doc, start - 1).stateAfter; var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start); doc.iter(start, n, function (line) { processLine(cm, line.text, context); var pos = context.line; line.stateAfter = pos == n - 1 || pos % 5 == 0 || (pos >= display.viewFrom && pos < display.viewTo) ? context.save() : null; context.nextLine(); }); if (precise) { doc.modeFrontier = context.line; } return context; } // Lightweight form of highlight -- proceed over this line and // update state, but don't save a style array. Used for lines that // aren't currently visible. function processLine(cm, text, context, startAt) { var mode = cm.doc.mode; var stream = new StringStream(text, cm.options.tabSize, context); stream.start = stream.pos = startAt || 0; if (text == "") { callBlankLine(mode, context.state); } while (!stream.eol()) { readToken(mode, stream, context.state); stream.start = stream.pos; } } function callBlankLine(mode, state) { if (mode.blankLine) { return mode.blankLine(state); } if (!mode.innerMode) { return; } var inner = innerMode(mode, state); if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state); } } function readToken(mode, stream, state, inner) { for (var i = 0; i < 10; i++) { if (inner) { inner[0] = innerMode(mode, state).mode; } var style = mode.token(stream, state); if (stream.pos > stream.start) { return style; } } throw new Error("Mode " + mode.name + " failed to advance stream."); } var Token = function (stream, type, state) { this.start = stream.start; this.end = stream.pos; this.string = stream.current(); this.type = type || null; this.state = state; }; // Utility for getTokenAt and getLineTokens function takeToken(cm, pos, precise, asArray) { var doc = cm.doc, mode = doc.mode, style; pos = clipPos(doc, pos); var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise); var stream = new StringStream(line.text, cm.options.tabSize, context), tokens; if (asArray) { tokens = []; } while ((asArray || stream.pos < pos.ch) && !stream.eol()) { stream.start = stream.pos; style = readToken(mode, stream, context.state); if (asArray) { tokens.push( new Token(stream, style, copyState(doc.mode, context.state)) ); } } return asArray ? tokens : new Token(stream, style, context.state); } function extractLineClasses(type, output) { if (type) { for (;;) { var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!lineClass) { break; } type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); var prop = lineClass[1] ? "bgClass" : "textClass"; if (output[prop] == null) { output[prop] = lineClass[2]; } else if ( !new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)").test( output[prop] ) ) { output[prop] += " " + lineClass[2]; } } } return type; } // Run the given mode's parser over a line, calling f for each token. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { var flattenSpans = mode.flattenSpans; if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; } var curStart = 0, curStyle = null; var stream = new StringStream(text, cm.options.tabSize, context), style; var inner = cm.options.addModeClass && [null]; if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); } while (!stream.eol()) { if (stream.pos > cm.options.maxHighlightLength) { flattenSpans = false; if (forceToEnd) { processLine(cm, text, context, stream.pos); } stream.pos = text.length; style = null; } else { style = extractLineClasses( readToken(mode, stream, context.state, inner), lineClasses ); } if (inner) { var mName = inner[0].name; if (mName) { style = "m-" + (style ? mName + " " + style : mName); } } if (!flattenSpans || curStyle != style) { while (curStart < stream.start) { curStart = Math.min(stream.start, curStart + 5000); f(curStart, curStyle); } curStyle = style; } stream.start = stream.pos; } while (curStart < stream.pos) { // Webkit seems to refuse to render text nodes longer than 57444 // characters, and returns inaccurate measurements in nodes // starting around 5000 chars. var pos = Math.min(stream.pos, curStart + 5000); f(pos, curStyle); curStart = pos; } } // Finds the line to start with when starting a parse. Tries to // find a line with a stateAfter, so that it can start with a // valid state. If that fails, it returns the line with the // smallest indentation, which tends to need the least context to // parse correctly. function findStartLine(cm, n, precise) { var minindent, minline, doc = cm.doc; var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); for (var search = n; search > lim; --search) { if (search <= doc.first) { return doc.first; } var line = getLine(doc, search - 1), after = line.stateAfter; if ( after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier) ) { return search; } var indented = countColumn(line.text, null, cm.options.tabSize); if (minline == null || minindent > indented) { minline = search - 1; minindent = indented; } } return minline; } function retreatFrontier(doc, n) { doc.modeFrontier = Math.min(doc.modeFrontier, n); if (doc.highlightFrontier < n - 10) { return; } var start = doc.first; for (var line = n - 1; line > start; line--) { var saved = getLine(doc, line).stateAfter; // change is on 3 // state on line 1 looked ahead 2 -- so saw 3 // test 1 + 2 < 3 should cover this if ( saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n) ) { start = line + 1; break; } } doc.highlightFrontier = Math.min(doc.highlightFrontier, start); } // Optimize some code when these features are not used. var sawReadOnlySpans = false, sawCollapsedSpans = false; function seeReadOnlySpans() { sawReadOnlySpans = true; } function seeCollapsedSpans() { sawCollapsedSpans = true; } // TEXTMARKER SPANS function MarkedSpan(marker, from, to) { this.marker = marker; this.from = from; this.to = to; } // Search an array of spans for a span matching the given marker. function getMarkedSpanFor(spans, marker) { if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.marker == marker) { return span; } } } } // Remove a span from an array, returning undefined if no spans are // left (we don't store arrays for lines without spans). function removeMarkedSpan(spans, span) { var r; for (var i = 0; i < spans.length; ++i) { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } } return r; } // Add a span to a line. function addMarkedSpan(line, span, op) { var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet())); if (inThisOp && inThisOp.has(line.markedSpans)) { line.markedSpans.push(span); } else { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; if (inThisOp) { inThisOp.add(line.markedSpans); } } span.marker.attachLine(line); } // Used for the algorithm that adjusts markers for a change in the // document. These functions cut an array of spans at a given // character position, returning an array of remaining chunks (or // undefined if nothing remains). function markedSpansBefore(old, startCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); if ( startsBefore || (span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) ) { var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); (nw || (nw = [])).push( new MarkedSpan( marker, span.from, endsAfter ? null : span.to ) ); } } } return nw; } function markedSpansAfter(old, endCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); if ( endsAfter || (span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) ) { var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); (nw || (nw = [])).push( new MarkedSpan( marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh ) ); } } } return nw; } // Given a change object, compute the new set of marker spans that // cover the line in which the change took place. Removes spans // entirely within the change, reconnects spans belonging to the // same marker that appear on both sides of the change, and cuts off // spans partially within the change. Returns an array of span // arrays with one element for each line in (after) the change. function stretchSpansOverChange(doc, change) { if (change.full) { return null; } var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; if (!oldFirst && !oldLast) { return null; } var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; // Get the spans that 'stick out' on both sides var first = markedSpansBefore(oldFirst, startCh, isInsert); var last = markedSpansAfter(oldLast, endCh, isInsert); // Next, merge those two ends var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); if (first) { // Fix up .to properties of first for (var i = 0; i < first.length; ++i) { var span = first[i]; if (span.to == null) { var found = getMarkedSpanFor(last, span.marker); if (!found) { span.to = startCh; } else if (sameLine) { span.to = found.to == null ? null : found.to + offset; } } } } if (last) { // Fix up .from in last (or move them into first in case of sameLine) for (var i$1 = 0; i$1 < last.length; ++i$1) { var span$1 = last[i$1]; if (span$1.to != null) { span$1.to += offset; } if (span$1.from == null) { var found$1 = getMarkedSpanFor(first, span$1.marker); if (!found$1) { span$1.from = offset; if (sameLine) { (first || (first = [])).push(span$1); } } } else { span$1.from += offset; if (sameLine) { (first || (first = [])).push(span$1); } } } } // Make sure we didn't create any zero-length spans if (first) { first = clearEmptySpans(first); } if (last && last != first) { last = clearEmptySpans(last); } var newMarkers = [first]; if (!sameLine) { // Fill gap with whole-line-spans var gap = change.text.length - 2, gapMarkers; if (gap > 0 && first) { for (var i$2 = 0; i$2 < first.length; ++i$2) { if (first[i$2].to == null) { (gapMarkers || (gapMarkers = [])).push( new MarkedSpan(first[i$2].marker, null, null) ); } } } for (var i$3 = 0; i$3 < gap; ++i$3) { newMarkers.push(gapMarkers); } newMarkers.push(last); } return newMarkers; } // Remove spans that are empty and don't have a clearWhenEmpty // option of false. function clearEmptySpans(spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if ( span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false ) { spans.splice(i--, 1); } } if (!spans.length) { return null; } return spans; } // Used to 'clip' out readOnly ranges when making a change. function removeReadOnlyRanges(doc, from, to) { var markers = null; doc.iter(from.line, to.line + 1, function (line) { if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var mark = line.markedSpans[i].marker; if ( mark.readOnly && (!markers || indexOf(markers, mark) == -1) ) { (markers || (markers = [])).push(mark); } } } }); if (!markers) { return null; } var parts = [{ from: from, to: to }]; for (var i = 0; i < markers.length; ++i) { var mk = markers[i], m = mk.find(0); for (var j = 0; j < parts.length; ++j) { var p = parts[j]; if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue; } var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); if (dfrom < 0 || (!mk.inclusiveLeft && !dfrom)) { newParts.push({ from: p.from, to: m.from }); } if (dto > 0 || (!mk.inclusiveRight && !dto)) { newParts.push({ from: m.to, to: p.to }); } parts.splice.apply(parts, newParts); j += newParts.length - 3; } } return parts; } // Connect or disconnect spans from a line. function detachMarkedSpans(line) { var spans = line.markedSpans; if (!spans) { return; } for (var i = 0; i < spans.length; ++i) { spans[i].marker.detachLine(line); } line.markedSpans = null; } function attachMarkedSpans(line, spans) { if (!spans) { return; } for (var i = 0; i < spans.length; ++i) { spans[i].marker.attachLine(line); } line.markedSpans = spans; } // Helpers used when computing which overlapping collapsed span // counts as the larger one. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; } function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; } // Returns a number indicating which of two overlapping collapsed // spans is larger (and thus includes the other). Falls back to // comparing ids when the spans cover exactly the same range. function compareCollapsedMarkers(a, b) { var lenDiff = a.lines.length - b.lines.length; if (lenDiff != 0) { return lenDiff; } var aPos = a.find(), bPos = b.find(); var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); if (fromCmp) { return -fromCmp; } var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); if (toCmp) { return toCmp; } return b.id - a.id; } // Find out whether a line ends or starts in a collapsed span. If // so, return the marker for that span. function collapsedSpanAtSide(line, start) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) { sp = sps[i]; if ( sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0) ) { found = sp.marker; } } } return found; } function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); } function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); } function collapsedSpanAround(line, ch) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if ( sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && (!found || compareCollapsedMarkers(found, sp.marker) < 0) ) { found = sp.marker; } } } return found; } // Test whether there exists a collapsed span that partially // overlaps (covers the start or end, but not both) of a new span. // Such overlap is not allowed. function conflictingCollapsedRange(doc, lineNo, from, to, marker) { var line = getLine(doc, lineNo); var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (!sp.marker.collapsed) { continue; } var found = sp.marker.find(0); var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); if ( (fromCmp >= 0 && toCmp <= 0) || (fromCmp <= 0 && toCmp >= 0) ) { continue; } if ( (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0)) || (fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) ) { return true; } } } } // A visual line is a line as drawn on the screen. Folding, for // example, can cause multiple logical lines to appear on the same // visual line. This finds the start of the visual line that the // given line is part of (usually that is the line itself). function visualLine(line) { var merged; while ((merged = collapsedSpanAtStart(line))) { line = merged.find(-1, true).line; } return line; } function visualLineEnd(line) { var merged; while ((merged = collapsedSpanAtEnd(line))) { line = merged.find(1, true).line; } return line; } // Returns an array of logical lines that continue the visual line // started by the argument, or undefined if there are no such lines. function visualLineContinued(line) { var merged, lines; while ((merged = collapsedSpanAtEnd(line))) { line = merged.find(1, true).line; (lines || (lines = [])).push(line); } return lines; } // Get the line number of the start of the visual line that the // given line number is part of. function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); if (line == vis) { return lineN; } return lineNo(vis); } // Get the line number of the start of the next visual line after // the given line. function visualLineEndNo(doc, lineN) { if (lineN > doc.lastLine()) { return lineN; } var line = getLine(doc, lineN), merged; if (!lineIsHidden(doc, line)) { return lineN; } while ((merged = collapsedSpanAtEnd(line))) { line = merged.find(1, true).line; } return lineNo(line) + 1; } // Compute whether a line is hidden. Lines count as hidden when they // are part of a visual line that starts with another line, or when // they are entirely covered by collapsed, non-widget span. function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) { sp = sps[i]; if (!sp.marker.collapsed) { continue; } if (sp.from == null) { return true; } if (sp.marker.widgetNode) { continue; } if ( sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp) ) { return true; } } } } function lineIsHiddenInner(doc, line, span) { if (span.to == null) { var end = span.marker.find(1, true); return lineIsHiddenInner( doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker) ); } if (span.marker.inclusiveRight && span.to == line.text.length) { return true; } for (var sp = void 0, i = 0; i < line.markedSpans.length; ++i) { sp = line.markedSpans[i]; if ( sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp) ) { return true; } } } // Find the height above the given line. function heightAtLine(lineObj) { lineObj = visualLine(lineObj); var h = 0, chunk = lineObj.parent; for (var i = 0; i < chunk.lines.length; ++i) { var line = chunk.lines[i]; if (line == lineObj) { break; } else { h += line.height; } } for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { for (var i$1 = 0; i$1 < p.children.length; ++i$1) { var cur = p.children[i$1]; if (cur == chunk) { break; } else { h += cur.height; } } } return h; } // Compute the character length of a line, taking into account // collapsed ranges (see markText) that might hide parts, and join // other lines onto it. function lineLength(line) { if (line.height == 0) { return 0; } var len = line.text.length, merged, cur = line; while ((merged = collapsedSpanAtStart(cur))) { var found = merged.find(0, true); cur = found.from.line; len += found.from.ch - found.to.ch; } cur = line; while ((merged = collapsedSpanAtEnd(cur))) { var found$1 = merged.find(0, true); len -= cur.text.length - found$1.from.ch; cur = found$1.to.line; len += cur.text.length - found$1.to.ch; } return len; } // Find the longest line in the document. function findMaxLine(cm) { var d = cm.display, doc = cm.doc; d.maxLine = getLine(doc, doc.first); d.maxLineLength = lineLength(d.maxLine); d.maxLineChanged = true; doc.iter(function (line) { var len = lineLength(line); if (len > d.maxLineLength) { d.maxLineLength = len; d.maxLine = line; } }); } // LINE DATA STRUCTURE // Line objects. These hold state related to a line, including // highlighting info (the styles array). var Line = function (text, markedSpans, estimateHeight) { this.text = text; attachMarkedSpans(this, markedSpans); this.height = estimateHeight ? estimateHeight(this) : 1; }; Line.prototype.lineNo = function () { return lineNo(this); }; eventMixin(Line); // Change the content (text, markers) of a line. Automatically // invalidates cached information and tries to re-estimate the // line's height. function updateLine(line, text, markedSpans, estimateHeight) { line.text = text; if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } if (line.order != null) { line.order = null; } detachMarkedSpans(line); attachMarkedSpans(line, markedSpans); var estHeight = estimateHeight ? estimateHeight(line) : 1; if (estHeight != line.height) { updateLineHeight(line, estHeight); } } // Detach a line from the document tree and its markers. function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); } // Convert a style as returned by a mode (either null, or a string // containing one or more styles) to a CSS style. This is cached, // and also looks for line-wide styles. var styleToClassCache = {}, styleToClassCacheWithMode = {}; function interpretTokenStyle(style, options) { if (!style || /^\s*$/.test(style)) { return null; } var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&")); } // Render the DOM representation of the text of a line. Also builds // up a 'line map', which points at the DOM nodes that represent // specific stretches of text, and is used by the measuring code. // The returned object contains the DOM node, this map, and // information about line-wide styles that were set by the mode. function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = eltP( "span", null, null, webkit ? "padding-right: .1px" : null ); var builder = { pre: eltP("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, trailingSpace: false, splitSpaces: cm.getOption("lineWrapping"), }; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { var line = i ? lineView.rest[i - 1] : lineView.line, order = void 0; builder.pos = 0; builder.addToken = buildToken; // Optionally wire in some hacks into the token-rendering // algorithm, to deal with browser quirks. if ( hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)) ) { builder.addToken = buildTokenBadBidi(builder.addToken, order); } builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); insertLineContent( line, builder, getLineStyles(cm, line, allowFrontierUpdate) ); if (line.styleClasses) { if (line.styleClasses.bgClass) { builder.bgClass = joinClasses( line.styleClasses.bgClass, builder.bgClass || "" ); } if (line.styleClasses.textClass) { builder.textClass = joinClasses( line.styleClasses.textClass, builder.textClass || "" ); } } // Ensure at least a single node is present, for measuring. if (builder.map.length == 0) { builder.map.push( 0, 0, builder.content.appendChild( zeroWidthElement(cm.display.measure) ) ); } // Store the map and a cache object for the current logical line if (i == 0) { lineView.measure.map = builder.map; lineView.measure.cache = {}; } else { (lineView.measure.maps || (lineView.measure.maps = [])).push( builder.map ); ( lineView.measure.caches || (lineView.measure.caches = []) ).push({}); } } // See issue #2901 if (webkit) { var last = builder.content.lastChild; if ( /\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")) ) { builder.content.className = "cm-tab-wrap-hack"; } } signal(cm, "renderLine", cm, lineView.line, builder.pre); if (builder.pre.className) { builder.textClass = joinClasses( builder.pre.className, builder.textClass || "" ); } return builder; } function defaultSpecialCharPlaceholder(ch) { var token = elt("span", "\u2022", "cm-invalidchar"); token.title = "\\u" + ch.charCodeAt(0).toString(16); token.setAttribute("aria-label", token.title); return token; } // Build up the DOM representation for a single token, and add it to // the line map. Takes care to render special characters separately. function buildToken( builder, text, style, startStyle, endStyle, css, attributes ) { if (!text) { return; } var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text; var special = builder.cm.state.specialChars, mustWrap = false; var content; if (!special.test(text)) { builder.col += text.length; content = document.createTextNode(displayText); builder.map.push(builder.pos, builder.pos + text.length, content); if (ie && ie_version < 9) { mustWrap = true; } builder.pos += text.length; } else { content = document.createDocumentFragment(); var pos = 0; while (true) { special.lastIndex = pos; var m = special.exec(text); var skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode( displayText.slice(pos, pos + skipped) ); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); } else { content.appendChild(txt); } builder.map.push(builder.pos, builder.pos + skipped, txt); builder.col += skipped; builder.pos += skipped; } if (!m) { break; } pos += skipped + 1; var txt$1 = void 0; if (m[0] == "\t") { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - (builder.col % tabSize); txt$1 = content.appendChild( elt("span", spaceStr(tabWidth), "cm-tab") ); txt$1.setAttribute("role", "presentation"); txt$1.setAttribute("cm-text", "\t"); builder.col += tabWidth; } else if (m[0] == "\r" || m[0] == "\n") { txt$1 = content.appendChild( elt( "span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar" ) ); txt$1.setAttribute("cm-text", m[0]); builder.col += 1; } else { txt$1 = builder.cm.options.specialCharPlaceholder(m[0]); txt$1.setAttribute("cm-text", m[0]); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); } else { content.appendChild(txt$1); } builder.col += 1; } builder.map.push(builder.pos, builder.pos + 1, txt$1); builder.pos++; } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; if (style || startStyle || endStyle || mustWrap || css || attributes) { var fullStyle = style || ""; if (startStyle) { fullStyle += startStyle; } if (endStyle) { fullStyle += endStyle; } var token = elt("span", [content], fullStyle, css); if (attributes) { for (var attr in attributes) { if ( attributes.hasOwnProperty(attr) && attr != "style" && attr != "class" ) { token.setAttribute(attr, attributes[attr]); } } } return builder.content.appendChild(token); } builder.content.appendChild(content); } // Change some spaces to NBSP to prevent the browser from collapsing // trailing spaces at the end of a line when rendering text (issue #1362). function splitSpaces(text, trailingBefore) { if (text.length > 1 && !/ /.test(text)) { return text; } var spaceBefore = trailingBefore, result = ""; for (var i = 0; i < text.length; i++) { var ch = text.charAt(i); if ( ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32) ) { ch = "\u00a0"; } result += ch; spaceBefore = ch == " "; } return result; } // Work around nonsense dimensions being reported for stretches of // right-to-left text. function buildTokenBadBidi(inner, order) { return function ( builder, text, style, startStyle, endStyle, css, attributes ) { style = style ? style + " cm-force-border" : "cm-force-border"; var start = builder.pos, end = start + text.length; for (;;) { // Find the part that overlaps with the start of this text var part = void 0; for (var i = 0; i < order.length; i++) { part = order[i]; if (part.to > start && part.from <= start) { break; } } if (part.to >= end) { return inner( builder, text, style, startStyle, endStyle, css, attributes ); } inner( builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes ); startStyle = null; text = text.slice(part.to - start); start = part.to; } }; } function buildCollapsedSpan(builder, size, marker, ignoreWidget) { var widget = !ignoreWidget && marker.widgetNode; if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); } if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { if (!widget) { widget = builder.content.appendChild( document.createElement("span") ); } widget.setAttribute("cm-marker", marker.id); } if (widget) { builder.cm.display.input.setUneditable(widget); builder.content.appendChild(widget); } builder.pos += size; builder.trailingSpace = false; } // Outputs a number of spans to make up a line, taking highlighting // and marked text into account. function insertLineContent(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for (var i$1 = 1; i$1 < styles.length; i$1 += 2) { builder.addToken( builder, allText.slice(at, (at = styles[i$1])), interpretTokenStyle(styles[i$1 + 1], builder.cm.options) ); } return; } var len = allText.length, pos = 0, i = 1, text = "", style, css; var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes; for (;;) { if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = css = ""; attributes = null; collapsed = null; nextChange = Infinity; var foundBookmarks = [], endStyles = void 0; for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if ( m.type == "bookmark" && sp.from == pos && m.widgetNode ) { foundBookmarks.push(m); } else if ( sp.from <= pos && (sp.to == null || sp.to > pos || (m.collapsed && sp.to == pos && sp.from == pos)) ) { if ( sp.to != null && sp.to != pos && nextChange > sp.to ) { nextChange = sp.to; spanEndStyle = ""; } if (m.className) { spanStyle += " " + m.className; } if (m.css) { css = (css ? css + ";" : "") + m.css; } if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push( m.endStyle, sp.to ); } // support for the old title property // https://github.com/codemirror/CodeMirror/pull/5673 if (m.title) { (attributes || (attributes = {})).title = m.title; } if (m.attributes) { for (var attr in m.attributes) { (attributes || (attributes = {}))[attr] = m.attributes[attr]; } } if ( m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0) ) { collapsed = sp; } } else if (sp.from > pos && nextChange > sp.from) { nextChange = sp.from; } } if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan( builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null ); if (collapsed.to == null) { return; } if (collapsed.to == pos) { collapsed = false; } } } if (pos >= len) { break; } var upto = Math.min(len, nextChange); while (true) { if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken( builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes ); } if (end >= upto) { text = text.slice(upto - pos); pos = upto; break; } pos = end; spanStartStyle = ""; } text = allText.slice(at, (at = styles[i++])); style = interpretTokenStyle(styles[i++], builder.cm.options); } } } // These objects are used to represent the visible (currently drawn) // part of the document. A LineView may correspond to multiple // logical lines, if those are connected by collapsed ranges. function LineView(doc, line, lineN) { // The starting line this.line = line; // Continuing lines, if any this.rest = visualLineContinued(line); // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; this.node = this.text = null; this.hidden = lineIsHidden(doc, line); } // Create a range of LineView objects for the given lines. function buildViewArray(cm, from, to) { var array = [], nextPos; for (var pos = from; pos < to; pos = nextPos) { var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size; array.push(view); } return array; } var operationGroup = null; function pushOperation(op) { if (operationGroup) { operationGroup.ops.push(op); } else { op.ownsGroup = operationGroup = { ops: [op], delayedCallbacks: [], }; } } function fireCallbacksForOps(group) { // Calls delayed callbacks and cursorActivity handlers until no // new ones appear var callbacks = group.delayedCallbacks, i = 0; do { for (; i < callbacks.length; i++) { callbacks[i].call(null); } for (var j = 0; j < group.ops.length; j++) { var op = group.ops[j]; if (op.cursorActivityHandlers) { while ( op.cursorActivityCalled < op.cursorActivityHandlers.length ) { op.cursorActivityHandlers[ op.cursorActivityCalled++ ].call(null, op.cm); } } } } while (i < callbacks.length); } function finishOperation(op, endCb) { var group = op.ownsGroup; if (!group) { return; } try { fireCallbacksForOps(group); } finally { operationGroup = null; endCb(group); } } var orphanDelayedCallbacks = null; // Often, we want to signal events at a point where we are in the // middle of some work, but don't want the handler to start calling // other methods on the editor, which might be in an inconsistent // state or simply not expect any other events to happen. // signalLater looks whether there are any handlers, and schedules // them to be executed when the last operation ends, or, if no // operation is active, when a timeout fires. function signalLater(emitter, type /*, values...*/) { var arr = getHandlers(emitter, type); if (!arr.length) { return; } var args = Array.prototype.slice.call(arguments, 2), list; if (operationGroup) { list = operationGroup.delayedCallbacks; } else if (orphanDelayedCallbacks) { list = orphanDelayedCallbacks; } else { list = orphanDelayedCallbacks = []; setTimeout(fireOrphanDelayed, 0); } var loop = function (i) { list.push(function () { return arr[i].apply(null, args); }); }; for (var i = 0; i < arr.length; ++i) loop(i); } function fireOrphanDelayed() { var delayed = orphanDelayedCallbacks; orphanDelayedCallbacks = null; for (var i = 0; i < delayed.length; ++i) { delayed[i](); } } // When an aspect of a line changes, a string is added to // lineView.changes. This updates the relevant part of the line's // DOM structure. function updateLineForChanges(cm, lineView, lineN, dims) { for (var j = 0; j < lineView.changes.length; j++) { var type = lineView.changes[j]; if (type == "text") { updateLineText(cm, lineView); } else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); } else if (type == "class") { updateLineClasses(cm, lineView); } else if (type == "widget") { updateLineWidgets(cm, lineView, dims); } } lineView.changes = null; } // Lines with gutter elements, widgets or a background class need to // be wrapped, and have the extra elements added to the wrapper div function ensureLineWrapped(lineView) { if (lineView.node == lineView.text) { lineView.node = elt("div", null, null, "position: relative"); if (lineView.text.parentNode) { lineView.text.parentNode.replaceChild( lineView.node, lineView.text ); } lineView.node.appendChild(lineView.text); if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; } } return lineView.node; } function updateLineBackground(cm, lineView) { var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; if (cls) { cls += " CodeMirror-linebackground"; } if (lineView.background) { if (cls) { lineView.background.className = cls; } else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } } else if (cls) { var wrap = ensureLineWrapped(lineView); lineView.background = wrap.insertBefore( elt("div", null, cls), wrap.firstChild ); cm.display.input.setUneditable(lineView.background); } } // Wrapper around buildLineContent which will reuse the structure // in display.externalMeasured when possible. function getLineContent(cm, lineView) { var ext = cm.display.externalMeasured; if (ext && ext.line == lineView.line) { cm.display.externalMeasured = null; lineView.measure = ext.measure; return ext.built; } return buildLineContent(cm, lineView); } // Redraw the line's text. Interacts with the background and text // classes because the mode may output tokens that influence these // classes. function updateLineText(cm, lineView) { var cls = lineView.text.className; var built = getLineContent(cm, lineView); if (lineView.text == lineView.node) { lineView.node = built.pre; } lineView.text.parentNode.replaceChild(built.pre, lineView.text); lineView.text = built.pre; if ( built.bgClass != lineView.bgClass || built.textClass != lineView.textClass ) { lineView.bgClass = built.bgClass; lineView.textClass = built.textClass; updateLineClasses(cm, lineView); } else if (cls) { lineView.text.className = cls; } } function updateLineClasses(cm, lineView) { updateLineBackground(cm, lineView); if (lineView.line.wrapClass) { ensureLineWrapped(lineView).className = lineView.line.wrapClass; } else if (lineView.node != lineView.text) { lineView.node.className = ""; } var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; lineView.text.className = textClass || ""; } function updateLineGutter(cm, lineView, lineN, dims) { if (lineView.gutter) { lineView.node.removeChild(lineView.gutter); lineView.gutter = null; } if (lineView.gutterBackground) { lineView.node.removeChild(lineView.gutterBackground); lineView.gutterBackground = null; } if (lineView.line.gutterClass) { var wrap = ensureLineWrapped(lineView); lineView.gutterBackground = elt( "div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + dims.gutterTotalWidth + "px" ); cm.display.input.setUneditable(lineView.gutterBackground); wrap.insertBefore(lineView.gutterBackground, lineView.text); } var markers = lineView.line.gutterMarkers; if (cm.options.lineNumbers || markers) { var wrap$1 = ensureLineWrapped(lineView); var gutterWrap = (lineView.gutter = elt( "div", null, "CodeMirror-gutter-wrapper", "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px" )); gutterWrap.setAttribute("aria-hidden", "true"); cm.display.input.setUneditable(gutterWrap); wrap$1.insertBefore(gutterWrap, lineView.text); if (lineView.line.gutterClass) { gutterWrap.className += " " + lineView.line.gutterClass; } if ( cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]) ) { lineView.lineNumber = gutterWrap.appendChild( elt( "div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + cm.display.lineNumInnerWidth + "px" ) ); } if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) { var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id]; if (found) { gutterWrap.appendChild( elt( "div", [found], "CodeMirror-gutter-elt", "left: " + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px" ) ); } } } } } function updateLineWidgets(cm, lineView, dims) { if (lineView.alignable) { lineView.alignable = null; } var isWidget = classTest("CodeMirror-linewidget"); for ( var node = lineView.node.firstChild, next = void 0; node; node = next ) { next = node.nextSibling; if (isWidget.test(node.className)) { lineView.node.removeChild(node); } } insertLineWidgets(cm, lineView, dims); } // Build a line's DOM representation from scratch function buildLineElement(cm, lineView, lineN, dims) { var built = getLineContent(cm, lineView); lineView.text = lineView.node = built.pre; if (built.bgClass) { lineView.bgClass = built.bgClass; } if (built.textClass) { lineView.textClass = built.textClass; } updateLineClasses(cm, lineView); updateLineGutter(cm, lineView, lineN, dims); insertLineWidgets(cm, lineView, dims); return lineView.node; } // A lineView may contain multiple logical lines (when merged by // collapsed spans). The widgets for all of them need to be drawn. function insertLineWidgets(cm, lineView, dims) { insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { insertLineWidgetsFor( cm, lineView.rest[i], lineView, dims, false ); } } } function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { if (!line.widgets) { return; } var wrap = ensureLineWrapped(lineView); for (var i = 0, ws = line.widgets; i < ws.length; ++i) { var widget = ws[i], node = elt( "div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "") ); if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); } positionLineWidget(widget, node, lineView, dims); cm.display.input.setUneditable(node); if (allowAbove && widget.above) { wrap.insertBefore(node, lineView.gutter || lineView.text); } else { wrap.appendChild(node); } signalLater(widget, "redraw"); } } function positionLineWidget(widget, node, lineView, dims) { if (widget.noHScroll) { (lineView.alignable || (lineView.alignable = [])).push(node); var width = dims.wrapperWidth; node.style.left = dims.fixedPos + "px"; if (!widget.coverGutter) { width -= dims.gutterTotalWidth; node.style.paddingLeft = dims.gutterTotalWidth + "px"; } node.style.width = width + "px"; } if (widget.coverGutter) { node.style.zIndex = 5; node.style.position = "relative"; if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; } } } function widgetHeight(widget) { if (widget.height != null) { return widget.height; } var cm = widget.doc.cm; if (!cm) { return 0; } if (!contains(document.body, widget.node)) { var parentStyle = "position: relative;"; if (widget.coverGutter) { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; } if (widget.noHScroll) { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; } removeChildrenAndAdd( cm.display.measure, elt("div", [widget.node], null, parentStyle) ); } return (widget.height = widget.node.parentNode.offsetHeight); } // Return true when the given mouse event happened in a widget function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if ( !n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || (n.parentNode == display.sizer && n != display.mover) ) { return true; } } } // POSITION MEASUREMENT function paddingTop(display) { return display.lineSpace.offsetTop; } function paddingVert(display) { return display.mover.offsetHeight - display.lineSpace.offsetHeight; } function paddingH(display) { if (display.cachedPaddingH) { return display.cachedPaddingH; } var e = removeChildrenAndAdd( display.measure, elt("pre", "x", "CodeMirror-line-like") ); var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; var data = { left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight), }; if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; } return data; } function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; } function displayWidth(cm) { return ( cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth ); } function displayHeight(cm) { return ( cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight ); } // Ensure the lineView.wrapping.heights array is populated. This is // an array of bottom offsets for the lines that make up a drawn // line. When lineWrapping is on, there might be more than one // height. function ensureLineHeights(cm, lineView, rect) { var wrapping = cm.options.lineWrapping; var curWidth = wrapping && displayWidth(cm); if ( !lineView.measure.heights || (wrapping && lineView.measure.width != curWidth) ) { var heights = (lineView.measure.heights = []); if (wrapping) { lineView.measure.width = curWidth; var rects = lineView.text.firstChild.getClientRects(); for (var i = 0; i < rects.length - 1; i++) { var cur = rects[i], next = rects[i + 1]; if (Math.abs(cur.bottom - next.bottom) > 2) { heights.push((cur.bottom + next.top) / 2 - rect.top); } } } heights.push(rect.bottom - rect.top); } } // Find a line map (mapping character offsets to text nodes) and a // measurement cache for the given line number. (A line view might // contain multiple lines when collapsed ranges are present.) function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return { map: lineView.measure.map, cache: lineView.measure.cache }; } if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { if (lineView.rest[i] == line) { return { map: lineView.measure.maps[i], cache: lineView.measure.caches[i], }; } } for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) { if (lineNo(lineView.rest[i$1]) > lineN) { return { map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true, }; } } } } // Render a line into the hidden node display.externalMeasured. Used // when measurement is needed for a line that's not in the viewport. function updateExternalMeasurement(cm, line) { line = visualLine(line); var lineN = lineNo(line); var view = (cm.display.externalMeasured = new LineView( cm.doc, line, lineN )); view.lineN = lineN; var built = (view.built = buildLineContent(cm, view)); view.text = built.pre; removeChildrenAndAdd(cm.display.lineMeasure, built.pre); return view; } // Get a {top, bottom, left, right} box (in line-local coordinates) // for a given character. function measureChar(cm, line, ch, bias) { return measureCharPrepared( cm, prepareMeasureForLine(cm, line), ch, bias ); } // Find a line view that corresponds to the given line number. function findViewForLine(cm, lineN) { if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) { return cm.display.view[findViewIndex(cm, lineN)]; } var ext = cm.display.externalMeasured; if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) { return ext; } } // Measurement can be split in two steps, the set-up work that // applies to the whole line, and the measurement of the actual // character. Functions like coordsChar, that need to do a lot of // measurements in a row, can thus ensure that the set-up work is // only done once. function prepareMeasureForLine(cm, line) { var lineN = lineNo(line); var view = findViewForLine(cm, lineN); if (view && !view.text) { view = null; } else if (view && view.changes) { updateLineForChanges(cm, view, lineN, getDimensions(cm)); cm.curOp.forceUpdate = true; } if (!view) { view = updateExternalMeasurement(cm, line); } var info = mapFromLineView(view, line, lineN); return { line: line, view: view, rect: null, map: info.map, cache: info.cache, before: info.before, hasHeights: false, }; } // Given a prepared measurement object, measures the position of an // actual character (or fetches it from the cache). function measureCharPrepared(cm, prepared, ch, bias, varHeight) { if (prepared.before) { ch = -1; } var key = ch + (bias || ""), found; if (prepared.cache.hasOwnProperty(key)) { found = prepared.cache[key]; } else { if (!prepared.rect) { prepared.rect = prepared.view.text.getBoundingClientRect(); } if (!prepared.hasHeights) { ensureLineHeights(cm, prepared.view, prepared.rect); prepared.hasHeights = true; } found = measureCharInner(cm, prepared, ch, bias); if (!found.bogus) { prepared.cache[key] = found; } } return { left: found.left, right: found.right, top: varHeight ? found.rtop : found.top, bottom: varHeight ? found.rbottom : found.bottom, }; } var nullRect = { left: 0, right: 0, top: 0, bottom: 0 }; function nodeAndOffsetInLineMap(map, ch, bias) { var node, start, end, collapse, mStart, mEnd; // First, search the line map for the text node corresponding to, // or closest to, the target character. for (var i = 0; i < map.length; i += 3) { mStart = map[i]; mEnd = map[i + 1]; if (ch < mStart) { start = 0; end = 1; collapse = "left"; } else if (ch < mEnd) { start = ch - mStart; end = start + 1; } else if (i == map.length - 3 || (ch == mEnd && map[i + 3] > ch)) { end = mEnd - mStart; start = end - 1; if (ch >= mEnd) { collapse = "right"; } } if (start != null) { node = map[i + 2]; if ( mStart == mEnd && bias == (node.insertLeft ? "left" : "right") ) { collapse = bias; } if (bias == "left" && start == 0) { while ( i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft ) { node = map[(i -= 3) + 2]; collapse = "left"; } } if (bias == "right" && start == mEnd - mStart) { while ( i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft ) { node = map[(i += 3) + 2]; collapse = "right"; } } break; } } return { node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd, }; } function getUsefulRect(rects, bias) { var rect = nullRect; if (bias == "left") { for (var i = 0; i < rects.length; i++) { if ((rect = rects[i]).left != rect.right) { break; } } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) { if ((rect = rects[i$1]).left != rect.right) { break; } } } return rect; } function measureCharInner(cm, prepared, ch, bias) { var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); var node = place.node, start = place.start, end = place.end, collapse = place.collapse; var rect; if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned while ( start && isExtendingChar( prepared.line.text.charAt(place.coverStart + start) ) ) { --start; } while ( place.coverStart + end < place.coverEnd && isExtendingChar( prepared.line.text.charAt(place.coverStart + end) ) ) { ++end; } if ( ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart ) { rect = node.parentNode.getBoundingClientRect(); } else { rect = getUsefulRect( range(node, start, end).getClientRects(), bias ); } if (rect.left || rect.right || start == 0) { break; } end = start; start = start - 1; collapse = "right"; } if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); } } else { // If it is a widget, simply get the box for the whole widget. if (start > 0) { collapse = bias = "right"; } var rects; if ( cm.options.lineWrapping && (rects = node.getClientRects()).length > 1 ) { rect = rects[bias == "right" ? rects.length - 1 : 0]; } else { rect = node.getBoundingClientRect(); } } if ( ie && ie_version < 9 && !start && (!rect || (!rect.left && !rect.right)) ) { var rSpan = node.parentNode.getClientRects()[0]; if (rSpan) { rect = { left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom, }; } else { rect = nullRect; } } var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; var mid = (rtop + rbot) / 2; var heights = prepared.view.measure.heights; var i = 0; for (; i < heights.length - 1; i++) { if (mid < heights[i]) { break; } } var top = i ? heights[i - 1] : 0, bot = heights[i]; var result = { left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, top: top, bottom: bot, }; if (!rect.left && !rect.right) { result.bogus = true; } if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } return result; } // Work around problem with bounding client rects on ranges being // returned incorrectly when zoomed on IE10 and below. function maybeUpdateRectForZooming(measure, rect) { if ( !window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure) ) { return rect; } var scaleX = screen.logicalXDPI / screen.deviceXDPI; var scaleY = screen.logicalYDPI / screen.deviceYDPI; return { left: rect.left * scaleX, right: rect.right * scaleX, top: rect.top * scaleY, bottom: rect.bottom * scaleY, }; } function clearLineMeasurementCacheFor(lineView) { if (lineView.measure) { lineView.measure.cache = {}; lineView.measure.heights = null; if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { lineView.measure.caches[i] = {}; } } } } function clearLineMeasurementCache(cm) { cm.display.externalMeasure = null; removeChildren(cm.display.lineMeasure); for (var i = 0; i < cm.display.view.length; i++) { clearLineMeasurementCacheFor(cm.display.view[i]); } } function clearCaches(cm) { clearLineMeasurementCache(cm); cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; } cm.display.lineNumChars = null; } function pageScrollX() { // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // which causes page_Offset and bounding client rects to use // different reference viewports and invalidate our calculations. if (chrome && android) { return -( document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft) ); } return ( window.pageXOffset || (document.documentElement || document.body).scrollLeft ); } function pageScrollY() { if (chrome && android) { return -( document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop) ); } return ( window.pageYOffset || (document.documentElement || document.body).scrollTop ); } function widgetTopHeight(lineObj) { var ref = visualLine(lineObj); var widgets = ref.widgets; var height = 0; if (widgets) { for (var i = 0; i < widgets.length; ++i) { if (widgets[i].above) { height += widgetHeight(widgets[i]); } } } return height; } // Converts a {top, bottom, left, right} box from line-local // coordinates into another coordinate system. Context may be one of // "line", "div" (display.lineDiv), "local"./null (editor), "window", // or "page". function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { if (!includeWidgets) { var height = widgetTopHeight(lineObj); rect.top += height; rect.bottom += height; } if (context == "line") { return rect; } if (!context) { context = "local"; } var yOff = heightAtLine(lineObj); if (context == "local") { yOff += paddingTop(cm.display); } else { yOff -= cm.display.viewOffset; } if (context == "page" || context == "window") { var lOff = cm.display.lineSpace.getBoundingClientRect(); yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); rect.left += xOff; rect.right += xOff; } rect.top += yOff; rect.bottom += yOff; return rect; } // Coverts a box from "div" coords to another coordinate system. // Context may be "window", "page", "div", or "local"./null. function fromCoordSystem(cm, coords, context) { if (context == "div") { return coords; } var left = coords.left, top = coords.top; // First move into "page" coordinate system if (context == "page") { left -= pageScrollX(); top -= pageScrollY(); } else if (context == "local" || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left; top += localBox.top; } var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); return { left: left - lineSpaceBox.left, top: top - lineSpaceBox.top }; } function charCoords(cm, pos, context, lineObj, bias) { if (!lineObj) { lineObj = getLine(cm.doc, pos.line); } return intoCoordSystem( cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context ); } // Returns a box for a given cursor position, which may have an // 'other' property containing the position of the secondary cursor // on a bidi boundary. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1` // and after `char - 1` in writing order of `char - 1` // A cursor Pos(line, char, "after") is on the same visual line as `char` // and before `char` in writing order of `char` // Examples (upper-case letters are RTL, lower-case are LTR): // Pos(0, 1, ...) // before after // ab a|b a|b // aB a|B aB| // Ab |Ab A|b // AB B|A B|A // Every position after the last character on a line is considered to stick // to the last character on the line. function cursorCoords( cm, pos, context, lineObj, preparedMeasure, varHeight ) { lineObj = lineObj || getLine(cm.doc, pos.line); if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } function get(ch, right) { var m = measureCharPrepared( cm, preparedMeasure, ch, right ? "right" : "left", varHeight ); if (right) { m.left = m.right; } else { m.right = m.left; } return intoCoordSystem(cm, lineObj, m, context); } var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; if (ch >= lineObj.text.length) { ch = lineObj.text.length; sticky = "before"; } else if (ch <= 0) { ch = 0; sticky = "after"; } if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before"); } function getBidi(ch, partPos, invert) { var part = order[partPos], right = part.level == 1; return get(invert ? ch - 1 : ch, right != invert); } var partPos = getBidiPartAt(order, ch, sticky); var other = bidiOther; var val = getBidi(ch, partPos, sticky == "before"); if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } return val; } // Used to cheaply estimate the coordinates for a position. Used for // intermediate scroll updates. function estimateCoords(cm, pos) { var left = 0; pos = clipPos(cm.doc, pos); if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; } var lineObj = getLine(cm.doc, pos.line); var top = heightAtLine(lineObj) + paddingTop(cm.display); return { left: left, right: left, top: top, bottom: top + lineObj.height, }; } // Positions returned by coordsChar contain some extra information. // xRel is the relative x position of the input coordinates compared // to the found position (so xRel > 0 means the coordinates are to // the right of the character position, for example). When outside // is true, that means the coordinates lie outside the line's // vertical range. function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); pos.xRel = xRel; if (outside) { pos.outside = outside; } return pos; } // Compute the character position closest to the given coordinates. // Input must be lineSpace-local ("div" coordinate system). function coordsChar(cm, x, y) { var doc = cm.doc; y += cm.display.viewOffset; if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1); } var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; if (lineN > last) { return PosWithInfo( doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1 ); } if (x < 0) { x = 0; } var lineObj = getLine(doc, lineN); for (;;) { var found = coordsCharInner(cm, lineObj, lineN, x, y); var collapsed = collapsedSpanAround( lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0) ); if (!collapsed) { return found; } var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) { return rangeEnd; } lineObj = getLine(doc, (lineN = rangeEnd.line)); } } function wrappedLineExtent(cm, lineObj, preparedMeasure, y) { y -= widgetTopHeight(lineObj); var end = lineObj.text.length; var begin = findFirst( function (ch) { return ( measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y ); }, end, 0 ); end = findFirst( function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end ); return { begin: begin, end: end }; } function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) { if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } var targetTop = intoCoordSystem( cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line" ).top; return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop); } // Returns true if the given side of a box is after the given // coordinates, in top-to-bottom, left-to-right order. function boxIsAfter(box, x, y, left) { return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x; } function coordsCharInner(cm, lineObj, lineNo, x, y) { // Move y into line-local coordinate space y -= heightAtLine(lineObj); var preparedMeasure = prepareMeasureForLine(cm, lineObj); // When directly calling `measureCharPrepared`, we have to adjust // for the widgets at this line. var widgetHeight = widgetTopHeight(lineObj); var begin = 0, end = lineObj.text.length, ltr = true; var order = getOrder(lineObj, cm.doc.direction); // If the line isn't plain left-to-right text, first figure out // which bidi section the coordinates fall into. if (order) { var part = ( cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart )(cm, lineObj, lineNo, preparedMeasure, order, x, y); ltr = part.level != 1; // The awkward -1 offsets are needed because findFirst (called // on these below) will treat its first bound as inclusive, // second as exclusive, but we want to actually address the // characters in the part's range begin = ltr ? part.from : part.to - 1; end = ltr ? part.to : part.from - 1; } // A binary search to find the first character whose bounding box // starts after the coordinates. If we run across any whose box wrap // the coordinates, store that. var chAround = null, boxAround = null; var ch = findFirst( function (ch) { var box = measureCharPrepared(cm, preparedMeasure, ch); box.top += widgetHeight; box.bottom += widgetHeight; if (!boxIsAfter(box, x, y, false)) { return false; } if (box.top <= y && box.left <= x) { chAround = ch; boxAround = box; } return true; }, begin, end ); var baseX, sticky, outside = false; // If a box around the coordinates was found, use that if (boxAround) { // Distinguish coordinates nearer to the left or right side of the box var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr; ch = chAround + (atStart ? 0 : 1); sticky = atStart ? "after" : "before"; baseX = atLeft ? boxAround.left : boxAround.right; } else { // (Adjust for extended bound, if necessary.) if (!ltr && (ch == end || ch == begin)) { ch++; } // To determine which side to associate with, get the box to the // left of the character and compare it's vertical position to the // coordinates sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : measureCharPrepared( cm, preparedMeasure, ch - (ltr ? 1 : 0) ).bottom + widgetHeight <= y == ltr ? "after" : "before"; // Now get accurate coordinates for this place, in order to get a // base X position var coords = cursorCoords( cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure ); baseX = coords.left; outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0; } ch = skipExtendingChars(lineObj.text, ch, 1); return PosWithInfo(lineNo, ch, sticky, outside, x - baseX); } function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) { // Bidi parts are sorted left-to-right, and in a non-line-wrapping // situation, we can take this ordering to correspond to the visual // ordering. This finds the first part whose end is after the given // coordinates. var index = findFirst( function (i) { var part = order[i], ltr = part.level != 1; return boxIsAfter( cursorCoords( cm, Pos( lineNo, ltr ? part.to : part.from, ltr ? "before" : "after" ), "line", lineObj, preparedMeasure ), x, y, true ); }, 0, order.length - 1 ); var part = order[index]; // If this isn't the first part, the part's start is also after // the coordinates, and the coordinates aren't on the same line as // that start, move one part back. if (index > 0) { var ltr = part.level != 1; var start = cursorCoords( cm, Pos( lineNo, ltr ? part.from : part.to, ltr ? "after" : "before" ), "line", lineObj, preparedMeasure ); if (boxIsAfter(start, x, y, true) && start.top > y) { part = order[index - 1]; } } return part; } function coordsBidiPartWrapped( cm, lineObj, _lineNo, preparedMeasure, order, x, y ) { // In a wrapped line, rtl text on wrapping boundaries can do things // that don't correspond to the ordering in our `order` array at // all, so a binary search doesn't work, and we want to return a // part that only spans one line so that the binary search in // coordsCharInner is safe. As such, we first find the extent of the // wrapped line, and then do a flat search in which we discard any // spans that aren't on the line. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y); var begin = ref.begin; var end = ref.end; if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; } var part = null, closestDist = null; for (var i = 0; i < order.length; i++) { var p = order[i]; if (p.from >= end || p.to <= begin) { continue; } var ltr = p.level != 1; var endX = measureCharPrepared( cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from) ).right; // Weigh against spans ending before this, so that they are only // picked if nothing ends after var dist = endX < x ? x - endX + 1e9 : endX - x; if (!part || closestDist > dist) { part = p; closestDist = dist; } } if (!part) { part = order[order.length - 1]; } // Clip the part to the wrapped line. if (part.from < begin) { part = { from: begin, to: part.to, level: part.level }; } if (part.to > end) { part = { from: part.from, to: end, level: part.level }; } return part; } var measureText; // Compute the default text height. function textHeight(display) { if (display.cachedTextHeight != null) { return display.cachedTextHeight; } if (measureText == null) { measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for (var i = 0; i < 49; ++i) { measureText.appendChild(document.createTextNode("x")); measureText.appendChild(elt("br")); } measureText.appendChild(document.createTextNode("x")); } removeChildrenAndAdd(display.measure, measureText); var height = measureText.offsetHeight / 50; if (height > 3) { display.cachedTextHeight = height; } removeChildren(display.measure); return height || 1; } // Compute the default character width. function charWidth(display) { if (display.cachedCharWidth != null) { return display.cachedCharWidth; } var anchor = elt("span", "xxxxxxxxxx"); var pre = elt("pre", [anchor], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; if (width > 2) { display.cachedCharWidth = width; } return width || 10; } // Do a bulk-read of the DOM positions and sizes needed to draw the // view, so that we don't interleave reading and writing to the DOM. function getDimensions(cm) { var d = cm.display, left = {}, width = {}; var gutterLeft = d.gutters.clientLeft; for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { var id = cm.display.gutterSpecs[i].className; left[id] = n.offsetLeft + n.clientLeft + gutterLeft; width[id] = n.clientWidth; } return { fixedPos: compensateForHScroll(d), gutterTotalWidth: d.gutters.offsetWidth, gutterLeft: left, gutterWidth: width, wrapperWidth: d.wrapper.clientWidth, }; } // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, // but using getBoundingClientRect to get a sub-pixel-accurate // result. function compensateForHScroll(display) { return ( display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left ); } // Returns a function that estimates the height of a line, to use as // first approximation until the line becomes visible (and is thus // properly measurable). function estimateHeight(cm) { var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; var perLine = wrapping && Math.max( 5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3 ); return function (line) { if (lineIsHidden(cm.doc, line)) { return 0; } var widgetsHeight = 0; if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; } } } if (wrapping) { return ( widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th ); } else { return widgetsHeight + th; } }; } function estimateLineHeights(cm) { var doc = cm.doc, est = estimateHeight(cm); doc.iter(function (line) { var estHeight = est(line); if (estHeight != line.height) { updateLineHeight(line, estHeight); } }); } // Given a mouse event, find the corresponding position. If liberal // is false, it checks whether a gutter or scrollbar was clicked, // and returns null if it was. forRect is used by rectangular // selections, and tries to estimate a character position even for // coordinates beyond the right of the text. function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null; } var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left; y = e.clientY - space.top; } catch (e$1) { return null; } var coords = coordsChar(cm, x, y), line; if ( forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch ) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos( coords.line, Math.max( 0, Math.round( (x - paddingH(cm.display).left) / charWidth(cm.display) ) - colDiff ) ); } return coords; } // Find the view element corresponding to a given line. Return null // when the line isn't visible. function findViewIndex(cm, n) { if (n >= cm.display.viewTo) { return null; } n -= cm.display.viewFrom; if (n < 0) { return null; } var view = cm.display.view; for (var i = 0; i < view.length; i++) { n -= view[i].size; if (n < 0) { return i; } } } // Updates the display.view data structure for a given change to the // document. From and to are in pre-change coordinates. Lendiff is // the amount of lines added or subtracted by the change. This is // used for changes that span multiple lines, or change the way // lines are divided into visual lines. regLineChange (below) // registers single-line changes. function regChange(cm, from, to, lendiff) { if (from == null) { from = cm.doc.first; } if (to == null) { to = cm.doc.first + cm.doc.size; } if (!lendiff) { lendiff = 0; } var display = cm.display; if ( lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from) ) { display.updateLineNumbers = from; } cm.curOp.viewChanged = true; if (from >= display.viewTo) { // Change after if ( sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo ) { resetView(cm); } } else if (to <= display.viewFrom) { // Change before if ( sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom ) { resetView(cm); } else { display.viewFrom += lendiff; display.viewTo += lendiff; } } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap resetView(cm); } else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); if (cut) { display.view = display.view.slice(cut.index); display.viewFrom = cut.lineN; display.viewTo += lendiff; } else { resetView(cm); } } else if (to >= display.viewTo) { // Bottom overlap var cut$1 = viewCuttingPoint(cm, from, from, -1); if (cut$1) { display.view = display.view.slice(0, cut$1.index); display.viewTo = cut$1.lineN; } else { resetView(cm); } } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1); var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); if (cutTop && cutBot) { display.view = display.view .slice(0, cutTop.index) .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) .concat(display.view.slice(cutBot.index)); display.viewTo += lendiff; } else { resetView(cm); } } var ext = display.externalMeasured; if (ext) { if (to < ext.lineN) { ext.lineN += lendiff; } else if (from < ext.lineN + ext.size) { display.externalMeasured = null; } } } // Register a change to a single line. Type must be one of "text", // "gutter", "class", "widget" function regLineChange(cm, line, type) { cm.curOp.viewChanged = true; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size) { display.externalMeasured = null; } if (line < display.viewFrom || line >= display.viewTo) { return; } var lineView = display.view[findViewIndex(cm, line)]; if (lineView.node == null) { return; } var arr = lineView.changes || (lineView.changes = []); if (indexOf(arr, type) == -1) { arr.push(type); } } // Clear the view. function resetView(cm) { cm.display.viewFrom = cm.display.viewTo = cm.doc.first; cm.display.view = []; cm.display.viewOffset = 0; } function viewCuttingPoint(cm, oldN, newN, dir) { var index = findViewIndex(cm, oldN), diff, view = cm.display.view; if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) { return { index: index, lineN: newN }; } var n = cm.display.viewFrom; for (var i = 0; i < index; i++) { n += view[i].size; } if (n != oldN) { if (dir > 0) { if (index == view.length - 1) { return null; } diff = n + view[index].size - oldN; index++; } else { diff = n - oldN; } oldN += diff; newN += diff; } while (visualLineNo(cm.doc, newN) != newN) { if (index == (dir < 0 ? 0 : view.length - 1)) { return null; } newN += dir * view[index - (dir < 0 ? 1 : 0)].size; index += dir; } return { index: index, lineN: newN }; } // Force the view to cover a given range, adding empty view element // or clipping off existing ones as needed. function adjustView(cm, from, to) { var display = cm.display, view = display.view; if ( view.length == 0 || from >= display.viewTo || to <= display.viewFrom ) { display.view = buildViewArray(cm, from, to); display.viewFrom = from; } else { if (display.viewFrom > from) { display.view = buildViewArray( cm, from, display.viewFrom ).concat(display.view); } else if (display.viewFrom < from) { display.view = display.view.slice(findViewIndex(cm, from)); } display.viewFrom = from; if (display.viewTo < to) { display.view = display.view.concat( buildViewArray(cm, display.viewTo, to) ); } else if (display.viewTo > to) { display.view = display.view.slice(0, findViewIndex(cm, to)); } } display.viewTo = to; } // Count the number of lines in the view whose DOM representation is // out of date (or nonexistent). function countDirtyView(cm) { var view = cm.display.view, dirty = 0; for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; } } return dirty; } function updateSelection(cm) { cm.display.input.showSelection(cm.display.input.prepareSelection()); } function prepareSelection(cm, primary) { if (primary === void 0) primary = true; var doc = cm.doc, result = {}; var curFragment = (result.cursors = document.createDocumentFragment()); var selFragment = (result.selection = document.createDocumentFragment()); var customCursor = cm.options.$customCursor; if (customCursor) { primary = true; } for (var i = 0; i < doc.sel.ranges.length; i++) { if (!primary && i == doc.sel.primIndex) { continue; } var range = doc.sel.ranges[i]; if ( range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom ) { continue; } var collapsed = range.empty(); if (customCursor) { var head = customCursor(cm, range); if (head) { drawSelectionCursor(cm, head, curFragment); } } else if (collapsed || cm.options.showCursorWhenSelecting) { drawSelectionCursor(cm, range.head, curFragment); } if (!collapsed) { drawSelectionRange(cm, range, selFragment); } } return result; } // Draws a cursor for the given range function drawSelectionCursor(cm, head, output) { var pos = cursorCoords( cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine ); var cursor = output.appendChild( elt("div", "\u00a0", "CodeMirror-cursor") ); cursor.style.left = pos.left + "px"; cursor.style.top = pos.top + "px"; cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) { var charPos = charCoords(cm, head, "div", null, null); var width = charPos.right - charPos.left; cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px"; } if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text var otherCursor = output.appendChild( elt( "div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor" ) ); otherCursor.style.display = ""; otherCursor.style.left = pos.other.left + "px"; otherCursor.style.top = pos.other.top + "px"; otherCursor.style.height = (pos.other.bottom - pos.other.top) * 0.85 + "px"; } } function cmpCoords(a, b) { return a.top - b.top || a.left - b.left; } // Draws the given range as a highlighted selection function drawSelectionRange(cm, range, output) { var display = cm.display, doc = cm.doc; var fragment = document.createDocumentFragment(); var padding = paddingH(cm.display), leftSide = padding.left; var rightSide = Math.max( display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft ) - padding.right; var docLTR = doc.direction == "ltr"; function add(left, top, width, bottom) { if (top < 0) { top = 0; } top = Math.round(top); bottom = Math.round(bottom); fragment.appendChild( elt( "div", null, "CodeMirror-selected", "position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px" ) ); } function drawForLine(line, fromArg, toArg) { var lineObj = getLine(doc, line); var lineLen = lineObj.text.length; var start, end; function coords(ch, bias) { return charCoords(cm, Pos(line, ch), "div", lineObj, bias); } function wrapX(pos, dir, side) { var extent = wrappedLineExtentChar(cm, lineObj, null, pos); var prop = (dir == "ltr") == (side == "after") ? "left" : "right"; var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1); return coords(ch, prop)[prop]; } var order = getOrder(lineObj, doc.direction); iterateBidiSections( order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) { var ltr = dir == "ltr"; var fromPos = coords(from, ltr ? "left" : "right"); var toPos = coords(to - 1, ltr ? "right" : "left"); var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen; var first = i == 0, last = !order || i == order.length - 1; if (toPos.top - fromPos.top <= 3) { // Single line var openLeft = (docLTR ? openStart : openEnd) && first; var openRight = (docLTR ? openEnd : openStart) && last; var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left; var right = openRight ? rightSide : (ltr ? toPos : fromPos).right; add(left, fromPos.top, right - left, fromPos.bottom); } else { // Multiple lines var topLeft, topRight, botLeft, botRight; if (ltr) { topLeft = docLTR && openStart && first ? leftSide : fromPos.left; topRight = docLTR ? rightSide : wrapX(from, dir, "before"); botLeft = docLTR ? leftSide : wrapX(to, dir, "after"); botRight = docLTR && openEnd && last ? rightSide : toPos.right; } else { topLeft = !docLTR ? leftSide : wrapX(from, dir, "before"); topRight = !docLTR && openStart && first ? rightSide : fromPos.right; botLeft = !docLTR && openEnd && last ? leftSide : toPos.left; botRight = !docLTR ? rightSide : wrapX(to, dir, "after"); } add( topLeft, fromPos.top, topRight - topLeft, fromPos.bottom ); if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); } add( botLeft, toPos.top, botRight - botLeft, toPos.bottom ); } if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; } if (cmpCoords(toPos, start) < 0) { start = toPos; } if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; } if (cmpCoords(toPos, end) < 0) { end = toPos; } } ); return { start: start, end: end }; } var sFrom = range.from(), sTo = range.to(); if (sFrom.line == sTo.line) { drawForLine(sFrom.line, sFrom.ch, sTo.ch); } else { var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); var singleVLine = visualLine(fromLine) == visualLine(toLine); var leftEnd = drawForLine( sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null ).end; var rightStart = drawForLine( sTo.line, singleVLine ? 0 : null, sTo.ch ).start; if (singleVLine) { if (leftEnd.top < rightStart.top - 2) { add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); add( leftSide, rightStart.top, rightStart.left, rightStart.bottom ); } else { add( leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom ); } } if (leftEnd.bottom < rightStart.top) { add(leftSide, leftEnd.bottom, null, rightStart.top); } } output.appendChild(fragment); } // Cursor-blinking function restartBlink(cm) { if (!cm.state.focused) { return; } var display = cm.display; clearInterval(display.blinker); var on = true; display.cursorDiv.style.visibility = ""; if (cm.options.cursorBlinkRate > 0) { display.blinker = setInterval(function () { if (!cm.hasFocus()) { onBlur(cm); } display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; }, cm.options.cursorBlinkRate); } else if (cm.options.cursorBlinkRate < 0) { display.cursorDiv.style.visibility = "hidden"; } } function ensureFocus(cm) { if (!cm.hasFocus()) { cm.display.input.focus(); if (!cm.state.focused) { onFocus(cm); } } } function delayBlurEvent(cm) { cm.state.delayingBlurEvent = true; setTimeout(function () { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; if (cm.state.focused) { onBlur(cm); } } }, 100); } function onFocus(cm, e) { if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; } if (cm.options.readOnly == "nocursor") { return; } if (!cm.state.focused) { signal(cm, "focus", cm, e); cm.state.focused = true; addClass(cm.display.wrapper, "CodeMirror-focused"); // This test prevents this from firing when a context // menu is closed (since the input reset would kill the // select-all detection hack) if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { cm.display.input.reset(); if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730 } cm.display.input.receivedFocus(); } restartBlink(cm); } function onBlur(cm, e) { if (cm.state.delayingBlurEvent) { return; } if (cm.state.focused) { signal(cm, "blur", cm, e); cm.state.focused = false; rmClass(cm.display.wrapper, "CodeMirror-focused"); } clearInterval(cm.display.blinker); setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150); } // Read the actual heights of the rendered lines, and update their // stored heights to match. function updateHeightsInViewport(cm) { var display = cm.display; var prevBottom = display.lineDiv.offsetTop; var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top); var oldHeight = display.lineDiv.getBoundingClientRect().top; var mustScroll = 0; for (var i = 0; i < display.view.length; i++) { var cur = display.view[i], wrapping = cm.options.lineWrapping; var height = void 0, width = 0; if (cur.hidden) { continue; } oldHeight += cur.line.height; if (ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom; prevBottom = bot; } else { var box = cur.node.getBoundingClientRect(); height = box.bottom - box.top; // Check that lines don't extend past the right of the current // editor width if (!wrapping && cur.text.firstChild) { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; } } var diff = cur.line.height - height; if (diff > 0.005 || diff < -0.005) { if (oldHeight < viewTop) { mustScroll -= diff; } updateLineHeight(cur.line, height); updateWidgetHeight(cur.line); if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) { updateWidgetHeight(cur.rest[j]); } } } if (width > cm.display.sizerWidth) { var chWidth = Math.ceil(width / charWidth(cm.display)); if (chWidth > cm.display.maxLineLength) { cm.display.maxLineLength = chWidth; cm.display.maxLine = cur.line; cm.display.maxLineChanged = true; } } } if (Math.abs(mustScroll) > 2) { display.scroller.scrollTop += mustScroll; } } // Read and store the height of line widgets associated with the // given line. function updateWidgetHeight(line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) { var w = line.widgets[i], parent = w.node.parentNode; if (parent) { w.height = parent.offsetHeight; } } } } // Compute the lines that are visible in a given viewport (defaults // the the current scroll position). viewport may contain top, // height, and ensure (see op.scrollToPos) properties. function visibleLines(display, doc, viewport) { var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; top = Math.floor(top - paddingTop(display)); var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); // Ensure is a {from: {line, ch}, to: {line, ch}} object, and // forces those lines into the viewport (if possible). if (viewport && viewport.ensure) { var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; if (ensureFrom < from) { from = ensureFrom; to = lineAtHeight( doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight ); } else if (Math.min(ensureTo, doc.lastLine()) >= to) { from = lineAtHeight( doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight ); to = ensureTo; } } return { from: from, to: Math.max(to, from + 1) }; } // SCROLLING THINGS INTO VIEW // If an editor sits on the top or bottom of the window, partially // scrolled out of view, this ensures that the cursor is visible. function maybeScrollWindow(cm, rect) { if (signalDOMEvent(cm, "scrollCursorIntoView")) { return; } var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (rect.top + box.top < 0) { doScroll = true; } else if ( rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight) ) { doScroll = false; } if (doScroll != null && !phantom) { var scrollNode = elt( "div", "\u200b", null, "position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + rect.left + "px; width: " + Math.max(2, rect.right - rect.left) + "px;" ); cm.display.lineSpace.appendChild(scrollNode); scrollNode.scrollIntoView(doScroll); cm.display.lineSpace.removeChild(scrollNode); } } // Scroll a given position into view (immediately), verifying that // it actually became visible (as line heights are accurately // measured, the position of something may 'drift' during drawing). function scrollPosIntoView(cm, pos, end, margin) { if (margin == null) { margin = 0; } var rect; if (!cm.options.lineWrapping && pos == end) { // Set pos and end to the cursor positions around the character pos sticks to // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch // If pos == Pos(_, 0, "before"), pos and end are unchanged end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos; pos = pos.ch ? Pos( pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after" ) : pos; } for (var limit = 0; limit < 5; limit++) { var changed = false; var coords = cursorCoords(cm, pos); var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); rect = { left: Math.min(coords.left, endCoords.left), top: Math.min(coords.top, endCoords.top) - margin, right: Math.max(coords.left, endCoords.left), bottom: Math.max(coords.bottom, endCoords.bottom) + margin, }; var scrollPos = calculateScrollPos(cm, rect); var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; } } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; } } if (!changed) { break; } } return rect; } // Scroll a given set of coordinates into view (immediately). function scrollIntoView(cm, rect) { var scrollPos = calculateScrollPos(cm, rect); if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); } } // Calculate a new scroll position needed to scroll the given // rectangle into view. Returns an object with scrollTop and // scrollLeft properties. When these are undefined, the // vertical/horizontal position does not need to be adjusted. function calculateScrollPos(cm, rect) { var display = cm.display, snapMargin = textHeight(cm.display); if (rect.top < 0) { rect.top = 0; } var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = displayHeight(cm), result = {}; if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; } var docBottom = cm.doc.height + paddingVert(display); var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; if (rect.top < screentop) { result.scrollTop = atTop ? 0 : rect.top; } else if (rect.bottom > screentop + screen) { var newTop = Math.min( rect.top, (atBottom ? docBottom : rect.bottom) - screen ); if (newTop != screentop) { result.scrollTop = newTop; } } var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth; var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace; var screenw = displayWidth(cm) - display.gutters.offsetWidth; var tooWide = rect.right - rect.left > screenw; if (tooWide) { rect.right = rect.left + screenw; } if (rect.left < 10) { result.scrollLeft = 0; } else if (rect.left < screenleft) { result.scrollLeft = Math.max( 0, rect.left + gutterSpace - (tooWide ? 0 : 10) ); } else if (rect.right > screenw + screenleft - 3) { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } return result; } // Store a relative adjustment to the scroll position in the current // operation (to be applied when the operation finishes). function addToScrollTop(cm, top) { if (top == null) { return; } resolveScrollToPos(cm); cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; } // Make sure that at the end of the operation the current cursor is // shown. function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(); cm.curOp.scrollToPos = { from: cur, to: cur, margin: cm.options.cursorScrollMargin, }; } function scrollToCoords(cm, x, y) { if (x != null || y != null) { resolveScrollToPos(cm); } if (x != null) { cm.curOp.scrollLeft = x; } if (y != null) { cm.curOp.scrollTop = y; } } function scrollToRange(cm, range) { resolveScrollToPos(cm); cm.curOp.scrollToPos = range; } // When an operation has its scrollToPos property set, and another // scroll action is applied before the end of the operation, this // 'simulates' scrolling that position into view in a cheap way, so // that the effect of intermediate scroll commands is not ignored. function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); scrollToCoordsRange(cm, from, to, range.margin); } } function scrollToCoordsRange(cm, from, to, margin) { var sPos = calculateScrollPos(cm, { left: Math.min(from.left, to.left), top: Math.min(from.top, to.top) - margin, right: Math.max(from.right, to.right), bottom: Math.max(from.bottom, to.bottom) + margin, }); scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop); } // Sync the scrollable area and scrollbars, ensure the viewport // covers the visible area. function updateScrollTop(cm, val) { if (Math.abs(cm.doc.scrollTop - val) < 2) { return; } if (!gecko) { updateDisplaySimple(cm, { top: val }); } setScrollTop(cm, val, true); if (gecko) { updateDisplaySimple(cm); } startWorker(cm, 100); } function setScrollTop(cm, val, forceScroll) { val = Math.max( 0, Math.min( cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val ) ); if (cm.display.scroller.scrollTop == val && !forceScroll) { return; } cm.doc.scrollTop = val; cm.display.scrollbars.setScrollTop(val); if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; } } // Sync scroller and scrollbar, ensure the gutter elements are // aligned. function setScrollLeft(cm, val, isScroller, forceScroll) { val = Math.max( 0, Math.min( val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth ) ); if ( (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll ) { return; } cm.doc.scrollLeft = val; alignHorizontally(cm); if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; } cm.display.scrollbars.setScrollLeft(val); } // SCROLLBARS // Prepare DOM reads needed to update the scrollbars. Done in one // shot to minimize update/measure roundtrips. function measureForScrollbars(cm) { var d = cm.display, gutterW = d.gutters.offsetWidth; var docH = Math.round(cm.doc.height + paddingVert(cm.display)); return { clientHeight: d.scroller.clientHeight, viewHeight: d.wrapper.clientHeight, scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, viewWidth: d.wrapper.clientWidth, barLeft: cm.options.fixedGutter ? gutterW : 0, docHeight: docH, scrollHeight: docH + scrollGap(cm) + d.barHeight, nativeBarWidth: d.nativeBarWidth, gutterWidth: gutterW, }; } var NativeScrollbars = function (place, scroll, cm) { this.cm = cm; var vert = (this.vert = elt( "div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar" )); var horiz = (this.horiz = elt( "div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar" )); vert.tabIndex = horiz.tabIndex = -1; place(vert); place(horiz); on(vert, "scroll", function () { if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); } }); on(horiz, "scroll", function () { if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); } }); this.checkedZeroWidth = false; // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; } }; NativeScrollbars.prototype.update = function (measure) { var needsH = measure.scrollWidth > measure.clientWidth + 1; var needsV = measure.scrollHeight > measure.clientHeight + 1; var sWidth = measure.nativeBarWidth; if (needsV) { this.vert.style.display = "block"; this.vert.style.bottom = needsH ? sWidth + "px" : "0"; var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); // A bug in IE8 can cause this value to be negative, so guard it. this.vert.firstChild.style.height = Math.max( 0, measure.scrollHeight - measure.clientHeight + totalHeight ) + "px"; } else { this.vert.scrollTop = 0; this.vert.style.display = ""; this.vert.firstChild.style.height = "0"; } if (needsH) { this.horiz.style.display = "block"; this.horiz.style.right = needsV ? sWidth + "px" : "0"; this.horiz.style.left = measure.barLeft + "px"; var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); this.horiz.firstChild.style.width = Math.max( 0, measure.scrollWidth - measure.clientWidth + totalWidth ) + "px"; } else { this.horiz.style.display = ""; this.horiz.firstChild.style.width = "0"; } if (!this.checkedZeroWidth && measure.clientHeight > 0) { if (sWidth == 0) { this.zeroWidthHack(); } this.checkedZeroWidth = true; } return { right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0 }; }; NativeScrollbars.prototype.setScrollLeft = function (pos) { if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; } if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); } }; NativeScrollbars.prototype.setScrollTop = function (pos) { if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; } if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); } }; NativeScrollbars.prototype.zeroWidthHack = function () { var w = mac && !mac_geMountainLion ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = w; this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"; this.disableHoriz = new Delayed(); this.disableVert = new Delayed(); }; NativeScrollbars.prototype.enableZeroWidthBar = function ( bar, delay, type ) { bar.style.pointerEvents = "auto"; function maybeDisable() { // To find out whether the scrollbar is still visible, we // check whether the element under the pixel in the bottom // right corner of the scrollbar box is the scrollbar box // itself (when the bar is still visible) or its filler child // (when the bar is hidden). If it is still visible, we keep // it enabled, if it's hidden, we disable pointer events. var box = bar.getBoundingClientRect(); var elt = type == "vert" ? document.elementFromPoint( box.right - 1, (box.top + box.bottom) / 2 ) : document.elementFromPoint( (box.right + box.left) / 2, box.bottom - 1 ); if (elt != bar) { bar.style.pointerEvents = "none"; } else { delay.set(1000, maybeDisable); } } delay.set(1000, maybeDisable); }; NativeScrollbars.prototype.clear = function () { var parent = this.horiz.parentNode; parent.removeChild(this.horiz); parent.removeChild(this.vert); }; var NullScrollbars = function () {}; NullScrollbars.prototype.update = function () { return { bottom: 0, right: 0 }; }; NullScrollbars.prototype.setScrollLeft = function () {}; NullScrollbars.prototype.setScrollTop = function () {}; NullScrollbars.prototype.clear = function () {}; function updateScrollbars(cm, measure) { if (!measure) { measure = measureForScrollbars(cm); } var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; updateScrollbarsInner(cm, measure); for ( var i = 0; (i < 4 && startWidth != cm.display.barWidth) || startHeight != cm.display.barHeight; i++ ) { if (startWidth != cm.display.barWidth && cm.options.lineWrapping) { updateHeightsInViewport(cm); } updateScrollbarsInner(cm, measureForScrollbars(cm)); startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; } } // Re-synchronize the fake scrollbars with the actual size of the // content. function updateScrollbarsInner(cm, measure) { var d = cm.display; var sizes = d.scrollbars.update(measure); d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"; if (sizes.right && sizes.bottom) { d.scrollbarFiller.style.display = "block"; d.scrollbarFiller.style.height = sizes.bottom + "px"; d.scrollbarFiller.style.width = sizes.right + "px"; } else { d.scrollbarFiller.style.display = ""; } if ( sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter ) { d.gutterFiller.style.display = "block"; d.gutterFiller.style.height = sizes.bottom + "px"; d.gutterFiller.style.width = measure.gutterWidth + "px"; } else { d.gutterFiller.style.display = ""; } } var scrollbarModel = { native: NativeScrollbars, null: NullScrollbars }; function initScrollbars(cm) { if (cm.display.scrollbars) { cm.display.scrollbars.clear(); if (cm.display.scrollbars.addClass) { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle]( function (node) { cm.display.wrapper.insertBefore( node, cm.display.scrollbarFiller ); // Prevent clicks in the scrollbars from killing focus on(node, "mousedown", function () { if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); } }); node.setAttribute("cm-not-content", "true"); }, function (pos, axis) { if (axis == "horizontal") { setScrollLeft(cm, pos); } else { updateScrollTop(cm, pos); } }, cm ); if (cm.display.scrollbars.addClass) { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } // Operations are used to wrap a series of changes to the editor // state in such a way that each change won't have to update the // cursor and display (which would be awkward, slow, and // error-prone). Instead, display updates are batched and then all // combined and executed at once. var nextOpId = 0; // Start a new operation. function startOperation(cm) { cm.curOp = { cm: cm, viewChanged: false, // Flag that indicates that lines might need to be redrawn startHeight: cm.doc.height, // Used to detect need to update scrollbar forceUpdate: false, // Used to force a redraw updateInput: 0, // Whether to reset the input textarea typing: false, // Whether this reset should be careful to leave existing text (for compositing) changeObjs: null, // Accumulated changes, for firing change events cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already selectionChanged: false, // Whether the selection needs to be redrawn updateMaxLine: false, // Set when the widest line needs to be determined anew scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet scrollToPos: null, // Used to scroll to a specific position focus: false, id: ++nextOpId, // Unique ID markArrays: null, // Used by addMarkedSpan }; pushOperation(cm.curOp); } // Finish an operation, updating the display and signalling delayed events function endOperation(cm) { var op = cm.curOp; if (op) { finishOperation(op, function (group) { for (var i = 0; i < group.ops.length; i++) { group.ops[i].cm.curOp = null; } endOperations(group); }); } } // The DOM updates done when an operation finishes are batched so // that the minimum number of relayouts are required. function endOperations(group) { var ops = group.ops; for ( var i = 0; i < ops.length; i++ // Read DOM ) { endOperation_R1(ops[i]); } for ( var i$1 = 0; i$1 < ops.length; i$1++ // Write DOM (maybe) ) { endOperation_W1(ops[i$1]); } for ( var i$2 = 0; i$2 < ops.length; i$2++ // Read DOM ) { endOperation_R2(ops[i$2]); } for ( var i$3 = 0; i$3 < ops.length; i$3++ // Write DOM (maybe) ) { endOperation_W2(ops[i$3]); } for ( var i$4 = 0; i$4 < ops.length; i$4++ // Read DOM ) { endOperation_finish(ops[i$4]); } } function endOperation_R1(op) { var cm = op.cm, display = cm.display; maybeClipScrollbars(cm); if (op.updateMaxLine) { findMaxLine(cm); } op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || (op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo)) || (display.maxLineChanged && cm.options.lineWrapping); op.update = op.mustUpdate && new DisplayUpdate( cm, op.mustUpdate && { top: op.scrollTop, ensure: op.scrollToPos }, op.forceUpdate ); } function endOperation_W1(op) { op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); } function endOperation_R2(op) { var cm = op.cm, display = cm.display; if (op.updatedDisplay) { updateHeightsInViewport(cm); } op.barMeasure = measureForScrollbars(cm); // If the max line changed since it was last measured, measure it, // and ensure the document's width matches it. // updateDisplay_W2 will use these properties to do the actual resizing if (display.maxLineChanged && !cm.options.lineWrapping) { op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length) .left + 3; cm.display.sizerWidth = op.adjustWidthTo; op.barMeasure.scrollWidth = Math.max( display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth ); op.maxScrollLeft = Math.max( 0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm) ); } if (op.updatedDisplay || op.selectionChanged) { op.preparedSelection = display.input.prepareSelection(); } } function endOperation_W2(op) { var cm = op.cm; if (op.adjustWidthTo != null) { cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; if (op.maxScrollLeft < cm.doc.scrollLeft) { setScrollLeft( cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true ); } cm.display.maxLineChanged = false; } var takeFocus = op.focus && op.focus == activeElt(); if (op.preparedSelection) { cm.display.input.showSelection(op.preparedSelection, takeFocus); } if (op.updatedDisplay || op.startHeight != cm.doc.height) { updateScrollbars(cm, op.barMeasure); } if (op.updatedDisplay) { setDocumentHeight(cm, op.barMeasure); } if (op.selectionChanged) { restartBlink(cm); } if (cm.state.focused && op.updateInput) { cm.display.input.reset(op.typing); } if (takeFocus) { ensureFocus(op.cm); } } function endOperation_finish(op) { var cm = op.cm, display = cm.display, doc = cm.doc; if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); } // Abort mouse wheel delta measurement, when scrolling explicitly if ( display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos) ) { display.wheelStartX = display.wheelStartY = null; } // Propagate the scroll position to the actual DOM scroller if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); } if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); } // If we need to scroll a specific position into view, do so. if (op.scrollToPos) { var rect = scrollPosIntoView( cm, clipPos(doc, op.scrollToPos.from), clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin ); maybeScrollWindow(cm, rect); } // Fire events for markers that are hidden/unidden by editing or // undoing var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; if (hidden) { for (var i = 0; i < hidden.length; ++i) { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } } if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1) { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } } if (display.wrapper.offsetHeight) { doc.scrollTop = cm.display.scroller.scrollTop; } // Fire change events, and delayed event handlers if (op.changeObjs) { signal(cm, "changes", cm, op.changeObjs); } if (op.update) { op.update.finish(); } } // Run the given function in an operation function runInOp(cm, f) { if (cm.curOp) { return f(); } startOperation(cm); try { return f(); } finally { endOperation(cm); } } // Wraps a function in an operation. Returns the wrapped function. function operation(cm, f) { return function () { if (cm.curOp) { return f.apply(cm, arguments); } startOperation(cm); try { return f.apply(cm, arguments); } finally { endOperation(cm); } }; } // Used to add methods to editor and doc instances, wrapping them in // operations. function methodOp(f) { return function () { if (this.curOp) { return f.apply(this, arguments); } startOperation(this); try { return f.apply(this, arguments); } finally { endOperation(this); } }; } function docMethodOp(f) { return function () { var cm = this.cm; if (!cm || cm.curOp) { return f.apply(this, arguments); } startOperation(cm); try { return f.apply(this, arguments); } finally { endOperation(cm); } }; } // HIGHLIGHT WORKER function startWorker(cm, time) { if (cm.doc.highlightFrontier < cm.display.viewTo) { cm.state.highlight.set(time, bind(highlightWorker, cm)); } } function highlightWorker(cm) { var doc = cm.doc; if (doc.highlightFrontier >= cm.display.viewTo) { return; } var end = +new Date() + cm.options.workTime; var context = getContextBefore(cm, doc.highlightFrontier); var changedLines = []; doc.iter( context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { if (context.line >= cm.display.viewFrom) { // Visible var oldStyles = line.styles; var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null; var highlighted = highlightLine(cm, line, context, true); if (resetState) { context.state = resetState; } line.styles = highlighted.styles; var oldCls = line.styleClasses, newCls = highlighted.classes; if (newCls) { line.styleClasses = newCls; } else if (oldCls) { line.styleClasses = null; } var ischange = !oldStyles || oldStyles.length != line.styles.length || (oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass)); for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; } if (ischange) { changedLines.push(context.line); } line.stateAfter = context.save(); context.nextLine(); } else { if (line.text.length <= cm.options.maxHighlightLength) { processLine(cm, line.text, context); } line.stateAfter = context.line % 5 == 0 ? context.save() : null; context.nextLine(); } if (+new Date() > end) { startWorker(cm, cm.options.workDelay); return true; } } ); doc.highlightFrontier = context.line; doc.modeFrontier = Math.max(doc.modeFrontier, context.line); if (changedLines.length) { runInOp(cm, function () { for (var i = 0; i < changedLines.length; i++) { regLineChange(cm, changedLines[i], "text"); } }); } } // DISPLAY DRAWING var DisplayUpdate = function (cm, viewport, force) { var display = cm.display; this.viewport = viewport; // Store some values that we'll need later (but don't want to force a relayout for) this.visible = visibleLines(display, cm.doc, viewport); this.editorIsHidden = !display.wrapper.offsetWidth; this.wrapperHeight = display.wrapper.clientHeight; this.wrapperWidth = display.wrapper.clientWidth; this.oldDisplayWidth = displayWidth(cm); this.force = force; this.dims = getDimensions(cm); this.events = []; }; DisplayUpdate.prototype.signal = function (emitter, type) { if (hasHandler(emitter, type)) { this.events.push(arguments); } }; DisplayUpdate.prototype.finish = function () { for (var i = 0; i < this.events.length; i++) { signal.apply(null, this.events[i]); } }; function maybeClipScrollbars(cm) { var display = cm.display; if (!display.scrollbarsClipped && display.scroller.offsetWidth) { display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; display.heightForcer.style.height = scrollGap(cm) + "px"; display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; display.scrollbarsClipped = true; } } function selectionSnapshot(cm) { if (cm.hasFocus()) { return null; } var active = activeElt(); if (!active || !contains(cm.display.lineDiv, active)) { return null; } var result = { activeElt: active }; if (window.getSelection) { var sel = window.getSelection(); if ( sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode) ) { result.anchorNode = sel.anchorNode; result.anchorOffset = sel.anchorOffset; result.focusNode = sel.focusNode; result.focusOffset = sel.focusOffset; } } return result; } function restoreSelection(snapshot) { if ( !snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt() ) { return; } snapshot.activeElt.focus(); if ( !/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode) ) { var sel = window.getSelection(), range = document.createRange(); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); range.collapse(false); sel.removeAllRanges(); sel.addRange(range); sel.extend(snapshot.focusNode, snapshot.focusOffset); } } // Does the actual updating of the line display. Bails out // (returning false) when there is nothing to be done and forced is // false. function updateDisplayIfNeeded(cm, update) { var display = cm.display, doc = cm.doc; if (update.editorIsHidden) { resetView(cm); return false; } // Bail out if the visible area is already rendered and nothing changed. if ( !update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0 ) { return false; } if (maybeUpdateLineNumberWidth(cm)) { resetView(cm); update.dims = getDimensions(cm); } // Compute a suitable new viewport (from & to) var end = doc.first + doc.size; var from = Math.max( update.visible.from - cm.options.viewportMargin, doc.first ); var to = Math.min(end, update.visible.to + cm.options.viewportMargin); if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); } if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); } if (sawCollapsedSpans) { from = visualLineNo(cm.doc, from); to = visualLineEndNo(cm.doc, to); } var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; adjustView(cm, from, to); display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); // Position the mover div to align with the current scroll position cm.display.mover.style.top = display.viewOffset + "px"; var toUpdate = countDirtyView(cm); if ( !different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) ) { return false; } // For big changes, we hide the enclosing element during the // update, since that speeds up the operations on most browsers. var selSnapshot = selectionSnapshot(cm); if (toUpdate > 4) { display.lineDiv.style.display = "none"; } patchDisplay(cm, display.updateLineNumbers, update.dims); if (toUpdate > 4) { display.lineDiv.style.display = ""; } display.renderedView = display.view; // There might have been a widget with a focused element that got // hidden or updated, if so re-focus it. restoreSelection(selSnapshot); // Prevent selection and cursors from interfering with the scroll // width and height. removeChildren(display.cursorDiv); removeChildren(display.selectionDiv); display.gutters.style.height = display.sizer.style.minHeight = 0; if (different) { display.lastWrapHeight = update.wrapperHeight; display.lastWrapWidth = update.wrapperWidth; startWorker(cm, 400); } display.updateLineNumbers = null; return true; } function postUpdateDisplay(cm, update) { var viewport = update.viewport; for (var first = true; ; first = false) { if ( !first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm) ) { // Clip forced viewport to actual scrollable area. if (viewport && viewport.top != null) { viewport = { top: Math.min( cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top ), }; } // Updated line heights might result in the drawn area not // actually covering the viewport. Keep looping until it does. update.visible = visibleLines(cm.display, cm.doc, viewport); if ( update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo ) { break; } } else if (first) { update.visible = visibleLines(cm.display, cm.doc, viewport); } if (!updateDisplayIfNeeded(cm, update)) { break; } updateHeightsInViewport(cm); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.force = false; } update.signal(cm, "update", cm); if ( cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo ) { update.signal( cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo ); cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; } } function updateDisplaySimple(cm, viewport) { var update = new DisplayUpdate(cm, viewport); if (updateDisplayIfNeeded(cm, update)) { updateHeightsInViewport(cm); postUpdateDisplay(cm, update); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.finish(); } } // Sync the actual display DOM structure with display.view, removing // nodes for lines that are no longer in view, and creating the ones // that are not there yet, and updating the ones that are out of // date. function patchDisplay(cm, updateNumbersFrom, dims) { var display = cm.display, lineNumbers = cm.options.lineNumbers; var container = display.lineDiv, cur = container.firstChild; function rm(node) { var next = node.nextSibling; // Works around a throw-scroll bug in OS X Webkit if (webkit && mac && cm.display.currentWheelTarget == node) { node.style.display = "none"; } else { node.parentNode.removeChild(node); } return next; } var view = display.view, lineN = display.viewFrom; // Loop over the elements in the view, syncing cur (the DOM nodes // in display.lineDiv) with the view as we go. for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (lineView.hidden); else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet var node = buildLineElement(cm, lineView, lineN, dims); container.insertBefore(node, cur); } else { // Already drawn while (cur != lineView.node) { cur = rm(cur); } var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber; if (lineView.changes) { if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; } updateLineForChanges(cm, lineView, lineN, dims); } if (updateNumber) { removeChildren(lineView.lineNumber); lineView.lineNumber.appendChild( document.createTextNode( lineNumberFor(cm.options, lineN) ) ); } cur = lineView.node.nextSibling; } lineN += lineView.size; } while (cur) { cur = rm(cur); } } function updateGutterSpace(display) { var width = display.gutters.offsetWidth; display.sizer.style.marginLeft = width + "px"; // Send an event to consumers responding to changes in gutter width. signalLater(display, "gutterChanged", display); } function setDocumentHeight(cm, measure) { cm.display.sizer.style.minHeight = measure.docHeight + "px"; cm.display.heightForcer.style.top = measure.docHeight + "px"; cm.display.gutters.style.height = measure.docHeight + cm.display.barHeight + scrollGap(cm) + "px"; } // Re-align line numbers and gutter marks to compensate for // horizontal scrolling. function alignHorizontally(cm) { var display = cm.display, view = display.view; if ( !display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter) ) { return; } var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; var gutterW = display.gutters.offsetWidth, left = comp + "px"; for (var i = 0; i < view.length; i++) { if (!view[i].hidden) { if (cm.options.fixedGutter) { if (view[i].gutter) { view[i].gutter.style.left = left; } if (view[i].gutterBackground) { view[i].gutterBackground.style.left = left; } } var align = view[i].alignable; if (align) { for (var j = 0; j < align.length; j++) { align[j].style.left = left; } } } } if (cm.options.fixedGutter) { display.gutters.style.left = comp + gutterW + "px"; } } // Used to ensure that the line number gutter is still the right // size for the current document size. Returns true when an update // is needed. function maybeUpdateLineNumberWidth(cm) { if (!cm.options.lineNumbers) { return false; } var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; if (last.length != display.lineNumChars) { var test = display.measure.appendChild( elt( "div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt" ) ); var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; display.lineGutter.style.width = ""; display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; display.lineNumWidth = display.lineNumInnerWidth + padding; display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; display.lineGutter.style.width = display.lineNumWidth + "px"; updateGutterSpace(cm.display); return true; } return false; } function getGutters(gutters, lineNumbers) { var result = [], sawLineNumbers = false; for (var i = 0; i < gutters.length; i++) { var name = gutters[i], style = null; if (typeof name != "string") { style = name.style; name = name.className; } if (name == "CodeMirror-linenumbers") { if (!lineNumbers) { continue; } else { sawLineNumbers = true; } } result.push({ className: name, style: style }); } if (lineNumbers && !sawLineNumbers) { result.push({ className: "CodeMirror-linenumbers", style: null }); } return result; } // Rebuild the gutter elements, ensure the margin to the left of the // code matches their width. function renderGutters(display) { var gutters = display.gutters, specs = display.gutterSpecs; removeChildren(gutters); display.lineGutter = null; for (var i = 0; i < specs.length; ++i) { var ref = specs[i]; var className = ref.className; var style = ref.style; var gElt = gutters.appendChild( elt("div", null, "CodeMirror-gutter " + className) ); if (style) { gElt.style.cssText = style; } if (className == "CodeMirror-linenumbers") { display.lineGutter = gElt; gElt.style.width = (display.lineNumWidth || 1) + "px"; } } gutters.style.display = specs.length ? "" : "none"; updateGutterSpace(display); } function updateGutters(cm) { renderGutters(cm.display); regChange(cm); alignHorizontally(cm); } // The display handles the DOM integration, both for input reading // and content drawing. It holds references to DOM nodes and // display-related state. function Display(place, doc, input, options) { var d = this; this.input = input; // Covers bottom-right square when both scrollbars are present. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); d.scrollbarFiller.setAttribute("cm-not-content", "true"); // Covers bottom of gutter when coverGutterNextToScrollbar is on // and h scrollbar is present. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); d.gutterFiller.setAttribute("cm-not-content", "true"); // Will contain the actual code, positioned to cover the viewport. d.lineDiv = eltP("div", null, "CodeMirror-code"); // Elements are added to these to represent selection and cursors. d.selectionDiv = elt( "div", null, null, "position: relative; z-index: 1" ); d.cursorDiv = elt("div", null, "CodeMirror-cursors"); // A visibility: hidden element used to find the size of things. d.measure = elt("div", null, "CodeMirror-measure"); // When lines outside of the viewport are measured, they are drawn in this. d.lineMeasure = elt("div", null, "CodeMirror-measure"); // Wraps everything that needs to exist inside the vertically-padded coordinate system d.lineSpace = eltP( "div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none" ); var lines = eltP("div", [d.lineSpace], "CodeMirror-lines"); // Moved around its parent to cover visible view. d.mover = elt("div", [lines], null, "position: relative"); // Set to the height of the document, allowing scrolling. d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); d.sizerWidth = null; // Behavior of elts with overflow: auto and padding is // inconsistent across browsers. This is used to ensure the // scrollable area is big enough. d.heightForcer = elt( "div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;" ); // Will contain the gutters, if any. d.gutters = elt("div", null, "CodeMirror-gutters"); d.lineGutter = null; // Actual scrollable element. d.scroller = elt( "div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll" ); d.scroller.setAttribute("tabIndex", "-1"); // The element in which the editor lives. d.wrapper = elt( "div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror" ); // This attribute is respected by automatic translation systems such as Google Translate, // and may also be respected by tools used by human translators. d.wrapper.setAttribute("translate", "no"); // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; } if (place) { if (place.appendChild) { place.appendChild(d.wrapper); } else { place(d.wrapper); } } // Current rendered range (may be bigger than the view window). d.viewFrom = d.viewTo = doc.first; d.reportedViewFrom = d.reportedViewTo = doc.first; // Information about the rendered lines. d.view = []; d.renderedView = null; // Holds info about a single rendered line when it was rendered // for measurement, while not in view. d.externalMeasured = null; // Empty space (in pixels) above the view d.viewOffset = 0; d.lastWrapHeight = d.lastWrapWidth = 0; d.updateLineNumbers = null; d.nativeBarWidth = d.barHeight = d.barWidth = 0; d.scrollbarsClipped = false; // Used to only resize the line number gutter when necessary (when // the amount of lines crosses a boundary that makes its width change) d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; // Set to true when a non-horizontal-scrolling line widget is // added. As an optimization, line widget aligning is skipped when // this is false. d.alignWidgets = false; d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; // Tracks the maximum line length so that the horizontal scrollbar // can be kept static when scrolling. d.maxLine = null; d.maxLineLength = 0; d.maxLineChanged = false; // Used for measuring wheel scrolling granularity d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; // True when shift is held down. d.shift = false; // Used to track whether anything happened since the context menu // was opened. d.selForContextMenu = null; d.activeTouch = null; d.gutterSpecs = getGutters(options.gutters, options.lineNumbers); renderGutters(d); input.init(d); } // Since the delta values reported on mouse wheel events are // unstandardized between browsers and even browser versions, and // generally horribly unpredictable, this code starts by measuring // the scroll effect that the first few mouse wheel events have, // and, from that, detects the way it can convert deltas to pixel // offsets afterwards. // // The reason we want to know the amount a wheel event will scroll // is that it gives us a chance to update the display before the // actual scrolling happens, reducing flickering. var wheelSamples = 0, wheelPixelsPerUnit = null; // Fill in a browser-detected starting value on browsers where we // know one. These don't have to be accurate -- the result of them // being wrong would just be a slight flicker on the first wheel // scroll (if it is large enough). if (ie) { wheelPixelsPerUnit = -0.53; } else if (gecko) { wheelPixelsPerUnit = 15; } else if (chrome) { wheelPixelsPerUnit = -0.7; } else if (safari) { wheelPixelsPerUnit = -1 / 3; } function wheelEventDelta(e) { var dx = e.wheelDeltaX, dy = e.wheelDeltaY; if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; } if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; } else if (dy == null) { dy = e.wheelDelta; } return { x: dx, y: dy }; } function wheelEventPixels(e) { var delta = wheelEventDelta(e); delta.x *= wheelPixelsPerUnit; delta.y *= wheelPixelsPerUnit; return delta; } function onScrollWheel(cm, e) { var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; var pixelsPerUnit = wheelPixelsPerUnit; if (e.deltaMode === 0) { dx = e.deltaX; dy = e.deltaY; pixelsPerUnit = 1; } var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here var canScrollX = scroll.scrollWidth > scroll.clientWidth; var canScrollY = scroll.scrollHeight > scroll.clientHeight; if (!((dx && canScrollX) || (dy && canScrollY))) { return; } // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. // This hack (see related code in patchDisplay) makes sure the // element is kept around. if (dy && mac && webkit) { outer: for ( var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode ) { for (var i = 0; i < view.length; i++) { if (view[i].node == cur) { cm.display.currentWheelTarget = cur; break outer; } } } } // On some browsers, horizontal scrolling will cause redraws to // happen before the gutter has been realigned, causing it to // wriggle around in a most unseemly way. When we have an // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && pixelsPerUnit != null) { if (dy && canScrollY) { updateScrollTop( cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit) ); } setScrollLeft( cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit) ); // Only prevent default scrolling if vertical scrolling is // actually possible. Otherwise, it causes vertical scroll // jitter on OSX trackpads when deltaX is small and deltaY // is large (issue #3579) if (!dy || (dy && canScrollY)) { e_preventDefault(e); } display.wheelStartX = null; // Abort measurement, if in progress return; } // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). if (dy && pixelsPerUnit != null) { var pixels = dy * pixelsPerUnit; var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; if (pixels < 0) { top = Math.max(0, top + pixels - 50); } else { bot = Math.min(cm.doc.height, bot + pixels + 50); } updateDisplaySimple(cm, { top: top, bottom: bot }); } if (wheelSamples < 20 && e.deltaMode !== 0) { if (display.wheelStartX == null) { display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; display.wheelDX = dx; display.wheelDY = dy; setTimeout(function () { if (display.wheelStartX == null) { return; } var movedX = scroll.scrollLeft - display.wheelStartX; var movedY = scroll.scrollTop - display.wheelStartY; var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || (movedX && display.wheelDX && movedX / display.wheelDX); display.wheelStartX = display.wheelStartY = null; if (!sample) { return; } wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); ++wheelSamples; }, 200); } else { display.wheelDX += dx; display.wheelDY += dy; } } } // Selection objects are immutable. A new one is created every time // the selection changes. A selection is one or more non-overlapping // (and non-touching) ranges, sorted, and an integer that indicates // which one is the primary selection (the one that's scrolled into // view, that getCursor returns, etc). var Selection = function (ranges, primIndex) { this.ranges = ranges; this.primIndex = primIndex; }; Selection.prototype.primary = function () { return this.ranges[this.primIndex]; }; Selection.prototype.equals = function (other) { if (other == this) { return true; } if ( other.primIndex != this.primIndex || other.ranges.length != this.ranges.length ) { return false; } for (var i = 0; i < this.ranges.length; i++) { var here = this.ranges[i], there = other.ranges[i]; if ( !equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head) ) { return false; } } return true; }; Selection.prototype.deepCopy = function () { var out = []; for (var i = 0; i < this.ranges.length; i++) { out[i] = new Range( copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head) ); } return new Selection(out, this.primIndex); }; Selection.prototype.somethingSelected = function () { for (var i = 0; i < this.ranges.length; i++) { if (!this.ranges[i].empty()) { return true; } } return false; }; Selection.prototype.contains = function (pos, end) { if (!end) { end = pos; } for (var i = 0; i < this.ranges.length; i++) { var range = this.ranges[i]; if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) { return i; } } return -1; }; var Range = function (anchor, head) { this.anchor = anchor; this.head = head; }; Range.prototype.from = function () { return minPos(this.anchor, this.head); }; Range.prototype.to = function () { return maxPos(this.anchor, this.head); }; Range.prototype.empty = function () { return ( this.head.line == this.anchor.line && this.head.ch == this.anchor.ch ); }; // Take an unsorted, potentially overlapping set of ranges, and // build a selection out of it. 'Consumes' ranges array (modifying // it). function normalizeSelection(cm, ranges, primIndex) { var mayTouch = cm && cm.options.selectionsMayTouch; var prim = ranges[primIndex]; ranges.sort(function (a, b) { return cmp(a.from(), b.from()); }); primIndex = indexOf(ranges, prim); for (var i = 1; i < ranges.length; i++) { var cur = ranges[i], prev = ranges[i - 1]; var diff = cmp(prev.to(), cur.from()); if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; if (i <= primIndex) { --primIndex; } ranges.splice( --i, 2, new Range(inv ? to : from, inv ? from : to) ); } } return new Selection(ranges, primIndex); } function simpleSelection(anchor, head) { return new Selection([new Range(anchor, head || anchor)], 0); } // Compute the position of the end of a change (its 'to' property // refers to the pre-change end). function changeEnd(change) { if (!change.text) { return change.to; } return Pos( change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0) ); } // Adjust a position to refer to the post-change position of the // same text, or the end of the change if the change covers it. function adjustForChange(pos, change) { if (cmp(pos, change.from) < 0) { return pos; } if (cmp(pos, change.to) <= 0) { return changeEnd(change); } var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; } return Pos(line, ch); } function computeSelAfterChange(doc, change) { var out = []; for (var i = 0; i < doc.sel.ranges.length; i++) { var range = doc.sel.ranges[i]; out.push( new Range( adjustForChange(range.anchor, change), adjustForChange(range.head, change) ) ); } return normalizeSelection(doc.cm, out, doc.sel.primIndex); } function offsetPos(pos, old, nw) { if (pos.line == old.line) { return Pos(nw.line, pos.ch - old.ch + nw.ch); } else { return Pos(nw.line + (pos.line - old.line), pos.ch); } } // Used by replaceSelections to allow moving the selection to the // start or around the replaced test. Hint may be "start" or "around". function computeReplacedSel(doc, changes, hint) { var out = []; var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; for (var i = 0; i < changes.length; i++) { var change = changes[i]; var from = offsetPos(change.from, oldPrev, newPrev); var to = offsetPos(changeEnd(change), oldPrev, newPrev); oldPrev = change.to; newPrev = to; if (hint == "around") { var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; out[i] = new Range(inv ? to : from, inv ? from : to); } else { out[i] = new Range(from, from); } } return new Selection(out, doc.sel.primIndex); } // Used to get the editor into a consistent state again when options change. function loadMode(cm) { cm.doc.mode = getMode(cm.options, cm.doc.modeOption); resetModeState(cm); } function resetModeState(cm) { cm.doc.iter(function (line) { if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } }); cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first; startWorker(cm, 100); cm.state.modeGen++; if (cm.curOp) { regChange(cm); } } // DOCUMENT DATA STRUCTURE // By default, updates that start and end at the beginning of a line // are treated specially, in order to make the association of line // widgets and marker elements with the text behave more intuitive. function isWholeLineUpdate(doc, change) { return ( change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore) ); } // Perform a change on the document data structure. function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) { return markedSpans ? markedSpans[n] : null; } function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); } function linesFor(start, end) { var result = []; for (var i = start; i < end; ++i) { result.push(new Line(text[i], spansFor(i), estimateHeight)); } return result; } var from = change.from, to = change.to, text = change.text; var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) { doc.insert(0, linesFor(0, text.length)); doc.remove(text.length, doc.size - text.length); } else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans); if (nlines) { doc.remove(from.line, nlines); } if (added.length) { doc.insert(from.line, added); } } else if (firstLine == lastLine) { if (text.length == 1) { update( firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans ); } else { var added$1 = linesFor(1, text.length - 1); added$1.push( new Line( lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight ) ); update( firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0) ); doc.insert(from.line + 1, added$1); } } else if (text.length == 1) { update( firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0) ); doc.remove(from.line + 1, nlines); } else { update( firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0) ); update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added$2 = linesFor(1, text.length - 1); if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); } doc.insert(from.line + 1, added$2); } signalLater(doc, "change", doc, change); } // Call f for all linked documents. function linkedDocs(doc, f, sharedHistOnly) { function propagate(doc, skip, sharedHist) { if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) { continue; } var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) { continue; } f(rel.doc, shared); propagate(rel.doc, doc, shared); } } } propagate(doc, null, true); } // Attach a document to an editor. function attachDoc(cm, doc) { if (doc.cm) { throw new Error("This document is already in use."); } cm.doc = doc; doc.cm = cm; estimateLineHeights(cm); loadMode(cm); setDirectionClass(cm); cm.options.direction = doc.direction; if (!cm.options.lineWrapping) { findMaxLine(cm); } cm.options.mode = doc.modeOption; regChange(cm); } function setDirectionClass(cm) { (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); } function directionChanged(cm) { runInOp(cm, function () { setDirectionClass(cm); regChange(cm); }); } function History(prev) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = []; this.undone = []; this.undoDepth = prev ? prev.undoDepth : Infinity; // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1; } // Create a history change event from an updateDoc-style change // object. function historyChangeFromChange(doc, change) { var histChange = { from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to), }; attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); linkedDocs( doc, function (doc) { return attachLocalSpans( doc, histChange, change.from.line, change.to.line + 1 ); }, true ); return histChange; } // Pop all selection events off the end of a history array. Stop at // a change event. function clearSelectionEvents(array) { while (array.length) { var last = lst(array); if (last.ranges) { array.pop(); } else { break; } } } // Find the top change event in the history. Pop off selection // events that are in the way. function lastChangeEvent(hist, force) { if (force) { clearSelectionEvents(hist.done); return lst(hist.done); } else if (hist.done.length && !lst(hist.done).ranges) { return lst(hist.done); } else if ( hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges ) { hist.done.pop(); return lst(hist.done); } } // Register a change in the history. Merges changes that are within // a single operation, or are close together with an origin that // allows merging (starting with "+") into a single event. function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; hist.undone.length = 0; var time = +new Date(), cur; var last; if ( (hist.lastOp == opId || (hist.lastOrigin == change.origin && change.origin && ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) || change.origin.charAt(0) == "*"))) && (cur = lastChangeEvent(hist, hist.lastOp == opId)) ) { // Merge this change into the last event last = lst(cur.changes); if ( cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0 ) { // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change); } else { // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); } } else { // Can not be merged, start a new event. var before = lst(hist.done); if (!before || !before.ranges) { pushSelectionToHistory(doc.sel, hist.done); } cur = { changes: [historyChangeFromChange(doc, change)], generation: hist.generation, }; hist.done.push(cur); while (hist.done.length > hist.undoDepth) { hist.done.shift(); if (!hist.done[0].ranges) { hist.done.shift(); } } } hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) { signal(doc, "historyAdded"); } } function selectionEventCanBeMerged(doc, origin, prev, sel) { var ch = origin.charAt(0); return ( ch == "*" || (ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date() - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)) ); } // Called whenever the selection changes, sets the new selection as // the pending selection in the history, and pushes the old pending // selection into the 'done' array when it was significantly // different (in number of selected ranges, emptiness, or time). function addSelectionToHistory(doc, sel, opId, options) { var hist = doc.history, origin = options && options.origin; // A new event is started when the previous origin does not match // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. if ( opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && ((hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin) || selectionEventCanBeMerged( doc, origin, lst(hist.done), sel ))) ) { hist.done[hist.done.length - 1] = sel; } else { pushSelectionToHistory(sel, hist.done); } hist.lastSelTime = +new Date(); hist.lastSelOrigin = origin; hist.lastSelOp = opId; if (options && options.clearRedo !== false) { clearSelectionEvents(hist.undone); } } function pushSelectionToHistory(sel, dest) { var top = lst(dest); if (!(top && top.ranges && top.equals(sel))) { dest.push(sel); } } // Used to store marked span information in the history. function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter( Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { if (line.markedSpans) { (existing || (existing = change["spans_" + doc.id] = {}))[ n ] = line.markedSpans; } ++n; } ); } // When un/re-doing restores text containing marked spans, those // that have been explicitly cleared should not be restored. function removeClearedSpans(spans) { if (!spans) { return null; } var out; for (var i = 0; i < spans.length; ++i) { if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } } else if (out) { out.push(spans[i]); } } return !out ? spans : out.length ? out : null; } // Retrieve and filter the old marked spans stored in a change event. function getOldSpans(doc, change) { var found = change["spans_" + doc.id]; if (!found) { return null; } var nw = []; for (var i = 0; i < change.text.length; ++i) { nw.push(removeClearedSpans(found[i])); } return nw; } // Used for un/re-doing changes from the history. Combines the // result of computing the existing spans with the set of spans that // existed in the history (so that deleting around a span and then // undoing brings back the span). function mergeOldSpans(doc, change) { var old = getOldSpans(doc, change); var stretched = stretchSpansOverChange(doc, change); if (!old) { return stretched; } if (!stretched) { return old; } for (var i = 0; i < old.length; ++i) { var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) { spans: for (var j = 0; j < stretchCur.length; ++j) { var span = stretchCur[j]; for (var k = 0; k < oldCur.length; ++k) { if (oldCur[k].marker == span.marker) { continue spans; } } oldCur.push(span); } } else if (stretchCur) { old[i] = stretchCur; } } return old; } // Used both to provide a JSON-safe object in .getHistory, and, when // detaching a document, to split the history in two function copyHistoryArray(events, newGroup, instantiateSel) { var copy = []; for (var i = 0; i < events.length; ++i) { var event = events[i]; if (event.ranges) { copy.push( instantiateSel ? Selection.prototype.deepCopy.call(event) : event ); continue; } var changes = event.changes, newChanges = []; copy.push({ changes: newChanges }); for (var j = 0; j < changes.length; ++j) { var change = changes[j], m = void 0; newChanges.push({ from: change.from, to: change.to, text: change.text, }); if (newGroup) { for (var prop in change) { if ((m = prop.match(/^spans_(\d+)$/))) { if (indexOf(newGroup, Number(m[1])) > -1) { lst(newChanges)[prop] = change[prop]; delete change[prop]; } } } } } } return copy; } // The 'scroll' parameter given to many of these indicated whether // the new cursor position should be scrolled into view after // modifying the selection. // If shift is held or the extend flag is set, extends a range to // include a given position (and optionally a second position). // Otherwise, simply returns the range between the given positions. // Used for cursor motion and such. function extendRange(range, head, other, extend) { if (extend) { var anchor = range.anchor; if (other) { var posBefore = cmp(head, anchor) < 0; if (posBefore != cmp(other, anchor) < 0) { anchor = head; head = other; } else if (posBefore != cmp(head, other) < 0) { head = other; } } return new Range(anchor, head); } else { return new Range(other || head, head); } } // Extend the primary selection range, discard the rest. function extendSelection(doc, head, other, options, extend) { if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); } setSelection( doc, new Selection( [extendRange(doc.sel.primary(), head, other, extend)], 0 ), options ); } // Extend all selections (pos is an array of selections with length // equal the number of selections) function extendSelections(doc, heads, options) { var out = []; var extend = doc.cm && (doc.cm.display.shift || doc.extend); for (var i = 0; i < doc.sel.ranges.length; i++) { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); } var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); setSelection(doc, newSel, options); } // Updates a single range in the selection. function replaceOneSelection(doc, i, range, options) { var ranges = doc.sel.ranges.slice(0); ranges[i] = range; setSelection( doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options ); } // Reset the selection to a single range. function setSimpleSelection(doc, anchor, head, options) { setSelection(doc, simpleSelection(anchor, head), options); } // Give beforeSelectionChange handlers a change to influence a // selection update. function filterSelectionChange(doc, sel, options) { var obj = { ranges: sel.ranges, update: function (ranges) { this.ranges = []; for (var i = 0; i < ranges.length; i++) { this.ranges[i] = new Range( clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head) ); } }, origin: options && options.origin, }; signal(doc, "beforeSelectionChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); } if (obj.ranges != sel.ranges) { return normalizeSelection( doc.cm, obj.ranges, obj.ranges.length - 1 ); } else { return sel; } } function setSelectionReplaceHistory(doc, sel, options) { var done = doc.history.done, last = lst(done); if (last && last.ranges) { done[done.length - 1] = sel; setSelectionNoUndo(doc, sel, options); } else { setSelection(doc, sel, options); } } // Set a new selection. function setSelection(doc, sel, options) { setSelectionNoUndo(doc, sel, options); addSelectionToHistory( doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options ); } function setSelectionNoUndo(doc, sel, options) { if ( hasHandler(doc, "beforeSelectionChange") || (doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) ) { sel = filterSelectionChange(doc, sel, options); } var bias = (options && options.bias) || (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); if ( !(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor" ) { ensureCursorVisible(doc.cm); } } function setSelectionInner(doc, sel) { if (sel.equals(doc.sel)) { return; } doc.sel = sel; if (doc.cm) { doc.cm.curOp.updateInput = 1; doc.cm.curOp.selectionChanged = true; signalCursorActivity(doc.cm); } signalLater(doc, "cursorActivity", doc); } // Verify that the selection does not partially select any atomic // marked ranges. function reCheckSelection(doc) { setSelectionInner( doc, skipAtomicInSelection(doc, doc.sel, null, false) ); } // Return a selection that does not partially select any atomic // ranges. function skipAtomicInSelection(doc, sel, bias, mayClear) { var out; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; var newAnchor = skipAtomic( doc, range.anchor, old && old.anchor, bias, mayClear ); var newHead = skipAtomic( doc, range.head, old && old.head, bias, mayClear ); if (out || newAnchor != range.anchor || newHead != range.head) { if (!out) { out = sel.ranges.slice(0, i); } out[i] = new Range(newAnchor, newHead); } } return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel; } function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { var line = getLine(doc, pos.line); if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var sp = line.markedSpans[i], m = sp.marker; // Determine if we should prevent the cursor being placed to the left/right of an atomic marker // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it // is with selectLeft/Right var preventCursorLeft = "selectLeft" in m ? !m.selectLeft : m.inclusiveLeft; var preventCursorRight = "selectRight" in m ? !m.selectRight : m.inclusiveRight; if ( (sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch)) ) { if (mayClear) { signal(m, "beforeCursorEnter"); if (m.explicitlyCleared) { if (!line.markedSpans) { break; } else { --i; continue; } } } if (!m.atomic) { continue; } if (oldPos) { var near = m.find(dir < 0 ? 1 : -1), diff = void 0; if (dir < 0 ? preventCursorRight : preventCursorLeft) { near = movePos( doc, near, -dir, near && near.line == pos.line ? line : null ); } if ( near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0) ) { return skipAtomicInner( doc, near, pos, dir, mayClear ); } } var far = m.find(dir < 0 ? -1 : 1); if (dir < 0 ? preventCursorLeft : preventCursorRight) { far = movePos( doc, far, dir, far.line == pos.line ? line : null ); } return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null; } } } return pos; } // Ensure a given position is not inside an atomic range. function skipAtomic(doc, pos, oldPos, bias, mayClear) { var dir = bias || 1; var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true)); if (!found) { doc.cantEdit = true; return Pos(doc.first, 0); } return found; } function movePos(doc, pos, dir, line) { if (dir < 0 && pos.ch == 0) { if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)); } else { return null; } } else if ( dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length ) { if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0); } else { return null; } } else { return new Pos(pos.line, pos.ch + dir); } } function selectAll(cm) { cm.setSelection( Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll ); } // UPDATING // Allow "beforeChange" event handlers to influence a change function filterChange(doc, change, update) { var obj = { canceled: false, from: change.from, to: change.to, text: change.text, origin: change.origin, cancel: function () { return (obj.canceled = true); }, }; if (update) { obj.update = function (from, to, text, origin) { if (from) { obj.from = clipPos(doc, from); } if (to) { obj.to = clipPos(doc, to); } if (text) { obj.text = text; } if (origin !== undefined) { obj.origin = origin; } }; } signal(doc, "beforeChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); } if (obj.canceled) { if (doc.cm) { doc.cm.curOp.updateInput = 2; } return null; } return { from: obj.from, to: obj.to, text: obj.text, origin: obj.origin, }; } // Apply a change to a document, and add it to the document's // history, and propagating it to all linked documents. function makeChange(doc, change, ignoreReadOnly) { if (doc.cm) { if (!doc.cm.curOp) { return operation(doc.cm, makeChange)( doc, change, ignoreReadOnly ); } if (doc.cm.state.suppressEdits) { return; } } if ( hasHandler(doc, "beforeChange") || (doc.cm && hasHandler(doc.cm, "beforeChange")) ) { change = filterChange(doc, change, true); if (!change) { return; } } // Possibly split or suppress the update based on the presence // of read-only spans in its range. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); if (split) { for (var i = split.length - 1; i >= 0; --i) { makeChangeInner(doc, { from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin, }); } } else { makeChangeInner(doc, change); } } function makeChangeInner(doc, change) { if ( change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0 ) { return; } var selAfter = computeSelAfterChange(doc, change); addChangeToHistory( doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN ); makeChangeSingleDoc( doc, change, selAfter, stretchSpansOverChange(doc, change) ); var rebased = []; linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc( doc, change, null, stretchSpansOverChange(doc, change) ); }); } // Revert a change stored in a document's history. function makeChangeFromHistory(doc, type, allowSelectionOnly) { var suppress = doc.cm && doc.cm.state.suppressEdits; if (suppress && !allowSelectionOnly) { return; } var hist = doc.history, event, selAfter = doc.sel; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; // Verify that there is a useable event (so that ctrl-z won't // needlessly clear selection events) var i = 0; for (; i < source.length; i++) { event = source[i]; if ( allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges ) { break; } } if (i == source.length) { return; } hist.lastOrigin = hist.lastSelOrigin = null; for (;;) { event = source.pop(); if (event.ranges) { pushSelectionToHistory(event, dest); if (allowSelectionOnly && !event.equals(doc.sel)) { setSelection(doc, event, { clearRedo: false }); return; } selAfter = event; } else if (suppress) { source.push(event); return; } else { break; } } // Build up a reverse change object to add to the opposite history // stack (redo when undoing, and vice versa). var antiChanges = []; pushSelectionToHistory(selAfter, dest); dest.push({ changes: antiChanges, generation: hist.generation }); hist.generation = event.generation || ++hist.maxGeneration; var filter = hasHandler(doc, "beforeChange") || (doc.cm && hasHandler(doc.cm, "beforeChange")); var loop = function (i) { var change = event.changes[i]; change.origin = type; if (filter && !filterChange(doc, change, false)) { source.length = 0; return {}; } antiChanges.push(historyChangeFromChange(doc, change)); var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); if (!i && doc.cm) { doc.cm.scrollIntoView({ from: change.from, to: changeEnd(change), }); } var rebased = []; // Propagate to the linked documents linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc( doc, change, null, mergeOldSpans(doc, change) ); }); }; for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) { var returned = loop(i$1); if (returned) return returned.v; } } // Sub-views need their line numbers shifted when text is added // above or below them in the parent document. function shiftDoc(doc, distance) { if (distance == 0) { return; } doc.first += distance; doc.sel = new Selection( map(doc.sel.ranges, function (range) { return new Range( Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch) ); }), doc.sel.primIndex ); if (doc.cm) { regChange(doc.cm, doc.first, doc.first - distance, distance); for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) { regLineChange(doc.cm, l, "gutter"); } } } // More lower-level change function, handling only a single document // (not linked ones). function makeChangeSingleDoc(doc, change, selAfter, spans) { if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, makeChangeSingleDoc)( doc, change, selAfter, spans ); } if (change.to.line < doc.first) { shiftDoc( doc, change.text.length - 1 - (change.to.line - change.from.line) ); return; } if (change.from.line > doc.lastLine()) { return; } // Clip the change to the size of this doc if (change.from.line < doc.first) { var shift = change.text.length - 1 - (doc.first - change.from.line); shiftDoc(doc, shift); change = { from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), text: [lst(change.text)], origin: change.origin, }; } var last = doc.lastLine(); if (change.to.line > last) { change = { from: change.from, to: Pos(last, getLine(doc, last).text.length), text: [change.text[0]], origin: change.origin, }; } change.removed = getBetween(doc, change.from, change.to); if (!selAfter) { selAfter = computeSelAfterChange(doc, change); } if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); } else { updateDoc(doc, change, spans); } setSelectionNoUndo(doc, selAfter, sel_dontScroll); if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0))) { doc.cantEdit = false; } } // Handle the interaction of a change to a document with the editor // that this document is part of. function makeChangeSingleDocInEditor(cm, change, spans) { var doc = cm.doc, display = cm.display, from = change.from, to = change.to; var recomputeMaxLength = false, checkWidthStart = from.line; if (!cm.options.lineWrapping) { checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); doc.iter(checkWidthStart, to.line + 1, function (line) { if (line == display.maxLine) { recomputeMaxLength = true; return true; } }); } if (doc.sel.contains(change.from, change.to) > -1) { signalCursorActivity(cm); } updateDoc(doc, change, spans, estimateHeight(cm)); if (!cm.options.lineWrapping) { doc.iter( checkWidthStart, from.line + change.text.length, function (line) { var len = lineLength(line); if (len > display.maxLineLength) { display.maxLine = line; display.maxLineLength = len; display.maxLineChanged = true; recomputeMaxLength = false; } } ); if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; } } retreatFrontier(doc, from.line); startWorker(cm, 400); var lendiff = change.text.length - (to.line - from.line) - 1; // Remember that these lines changed, for updating the display if (change.full) { regChange(cm); } else if ( from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change) ) { regLineChange(cm, from.line, "text"); } else { regChange(cm, from.line, to.line + 1, lendiff); } var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); if (changeHandler || changesHandler) { var obj = { from: from, to: to, text: change.text, removed: change.removed, origin: change.origin, }; if (changeHandler) { signalLater(cm, "change", cm, obj); } if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } } cm.display.selForContextMenu = null; } function replaceRange(doc, code, from, to, origin) { var assign; if (!to) { to = from; } if (cmp(to, from) < 0) { (assign = [to, from]), (from = assign[0]), (to = assign[1]); } if (typeof code == "string") { code = doc.splitLines(code); } makeChange(doc, { from: from, to: to, text: code, origin: origin }); } // Rebasing/resetting history to deal with externally-sourced changes function rebaseHistSelSingle(pos, from, to, diff) { if (to < pos.line) { pos.line += diff; } else if (from < pos.line) { pos.line = from; pos.ch = 0; } } // Tries to rebase an array of history events given a change in the // document. If the change touches the same lines as the event, the // event, and everything 'behind' it, is discarded. If the change is // before the event, the event's positions are updated. Uses a // copy-on-write scheme for the positions, to avoid having to // reallocate them all on every rebase, but also avoid problems with // shared position objects being unsafely updated. function rebaseHistArray(array, from, to, diff) { for (var i = 0; i < array.length; ++i) { var sub = array[i], ok = true; if (sub.ranges) { if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } for (var j = 0; j < sub.ranges.length; j++) { rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); } continue; } for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) { var cur = sub.changes[j$1]; if (to < cur.from.line) { cur.from = Pos(cur.from.line + diff, cur.from.ch); cur.to = Pos(cur.to.line + diff, cur.to.ch); } else if (from <= cur.to.line) { ok = false; break; } } if (!ok) { array.splice(0, i + 1); i = 0; } } } function rebaseHist(hist, change) { var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; rebaseHistArray(hist.done, from, to, diff); rebaseHistArray(hist.undone, from, to, diff); } // Utility for applying a change to a line by handle or number, // returning the number and optionally registering the line as // changed. function changeLine(doc, handle, changeType, op) { var no = handle, line = handle; if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); } else { no = lineNo(handle); } if (no == null) { return null; } if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); } return line; } // The document is represented as a BTree consisting of leaves, with // chunk of lines in them, and branches, with up to ten leaves or // other branch nodes below them. The top node is always a branch // node, and is the document object itself (meaning it has // additional methods and properties). // // All nodes have parent links. The tree is used both to go from // line numbers to line objects, and to go from objects to numbers. // It also indexes by height, and is used to convert between height // and line object, and to find the total height of the document. // // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html function LeafChunk(lines) { this.lines = lines; this.parent = null; var height = 0; for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; height += lines[i].height; } this.height = height; } LeafChunk.prototype = { chunkSize: function () { return this.lines.length; }, // Remove the n lines at offset 'at'. removeInner: function (at, n) { for (var i = at, e = at + n; i < e; ++i) { var line = this.lines[i]; this.height -= line.height; cleanUpLine(line); signalLater(line, "delete"); } this.lines.splice(at, n); }, // Helper used to collapse a small branch into a single leaf. collapse: function (lines) { lines.push.apply(lines, this.lines); }, // Insert the given array of lines at offset 'at', count them as // having the given height. insertInner: function (at, lines, height) { this.height += height; this.lines = this.lines .slice(0, at) .concat(lines) .concat(this.lines.slice(at)); for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; } }, // Used to iterate over a part of the tree. iterN: function (at, n, op) { for (var e = at + n; at < e; ++at) { if (op(this.lines[at])) { return true; } } }, }; function BranchChunk(children) { this.children = children; var size = 0, height = 0; for (var i = 0; i < children.length; ++i) { var ch = children[i]; size += ch.chunkSize(); height += ch.height; ch.parent = this; } this.size = size; this.height = height; this.parent = null; } BranchChunk.prototype = { chunkSize: function () { return this.size; }, removeInner: function (at, n) { this.size -= n; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var rm = Math.min(n, sz - at), oldHeight = child.height; child.removeInner(at, rm); this.height -= oldHeight - child.height; if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } if ((n -= rm) == 0) { break; } at = 0; } else { at -= sz; } } // If the result is smaller than 25 lines, ensure that it is a // single leaf node. if ( this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk)) ) { var lines = []; this.collapse(lines); this.children = [new LeafChunk(lines)]; this.children[0].parent = this; } }, collapse: function (lines) { for (var i = 0; i < this.children.length; ++i) { this.children[i].collapse(lines); } }, insertInner: function (at, lines, height) { this.size += lines.length; this.height += height; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at <= sz) { child.insertInner(at, lines, height); if (child.lines && child.lines.length > 50) { // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest. var remaining = (child.lines.length % 25) + 25; for (var pos = remaining; pos < child.lines.length; ) { var leaf = new LeafChunk( child.lines.slice(pos, (pos += 25)) ); child.height -= leaf.height; this.children.splice(++i, 0, leaf); leaf.parent = this; } child.lines = child.lines.slice(0, remaining); this.maybeSpill(); } break; } at -= sz; } }, // When a node has grown, check whether it should be split. maybeSpill: function () { if (this.children.length <= 10) { return; } var me = this; do { var spilled = me.children.splice(me.children.length - 5, 5); var sibling = new BranchChunk(spilled); if (!me.parent) { // Become the parent node var copy = new BranchChunk(me.children); copy.parent = me; me.children = [copy, sibling]; me = copy; } else { me.size -= sibling.size; me.height -= sibling.height; var myIndex = indexOf(me.parent.children, me); me.parent.children.splice(myIndex + 1, 0, sibling); } sibling.parent = me.parent; } while (me.children.length > 10); me.parent.maybeSpill(); }, iterN: function (at, n, op) { for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var used = Math.min(n, sz - at); if (child.iterN(at, used, op)) { return true; } if ((n -= used) == 0) { break; } at = 0; } else { at -= sz; } } }, }; // Line widgets are block elements displayed above or below a line. var LineWidget = function (doc, node, options) { if (options) { for (var opt in options) { if (options.hasOwnProperty(opt)) { this[opt] = options[opt]; } } } this.doc = doc; this.node = node; }; LineWidget.prototype.clear = function () { var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); if (no == null || !ws) { return; } for (var i = 0; i < ws.length; ++i) { if (ws[i] == this) { ws.splice(i--, 1); } } if (!ws.length) { line.widgets = null; } var height = widgetHeight(this); updateLineHeight(line, Math.max(0, line.height - height)); if (cm) { runInOp(cm, function () { adjustScrollWhenAboveVisible(cm, line, -height); regLineChange(cm, no, "widget"); }); signalLater(cm, "lineWidgetCleared", cm, this, no); } }; LineWidget.prototype.changed = function () { var this$1 = this; var oldH = this.height, cm = this.doc.cm, line = this.line; this.height = null; var diff = widgetHeight(this) - oldH; if (!diff) { return; } if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); } if (cm) { runInOp(cm, function () { cm.curOp.forceUpdate = true; adjustScrollWhenAboveVisible(cm, line, diff); signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line)); }); } }; eventMixin(LineWidget); function adjustScrollWhenAboveVisible(cm, line, diff) { if ( heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop) ) { addToScrollTop(cm, diff); } } function addLineWidget(doc, handle, node, options) { var widget = new LineWidget(doc, node, options); var cm = doc.cm; if (cm && widget.noHScroll) { cm.display.alignWidgets = true; } changeLine(doc, handle, "widget", function (line) { var widgets = line.widgets || (line.widgets = []); if (widget.insertAt == null) { widgets.push(widget); } else { widgets.splice( Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget ); } widget.line = line; if (cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; updateLineHeight(line, line.height + widgetHeight(widget)); if (aboveVisible) { addToScrollTop(cm, widget.height); } cm.curOp.forceUpdate = true; } return true; }); if (cm) { signalLater( cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle) ); } return widget; } // TEXTMARKERS // Created with markText and setBookmark methods. A TextMarker is a // handle that can be used to clear or find a marked position in the // document. Line objects hold arrays (markedSpans) containing // {from, to, marker} object pointing to such marker objects, and // indicating that such a marker is present on that line. Multiple // lines may point to the same marker when it spans across lines. // The spans will have null for their from/to properties when the // marker continues beyond the start/end of the line. Markers have // links back to the lines they currently touch. // Collapsed markers have unique ids, in order to be able to order // them, which is needed for uniquely determining an outer marker // when they overlap (they may nest, but not partially overlap). var nextMarkerId = 0; var TextMarker = function (doc, type) { this.lines = []; this.type = type; this.doc = doc; this.id = ++nextMarkerId; }; // Clear the marker. TextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return; } var cm = this.doc.cm, withOp = cm && !cm.curOp; if (withOp) { startOperation(cm); } if (hasHandler(this, "clear")) { var found = this.find(); if (found) { signalLater(this, "clear", found.from, found.to); } } var min = null, max = null; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (cm && !this.collapsed) { regLineChange(cm, lineNo(line), "text"); } else if (cm) { if (span.to != null) { max = lineNo(line); } if (span.from != null) { min = lineNo(line); } } line.markedSpans = removeMarkedSpan(line.markedSpans, span); if ( span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm ) { updateLineHeight(line, textHeight(cm.display)); } } if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) { var visual = visualLine(this.lines[i$1]), len = lineLength(visual); if (len > cm.display.maxLineLength) { cm.display.maxLine = visual; cm.display.maxLineLength = len; cm.display.maxLineChanged = true; } } } if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); } this.lines.length = 0; this.explicitlyCleared = true; if (this.atomic && this.doc.cantEdit) { this.doc.cantEdit = false; if (cm) { reCheckSelection(cm.doc); } } if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); } if (withOp) { endOperation(cm); } if (this.parent) { this.parent.clear(); } }; // Find the position of the marker in the document. Returns a {from, // to} object by default. Side can be passed to get a specific side // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the // Pos objects returned contain a line object, rather than a line // number (used to prevent looking up the same line twice). TextMarker.prototype.find = function (side, lineObj) { if (side == null && this.type == "bookmark") { side = 1; } var from, to; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (span.from != null) { from = Pos(lineObj ? line : lineNo(line), span.from); if (side == -1) { return from; } } if (span.to != null) { to = Pos(lineObj ? line : lineNo(line), span.to); if (side == 1) { return to; } } } return from && { from: from, to: to }; }; // Signals that the marker's widget changed, and surrounding layout // should be recomputed. TextMarker.prototype.changed = function () { var this$1 = this; var pos = this.find(-1, true), widget = this, cm = this.doc.cm; if (!pos || !cm) { return; } runInOp(cm, function () { var line = pos.line, lineN = lineNo(pos.line); var view = findViewForLine(cm, lineN); if (view) { clearLineMeasurementCacheFor(view); cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; } cm.curOp.updateMaxLine = true; if (!lineIsHidden(widget.doc, line) && widget.height != null) { var oldHeight = widget.height; widget.height = null; var dHeight = widgetHeight(widget) - oldHeight; if (dHeight) { updateLineHeight(line, line.height + dHeight); } } signalLater(cm, "markerChanged", cm, this$1); }); }; TextMarker.prototype.attachLine = function (line) { if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; if ( !op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1 ) { ( op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = []) ).push(this); } } this.lines.push(line); }; TextMarker.prototype.detachLine = function (line) { this.lines.splice(indexOf(this.lines, line), 1); if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); } }; eventMixin(TextMarker); // Create a marker, wire it up to the right lines, and function markText(doc, from, to, options, type) { // Shared markers (across linked documents) are handled separately // (markTextShared will call out to this again, once per // document). if (options && options.shared) { return markTextShared(doc, from, to, options, type); } // Ensure we are in an operation. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type); } var marker = new TextMarker(doc, type), diff = cmp(from, to); if (options) { copyObj(options, marker, false); } // Don't connect empty markers unless clearWhenEmpty is false if (diff > 0 || (diff == 0 && marker.clearWhenEmpty !== false)) { return marker; } if (marker.replacedWith) { // Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = true; marker.widgetNode = eltP( "span", [marker.replacedWith], "CodeMirror-widget" ); if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); } if (options.insertLeft) { marker.widgetNode.insertLeft = true; } } if (marker.collapsed) { if ( conflictingCollapsedRange(doc, from.line, from, to, marker) || (from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) ) { throw new Error( "Inserting collapsed marker partially overlapping an existing one" ); } seeCollapsedSpans(); } if (marker.addToHistory) { addChangeToHistory( doc, { from: from, to: to, origin: "markText" }, doc.sel, NaN ); } var curLine = from.line, cm = doc.cm, updateMaxLine; doc.iter(curLine, to.line + 1, function (line) { if ( cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine ) { updateMaxLine = true; } if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); } addMarkedSpan( line, new MarkedSpan( marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null ), doc.cm && doc.cm.curOp ); ++curLine; }); // lineIsHidden depends on the presence of the spans, so needs a second pass if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) { if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); } }); } if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); } if (marker.readOnly) { seeReadOnlySpans(); if (doc.history.done.length || doc.history.undone.length) { doc.clearHistory(); } } if (marker.collapsed) { marker.id = ++nextMarkerId; marker.atomic = true; } if (cm) { // Sync editor state if (updateMaxLine) { cm.curOp.updateMaxLine = true; } if (marker.collapsed) { regChange(cm, from.line, to.line + 1); } else if ( marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title ) { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } } if (marker.atomic) { reCheckSelection(cm.doc); } signalLater(cm, "markerAdded", cm, marker); } return marker; } // SHARED TEXTMARKERS // A shared marker spans multiple linked documents. It is // implemented as a meta-marker-object controlling multiple normal // markers. var SharedTextMarker = function (markers, primary) { this.markers = markers; this.primary = primary; for (var i = 0; i < markers.length; ++i) { markers[i].parent = this; } }; SharedTextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return; } this.explicitlyCleared = true; for (var i = 0; i < this.markers.length; ++i) { this.markers[i].clear(); } signalLater(this, "clear"); }; SharedTextMarker.prototype.find = function (side, lineObj) { return this.primary.find(side, lineObj); }; eventMixin(SharedTextMarker); function markTextShared(doc, from, to, options, type) { options = copyObj(options); options.shared = false; var markers = [markText(doc, from, to, options, type)], primary = markers[0]; var widget = options.widgetNode; linkedDocs(doc, function (doc) { if (widget) { options.widgetNode = widget.cloneNode(true); } markers.push( markText( doc, clipPos(doc, from), clipPos(doc, to), options, type ) ); for (var i = 0; i < doc.linked.length; ++i) { if (doc.linked[i].isParent) { return; } } primary = lst(markers); }); return new SharedTextMarker(markers, primary); } function findSharedMarkers(doc) { return doc.findMarks( Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; } ); } function copySharedMarkers(doc, markers) { for (var i = 0; i < markers.length; i++) { var marker = markers[i], pos = marker.find(); var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); if (cmp(mFrom, mTo)) { var subMark = markText( doc, mFrom, mTo, marker.primary, marker.primary.type ); marker.markers.push(subMark); subMark.parent = marker; } } } function detachSharedMarkers(markers) { var loop = function (i) { var marker = markers[i], linked = [marker.primary.doc]; linkedDocs(marker.primary.doc, function (d) { return linked.push(d); }); for (var j = 0; j < marker.markers.length; j++) { var subMarker = marker.markers[j]; if (indexOf(linked, subMarker.doc) == -1) { subMarker.parent = null; marker.markers.splice(j--, 1); } } }; for (var i = 0; i < markers.length; i++) loop(i); } var nextDocId = 0; var Doc = function (text, mode, firstLine, lineSep, direction) { if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction); } if (firstLine == null) { firstLine = 0; } BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); this.first = firstLine; this.scrollTop = this.scrollLeft = 0; this.cantEdit = false; this.cleanGeneration = 1; this.modeFrontier = this.highlightFrontier = firstLine; var start = Pos(firstLine, 0); this.sel = simpleSelection(start); this.history = new History(null); this.id = ++nextDocId; this.modeOption = mode; this.lineSep = lineSep; this.direction = direction == "rtl" ? "rtl" : "ltr"; this.extend = false; if (typeof text == "string") { text = this.splitLines(text); } updateDoc(this, { from: start, to: start, text: text }); setSelection(this, simpleSelection(start), sel_dontScroll); }; Doc.prototype = createObj(BranchChunk.prototype, { constructor: Doc, // Iterate over the document. Supports two forms -- with only one // argument, it calls that for each line in the document. With // three, it iterates over the range given by the first two (with // the second being non-inclusive). iter: function (from, to, op) { if (op) { this.iterN(from - this.first, to - from, op); } else { this.iterN(this.first, this.first + this.size, from); } }, // Non-public interface for adding and removing lines. insert: function (at, lines) { var height = 0; for (var i = 0; i < lines.length; ++i) { height += lines[i].height; } this.insertInner(at - this.first, lines, height); }, remove: function (at, n) { this.removeInner(at - this.first, n); }, // From here, the methods are part of the public interface. Most // are also available from CodeMirror (editor) instances. getValue: function (lineSep) { var lines = getLines(this, this.first, this.first + this.size); if (lineSep === false) { return lines; } return lines.join(lineSep || this.lineSeparator()); }, setValue: docMethodOp(function (code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; makeChange( this, { from: top, to: Pos(last, getLine(this, last).text.length), text: this.splitLines(code), origin: "setValue", full: true, }, true ); if (this.cm) { scrollToCoords(this.cm, 0, 0); } setSelection(this, simpleSelection(top), sel_dontScroll); }), replaceRange: function (code, from, to, origin) { from = clipPos(this, from); to = to ? clipPos(this, to) : from; replaceRange(this, code, from, to, origin); }, getRange: function (from, to, lineSep) { var lines = getBetween( this, clipPos(this, from), clipPos(this, to) ); if (lineSep === false) { return lines; } if (lineSep === "") { return lines.join(""); } return lines.join(lineSep || this.lineSeparator()); }, getLine: function (line) { var l = this.getLineHandle(line); return l && l.text; }, getLineHandle: function (line) { if (isLine(this, line)) { return getLine(this, line); } }, getLineNumber: function (line) { return lineNo(line); }, getLineHandleVisualStart: function (line) { if (typeof line == "number") { line = getLine(this, line); } return visualLine(line); }, lineCount: function () { return this.size; }, firstLine: function () { return this.first; }, lastLine: function () { return this.first + this.size - 1; }, clipPos: function (pos) { return clipPos(this, pos); }, getCursor: function (start) { var range = this.sel.primary(), pos; if (start == null || start == "head") { pos = range.head; } else if (start == "anchor") { pos = range.anchor; } else if (start == "end" || start == "to" || start === false) { pos = range.to(); } else { pos = range.from(); } return pos; }, listSelections: function () { return this.sel.ranges; }, somethingSelected: function () { return this.sel.somethingSelected(); }, setCursor: docMethodOp(function (line, ch, options) { setSimpleSelection( this, clipPos( this, typeof line == "number" ? Pos(line, ch || 0) : line ), null, options ); }), setSelection: docMethodOp(function (anchor, head, options) { setSimpleSelection( this, clipPos(this, anchor), clipPos(this, head || anchor), options ); }), extendSelection: docMethodOp(function (head, other, options) { extendSelection( this, clipPos(this, head), other && clipPos(this, other), options ); }), extendSelections: docMethodOp(function (heads, options) { extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function (f, options) { var heads = map(this.sel.ranges, f); extendSelections(this, clipPosArray(this, heads), options); }), setSelections: docMethodOp(function (ranges, primary, options) { if (!ranges.length) { return; } var out = []; for (var i = 0; i < ranges.length; i++) { out[i] = new Range( clipPos(this, ranges[i].anchor), clipPos(this, ranges[i].head || ranges[i].anchor) ); } if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); } setSelection( this, normalizeSelection(this.cm, out, primary), options ); }), addSelection: docMethodOp(function (anchor, head, options) { var ranges = this.sel.ranges.slice(0); ranges.push( new Range(clipPos(this, anchor), clipPos(this, head || anchor)) ); setSelection( this, normalizeSelection(this.cm, ranges, ranges.length - 1), options ); }), getSelection: function (lineSep) { var ranges = this.sel.ranges, lines; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); lines = lines ? lines.concat(sel) : sel; } if (lineSep === false) { return lines; } else { return lines.join(lineSep || this.lineSeparator()); } }, getSelections: function (lineSep) { var parts = [], ranges = this.sel.ranges; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); if (lineSep !== false) { sel = sel.join(lineSep || this.lineSeparator()); } parts[i] = sel; } return parts; }, replaceSelection: function (code, collapse, origin) { var dup = []; for (var i = 0; i < this.sel.ranges.length; i++) { dup[i] = code; } this.replaceSelections(dup, collapse, origin || "+input"); }, replaceSelections: docMethodOp(function (code, collapse, origin) { var changes = [], sel = this.sel; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; changes[i] = { from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin, }; } var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); for (var i$1 = changes.length - 1; i$1 >= 0; i$1--) { makeChange(this, changes[i$1]); } if (newSel) { setSelectionReplaceHistory(this, newSel); } else if (this.cm) { ensureCursorVisible(this.cm); } }), undo: docMethodOp(function () { makeChangeFromHistory(this, "undo"); }), redo: docMethodOp(function () { makeChangeFromHistory(this, "redo"); }), undoSelection: docMethodOp(function () { makeChangeFromHistory(this, "undo", true); }), redoSelection: docMethodOp(function () { makeChangeFromHistory(this, "redo", true); }), setExtending: function (val) { this.extend = val; }, getExtending: function () { return this.extend; }, historySize: function () { var hist = this.history, done = 0, undone = 0; for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } } for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } } return { undo: done, redo: undone }; }, clearHistory: function () { var this$1 = this; this.history = new History(this.history); linkedDocs( this, function (doc) { return (doc.history = this$1.history); }, true ); }, markClean: function () { this.cleanGeneration = this.changeGeneration(true); }, changeGeneration: function (forceSplit) { if (forceSplit) { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; } return this.history.generation; }, isClean: function (gen) { return this.history.generation == (gen || this.cleanGeneration); }, getHistory: function () { return { done: copyHistoryArray(this.history.done), undone: copyHistoryArray(this.history.undone), }; }, setHistory: function (histData) { var hist = (this.history = new History(this.history)); hist.done = copyHistoryArray(histData.done.slice(0), null, true); hist.undone = copyHistoryArray( histData.undone.slice(0), null, true ); }, setGutterMarker: docMethodOp(function (line, gutterID, value) { return changeLine(this, line, "gutter", function (line) { var markers = line.gutterMarkers || (line.gutterMarkers = {}); markers[gutterID] = value; if (!value && isEmpty(markers)) { line.gutterMarkers = null; } return true; }); }), clearGutter: docMethodOp(function (gutterID) { var this$1 = this; this.iter(function (line) { if (line.gutterMarkers && line.gutterMarkers[gutterID]) { changeLine(this$1, line, "gutter", function () { line.gutterMarkers[gutterID] = null; if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; } return true; }); } }); }), lineInfo: function (line) { var n; if (typeof line == "number") { if (!isLine(this, line)) { return null; } n = line; line = getLine(this, line); if (!line) { return null; } } else { n = lineNo(line); if (n == null) { return null; } } return { line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, widgets: line.widgets, }; }, addLineClass: docMethodOp(function (handle, where, cls) { return changeLine( this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; if (!line[prop]) { line[prop] = cls; } else if (classTest(cls).test(line[prop])) { return false; } else { line[prop] += " " + cls; } return true; } ); }), removeLineClass: docMethodOp(function (handle, where, cls) { return changeLine( this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; var cur = line[prop]; if (!cur) { return false; } else if (cls == null) { line[prop] = null; } else { var found = cur.match(classTest(cls)); if (!found) { return false; } var end = found.index + found[0].length; line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; } return true; } ); }), addLineWidget: docMethodOp(function (handle, node, options) { return addLineWidget(this, handle, node, options); }), removeLineWidget: function (widget) { widget.clear(); }, markText: function (from, to, options) { return markText( this, clipPos(this, from), clipPos(this, to), options, (options && options.type) || "range" ); }, setBookmark: function (pos, options) { var realOpts = { replacedWith: options && (options.nodeType == null ? options.widget : options), insertLeft: options && options.insertLeft, clearWhenEmpty: false, shared: options && options.shared, handleMouseEvents: options && options.handleMouseEvents, }; pos = clipPos(this, pos); return markText(this, pos, pos, realOpts, "bookmark"); }, findMarksAt: function (pos) { pos = clipPos(this, pos); var markers = [], spans = getLine(this, pos.line).markedSpans; if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if ( (span.from == null || span.from <= pos.ch) && (span.to == null || span.to >= pos.ch) ) { markers.push(span.marker.parent || span.marker); } } } return markers; }, findMarks: function (from, to, filter) { from = clipPos(this, from); to = clipPos(this, to); var found = [], lineNo = from.line; this.iter(from.line, to.line + 1, function (line) { var spans = line.markedSpans; if (spans) { for (var i = 0; i < spans.length; i++) { var span = spans[i]; if ( !( (span.to != null && lineNo == from.line && from.ch >= span.to) || (span.from == null && lineNo != from.line) || (span.from != null && lineNo == to.line && span.from >= to.ch) ) && (!filter || filter(span.marker)) ) { found.push(span.marker.parent || span.marker); } } } ++lineNo; }); return found; }, getAllMarks: function () { var markers = []; this.iter(function (line) { var sps = line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { if (sps[i].from != null) { markers.push(sps[i].marker); } } } }); return markers; }, posFromIndex: function (off) { var ch, lineNo = this.first, sepSize = this.lineSeparator().length; this.iter(function (line) { var sz = line.text.length + sepSize; if (sz > off) { ch = off; return true; } off -= sz; ++lineNo; }); return clipPos(this, Pos(lineNo, ch)); }, indexFromPos: function (coords) { coords = clipPos(this, coords); var index = coords.ch; if (coords.line < this.first || coords.ch < 0) { return 0; } var sepSize = this.lineSeparator().length; this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value index += line.text.length + sepSize; }); return index; }, copy: function (copyHistory) { var doc = new Doc( getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction ); doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; doc.sel = this.sel; doc.extend = false; if (copyHistory) { doc.history.undoDepth = this.history.undoDepth; doc.setHistory(this.getHistory()); } return doc; }, linkedDoc: function (options) { if (!options) { options = {}; } var from = this.first, to = this.first + this.size; if (options.from != null && options.from > from) { from = options.from; } if (options.to != null && options.to < to) { to = options.to; } var copy = new Doc( getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction ); if (options.sharedHist) { copy.history = this.history; } (this.linked || (this.linked = [])).push({ doc: copy, sharedHist: options.sharedHist, }); copy.linked = [ { doc: this, isParent: true, sharedHist: options.sharedHist }, ]; copySharedMarkers(copy, findSharedMarkers(this)); return copy; }, unlinkDoc: function (other) { if (other instanceof CodeMirror) { other = other.doc; } if (this.linked) { for (var i = 0; i < this.linked.length; ++i) { var link = this.linked[i]; if (link.doc != other) { continue; } this.linked.splice(i, 1); other.unlinkDoc(this); detachSharedMarkers(findSharedMarkers(this)); break; } } // If the histories were shared, split them again if (other.history == this.history) { var splitIds = [other.id]; linkedDocs( other, function (doc) { return splitIds.push(doc.id); }, true ); other.history = new History(null); other.history.done = copyHistoryArray( this.history.done, splitIds ); other.history.undone = copyHistoryArray( this.history.undone, splitIds ); } }, iterLinkedDocs: function (f) { linkedDocs(this, f); }, getMode: function () { return this.mode; }, getEditor: function () { return this.cm; }, splitLines: function (str) { if (this.lineSep) { return str.split(this.lineSep); } return splitLinesAuto(str); }, lineSeparator: function () { return this.lineSep || "\n"; }, setDirection: docMethodOp(function (dir) { if (dir != "rtl") { dir = "ltr"; } if (dir == this.direction) { return; } this.direction = dir; this.iter(function (line) { return (line.order = null); }); if (this.cm) { directionChanged(this.cm); } }), }); // Public alias. Doc.prototype.eachLine = Doc.prototype.iter; // Kludge to work around strange IE behavior where it'll sometimes // re-fire a series of drag-related events right after the drop (#1551) var lastDrop = 0; function onDrop(e) { var cm = this; clearDragCursor(cm); if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return; } e_preventDefault(e); if (ie) { lastDrop = +new Date(); } var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; if (!pos || cm.isReadOnly()) { return; } // Might be a file drop, in which case we simply extract the text // and insert it. if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var markAsReadAndPasteIfAllFilesAreRead = function () { if (++read == n) { operation(cm, function () { pos = clipPos(cm.doc, pos); var change = { from: pos, to: pos, text: cm.doc.splitLines( text .filter(function (t) { return t != null; }) .join(cm.doc.lineSeparator()) ), origin: "paste", }; makeChange(cm.doc, change); setSelectionReplaceHistory( cm.doc, simpleSelection( clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)) ) ); })(); } }; var readTextFromFile = function (file, i) { if ( cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1 ) { markAsReadAndPasteIfAllFilesAreRead(); return; } var reader = new FileReader(); reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); }; reader.onload = function () { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { markAsReadAndPasteIfAllFilesAreRead(); return; } text[i] = content; markAsReadAndPasteIfAllFilesAreRead(); }; reader.readAsText(file); }; for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); } } else { // Normal drop // Don't do a replace if the drop happened inside of the selected text. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { cm.state.draggingText(e); // Ensure the editor is re-focused setTimeout(function () { return cm.display.input.focus(); }, 20); return; } try { var text$1 = e.dataTransfer.getData("Text"); if (text$1) { var selected; if (cm.state.draggingText && !cm.state.draggingText.copy) { selected = cm.listSelections(); } setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1) { replaceRange( cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag" ); } } cm.replaceSelection(text$1, "around", "paste"); cm.display.input.focus(); } } catch (e$1) {} } } function onDragStart(cm, e) { if (ie && (!cm.state.draggingText || +new Date() - lastDrop < 100)) { e_stop(e); return; } if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return; } e.dataTransfer.setData("Text", cm.getSelection()); e.dataTransfer.effectAllowed = "copyMove"; // Use dummy image instead of default browsers image. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. if (e.dataTransfer.setDragImage && !safari) { var img = elt( "img", null, null, "position: fixed; left: 0; top: 0;" ); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; if (presto) { img.width = img.height = 1; cm.display.wrapper.appendChild(img); // Force a relayout, or Opera won't use our image for some obscure reason img._top = img.offsetTop; } e.dataTransfer.setDragImage(img, 0, 0); if (presto) { img.parentNode.removeChild(img); } } } function onDragOver(cm, e) { var pos = posFromMouse(cm, e); if (!pos) { return; } var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag); if (!cm.display.dragCursor) { cm.display.dragCursor = elt( "div", null, "CodeMirror-cursors CodeMirror-dragcursors" ); cm.display.lineSpace.insertBefore( cm.display.dragCursor, cm.display.cursorDiv ); } removeChildrenAndAdd(cm.display.dragCursor, frag); } function clearDragCursor(cm) { if (cm.display.dragCursor) { cm.display.lineSpace.removeChild(cm.display.dragCursor); cm.display.dragCursor = null; } } // These must be handled carefully, because naively registering a // handler for each editor will cause the editors to never be // garbage collected. function forEachCodeMirror(f) { if (!document.getElementsByClassName) { return; } var byClass = document.getElementsByClassName("CodeMirror"), editors = []; for (var i = 0; i < byClass.length; i++) { var cm = byClass[i].CodeMirror; if (cm) { editors.push(cm); } } if (editors.length) { editors[0].operation(function () { for (var i = 0; i < editors.length; i++) { f(editors[i]); } }); } } var globalsRegistered = false; function ensureGlobalHandlers() { if (globalsRegistered) { return; } registerGlobalHandlers(); globalsRegistered = true; } function registerGlobalHandlers() { // When the window resizes, we need to refresh active editors. var resizeTimer; on(window, "resize", function () { if (resizeTimer == null) { resizeTimer = setTimeout(function () { resizeTimer = null; forEachCodeMirror(onResize); }, 100); } }); // When the window loses focus, we want to show the editor as blurred on(window, "blur", function () { return forEachCodeMirror(onBlur); }); } // Called when the window resizes function onResize(cm) { var d = cm.display; // Might be a text scaling operation, clear size caches. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; d.scrollbarsClipped = false; cm.setSize(); } var keyNames = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert", }; // Number keys for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); } // Alphabetic keys for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); } // Function keys for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; } var keyMap = {}; keyMap.basic = { Left: "goCharLeft", Right: "goCharRight", Up: "goLineUp", Down: "goLineDown", End: "goLineEnd", Home: "goLineStartSmart", PageUp: "goPageUp", PageDown: "goPageDown", Delete: "delCharAfter", Backspace: "delCharBefore", "Shift-Backspace": "delCharBefore", Tab: "defaultTab", "Shift-Tab": "indentAuto", Enter: "newlineAndIndent", Insert: "toggleOverwrite", Esc: "singleSelection", }; // Note that the save and find-related commands aren't defined by // default. User code or addons can define them. Unknown commands // are simply ignored. keyMap.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", fallthrough: "basic", }; // Very basic readline/emacs-style bindings, which are standard on Mac. keyMap.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine", }; keyMap.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", fallthrough: ["basic", "emacsy"], }; keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; // KEYMAP DISPATCH function normalizeKeyName(name) { var parts = name.split(/-(?!$)/); name = parts[parts.length - 1]; var alt, ctrl, shift, cmd; for (var i = 0; i < parts.length - 1; i++) { var mod = parts[i]; if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; } else if (/^a(lt)?$/i.test(mod)) { alt = true; } else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; } else if (/^s(hift)?$/i.test(mod)) { shift = true; } else { throw new Error("Unrecognized modifier name: " + mod); } } if (alt) { name = "Alt-" + name; } if (ctrl) { name = "Ctrl-" + name; } if (cmd) { name = "Cmd-" + name; } if (shift) { name = "Shift-" + name; } return name; } // This is a kludge to keep keymaps mostly working as raw objects // (backwards compatibility) while at the same time support features // like normalization and multi-stroke key bindings. It compiles a // new normalized keymap, and then updates the old object to reflect // this. function normalizeKeyMap(keymap) { var copy = {}; for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) { var value = keymap[keyname]; if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue; } if (value == "...") { delete keymap[keyname]; continue; } var keys = map(keyname.split(" "), normalizeKeyName); for (var i = 0; i < keys.length; i++) { var val = void 0, name = void 0; if (i == keys.length - 1) { name = keys.join(" "); val = value; } else { name = keys.slice(0, i + 1).join(" "); val = "..."; } var prev = copy[name]; if (!prev) { copy[name] = val; } else if (prev != val) { throw new Error("Inconsistent bindings for " + name); } } delete keymap[keyname]; } } for (var prop in copy) { keymap[prop] = copy[prop]; } return keymap; } function lookupKey(key, map, handle, context) { map = getKeyMap(map); var found = map.call ? map.call(key, context) : map[key]; if (found === false) { return "nothing"; } if (found === "...") { return "multi"; } if (found != null && handle(found)) { return "handled"; } if (map.fallthrough) { if ( Object.prototype.toString.call(map.fallthrough) != "[object Array]" ) { return lookupKey(key, map.fallthrough, handle, context); } for (var i = 0; i < map.fallthrough.length; i++) { var result = lookupKey( key, map.fallthrough[i], handle, context ); if (result) { return result; } } } } // Modifier key presses don't count as 'real' key presses for the // purpose of keymap fallthrough. function isModifierKey(value) { var name = typeof value == "string" ? value : keyNames[value.keyCode]; return ( name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod" ); } function addModifierNames(name, event, noShift) { var base = name; if (event.altKey && base != "Alt") { name = "Alt-" + name; } if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; } if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") { name = "Cmd-" + name; } if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; } return name; } // Look up the name of a key as indicated by an event object. function keyName(event, noShift) { if (presto && event.keyCode == 34 && event["char"]) { return false; } var name = keyNames[event.keyCode]; if (name == null || event.altGraphKey) { return false; } // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause, // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+) if (event.keyCode == 3 && event.code) { name = event.code; } return addModifierNames(name, event, noShift); } function getKeyMap(val) { return typeof val == "string" ? keyMap[val] : val; } // Helper for deleting text near the selection(s), used to implement // backspace, delete, and similar functionality. function deleteNearSelection(cm, compute) { var ranges = cm.doc.sel.ranges, kill = []; // Build up a set of ranges to kill first, merging overlapping // ranges. for (var i = 0; i < ranges.length; i++) { var toKill = compute(ranges[i]); while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { var replaced = kill.pop(); if (cmp(replaced.from, toKill.from) < 0) { toKill.from = replaced.from; break; } } kill.push(toKill); } // Next, remove those actual ranges. runInOp(cm, function () { for (var i = kill.length - 1; i >= 0; i--) { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); } ensureCursorVisible(cm); }); } function moveCharLogically(line, ch, dir) { var target = skipExtendingChars(line.text, ch + dir, dir); return target < 0 || target > line.text.length ? null : target; } function moveLogically(line, start, dir) { var ch = moveCharLogically(line, start.ch, dir); return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before"); } function endOfLine(visually, cm, lineObj, lineNo, dir) { if (visually) { if (cm.doc.direction == "rtl") { dir = -dir; } var order = getOrder(lineObj, cm.doc.direction); if (order) { var part = dir < 0 ? lst(order) : order[0]; var moveInStorageOrder = dir < 0 == (part.level == 1); var sticky = moveInStorageOrder ? "after" : "before"; var ch; // With a wrapped rtl chunk (possibly spanning multiple bidi parts), // it could be that the last bidi part is not on the last visual line, // since visual lines contain content order-consecutive chunks. // Thus, in rtl, we are looking for the first (content-order) character // in the rtl chunk that is on the last line (that is, the same line // as the last (content-order) character). if (part.level > 0 || cm.doc.direction == "rtl") { var prep = prepareMeasureForLine(cm, lineObj); ch = dir < 0 ? lineObj.text.length - 1 : 0; var targetTop = measureCharPrepared(cm, prep, ch).top; ch = findFirst( function (ch) { return ( measureCharPrepared(cm, prep, ch).top == targetTop ); }, dir < 0 == (part.level == 1) ? part.from : part.to - 1, ch ); if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); } } else { ch = dir < 0 ? part.to : part.from; } return new Pos(lineNo, ch, sticky); } } return new Pos( lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after" ); } function moveVisually(cm, line, start, dir) { var bidi = getOrder(line, cm.doc.direction); if (!bidi) { return moveLogically(line, start, dir); } if (start.ch >= line.text.length) { start.ch = line.text.length; start.sticky = "before"; } else if (start.ch <= 0) { start.ch = 0; start.sticky = "after"; } var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]; if ( cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch) ) { // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines, // nothing interesting happens. return moveLogically(line, start, dir); } var mv = function (pos, dir) { return moveCharLogically( line, pos instanceof Pos ? pos.ch : pos, dir ); }; var prep; var getWrappedLineExtent = function (ch) { if (!cm.options.lineWrapping) { return { begin: 0, end: line.text.length }; } prep = prep || prepareMeasureForLine(cm, line); return wrappedLineExtentChar(cm, line, prep, ch); }; var wrappedLineExtent = getWrappedLineExtent( start.sticky == "before" ? mv(start, -1) : start.ch ); if (cm.doc.direction == "rtl" || part.level == 1) { var moveInStorageOrder = (part.level == 1) == dir < 0; var ch = mv(start, moveInStorageOrder ? 1 : -1); if ( ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end) ) { // Case 2: We move within an rtl part or in an rtl editor on the same visual line var sticky = moveInStorageOrder ? "before" : "after"; return new Pos(start.line, ch, sticky); } } // Case 3: Could not move within this bidi part in this visual line, so leave // the current bidi part var searchInVisualLine = function (partPos, dir, wrappedLineExtent) { var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after"); }; for (; partPos >= 0 && partPos < bidi.length; partPos += dir) { var part = bidi[partPos]; var moveInStorageOrder = dir > 0 == (part.level != 1); var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder); } ch = moveInStorageOrder ? part.from : mv(part.to, -1); if ( wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end ) { return getRes(ch, moveInStorageOrder); } } }; // Case 3a: Look for other bidi parts on the same visual line var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent); if (res) { return res; } // Case 3b: Look for other bidi parts on the next visual line var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1); if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) { res = searchInVisualLine( dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh) ); if (res) { return res; } } // Case 4: Nowhere to move return null; } // Commands are parameter-less actions that can be performed on an // editor, mostly used for keybindings. var commands = { selectAll: selectAll, singleSelection: function (cm) { return cm.setSelection( cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll ); }, killLine: function (cm) { return deleteNearSelection(cm, function (range) { if (range.empty()) { var len = getLine(cm.doc, range.head.line).text.length; if ( range.head.ch == len && range.head.line < cm.lastLine() ) { return { from: range.head, to: Pos(range.head.line + 1, 0), }; } else { return { from: range.head, to: Pos(range.head.line, len), }; } } else { return { from: range.from(), to: range.to() }; } }); }, deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return { from: Pos(range.from().line, 0), to: clipPos(cm.doc, Pos(range.to().line + 1, 0)), }; }); }, delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return { from: Pos(range.from().line, 0), to: range.from(), }; }); }, delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var leftPos = cm.coordsChar({ left: 0, top: top }, "div"); return { from: leftPos, to: range.from() }; }); }, delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var rightPos = cm.coordsChar( { left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div" ); return { from: range.from(), to: rightPos }; }); }, undo: function (cm) { return cm.undo(); }, redo: function (cm) { return cm.redo(); }, undoSelection: function (cm) { return cm.undoSelection(); }, redoSelection: function (cm) { return cm.redoSelection(); }, goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); }, goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); }, goLineStart: function (cm) { return cm.extendSelectionsBy( function (range) { return lineStart(cm, range.head.line); }, { origin: "+move", bias: 1 } ); }, goLineStartSmart: function (cm) { return cm.extendSelectionsBy( function (range) { return lineStartSmart(cm, range.head); }, { origin: "+move", bias: 1 } ); }, goLineEnd: function (cm) { return cm.extendSelectionsBy( function (range) { return lineEnd(cm, range.head.line); }, { origin: "+move", bias: -1 } ); }, goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar( { left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div" ); }, sel_move); }, goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({ left: 0, top: top }, "div"); }, sel_move); }, goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; var pos = cm.coordsChar({ left: 0, top: top }, "div"); if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head); } return pos; }, sel_move); }, goLineUp: function (cm) { return cm.moveV(-1, "line"); }, goLineDown: function (cm) { return cm.moveV(1, "line"); }, goPageUp: function (cm) { return cm.moveV(-1, "page"); }, goPageDown: function (cm) { return cm.moveV(1, "page"); }, goCharLeft: function (cm) { return cm.moveH(-1, "char"); }, goCharRight: function (cm) { return cm.moveH(1, "char"); }, goColumnLeft: function (cm) { return cm.moveH(-1, "column"); }, goColumnRight: function (cm) { return cm.moveH(1, "column"); }, goWordLeft: function (cm) { return cm.moveH(-1, "word"); }, goGroupRight: function (cm) { return cm.moveH(1, "group"); }, goGroupLeft: function (cm) { return cm.moveH(-1, "group"); }, goWordRight: function (cm) { return cm.moveH(1, "word"); }, delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); }, delCharAfter: function (cm) { return cm.deleteH(1, "char"); }, delWordBefore: function (cm) { return cm.deleteH(-1, "word"); }, delWordAfter: function (cm) { return cm.deleteH(1, "word"); }, delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); }, delGroupAfter: function (cm) { return cm.deleteH(1, "group"); }, indentAuto: function (cm) { return cm.indentSelection("smart"); }, indentMore: function (cm) { return cm.indentSelection("add"); }, indentLess: function (cm) { return cm.indentSelection("subtract"); }, insertTab: function (cm) { return cm.replaceSelection("\t"); }, insertSoftTab: function (cm) { var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].from(); var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); spaces.push(spaceStr(tabSize - (col % tabSize))); } cm.replaceSelections(spaces); }, defaultTab: function (cm) { if (cm.somethingSelected()) { cm.indentSelection("add"); } else { cm.execCommand("insertTab"); } }, // Swap the two chars left and right of each selection's head. // Move cursor behind the two swapped characters afterwards. // // Doesn't consider line feeds a character. // Doesn't scan more than one line above to find a character. // Doesn't do anything on an empty line. // Doesn't do anything with non-empty selections. transposeChars: function (cm) { return runInOp(cm, function () { var ranges = cm.listSelections(), newSel = []; for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) { continue; } var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; if (line) { if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); } if (cur.ch > 0) { cur = new Pos(cur.line, cur.ch + 1); cm.replaceRange( line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose" ); } else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; if (prev) { cur = new Pos(cur.line, 1); cm.replaceRange( line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose" ); } } } newSel.push(new Range(cur, cur)); } cm.setSelections(newSel); }); }, newlineAndIndent: function (cm) { return runInOp(cm, function () { var sels = cm.listSelections(); for (var i = sels.length - 1; i >= 0; i--) { cm.replaceRange( cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input" ); } sels = cm.listSelections(); for (var i$1 = 0; i$1 < sels.length; i$1++) { cm.indentLine(sels[i$1].from().line, null, true); } ensureCursorVisible(cm); }); }, openLine: function (cm) { return cm.replaceSelection("\n", "start"); }, toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }, }; function lineStart(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLine(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, visual, lineN, 1); } function lineEnd(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLineEnd(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, line, lineN, -1); } function lineStartSmart(cm, pos) { var start = lineStart(cm, pos.line); var line = getLine(cm.doc, start.line); var order = getOrder(line, cm.doc.direction); if (!order || order[0].level == 0) { var firstNonWS = Math.max(start.ch, line.text.search(/\S/)); var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky); } return start; } // Run a handler that was bound to a key. function doHandleBinding(cm, bound, dropShift) { if (typeof bound == "string") { bound = commands[bound]; if (!bound) { return false; } } // Ensure previous input has been read, so that the handler sees a // consistent view of the document cm.display.input.ensurePolled(); var prevShift = cm.display.shift, done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } if (dropShift) { cm.display.shift = false; } done = bound(cm) != Pass; } finally { cm.display.shift = prevShift; cm.state.suppressEdits = false; } return done; } function lookupKeyForEditor(cm, name, handle) { for (var i = 0; i < cm.state.keyMaps.length; i++) { var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); if (result) { return result; } } return ( (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) || lookupKey(name, cm.options.keyMap, handle, cm) ); } // Note that, despite the name, this function is also used to check // for bound mouse clicks. var stopSeq = new Delayed(); function dispatchKey(cm, name, e, handle) { var seq = cm.state.keySeq; if (seq) { if (isModifierKey(name)) { return "handled"; } if (/\'$/.test(name)) { cm.state.keySeq = null; } else { stopSeq.set(50, function () { if (cm.state.keySeq == seq) { cm.state.keySeq = null; cm.display.input.reset(); } }); } if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true; } } return dispatchKeyInner(cm, name, e, handle); } function dispatchKeyInner(cm, name, e, handle) { var result = lookupKeyForEditor(cm, name, handle); if (result == "multi") { cm.state.keySeq = name; } if (result == "handled") { signalLater(cm, "keyHandled", cm, name, e); } if (result == "handled" || result == "multi") { e_preventDefault(e); restartBlink(cm); } return !!result; } // Handle a key from the keydown event. function handleKeyBinding(cm, e) { var name = keyName(e, true); if (!name) { return false; } if (e.shiftKey && !cm.state.keySeq) { // First try to resolve full name (including 'Shift-'). Failing // that, see if there is a cursor-motion command (starting with // 'go') bound to the keyname without 'Shift-'. return ( dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); }) || dispatchKey(cm, name, e, function (b) { if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) { return doHandleBinding(cm, b); } }) ); } else { return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); }); } } // Handle a key from the keypress event function handleCharBinding(cm, e, ch) { return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); }); } var lastStoppedKey = null; function onKeyDown(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return; } cm.curOp.focus = activeElt(); if (signalDOMEvent(cm, e)) { return; } // IE does strange things with escape. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } var code = e.keyCode; cm.display.shift = code == 16 || e.shiftKey; var handled = handleKeyBinding(cm, e); if (presto) { lastStoppedKey = handled ? code : null; // Opera has no cut event... we try to at least catch the key combo if ( !handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey) ) { cm.replaceSelection("", null, "cut"); } } if ( gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand ) { document.execCommand("cut"); } // Turn mouse into crosshair when Alt is held on Mac. if ( code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className) ) { showCrossHair(cm); } } function showCrossHair(cm) { var lineDiv = cm.display.lineDiv; addClass(lineDiv, "CodeMirror-crosshair"); function up(e) { if (e.keyCode == 18 || !e.altKey) { rmClass(lineDiv, "CodeMirror-crosshair"); off(document, "keyup", up); off(document, "mouseover", up); } } on(document, "keyup", up); on(document, "mouseover", up); } function onKeyUp(e) { if (e.keyCode == 16) { this.doc.sel.shift = false; } signalDOMEvent(this, e); } function onKeyPress(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return; } if ( eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || (e.ctrlKey && !e.altKey) || (mac && e.metaKey) ) { return; } var keyCode = e.keyCode, charCode = e.charCode; if (presto && keyCode == lastStoppedKey) { lastStoppedKey = null; e_preventDefault(e); return; } if (presto && (!e.which || e.which < 10) && handleKeyBinding(cm, e)) { return; } var ch = String.fromCharCode(charCode == null ? keyCode : charCode); // Some browsers fire keypress events for backspace if (ch == "\x08") { return; } if (handleCharBinding(cm, e, ch)) { return; } cm.display.input.onKeyPress(e); } var DOUBLECLICK_DELAY = 400; var PastClick = function (time, pos, button) { this.time = time; this.pos = pos; this.button = button; }; PastClick.prototype.compare = function (time, pos, button) { return ( this.time + DOUBLECLICK_DELAY > time && cmp(pos, this.pos) == 0 && button == this.button ); }; var lastClick, lastDoubleClick; function clickRepeat(pos, button) { var now = +new Date(); if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) { lastClick = lastDoubleClick = null; return "triple"; } else if (lastClick && lastClick.compare(now, pos, button)) { lastDoubleClick = new PastClick(now, pos, button); lastClick = null; return "double"; } else { lastClick = new PastClick(now, pos, button); lastDoubleClick = null; return "single"; } } // A mouse down can be a single click, double click, triple click, // start of selection drag, start of text drag, new cursor // (ctrl-click), rectangle drag (alt-drag), or xwin // middle-click-paste. Or it might be a click on something we should // not interfere with, such as a scrollbar or widget. function onMouseDown(e) { var cm = this, display = cm.display; if ( signalDOMEvent(cm, e) || (display.activeTouch && display.input.supportsTouch()) ) { return; } display.input.ensurePolled(); display.shift = e.shiftKey; if (eventInWidget(display, e)) { if (!webkit) { // Briefly turn off draggability, to allow widgets to do // normal dragging things. display.scroller.draggable = false; setTimeout(function () { return (display.scroller.draggable = true); }, 100); } return; } if (clickInGutter(cm, e)) { return; } var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; window.focus(); // #3261: make sure, that we're not starting a second selection if (button == 1 && cm.state.selectingText) { cm.state.selectingText(e); } if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return; } if (button == 1) { if (pos) { leftButtonDown(cm, pos, repeat, e); } else if (e_target(e) == display.scroller) { e_preventDefault(e); } } else if (button == 2) { if (pos) { extendSelection(cm.doc, pos); } setTimeout(function () { return display.input.focus(); }, 20); } else if (button == 3) { if (captureRightClick) { cm.display.input.onContextMenu(e); } else { delayBlurEvent(cm); } } } function handleMappedButton(cm, button, pos, repeat, event) { var name = "Click"; if (repeat == "double") { name = "Double" + name; } else if (repeat == "triple") { name = "Triple" + name; } name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name; return dispatchKey( cm, addModifierNames(name, event), event, function (bound) { if (typeof bound == "string") { bound = commands[bound]; } if (!bound) { return false; } var done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } done = bound(cm, pos) != Pass; } finally { cm.state.suppressEdits = false; } return done; } ); } function configureMouse(cm, repeat, event) { var option = cm.getOption("configureMouse"); var value = option ? option(cm, repeat, event) : {}; if (value.unit == null) { var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey; value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"; } if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; } if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; } if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); } return value; } function leftButtonDown(cm, pos, repeat, event) { if (ie) { setTimeout(bind(ensureFocus, cm), 0); } else { cm.curOp.focus = activeElt(); } var behavior = configureMouse(cm, repeat, event); var sel = cm.doc.sel, contained; if ( cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && repeat == "single" && (contained = sel.contains(pos)) > -1 && (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0) ) { leftButtonStartDrag(cm, event, pos, behavior); } else { leftButtonSelect(cm, event, pos, behavior); } } // Start a text drag. When it ends, see if any dragging actually // happen, and treat as a click if it didn't. function leftButtonStartDrag(cm, event, pos, behavior) { var display = cm.display, moved = false; var dragEnd = operation(cm, function (e) { if (webkit) { display.scroller.draggable = false; } cm.state.draggingText = false; if (cm.state.delayingBlurEvent) { if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; } else { delayBlurEvent(cm); } } off(display.wrapper.ownerDocument, "mouseup", dragEnd); off(display.wrapper.ownerDocument, "mousemove", mouseMove); off(display.scroller, "dragstart", dragStart); off(display.scroller, "drop", dragEnd); if (!moved) { e_preventDefault(e); if (!behavior.addNew) { extendSelection(cm.doc, pos, null, null, behavior.extend); } // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) if ((webkit && !safari) || (ie && ie_version == 9)) { setTimeout(function () { display.wrapper.ownerDocument.body.focus({ preventScroll: true, }); display.input.focus(); }, 20); } else { display.input.focus(); } } }); var mouseMove = function (e2) { moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10; }; var dragStart = function () { return (moved = true); }; // Let the drag handler handle this. if (webkit) { display.scroller.draggable = true; } cm.state.draggingText = dragEnd; dragEnd.copy = !behavior.moveOnDrag; on(display.wrapper.ownerDocument, "mouseup", dragEnd); on(display.wrapper.ownerDocument, "mousemove", mouseMove); on(display.scroller, "dragstart", dragStart); on(display.scroller, "drop", dragEnd); cm.state.delayingBlurEvent = true; setTimeout(function () { return display.input.focus(); }, 20); // IE's approach to draggable if (display.scroller.dragDrop) { display.scroller.dragDrop(); } } function rangeForUnit(cm, pos, unit) { if (unit == "char") { return new Range(pos, pos); } if (unit == "word") { return cm.findWordAt(pos); } if (unit == "line") { return new Range( Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)) ); } var result = unit(cm, pos); return new Range(result.from, result.to); } // Normal selection, as opposed to text dragging. function leftButtonSelect(cm, event, start, behavior) { if (ie) { delayBlurEvent(cm); } var display = cm.display, doc = cm.doc; e_preventDefault(event); var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; if (behavior.addNew && !behavior.extend) { ourIndex = doc.sel.contains(start); if (ourIndex > -1) { ourRange = ranges[ourIndex]; } else { ourRange = new Range(start, start); } } else { ourRange = doc.sel.primary(); ourIndex = doc.sel.primIndex; } if (behavior.unit == "rectangle") { if (!behavior.addNew) { ourRange = new Range(start, start); } start = posFromMouse(cm, event, true, true); ourIndex = -1; } else { var range = rangeForUnit(cm, start, behavior.unit); if (behavior.extend) { ourRange = extendRange( ourRange, range.anchor, range.head, behavior.extend ); } else { ourRange = range; } } if (!behavior.addNew) { ourIndex = 0; setSelection(doc, new Selection([ourRange], 0), sel_mouse); startSel = doc.sel; } else if (ourIndex == -1) { ourIndex = ranges.length; setSelection( doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), { scroll: false, origin: "*mouse" } ); } else if ( ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend ) { setSelection( doc, normalizeSelection( cm, ranges .slice(0, ourIndex) .concat(ranges.slice(ourIndex + 1)), 0 ), { scroll: false, origin: "*mouse" } ); startSel = doc.sel; } else { replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); } var lastPos = start; function extendTo(pos) { if (cmp(lastPos, pos) == 0) { return; } lastPos = pos; if (behavior.unit == "rectangle") { var ranges = [], tabSize = cm.options.tabSize; var startCol = countColumn( getLine(doc, start.line).text, start.ch, tabSize ); var posCol = countColumn( getLine(doc, pos.line).text, pos.ch, tabSize ); var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); for ( var line = Math.min(start.line, pos.line), end = Math.min( cm.lastLine(), Math.max(start.line, pos.line) ); line <= end; line++ ) { var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); if (left == right) { ranges.push( new Range(Pos(line, leftPos), Pos(line, leftPos)) ); } else if (text.length > leftPos) { ranges.push( new Range( Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)) ) ); } } if (!ranges.length) { ranges.push(new Range(start, start)); } setSelection( doc, normalizeSelection( cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex ), { origin: "*mouse", scroll: false } ); cm.scrollIntoView(pos); } else { var oldRange = ourRange; var range = rangeForUnit(cm, pos, behavior.unit); var anchor = oldRange.anchor, head; if (cmp(range.anchor, anchor) > 0) { head = range.head; anchor = minPos(oldRange.from(), range.anchor); } else { head = range.anchor; anchor = maxPos(oldRange.to(), range.head); } var ranges$1 = startSel.ranges.slice(0); ranges$1[ourIndex] = bidiSimplify( cm, new Range(clipPos(doc, anchor), head) ); setSelection( doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse ); } } var editorSize = display.wrapper.getBoundingClientRect(); // Used to ensure timeout re-tries don't fire when another extend // happened in the meantime (clearTimeout isn't reliable -- at // least on Chrome, the timeouts still happen even when cleared, // if the clear happens after their scheduled firing time). var counter = 0; function extend(e) { var curCount = ++counter; var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); if (!cur) { return; } if (cmp(cur, lastPos) != 0) { cm.curOp.focus = activeElt(); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) { setTimeout( operation(cm, function () { if (counter == curCount) { extend(e); } }), 150 ); } } else { var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; if (outside) { setTimeout( operation(cm, function () { if (counter != curCount) { return; } display.scroller.scrollTop += outside; extend(e); }), 50 ); } } } function done(e) { cm.state.selectingText = false; counter = Infinity; // If e is null or undefined we interpret this as someone trying // to explicitly cancel the selection rather than the user // letting go of the mouse button. if (e) { e_preventDefault(e); display.input.focus(); } off(display.wrapper.ownerDocument, "mousemove", move); off(display.wrapper.ownerDocument, "mouseup", up); doc.history.lastSelOrigin = null; } var move = operation(cm, function (e) { if (e.buttons === 0 || !e_button(e)) { done(e); } else { extend(e); } }); var up = operation(cm, done); cm.state.selectingText = up; on(display.wrapper.ownerDocument, "mousemove", move); on(display.wrapper.ownerDocument, "mouseup", up); } // Used when mouse-selecting to adjust the anchor to the proper side // of a bidi jump depending on the visual position of the head. function bidiSimplify(cm, range) { var anchor = range.anchor; var head = range.head; var anchorLine = getLine(cm.doc, anchor.line); if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range; } var order = getOrder(anchorLine); if (!order) { return range; } var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]; if (part.from != anchor.ch && part.to != anchor.ch) { return range; } var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1); if (boundary == 0 || boundary == order.length) { return range; } // Compute the relative visual position of the head compared to the // anchor (<0 is to the left, >0 to the right) var leftSide; if (head.line != anchor.line) { leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0; } else { var headIndex = getBidiPartAt(order, head.ch, head.sticky); var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1); if (headIndex == boundary - 1 || headIndex == boundary) { leftSide = dir < 0; } else { leftSide = dir > 0; } } var usePart = order[boundary + (leftSide ? -1 : 0)]; var from = leftSide == (usePart.level == 1); var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"; return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head); } // Determines whether an event happened in the gutter, and fires the // handlers for the corresponding event. function gutterEvent(cm, e, type, prevent) { var mX, mY; if (e.touches) { mX = e.touches[0].clientX; mY = e.touches[0].clientY; } else { try { mX = e.clientX; mY = e.clientY; } catch (e$1) { return false; } } if ( mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right) ) { return false; } if (prevent) { e_preventDefault(e); } var display = cm.display; var lineBox = display.lineDiv.getBoundingClientRect(); if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e); } mY -= lineBox.top - display.viewOffset; for (var i = 0; i < cm.display.gutterSpecs.length; ++i) { var g = display.gutters.childNodes[i]; if (g && g.getBoundingClientRect().right >= mX) { var line = lineAtHeight(cm.doc, mY); var gutter = cm.display.gutterSpecs[i]; signal(cm, type, cm, line, gutter.className, e); return e_defaultPrevented(e); } } } function clickInGutter(cm, e) { return gutterEvent(cm, e, "gutterClick", true); } // CONTEXT MENU HANDLING // To make the context menu work, we need to briefly unhide the // textarea (making it as unobtrusive as possible) to let the // right-click take effect on it. function onContextMenu(cm, e) { if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return; } if (signalDOMEvent(cm, e, "contextmenu")) { return; } if (!captureRightClick) { cm.display.input.onContextMenu(e); } } function contextMenuInGutter(cm, e) { if (!hasHandler(cm, "gutterContextMenu")) { return false; } return gutterEvent(cm, e, "gutterContextMenu", false); } function themeChanged(cm) { cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); clearCaches(cm); } var Init = { toString: function () { return "CodeMirror.Init"; }, }; var defaults = {}; var optionHandlers = {}; function defineOptions(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; function option(name, deflt, handle, notOnInit) { CodeMirror.defaults[name] = deflt; if (handle) { optionHandlers[name] = notOnInit ? function (cm, val, old) { if (old != Init) { handle(cm, val, old); } } : handle; } } CodeMirror.defineOption = option; // Passed to option handlers when there is no old value. CodeMirror.Init = Init; // These two are, on init, called from the constructor because they // have to be initialized before the editor can start at all. option( "value", "", function (cm, val) { return cm.setValue(val); }, true ); option( "mode", null, function (cm, val) { cm.doc.modeOption = val; loadMode(cm); }, true ); option("indentUnit", 2, loadMode, true); option("indentWithTabs", false); option("smartIndent", true); option( "tabSize", 4, function (cm) { resetModeState(cm); clearCaches(cm); regChange(cm); }, true ); option("lineSeparator", null, function (cm, val) { cm.doc.lineSep = val; if (!val) { return; } var newBreaks = [], lineNo = cm.doc.first; cm.doc.iter(function (line) { for (var pos = 0; ; ) { var found = line.text.indexOf(val, pos); if (found == -1) { break; } pos = found + val.length; newBreaks.push(Pos(lineNo, found)); } lineNo++; }); for (var i = newBreaks.length - 1; i >= 0; i--) { replaceRange( cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length) ); } }); option( "specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { cm.state.specialChars = new RegExp( val.source + (val.test("\t") ? "" : "|\t"), "g" ); if (old != Init) { cm.refresh(); } } ); option( "specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true ); option("electricChars", true); option( "inputStyle", mobile ? "contenteditable" : "textarea", function () { throw new Error( "inputStyle can not (yet) be changed in a running editor" ); // FIXME }, true ); option( "spellcheck", false, function (cm, val) { return (cm.getInputField().spellcheck = val); }, true ); option( "autocorrect", false, function (cm, val) { return (cm.getInputField().autocorrect = val); }, true ); option( "autocapitalize", false, function (cm, val) { return (cm.getInputField().autocapitalize = val); }, true ); option("rtlMoveVisually", !windows); option("wholeLineUpdateBefore", true); option( "theme", "default", function (cm) { themeChanged(cm); updateGutters(cm); }, true ); option("keyMap", "default", function (cm, val, old) { var next = getKeyMap(val); var prev = old != Init && getKeyMap(old); if (prev && prev.detach) { prev.detach(cm, next); } if (next.attach) { next.attach(cm, prev || null); } }); option("extraKeys", null); option("configureMouse", null); option("lineWrapping", false, wrappingChanged, true); option( "gutters", [], function (cm, val) { cm.display.gutterSpecs = getGutters( val, cm.options.lineNumbers ); updateGutters(cm); }, true ); option( "fixedGutter", true, function (cm, val) { cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; cm.refresh(); }, true ); option( "coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true ); option( "scrollbarStyle", "native", function (cm) { initScrollbars(cm); updateScrollbars(cm); cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); }, true ); option( "lineNumbers", false, function (cm, val) { cm.display.gutterSpecs = getGutters(cm.options.gutters, val); updateGutters(cm); }, true ); option("firstLineNumber", 1, updateGutters, true); option( "lineNumberFormatter", function (integer) { return integer; }, updateGutters, true ); option("showCursorWhenSelecting", false, updateSelection, true); option("resetSelectionOnContextMenu", true); option("lineWiseCopyCut", true); option("pasteLinesPerSelection", true); option("selectionsMayTouch", false); option("readOnly", false, function (cm, val) { if (val == "nocursor") { onBlur(cm); cm.display.input.blur(); } cm.display.input.readOnlyChanged(val); }); option("screenReaderLabel", null, function (cm, val) { val = val === "" ? null : val; cm.display.input.screenReaderLabelChanged(val); }); option( "disableInput", false, function (cm, val) { if (!val) { cm.display.input.reset(); } }, true ); option("dragDrop", true, dragDropChanged); option("allowDropFileTypes", null); option("cursorBlinkRate", 530); option("cursorScrollMargin", 0); option("cursorHeight", 1, updateSelection, true); option("singleCursorHeightPerLine", true, updateSelection, true); option("workTime", 100); option("workDelay", 100); option("flattenSpans", true, resetModeState, true); option("addModeClass", false, resetModeState, true); option("pollInterval", 100); option("undoDepth", 200, function (cm, val) { return (cm.doc.history.undoDepth = val); }); option("historyEventDelay", 1250); option( "viewportMargin", 10, function (cm) { return cm.refresh(); }, true ); option("maxHighlightLength", 10000, resetModeState, true); option("moveInputWithCursor", true, function (cm, val) { if (!val) { cm.display.input.resetPosition(); } }); option("tabindex", null, function (cm, val) { return (cm.display.input.getField().tabIndex = val || ""); }); option("autofocus", null); option( "direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true ); option("phrases", null); } function dragDropChanged(cm, value, old) { var wasOn = old && old != Init; if (!value != !wasOn) { var funcs = cm.display.dragFunctions; var toggle = value ? on : off; toggle(cm.display.scroller, "dragstart", funcs.start); toggle(cm.display.scroller, "dragenter", funcs.enter); toggle(cm.display.scroller, "dragover", funcs.over); toggle(cm.display.scroller, "dragleave", funcs.leave); toggle(cm.display.scroller, "drop", funcs.drop); } } function wrappingChanged(cm) { if (cm.options.lineWrapping) { addClass(cm.display.wrapper, "CodeMirror-wrap"); cm.display.sizer.style.minWidth = ""; cm.display.sizerWidth = null; } else { rmClass(cm.display.wrapper, "CodeMirror-wrap"); findMaxLine(cm); } estimateLineHeights(cm); regChange(cm); clearCaches(cm); setTimeout(function () { return updateScrollbars(cm); }, 100); } // A CodeMirror instance represents an editor. This is the object // that user code is usually dealing with. function CodeMirror(place, options) { var this$1 = this; if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options); } this.options = options = options ? copyObj(options) : {}; // Determine effective options based on given values and defaults. copyObj(defaults, options, false); var doc = options.value; if (typeof doc == "string") { doc = new Doc( doc, options.mode, null, options.lineSeparator, options.direction ); } else if (options.mode) { doc.modeOption = options.mode; } this.doc = doc; var input = new CodeMirror.inputStyles[options.inputStyle](this); var display = (this.display = new Display(place, doc, input, options)); display.wrapper.CodeMirror = this; themeChanged(this); if (options.lineWrapping) { this.display.wrapper.className += " CodeMirror-wrap"; } initScrollbars(this); this.state = { keyMaps: [], // stores maps added by addKeyMap overlays: [], // highlighting overlays, as added by addOverlay modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info overwrite: false, delayingBlurEvent: false, focused: false, suppressEdits: false, // used to disable editing during key handlers when in readOnly mode pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll selectingText: false, draggingText: false, highlight: new Delayed(), // stores highlight worker timeout keySeq: null, // Unfinished key sequence specialChars: null, }; if (options.autofocus && !mobile) { display.input.focus(); } // Override magic textarea content restore that IE sometimes does // on our hidden textarea on reload if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); } registerEventHandlers(this); ensureGlobalHandlers(); startOperation(this); this.curOp.forceUpdate = true; attachDoc(this, doc); if ((options.autofocus && !mobile) || this.hasFocus()) { setTimeout(function () { if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); } }, 20); } else { onBlur(this); } for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt)) { optionHandlers[opt](this, options[opt], Init); } } maybeUpdateLineNumberWidth(this); if (options.finishInit) { options.finishInit(this); } for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this); } endOperation(this); // Suppress optimizelegibility in Webkit, since it breaks text // measuring on line wrapping boundaries. if ( webkit && options.lineWrapping && getComputedStyle(display.lineDiv).textRendering == "optimizelegibility" ) { display.lineDiv.style.textRendering = "auto"; } } // The default configuration options. CodeMirror.defaults = defaults; // Functions to run when options are changed. CodeMirror.optionHandlers = optionHandlers; // Attach the necessary event handlers when initializing the editor function registerEventHandlers(cm) { var d = cm.display; on(d.scroller, "mousedown", operation(cm, onMouseDown)); // Older IE's will not fire a second mousedown for a double click if (ie && ie_version < 11) { on( d.scroller, "dblclick", operation(cm, function (e) { if (signalDOMEvent(cm, e)) { return; } var pos = posFromMouse(cm, e); if ( !pos || clickInGutter(cm, e) || eventInWidget(cm.display, e) ) { return; } e_preventDefault(e); var word = cm.findWordAt(pos); extendSelection(cm.doc, word.anchor, word.head); }) ); } else { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); } // Some browsers fire contextmenu *after* opening the menu, at // which point we can't mess with it anymore. Context menu is // handled in onMouseDown for these browsers. on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); on(d.input.getField(), "contextmenu", function (e) { if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); } }); // Used to suppress mouse event handling when a touch happens var touchFinished, prevTouch = { end: 0 }; function finishTouch() { if (d.activeTouch) { touchFinished = setTimeout(function () { return (d.activeTouch = null); }, 1000); prevTouch = d.activeTouch; prevTouch.end = +new Date(); } } function isMouseLikeTouchEvent(e) { if (e.touches.length != 1) { return false; } var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1; } function farAway(touch, other) { if (other.left == null) { return true; } var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 20 * 20; } on(d.scroller, "touchstart", function (e) { if ( !signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e) ) { d.input.ensurePolled(); clearTimeout(touchFinished); var now = +new Date(); d.activeTouch = { start: now, moved: false, prev: now - prevTouch.end <= 300 ? prevTouch : null, }; if (e.touches.length == 1) { d.activeTouch.left = e.touches[0].pageX; d.activeTouch.top = e.touches[0].pageY; } } }); on(d.scroller, "touchmove", function () { if (d.activeTouch) { d.activeTouch.moved = true; } }); on(d.scroller, "touchend", function (e) { var touch = d.activeTouch; if ( touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date() - touch.start < 300 ) { var pos = cm.coordsChar(d.activeTouch, "page"), range; if (!touch.prev || farAway(touch, touch.prev)) { // Single tap range = new Range(pos, pos); } else if ( !touch.prev.prev || farAway(touch, touch.prev.prev) ) { // Double tap range = cm.findWordAt(pos); } // Triple tap else { range = new Range( Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)) ); } cm.setSelection(range.anchor, range.head); cm.focus(); e_preventDefault(e); } finishTouch(); }); on(d.scroller, "touchcancel", finishTouch); // Sync scrolling between fake scrollbars and real scrollable // area, ensure viewport is updated when scrolling. on(d.scroller, "scroll", function () { if (d.scroller.clientHeight) { updateScrollTop(cm, d.scroller.scrollTop); setScrollLeft(cm, d.scroller.scrollLeft, true); signal(cm, "scroll", cm); } }); // Listen to wheel events in order to try and update the viewport on time. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); }); on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); }); // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function () { return (d.wrapper.scrollTop = d.wrapper.scrollLeft = 0); }); d.dragFunctions = { enter: function (e) { if (!signalDOMEvent(cm, e)) { e_stop(e); } }, over: function (e) { if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); } }, start: function (e) { return onDragStart(cm, e); }, drop: operation(cm, onDrop), leave: function (e) { if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); } }, }; var inp = d.input.getField(); on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); }); on(inp, "keydown", operation(cm, onKeyDown)); on(inp, "keypress", operation(cm, onKeyPress)); on(inp, "focus", function (e) { return onFocus(cm, e); }); on(inp, "blur", function (e) { return onBlur(cm, e); }); } var initHooks = []; CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }; // Indent the given line. The how parameter can be "smart", // "add"/null, "subtract", or "prev". When aggressive is false // (typically set to true for forced single-line indents), empty // lines are not indented, and places where the mode returns Pass // are left alone. function indentLine(cm, n, how, aggressive) { var doc = cm.doc, state; if (how == null) { how = "add"; } if (how == "smart") { // Fall back to "prev" when the mode doesn't have an indentation // method. if (!doc.mode.indent) { how = "prev"; } else { state = getContextBefore(cm, n).state; } } var tabSize = cm.options.tabSize; var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); if (line.stateAfter) { line.stateAfter = null; } var curSpaceString = line.text.match(/^\s*/)[0], indentation; if (!aggressive && !/\S/.test(line.text)) { indentation = 0; how = "not"; } else if (how == "smart") { indentation = doc.mode.indent( state, line.text.slice(curSpaceString.length), line.text ); if (indentation == Pass || indentation > 150) { if (!aggressive) { return; } how = "prev"; } } if (how == "prev") { if (n > doc.first) { indentation = countColumn( getLine(doc, n - 1).text, null, tabSize ); } else { indentation = 0; } } else if (how == "add") { indentation = curSpace + cm.options.indentUnit; } else if (how == "subtract") { indentation = curSpace - cm.options.indentUnit; } else if (typeof how == "number") { indentation = curSpace + how; } indentation = Math.max(0, indentation); var indentString = "", pos = 0; if (cm.options.indentWithTabs) { for (var i = Math.floor(indentation / tabSize); i; --i) { pos += tabSize; indentString += "\t"; } } if (pos < indentation) { indentString += spaceStr(indentation - pos); } if (indentString != curSpaceString) { replaceRange( doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input" ); line.stateAfter = null; return true; } else { // Ensure that, if the cursor was in the whitespace at the start // of the line, it is moved to the end of that space. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) { var range = doc.sel.ranges[i$1]; if ( range.head.line == n && range.head.ch < curSpaceString.length ) { var pos$1 = Pos(n, curSpaceString.length); replaceOneSelection(doc, i$1, new Range(pos$1, pos$1)); break; } } } } // This will be set to a {lineWise: bool, text: [string]} object, so // that, when pasting, we know what kind of selections the copied // text was made out of. var lastCopied = null; function setLastCopied(newLastCopied) { lastCopied = newLastCopied; } function applyTextInput(cm, inserted, deleted, sel, origin) { var doc = cm.doc; cm.display.shift = false; if (!sel) { sel = doc.sel; } var recent = +new Date() - 200; var paste = origin == "paste" || cm.state.pasteIncoming > recent; var textLines = splitLinesAuto(inserted), multiPaste = null; // When pasting N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { if (lastCopied && lastCopied.text.join("\n") == inserted) { if (sel.ranges.length % lastCopied.text.length == 0) { multiPaste = []; for (var i = 0; i < lastCopied.text.length; i++) { multiPaste.push(doc.splitLines(lastCopied.text[i])); } } } else if ( textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection ) { multiPaste = map(textLines, function (l) { return [l]; }); } } var updateInput = cm.curOp.updateInput; // Normal behavior is to insert the new text into every selection for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) { var range = sel.ranges[i$1]; var from = range.from(), to = range.to(); if (range.empty()) { if (deleted && deleted > 0) { // Handle deletion from = Pos(from.line, from.ch - deleted); } else if (cm.state.overwrite && !paste) { // Handle overwrite to = Pos( to.line, Math.min( getLine(doc, to.line).text.length, to.ch + lst(textLines).length ) ); } else if ( paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n") ) { from = to = Pos(from.line, 0); } } var changeEvent = { from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines, origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input"), }; makeChange(cm.doc, changeEvent); signalLater(cm, "inputRead", cm, changeEvent); } if (inserted && !paste) { triggerElectric(cm, inserted); } ensureCursorVisible(cm); if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; } cm.curOp.typing = true; cm.state.pasteIncoming = cm.state.cutIncoming = -1; } function handlePaste(e, cm) { var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) { e.preventDefault(); if (!cm.isReadOnly() && !cm.options.disableInput) { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); } return true; } } function triggerElectric(cm, inserted) { // When an 'electric' character is inserted, immediately trigger a reindent if (!cm.options.electricChars || !cm.options.smartIndent) { return; } var sel = cm.doc.sel; for (var i = sel.ranges.length - 1; i >= 0; i--) { var range = sel.ranges[i]; if ( range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line) ) { continue; } var mode = cm.getModeAt(range.head); var indented = false; if (mode.electricChars) { for (var j = 0; j < mode.electricChars.length; j++) { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { indented = indentLine(cm, range.head.line, "smart"); break; } } } else if (mode.electricInput) { if ( mode.electricInput.test( getLine(cm.doc, range.head.line).text.slice( 0, range.head.ch ) ) ) { indented = indentLine(cm, range.head.line, "smart"); } } if (indented) { signalLater(cm, "electricInput", cm, range.head.line); } } } function copyableRanges(cm) { var text = [], ranges = []; for (var i = 0; i < cm.doc.sel.ranges.length; i++) { var line = cm.doc.sel.ranges[i].head.line; var lineRange = { anchor: Pos(line, 0), head: Pos(line + 1, 0) }; ranges.push(lineRange); text.push(cm.getRange(lineRange.anchor, lineRange.head)); } return { text: text, ranges: ranges }; } function disableBrowserMagic( field, spellcheck, autocorrect, autocapitalize ) { field.setAttribute("autocorrect", autocorrect ? "" : "off"); field.setAttribute("autocapitalize", autocapitalize ? "" : "off"); field.setAttribute("spellcheck", !!spellcheck); } function hiddenTextarea() { var te = elt( "textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none" ); var div = elt( "div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;" ); // The textarea is kept positioned near the cursor to prevent the // fact that it'll be scrolled into view on input from scrolling // our fake cursor out of view. On webkit, when wrap=off, paste is // very slow. So make the area wide instead. if (webkit) { te.style.width = "1000px"; } else { te.setAttribute("wrap", "off"); } // If border: 0; -- iOS fails to open keyboard (issue #1287) if (ios) { te.style.border = "1px solid black"; } disableBrowserMagic(te); return div; } // The publicly visible API. Note that methodOp(f) means // 'wrap f in an operation, performed on its `this` parameter'. // This is not the complete set of editor methods. Most of the // methods defined on the Doc type are also injected into // CodeMirror.prototype, for backwards compatibility and // convenience. function addEditorMethods(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; var helpers = (CodeMirror.helpers = {}); CodeMirror.prototype = { constructor: CodeMirror, focus: function () { window.focus(); this.display.input.focus(); }, setOption: function (option, value) { var options = this.options, old = options[option]; if (options[option] == value && option != "mode") { return; } options[option] = value; if (optionHandlers.hasOwnProperty(option)) { operation(this, optionHandlers[option])(this, value, old); } signal(this, "optionChange", this, option); }, getOption: function (option) { return this.options[option]; }, getDoc: function () { return this.doc; }, addKeyMap: function (map, bottom) { this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); }, removeKeyMap: function (map) { var maps = this.state.keyMaps; for (var i = 0; i < maps.length; ++i) { if (maps[i] == map || maps[i].name == map) { maps.splice(i, 1); return true; } } }, addOverlay: methodOp(function (spec, options) { var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); if (mode.startState) { throw new Error("Overlays may not be stateful."); } insertSorted( this.state.overlays, { mode: mode, modeSpec: spec, opaque: options && options.opaque, priority: (options && options.priority) || 0, }, function (overlay) { return overlay.priority; } ); this.state.modeGen++; regChange(this); }), removeOverlay: methodOp(function (spec) { var overlays = this.state.overlays; for (var i = 0; i < overlays.length; ++i) { var cur = overlays[i].modeSpec; if ( cur == spec || (typeof spec == "string" && cur.name == spec) ) { overlays.splice(i, 1); this.state.modeGen++; regChange(this); return; } } }), indentLine: methodOp(function (n, dir, aggressive) { if (typeof dir != "string" && typeof dir != "number") { if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; } else { dir = dir ? "add" : "subtract"; } } if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); } }), indentSelection: methodOp(function (how) { var ranges = this.doc.sel.ranges, end = -1; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (!range.empty()) { var from = range.from(), to = range.to(); var start = Math.max(end, from.line); end = Math.min( this.lastLine(), to.line - (to.ch ? 0 : 1) ) + 1; for (var j = start; j < end; ++j) { indentLine(this, j, how); } var newRanges = this.doc.sel.ranges; if ( from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0 ) { replaceOneSelection( this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll ); } } else if (range.head.line > end) { indentLine(this, range.head.line, how, true); end = range.head.line; if (i == this.doc.sel.primIndex) { ensureCursorVisible(this); } } } }), // Fetch the parser token for a given character. Useful for hacks // that want to inspect the mode state (say, for completion). getTokenAt: function (pos, precise) { return takeToken(this, pos, precise); }, getLineTokens: function (line, precise) { return takeToken(this, Pos(line), precise, true); }, getTokenTypeAt: function (pos) { pos = clipPos(this.doc, pos); var styles = getLineStyles(this, getLine(this.doc, pos.line)); var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; var type; if (ch == 0) { type = styles[2]; } else { for (;;) { var mid = (before + after) >> 1; if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; } else if (styles[mid * 2 + 1] < ch) { before = mid + 1; } else { type = styles[mid * 2 + 2]; break; } } } var cut = type ? type.indexOf("overlay ") : -1; return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1); }, getModeAt: function (pos) { var mode = this.doc.mode; if (!mode.innerMode) { return mode; } return CodeMirror.innerMode(mode, this.getTokenAt(pos).state) .mode; }, getHelper: function (pos, type) { return this.getHelpers(pos, type)[0]; }, getHelpers: function (pos, type) { var found = []; if (!helpers.hasOwnProperty(type)) { return found; } var help = helpers[type], mode = this.getModeAt(pos); if (typeof mode[type] == "string") { if (help[mode[type]]) { found.push(help[mode[type]]); } } else if (mode[type]) { for (var i = 0; i < mode[type].length; i++) { var val = help[mode[type][i]]; if (val) { found.push(val); } } } else if (mode.helperType && help[mode.helperType]) { found.push(help[mode.helperType]); } else if (help[mode.name]) { found.push(help[mode.name]); } for (var i$1 = 0; i$1 < help._global.length; i$1++) { var cur = help._global[i$1]; if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) { found.push(cur.val); } } return found; }, getStateAfter: function (line, precise) { var doc = this.doc; line = clipLine( doc, line == null ? doc.first + doc.size - 1 : line ); return getContextBefore(this, line + 1, precise).state; }, cursorCoords: function (start, mode) { var pos, range = this.doc.sel.primary(); if (start == null) { pos = range.head; } else if (typeof start == "object") { pos = clipPos(this.doc, start); } else { pos = start ? range.from() : range.to(); } return cursorCoords(this, pos, mode || "page"); }, charCoords: function (pos, mode) { return charCoords(this, clipPos(this.doc, pos), mode || "page"); }, coordsChar: function (coords, mode) { coords = fromCoordSystem(this, coords, mode || "page"); return coordsChar(this, coords.left, coords.top); }, lineAtHeight: function (height, mode) { height = fromCoordSystem( this, { top: height, left: 0 }, mode || "page" ).top; return lineAtHeight(this.doc, height + this.display.viewOffset); }, heightAtLine: function (line, mode, includeWidgets) { var end = false, lineObj; if (typeof line == "number") { var last = this.doc.first + this.doc.size - 1; if (line < this.doc.first) { line = this.doc.first; } else if (line > last) { line = last; end = true; } lineObj = getLine(this.doc, line); } else { lineObj = line; } return ( intoCoordSystem( this, lineObj, { top: 0, left: 0 }, mode || "page", includeWidgets || end ).top + (end ? this.doc.height - heightAtLine(lineObj) : 0) ); }, defaultTextHeight: function () { return textHeight(this.display); }, defaultCharWidth: function () { return charWidth(this.display); }, getViewport: function () { return { from: this.display.viewFrom, to: this.display.viewTo }; }, addWidget: function (pos, node, scroll, vert, horiz) { var display = this.display; pos = cursorCoords(this, clipPos(this.doc, pos)); var top = pos.bottom, left = pos.left; node.style.position = "absolute"; node.setAttribute("cm-ignore-events", "true"); this.display.input.setUneditable(node); display.sizer.appendChild(node); if (vert == "over") { top = pos.top; } else if (vert == "above" || vert == "near") { var vspace = Math.max( display.wrapper.clientHeight, this.doc.height ), hspace = Math.max( display.sizer.clientWidth, display.lineSpace.clientWidth ); // Default to positioning above (if specified and possible); otherwise default to positioning below if ( (vert == "above" || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight ) { top = pos.top - node.offsetHeight; } else if (pos.bottom + node.offsetHeight <= vspace) { top = pos.bottom; } if (left + node.offsetWidth > hspace) { left = hspace - node.offsetWidth; } } node.style.top = top + "px"; node.style.left = node.style.right = ""; if (horiz == "right") { left = display.sizer.clientWidth - node.offsetWidth; node.style.right = "0px"; } else { if (horiz == "left") { left = 0; } else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; } node.style.left = left + "px"; } if (scroll) { scrollIntoView(this, { left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight, }); } }, triggerOnKeyDown: methodOp(onKeyDown), triggerOnKeyPress: methodOp(onKeyPress), triggerOnKeyUp: onKeyUp, triggerOnMouseDown: methodOp(onMouseDown), execCommand: function (cmd) { if (commands.hasOwnProperty(cmd)) { return commands[cmd].call(null, this); } }, triggerElectric: methodOp(function (text) { triggerElectric(this, text); }), findPosH: function (from, amount, unit, visually) { var dir = 1; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { cur = findPosH(this.doc, cur, dir, unit, visually); if (cur.hitSide) { break; } } return cur; }, moveH: methodOp(function (dir, unit) { var this$1 = this; this.extendSelectionsBy(function (range) { if ( this$1.display.shift || this$1.doc.extend || range.empty() ) { return findPosH( this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually ); } else { return dir < 0 ? range.from() : range.to(); } }, sel_move); }), deleteH: methodOp(function (dir, unit) { var sel = this.doc.sel, doc = this.doc; if (sel.somethingSelected()) { doc.replaceSelection("", null, "+delete"); } else { deleteNearSelection(this, function (range) { var other = findPosH(doc, range.head, dir, unit, false); return dir < 0 ? { from: other, to: range.head } : { from: range.head, to: other }; }); } }), findPosV: function (from, amount, unit, goalColumn) { var dir = 1, x = goalColumn; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { var coords = cursorCoords(this, cur, "div"); if (x == null) { x = coords.left; } else { coords.left = x; } cur = findPosV(this, coords, dir, unit); if (cur.hitSide) { break; } } return cur; }, moveV: methodOp(function (dir, unit) { var this$1 = this; var doc = this.doc, goals = []; var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected(); doc.extendSelectionsBy(function (range) { if (collapse) { return dir < 0 ? range.from() : range.to(); } var headPos = cursorCoords(this$1, range.head, "div"); if (range.goalColumn != null) { headPos.left = range.goalColumn; } goals.push(headPos.left); var pos = findPosV(this$1, headPos, dir, unit); if (unit == "page" && range == doc.sel.primary()) { addToScrollTop( this$1, charCoords(this$1, pos, "div").top - headPos.top ); } return pos; }, sel_move); if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++) { doc.sel.ranges[i].goalColumn = goals[i]; } } }), // Find the word at the given position (as returned by coordsChar). findWordAt: function (pos) { var doc = this.doc, line = getLine(doc, pos.line).text; var start = pos.ch, end = pos.ch; if (line) { var helper = this.getHelper(pos, "wordChars"); if ( (pos.sticky == "before" || end == line.length) && start ) { --start; } else { ++end; } var startChar = line.charAt(start); var check = isWordChar(startChar, helper) ? function (ch) { return isWordChar(ch, helper); } : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); } : function (ch) { return !/\s/.test(ch) && !isWordChar(ch); }; while (start > 0 && check(line.charAt(start - 1))) { --start; } while (end < line.length && check(line.charAt(end))) { ++end; } } return new Range(Pos(pos.line, start), Pos(pos.line, end)); }, toggleOverwrite: function (value) { if (value != null && value == this.state.overwrite) { return; } if ((this.state.overwrite = !this.state.overwrite)) { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); } else { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); } signal(this, "overwriteToggle", this, this.state.overwrite); }, hasFocus: function () { return this.display.input.getField() == activeElt(); }, isReadOnly: function () { return !!(this.options.readOnly || this.doc.cantEdit); }, scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), getScrollInfo: function () { var scroller = this.display.scroller; return { left: scroller.scrollLeft, top: scroller.scrollTop, height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, clientHeight: displayHeight(this), clientWidth: displayWidth(this), }; }, scrollIntoView: methodOp(function (range, margin) { if (range == null) { range = { from: this.doc.sel.primary().head, to: null }; if (margin == null) { margin = this.options.cursorScrollMargin; } } else if (typeof range == "number") { range = { from: Pos(range, 0), to: null }; } else if (range.from == null) { range = { from: range, to: null }; } if (!range.to) { range.to = range.from; } range.margin = margin || 0; if (range.from.line != null) { scrollToRange(this, range); } else { scrollToCoordsRange( this, range.from, range.to, range.margin ); } }), setSize: methodOp(function (width, height) { var this$1 = this; var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }; if (width != null) { this.display.wrapper.style.width = interpret(width); } if (height != null) { this.display.wrapper.style.height = interpret(height); } if (this.options.lineWrapping) { clearLineMeasurementCache(this); } var lineNo = this.display.viewFrom; this.doc.iter(lineNo, this.display.viewTo, function (line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break; } } } ++lineNo; }); this.curOp.forceUpdate = true; signal(this, "refresh", this); }), operation: function (f) { return runInOp(this, f); }, startOperation: function () { return startOperation(this); }, endOperation: function () { return endOperation(this); }, refresh: methodOp(function () { var oldHeight = this.display.cachedTextHeight; regChange(this); this.curOp.forceUpdate = true; clearCaches(this); scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop); updateGutterSpace(this.display); if ( oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > 0.5 || this.options.lineWrapping ) { estimateLineHeights(this); } signal(this, "refresh", this); }), swapDoc: methodOp(function (doc) { var old = this.doc; old.cm = null; // Cancel the current text selection if any (#5821) if (this.state.selectingText) { this.state.selectingText(); } attachDoc(this, doc); clearCaches(this); this.display.input.reset(); scrollToCoords(this, doc.scrollLeft, doc.scrollTop); this.curOp.forceScroll = true; signalLater(this, "swapDoc", this, old); return old; }), phrase: function (phraseText) { var phrases = this.options.phrases; return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText; }, getInputField: function () { return this.display.input.getField(); }, getWrapperElement: function () { return this.display.wrapper; }, getScrollerElement: function () { return this.display.scroller; }, getGutterElement: function () { return this.display.gutters; }, }; eventMixin(CodeMirror); CodeMirror.registerHelper = function (type, name, value) { if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = { _global: [] }; } helpers[type][name] = value; }; CodeMirror.registerGlobalHelper = function ( type, name, predicate, value ) { CodeMirror.registerHelper(type, name, value); helpers[type]._global.push({ pred: predicate, val: value }); }; } // Used for horizontal relative motion. Dir is -1 or 1 (left or // right), unit can be "codepoint", "char", "column" (like char, but // doesn't cross line boundaries), "word" (across next word), or // "group" (to the start of next group of word or // non-word-non-whitespace chars). The visually param controls // whether, in right-to-left text, direction 1 means to move towards // the next index in the string, or towards the character to the right // of the current position. The resulting position will have a // hitSide=true property if it reached the end of the document. function findPosH(doc, pos, dir, unit, visually) { var oldPos = pos; var origDir = dir; var lineObj = getLine(doc, pos.line); var lineDir = visually && doc.direction == "rtl" ? -dir : dir; function findNextLine() { var l = pos.line + lineDir; if (l < doc.first || l >= doc.first + doc.size) { return false; } pos = new Pos(l, pos.ch, pos.sticky); return (lineObj = getLine(doc, l)); } function moveOnce(boundToLine) { var next; if (unit == "codepoint") { var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1)); if (isNaN(ch)) { next = null; } else { var astral = dir > 0 ? ch >= 0xd800 && ch < 0xdc00 : ch >= 0xdc00 && ch < 0xdfff; next = new Pos( pos.line, Math.max( 0, Math.min( lineObj.text.length, pos.ch + dir * (astral ? 2 : 1) ) ), -dir ); } } else if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir); } else { next = moveLogically(lineObj, pos, dir); } if (next == null) { if (!boundToLine && findNextLine()) { pos = endOfLine( visually, doc.cm, lineObj, pos.line, lineDir ); } else { return false; } } else { pos = next; } return true; } if (unit == "char" || unit == "codepoint") { moveOnce(); } else if (unit == "column") { moveOnce(true); } else if (unit == "word" || unit == "group") { var sawType = null, group = unit == "group"; var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); for (var first = true; ; first = false) { if (dir < 0 && !moveOnce(!first)) { break; } var cur = lineObj.text.charAt(pos.ch) || "\n"; var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p"; if (group && !first && !type) { type = "s"; } if (sawType && sawType != type) { if (dir < 0) { dir = 1; moveOnce(); pos.sticky = "after"; } break; } if (type) { sawType = type; } if (dir > 0 && !moveOnce(!first)) { break; } } } var result = skipAtomic(doc, pos, oldPos, origDir, true); if (equalCursorPos(oldPos, result)) { result.hitSide = true; } return result; } // For relative vertical movement. Dir may be -1 or 1. Unit can be // "page" or "line". The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosV(cm, pos, dir, unit) { var doc = cm.doc, x = pos.left, y; if (unit == "page") { var pageSize = Math.min( cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight ); var moveAmount = Math.max( pageSize - 0.5 * textHeight(cm.display), 3 ); y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; } else if (unit == "line") { y = dir > 0 ? pos.bottom + 3 : pos.top - 3; } var target; for (;;) { target = coordsChar(cm, x, y); if (!target.outside) { break; } if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; } y += dir * 5; } return target; } // CONTENTEDITABLE INPUT STYLE var ContentEditableInput = function (cm) { this.cm = cm; this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; this.polling = new Delayed(); this.composing = null; this.gracePeriod = false; this.readDOMTimeout = null; }; ContentEditableInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = input.cm; var div = (input.div = display.lineDiv); div.contentEditable = true; disableBrowserMagic( div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize ); function belongsToInput(e) { for (var t = e.target; t; t = t.parentNode) { if (t == div) { return true; } if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break; } } return false; } on(div, "paste", function (e) { if ( !belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm) ) { return; } // IE doesn't fire input events, so we schedule a read for the pasted content in this way if (ie_version <= 11) { setTimeout( operation(cm, function () { return this$1.updateFromDOM(); }), 20 ); } }); on(div, "compositionstart", function (e) { this$1.composing = { data: e.data, done: false }; }); on(div, "compositionupdate", function (e) { if (!this$1.composing) { this$1.composing = { data: e.data, done: false }; } }); on(div, "compositionend", function (e) { if (this$1.composing) { if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); } this$1.composing.done = true; } }); on(div, "touchstart", function () { return input.forceCompositionEnd(); }); on(div, "input", function () { if (!this$1.composing) { this$1.readFromDOMSoon(); } }); function onCopyCut(e) { if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return; } if (cm.somethingSelected()) { setLastCopied({ lineWise: false, text: cm.getSelections() }); if (e.type == "cut") { cm.replaceSelection("", null, "cut"); } } else if (!cm.options.lineWiseCopyCut) { return; } else { var ranges = copyableRanges(cm); setLastCopied({ lineWise: true, text: ranges.text }); if (e.type == "cut") { cm.operation(function () { cm.setSelections(ranges.ranges, 0, sel_dontScroll); cm.replaceSelection("", null, "cut"); }); } } if (e.clipboardData) { e.clipboardData.clearData(); var content = lastCopied.text.join("\n"); // iOS exposes the clipboard API, but seems to discard content inserted into it e.clipboardData.setData("Text", content); if (e.clipboardData.getData("Text") == content) { e.preventDefault(); return; } } // Old-fashioned briefly-focus-a-textarea hack var kludge = hiddenTextarea(), te = kludge.firstChild; cm.display.lineSpace.insertBefore( kludge, cm.display.lineSpace.firstChild ); te.value = lastCopied.text.join("\n"); var hadFocus = activeElt(); selectInput(te); setTimeout(function () { cm.display.lineSpace.removeChild(kludge); hadFocus.focus(); if (hadFocus == div) { input.showPrimarySelection(); } }, 50); } on(div, "copy", onCopyCut); on(div, "cut", onCopyCut); }; ContentEditableInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if (label) { this.div.setAttribute("aria-label", label); } else { this.div.removeAttribute("aria-label"); } }; ContentEditableInput.prototype.prepareSelection = function () { var result = prepareSelection(this.cm, false); result.focus = activeElt() == this.div; return result; }; ContentEditableInput.prototype.showSelection = function (info, takeFocus) { if (!info || !this.cm.display.view.length) { return; } if (info.focus || takeFocus) { this.showPrimarySelection(); } this.showMultipleSelections(info); }; ContentEditableInput.prototype.getSelection = function () { return this.cm.display.wrapper.ownerDocument.getSelection(); }; ContentEditableInput.prototype.showPrimarySelection = function () { var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); var from = prim.from(), to = prim.to(); if ( cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom ) { sel.removeAllRanges(); return; } var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset); if ( curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && cmp(minPos(curAnchor, curFocus), from) == 0 && cmp(maxPos(curAnchor, curFocus), to) == 0 ) { return; } var view = cm.display.view; var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) || { node: view[0].measure.map[2], offset: 0 }; var end = to.line < cm.display.viewTo && posToDOM(cm, to); if (!end) { var measure = view[view.length - 1].measure; var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; end = { node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3], }; } if (!start || !end) { sel.removeAllRanges(); return; } var old = sel.rangeCount && sel.getRangeAt(0), rng; try { rng = range(start.node, start.offset, end.offset, end.node); } catch (e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible if (rng) { if (!gecko && cm.state.focused) { sel.collapse(start.node, start.offset); if (!rng.collapsed) { sel.removeAllRanges(); sel.addRange(rng); } } else { sel.removeAllRanges(); sel.addRange(rng); } if (old && sel.anchorNode == null) { sel.addRange(old); } else if (gecko) { this.startGracePeriod(); } } this.rememberSelection(); }; ContentEditableInput.prototype.startGracePeriod = function () { var this$1 = this; clearTimeout(this.gracePeriod); this.gracePeriod = setTimeout(function () { this$1.gracePeriod = false; if (this$1.selectionChanged()) { this$1.cm.operation(function () { return (this$1.cm.curOp.selectionChanged = true); }); } }, 20); }; ContentEditableInput.prototype.showMultipleSelections = function (info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); }; ContentEditableInput.prototype.rememberSelection = function () { var sel = this.getSelection(); this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; }; ContentEditableInput.prototype.selectionInEditor = function () { var sel = this.getSelection(); if (!sel.rangeCount) { return false; } var node = sel.getRangeAt(0).commonAncestorContainer; return contains(this.div, node); }; ContentEditableInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor") { if (!this.selectionInEditor() || activeElt() != this.div) { this.showSelection(this.prepareSelection(), true); } this.div.focus(); } }; ContentEditableInput.prototype.blur = function () { this.div.blur(); }; ContentEditableInput.prototype.getField = function () { return this.div; }; ContentEditableInput.prototype.supportsTouch = function () { return true; }; ContentEditableInput.prototype.receivedFocus = function () { var this$1 = this; var input = this; if (this.selectionInEditor()) { setTimeout(function () { return this$1.pollSelection(); }, 20); } else { runInOp(this.cm, function () { return (input.cm.curOp.selectionChanged = true); }); } function poll() { if (input.cm.state.focused) { input.pollSelection(); input.polling.set(input.cm.options.pollInterval, poll); } } this.polling.set(this.cm.options.pollInterval, poll); }; ContentEditableInput.prototype.selectionChanged = function () { var sel = this.getSelection(); return ( sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset ); }; ContentEditableInput.prototype.pollSelection = function () { if ( this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged() ) { return; } var sel = this.getSelection(), cm = this.cm; // On Android Chrome (version 56, at least), backspacing into an // uneditable block element will put the cursor in that element, // and then, because it's not editable, hide the virtual keyboard. // Because Android doesn't allow us to actually detect backspace // presses in a sane way, this code checks for when that happens // and simulates a backspace press in this case. if ( android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode) ) { this.cm.triggerOnKeyDown({ type: "keydown", keyCode: 8, preventDefault: Math.abs, }); this.blur(); this.focus(); return; } if (this.composing) { return; } this.rememberSelection(); var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var head = domToPos(cm, sel.focusNode, sel.focusOffset); if (anchor && head) { runInOp(cm, function () { setSelection( cm.doc, simpleSelection(anchor, head), sel_dontScroll ); if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; } }); } }; ContentEditableInput.prototype.pollContent = function () { if (this.readDOMTimeout != null) { clearTimeout(this.readDOMTimeout); this.readDOMTimeout = null; } var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); var from = sel.from(), to = sel.to(); if (from.ch == 0 && from.line > cm.firstLine()) { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); } if ( to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine() ) { to = Pos(to.line + 1, 0); } if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false; } var fromIndex, fromLine, fromNode; if ( from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0 ) { fromLine = lineNo(display.view[0].line); fromNode = display.view[0].node; } else { fromLine = lineNo(display.view[fromIndex].line); fromNode = display.view[fromIndex - 1].node.nextSibling; } var toIndex = findViewIndex(cm, to.line); var toLine, toNode; if (toIndex == display.view.length - 1) { toLine = display.viewTo - 1; toNode = display.lineDiv.lastChild; } else { toLine = lineNo(display.view[toIndex + 1].line) - 1; toNode = display.view[toIndex + 1].node.previousSibling; } if (!fromNode) { return false; } var newText = cm.doc.splitLines( domTextBetween(cm, fromNode, toNode, fromLine, toLine) ); var oldText = getBetween( cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length) ); while (newText.length > 1 && oldText.length > 1) { if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } else { break; } } var cutFront = 0, cutEnd = 0; var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); while ( cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront) ) { ++cutFront; } var newBot = lst(newText), oldBot = lst(oldText); var maxCutEnd = Math.min( newBot.length - (newText.length == 1 ? cutFront : 0), oldBot.length - (oldText.length == 1 ? cutFront : 0) ); while ( cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1) ) { ++cutEnd; } // Try to move start of change to start of selection if ambiguous if ( newText.length == 1 && oldText.length == 1 && fromLine == from.line ) { while ( cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1) ) { cutFront--; cutEnd++; } } newText[newText.length - 1] = newBot .slice(0, newBot.length - cutEnd) .replace(/^\u200b+/, ""); newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, ""); var chFrom = Pos(fromLine, cutFront); var chTo = Pos( toLine, oldText.length ? lst(oldText).length - cutEnd : 0 ); if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { replaceRange(cm.doc, newText, chFrom, chTo, "+input"); return true; } }; ContentEditableInput.prototype.ensurePolled = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.reset = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.forceCompositionEnd = function () { if (!this.composing) { return; } clearTimeout(this.readDOMTimeout); this.composing = null; this.updateFromDOM(); this.div.blur(); this.div.focus(); }; ContentEditableInput.prototype.readFromDOMSoon = function () { var this$1 = this; if (this.readDOMTimeout != null) { return; } this.readDOMTimeout = setTimeout(function () { this$1.readDOMTimeout = null; if (this$1.composing) { if (this$1.composing.done) { this$1.composing = null; } else { return; } } this$1.updateFromDOM(); }, 80); }; ContentEditableInput.prototype.updateFromDOM = function () { var this$1 = this; if (this.cm.isReadOnly() || !this.pollContent()) { runInOp(this.cm, function () { return regChange(this$1.cm); }); } }; ContentEditableInput.prototype.setUneditable = function (node) { node.contentEditable = "false"; }; ContentEditableInput.prototype.onKeyPress = function (e) { if (e.charCode == 0 || this.composing) { return; } e.preventDefault(); if (!this.cm.isReadOnly()) { operation(this.cm, applyTextInput)( this.cm, String.fromCharCode( e.charCode == null ? e.keyCode : e.charCode ), 0 ); } }; ContentEditableInput.prototype.readOnlyChanged = function (val) { this.div.contentEditable = String(val != "nocursor"); }; ContentEditableInput.prototype.onContextMenu = function () {}; ContentEditableInput.prototype.resetPosition = function () {}; ContentEditableInput.prototype.needsContentAttribute = true; function posToDOM(cm, pos) { var view = findViewForLine(cm, pos.line); if (!view || view.hidden) { return null; } var line = getLine(cm.doc, pos.line); var info = mapFromLineView(view, line, pos.line); var order = getOrder(line, cm.doc.direction), side = "left"; if (order) { var partPos = getBidiPartAt(order, pos.ch); side = partPos % 2 ? "right" : "left"; } var result = nodeAndOffsetInLineMap(info.map, pos.ch, side); result.offset = result.collapse == "right" ? result.end : result.start; return result; } function isInGutter(node) { for (var scan = node; scan; scan = scan.parentNode) { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true; } } return false; } function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos; } function domTextBetween(cm, from, to, fromLine, toLine) { var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false; function recognizeMarker(id) { return function (marker) { return marker.id == id; }; } function close() { if (closing) { text += lineSep; if (extraLinebreak) { text += lineSep; } closing = extraLinebreak = false; } } function addText(str) { if (str) { close(); text += str; } } function walk(node) { if (node.nodeType == 1) { var cmText = node.getAttribute("cm-text"); if (cmText) { addText(cmText); return; } var markerID = node.getAttribute("cm-marker"), range; if (markerID) { var found = cm.findMarks( Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID) ); if (found.length && (range = found[0].find(0))) { addText( getBetween(cm.doc, range.from, range.to).join( lineSep ) ); } return; } if (node.getAttribute("contenteditable") == "false") { return; } var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); if ( !/^br$/i.test(node.nodeName) && node.textContent.length == 0 ) { return; } if (isBlock) { close(); } for (var i = 0; i < node.childNodes.length; i++) { walk(node.childNodes[i]); } if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; } if (isBlock) { closing = true; } } else if (node.nodeType == 3) { addText( node.nodeValue .replace(/\u200b/g, "") .replace(/\u00a0/g, " ") ); } } for (;;) { walk(from); if (from == to) { break; } from = from.nextSibling; extraLinebreak = false; } return text; } function domToPos(cm, node, offset) { var lineNode; if (node == cm.display.lineDiv) { lineNode = cm.display.lineDiv.childNodes[offset]; if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true); } node = null; offset = 0; } else { for (lineNode = node; ; lineNode = lineNode.parentNode) { if (!lineNode || lineNode == cm.display.lineDiv) { return null; } if ( lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv ) { break; } } } for (var i = 0; i < cm.display.view.length; i++) { var lineView = cm.display.view[i]; if (lineView.node == lineNode) { return locateNodeInLineView(lineView, node, offset); } } } function locateNodeInLineView(lineView, node, offset) { var wrapper = lineView.text.firstChild, bad = false; if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true); } if (node == wrapper) { bad = true; node = wrapper.childNodes[offset]; offset = 0; if (!node) { var line = lineView.rest ? lst(lineView.rest) : lineView.line; return badPos(Pos(lineNo(line), line.text.length), bad); } } var textNode = node.nodeType == 3 ? node : null, topNode = node; if ( !textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3 ) { textNode = node.firstChild; if (offset) { offset = textNode.nodeValue.length; } } while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; } var measure = lineView.measure, maps = measure.maps; function find(textNode, topNode, offset) { for (var i = -1; i < (maps ? maps.length : 0); i++) { var map = i < 0 ? measure.map : maps[i]; for (var j = 0; j < map.length; j += 3) { var curNode = map[j + 2]; if (curNode == textNode || curNode == topNode) { var line = lineNo( i < 0 ? lineView.line : lineView.rest[i] ); var ch = map[j] + offset; if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)]; } return Pos(line, ch); } } } } var found = find(textNode, topNode, offset); if (found) { return badPos(found, bad); } // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems for ( var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling ) { found = find(after, after.firstChild, 0); if (found) { return badPos(Pos(found.line, found.ch - dist), bad); } else { dist += after.textContent.length; } } for ( var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling ) { found = find(before, before.firstChild, -1); if (found) { return badPos(Pos(found.line, found.ch + dist$1), bad); } else { dist$1 += before.textContent.length; } } } // TEXTAREA INPUT STYLE var TextareaInput = function (cm) { this.cm = cm; // See input.poll and input.reset this.prevInput = ""; // Flag that indicates whether we expect input to appear real soon // now (after some event like 'keypress' or 'input') and are // polling intensively. this.pollingFast = false; // Self-resetting timeout for the poller this.polling = new Delayed(); // Used to work around IE issue with selection being forgotten when focus moves away from textarea this.hasSelection = false; this.composing = null; }; TextareaInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = this.cm; this.createField(display); var te = this.textarea; display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild); // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) if (ios) { te.style.width = "0px"; } on(te, "input", function () { if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; } input.poll(); }); on(te, "paste", function (e) { if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return; } cm.state.pasteIncoming = +new Date(); input.fastPoll(); }); function prepareCopyCut(e) { if (signalDOMEvent(cm, e)) { return; } if (cm.somethingSelected()) { setLastCopied({ lineWise: false, text: cm.getSelections() }); } else if (!cm.options.lineWiseCopyCut) { return; } else { var ranges = copyableRanges(cm); setLastCopied({ lineWise: true, text: ranges.text }); if (e.type == "cut") { cm.setSelections(ranges.ranges, null, sel_dontScroll); } else { input.prevInput = ""; te.value = ranges.text.join("\n"); selectInput(te); } } if (e.type == "cut") { cm.state.cutIncoming = +new Date(); } } on(te, "cut", prepareCopyCut); on(te, "copy", prepareCopyCut); on(display.scroller, "paste", function (e) { if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return; } if (!te.dispatchEvent) { cm.state.pasteIncoming = +new Date(); input.focus(); return; } // Pass the `paste` event to the textarea so it's handled by its event listener. var event = new Event("paste"); event.clipboardData = e.clipboardData; te.dispatchEvent(event); }); // Prevent normal selection in the editor (we handle our own) on(display.lineSpace, "selectstart", function (e) { if (!eventInWidget(display, e)) { e_preventDefault(e); } }); on(te, "compositionstart", function () { var start = cm.getCursor("from"); if (input.composing) { input.composing.range.clear(); } input.composing = { start: start, range: cm.markText(start, cm.getCursor("to"), { className: "CodeMirror-composing", }), }; }); on(te, "compositionend", function () { if (input.composing) { input.poll(); input.composing.range.clear(); input.composing = null; } }); }; TextareaInput.prototype.createField = function (_display) { // Wraps and hides input textarea this.wrapper = hiddenTextarea(); // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild; }; TextareaInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if (label) { this.textarea.setAttribute("aria-label", label); } else { this.textarea.removeAttribute("aria-label"); } }; TextareaInput.prototype.prepareSelection = function () { // Redraw the selection and/or cursor var cm = this.cm, display = cm.display, doc = cm.doc; var result = prepareSelection(cm); // Move the hidden textarea near the cursor to prevent scrolling artifacts if (cm.options.moveInputWithCursor) { var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); result.teTop = Math.max( 0, Math.min( display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top ) ); result.teLeft = Math.max( 0, Math.min( display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left ) ); } return result; }; TextareaInput.prototype.showSelection = function (drawn) { var cm = this.cm, display = cm.display; removeChildrenAndAdd(display.cursorDiv, drawn.cursors); removeChildrenAndAdd(display.selectionDiv, drawn.selection); if (drawn.teTop != null) { this.wrapper.style.top = drawn.teTop + "px"; this.wrapper.style.left = drawn.teLeft + "px"; } }; // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) TextareaInput.prototype.reset = function (typing) { if (this.contextMenuPending || this.composing) { return; } var cm = this.cm; if (cm.somethingSelected()) { this.prevInput = ""; var content = cm.getSelection(); this.textarea.value = content; if (cm.state.focused) { selectInput(this.textarea); } if (ie && ie_version >= 9) { this.hasSelection = content; } } else if (!typing) { this.prevInput = this.textarea.value = ""; if (ie && ie_version >= 9) { this.hasSelection = null; } } }; TextareaInput.prototype.getField = function () { return this.textarea; }; TextareaInput.prototype.supportsTouch = function () { return false; }; TextareaInput.prototype.focus = function () { if ( this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea) ) { try { this.textarea.focus(); } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } }; TextareaInput.prototype.blur = function () { this.textarea.blur(); }; TextareaInput.prototype.resetPosition = function () { this.wrapper.style.top = this.wrapper.style.left = 0; }; TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); }; // Poll for input changes, using the normal rate of polling. This // runs as long as the editor is focused. TextareaInput.prototype.slowPoll = function () { var this$1 = this; if (this.pollingFast) { return; } this.polling.set(this.cm.options.pollInterval, function () { this$1.poll(); if (this$1.cm.state.focused) { this$1.slowPoll(); } }); }; // When an event has just come in that is likely to add or change // something in the input textarea, we poll faster, to ensure that // the change appears on the screen quickly. TextareaInput.prototype.fastPoll = function () { var missed = false, input = this; input.pollingFast = true; function p() { var changed = input.poll(); if (!changed && !missed) { missed = true; input.polling.set(60, p); } else { input.pollingFast = false; input.slowPoll(); } } input.polling.set(20, p); }; // Read input from the textarea, and update the document to match. // When something is selected, it is present in the textarea, and // selected (unless it is huge, in which case a placeholder is // used). When nothing is selected, the cursor sits after previously // seen text (can be empty), which is stored in prevInput (we must // not reset the textarea when typing, because that breaks IME). TextareaInput.prototype.poll = function () { var this$1 = this; var cm = this.cm, input = this.textarea, prevInput = this.prevInput; // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if ( this.contextMenuPending || !cm.state.focused || (hasSelection(input) && !prevInput && !this.composing) || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq ) { return false; } var text = input.value; // If nothing changed, bail. if (text == prevInput && !cm.somethingSelected()) { return false; } // Work around nonsensical selection resetting in IE9/10, and // inexplicable appearance of private area unicode characters on // some key combos in Mac (#2689). if ( (ie && ie_version >= 9 && this.hasSelection === text) || (mac && /[\uf700-\uf7ff]/.test(text)) ) { cm.display.input.reset(); return false; } if (cm.doc.sel == cm.display.selForContextMenu) { var first = text.charCodeAt(0); if (first == 0x200b && !prevInput) { prevInput = "\u200b"; } if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); } } // Find the part of the input that is actually new var same = 0, l = Math.min(prevInput.length, text.length); while ( same < l && prevInput.charCodeAt(same) == text.charCodeAt(same) ) { ++same; } runInOp(cm, function () { applyTextInput( cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null ); // Don't leave long text in the textarea, since it makes further polling slow if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; } else { this$1.prevInput = text; } if (this$1.composing) { this$1.composing.range.clear(); this$1.composing.range = cm.markText( this$1.composing.start, cm.getCursor("to"), { className: "CodeMirror-composing" } ); } }); return true; }; TextareaInput.prototype.ensurePolled = function () { if (this.pollingFast && this.poll()) { this.pollingFast = false; } }; TextareaInput.prototype.onKeyPress = function () { if (ie && ie_version >= 9) { this.hasSelection = null; } this.fastPoll(); }; TextareaInput.prototype.onContextMenu = function (e) { var input = this, cm = input.cm, display = cm.display, te = input.textarea; if (input.contextMenuPending) { input.contextMenuPending(); } var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; if (!pos || presto) { return; } // Opera is difficult. // Reset the current text selection only if the click is done outside of the selection // and 'resetSelectionOnContextMenu' option is true. var reset = cm.options.resetSelectionOnContextMenu; if (reset && cm.doc.sel.contains(pos) == -1) { operation(cm, setSelection)( cm.doc, simpleSelection(pos), sel_dontScroll ); } var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText; var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect(); input.wrapper.style.cssText = "position: static"; te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; var oldScrollY; if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) display.input.focus(); if (webkit) { window.scrollTo(null, oldScrollY); } display.input.reset(); // Adds "Select all" to context menu in FF if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } input.contextMenuPending = rehide; display.selForContextMenu = cm.doc.sel; clearTimeout(display.detectingSelectAll); // Select-all will be greyed out if there's nothing to select, so // this adds a zero-width space so that we can later check whether // it got selected. function prepareSelectAllHack() { if (te.selectionStart != null) { var selected = cm.somethingSelected(); var extval = "\u200b" + (selected ? te.value : ""); te.value = "\u21da"; // Used to catch context-menu undo te.value = extval; input.prevInput = selected ? "" : "\u200b"; te.selectionStart = 1; te.selectionEnd = extval.length; // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } } function rehide() { if (input.contextMenuPending != rehide) { return; } input.contextMenuPending = false; input.wrapper.style.cssText = oldWrapperCSS; te.style.cssText = oldCSS; if (ie && ie_version < 9) { display.scrollbars.setScrollTop( (display.scroller.scrollTop = scrollPos) ); } // Try to detect the user choosing select-all if (te.selectionStart != null) { if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); } var i = 0, poll = function () { if ( display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && te.selectionEnd > 0 && input.prevInput == "\u200b" ) { operation(cm, selectAll)(cm); } else if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500); } else { display.selForContextMenu = null; display.input.reset(); } }; display.detectingSelectAll = setTimeout(poll, 200); } } if (ie && ie_version >= 9) { prepareSelectAllHack(); } if (captureRightClick) { e_stop(e); var mouseup = function () { off(window, "mouseup", mouseup); setTimeout(rehide, 20); }; on(window, "mouseup", mouseup); } else { setTimeout(rehide, 50); } }; TextareaInput.prototype.readOnlyChanged = function (val) { if (!val) { this.reset(); } this.textarea.disabled = val == "nocursor"; this.textarea.readOnly = !!val; }; TextareaInput.prototype.setUneditable = function () {}; TextareaInput.prototype.needsContentAttribute = false; function fromTextArea(textarea, options) { options = options ? copyObj(options) : {}; options.value = textarea.value; if (!options.tabindex && textarea.tabIndex) { options.tabindex = textarea.tabIndex; } if (!options.placeholder && textarea.placeholder) { options.placeholder = textarea.placeholder; } // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if (options.autofocus == null) { var hasFocus = activeElt(); options.autofocus = hasFocus == textarea || (textarea.getAttribute("autofocus") != null && hasFocus == document.body); } function save() { textarea.value = cm.getValue(); } var realSubmit; if (textarea.form) { on(textarea.form, "submit", save); // Deplorable hack to make the submit method do the right thing. if (!options.leaveSubmitMethodAlone) { var form = textarea.form; realSubmit = form.submit; try { var wrappedSubmit = (form.submit = function () { save(); form.submit = realSubmit; form.submit(); form.submit = wrappedSubmit; }); } catch (e) {} } } options.finishInit = function (cm) { cm.save = save; cm.getTextArea = function () { return textarea; }; cm.toTextArea = function () { cm.toTextArea = isNaN; // Prevent this from being ran twice save(); textarea.parentNode.removeChild(cm.getWrapperElement()); textarea.style.display = ""; if (textarea.form) { off(textarea.form, "submit", save); if ( !options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function" ) { textarea.form.submit = realSubmit; } } }; }; textarea.style.display = "none"; var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); }, options); return cm; } function addLegacyProps(CodeMirror) { CodeMirror.off = off; CodeMirror.on = on; CodeMirror.wheelEventPixels = wheelEventPixels; CodeMirror.Doc = Doc; CodeMirror.splitLines = splitLinesAuto; CodeMirror.countColumn = countColumn; CodeMirror.findColumn = findColumn; CodeMirror.isWordChar = isWordCharBasic; CodeMirror.Pass = Pass; CodeMirror.signal = signal; CodeMirror.Line = Line; CodeMirror.changeEnd = changeEnd; CodeMirror.scrollbarModel = scrollbarModel; CodeMirror.Pos = Pos; CodeMirror.cmpPos = cmp; CodeMirror.modes = modes; CodeMirror.mimeModes = mimeModes; CodeMirror.resolveMode = resolveMode; CodeMirror.getMode = getMode; CodeMirror.modeExtensions = modeExtensions; CodeMirror.extendMode = extendMode; CodeMirror.copyState = copyState; CodeMirror.startState = startState; CodeMirror.innerMode = innerMode; CodeMirror.commands = commands; CodeMirror.keyMap = keyMap; CodeMirror.keyName = keyName; CodeMirror.isModifierKey = isModifierKey; CodeMirror.lookupKey = lookupKey; CodeMirror.normalizeKeyMap = normalizeKeyMap; CodeMirror.StringStream = StringStream; CodeMirror.SharedTextMarker = SharedTextMarker; CodeMirror.TextMarker = TextMarker; CodeMirror.LineWidget = LineWidget; CodeMirror.e_preventDefault = e_preventDefault; CodeMirror.e_stopPropagation = e_stopPropagation; CodeMirror.e_stop = e_stop; CodeMirror.addClass = addClass; CodeMirror.contains = contains; CodeMirror.rmClass = rmClass; CodeMirror.keyNames = keyNames; } // EDITOR CONSTRUCTOR defineOptions(CodeMirror); addEditorMethods(CodeMirror); // Set up methods on CodeMirror's prototype to redirect to the editor's document. var dontDelegate = "iter insert remove copy getEditor constructor".split( " " ); for (var prop in Doc.prototype) { if ( Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0 ) { CodeMirror.prototype[prop] = (function (method) { return function () { return method.apply(this.doc, arguments); }; })(Doc.prototype[prop]); } } eventMixin(Doc); CodeMirror.inputStyles = { textarea: TextareaInput, contenteditable: ContentEditableInput, }; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) CodeMirror.defineMode = function (name /*, mode, …*/) { if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; } defineMode.apply(this, arguments); }; CodeMirror.defineMIME = defineMIME; // Minimal default mode. CodeMirror.defineMode("null", function () { return { token: function (stream) { return stream.skipToEnd(); }, }; }); CodeMirror.defineMIME("text/plain", "null"); // EXTENSIONS CodeMirror.defineExtension = function (name, func) { CodeMirror.prototype[name] = func; }; CodeMirror.defineDocExtension = function (name, func) { Doc.prototype[name] = func; }; CodeMirror.fromTextArea = fromTextArea; addLegacyProps(CodeMirror); CodeMirror.version = "5.65.1"; return CodeMirror; });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js
JavaScript
!// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // This is CodeMirror (https://codemirror.net), a code editor // implemented in JavaScript on top of the browser's DOM. // // You can find some technical background for some of the code below // at http://marijnhaverbeke.nl/blog/#cm-internals . function(global, factory) { "object" == typeof exports && "undefined" != typeof module ? module.exports = factory() : "function" == typeof define && define.amd ? define(factory) : (global = global || self).CodeMirror = factory(); }(this, function() { "use strict"; // Kludges for bugs and behavior differences that can't be feature // detected are enabled based on userAgent etc sniffing. var e, optionHandlers, helpers, range, zwspSupported, badBidiRects, measureText, lastClick, lastDoubleClick, userAgent = navigator.userAgent, platform = navigator.platform, gecko = /gecko\/\d/i.test(userAgent), ie_upto10 = /MSIE \d/.test(userAgent), ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent), edge = /Edge\/(\d+)/.exec(userAgent), ie = ie_upto10 || ie_11up || edge, ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]), webkit = !edge && /WebKit\//.test(userAgent), qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent), chrome = !edge && /Chrome\//.test(userAgent), presto = /Opera\//.test(userAgent), safari = /Apple Computer/.test(navigator.vendor), mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent), phantom = /PhantomJS/.test(userAgent), ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2), android = /Android/.test(userAgent), mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent), mac = ios || /Mac/.test(platform), chromeOS = /\bCrOS\b/.test(userAgent), windows = /win/i.test(platform), presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); presto_version && (presto_version = Number(presto_version[1])), presto_version && presto_version >= 15 && (presto = !1, webkit = !0); // Some browsers use the wrong event properties to signal cmd/ctrl on OS X var flipCtrlCmd = mac && (qtwebkit || presto && (null == presto_version || presto_version < 12.11)), captureRightClick = gecko || ie && ie_version >= 9; function classTest(cls) { return RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); } var rmClass = function(node, cls) { var current = node.className, match = classTest(cls).exec(current); if (match) { var after = current.slice(match.index + match[0].length); node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); } }; function removeChildren(e) { for(var count = e.childNodes.length; count > 0; --count)e.removeChild(e.firstChild); return e; } function removeChildrenAndAdd(parent, e) { return removeChildren(parent).appendChild(e); } function elt(tag, content, className, style) { var e = document.createElement(tag); if (className && (e.className = className), style && (e.style.cssText = style), "string" == typeof content) e.appendChild(document.createTextNode(content)); else if (content) for(var i = 0; i < content.length; ++i)e.appendChild(content[i]); return e; } // wrapper for elt, which removes the elt from the accessibility tree function eltP(tag, content, className, style) { var e = elt(tag, content, className, style); return e.setAttribute("role", "presentation"), e; } function contains(parent, child) { if (3 == child.nodeType && // Android browser always returns false when child is a textnode (child = child.parentNode), parent.contains) return parent.contains(child); do if (11 == child.nodeType && (child = child.host), child == parent) return !0; while (child = child.parentNode) } function activeElt() { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. var activeElement; try { activeElement = document.activeElement; } catch (e) { activeElement = document.body || null; } for(; activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement;)activeElement = activeElement.shadowRoot.activeElement; return activeElement; } function addClass(node, cls) { var current = node.className; classTest(cls).test(current) || (node.className += (current ? " " : "") + cls); } function joinClasses(a, b) { for(var as = a.split(" "), i = 0; i < as.length; i++)as[i] && !classTest(as[i]).test(b) && (b += " " + as[i]); return b; } range = document.createRange ? function(node, start, end, endNode) { var r = document.createRange(); return r.setEnd(endNode || node, end), r.setStart(node, start), r; } : function(node, start, end) { var r = document.body.createTextRange(); try { r.moveToElementText(node.parentNode); } catch (e) { return r; } return r.collapse(!0), r.moveEnd("character", end), r.moveStart("character", start), r; }; var selectInput = function(node) { node.select(); }; function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function() { return f.apply(null, args); }; } function copyObj(obj, target, overwrite) { for(var prop in target || (target = {}), obj)obj.hasOwnProperty(prop) && (!1 !== overwrite || !target.hasOwnProperty(prop)) && (target[prop] = obj[prop]); return target; } // Counts the column offset in a string, taking tabs into account. // Used mostly to find indentation. function countColumn(string, end, tabSize, startIndex, startValue) { null == end && -1 == (end = string.search(/[^\s\u00a0]/)) && (end = string.length); for(var i = startIndex || 0, n = startValue || 0;;){ var nextTab = string.indexOf("\t", i); if (nextTab < 0 || nextTab >= end) return n + (end - i); n += nextTab - i, n += tabSize - n % tabSize, i = nextTab + 1; } } ios ? // Mobile Safari apparently has a bug where select() is broken. selectInput = function(node) { node.selectionStart = 0, node.selectionEnd = node.value.length; } : ie && // Suppress mysterious IE10 errors (selectInput = function(node) { try { node.select(); } catch (_e) {} }); var Delayed = function() { this.id = null, this.f = null, this.time = 0, this.handler = bind(this.onTimeout, this); }; function indexOf(array, elt) { for(var i = 0; i < array.length; ++i)if (array[i] == elt) return i; return -1; } Delayed.prototype.onTimeout = function(self1) { self1.id = 0, self1.time <= +new Date() ? self1.f() : setTimeout(self1.handler, self1.time - +new Date()); }, Delayed.prototype.set = function(ms, f) { this.f = f; var time = +new Date() + ms; (!this.id || time < this.time) && (clearTimeout(this.id), this.id = setTimeout(this.handler, ms), this.time = time); }; // Returned or thrown by various protocols to signal 'I'm not // handling this'. var Pass = { toString: function() { return "CodeMirror.Pass"; } }, sel_dontScroll = { scroll: !1 }, sel_mouse = { origin: "*mouse" }, sel_move = { origin: "+move" }; // The inverse of countColumn -- find the offset that corresponds to // a particular column. function findColumn(string, goal, tabSize) { for(var pos = 0, col = 0;;){ var nextTab = string.indexOf("\t", pos); -1 == nextTab && (nextTab = string.length); var skipped = nextTab - pos; if (nextTab == string.length || col + skipped >= goal) return pos + Math.min(skipped, goal - col); if (col += nextTab - pos, col += tabSize - col % tabSize, pos = nextTab + 1, col >= goal) return pos; } } var spaceStrs = [ "" ]; function spaceStr(n) { for(; spaceStrs.length <= n;)spaceStrs.push(lst(spaceStrs) + " "); return spaceStrs[n]; } function lst(arr) { return arr[arr.length - 1]; } function map(array, f) { for(var out = [], i = 0; i < array.length; i++)out[i] = f(array[i], i); return out; } function nothing() {} function createObj(base, props) { var inst; return Object.create ? inst = Object.create(base) : (nothing.prototype = base, inst = new nothing()), props && copyObj(props, inst), inst; } var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function isWordCharBasic(ch) { return /\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); } function isWordChar(ch, helper) { return helper ? !!(helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) || helper.test(ch) : isWordCharBasic(ch); } function isEmpty(obj) { for(var n in obj)if (obj.hasOwnProperty(n) && obj[n]) return !1; return !0; } // Extending unicode characters. A series of a non-extending char + // any number of extending chars is treated as a single unit as far // as editing and measuring is concerned. This is not fully correct, // since some scripts/fonts/browsers also treat other configurations // of code points as a group. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); } // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range. function skipExtendingChars(str, pos, dir) { for(; (dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos));)pos += dir; return pos; } // Returns the value from the range [`from`; `to`] that satisfies // `pred` and is closest to `from`. Assumes that at least `to` // satisfies `pred`. Supports `from` being greater than `to`. function findFirst(pred, from, to) { for(// At any point we are certain `to` satisfies `pred`, don't know // whether `from` does. var dir = from > to ? -1 : 1;;){ if (from == to) return from; var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); if (mid == from) return pred(mid) ? from : to; pred(mid) ? to = mid : from = mid + dir; } } var bidiOther = null; function getBidiPartAt(order, ch, sticky) { var found; bidiOther = null; for(var i = 0; i < order.length; ++i){ var cur = order[i]; if (cur.from < ch && cur.to > ch) return i; cur.to == ch && (cur.from != cur.to && "before" == sticky ? found = i : bidiOther = i), cur.from == ch && (cur.from != cur.to && "before" != sticky ? found = i : bidiOther = i); } return null != found ? found : bidiOther; } // Bidirectional ordering algorithm // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm // that this (partially) implements. // One-char codes used for character types: // L (L): Left-to-Right // R (R): Right-to-Left // r (AL): Right-to-Left Arabic // 1 (EN): European Number // + (ES): European Number Separator // % (ET): European Number Terminator // n (AN): Arabic Number // , (CS): Common Number Separator // m (NSM): Non-Spacing Mark // b (BN): Boundary Neutral // s (B): Paragraph Separator // t (S): Segment Separator // w (WS): Whitespace // N (ON): Other Neutrals // Returns null if characters are ordered as they appear // (left-to-right), or an array of sections ({from, to, level} // objects) in the order in which they occur visually. var bidiOrdering = function() { var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/, isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; function BidiSpan(level, from, to) { this.level = level, this.from = from, this.to = to; } return function(str, direction) { var outerType = "ltr" == direction ? "L" : "R"; if (0 == str.length || "ltr" == direction && !bidiRE.test(str)) return !1; for(var len = str.length, types = [], i = 0; i < len; ++i)types.push((code = str.charCodeAt(i)) <= 0xf7 ? "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(code) : 0x590 <= code && code <= 0x5f4 ? "R" : 0x600 <= code && code <= 0x6f9 ? "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(code - 0x600) : 0x6ee <= code && code <= 0x8ac ? "r" : 0x2000 <= code && code <= 0x200b ? "w" : 0x200c == code ? "b" : "L"); // W1. Examine each non-spacing mark (NSM) in the level run, and // change the type of the NSM to the type of the previous // character. If the NSM is at the start of the level run, it will // get the type of sor. for(var i$1 = 0, prev = outerType; i$1 < len; ++i$1){ var type = types[i$1]; "m" == type ? types[i$1] = prev : prev = type; } // W2. Search backwards from each instance of a European number // until the first strong type (R, L, AL, or sor) is found. If an // AL is found, change the type of the European number to Arabic // number. // W3. Change all ALs to R. for(var i$2 = 0, cur = outerType; i$2 < len; ++i$2){ var type$1 = types[i$2]; "1" == type$1 && "r" == cur ? types[i$2] = "n" : isStrong.test(type$1) && (cur = type$1, "r" == type$1 && (types[i$2] = "R")); } // W4. A single European separator between two European numbers // changes to a European number. A single common separator between // two numbers of the same type changes to that type. for(var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3){ var type$2 = types[i$3]; "+" == type$2 && "1" == prev$1 && "1" == types[i$3 + 1] ? types[i$3] = "1" : "," == type$2 && prev$1 == types[i$3 + 1] && ("1" == prev$1 || "n" == prev$1) && (types[i$3] = prev$1), prev$1 = type$2; } // W5. A sequence of European terminators adjacent to European // numbers changes to all European numbers. // W6. Otherwise, separators and terminators change to Other // Neutral. for(var i$4 = 0; i$4 < len; ++i$4){ var type$3 = types[i$4]; if ("," == type$3) types[i$4] = "N"; else if ("%" == type$3) { var end = void 0; for(end = i$4 + 1; end < len && "%" == types[end]; ++end); for(var replace = i$4 && "!" == types[i$4 - 1] || end < len && "1" == types[end] ? "1" : "N", j = i$4; j < end; ++j)types[j] = replace; i$4 = end - 1; } } // W7. Search backwards from each instance of a European number // until the first strong type (R, L, or sor) is found. If an L is // found, then change the type of the European number to L. for(var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5){ var type$4 = types[i$5]; "L" == cur$1 && "1" == type$4 ? types[i$5] = "L" : isStrong.test(type$4) && (cur$1 = type$4); } // N1. A sequence of neutrals takes the direction of the // surrounding strong text if the text on both sides has the same // direction. European and Arabic numbers act as if they were R in // terms of their influence on neutrals. Start-of-level-run (sor) // and end-of-level-run (eor) are used at level run boundaries. // N2. Any remaining neutrals take the embedding direction. for(var i$6 = 0; i$6 < len; ++i$6)if (isNeutral.test(types[i$6])) { var end$1 = void 0; for(end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1); for(var before = (i$6 ? types[i$6 - 1] : outerType) == "L", replace$1 = before == ((end$1 < len ? types[end$1] : outerType) == "L") ? before ? "L" : "R" : outerType, j$1 = i$6; j$1 < end$1; ++j$1)types[j$1] = replace$1; i$6 = end$1 - 1; } for(var code, m, order = [], i$7 = 0; i$7 < len;)if (countsAsLeft.test(types[i$7])) { var start = i$7; for(++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7); order.push(new BidiSpan(0, start, i$7)); } else { var pos = i$7, at = order.length, isRTL = +("rtl" == direction); for(++i$7; i$7 < len && "L" != types[i$7]; ++i$7); for(var j$2 = pos; j$2 < i$7;)if (countsAsNum.test(types[j$2])) { pos < j$2 && (order.splice(at, 0, new BidiSpan(1, pos, j$2)), at += isRTL); var nstart = j$2; for(++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2); order.splice(at, 0, new BidiSpan(2, nstart, j$2)), at += isRTL, pos = j$2; } else ++j$2; pos < i$7 && order.splice(at, 0, new BidiSpan(1, pos, i$7)); } return "ltr" == direction && (1 == order[0].level && (m = str.match(/^\s+/)) && (order[0].from = m[0].length, order.unshift(new BidiSpan(0, 0, m[0].length))), 1 == lst(order).level && (m = str.match(/\s+$/)) && (lst(order).to -= m[0].length, order.push(new BidiSpan(0, len - m[0].length, len)))), "rtl" == direction ? order.reverse() : order; }; }(); // Get the bidi ordering for the given line (and cache it). Returns // false for lines that are fully left-to-right, and an array of // BidiSpan objects otherwise. function getOrder(line, direction) { var order = line.order; return null == order && (order = line.order = bidiOrdering(line.text, direction)), order; } // EVENT HANDLING // Lightweight event framework. on/off also work on DOM nodes, // registering native DOM handlers. var noHandlers = [], on = function(emitter, type, f) { if (emitter.addEventListener) emitter.addEventListener(type, f, !1); else if (emitter.attachEvent) emitter.attachEvent("on" + type, f); else { var map = emitter._handlers || (emitter._handlers = {}); map[type] = (map[type] || noHandlers).concat(f); } }; function getHandlers(emitter, type) { return emitter._handlers && emitter._handlers[type] || noHandlers; } function off(emitter, type, f) { if (emitter.removeEventListener) emitter.removeEventListener(type, f, !1); else if (emitter.detachEvent) emitter.detachEvent("on" + type, f); else { var map = emitter._handlers, arr = map && map[type]; if (arr) { var index = indexOf(arr, f); index > -1 && (map[type] = arr.slice(0, index).concat(arr.slice(index + 1))); } } } function signal(emitter, type /*, values...*/ ) { var handlers = getHandlers(emitter, type); if (handlers.length) for(var args = Array.prototype.slice.call(arguments, 2), i = 0; i < handlers.length; ++i)handlers[i].apply(null, args); } // The DOM events that CodeMirror handles can be overridden by // registering a (non-DOM) handler on the editor for the event name, // and preventDefault-ing the event in that handler. function signalDOMEvent(cm, e, override) { return "string" == typeof e && (e = { type: e, preventDefault: function() { this.defaultPrevented = !0; } }), signal(cm, override || e.type, cm, e), e_defaultPrevented(e) || e.codemirrorIgnore; } function signalCursorActivity(cm) { var arr = cm._handlers && cm._handlers.cursorActivity; if (arr) for(var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []), i = 0; i < arr.length; ++i)-1 == indexOf(set, arr[i]) && set.push(arr[i]); } function hasHandler(emitter, type) { return getHandlers(emitter, type).length > 0; } // Add on and off methods to a constructor's prototype, to make // registering events on such objects more convenient. function eventMixin(ctor) { ctor.prototype.on = function(type, f) { on(this, type, f); }, ctor.prototype.off = function(type, f) { off(this, type, f); }; } // Due to the fact that we still support jurassic IE versions, some // compatibility wrappers are needed. function e_preventDefault(e) { e.preventDefault ? e.preventDefault() : e.returnValue = !1; } function e_stopPropagation(e) { e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0; } function e_defaultPrevented(e) { return null != e.defaultPrevented ? e.defaultPrevented : !1 == e.returnValue; } function e_stop(e) { e_preventDefault(e), e_stopPropagation(e); } function e_target(e) { return e.target || e.srcElement; } function e_button(e) { var b = e.which; return null == b && (1 & e.button ? b = 1 : 2 & e.button ? b = 3 : 4 & e.button && (b = 2)), mac && e.ctrlKey && 1 == b && (b = 3), b; } // Detect drag-and-drop var dragAndDrop = function() { // There is *some* kind of drag-and-drop support in IE6-8, but I // couldn't get it to work yet. if (ie && ie_version < 9) return !1; var div = elt("div"); return "draggable" in div || "dragDrop" in div; }(), splitLinesAuto = 3 != "\n\nb".split(/\n/).length ? function(string) { for(var pos = 0, result = [], l = string.length; pos <= l;){ var nl = string.indexOf("\n", pos); -1 == nl && (nl = string.length); var line = string.slice(pos, "\r" == string.charAt(nl - 1) ? nl - 1 : nl), rt = line.indexOf("\r"); -1 != rt ? (result.push(line.slice(0, rt)), pos += rt + 1) : (result.push(line), pos = nl + 1); } return result; } : function(string) { return string.split(/\r\n?|\n/); }, hasSelection = window.getSelection ? function(te) { try { return te.selectionStart != te.selectionEnd; } catch (e) { return !1; } } : function(te) { var range; try { range = te.ownerDocument.selection.createRange(); } catch (e) {} return !!range && range.parentElement() == te && 0 != range.compareEndPoints("StartToEnd", range); }, hasCopyEvent = "oncopy" in (e = elt("div")) || (e.setAttribute("oncopy", "return;"), "function" == typeof e.oncopy), badZoomedRects = null, modes = {}, mimeModes = {}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) function defineMode(name, mode) { arguments.length > 2 && (mode.dependencies = Array.prototype.slice.call(arguments, 2)), modes[name] = mode; } // Given a MIME type, a {name, ...options} config object, or a name // string, return a mode config object. function resolveMode(spec) { if ("string" == typeof spec && mimeModes.hasOwnProperty(spec)) spec = mimeModes[spec]; else if (spec && "string" == typeof spec.name && mimeModes.hasOwnProperty(spec.name)) { var found = mimeModes[spec.name]; "string" == typeof found && (found = { name: found }), (spec = createObj(found, spec)).name = found.name; } else if ("string" == typeof spec && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) return resolveMode("application/xml"); else if ("string" == typeof spec && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) return resolveMode("application/json"); return "string" == typeof spec ? { name: spec } : spec || { name: "null" }; } // Given a mode spec (anything that resolveMode accepts), find and // initialize an actual mode object. function getMode(options, spec) { var mfactory = modes[(spec = resolveMode(spec)).name]; if (!mfactory) return getMode(options, "text/plain"); var modeObj = mfactory(options, spec); if (modeExtensions.hasOwnProperty(spec.name)) { var exts = modeExtensions[spec.name]; for(var prop in exts)exts.hasOwnProperty(prop) && (modeObj.hasOwnProperty(prop) && (modeObj["_" + prop] = modeObj[prop]), modeObj[prop] = exts[prop]); } if (modeObj.name = spec.name, spec.helperType && (modeObj.helperType = spec.helperType), spec.modeProps) for(var prop$1 in spec.modeProps)modeObj[prop$1] = spec.modeProps[prop$1]; return modeObj; } // This can be used to attach properties to mode objects from // outside the actual mode definition. var modeExtensions = {}; function copyState(mode, state) { if (!0 === state) return state; if (mode.copyState) return mode.copyState(state); var nstate = {}; for(var n in state){ var val = state[n]; val instanceof Array && (val = val.concat([])), nstate[n] = val; } return nstate; } // Given a mode and a state (for that mode), find the inner mode and // state at the position that the state refers to. function innerMode(mode, state) { for(var info; mode.innerMode && (info = mode.innerMode(state)) && info.mode != mode;)state = info.state, mode = info.mode; return info || { mode: mode, state: state }; } function startState(mode, a1, a2) { return !mode.startState || mode.startState(a1, a2); } // STRING STREAM // Fed to the mode parsers, provides helper functions to make // parsers more succinct. var StringStream = function(string, tabSize, lineOracle) { this.pos = this.start = 0, this.string = string, this.tabSize = tabSize || 8, this.lastColumnPos = this.lastColumnValue = 0, this.lineStart = 0, this.lineOracle = lineOracle; }; // Find the line object corresponding to the given line number. function getLine(doc, n) { if ((n -= doc.first) < 0 || n >= doc.size) throw Error("There is no line " + (n + doc.first) + " in the document."); for(var chunk = doc; !chunk.lines;)for(var i = 0;; ++i){ var child = chunk.children[i], sz = child.chunkSize(); if (n < sz) { chunk = child; break; } n -= sz; } return chunk.lines[n]; } // Get the part of a document between two positions, as an array of // strings. function getBetween(doc, start, end) { var out = [], n = start.line; return doc.iter(start.line, end.line + 1, function(line) { var text = line.text; n == end.line && (text = text.slice(0, end.ch)), n == start.line && (text = text.slice(start.ch)), out.push(text), ++n; }), out; } // Get the lines between from and to, as array of strings. function getLines(doc, from, to) { var out = []; return doc.iter(from, to, function(line) { out.push(line.text); }), out; } // Update the height of a line, propagating the height change // upwards to parent nodes. function updateLineHeight(line, height) { var diff = height - line.height; if (diff) for(var n = line; n; n = n.parent)n.height += diff; } // Given a line object, find its line number by walking up through // its parent links. function lineNo(line) { if (null == line.parent) return null; for(var cur = line.parent, no = indexOf(cur.lines, line), chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent)for(var i = 0; chunk.children[i] != cur; ++i)no += chunk.children[i].chunkSize(); return no + cur.first; } // Find the line at the given vertical position, using the height // information in the document tree. function lineAtHeight(chunk, h) { var n = chunk.first; outer: do { for(var i$1 = 0; i$1 < chunk.children.length; ++i$1){ var child = chunk.children[i$1], ch = child.height; if (h < ch) { chunk = child; continue outer; } h -= ch, n += child.chunkSize(); } return n; }while (!chunk.lines) for(var i = 0; i < chunk.lines.length; ++i){ var lh = chunk.lines[i].height; if (h < lh) break; h -= lh; } return n + i; } function isLine(doc, l) { return l >= doc.first && l < doc.first + doc.size; } function lineNumberFor(options, i) { return String(options.lineNumberFormatter(i + options.firstLineNumber)); } // A Pos instance represents a position within the text. function Pos(line, ch, sticky) { if (void 0 === sticky && (sticky = null), !(this instanceof Pos)) return new Pos(line, ch, sticky); this.line = line, this.ch = ch, this.sticky = sticky; } // Compare two positions, return 0 if they are the same, a negative // number when a is less, and a positive number otherwise. function cmp(a, b) { return a.line - b.line || a.ch - b.ch; } function equalCursorPos(a, b) { return a.sticky == b.sticky && 0 == cmp(a, b); } function copyPos(x) { return Pos(x.line, x.ch); } function maxPos(a, b) { return 0 > cmp(a, b) ? b : a; } function minPos(a, b) { return 0 > cmp(a, b) ? a : b; } // Most of the external API clips given positions to make sure they // actually exist within the document. function clipLine(doc, n) { return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1)); } function clipPos(doc, pos) { if (pos.line < doc.first) return Pos(doc.first, 0); var linelen, ch, last = doc.first + doc.size - 1; return pos.line > last ? Pos(last, getLine(doc, last).text.length) : (linelen = getLine(doc, pos.line).text.length, null == (ch = pos.ch) || ch > linelen ? Pos(pos.line, linelen) : ch < 0 ? Pos(pos.line, 0) : pos); } function clipPosArray(doc, array) { for(var out = [], i = 0; i < array.length; i++)out[i] = clipPos(doc, array[i]); return out; } StringStream.prototype.eol = function() { return this.pos >= this.string.length; }, StringStream.prototype.sol = function() { return this.pos == this.lineStart; }, StringStream.prototype.peek = function() { return this.string.charAt(this.pos) || void 0; }, StringStream.prototype.next = function() { if (this.pos < this.string.length) return this.string.charAt(this.pos++); }, StringStream.prototype.eat = function(match) { var ch = this.string.charAt(this.pos); if ("string" == typeof match ? ch == match : ch && (match.test ? match.test(ch) : match(ch))) return ++this.pos, ch; }, StringStream.prototype.eatWhile = function(match) { for(var start = this.pos; this.eat(match);); return this.pos > start; }, StringStream.prototype.eatSpace = function() { for(var start = this.pos; /[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos; return this.pos > start; }, StringStream.prototype.skipToEnd = function() { this.pos = this.string.length; }, StringStream.prototype.skipTo = function(ch) { var found = this.string.indexOf(ch, this.pos); if (found > -1) return this.pos = found, !0; }, StringStream.prototype.backUp = function(n) { this.pos -= n; }, StringStream.prototype.column = function() { return this.lastColumnPos < this.start && (this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue), this.lastColumnPos = this.start), this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); }, StringStream.prototype.indentation = function() { return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); }, StringStream.prototype.match = function(pattern, consume, caseInsensitive) { if ("string" == typeof pattern) { var cased = function(str) { return caseInsensitive ? str.toLowerCase() : str; }; if (cased(this.string.substr(this.pos, pattern.length)) == cased(pattern)) return !1 !== consume && (this.pos += pattern.length), !0; } else { var match = this.string.slice(this.pos).match(pattern); return match && match.index > 0 ? null : (match && !1 !== consume && (this.pos += match[0].length), match); } }, StringStream.prototype.current = function() { return this.string.slice(this.start, this.pos); }, StringStream.prototype.hideFirstChars = function(n, inner) { this.lineStart += n; try { return inner(); } finally{ this.lineStart -= n; } }, StringStream.prototype.lookAhead = function(n) { var oracle = this.lineOracle; return oracle && oracle.lookAhead(n); }, StringStream.prototype.baseToken = function() { var oracle = this.lineOracle; return oracle && oracle.baseToken(this.pos); }; var SavedContext = function(state, lookAhead) { this.state = state, this.lookAhead = lookAhead; }, Context = function(doc, state, line, lookAhead) { this.state = state, this.doc = doc, this.line = line, this.maxLookAhead = lookAhead || 0, this.baseTokens = null, this.baseTokenPos = 1; }; // Compute a style array (an array starting with a mode generation // -- for invalidation -- followed by pairs of end positions and // style strings), which is used to highlight the tokens on the // line. function highlightLine(cm, line, context, forceToEnd) { // A styles array always starts with a number identifying the // mode/overlays that it is based on (for easy invalidation). var st = [ cm.state.modeGen ], lineClasses = {}; // Compute the base array of styles runMode(cm, line.text, cm.doc.mode, context, function(end, style) { return st.push(end, style); }, lineClasses, forceToEnd); for(var state = context.state, o = 0; o < cm.state.overlays.length; ++o)!function(o) { context.baseTokens = st; var overlay = cm.state.overlays[o], i = 1, at = 0; context.state = !0, runMode(cm, line.text, overlay.mode, context, function(end, style) { // Ensure there's a token end at the current position, and that i points at it for(var start = i; at < end;){ var i_end = st[i]; i_end > end && st.splice(i, 1, end, st[i + 1], i_end), i += 2, at = Math.min(end, i_end); } if (style) { if (overlay.opaque) st.splice(start, i - start, end, "overlay " + style), i = start + 2; else for(; start < i; start += 2){ var cur = st[start + 1]; st[start + 1] = (cur ? cur + " " : "") + "overlay " + style; } } }, lineClasses), context.state = state, context.baseTokens = null, context.baseTokenPos = 1; }(o); return { styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null }; } function getLineStyles(cm, line, updateFrontier) { if (!line.styles || line.styles[0] != cm.state.modeGen) { var context = getContextBefore(cm, lineNo(line)), resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state), result = highlightLine(cm, line, context); resetState && (context.state = resetState), line.stateAfter = context.save(!resetState), line.styles = result.styles, result.classes ? line.styleClasses = result.classes : line.styleClasses && (line.styleClasses = null), updateFrontier === cm.doc.highlightFrontier && (cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier)); } return line.styles; } function getContextBefore(cm, n, precise) { var doc = cm.doc, display = cm.display; if (!doc.mode.startState) return new Context(doc, !0, n); var start = // Finds the line to start with when starting a parse. Tries to // find a line with a stateAfter, so that it can start with a // valid state. If that fails, it returns the line with the // smallest indentation, which tends to need the least context to // parse correctly. function(cm, n, precise) { for(var minindent, minline, doc = cm.doc, lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100), search = n; search > lim; --search){ if (search <= doc.first) return doc.first; var line = getLine(doc, search - 1), after = line.stateAfter; if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier)) return search; var indented = countColumn(line.text, null, cm.options.tabSize); (null == minline || minindent > indented) && (minline = search - 1, minindent = indented); } return minline; }(cm, n, precise), saved = start > doc.first && getLine(doc, start - 1).stateAfter, context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start); return doc.iter(start, n, function(line) { processLine(cm, line.text, context); var pos = context.line; line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null, context.nextLine(); }), precise && (doc.modeFrontier = context.line), context; } // Lightweight form of highlight -- proceed over this line and // update state, but don't save a style array. Used for lines that // aren't currently visible. function processLine(cm, text, context, startAt) { var mode = cm.doc.mode, stream = new StringStream(text, cm.options.tabSize, context); for(stream.start = stream.pos = startAt || 0, "" == text && callBlankLine(mode, context.state); !stream.eol();)readToken(mode, stream, context.state), stream.start = stream.pos; } function callBlankLine(mode, state) { if (mode.blankLine) return mode.blankLine(state); if (mode.innerMode) { var inner = innerMode(mode, state); if (inner.mode.blankLine) return inner.mode.blankLine(inner.state); } } function readToken(mode, stream, state, inner) { for(var i = 0; i < 10; i++){ inner && (inner[0] = innerMode(mode, state).mode); var style = mode.token(stream, state); if (stream.pos > stream.start) return style; } throw Error("Mode " + mode.name + " failed to advance stream."); } Context.prototype.lookAhead = function(n) { var line = this.doc.getLine(this.line + n); return null != line && n > this.maxLookAhead && (this.maxLookAhead = n), line; }, Context.prototype.baseToken = function(n) { if (!this.baseTokens) return null; for(; this.baseTokens[this.baseTokenPos] <= n;)this.baseTokenPos += 2; var type = this.baseTokens[this.baseTokenPos + 1]; return { type: type && type.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - n }; }, Context.prototype.nextLine = function() { this.line++, this.maxLookAhead > 0 && this.maxLookAhead--; }, Context.fromSaved = function(doc, saved, line) { return saved instanceof SavedContext ? new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) : new Context(doc, copyState(doc.mode, saved), line); }, Context.prototype.save = function(copy) { var state = !1 !== copy ? copyState(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state; }; var Token = function(stream, type, state) { this.start = stream.start, this.end = stream.pos, this.string = stream.current(), this.type = type || null, this.state = state; }; // Utility for getTokenAt and getLineTokens function takeToken(cm, pos, precise, asArray) { var style, doc = cm.doc, mode = doc.mode; pos = clipPos(doc, pos); var tokens, line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise), stream = new StringStream(line.text, cm.options.tabSize, context); for(asArray && (tokens = []); (asArray || stream.pos < pos.ch) && !stream.eol();)stream.start = stream.pos, style = readToken(mode, stream, context.state), asArray && tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); return asArray ? tokens : new Token(stream, style, context.state); } function extractLineClasses(type, output) { if (type) for(;;){ var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!lineClass) break; type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); var prop = lineClass[1] ? "bgClass" : "textClass"; null == output[prop] ? output[prop] = lineClass[2] : RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)").test(output[prop]) || (output[prop] += " " + lineClass[2]); } return type; } // Run the given mode's parser over a line, calling f for each token. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { var flattenSpans = mode.flattenSpans; null == flattenSpans && (flattenSpans = cm.options.flattenSpans); var style, curStart = 0, curStyle = null, stream = new StringStream(text, cm.options.tabSize, context), inner = cm.options.addModeClass && [ null ]; for("" == text && extractLineClasses(callBlankLine(mode, context.state), lineClasses); !stream.eol();){ if (stream.pos > cm.options.maxHighlightLength ? (flattenSpans = !1, forceToEnd && processLine(cm, text, context, stream.pos), stream.pos = text.length, style = null) : style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses), inner) { var mName = inner[0].name; mName && (style = "m-" + (style ? mName + " " + style : mName)); } if (!flattenSpans || curStyle != style) { for(; curStart < stream.start;)f(curStart = Math.min(stream.start, curStart + 5000), curStyle); curStyle = style; } stream.start = stream.pos; } for(; curStart < stream.pos;){ // Webkit seems to refuse to render text nodes longer than 57444 // characters, and returns inaccurate measurements in nodes // starting around 5000 chars. var pos = Math.min(stream.pos, curStart + 5000); f(pos, curStyle), curStart = pos; } } // Optimize some code when these features are not used. var sawReadOnlySpans = !1, sawCollapsedSpans = !1; // TEXTMARKER SPANS function MarkedSpan(marker, from, to) { this.marker = marker, this.from = from, this.to = to; } // Search an array of spans for a span matching the given marker. function getMarkedSpanFor(spans, marker) { if (spans) for(var i = 0; i < spans.length; ++i){ var span = spans[i]; if (span.marker == marker) return span; } } // Given a change object, compute the new set of marker spans that // cover the line in which the change took place. Removes spans // entirely within the change, reconnects spans belonging to the // same marker that appear on both sides of the change, and cuts off // spans partially within the change. Returns an array of span // arrays with one element for each line in (after) the change. function stretchSpansOverChange(doc, change) { if (change.full) return null; var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans, oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; if (!oldFirst && !oldLast) return null; var startCh = change.from.ch, endCh = change.to.ch, isInsert = 0 == cmp(change.from, change.to), first = // Used for the algorithm that adjusts markers for a change in the // document. These functions cut an array of spans at a given // character position, returning an array of remaining chunks (or // undefined if nothing remains). function(old, startCh, isInsert) { var nw; if (old) for(var i = 0; i < old.length; ++i){ var span = old[i], marker = span.marker; if (null == span.from || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh) || span.from == startCh && "bookmark" == marker.type && (!isInsert || !span.marker.insertLeft)) { var endsAfter = null == span.to || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); } } return nw; }(oldFirst, startCh, isInsert), last = function(old, endCh, isInsert) { var nw; if (old) for(var i = 0; i < old.length; ++i){ var span = old[i], marker = span.marker; if (null == span.to || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh) || span.from == endCh && "bookmark" == marker.type && (!isInsert || span.marker.insertLeft)) { var startsBefore = null == span.from || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, null == span.to ? null : span.to - endCh)); } } return nw; }(oldLast, endCh, isInsert), sameLine = 1 == change.text.length, offset = lst(change.text).length + (sameLine ? startCh : 0); if (first) // Fix up .to properties of first for(var i = 0; i < first.length; ++i){ var span = first[i]; if (null == span.to) { var found = getMarkedSpanFor(last, span.marker); found ? sameLine && (span.to = null == found.to ? null : found.to + offset) : span.to = startCh; } } if (last) // Fix up .from in last (or move them into first in case of sameLine) for(var i$1 = 0; i$1 < last.length; ++i$1){ var span$1 = last[i$1]; null != span$1.to && (span$1.to += offset), null == span$1.from ? !getMarkedSpanFor(first, span$1.marker) && (span$1.from = offset, sameLine && (first || (first = [])).push(span$1)) : (span$1.from += offset, sameLine && (first || (first = [])).push(span$1)); } first && (first = clearEmptySpans(first)), last && last != first && (last = clearEmptySpans(last)); var newMarkers = [ first ]; if (!sameLine) { // Fill gap with whole-line-spans var gapMarkers, gap = change.text.length - 2; if (gap > 0 && first) for(var i$2 = 0; i$2 < first.length; ++i$2)null == first[i$2].to && (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); for(var i$3 = 0; i$3 < gap; ++i$3)newMarkers.push(gapMarkers); newMarkers.push(last); } return newMarkers; } // Remove spans that are empty and don't have a clearWhenEmpty // option of false. function clearEmptySpans(spans) { for(var i = 0; i < spans.length; ++i){ var span = spans[i]; null != span.from && span.from == span.to && !1 !== span.marker.clearWhenEmpty && spans.splice(i--, 1); } return spans.length ? spans : null; } // Connect or disconnect spans from a line. function detachMarkedSpans(line) { var spans = line.markedSpans; if (spans) { for(var i = 0; i < spans.length; ++i)spans[i].marker.detachLine(line); line.markedSpans = null; } } function attachMarkedSpans(line, spans) { if (spans) { for(var i = 0; i < spans.length; ++i)spans[i].marker.attachLine(line); line.markedSpans = spans; } } // Helpers used when computing which overlapping collapsed span // counts as the larger one. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; } function extraRight(marker) { return +!!marker.inclusiveRight; } // Returns a number indicating which of two overlapping collapsed // spans is larger (and thus includes the other). Falls back to // comparing ids when the spans cover exactly the same range. function compareCollapsedMarkers(a, b) { var lenDiff = a.lines.length - b.lines.length; if (0 != lenDiff) return lenDiff; var aPos = a.find(), bPos = b.find(), fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); return fromCmp ? -fromCmp : cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b) || b.id - a.id; } // Find out whether a line ends or starts in a collapsed span. If // so, return the marker for that span. function collapsedSpanAtSide(line, start) { var found, sps = sawCollapsedSpans && line.markedSpans; if (sps) for(var sp = void 0, i = 0; i < sps.length; ++i)(sp = sps[i]).marker.collapsed && (start ? sp.from : sp.to) == null && (!found || 0 > compareCollapsedMarkers(found, sp.marker)) && (found = sp.marker); return found; } // Test whether there exists a collapsed span that partially // overlaps (covers the start or end, but not both) of a new span. // Such overlap is not allowed. function conflictingCollapsedRange(doc, lineNo, from, to, marker) { var line = getLine(doc, lineNo), sps = sawCollapsedSpans && line.markedSpans; if (sps) for(var i = 0; i < sps.length; ++i){ var sp = sps[i]; if (sp.marker.collapsed) { var found = sp.marker.find(0), fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker), toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); if ((!(fromCmp >= 0) || !(toCmp <= 0)) && (!(fromCmp <= 0) || !(toCmp >= 0)) && (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? 0 >= cmp(found.from, to) : 0 > cmp(found.from, to)))) return !0; } } } // A visual line is a line as drawn on the screen. Folding, for // example, can cause multiple logical lines to appear on the same // visual line. This finds the start of the visual line that the // given line is part of (usually that is the line itself). function visualLine(line) { for(var merged; merged = collapsedSpanAtSide(line, !0);)line = merged.find(-1, !0).line; return line; } // Get the line number of the start of the visual line that the // given line number is part of. function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); return line == vis ? lineN : lineNo(vis); } // Get the line number of the start of the next visual line after // the given line. function visualLineEndNo(doc, lineN) { if (lineN > doc.lastLine()) return lineN; var merged, line = getLine(doc, lineN); if (!lineIsHidden(doc, line)) return lineN; for(; merged = collapsedSpanAtSide(line, !1);)line = merged.find(1, !0).line; return lineNo(line) + 1; } // Compute whether a line is hidden. Lines count as hidden when they // are part of a visual line that starts with another line, or when // they are entirely covered by collapsed, non-widget span. function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for(var sp = void 0, i = 0; i < sps.length; ++i)if ((sp = sps[i]).marker.collapsed && (null == sp.from || !sp.marker.widgetNode && 0 == sp.from && sp.marker.inclusiveLeft && function lineIsHiddenInner(doc, line, span) { if (null == span.to) { var end = span.marker.find(1, !0); return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); } if (span.marker.inclusiveRight && span.to == line.text.length) return !0; for(var sp = void 0, i = 0; i < line.markedSpans.length; ++i)if ((sp = line.markedSpans[i]).marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (null == sp.to || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp)) return !0; }(doc, line, sp))) return !0; } } // Find the height above the given line. function heightAtLine(lineObj) { lineObj = visualLine(lineObj); for(var h = 0, chunk = lineObj.parent, i = 0; i < chunk.lines.length; ++i){ var line = chunk.lines[i]; if (line == lineObj) break; h += line.height; } for(var p = chunk.parent; p; p = (chunk = p).parent)for(var i$1 = 0; i$1 < p.children.length; ++i$1){ var cur = p.children[i$1]; if (cur == chunk) break; h += cur.height; } return h; } // Compute the character length of a line, taking into account // collapsed ranges (see markText) that might hide parts, and join // other lines onto it. function lineLength(line) { if (0 == line.height) return 0; for(var merged, len = line.text.length, cur = line; merged = collapsedSpanAtSide(cur, !0);){ var found = merged.find(0, !0); cur = found.from.line, len += found.from.ch - found.to.ch; } for(cur = line; merged = collapsedSpanAtSide(cur, !1);){ var found$1 = merged.find(0, !0); len -= cur.text.length - found$1.from.ch, len += (cur = found$1.to.line).text.length - found$1.to.ch; } return len; } // Find the longest line in the document. function findMaxLine(cm) { var d = cm.display, doc = cm.doc; d.maxLine = getLine(doc, doc.first), d.maxLineLength = lineLength(d.maxLine), d.maxLineChanged = !0, doc.iter(function(line) { var len = lineLength(line); len > d.maxLineLength && (d.maxLineLength = len, d.maxLine = line); }); } // LINE DATA STRUCTURE // Line objects. These hold state related to a line, including // highlighting info (the styles array). var Line = function(text, markedSpans, estimateHeight) { this.text = text, attachMarkedSpans(this, markedSpans), this.height = estimateHeight ? estimateHeight(this) : 1; }; Line.prototype.lineNo = function() { return lineNo(this); }, eventMixin(Line); // Convert a style as returned by a mode (either null, or a string // containing one or more styles) to a CSS style. This is cached, // and also looks for line-wide styles. var styleToClassCache = {}, styleToClassCacheWithMode = {}; function interpretTokenStyle(style, options) { if (!style || /^\s*$/.test(style)) return null; var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&")); } // Render the DOM representation of the text of a line. Also builds // up a 'line map', which points at the DOM nodes that represent // specific stretches of text, and is used by the measuring code. // The returned object contains the DOM node, this map, and // information about line-wide styles that were set by the mode. function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null), builder = { pre: eltP("pre", [ content ], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, trailingSpace: !1, splitSpaces: cm.getOption("lineWrapping") }; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for(var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++){ var line = i ? lineView.rest[i - 1] : lineView.line, order = void 0; builder.pos = 0, builder.addToken = buildToken, function(measure) { if (null != badBidiRects) return badBidiRects; var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")), r0 = range(txt, 0, 1).getBoundingClientRect(), r1 = range(txt, 1, 2).getBoundingClientRect(); return removeChildren(measure), !!r0 && r0.left != r0.right && (badBidiRects = r1.right - r0.right < 3) // Safari returns null in some cases (#2780) ; }(cm.display.measure) && (order = getOrder(line, cm.doc.direction)) && (builder.addToken = // Work around nonsense dimensions being reported for stretches of // right-to-left text. function(inner, order) { return function(builder, text, style, startStyle, endStyle, css, attributes) { style = style ? style + " cm-force-border" : "cm-force-border"; for(var start = builder.pos, end = start + text.length;;){ for(var part = void 0, i = 0; i < order.length && (!((part = order[i]).to > start) || !(part.from <= start)); i++); if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, css, attributes); inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes), startStyle = null, text = text.slice(part.to - start), start = part.to; } }; }(builder.addToken, order)), builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); // Outputs a number of spans to make up a line, taking highlighting // and marked text into account. (function(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for(var i$1 = 1; i$1 < styles.length; i$1 += 2)builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1 + 1], builder.cm.options)); return; } for(var style, css, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes, len = allText.length, pos = 0, i = 1, text = "", nextChange = 0;;){ if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = css = "", attributes = null, collapsed = null, nextChange = 1 / 0; for(var foundBookmarks = [], endStyles = void 0, j = 0; j < spans.length; ++j){ var sp = spans[j], m = sp.marker; if ("bookmark" == m.type && sp.from == pos && m.widgetNode) foundBookmarks.push(m); else if (sp.from <= pos && (null == sp.to || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { if (null != sp.to && sp.to != pos && nextChange > sp.to && (nextChange = sp.to, spanEndStyle = ""), m.className && (spanStyle += " " + m.className), m.css && (css = (css ? css + ";" : "") + m.css), m.startStyle && sp.from == pos && (spanStartStyle += " " + m.startStyle), m.endStyle && sp.to == nextChange && (endStyles || (endStyles = [])).push(m.endStyle, sp.to), m.title && ((attributes || (attributes = {})).title = m.title), m.attributes) for(var attr in m.attributes)(attributes || (attributes = {}))[attr] = m.attributes[attr]; m.collapsed && (!collapsed || 0 > compareCollapsedMarkers(collapsed.marker, m)) && (collapsed = sp); } else sp.from > pos && nextChange > sp.from && (nextChange = sp.from); } if (endStyles) for(var j$1 = 0; j$1 < endStyles.length; j$1 += 2)endStyles[j$1 + 1] == nextChange && (spanEndStyle += " " + endStyles[j$1]); if (!collapsed || collapsed.from == pos) for(var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); if (collapsed && (collapsed.from || 0) == pos) { if (buildCollapsedSpan(builder, (null == collapsed.to ? len + 1 : collapsed.to) - pos, collapsed.marker, null == collapsed.from), null == collapsed.to) return; collapsed.to == pos && (collapsed = !1); } } if (pos >= len) break; for(var upto = Math.min(len, nextChange);;){ if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes); } if (end >= upto) { text = text.slice(upto - pos), pos = upto; break; } pos = end, spanStartStyle = ""; } text = allText.slice(at, at = styles[i++]), style = interpretTokenStyle(styles[i++], builder.cm.options); } } })(line, builder, getLineStyles(cm, line, allowFrontierUpdate)), line.styleClasses && (line.styleClasses.bgClass && (builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "")), line.styleClasses.textClass && (builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""))), 0 == builder.map.length && builder.map.push(0, 0, builder.content.appendChild(function(measure) { if (null == zwspSupported) { var test = elt("span", "\u200b"); removeChildrenAndAdd(measure, elt("span", [ test, document.createTextNode("x") ])), 0 != measure.firstChild.offsetHeight && (zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8)); } var node = zwspSupported ? elt("span", "\u200b") : elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); return node.setAttribute("cm-text", ""), node; }(cm.display.measure))), 0 == i ? (lineView.measure.map = builder.map, lineView.measure.cache = {}) : ((lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map), (lineView.measure.caches || (lineView.measure.caches = [])).push({})); } // See issue #2901 if (webkit) { var last = builder.content.lastChild; (/\bcm-tab\b/.test(last.className) || last.querySelector && last.querySelector(".cm-tab")) && (builder.content.className = "cm-tab-wrap-hack"); } return signal(cm, "renderLine", cm, lineView.line, builder.pre), builder.pre.className && (builder.textClass = joinClasses(builder.pre.className, builder.textClass || "")), builder; } function defaultSpecialCharPlaceholder(ch) { var token = elt("span", "\u2022", "cm-invalidchar"); return token.title = "\\u" + ch.charCodeAt(0).toString(16), token.setAttribute("aria-label", token.title), token; } // Build up the DOM representation for a single token, and add it to // the line map. Takes care to render special characters separately. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { if (text) { var content, displayText = builder.splitSpaces ? // Change some spaces to NBSP to prevent the browser from collapsing // trailing spaces at the end of a line when rendering text (issue #1362). function(text, trailingBefore) { if (text.length > 1 && !/ /.test(text)) return text; for(var spaceBefore = trailingBefore, result = "", i = 0; i < text.length; i++){ var ch = text.charAt(i); " " == ch && spaceBefore && (i == text.length - 1 || 32 == text.charCodeAt(i + 1)) && (ch = "\u00a0"), result += ch, spaceBefore = " " == ch; } return result; }(text, builder.trailingSpace) : text, special = builder.cm.state.specialChars, mustWrap = !1; if (special.test(text)) { content = document.createDocumentFragment(); for(var pos = 0;;){ special.lastIndex = pos; var m = special.exec(text), skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); ie && ie_version < 9 ? content.appendChild(elt("span", [ txt ])) : content.appendChild(txt), builder.map.push(builder.pos, builder.pos + skipped, txt), builder.col += skipped, builder.pos += skipped; } if (!m) break; pos += skipped + 1; var txt$1 = void 0; if ("\t" == m[0]) { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; (txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))).setAttribute("role", "presentation"), txt$1.setAttribute("cm-text", "\t"), builder.col += tabWidth; } else "\r" == m[0] || "\n" == m[0] ? (txt$1 = content.appendChild(elt("span", "\r" == m[0] ? "\u240d" : "\u2424", "cm-invalidchar"))).setAttribute("cm-text", m[0]) : ((txt$1 = builder.cm.options.specialCharPlaceholder(m[0])).setAttribute("cm-text", m[0]), ie && ie_version < 9 ? content.appendChild(elt("span", [ txt$1 ])) : content.appendChild(txt$1)), builder.col += 1; builder.map.push(builder.pos, builder.pos + 1, txt$1), builder.pos++; } } else builder.col += text.length, content = document.createTextNode(displayText), builder.map.push(builder.pos, builder.pos + text.length, content), ie && ie_version < 9 && (mustWrap = !0), builder.pos += text.length; if (builder.trailingSpace = 32 == displayText.charCodeAt(text.length - 1), style || startStyle || endStyle || mustWrap || css || attributes) { var fullStyle = style || ""; startStyle && (fullStyle += startStyle), endStyle && (fullStyle += endStyle); var token = elt("span", [ content ], fullStyle, css); if (attributes) for(var attr in attributes)attributes.hasOwnProperty(attr) && "style" != attr && "class" != attr && token.setAttribute(attr, attributes[attr]); return builder.content.appendChild(token); } builder.content.appendChild(content); } } function buildCollapsedSpan(builder, size, marker, ignoreWidget) { var widget = !ignoreWidget && marker.widgetNode; widget && builder.map.push(builder.pos, builder.pos + size, widget), !ignoreWidget && builder.cm.display.input.needsContentAttribute && (widget || (widget = builder.content.appendChild(document.createElement("span"))), widget.setAttribute("cm-marker", marker.id)), widget && (builder.cm.display.input.setUneditable(widget), builder.content.appendChild(widget)), builder.pos += size, builder.trailingSpace = !1; } // These objects are used to represent the visible (currently drawn) // part of the document. A LineView may correspond to multiple // logical lines, if those are connected by collapsed ranges. function LineView(doc, line, lineN) { // The starting line this.line = line, // Continuing lines, if any this.rest = // Returns an array of logical lines that continue the visual line // started by the argument, or undefined if there are no such lines. function(line) { for(var merged, lines; merged = collapsedSpanAtSide(line, !1);)line = merged.find(1, !0).line, (lines || (lines = [])).push(line); return lines; }(line), // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1, this.node = this.text = null, this.hidden = lineIsHidden(doc, line); } // Create a range of LineView objects for the given lines. function buildViewArray(cm, from, to) { for(var nextPos, array = [], pos = from; pos < to; pos = nextPos){ var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size, array.push(view); } return array; } var operationGroup = null, orphanDelayedCallbacks = null; // Often, we want to signal events at a point where we are in the // middle of some work, but don't want the handler to start calling // other methods on the editor, which might be in an inconsistent // state or simply not expect any other events to happen. // signalLater looks whether there are any handlers, and schedules // them to be executed when the last operation ends, or, if no // operation is active, when a timeout fires. function signalLater(emitter, type /*, values...*/ ) { var arr = getHandlers(emitter, type); if (arr.length) { var list, args = Array.prototype.slice.call(arguments, 2); operationGroup ? list = operationGroup.delayedCallbacks : orphanDelayedCallbacks ? list = orphanDelayedCallbacks : (list = orphanDelayedCallbacks = [], setTimeout(fireOrphanDelayed, 0)); for(var loop = function(i) { list.push(function() { return arr[i].apply(null, args); }); }, i = 0; i < arr.length; ++i)loop(i); } } function fireOrphanDelayed() { var delayed = orphanDelayedCallbacks; orphanDelayedCallbacks = null; for(var i = 0; i < delayed.length; ++i)delayed[i](); } // When an aspect of a line changes, a string is added to // lineView.changes. This updates the relevant part of the line's // DOM structure. function updateLineForChanges(cm, lineView, lineN, dims) { for(var j = 0; j < lineView.changes.length; j++){ var type = lineView.changes[j]; "text" == type ? // Redraw the line's text. Interacts with the background and text // classes because the mode may output tokens that influence these // classes. function(cm, lineView) { var cls = lineView.text.className, built = getLineContent(cm, lineView); lineView.text == lineView.node && (lineView.node = built.pre), lineView.text.parentNode.replaceChild(built.pre, lineView.text), lineView.text = built.pre, built.bgClass != lineView.bgClass || built.textClass != lineView.textClass ? (lineView.bgClass = built.bgClass, lineView.textClass = built.textClass, updateLineClasses(cm, lineView)) : cls && (lineView.text.className = cls); }(cm, lineView) : "gutter" == type ? updateLineGutter(cm, lineView, lineN, dims) : "class" == type ? updateLineClasses(cm, lineView) : "widget" == type && function(cm, lineView, dims) { lineView.alignable && (lineView.alignable = null); for(var isWidget = classTest("CodeMirror-linewidget"), node = lineView.node.firstChild, next = void 0; node; node = next)next = node.nextSibling, isWidget.test(node.className) && lineView.node.removeChild(node); insertLineWidgets(cm, lineView, dims); }(cm, lineView, dims); } lineView.changes = null; } // Lines with gutter elements, widgets or a background class need to // be wrapped, and have the extra elements added to the wrapper div function ensureLineWrapped(lineView) { return lineView.node == lineView.text && (lineView.node = elt("div", null, null, "position: relative"), lineView.text.parentNode && lineView.text.parentNode.replaceChild(lineView.node, lineView.text), lineView.node.appendChild(lineView.text), ie && ie_version < 8 && (lineView.node.style.zIndex = 2)), lineView.node; } // Wrapper around buildLineContent which will reuse the structure // in display.externalMeasured when possible. function getLineContent(cm, lineView) { var ext = cm.display.externalMeasured; return ext && ext.line == lineView.line ? (cm.display.externalMeasured = null, lineView.measure = ext.measure, ext.built) : buildLineContent(cm, lineView); } function updateLineClasses(cm, lineView) { !function(cm, lineView) { var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; if (cls && (cls += " CodeMirror-linebackground"), lineView.background) cls ? lineView.background.className = cls : (lineView.background.parentNode.removeChild(lineView.background), lineView.background = null); else if (cls) { var wrap = ensureLineWrapped(lineView); lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild), cm.display.input.setUneditable(lineView.background); } }(cm, lineView), lineView.line.wrapClass ? ensureLineWrapped(lineView).className = lineView.line.wrapClass : lineView.node != lineView.text && (lineView.node.className = ""); var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; lineView.text.className = textClass || ""; } function updateLineGutter(cm, lineView, lineN, dims) { if (lineView.gutter && (lineView.node.removeChild(lineView.gutter), lineView.gutter = null), lineView.gutterBackground && (lineView.node.removeChild(lineView.gutterBackground), lineView.gutterBackground = null), lineView.line.gutterClass) { var wrap = ensureLineWrapped(lineView); lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + dims.gutterTotalWidth + "px"), cm.display.input.setUneditable(lineView.gutterBackground), wrap.insertBefore(lineView.gutterBackground, lineView.text); } var markers = lineView.line.gutterMarkers; if (cm.options.lineNumbers || markers) { var wrap$1 = ensureLineWrapped(lineView), gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"); if (gutterWrap.setAttribute("aria-hidden", "true"), cm.display.input.setUneditable(gutterWrap), wrap$1.insertBefore(gutterWrap, lineView.text), lineView.line.gutterClass && (gutterWrap.className += " " + lineView.line.gutterClass), !cm.options.lineNumbers || markers && markers["CodeMirror-linenumbers"] || (lineView.lineNumber = gutterWrap.appendChild(elt("div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + cm.display.lineNumInnerWidth + "px"))), markers) for(var k = 0; k < cm.display.gutterSpecs.length; ++k){ var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id]; found && gutterWrap.appendChild(elt("div", [ found ], "CodeMirror-gutter-elt", "left: " + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); } } } // A lineView may contain multiple logical lines (when merged by // collapsed spans). The widgets for all of them need to be drawn. function insertLineWidgets(cm, lineView, dims) { if (insertLineWidgetsFor(cm, lineView.line, lineView, dims, !0), lineView.rest) for(var i = 0; i < lineView.rest.length; i++)insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, !1); } function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { if (line.widgets) for(var wrap = ensureLineWrapped(lineView), i = 0, ws = line.widgets; i < ws.length; ++i){ var widget = ws[i], node = elt("div", [ widget.node ], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "")); widget.handleMouseEvents || node.setAttribute("cm-ignore-events", "true"), function(widget, node, lineView, dims) { if (widget.noHScroll) { (lineView.alignable || (lineView.alignable = [])).push(node); var width = dims.wrapperWidth; node.style.left = dims.fixedPos + "px", widget.coverGutter || (width -= dims.gutterTotalWidth, node.style.paddingLeft = dims.gutterTotalWidth + "px"), node.style.width = width + "px"; } widget.coverGutter && (node.style.zIndex = 5, node.style.position = "relative", widget.noHScroll || (node.style.marginLeft = -dims.gutterTotalWidth + "px")); }(widget, node, lineView, dims), cm.display.input.setUneditable(node), allowAbove && widget.above ? wrap.insertBefore(node, lineView.gutter || lineView.text) : wrap.appendChild(node), signalLater(widget, "redraw"); } } function widgetHeight(widget) { if (null != widget.height) return widget.height; var cm = widget.doc.cm; if (!cm) return 0; if (!contains(document.body, widget.node)) { var parentStyle = "position: relative;"; widget.coverGutter && (parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"), widget.noHScroll && (parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"), removeChildrenAndAdd(cm.display.measure, elt("div", [ widget.node ], null, parentStyle)); } return widget.height = widget.node.parentNode.offsetHeight; } // Return true when the given mouse event happened in a widget function eventInWidget(display, e) { for(var n = e_target(e); n != display.wrapper; n = n.parentNode)if (!n || 1 == n.nodeType && "true" == n.getAttribute("cm-ignore-events") || n.parentNode == display.sizer && n != display.mover) return !0; } // POSITION MEASUREMENT function paddingTop(display) { return display.lineSpace.offsetTop; } function paddingVert(display) { return display.mover.offsetHeight - display.lineSpace.offsetHeight; } function paddingH(display) { if (display.cachedPaddingH) return display.cachedPaddingH; var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like")), style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle, data = { left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight) }; return isNaN(data.left) || isNaN(data.right) || (display.cachedPaddingH = data), data; } function scrollGap(cm) { return 50 - cm.display.nativeBarWidth; } function displayWidth(cm) { return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth; } function displayHeight(cm) { return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight; } // Find a line map (mapping character offsets to text nodes) and a // measurement cache for the given line number. (A line view might // contain multiple lines when collapsed ranges are present.) function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) return { map: lineView.measure.map, cache: lineView.measure.cache }; if (lineView.rest) { for(var i = 0; i < lineView.rest.length; i++)if (lineView.rest[i] == line) return { map: lineView.measure.maps[i], cache: lineView.measure.caches[i] }; for(var i$1 = 0; i$1 < lineView.rest.length; i$1++)if (lineNo(lineView.rest[i$1]) > lineN) return { map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: !0 }; } } // Find a line view that corresponds to the given line number. function findViewForLine(cm, lineN) { if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) return cm.display.view[findViewIndex(cm, lineN)]; var ext = cm.display.externalMeasured; if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) return ext; } // Measurement can be split in two steps, the set-up work that // applies to the whole line, and the measurement of the actual // character. Functions like coordsChar, that need to do a lot of // measurements in a row, can thus ensure that the set-up work is // only done once. function prepareMeasureForLine(cm, line) { var line1, lineN, view, built, lineN1 = lineNo(line), view1 = findViewForLine(cm, lineN1); view1 && !view1.text ? view1 = null : view1 && view1.changes && (updateLineForChanges(cm, view1, lineN1, getDimensions(cm)), cm.curOp.forceUpdate = !0), view1 || (lineN = lineNo(line1 = visualLine(line1 = line)), (view = cm.display.externalMeasured = new LineView(cm.doc, line1, lineN)).lineN = lineN, built = view.built = buildLineContent(cm, view), view.text = built.pre, removeChildrenAndAdd(cm.display.lineMeasure, built.pre), view1 = view); var info = mapFromLineView(view1, line, lineN1); return { line: line, view: view1, rect: null, map: info.map, cache: info.cache, before: info.before, hasHeights: !1 }; } // Given a prepared measurement object, measures the position of an // actual character (or fetches it from the cache). function measureCharPrepared(cm, prepared, ch, bias, varHeight) { prepared.before && (ch = -1); var found, key = ch + (bias || ""); return prepared.cache.hasOwnProperty(key) ? found = prepared.cache[key] : (prepared.rect || (prepared.rect = prepared.view.text.getBoundingClientRect()), prepared.hasHeights || (// Ensure the lineView.wrapping.heights array is populated. This is // an array of bottom offsets for the lines that make up a drawn // line. When lineWrapping is on, there might be more than one // height. function(cm, lineView, rect) { var wrapping = cm.options.lineWrapping, curWidth = wrapping && displayWidth(cm); if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { var heights = lineView.measure.heights = []; if (wrapping) { lineView.measure.width = curWidth; for(var rects = lineView.text.firstChild.getClientRects(), i = 0; i < rects.length - 1; i++){ var cur = rects[i], next = rects[i + 1]; Math.abs(cur.bottom - next.bottom) > 2 && heights.push((cur.bottom + next.top) / 2 - rect.top); } } heights.push(rect.bottom - rect.top); } }(cm, prepared.view, prepared.rect), prepared.hasHeights = !0), (found = function(cm, prepared, ch, bias) { var rect, rects, place = nodeAndOffsetInLineMap(prepared.map, ch, bias), node = place.node, start = place.start, end = place.end, collapse = place.collapse; if (3 == node.nodeType) { // If it is a text node, use a range to retrieve the coordinates. for(var i$1 = 0; i$1 < 4; i$1++){ // Retry a maximum of 4 times when nonsense rectangles are returned for(; start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start));)--start; for(; place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end));)++end; if ((rect = ie && ie_version < 9 && 0 == start && end == place.coverEnd - place.coverStart ? node.parentNode.getBoundingClientRect() : function(rects, bias) { var rect = nullRect; if ("left" == bias) for(var i = 0; i < rects.length && (rect = rects[i]).left == rect.right; i++); else for(var i$1 = rects.length - 1; i$1 >= 0 && (rect = rects[i$1]).left == rect.right; i$1--); return rect; }(range(node, start, end).getClientRects(), bias)).left || rect.right || 0 == start) break; end = start, start -= 1, collapse = "right"; } ie && ie_version < 11 && (rect = // Work around problem with bounding client rects on ranges being // returned incorrectly when zoomed on IE10 and below. function(measure, rect) { if (!window.screen || null == screen.logicalXDPI || screen.logicalXDPI == screen.deviceXDPI || !function(measure) { if (null != badZoomedRects) return badZoomedRects; var node = removeChildrenAndAdd(measure, elt("span", "x")), normal = node.getBoundingClientRect(), fromRange = range(node, 0, 1).getBoundingClientRect(); return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1; }(measure)) return rect; var scaleX = screen.logicalXDPI / screen.deviceXDPI, scaleY = screen.logicalYDPI / screen.deviceYDPI; return { left: rect.left * scaleX, right: rect.right * scaleX, top: rect.top * scaleY, bottom: rect.bottom * scaleY }; }(cm.display.measure, rect)); } else start > 0 && (collapse = bias = "right"), rect = cm.options.lineWrapping && (rects = node.getClientRects()).length > 1 ? rects["right" == bias ? rects.length - 1 : 0] : node.getBoundingClientRect(); if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { var rSpan = node.parentNode.getClientRects()[0]; rect = rSpan ? { left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom } : nullRect; } for(var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top, mid = (rtop + rbot) / 2, heights = prepared.view.measure.heights, i = 0; i < heights.length - 1 && !(mid < heights[i]); i++); var top = i ? heights[i - 1] : 0, bot = heights[i], result = { left: ("right" == collapse ? rect.right : rect.left) - prepared.rect.left, right: ("left" == collapse ? rect.left : rect.right) - prepared.rect.left, top: top, bottom: bot }; return rect.left || rect.right || (result.bogus = !0), cm.options.singleCursorHeightPerLine || (result.rtop = rtop, result.rbottom = rbot), result; }(cm, prepared, ch, bias)).bogus || (prepared.cache[key] = found)), { left: found.left, right: found.right, top: varHeight ? found.rtop : found.top, bottom: varHeight ? found.rbottom : found.bottom }; } var nullRect = { left: 0, right: 0, top: 0, bottom: 0 }; function nodeAndOffsetInLineMap(map, ch, bias) { // First, search the line map for the text node corresponding to, // or closest to, the target character. for(var node, start, end, collapse, mStart, mEnd, i = 0; i < map.length; i += 3)if (mStart = map[i], mEnd = map[i + 1], ch < mStart ? (start = 0, end = 1, collapse = "left") : ch < mEnd ? end = (start = ch - mStart) + 1 : (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) && (start = (end = mEnd - mStart) - 1, ch >= mEnd && (collapse = "right")), null != start) { if (node = map[i + 2], mStart == mEnd && bias == (node.insertLeft ? "left" : "right") && (collapse = bias), "left" == bias && 0 == start) for(; i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft;)node = map[(i -= 3) + 2], collapse = "left"; if ("right" == bias && start == mEnd - mStart) for(; i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft;)node = map[(i += 3) + 2], collapse = "right"; break; } return { node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd }; } function clearLineMeasurementCacheFor(lineView) { if (lineView.measure && (lineView.measure.cache = {}, lineView.measure.heights = null, lineView.rest)) for(var i = 0; i < lineView.rest.length; i++)lineView.measure.caches[i] = {}; } function clearLineMeasurementCache(cm) { cm.display.externalMeasure = null, removeChildren(cm.display.lineMeasure); for(var i = 0; i < cm.display.view.length; i++)clearLineMeasurementCacheFor(cm.display.view[i]); } function clearCaches(cm) { clearLineMeasurementCache(cm), cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null, cm.options.lineWrapping || (cm.display.maxLineChanged = !0), cm.display.lineNumChars = null; } function pageScrollX() { return(// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // which causes page_Offset and bounding client rects to use // different reference viewports and invalidate our calculations. chrome && android ? -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) : window.pageXOffset || (document.documentElement || document.body).scrollLeft); } function pageScrollY() { return chrome && android ? -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) : window.pageYOffset || (document.documentElement || document.body).scrollTop; } function widgetTopHeight(lineObj) { var widgets = visualLine(lineObj).widgets, height = 0; if (widgets) for(var i = 0; i < widgets.length; ++i)widgets[i].above && (height += widgetHeight(widgets[i])); return height; } // Converts a {top, bottom, left, right} box from line-local // coordinates into another coordinate system. Context may be one of // "line", "div" (display.lineDiv), "local"./null (editor), "window", // or "page". function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { if (!includeWidgets) { var height = widgetTopHeight(lineObj); rect.top += height, rect.bottom += height; } if ("line" == context) return rect; context || (context = "local"); var yOff = heightAtLine(lineObj); if ("local" == context ? yOff += paddingTop(cm.display) : yOff -= cm.display.viewOffset, "page" == context || "window" == context) { var lOff = cm.display.lineSpace.getBoundingClientRect(); yOff += lOff.top + ("window" == context ? 0 : pageScrollY()); var xOff = lOff.left + ("window" == context ? 0 : pageScrollX()); rect.left += xOff, rect.right += xOff; } return rect.top += yOff, rect.bottom += yOff, rect; } // Coverts a box from "div" coords to another coordinate system. // Context may be "window", "page", "div", or "local"./null. function fromCoordSystem(cm, coords, context) { if ("div" == context) return coords; var left = coords.left, top = coords.top; // First move into "page" coordinate system if ("page" == context) left -= pageScrollX(), top -= pageScrollY(); else if ("local" == context || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left, top += localBox.top; } var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); return { left: left - lineSpaceBox.left, top: top - lineSpaceBox.top }; } function charCoords(cm, pos, context, lineObj, bias) { var line, ch; return lineObj || (lineObj = getLine(cm.doc, pos.line)), intoCoordSystem(cm, lineObj, (line = lineObj, ch = pos.ch, measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)), context); } // Returns a box for a given cursor position, which may have an // 'other' property containing the position of the secondary cursor // on a bidi boundary. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1` // and after `char - 1` in writing order of `char - 1` // A cursor Pos(line, char, "after") is on the same visual line as `char` // and before `char` in writing order of `char` // Examples (upper-case letters are RTL, lower-case are LTR): // Pos(0, 1, ...) // before after // ab a|b a|b // aB a|B aB| // Ab |Ab A|b // AB B|A B|A // Every position after the last character on a line is considered to stick // to the last character on the line. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { function get(ch, right) { var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); return right ? m.left = m.right : m.right = m.left, intoCoordSystem(cm, lineObj, m, context); } lineObj = lineObj || getLine(cm.doc, pos.line), preparedMeasure || (preparedMeasure = prepareMeasureForLine(cm, lineObj)); var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; if (ch >= lineObj.text.length ? (ch = lineObj.text.length, sticky = "before") : ch <= 0 && (ch = 0, sticky = "after"), !order) return get("before" == sticky ? ch - 1 : ch, "before" == sticky); function getBidi(ch, partPos, invert) { return get(invert ? ch - 1 : ch, 1 == order[partPos].level != invert); } var partPos = getBidiPartAt(order, ch, sticky), other = bidiOther, val = getBidi(ch, partPos, "before" == sticky); return null != other && (val.other = getBidi(ch, other, "before" != sticky)), val; } // Used to cheaply estimate the coordinates for a position. Used for // intermediate scroll updates. function estimateCoords(cm, pos) { var left = 0; pos = clipPos(cm.doc, pos), cm.options.lineWrapping || (left = charWidth(cm.display) * pos.ch); var lineObj = getLine(cm.doc, pos.line), top = heightAtLine(lineObj) + paddingTop(cm.display); return { left: left, right: left, top: top, bottom: top + lineObj.height }; } // Positions returned by coordsChar contain some extra information. // xRel is the relative x position of the input coordinates compared // to the found position (so xRel > 0 means the coordinates are to // the right of the character position, for example). When outside // is true, that means the coordinates lie outside the line's // vertical range. function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); return pos.xRel = xRel, outside && (pos.outside = outside), pos; } // Compute the character position closest to the given coordinates. // Input must be lineSpace-local ("div" coordinate system). function coordsChar(cm, x, y) { var doc = cm.doc; if ((y += cm.display.viewOffset) < 0) return PosWithInfo(doc.first, 0, null, -1, -1); var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; if (lineN > last) return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1); x < 0 && (x = 0); for(var lineObj = getLine(doc, lineN);;){ var found = function(cm, lineObj, lineNo, x, y) { // Move y into line-local coordinate space y -= heightAtLine(lineObj); var preparedMeasure = prepareMeasureForLine(cm, lineObj), widgetHeight = widgetTopHeight(lineObj), begin = 0, end = lineObj.text.length, ltr = !0, order = getOrder(lineObj, cm.doc.direction); // If the line isn't plain left-to-right text, first figure out // which bidi section the coordinates fall into. if (order) { var part = (cm.options.lineWrapping ? function(cm, lineObj, _lineNo, preparedMeasure, order, x, y) { // In a wrapped line, rtl text on wrapping boundaries can do things // that don't correspond to the ordering in our `order` array at // all, so a binary search doesn't work, and we want to return a // part that only spans one line so that the binary search in // coordsCharInner is safe. As such, we first find the extent of the // wrapped line, and then do a flat search in which we discard any // spans that aren't on the line. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y), begin = ref.begin, end = ref.end; /\s/.test(lineObj.text.charAt(end - 1)) && end--; for(var part = null, closestDist = null, i = 0; i < order.length; i++){ var p = order[i]; if (!(p.from >= end) && !(p.to <= begin)) { var endX = measureCharPrepared(cm, preparedMeasure, 1 != p.level ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right, dist = endX < x ? x - endX + 1e9 : endX - x; (!part || closestDist > dist) && (part = p, closestDist = dist); } } return part || (part = order[order.length - 1]), part.from < begin && (part = { from: begin, to: part.to, level: part.level }), part.to > end && (part = { from: part.from, to: end, level: part.level }), part; } : function(cm, lineObj, lineNo, preparedMeasure, order, x, y) { // Bidi parts are sorted left-to-right, and in a non-line-wrapping // situation, we can take this ordering to correspond to the visual // ordering. This finds the first part whose end is after the given // coordinates. var index = findFirst(function(i) { var part = order[i], ltr = 1 != part.level; return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, !0); }, 0, order.length - 1), part = order[index]; // If this isn't the first part, the part's start is also after // the coordinates, and the coordinates aren't on the same line as // that start, move one part back. if (index > 0) { var ltr = 1 != part.level, start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure); boxIsAfter(start, x, y, !0) && start.top > y && (part = order[index - 1]); } return part; })(cm, lineObj, lineNo, preparedMeasure, order, x, y); // The awkward -1 offsets are needed because findFirst (called // on these below) will treat its first bound as inclusive, // second as exclusive, but we want to actually address the // characters in the part's range begin = (ltr = 1 != part.level) ? part.from : part.to - 1, end = ltr ? part.to : part.from - 1; } // A binary search to find the first character whose bounding box // starts after the coordinates. If we run across any whose box wrap // the coordinates, store that. var baseX, sticky, chAround = null, boxAround = null, ch = findFirst(function(ch) { var box = measureCharPrepared(cm, preparedMeasure, ch); return box.top += widgetHeight, box.bottom += widgetHeight, !!boxIsAfter(box, x, y, !1) && (box.top <= y && box.left <= x && (chAround = ch, boxAround = box), !0); }, begin, end), outside = !1; // If a box around the coordinates was found, use that if (boxAround) { // Distinguish coordinates nearer to the left or right side of the box var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr; ch = chAround + +!atStart, sticky = atStart ? "after" : "before", baseX = atLeft ? boxAround.left : boxAround.right; } else { !ltr && (ch == end || ch == begin) && ch++, // To determine which side to associate with, get the box to the // left of the character and compare it's vertical position to the // coordinates sticky = 0 == ch ? "after" : ch == lineObj.text.length ? "before" : measureCharPrepared(cm, preparedMeasure, ch - +!!ltr).bottom + widgetHeight <= y == ltr ? "after" : "before"; // Now get accurate coordinates for this place, in order to get a // base X position var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure); baseX = coords.left, outside = y < coords.top ? -1 : +(y >= coords.bottom); } return PosWithInfo(lineNo, ch = skipExtendingChars(lineObj.text, ch, 1), sticky, outside, x - baseX); }(cm, lineObj, lineN, x, y), collapsed = function(line, ch) { var found, sps = sawCollapsedSpans && line.markedSpans; if (sps) for(var i = 0; i < sps.length; ++i){ var sp = sps[i]; sp.marker.collapsed && (null == sp.from || sp.from < ch) && (null == sp.to || sp.to > ch) && (!found || 0 > compareCollapsedMarkers(found, sp.marker)) && (found = sp.marker); } return found; }(lineObj, found.ch + +(found.xRel > 0 || found.outside > 0)); if (!collapsed) return found; var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) return rangeEnd; lineObj = getLine(doc, lineN = rangeEnd.line); } } function wrappedLineExtent(cm, lineObj, preparedMeasure, y) { y -= widgetTopHeight(lineObj); var end = lineObj.text.length, begin = findFirst(function(ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0); return end = findFirst(function(ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end), { begin: begin, end: end }; } function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) { preparedMeasure || (preparedMeasure = prepareMeasureForLine(cm, lineObj)); var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top; return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop); } // Returns true if the given side of a box is after the given // coordinates, in top-to-bottom, left-to-right order. function boxIsAfter(box, x, y, left) { return !(box.bottom <= y) && (box.top > y || (left ? box.left : box.right) > x); } // Compute the default text height. function textHeight(display) { if (null != display.cachedTextHeight) return display.cachedTextHeight; if (null == measureText) { measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for(var i = 0; i < 49; ++i)measureText.appendChild(document.createTextNode("x")), measureText.appendChild(elt("br")); measureText.appendChild(document.createTextNode("x")); } removeChildrenAndAdd(display.measure, measureText); var height = measureText.offsetHeight / 50; return height > 3 && (display.cachedTextHeight = height), removeChildren(display.measure), height || 1; } // Compute the default character width. function charWidth(display) { if (null != display.cachedCharWidth) return display.cachedCharWidth; var anchor = elt("span", "xxxxxxxxxx"), pre = elt("pre", [ anchor ], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; return width > 2 && (display.cachedCharWidth = width), width || 10; } // Do a bulk-read of the DOM positions and sizes needed to draw the // view, so that we don't interleave reading and writing to the DOM. function getDimensions(cm) { for(var d = cm.display, left = {}, width = {}, gutterLeft = d.gutters.clientLeft, n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i){ var id = cm.display.gutterSpecs[i].className; left[id] = n.offsetLeft + n.clientLeft + gutterLeft, width[id] = n.clientWidth; } return { fixedPos: compensateForHScroll(d), gutterTotalWidth: d.gutters.offsetWidth, gutterLeft: left, gutterWidth: width, wrapperWidth: d.wrapper.clientWidth }; } // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, // but using getBoundingClientRect to get a sub-pixel-accurate // result. function compensateForHScroll(display) { return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; } // Returns a function that estimates the height of a line, to use as // first approximation until the line becomes visible (and is thus // properly measurable). function estimateHeight(cm) { var th = textHeight(cm.display), wrapping = cm.options.lineWrapping, perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); return function(line) { if (lineIsHidden(cm.doc, line)) return 0; var widgetsHeight = 0; if (line.widgets) for(var i = 0; i < line.widgets.length; i++)line.widgets[i].height && (widgetsHeight += line.widgets[i].height); return wrapping ? widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th : widgetsHeight + th; }; } function estimateLineHeights(cm) { var doc = cm.doc, est = estimateHeight(cm); doc.iter(function(line) { var estHeight = est(line); estHeight != line.height && updateLineHeight(line, estHeight); }); } // Given a mouse event, find the corresponding position. If liberal // is false, it checks whether a gutter or scrollbar was clicked, // and returns null if it was. forRect is used by rectangular // selections, and tries to estimate a character position even for // coordinates beyond the right of the text. function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && "true" == e_target(e).getAttribute("cm-not-content")) return null; var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left, y = e.clientY - space.top; } catch (e$1) { return null; } var line, coords = coordsChar(cm, x, y); if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords; } // Find the view element corresponding to a given line. Return null // when the line isn't visible. function findViewIndex(cm, n) { if (n >= cm.display.viewTo || (n -= cm.display.viewFrom) < 0) return null; for(var view = cm.display.view, i = 0; i < view.length; i++)if ((n -= view[i].size) < 0) return i; } // Updates the display.view data structure for a given change to the // document. From and to are in pre-change coordinates. Lendiff is // the amount of lines added or subtracted by the change. This is // used for changes that span multiple lines, or change the way // lines are divided into visual lines. regLineChange (below) // registers single-line changes. function regChange(cm, from, to, lendiff) { null == from && (from = cm.doc.first), null == to && (to = cm.doc.first + cm.doc.size), lendiff || (lendiff = 0); var display = cm.display; if (lendiff && to < display.viewTo && (null == display.updateLineNumbers || display.updateLineNumbers > from) && (display.updateLineNumbers = from), cm.curOp.viewChanged = !0, from >= display.viewTo) // Change after sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo && resetView(cm); else if (to <= display.viewFrom) // Change before sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom ? resetView(cm) : (display.viewFrom += lendiff, display.viewTo += lendiff); else if (from <= display.viewFrom && to >= display.viewTo) // Full overlap resetView(cm); else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); cut ? (display.view = display.view.slice(cut.index), display.viewFrom = cut.lineN, display.viewTo += lendiff) : resetView(cm); } else if (to >= display.viewTo) { // Bottom overlap var cut$1 = viewCuttingPoint(cm, from, from, -1); cut$1 ? (display.view = display.view.slice(0, cut$1.index), display.viewTo = cut$1.lineN) : resetView(cm); } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1), cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); cutTop && cutBot ? (display.view = display.view.slice(0, cutTop.index).concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)).concat(display.view.slice(cutBot.index)), display.viewTo += lendiff) : resetView(cm); } var ext = display.externalMeasured; ext && (to < ext.lineN ? ext.lineN += lendiff : from < ext.lineN + ext.size && (display.externalMeasured = null)); } // Register a change to a single line. Type must be one of "text", // "gutter", "class", "widget" function regLineChange(cm, line, type) { cm.curOp.viewChanged = !0; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size && (display.externalMeasured = null), !(line < display.viewFrom) && !(line >= display.viewTo)) { var lineView = display.view[findViewIndex(cm, line)]; if (null != lineView.node) { var arr = lineView.changes || (lineView.changes = []); -1 == indexOf(arr, type) && arr.push(type); } } } // Clear the view. function resetView(cm) { cm.display.viewFrom = cm.display.viewTo = cm.doc.first, cm.display.view = [], cm.display.viewOffset = 0; } function viewCuttingPoint(cm, oldN, newN, dir) { var diff, index = findViewIndex(cm, oldN), view = cm.display.view; if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) return { index: index, lineN: newN }; for(var n = cm.display.viewFrom, i = 0; i < index; i++)n += view[i].size; if (n != oldN) { if (dir > 0) { if (index == view.length - 1) return null; diff = n + view[index].size - oldN, index++; } else diff = n - oldN; oldN += diff, newN += diff; } for(; visualLineNo(cm.doc, newN) != newN;){ if (index == (dir < 0 ? 0 : view.length - 1)) return null; newN += dir * view[index - +(dir < 0)].size, index += dir; } return { index: index, lineN: newN }; } // Count the number of lines in the view whose DOM representation is // out of date (or nonexistent). function countDirtyView(cm) { for(var view = cm.display.view, dirty = 0, i = 0; i < view.length; i++){ var lineView = view[i]; !lineView.hidden && (!lineView.node || lineView.changes) && ++dirty; } return dirty; } function updateSelection(cm) { cm.display.input.showSelection(cm.display.input.prepareSelection()); } function prepareSelection(cm, primary) { void 0 === primary && (primary = !0); var doc = cm.doc, result = {}, curFragment = result.cursors = document.createDocumentFragment(), selFragment = result.selection = document.createDocumentFragment(), customCursor = cm.options.$customCursor; customCursor && (primary = !0); for(var i = 0; i < doc.sel.ranges.length; i++)if (primary || i != doc.sel.primIndex) { var range = doc.sel.ranges[i]; if (!(range.from().line >= cm.display.viewTo) && !(range.to().line < cm.display.viewFrom)) { var collapsed = range.empty(); if (customCursor) { var head = customCursor(cm, range); head && drawSelectionCursor(cm, head, curFragment); } else (collapsed || cm.options.showCursorWhenSelecting) && drawSelectionCursor(cm, range.head, curFragment); collapsed || // Draws the given range as a highlighted selection function(cm, range, output) { var display = cm.display, doc = cm.doc, fragment = document.createDocumentFragment(), padding = paddingH(cm.display), leftSide = padding.left, rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right, docLTR = "ltr" == doc.direction; function add(left, top, width, bottom) { top < 0 && (top = 0), top = Math.round(top), bottom = Math.round(bottom), fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (null == width ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")); } function drawForLine(line, fromArg, toArg) { var start, end, lineObj = getLine(doc, line), lineLen = lineObj.text.length; function coords(ch, bias) { return charCoords(cm, Pos(line, ch), "div", lineObj, bias); } function wrapX(pos, dir, side) { var extent = wrappedLineExtentChar(cm, lineObj, null, pos), prop = "ltr" == dir == ("after" == side) ? "left" : "right"; return coords("after" == side ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1), prop)[prop]; } var order = getOrder(lineObj, doc.direction); return !// BIDI HELPERS function(order, from, to, f) { if (!order) return f(from, to, "ltr", 0); for(var found = !1, i = 0; i < order.length; ++i){ var part = order[i]; (part.from < to && part.to > from || from == to && part.to == from) && (f(Math.max(part.from, from), Math.min(part.to, to), 1 == part.level ? "rtl" : "ltr", i), found = !0); } found || f(from, to, "ltr"); }(order, fromArg || 0, null == toArg ? lineLen : toArg, function(from, to, dir, i) { var topLeft, topRight, botLeft, botRight, ltr = "ltr" == dir, fromPos = coords(from, ltr ? "left" : "right"), toPos = coords(to - 1, ltr ? "right" : "left"), openStart = null == fromArg && 0 == from, openEnd = null == toArg && to == lineLen, first = 0 == i, last = !order || i == order.length - 1; if (toPos.top - fromPos.top <= 3) { // Single line var openLeft = (docLTR ? openStart : openEnd) && first, openRight = (docLTR ? openEnd : openStart) && last, left = openLeft ? leftSide : (ltr ? fromPos : toPos).left, right = openRight ? rightSide : (ltr ? toPos : fromPos).right; add(left, fromPos.top, right - left, fromPos.bottom); } else ltr ? (topLeft = docLTR && openStart && first ? leftSide : fromPos.left, topRight = docLTR ? rightSide : wrapX(from, dir, "before"), botLeft = docLTR ? leftSide : wrapX(to, dir, "after"), botRight = docLTR && openEnd && last ? rightSide : toPos.right) : (topLeft = docLTR ? wrapX(from, dir, "before") : leftSide, topRight = !docLTR && openStart && first ? rightSide : fromPos.right, botLeft = !docLTR && openEnd && last ? leftSide : toPos.left, botRight = docLTR ? wrapX(to, dir, "after") : rightSide), add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom), fromPos.bottom < toPos.top && add(leftSide, fromPos.bottom, null, toPos.top), add(botLeft, toPos.top, botRight - botLeft, toPos.bottom); (!start || 0 > cmpCoords(fromPos, start)) && (start = fromPos), 0 > cmpCoords(toPos, start) && (start = toPos), (!end || 0 > cmpCoords(fromPos, end)) && (end = fromPos), 0 > cmpCoords(toPos, end) && (end = toPos); }), { start: start, end: end }; } var sFrom = range.from(), sTo = range.to(); if (sFrom.line == sTo.line) drawForLine(sFrom.line, sFrom.ch, sTo.ch); else { var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line), singleVLine = visualLine(fromLine) == visualLine(toLine), leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end, rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; singleVLine && (leftEnd.top < rightStart.top - 2 ? (add(leftEnd.right, leftEnd.top, null, leftEnd.bottom), add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)) : add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)), leftEnd.bottom < rightStart.top && add(leftSide, leftEnd.bottom, null, rightStart.top); } output.appendChild(fragment); }(cm, range, selFragment); } } return result; } // Draws a cursor for the given range function drawSelectionCursor(cm, head, output) { var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine), cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); if (cursor.style.left = pos.left + "px", cursor.style.top = pos.top + "px", cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px", /\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) { var charPos = charCoords(cm, head, "div", null, null), width = charPos.right - charPos.left; cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px"; } if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); otherCursor.style.display = "", otherCursor.style.left = pos.other.left + "px", otherCursor.style.top = pos.other.top + "px", otherCursor.style.height = (pos.other.bottom - pos.other.top) * 0.85 + "px"; } } function cmpCoords(a, b) { return a.top - b.top || a.left - b.left; } // Cursor-blinking function restartBlink(cm) { if (cm.state.focused) { var display = cm.display; clearInterval(display.blinker); var on = !0; display.cursorDiv.style.visibility = "", cm.options.cursorBlinkRate > 0 ? display.blinker = setInterval(function() { cm.hasFocus() || onBlur(cm), display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; }, cm.options.cursorBlinkRate) : cm.options.cursorBlinkRate < 0 && (display.cursorDiv.style.visibility = "hidden"); } } function ensureFocus(cm) { cm.hasFocus() || (cm.display.input.focus(), cm.state.focused || onFocus(cm)); } function delayBlurEvent(cm) { cm.state.delayingBlurEvent = !0, setTimeout(function() { cm.state.delayingBlurEvent && (cm.state.delayingBlurEvent = !1, cm.state.focused && onBlur(cm)); }, 100); } function onFocus(cm, e) { cm.state.delayingBlurEvent && !cm.state.draggingText && (cm.state.delayingBlurEvent = !1), "nocursor" != cm.options.readOnly && (cm.state.focused || (signal(cm, "focus", cm, e), cm.state.focused = !0, addClass(cm.display.wrapper, "CodeMirror-focused"), !cm.curOp && cm.display.selForContextMenu != cm.doc.sel && (cm.display.input.reset(), webkit && setTimeout(function() { return cm.display.input.reset(!0); }, 20)), cm.display.input.receivedFocus()), restartBlink(cm)); } function onBlur(cm, e) { cm.state.delayingBlurEvent || (cm.state.focused && (signal(cm, "blur", cm, e), cm.state.focused = !1, rmClass(cm.display.wrapper, "CodeMirror-focused")), clearInterval(cm.display.blinker), setTimeout(function() { cm.state.focused || (cm.display.shift = !1); }, 150)); } // Read the actual heights of the rendered lines, and update their // stored heights to match. function updateHeightsInViewport(cm) { for(var display = cm.display, prevBottom = display.lineDiv.offsetTop, viewTop = Math.max(0, display.scroller.getBoundingClientRect().top), oldHeight = display.lineDiv.getBoundingClientRect().top, mustScroll = 0, i = 0; i < display.view.length; i++){ var cur = display.view[i], wrapping = cm.options.lineWrapping, height = void 0, width = 0; if (!cur.hidden) { if (oldHeight += cur.line.height, ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom, prevBottom = bot; } else { var box = cur.node.getBoundingClientRect(); height = box.bottom - box.top, !wrapping && cur.text.firstChild && (width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1); } var diff = cur.line.height - height; if ((diff > 0.005 || diff < -0.005) && (oldHeight < viewTop && (mustScroll -= diff), updateLineHeight(cur.line, height), updateWidgetHeight(cur.line), cur.rest)) for(var j = 0; j < cur.rest.length; j++)updateWidgetHeight(cur.rest[j]); if (width > cm.display.sizerWidth) { var chWidth = Math.ceil(width / charWidth(cm.display)); chWidth > cm.display.maxLineLength && (cm.display.maxLineLength = chWidth, cm.display.maxLine = cur.line, cm.display.maxLineChanged = !0); } } } Math.abs(mustScroll) > 2 && (display.scroller.scrollTop += mustScroll); } // Read and store the height of line widgets associated with the // given line. function updateWidgetHeight(line) { if (line.widgets) for(var i = 0; i < line.widgets.length; ++i){ var w = line.widgets[i], parent = w.node.parentNode; parent && (w.height = parent.offsetHeight); } } // Compute the lines that are visible in a given viewport (defaults // the the current scroll position). viewport may contain top, // height, and ensure (see op.scrollToPos) properties. function visibleLines(display, doc, viewport) { var top = viewport && null != viewport.top ? Math.max(0, viewport.top) : display.scroller.scrollTop; top = Math.floor(top - paddingTop(display)); var bottom = viewport && null != viewport.bottom ? viewport.bottom : top + display.wrapper.clientHeight, from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); // Ensure is a {from: {line, ch}, to: {line, ch}} object, and // forces those lines into the viewport (if possible). if (viewport && viewport.ensure) { var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; ensureFrom < from ? (from = ensureFrom, to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)) : Math.min(ensureTo, doc.lastLine()) >= to && (from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight), to = ensureTo); } return { from: from, to: Math.max(to, from + 1) }; } // Calculate a new scroll position needed to scroll the given // rectangle into view. Returns an object with scrollTop and // scrollLeft properties. When these are undefined, the // vertical/horizontal position does not need to be adjusted. function calculateScrollPos(cm, rect) { var display = cm.display, snapMargin = textHeight(cm.display); rect.top < 0 && (rect.top = 0); var screentop = cm.curOp && null != cm.curOp.scrollTop ? cm.curOp.scrollTop : display.scroller.scrollTop, screen1 = displayHeight(cm), result = {}; rect.bottom - rect.top > screen1 && (rect.bottom = rect.top + screen1); var docBottom = cm.doc.height + paddingVert(display), atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; if (rect.top < screentop) result.scrollTop = atTop ? 0 : rect.top; else if (rect.bottom > screentop + screen1) { var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen1); newTop != screentop && (result.scrollTop = newTop); } var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth, screenleft = cm.curOp && null != cm.curOp.scrollLeft ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace, screenw = displayWidth(cm) - display.gutters.offsetWidth, tooWide = rect.right - rect.left > screenw; return tooWide && (rect.right = rect.left + screenw), rect.left < 10 ? result.scrollLeft = 0 : rect.left < screenleft ? result.scrollLeft = Math.max(0, rect.left + gutterSpace - 10 * !tooWide) : rect.right > screenw + screenleft - 3 && (result.scrollLeft = rect.right + 10 * !tooWide - screenw), result; } // Store a relative adjustment to the scroll position in the current // operation (to be applied when the operation finishes). function addToScrollTop(cm, top) { null != top && (resolveScrollToPos(cm), cm.curOp.scrollTop = (null == cm.curOp.scrollTop ? cm.doc.scrollTop : cm.curOp.scrollTop) + top); } // Make sure that at the end of the operation the current cursor is // shown. function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(); cm.curOp.scrollToPos = { from: cur, to: cur, margin: cm.options.cursorScrollMargin }; } function scrollToCoords(cm, x, y) { (null != x || null != y) && resolveScrollToPos(cm), null != x && (cm.curOp.scrollLeft = x), null != y && (cm.curOp.scrollTop = y); } // When an operation has its scrollToPos property set, and another // scroll action is applied before the end of the operation, this // 'simulates' scrolling that position into view in a cheap way, so // that the effect of intermediate scroll commands is not ignored. function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); scrollToCoordsRange(cm, from, to, range.margin); } } function scrollToCoordsRange(cm, from, to, margin) { var sPos = calculateScrollPos(cm, { left: Math.min(from.left, to.left), top: Math.min(from.top, to.top) - margin, right: Math.max(from.right, to.right), bottom: Math.max(from.bottom, to.bottom) + margin }); scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop); } // Sync the scrollable area and scrollbars, ensure the viewport // covers the visible area. function updateScrollTop(cm, val) { 2 > Math.abs(cm.doc.scrollTop - val) || (gecko || updateDisplaySimple(cm, { top: val }), setScrollTop(cm, val, !0), gecko && updateDisplaySimple(cm), startWorker(cm, 100)); } function setScrollTop(cm, val, forceScroll) { val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)), (cm.display.scroller.scrollTop != val || forceScroll) && (cm.doc.scrollTop = val, cm.display.scrollbars.setScrollTop(val), cm.display.scroller.scrollTop != val && (cm.display.scroller.scrollTop = val)); } // Sync scroller and scrollbar, ensure the gutter elements are // aligned. function setScrollLeft(cm, val, isScroller, forceScroll) { val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)), ((isScroller ? val != cm.doc.scrollLeft : !(2 > Math.abs(cm.doc.scrollLeft - val))) || forceScroll) && (cm.doc.scrollLeft = val, alignHorizontally(cm), cm.display.scroller.scrollLeft != val && (cm.display.scroller.scrollLeft = val), cm.display.scrollbars.setScrollLeft(val)); } // SCROLLBARS // Prepare DOM reads needed to update the scrollbars. Done in one // shot to minimize update/measure roundtrips. function measureForScrollbars(cm) { var d = cm.display, gutterW = d.gutters.offsetWidth, docH = Math.round(cm.doc.height + paddingVert(cm.display)); return { clientHeight: d.scroller.clientHeight, viewHeight: d.wrapper.clientHeight, scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, viewWidth: d.wrapper.clientWidth, barLeft: cm.options.fixedGutter ? gutterW : 0, docHeight: docH, scrollHeight: docH + scrollGap(cm) + d.barHeight, nativeBarWidth: d.nativeBarWidth, gutterWidth: gutterW }; } var NativeScrollbars = function(place, scroll, cm) { this.cm = cm; var vert = this.vert = elt("div", [ elt("div", null, null, "min-width: 1px") ], "CodeMirror-vscrollbar"), horiz = this.horiz = elt("div", [ elt("div", null, null, "height: 100%; min-height: 1px") ], "CodeMirror-hscrollbar"); vert.tabIndex = horiz.tabIndex = -1, place(vert), place(horiz), on(vert, "scroll", function() { vert.clientHeight && scroll(vert.scrollTop, "vertical"); }), on(horiz, "scroll", function() { horiz.clientWidth && scroll(horiz.scrollLeft, "horizontal"); }), this.checkedZeroWidth = !1, ie && ie_version < 8 && (this.horiz.style.minHeight = this.vert.style.minWidth = "18px"); }; NativeScrollbars.prototype.update = function(measure) { var needsH = measure.scrollWidth > measure.clientWidth + 1, needsV = measure.scrollHeight > measure.clientHeight + 1, sWidth = measure.nativeBarWidth; if (needsV) { this.vert.style.display = "block", this.vert.style.bottom = needsH ? sWidth + "px" : "0"; var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); // A bug in IE8 can cause this value to be negative, so guard it. this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; } else this.vert.scrollTop = 0, this.vert.style.display = "", this.vert.firstChild.style.height = "0"; if (needsH) { this.horiz.style.display = "block", this.horiz.style.right = needsV ? sWidth + "px" : "0", this.horiz.style.left = measure.barLeft + "px"; var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); this.horiz.firstChild.style.width = Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; } else this.horiz.style.display = "", this.horiz.firstChild.style.width = "0"; return !this.checkedZeroWidth && measure.clientHeight > 0 && (0 == sWidth && this.zeroWidthHack(), this.checkedZeroWidth = !0), { right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0 }; }, NativeScrollbars.prototype.setScrollLeft = function(pos) { this.horiz.scrollLeft != pos && (this.horiz.scrollLeft = pos), this.disableHoriz && this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }, NativeScrollbars.prototype.setScrollTop = function(pos) { this.vert.scrollTop != pos && (this.vert.scrollTop = pos), this.disableVert && this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }, NativeScrollbars.prototype.zeroWidthHack = function() { this.horiz.style.height = this.vert.style.width = mac && !mac_geMountainLion ? "12px" : "18px", this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none", this.disableHoriz = new Delayed(), this.disableVert = new Delayed(); }, NativeScrollbars.prototype.enableZeroWidthBar = function(bar, delay, type) { bar.style.pointerEvents = "auto", delay.set(1000, function maybeDisable() { // To find out whether the scrollbar is still visible, we // check whether the element under the pixel in the bottom // right corner of the scrollbar box is the scrollbar box // itself (when the bar is still visible) or its filler child // (when the bar is hidden). If it is still visible, we keep // it enabled, if it's hidden, we disable pointer events. var box = bar.getBoundingClientRect(); ("vert" == type ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1)) != bar ? bar.style.pointerEvents = "none" : delay.set(1000, maybeDisable); }); }, NativeScrollbars.prototype.clear = function() { var parent = this.horiz.parentNode; parent.removeChild(this.horiz), parent.removeChild(this.vert); }; var NullScrollbars = function() {}; function updateScrollbars(cm, measure) { measure || (measure = measureForScrollbars(cm)); var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; updateScrollbarsInner(cm, measure); for(var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++)startWidth != cm.display.barWidth && cm.options.lineWrapping && updateHeightsInViewport(cm), updateScrollbarsInner(cm, measureForScrollbars(cm)), startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; } // Re-synchronize the fake scrollbars with the actual size of the // content. function updateScrollbarsInner(cm, measure) { var d = cm.display, sizes = d.scrollbars.update(measure); d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px", d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px", d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent", sizes.right && sizes.bottom ? (d.scrollbarFiller.style.display = "block", d.scrollbarFiller.style.height = sizes.bottom + "px", d.scrollbarFiller.style.width = sizes.right + "px") : d.scrollbarFiller.style.display = "", sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter ? (d.gutterFiller.style.display = "block", d.gutterFiller.style.height = sizes.bottom + "px", d.gutterFiller.style.width = measure.gutterWidth + "px") : d.gutterFiller.style.display = ""; } NullScrollbars.prototype.update = function() { return { bottom: 0, right: 0 }; }, NullScrollbars.prototype.setScrollLeft = function() {}, NullScrollbars.prototype.setScrollTop = function() {}, NullScrollbars.prototype.clear = function() {}; var scrollbarModel = { native: NativeScrollbars, null: NullScrollbars }; function initScrollbars(cm) { cm.display.scrollbars && (cm.display.scrollbars.clear(), cm.display.scrollbars.addClass && rmClass(cm.display.wrapper, cm.display.scrollbars.addClass)), cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function(node) { cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller), // Prevent clicks in the scrollbars from killing focus on(node, "mousedown", function() { cm.state.focused && setTimeout(function() { return cm.display.input.focus(); }, 0); }), node.setAttribute("cm-not-content", "true"); }, function(pos, axis) { "horizontal" == axis ? setScrollLeft(cm, pos) : updateScrollTop(cm, pos); }, cm), cm.display.scrollbars.addClass && addClass(cm.display.wrapper, cm.display.scrollbars.addClass); } // Operations are used to wrap a series of changes to the editor // state in such a way that each change won't have to update the // cursor and display (which would be awkward, slow, and // error-prone). Instead, display updates are batched and then all // combined and executed at once. var nextOpId = 0; // Start a new operation. function startOperation(cm) { var op; cm.curOp = { cm: cm, viewChanged: !1, startHeight: cm.doc.height, forceUpdate: !1, updateInput: 0, typing: !1, changeObjs: null, cursorActivityHandlers: null, cursorActivityCalled: 0, selectionChanged: !1, updateMaxLine: !1, scrollLeft: null, scrollTop: null, scrollToPos: null, focus: !1, id: ++nextOpId, markArrays: null }, op = cm.curOp, operationGroup ? operationGroup.ops.push(op) : op.ownsGroup = operationGroup = { ops: [ op ], delayedCallbacks: [] }; } // Finish an operation, updating the display and signalling delayed events function endOperation(cm) { var op = cm.curOp; op && function(op, endCb) { var group = op.ownsGroup; if (group) try { !function(group) { // Calls delayed callbacks and cursorActivity handlers until no // new ones appear var callbacks = group.delayedCallbacks, i = 0; do { for(; i < callbacks.length; i++)callbacks[i].call(null); for(var j = 0; j < group.ops.length; j++){ var op = group.ops[j]; if (op.cursorActivityHandlers) for(; op.cursorActivityCalled < op.cursorActivityHandlers.length;)op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }while (i < callbacks.length) }(group); } finally{ operationGroup = null, endCb(group); } }(op, function(group) { for(var i = 0; i < group.ops.length; i++)group.ops[i].cm.curOp = null; !// The DOM updates done when an operation finishes are batched so // that the minimum number of relayouts are required. function(group) { for(var op, ops = group.ops, i = 0; i < ops.length; i++ // Read DOM )!function(op) { var cm = op.cm, display = cm.display; (function(cm) { var display = cm.display; !display.scrollbarsClipped && display.scroller.offsetWidth && (display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth, display.heightForcer.style.height = scrollGap(cm) + "px", display.sizer.style.marginBottom = -display.nativeBarWidth + "px", display.sizer.style.borderRightWidth = scrollGap(cm) + "px", display.scrollbarsClipped = !0); })(cm), op.updateMaxLine && findMaxLine(cm), op.mustUpdate = op.viewChanged || op.forceUpdate || null != op.scrollTop || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping, op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && { top: op.scrollTop, ensure: op.scrollToPos }, op.forceUpdate); }(ops[i]); for(var i$1 = 0; i$1 < ops.length; i$1++ // Write DOM (maybe) )(op = ops[i$1]).updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); for(var i$2 = 0; i$2 < ops.length; i$2++ // Read DOM )!function(op) { var line, ch, cm = op.cm, display = cm.display; op.updatedDisplay && updateHeightsInViewport(cm), op.barMeasure = measureForScrollbars(cm), display.maxLineChanged && !cm.options.lineWrapping && (op.adjustWidthTo = (line = display.maxLine, ch = display.maxLine.text.length, measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, void 0)).left + 3, cm.display.sizerWidth = op.adjustWidthTo, op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth), op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm))), (op.updatedDisplay || op.selectionChanged) && (op.preparedSelection = display.input.prepareSelection()); }(ops[i$2]); for(var i$3 = 0; i$3 < ops.length; i$3++ // Write DOM (maybe) )!function(op) { var cm = op.cm; null != op.adjustWidthTo && (cm.display.sizer.style.minWidth = op.adjustWidthTo + "px", op.maxScrollLeft < cm.doc.scrollLeft && setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), !0), cm.display.maxLineChanged = !1); var takeFocus = op.focus && op.focus == activeElt(); op.preparedSelection && cm.display.input.showSelection(op.preparedSelection, takeFocus), (op.updatedDisplay || op.startHeight != cm.doc.height) && updateScrollbars(cm, op.barMeasure), op.updatedDisplay && setDocumentHeight(cm, op.barMeasure), op.selectionChanged && restartBlink(cm), cm.state.focused && op.updateInput && cm.display.input.reset(op.typing), takeFocus && ensureFocus(op.cm); }(ops[i$3]); for(var i$4 = 0; i$4 < ops.length; i$4++ // Read DOM )!function(op) { var cm = op.cm, display = cm.display, doc = cm.doc; // If we need to scroll a specific position into view, do so. if (op.updatedDisplay && postUpdateDisplay(cm, op.update), null != display.wheelStartX && (null != op.scrollTop || null != op.scrollLeft || op.scrollToPos) && (display.wheelStartX = display.wheelStartY = null), null != op.scrollTop && setScrollTop(cm, op.scrollTop, op.forceScroll), null != op.scrollLeft && setScrollLeft(cm, op.scrollLeft, !0, !0), op.scrollToPos) { var rect = // Scroll a given position into view (immediately), verifying that // it actually became visible (as line heights are accurately // measured, the position of something may 'drift' during drawing). function(cm, pos, end, margin) { null == margin && (margin = 0), cm.options.lineWrapping || pos != end || (// Set pos and end to the cursor positions around the character pos sticks to // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch // If pos == Pos(_, 0, "before"), pos and end are unchanged end = "before" == pos.sticky ? Pos(pos.line, pos.ch + 1, "before") : pos, pos = pos.ch ? Pos(pos.line, "before" == pos.sticky ? pos.ch - 1 : pos.ch, "after") : pos); for(var rect, limit = 0; limit < 5; limit++){ var changed = !1, coords = cursorCoords(cm, pos), endCoords = end && end != pos ? cursorCoords(cm, end) : coords, scrollPos = calculateScrollPos(cm, rect = { left: Math.min(coords.left, endCoords.left), top: Math.min(coords.top, endCoords.top) - margin, right: Math.max(coords.left, endCoords.left), bottom: Math.max(coords.bottom, endCoords.bottom) + margin }), startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (null != scrollPos.scrollTop && (updateScrollTop(cm, scrollPos.scrollTop), Math.abs(cm.doc.scrollTop - startTop) > 1 && (changed = !0)), null != scrollPos.scrollLeft && (setScrollLeft(cm, scrollPos.scrollLeft), Math.abs(cm.doc.scrollLeft - startLeft) > 1 && (changed = !0)), !changed) break; } return rect; }(cm, clipPos(doc, op.scrollToPos.from), clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); !// SCROLLING THINGS INTO VIEW // If an editor sits on the top or bottom of the window, partially // scrolled out of view, this ensures that the cursor is visible. function(cm, rect) { if (!signalDOMEvent(cm, "scrollCursorIntoView")) { var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (rect.top + box.top < 0 ? doScroll = !0 : rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight) && (doScroll = !1), null != doScroll && !phantom) { var scrollNode = elt("div", "\u200b", null, "position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + rect.left + "px; width: " + Math.max(2, rect.right - rect.left) + "px;"); cm.display.lineSpace.appendChild(scrollNode), scrollNode.scrollIntoView(doScroll), cm.display.lineSpace.removeChild(scrollNode); } } }(cm, rect); } // Fire events for markers that are hidden/unidden by editing or // undoing var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; if (hidden) for(var i = 0; i < hidden.length; ++i)hidden[i].lines.length || signal(hidden[i], "hide"); if (unhidden) for(var i$1 = 0; i$1 < unhidden.length; ++i$1)unhidden[i$1].lines.length && signal(unhidden[i$1], "unhide"); display.wrapper.offsetHeight && (doc.scrollTop = cm.display.scroller.scrollTop), op.changeObjs && signal(cm, "changes", cm, op.changeObjs), op.update && op.update.finish(); }(ops[i$4]); }(group); }); } // Run the given function in an operation function runInOp(cm, f) { if (cm.curOp) return f(); startOperation(cm); try { return f(); } finally{ endOperation(cm); } } // Wraps a function in an operation. Returns the wrapped function. function operation(cm, f) { return function() { if (cm.curOp) return f.apply(cm, arguments); startOperation(cm); try { return f.apply(cm, arguments); } finally{ endOperation(cm); } }; } // Used to add methods to editor and doc instances, wrapping them in // operations. function methodOp(f) { return function() { if (this.curOp) return f.apply(this, arguments); startOperation(this); try { return f.apply(this, arguments); } finally{ endOperation(this); } }; } function docMethodOp(f) { return function() { var cm = this.cm; if (!cm || cm.curOp) return f.apply(this, arguments); startOperation(cm); try { return f.apply(this, arguments); } finally{ endOperation(cm); } }; } // HIGHLIGHT WORKER function startWorker(cm, time) { cm.doc.highlightFrontier < cm.display.viewTo && cm.state.highlight.set(time, bind(highlightWorker, cm)); } function highlightWorker(cm) { var doc = cm.doc; if (!(doc.highlightFrontier >= cm.display.viewTo)) { var end = +new Date() + cm.options.workTime, context = getContextBefore(cm, doc.highlightFrontier), changedLines = []; doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) { if (context.line >= cm.display.viewFrom) { // Visible var oldStyles = line.styles, resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null, highlighted = highlightLine(cm, line, context, !0); resetState && (context.state = resetState), line.styles = highlighted.styles; var oldCls = line.styleClasses, newCls = highlighted.classes; newCls ? line.styleClasses = newCls : oldCls && (line.styleClasses = null); for(var ischange = !oldStyles || oldStyles.length != line.styles.length || oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass), i = 0; !ischange && i < oldStyles.length; ++i)ischange = oldStyles[i] != line.styles[i]; ischange && changedLines.push(context.line), line.stateAfter = context.save(), context.nextLine(); } else line.text.length <= cm.options.maxHighlightLength && processLine(cm, line.text, context), line.stateAfter = context.line % 5 == 0 ? context.save() : null, context.nextLine(); if (+new Date() > end) return startWorker(cm, cm.options.workDelay), !0; }), doc.highlightFrontier = context.line, doc.modeFrontier = Math.max(doc.modeFrontier, context.line), changedLines.length && runInOp(cm, function() { for(var i = 0; i < changedLines.length; i++)regLineChange(cm, changedLines[i], "text"); }); } } // DISPLAY DRAWING var DisplayUpdate = function(cm, viewport, force) { var display = cm.display; this.viewport = viewport, // Store some values that we'll need later (but don't want to force a relayout for) this.visible = visibleLines(display, cm.doc, viewport), this.editorIsHidden = !display.wrapper.offsetWidth, this.wrapperHeight = display.wrapper.clientHeight, this.wrapperWidth = display.wrapper.clientWidth, this.oldDisplayWidth = displayWidth(cm), this.force = force, this.dims = getDimensions(cm), this.events = []; }; // Does the actual updating of the line display. Bails out // (returning false) when there is nothing to be done and forced is // false. function updateDisplayIfNeeded(cm, update) { var from, to, display, display1 = cm.display, doc = cm.doc; if (update.editorIsHidden) return resetView(cm), !1; // Bail out if the visible area is already rendered and nothing changed. if (!update.force && update.visible.from >= display1.viewFrom && update.visible.to <= display1.viewTo && (null == display1.updateLineNumbers || display1.updateLineNumbers >= display1.viewTo) && display1.renderedView == display1.view && 0 == countDirtyView(cm)) return !1; maybeUpdateLineNumberWidth(cm) && (resetView(cm), update.dims = getDimensions(cm)); // Compute a suitable new viewport (from & to) var end = doc.first + doc.size, from1 = Math.max(update.visible.from - cm.options.viewportMargin, doc.first), to1 = Math.min(end, update.visible.to + cm.options.viewportMargin); display1.viewFrom < from1 && from1 - display1.viewFrom < 20 && (from1 = Math.max(doc.first, display1.viewFrom)), display1.viewTo > to1 && display1.viewTo - to1 < 20 && (to1 = Math.min(end, display1.viewTo)), sawCollapsedSpans && (from1 = visualLineNo(cm.doc, from1), to1 = visualLineEndNo(cm.doc, to1)); var different = from1 != display1.viewFrom || to1 != display1.viewTo || display1.lastWrapHeight != update.wrapperHeight || display1.lastWrapWidth != update.wrapperWidth; from = from1, to = to1, 0 == (display = cm.display).view.length || from >= display.viewTo || to <= display.viewFrom ? (display.view = buildViewArray(cm, from, to), display.viewFrom = from) : (display.viewFrom > from ? display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view) : display.viewFrom < from && (display.view = display.view.slice(findViewIndex(cm, from))), display.viewFrom = from, display.viewTo < to ? display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)) : display.viewTo > to && (display.view = display.view.slice(0, findViewIndex(cm, to)))), display.viewTo = to, display1.viewOffset = heightAtLine(getLine(cm.doc, display1.viewFrom)), // Position the mover div to align with the current scroll position cm.display.mover.style.top = display1.viewOffset + "px"; var toUpdate = countDirtyView(cm); if (!different && 0 == toUpdate && !update.force && display1.renderedView == display1.view && (null == display1.updateLineNumbers || display1.updateLineNumbers >= display1.viewTo)) return !1; // For big changes, we hide the enclosing element during the // update, since that speeds up the operations on most browsers. var selSnapshot = function(cm) { if (cm.hasFocus()) return null; var active = activeElt(); if (!active || !contains(cm.display.lineDiv, active)) return null; var result = { activeElt: active }; if (window.getSelection) { var sel = window.getSelection(); sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode) && (result.anchorNode = sel.anchorNode, result.anchorOffset = sel.anchorOffset, result.focusNode = sel.focusNode, result.focusOffset = sel.focusOffset); } return result; }(cm); return toUpdate > 4 && (display1.lineDiv.style.display = "none"), // Sync the actual display DOM structure with display.view, removing // nodes for lines that are no longer in view, and creating the ones // that are not there yet, and updating the ones that are out of // date. function(cm, updateNumbersFrom, dims) { var display = cm.display, lineNumbers = cm.options.lineNumbers, container = display.lineDiv, cur = container.firstChild; function rm(node) { var next = node.nextSibling; return webkit && mac && cm.display.currentWheelTarget == node ? node.style.display = "none" : node.parentNode.removeChild(node), next; } // Loop over the elements in the view, syncing cur (the DOM nodes // in display.lineDiv) with the view as we go. for(var view = display.view, lineN = display.viewFrom, i = 0; i < view.length; i++){ var lineView = view[i]; if (lineView.hidden) ; else if (lineView.node && lineView.node.parentNode == container) { // Already drawn for(; cur != lineView.node;)cur = rm(cur); var updateNumber = lineNumbers && null != updateNumbersFrom && updateNumbersFrom <= lineN && lineView.lineNumber; lineView.changes && (indexOf(lineView.changes, "gutter") > -1 && (updateNumber = !1), updateLineForChanges(cm, lineView, lineN, dims)), updateNumber && (removeChildren(lineView.lineNumber), lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))), cur = lineView.node.nextSibling; } else { // Not drawn yet var node = // Build a line's DOM representation from scratch function(cm, lineView, lineN, dims) { var built = getLineContent(cm, lineView); return lineView.text = lineView.node = built.pre, built.bgClass && (lineView.bgClass = built.bgClass), built.textClass && (lineView.textClass = built.textClass), updateLineClasses(cm, lineView), updateLineGutter(cm, lineView, lineN, dims), insertLineWidgets(cm, lineView, dims), lineView.node; }(cm, lineView, lineN, dims); container.insertBefore(node, cur); } lineN += lineView.size; } for(; cur;)cur = rm(cur); }(cm, display1.updateLineNumbers, update.dims), toUpdate > 4 && (display1.lineDiv.style.display = ""), display1.renderedView = display1.view, !// There might have been a widget with a focused element that got // hidden or updated, if so re-focus it. function(snapshot) { if (snapshot && snapshot.activeElt && snapshot.activeElt != activeElt() && (snapshot.activeElt.focus(), !/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode))) { var sel = window.getSelection(), range = document.createRange(); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset), range.collapse(!1), sel.removeAllRanges(), sel.addRange(range), sel.extend(snapshot.focusNode, snapshot.focusOffset); } }(selSnapshot), // Prevent selection and cursors from interfering with the scroll // width and height. removeChildren(display1.cursorDiv), removeChildren(display1.selectionDiv), display1.gutters.style.height = display1.sizer.style.minHeight = 0, different && (display1.lastWrapHeight = update.wrapperHeight, display1.lastWrapWidth = update.wrapperWidth, startWorker(cm, 400)), display1.updateLineNumbers = null, !0; } function postUpdateDisplay(cm, update) { for(var viewport = update.viewport, first = !0;; first = !1){ if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) first && (update.visible = visibleLines(cm.display, cm.doc, viewport)); else if (viewport && null != viewport.top && (viewport = { top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top) }), // Updated line heights might result in the drawn area not // actually covering the viewport. Keep looping until it does. update.visible = visibleLines(cm.display, cm.doc, viewport), update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) break; if (!updateDisplayIfNeeded(cm, update)) break; updateHeightsInViewport(cm); var barMeasure = measureForScrollbars(cm); updateSelection(cm), updateScrollbars(cm, barMeasure), setDocumentHeight(cm, barMeasure), update.force = !1; } update.signal(cm, "update", cm), (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) && (update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo), cm.display.reportedViewFrom = cm.display.viewFrom, cm.display.reportedViewTo = cm.display.viewTo); } function updateDisplaySimple(cm, viewport) { var update = new DisplayUpdate(cm, viewport); if (updateDisplayIfNeeded(cm, update)) { updateHeightsInViewport(cm), postUpdateDisplay(cm, update); var barMeasure = measureForScrollbars(cm); updateSelection(cm), updateScrollbars(cm, barMeasure), setDocumentHeight(cm, barMeasure), update.finish(); } } function updateGutterSpace(display) { var width = display.gutters.offsetWidth; display.sizer.style.marginLeft = width + "px", // Send an event to consumers responding to changes in gutter width. signalLater(display, "gutterChanged", display); } function setDocumentHeight(cm, measure) { cm.display.sizer.style.minHeight = measure.docHeight + "px", cm.display.heightForcer.style.top = measure.docHeight + "px", cm.display.gutters.style.height = measure.docHeight + cm.display.barHeight + scrollGap(cm) + "px"; } // Re-align line numbers and gutter marks to compensate for // horizontal scrolling. function alignHorizontally(cm) { var display = cm.display, view = display.view; if (display.alignWidgets || display.gutters.firstChild && cm.options.fixedGutter) { for(var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft, gutterW = display.gutters.offsetWidth, left = comp + "px", i = 0; i < view.length; i++)if (!view[i].hidden) { cm.options.fixedGutter && (view[i].gutter && (view[i].gutter.style.left = left), view[i].gutterBackground && (view[i].gutterBackground.style.left = left)); var align = view[i].alignable; if (align) for(var j = 0; j < align.length; j++)align[j].style.left = left; } cm.options.fixedGutter && (display.gutters.style.left = comp + gutterW + "px"); } } // Used to ensure that the line number gutter is still the right // size for the current document size. Returns true when an update // is needed. function maybeUpdateLineNumberWidth(cm) { if (!cm.options.lineNumbers) return !1; var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; if (last.length != display.lineNumChars) { var test = display.measure.appendChild(elt("div", [ elt("div", last) ], "CodeMirror-linenumber CodeMirror-gutter-elt")), innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; return display.lineGutter.style.width = "", display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1, display.lineNumWidth = display.lineNumInnerWidth + padding, display.lineNumChars = display.lineNumInnerWidth ? last.length : -1, display.lineGutter.style.width = display.lineNumWidth + "px", updateGutterSpace(cm.display), !0; } return !1; } function getGutters(gutters, lineNumbers) { for(var result = [], sawLineNumbers = !1, i = 0; i < gutters.length; i++){ var name = gutters[i], style = null; if ("string" != typeof name && (style = name.style, name = name.className), "CodeMirror-linenumbers" == name) { if (!lineNumbers) continue; sawLineNumbers = !0; } result.push({ className: name, style: style }); } return lineNumbers && !sawLineNumbers && result.push({ className: "CodeMirror-linenumbers", style: null }), result; } // Rebuild the gutter elements, ensure the margin to the left of the // code matches their width. function renderGutters(display) { var gutters = display.gutters, specs = display.gutterSpecs; removeChildren(gutters), display.lineGutter = null; for(var i = 0; i < specs.length; ++i){ var ref = specs[i], className = ref.className, style = ref.style, gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className)); style && (gElt.style.cssText = style), "CodeMirror-linenumbers" == className && (display.lineGutter = gElt, gElt.style.width = (display.lineNumWidth || 1) + "px"); } gutters.style.display = specs.length ? "" : "none", updateGutterSpace(display); } function updateGutters(cm) { renderGutters(cm.display), regChange(cm), alignHorizontally(cm); } // The display handles the DOM integration, both for input reading // and content drawing. It holds references to DOM nodes and // display-related state. function Display(place, doc, input, options) { this.input = input, // Covers bottom-right square when both scrollbars are present. this.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"), this.scrollbarFiller.setAttribute("cm-not-content", "true"), // Covers bottom of gutter when coverGutterNextToScrollbar is on // and h scrollbar is present. this.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"), this.gutterFiller.setAttribute("cm-not-content", "true"), // Will contain the actual code, positioned to cover the viewport. this.lineDiv = eltP("div", null, "CodeMirror-code"), // Elements are added to these to represent selection and cursors. this.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"), this.cursorDiv = elt("div", null, "CodeMirror-cursors"), // A visibility: hidden element used to find the size of things. this.measure = elt("div", null, "CodeMirror-measure"), // When lines outside of the viewport are measured, they are drawn in this. this.lineMeasure = elt("div", null, "CodeMirror-measure"), // Wraps everything that needs to exist inside the vertically-padded coordinate system this.lineSpace = eltP("div", [ this.measure, this.lineMeasure, this.selectionDiv, this.cursorDiv, this.lineDiv ], null, "position: relative; outline: none"); var lines = eltP("div", [ this.lineSpace ], "CodeMirror-lines"); // Moved around its parent to cover visible view. this.mover = elt("div", [ lines ], null, "position: relative"), // Set to the height of the document, allowing scrolling. this.sizer = elt("div", [ this.mover ], "CodeMirror-sizer"), this.sizerWidth = null, // Behavior of elts with overflow: auto and padding is // inconsistent across browsers. This is used to ensure the // scrollable area is big enough. this.heightForcer = elt("div", null, null, "position: absolute; height: 50px; width: 1px;"), // Will contain the gutters, if any. this.gutters = elt("div", null, "CodeMirror-gutters"), this.lineGutter = null, // Actual scrollable element. this.scroller = elt("div", [ this.sizer, this.heightForcer, this.gutters ], "CodeMirror-scroll"), this.scroller.setAttribute("tabIndex", "-1"), // The element in which the editor lives. this.wrapper = elt("div", [ this.scrollbarFiller, this.gutterFiller, this.scroller ], "CodeMirror"), // This attribute is respected by automatic translation systems such as Google Translate, // and may also be respected by tools used by human translators. this.wrapper.setAttribute("translate", "no"), ie && ie_version < 8 && (this.gutters.style.zIndex = -1, this.scroller.style.paddingRight = 0), webkit || gecko && mobile || (this.scroller.draggable = !0), place && (place.appendChild ? place.appendChild(this.wrapper) : place(this.wrapper)), // Current rendered range (may be bigger than the view window). this.viewFrom = this.viewTo = doc.first, this.reportedViewFrom = this.reportedViewTo = doc.first, // Information about the rendered lines. this.view = [], this.renderedView = null, // Holds info about a single rendered line when it was rendered // for measurement, while not in view. this.externalMeasured = null, // Empty space (in pixels) above the view this.viewOffset = 0, this.lastWrapHeight = this.lastWrapWidth = 0, this.updateLineNumbers = null, this.nativeBarWidth = this.barHeight = this.barWidth = 0, this.scrollbarsClipped = !1, // Used to only resize the line number gutter when necessary (when // the amount of lines crosses a boundary that makes its width change) this.lineNumWidth = this.lineNumInnerWidth = this.lineNumChars = null, // Set to true when a non-horizontal-scrolling line widget is // added. As an optimization, line widget aligning is skipped when // this is false. this.alignWidgets = !1, this.cachedCharWidth = this.cachedTextHeight = this.cachedPaddingH = null, // Tracks the maximum line length so that the horizontal scrollbar // can be kept static when scrolling. this.maxLine = null, this.maxLineLength = 0, this.maxLineChanged = !1, // Used for measuring wheel scrolling granularity this.wheelDX = this.wheelDY = this.wheelStartX = this.wheelStartY = null, // True when shift is held down. this.shift = !1, // Used to track whether anything happened since the context menu // was opened. this.selForContextMenu = null, this.activeTouch = null, this.gutterSpecs = getGutters(options.gutters, options.lineNumbers), renderGutters(this), input.init(this); } DisplayUpdate.prototype.signal = function(emitter, type) { hasHandler(emitter, type) && this.events.push(arguments); }, DisplayUpdate.prototype.finish = function() { for(var i = 0; i < this.events.length; i++)signal.apply(null, this.events[i]); }; // Since the delta values reported on mouse wheel events are // unstandardized between browsers and even browser versions, and // generally horribly unpredictable, this code starts by measuring // the scroll effect that the first few mouse wheel events have, // and, from that, detects the way it can convert deltas to pixel // offsets afterwards. // // The reason we want to know the amount a wheel event will scroll // is that it gives us a chance to update the display before the // actual scrolling happens, reducing flickering. var wheelSamples = 0, wheelPixelsPerUnit = null; function wheelEventDelta(e) { var dx = e.wheelDeltaX, dy = e.wheelDeltaY; return null == dx && e.detail && e.axis == e.HORIZONTAL_AXIS && (dx = e.detail), null == dy && e.detail && e.axis == e.VERTICAL_AXIS ? dy = e.detail : null == dy && (dy = e.wheelDelta), { x: dx, y: dy }; } function onScrollWheel(cm, e) { var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y, pixelsPerUnit = wheelPixelsPerUnit; 0 === e.deltaMode && (dx = e.deltaX, dy = e.deltaY, pixelsPerUnit = 1); var display = cm.display, scroll = display.scroller, canScrollX = scroll.scrollWidth > scroll.clientWidth, canScrollY = scroll.scrollHeight > scroll.clientHeight; if (dx && canScrollX || dy && canScrollY) { // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. // This hack (see related code in patchDisplay) makes sure the // element is kept around. if (dy && mac && webkit) { outer: for(var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode)for(var i = 0; i < view.length; i++)if (view[i].node == cur) { cm.display.currentWheelTarget = cur; break outer; } } // On some browsers, horizontal scrolling will cause redraws to // happen before the gutter has been realigned, causing it to // wriggle around in a most unseemly way. When we have an // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && null != pixelsPerUnit) { dy && canScrollY && updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit)), setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit)), (!dy || dy && canScrollY) && e_preventDefault(e), display.wheelStartX = null; return; } // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). if (dy && null != pixelsPerUnit) { var pixels = dy * pixelsPerUnit, top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; pixels < 0 ? top = Math.max(0, top + pixels - 50) : bot = Math.min(cm.doc.height, bot + pixels + 50), updateDisplaySimple(cm, { top: top, bottom: bot }); } wheelSamples < 20 && 0 !== e.deltaMode && (null == display.wheelStartX ? (display.wheelStartX = scroll.scrollLeft, display.wheelStartY = scroll.scrollTop, display.wheelDX = dx, display.wheelDY = dy, setTimeout(function() { if (null != display.wheelStartX) { var movedX = scroll.scrollLeft - display.wheelStartX, movedY = scroll.scrollTop - display.wheelStartY, sample = movedY && display.wheelDY && movedY / display.wheelDY || movedX && display.wheelDX && movedX / display.wheelDX; display.wheelStartX = display.wheelStartY = null, sample && (wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1), ++wheelSamples); } }, 200)) : (display.wheelDX += dx, display.wheelDY += dy)); } } ie ? wheelPixelsPerUnit = -0.53 : gecko ? wheelPixelsPerUnit = 15 : chrome ? wheelPixelsPerUnit = -0.7 : safari && (wheelPixelsPerUnit = -1 / 3); // Selection objects are immutable. A new one is created every time // the selection changes. A selection is one or more non-overlapping // (and non-touching) ranges, sorted, and an integer that indicates // which one is the primary selection (the one that's scrolled into // view, that getCursor returns, etc). var Selection = function(ranges, primIndex) { this.ranges = ranges, this.primIndex = primIndex; }; Selection.prototype.primary = function() { return this.ranges[this.primIndex]; }, Selection.prototype.equals = function(other) { if (other == this) return !0; if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return !1; for(var i = 0; i < this.ranges.length; i++){ var here = this.ranges[i], there = other.ranges[i]; if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) return !1; } return !0; }, Selection.prototype.deepCopy = function() { for(var out = [], i = 0; i < this.ranges.length; i++)out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); return new Selection(out, this.primIndex); }, Selection.prototype.somethingSelected = function() { for(var i = 0; i < this.ranges.length; i++)if (!this.ranges[i].empty()) return !0; return !1; }, Selection.prototype.contains = function(pos, end) { end || (end = pos); for(var i = 0; i < this.ranges.length; i++){ var range = this.ranges[i]; if (cmp(end, range.from()) >= 0 && 0 >= cmp(pos, range.to())) return i; } return -1; }; var Range = function(anchor, head) { this.anchor = anchor, this.head = head; }; // Take an unsorted, potentially overlapping set of ranges, and // build a selection out of it. 'Consumes' ranges array (modifying // it). function normalizeSelection(cm, ranges, primIndex) { var mayTouch = cm && cm.options.selectionsMayTouch, prim = ranges[primIndex]; ranges.sort(function(a, b) { return cmp(a.from(), b.from()); }), primIndex = indexOf(ranges, prim); for(var i = 1; i < ranges.length; i++){ var cur = ranges[i], prev = ranges[i - 1], diff = cmp(prev.to(), cur.from()); if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()), inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; i <= primIndex && --primIndex, ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); } } return new Selection(ranges, primIndex); } function simpleSelection(anchor, head) { return new Selection([ new Range(anchor, head || anchor) ], 0); } // Compute the position of the end of a change (its 'to' property // refers to the pre-change end). function changeEnd(change) { return change.text ? Pos(change.from.line + change.text.length - 1, lst(change.text).length + (1 == change.text.length ? change.from.ch : 0)) : change.to; } // Adjust a position to refer to the post-change position of the // same text, or the end of the change if the change covers it. function adjustForChange(pos, change) { if (0 > cmp(pos, change.from)) return pos; if (0 >= cmp(pos, change.to)) return changeEnd(change); var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; return pos.line == change.to.line && (ch += changeEnd(change).ch - change.to.ch), Pos(line, ch); } function computeSelAfterChange(doc, change) { for(var out = [], i = 0; i < doc.sel.ranges.length; i++){ var range = doc.sel.ranges[i]; out.push(new Range(adjustForChange(range.anchor, change), adjustForChange(range.head, change))); } return normalizeSelection(doc.cm, out, doc.sel.primIndex); } function offsetPos(pos, old, nw) { return pos.line == old.line ? Pos(nw.line, pos.ch - old.ch + nw.ch) : Pos(nw.line + (pos.line - old.line), pos.ch); } // Used to get the editor into a consistent state again when options change. function loadMode(cm) { cm.doc.mode = getMode(cm.options, cm.doc.modeOption), resetModeState(cm); } function resetModeState(cm) { cm.doc.iter(function(line) { line.stateAfter && (line.stateAfter = null), line.styles && (line.styles = null); }), cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first, startWorker(cm, 100), cm.state.modeGen++, cm.curOp && regChange(cm); } // DOCUMENT DATA STRUCTURE // By default, updates that start and end at the beginning of a line // are treated specially, in order to make the association of line // widgets and marker elements with the text behave more intuitive. function isWholeLineUpdate(doc, change) { return 0 == change.from.ch && 0 == change.to.ch && "" == lst(change.text) && (!doc.cm || doc.cm.options.wholeLineUpdateBefore); } // Perform a change on the document data structure. function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) { return markedSpans ? markedSpans[n] : null; } function update(line, text, spans) { var estHeight; line.text = text, line.stateAfter && (line.stateAfter = null), line.styles && (line.styles = null), null != line.order && (line.order = null), detachMarkedSpans(line), attachMarkedSpans(line, spans), (estHeight = estimateHeight ? estimateHeight(line) : 1) != line.height && updateLineHeight(line, estHeight), signalLater(line, "change", line, change); } function linesFor(start, end) { for(var result = [], i = start; i < end; ++i)result.push(new Line(text[i], spansFor(i), estimateHeight)); return result; } var from = change.from, to = change.to, text = change.text, firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line), lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) doc.insert(0, linesFor(0, text.length)), doc.remove(text.length, doc.size - text.length); else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans), nlines && doc.remove(from.line, nlines), added.length && doc.insert(from.line, added); } else if (firstLine == lastLine) { if (1 == text.length) update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); else { var added$1 = linesFor(1, text.length - 1); added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)), update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)), doc.insert(from.line + 1, added$1); } } else if (1 == text.length) update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)), doc.remove(from.line + 1, nlines); else { update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)), update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added$2 = linesFor(1, text.length - 1); nlines > 1 && doc.remove(from.line + 1, nlines - 1), doc.insert(from.line + 1, added$2); } signalLater(doc, "change", doc, change); } // Call f for all linked documents. function linkedDocs(doc, f, sharedHistOnly) { !function propagate(doc, skip, sharedHist) { if (doc.linked) for(var i = 0; i < doc.linked.length; ++i){ var rel = doc.linked[i]; if (rel.doc != skip) { var shared = sharedHist && rel.sharedHist; (!sharedHistOnly || shared) && (f(rel.doc, shared), propagate(rel.doc, doc, shared)); } } }(doc, null, !0); } // Attach a document to an editor. function attachDoc(cm, doc) { if (doc.cm) throw Error("This document is already in use."); cm.doc = doc, doc.cm = cm, estimateLineHeights(cm), loadMode(cm), setDirectionClass(cm), cm.options.direction = doc.direction, cm.options.lineWrapping || findMaxLine(cm), cm.options.mode = doc.modeOption, regChange(cm); } function setDirectionClass(cm) { ("rtl" == cm.doc.direction ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); } function History(prev) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = [], this.undone = [], this.undoDepth = prev ? prev.undoDepth : 1 / 0, // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0, this.lastOp = this.lastSelOp = null, this.lastOrigin = this.lastSelOrigin = null, // Used by the isClean() method this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1; } // Create a history change event from an updateDoc-style change // object. function historyChangeFromChange(doc, change) { var histChange = { from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to) }; return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1), linkedDocs(doc, function(doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, !0), histChange; } // Pop all selection events off the end of a history array. Stop at // a change event. function clearSelectionEvents(array) { for(; array.length;)if (lst(array).ranges) array.pop(); else break; } // Register a change in the history. Merges changes that are within // a single operation, or are close together with an origin that // allows merging (starting with "+") into a single event. function addChangeToHistory(doc, change, selAfter, opId) { var last, hist = doc.history; hist.undone.length = 0; var cur, time = +new Date(); if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && ("+" == change.origin.charAt(0) && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500) || "*" == change.origin.charAt(0))) && (cur = hist.lastOp == opId ? (clearSelectionEvents(hist.done), lst(hist.done)) : hist.done.length && !lst(hist.done).ranges ? lst(hist.done) : hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges ? (hist.done.pop(), lst(hist.done)) : void 0)) // Merge this change into the last event last = lst(cur.changes), 0 == cmp(change.from, change.to) && 0 == cmp(change.from, last.to) ? // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change) : // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); else { // Can not be merged, start a new event. var before = lst(hist.done); for(before && before.ranges || pushSelectionToHistory(doc.sel, hist.done), cur = { changes: [ historyChangeFromChange(doc, change) ], generation: hist.generation }, hist.done.push(cur); hist.done.length > hist.undoDepth;)hist.done.shift(), hist.done[0].ranges || hist.done.shift(); } hist.done.push(selAfter), hist.generation = ++hist.maxGeneration, hist.lastModTime = hist.lastSelTime = time, hist.lastOp = hist.lastSelOp = opId, hist.lastOrigin = hist.lastSelOrigin = change.origin, last || signal(doc, "historyAdded"); } function pushSelectionToHistory(sel, dest) { var top = lst(dest); top && top.ranges && top.equals(sel) || dest.push(sel); } // Used to store marked span information in the history. function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) { line.markedSpans && ((existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans), ++n; }); } // Used for un/re-doing changes from the history. Combines the // result of computing the existing spans with the set of spans that // existed in the history (so that deleting around a span and then // undoing brings back the span). function mergeOldSpans(doc, change) { var old = // Retrieve and filter the old marked spans stored in a change event. function(doc, change) { var found = change["spans_" + doc.id]; if (!found) return null; for(var nw = [], i = 0; i < change.text.length; ++i)nw.push(// When un/re-doing restores text containing marked spans, those // that have been explicitly cleared should not be restored. function(spans) { if (!spans) return null; for(var out, i = 0; i < spans.length; ++i)spans[i].marker.explicitlyCleared ? out || (out = spans.slice(0, i)) : out && out.push(spans[i]); return out ? out.length ? out : null : spans; }(found[i])); return nw; }(doc, change), stretched = stretchSpansOverChange(doc, change); if (!old) return stretched; if (!stretched) return old; for(var i = 0; i < old.length; ++i){ var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) spans: for(var j = 0; j < stretchCur.length; ++j){ for(var span = stretchCur[j], k = 0; k < oldCur.length; ++k)if (oldCur[k].marker == span.marker) continue spans; oldCur.push(span); } else stretchCur && (old[i] = stretchCur); } return old; } // Used both to provide a JSON-safe object in .getHistory, and, when // detaching a document, to split the history in two function copyHistoryArray(events, newGroup, instantiateSel) { for(var copy = [], i = 0; i < events.length; ++i){ var event = events[i]; if (event.ranges) { copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); continue; } var changes = event.changes, newChanges = []; copy.push({ changes: newChanges }); for(var j = 0; j < changes.length; ++j){ var change = changes[j], m = void 0; if (newChanges.push({ from: change.from, to: change.to, text: change.text }), newGroup) for(var prop in change)(m = prop.match(/^spans_(\d+)$/)) && indexOf(newGroup, Number(m[1])) > -1 && (lst(newChanges)[prop] = change[prop], delete change[prop]); } } return copy; } // The 'scroll' parameter given to many of these indicated whether // the new cursor position should be scrolled into view after // modifying the selection. // If shift is held or the extend flag is set, extends a range to // include a given position (and optionally a second position). // Otherwise, simply returns the range between the given positions. // Used for cursor motion and such. function extendRange(range, head, other, extend) { if (!extend) return new Range(other || head, head); var anchor = range.anchor; if (other) { var posBefore = 0 > cmp(head, anchor); posBefore != 0 > cmp(other, anchor) ? (anchor = head, head = other) : posBefore != 0 > cmp(head, other) && (head = other); } return new Range(anchor, head); } // Extend the primary selection range, discard the rest. function extendSelection(doc, head, other, options, extend) { null == extend && (extend = doc.cm && (doc.cm.display.shift || doc.extend)), setSelection(doc, new Selection([ extendRange(doc.sel.primary(), head, other, extend) ], 0), options); } // Extend all selections (pos is an array of selections with length // equal the number of selections) function extendSelections(doc, heads, options) { for(var out = [], extend = doc.cm && (doc.cm.display.shift || doc.extend), i = 0; i < doc.sel.ranges.length; i++)out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); setSelection(doc, newSel, options); } // Updates a single range in the selection. function replaceOneSelection(doc, i, range, options) { var ranges = doc.sel.ranges.slice(0); ranges[i] = range, setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options); } function setSelectionReplaceHistory(doc, sel, options) { var done = doc.history.done, last = lst(done); last && last.ranges ? (done[done.length - 1] = sel, setSelectionNoUndo(doc, sel, options)) : setSelection(doc, sel, options); } // Set a new selection. function setSelection(doc, sel, options) { var sel1, opId, prev, ch, hist, origin; setSelectionNoUndo(doc, sel, options), sel1 = doc.sel, opId = doc.cm ? doc.cm.curOp.id : NaN, hist = doc.history, origin = options && options.origin, opId == hist.lastSelOp || origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || (prev = lst(hist.done), "*" == (ch = origin.charAt(0)) || "+" == ch && prev.ranges.length == sel1.ranges.length && prev.somethingSelected() == sel1.somethingSelected() && new Date() - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500))) ? hist.done[hist.done.length - 1] = sel1 : pushSelectionToHistory(sel1, hist.done), hist.lastSelTime = +new Date(), hist.lastSelOrigin = origin, hist.lastSelOp = opId, options && !1 !== options.clearRedo && clearSelectionEvents(hist.undone); } function setSelectionNoUndo(doc, sel, options) { if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) { var sel1, obj; obj = { ranges: (sel1 = sel).ranges, update: function(ranges) { this.ranges = []; for(var i = 0; i < ranges.length; i++)this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head)); }, origin: options && options.origin }, signal(doc, "beforeSelectionChange", doc, obj), doc.cm && signal(doc.cm, "beforeSelectionChange", doc.cm, obj), sel = obj.ranges != sel1.ranges ? normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) : sel1; } var bias = options && options.bias || (0 > cmp(sel.primary().head, doc.sel.primary().head) ? -1 : 1); setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, !0)), !(options && !1 === options.scroll) && doc.cm && "nocursor" != doc.cm.getOption("readOnly") && ensureCursorVisible(doc.cm); } function setSelectionInner(doc, sel) { sel.equals(doc.sel) || (doc.sel = sel, doc.cm && (doc.cm.curOp.updateInput = 1, doc.cm.curOp.selectionChanged = !0, signalCursorActivity(doc.cm)), signalLater(doc, "cursorActivity", doc)); } // Verify that the selection does not partially select any atomic // marked ranges. function reCheckSelection(doc) { setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, !1)); } // Return a selection that does not partially select any atomic // ranges. function skipAtomicInSelection(doc, sel, bias, mayClear) { for(var out, i = 0; i < sel.ranges.length; i++){ var range = sel.ranges[i], old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i], newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear), newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); (out || newAnchor != range.anchor || newHead != range.head) && (out || (out = sel.ranges.slice(0, i)), out[i] = new Range(newAnchor, newHead)); } return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel; } function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { var line = getLine(doc, pos.line); if (line.markedSpans) for(var i = 0; i < line.markedSpans.length; ++i){ var sp = line.markedSpans[i], m = sp.marker, preventCursorLeft = "selectLeft" in m ? !m.selectLeft : m.inclusiveLeft, preventCursorRight = "selectRight" in m ? !m.selectRight : m.inclusiveRight; if ((null == sp.from || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (null == sp.to || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) { if (mayClear && (signal(m, "beforeCursorEnter"), m.explicitlyCleared)) { if (line.markedSpans) { --i; continue; } break; } if (!m.atomic) continue; if (oldPos) { var near = m.find(dir < 0 ? 1 : -1), diff = void 0; if ((dir < 0 ? preventCursorRight : preventCursorLeft) && (near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null)), near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) return skipAtomicInner(doc, near, pos, dir, mayClear); } var far = m.find(dir < 0 ? -1 : 1); return (dir < 0 ? preventCursorLeft : preventCursorRight) && (far = movePos(doc, far, dir, far.line == pos.line ? line : null)), far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null; } } return pos; } // Ensure a given position is not inside an atomic range. function skipAtomic(doc, pos, oldPos, bias, mayClear) { var dir = bias || 1; return skipAtomicInner(doc, pos, oldPos, dir, mayClear) || !mayClear && skipAtomicInner(doc, pos, oldPos, dir, !0) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || !mayClear && skipAtomicInner(doc, pos, oldPos, -dir, !0) || (doc.cantEdit = !0, Pos(doc.first, 0)); } function movePos(doc, pos, dir, line) { return dir < 0 && 0 == pos.ch ? pos.line > doc.first ? clipPos(doc, Pos(pos.line - 1)) : null : dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length ? pos.line < doc.first + doc.size - 1 ? Pos(pos.line + 1, 0) : null : new Pos(pos.line, pos.ch + dir); } function selectAll(cm) { cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll); } // UPDATING // Allow "beforeChange" event handlers to influence a change function filterChange(doc, change, update) { var obj = { canceled: !1, from: change.from, to: change.to, text: change.text, origin: change.origin, cancel: function() { return obj.canceled = !0; } }; return (update && (obj.update = function(from, to, text, origin) { from && (obj.from = clipPos(doc, from)), to && (obj.to = clipPos(doc, to)), text && (obj.text = text), void 0 !== origin && (obj.origin = origin); }), signal(doc, "beforeChange", doc, obj), doc.cm && signal(doc.cm, "beforeChange", doc.cm, obj), obj.canceled) ? (doc.cm && (doc.cm.curOp.updateInput = 2), null) : { from: obj.from, to: obj.to, text: obj.text, origin: obj.origin }; } // Apply a change to a document, and add it to the document's // history, and propagating it to all linked documents. function makeChange(doc, change, ignoreReadOnly) { if (doc.cm) { if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); if (doc.cm.state.suppressEdits) return; } if (!(hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) || (change = filterChange(doc, change, !0))) { // Possibly split or suppress the update based on the presence // of read-only spans in its range. var split = sawReadOnlySpans && !ignoreReadOnly && // Used to 'clip' out readOnly ranges when making a change. function(doc, from, to) { var markers = null; if (doc.iter(from.line, to.line + 1, function(line) { if (line.markedSpans) for(var i = 0; i < line.markedSpans.length; ++i){ var mark = line.markedSpans[i].marker; mark.readOnly && (!markers || -1 == indexOf(markers, mark)) && (markers || (markers = [])).push(mark); } }), !markers) return null; for(var parts = [ { from: from, to: to } ], i = 0; i < markers.length; ++i)for(var mk = markers[i], m = mk.find(0), j = 0; j < parts.length; ++j){ var p = parts[j]; if (!(0 > cmp(p.to, m.from) || cmp(p.from, m.to) > 0)) { var newParts = [ j, 1 ], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); !(dfrom < 0) && (mk.inclusiveLeft || dfrom) || newParts.push({ from: p.from, to: m.from }), !(dto > 0) && (mk.inclusiveRight || dto) || newParts.push({ from: m.to, to: p.to }), parts.splice.apply(parts, newParts), j += newParts.length - 3; } } return parts; }(doc, change.from, change.to); if (split) for(var i = split.length - 1; i >= 0; --i)makeChangeInner(doc, { from: split[i].from, to: split[i].to, text: i ? [ "" ] : change.text, origin: change.origin }); else makeChangeInner(doc, change); } } function makeChangeInner(doc, change) { if (1 != change.text.length || "" != change.text[0] || 0 != cmp(change.from, change.to)) { var selAfter = computeSelAfterChange(doc, change); addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN), makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); var rebased = []; linkedDocs(doc, function(doc, sharedHist) { sharedHist || -1 != indexOf(rebased, doc.history) || (rebaseHist(doc.history, change), rebased.push(doc.history)), makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); }); } } // Revert a change stored in a document's history. function makeChangeFromHistory(doc, type, allowSelectionOnly) { var suppress = doc.cm && doc.cm.state.suppressEdits; if (!suppress || allowSelectionOnly) { for(var event, hist = doc.history, selAfter = doc.sel, source = "undo" == type ? hist.done : hist.undone, dest = "undo" == type ? hist.undone : hist.done, i = 0; i < source.length && (event = source[i], allowSelectionOnly ? !event.ranges || event.equals(doc.sel) : event.ranges); i++); if (i != source.length) { for(hist.lastOrigin = hist.lastSelOrigin = null;;)if ((event = source.pop()).ranges) { if (pushSelectionToHistory(event, dest), allowSelectionOnly && !event.equals(doc.sel)) { setSelection(doc, event, { clearRedo: !1 }); return; } selAfter = event; } else if (suppress) { source.push(event); return; } else break; // Build up a reverse change object to add to the opposite history // stack (redo when undoing, and vice versa). var antiChanges = []; pushSelectionToHistory(selAfter, dest), dest.push({ changes: antiChanges, generation: hist.generation }), hist.generation = event.generation || ++hist.maxGeneration; for(var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"), i$1 = event.changes.length - 1; i$1 >= 0; --i$1){ var returned = function(i) { var change = event.changes[i]; if (change.origin = type, filter && !filterChange(doc, change, !1)) return source.length = 0, {}; antiChanges.push(historyChangeFromChange(doc, change)); var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)), !i && doc.cm && doc.cm.scrollIntoView({ from: change.from, to: changeEnd(change) }); var rebased = []; // Propagate to the linked documents linkedDocs(doc, function(doc, sharedHist) { sharedHist || -1 != indexOf(rebased, doc.history) || (rebaseHist(doc.history, change), rebased.push(doc.history)), makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); }); }(i$1); if (returned) return returned.v; } } } } // Sub-views need their line numbers shifted when text is added // above or below them in the parent document. function shiftDoc(doc, distance) { if (0 != distance && (doc.first += distance, doc.sel = new Selection(map(doc.sel.ranges, function(range) { return new Range(Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch)); }), doc.sel.primIndex), doc.cm)) { regChange(doc.cm, doc.first, doc.first - distance, distance); for(var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)regLineChange(doc.cm, l, "gutter"); } } // More lower-level change function, handling only a single document // (not linked ones). function makeChangeSingleDoc(doc, change, selAfter, spans) { if (doc.cm && !doc.cm.curOp) return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); if (change.to.line < doc.first) { shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); return; } if (!(change.from.line > doc.lastLine())) { // Clip the change to the size of this doc if (change.from.line < doc.first) { var shift = change.text.length - 1 - (doc.first - change.from.line); shiftDoc(doc, shift), change = { from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), text: [ lst(change.text) ], origin: change.origin }; } var last = doc.lastLine(); change.to.line > last && (change = { from: change.from, to: Pos(last, getLine(doc, last).text.length), text: [ change.text[0] ], origin: change.origin }), change.removed = getBetween(doc, change.from, change.to), selAfter || (selAfter = computeSelAfterChange(doc, change)), doc.cm ? // Handle the interaction of a change to a document with the editor // that this document is part of. function(cm, change, spans) { var doc = cm.doc, display = cm.display, from = change.from, to = change.to, recomputeMaxLength = !1, checkWidthStart = from.line; cm.options.lineWrapping || (checkWidthStart = lineNo(visualLine(getLine(doc, from.line))), doc.iter(checkWidthStart, to.line + 1, function(line) { if (line == display.maxLine) return recomputeMaxLength = !0, !0; })), doc.sel.contains(change.from, change.to) > -1 && signalCursorActivity(cm), updateDoc(doc, change, spans, estimateHeight(cm)), !cm.options.lineWrapping && (doc.iter(checkWidthStart, from.line + change.text.length, function(line) { var len = lineLength(line); len > display.maxLineLength && (display.maxLine = line, display.maxLineLength = len, display.maxLineChanged = !0, recomputeMaxLength = !1); }), recomputeMaxLength && (cm.curOp.updateMaxLine = !0)), function(doc, n) { if (doc.modeFrontier = Math.min(doc.modeFrontier, n), !(doc.highlightFrontier < n - 10)) { for(var start = doc.first, line = n - 1; line > start; line--){ var saved = getLine(doc, line).stateAfter; // change is on 3 // state on line 1 looked ahead 2 -- so saw 3 // test 1 + 2 < 3 should cover this if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) { start = line + 1; break; } } doc.highlightFrontier = Math.min(doc.highlightFrontier, start); } }(doc, from.line), startWorker(cm, 400); var lendiff = change.text.length - (to.line - from.line) - 1; change.full ? regChange(cm) : from.line != to.line || 1 != change.text.length || isWholeLineUpdate(cm.doc, change) ? regChange(cm, from.line, to.line + 1, lendiff) : regLineChange(cm, from.line, "text"); var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); if (changeHandler || changesHandler) { var obj = { from: from, to: to, text: change.text, removed: change.removed, origin: change.origin }; changeHandler && signalLater(cm, "change", cm, obj), changesHandler && (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } cm.display.selForContextMenu = null; }(doc.cm, change, spans) : updateDoc(doc, change, spans), setSelectionNoUndo(doc, selAfter, sel_dontScroll), doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)) && (doc.cantEdit = !1); } } function replaceRange(doc, code, from, to, origin) { var assign; to || (to = from), 0 > cmp(to, from) && (from = (assign = [ to, from ])[0], to = assign[1]), "string" == typeof code && (code = doc.splitLines(code)), makeChange(doc, { from: from, to: to, text: code, origin: origin }); } // Rebasing/resetting history to deal with externally-sourced changes function rebaseHistSelSingle(pos, from, to, diff) { to < pos.line ? pos.line += diff : from < pos.line && (pos.line = from, pos.ch = 0); } // Tries to rebase an array of history events given a change in the // document. If the change touches the same lines as the event, the // event, and everything 'behind' it, is discarded. If the change is // before the event, the event's positions are updated. Uses a // copy-on-write scheme for the positions, to avoid having to // reallocate them all on every rebase, but also avoid problems with // shared position objects being unsafely updated. function rebaseHistArray(array, from, to, diff) { for(var i = 0; i < array.length; ++i){ var sub = array[i], ok = !0; if (sub.ranges) { sub.copied || ((sub = array[i] = sub.deepCopy()).copied = !0); for(var j = 0; j < sub.ranges.length; j++)rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff), rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); continue; } for(var j$1 = 0; j$1 < sub.changes.length; ++j$1){ var cur = sub.changes[j$1]; if (to < cur.from.line) cur.from = Pos(cur.from.line + diff, cur.from.ch), cur.to = Pos(cur.to.line + diff, cur.to.ch); else if (from <= cur.to.line) { ok = !1; break; } } ok || (array.splice(0, i + 1), i = 0); } } function rebaseHist(hist, change) { var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; rebaseHistArray(hist.done, from, to, diff), rebaseHistArray(hist.undone, from, to, diff); } // Utility for applying a change to a line by handle or number, // returning the number and optionally registering the line as // changed. function changeLine(doc, handle, changeType, op) { var no = handle, line = handle; return ("number" == typeof handle ? line = getLine(doc, clipLine(doc, handle)) : no = lineNo(handle), null == no) ? null : (op(line, no) && doc.cm && regLineChange(doc.cm, no, changeType), line); } // The document is represented as a BTree consisting of leaves, with // chunk of lines in them, and branches, with up to ten leaves or // other branch nodes below them. The top node is always a branch // node, and is the document object itself (meaning it has // additional methods and properties). // // All nodes have parent links. The tree is used both to go from // line numbers to line objects, and to go from objects to numbers. // It also indexes by height, and is used to convert between height // and line object, and to find the total height of the document. // // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html function LeafChunk(lines) { this.lines = lines, this.parent = null; for(var height = 0, i = 0; i < lines.length; ++i)lines[i].parent = this, height += lines[i].height; this.height = height; } function BranchChunk(children) { this.children = children; for(var size = 0, height = 0, i = 0; i < children.length; ++i){ var ch = children[i]; size += ch.chunkSize(), height += ch.height, ch.parent = this; } this.size = size, this.height = height, this.parent = null; } Range.prototype.from = function() { return minPos(this.anchor, this.head); }, Range.prototype.to = function() { return maxPos(this.anchor, this.head); }, Range.prototype.empty = function() { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; }, LeafChunk.prototype = { chunkSize: function() { return this.lines.length; }, // Remove the n lines at offset 'at'. removeInner: function(at, n) { for(var i = at, e = at + n; i < e; ++i){ var line = this.lines[i]; this.height -= line.height, line.parent = null, detachMarkedSpans(line), signalLater(line, "delete"); } this.lines.splice(at, n); }, // Helper used to collapse a small branch into a single leaf. collapse: function(lines) { lines.push.apply(lines, this.lines); }, // Insert the given array of lines at offset 'at', count them as // having the given height. insertInner: function(at, lines, height) { this.height += height, this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); for(var i = 0; i < lines.length; ++i)lines[i].parent = this; }, // Used to iterate over a part of the tree. iterN: function(at, n, op) { for(var e = at + n; at < e; ++at)if (op(this.lines[at])) return !0; } }, BranchChunk.prototype = { chunkSize: function() { return this.size; }, removeInner: function(at, n) { this.size -= n; for(var i = 0; i < this.children.length; ++i){ var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var rm = Math.min(n, sz - at), oldHeight = child.height; if (child.removeInner(at, rm), this.height -= oldHeight - child.height, sz == rm && (this.children.splice(i--, 1), child.parent = null), 0 == (n -= rm)) break; at = 0; } else at -= sz; } // If the result is smaller than 25 lines, ensure that it is a // single leaf node. if (this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { var lines = []; this.collapse(lines), this.children = [ new LeafChunk(lines) ], this.children[0].parent = this; } }, collapse: function(lines) { for(var i = 0; i < this.children.length; ++i)this.children[i].collapse(lines); }, insertInner: function(at, lines, height) { this.size += lines.length, this.height += height; for(var i = 0; i < this.children.length; ++i){ var child = this.children[i], sz = child.chunkSize(); if (at <= sz) { if (child.insertInner(at, lines, height), child.lines && child.lines.length > 50) { for(var remaining = child.lines.length % 25 + 25, pos = remaining; pos < child.lines.length;){ var leaf = new LeafChunk(child.lines.slice(pos, pos += 25)); child.height -= leaf.height, this.children.splice(++i, 0, leaf), leaf.parent = this; } child.lines = child.lines.slice(0, remaining), this.maybeSpill(); } break; } at -= sz; } }, // When a node has grown, check whether it should be split. maybeSpill: function() { if (!(this.children.length <= 10)) { var me = this; do { var sibling = new BranchChunk(me.children.splice(me.children.length - 5, 5)); if (me.parent) { me.size -= sibling.size, me.height -= sibling.height; var myIndex = indexOf(me.parent.children, me); me.parent.children.splice(myIndex + 1, 0, sibling); } else { // Become the parent node var copy = new BranchChunk(me.children); copy.parent = me, me.children = [ copy, sibling ], me = copy; } sibling.parent = me.parent; }while (me.children.length > 10) me.parent.maybeSpill(); } }, iterN: function(at, n, op) { for(var i = 0; i < this.children.length; ++i){ var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var used = Math.min(n, sz - at); if (child.iterN(at, used, op)) return !0; if (0 == (n -= used)) break; at = 0; } else at -= sz; } } }; // Line widgets are block elements displayed above or below a line. var LineWidget = function(doc, node, options) { if (options) for(var opt in options)options.hasOwnProperty(opt) && (this[opt] = options[opt]); this.doc = doc, this.node = node; }; function adjustScrollWhenAboveVisible(cm, line, diff) { heightAtLine(line) < (cm.curOp && cm.curOp.scrollTop || cm.doc.scrollTop) && addToScrollTop(cm, diff); } LineWidget.prototype.clear = function() { var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); if (null != no && ws) { for(var i = 0; i < ws.length; ++i)ws[i] == this && ws.splice(i--, 1); ws.length || (line.widgets = null); var height = widgetHeight(this); updateLineHeight(line, Math.max(0, line.height - height)), cm && (runInOp(cm, function() { adjustScrollWhenAboveVisible(cm, line, -height), regLineChange(cm, no, "widget"); }), signalLater(cm, "lineWidgetCleared", cm, this, no)); } }, LineWidget.prototype.changed = function() { var this$1 = this, oldH = this.height, cm = this.doc.cm, line = this.line; this.height = null; var diff = widgetHeight(this) - oldH; diff && (lineIsHidden(this.doc, line) || updateLineHeight(line, line.height + diff), cm && runInOp(cm, function() { cm.curOp.forceUpdate = !0, adjustScrollWhenAboveVisible(cm, line, diff), signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line)); })); }, eventMixin(LineWidget); // TEXTMARKERS // Created with markText and setBookmark methods. A TextMarker is a // handle that can be used to clear or find a marked position in the // document. Line objects hold arrays (markedSpans) containing // {from, to, marker} object pointing to such marker objects, and // indicating that such a marker is present on that line. Multiple // lines may point to the same marker when it spans across lines. // The spans will have null for their from/to properties when the // marker continues beyond the start/end of the line. Markers have // links back to the lines they currently touch. // Collapsed markers have unique ids, in order to be able to order // them, which is needed for uniquely determining an outer marker // when they overlap (they may nest, but not partially overlap). var nextMarkerId = 0, TextMarker = function(doc, type) { this.lines = [], this.type = type, this.doc = doc, this.id = ++nextMarkerId; }; // Create a marker, wire it up to the right lines, and function markText(doc, from, to, options, type) { // Shared markers (across linked documents) are handled separately // (markTextShared will call out to this again, once per // document). if (options && options.shared) { var options1, markers, primary, widget; return (options1 = copyObj(options1 = options)).shared = !1, primary = (markers = [ markText(doc, from, to, options1, type) ])[0], widget = options1.widgetNode, linkedDocs(doc, function(doc) { widget && (options1.widgetNode = widget.cloneNode(!0)), markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options1, type)); for(var i = 0; i < doc.linked.length; ++i)if (doc.linked[i].isParent) return; primary = lst(markers); }), new SharedTextMarker(markers, primary); } // Ensure we are in an operation. if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type); var marker = new TextMarker(doc, type), diff = cmp(from, to); // Don't connect empty markers unless clearWhenEmpty is false if (options && copyObj(options, marker, !1), diff > 0 || 0 == diff && !1 !== marker.clearWhenEmpty) return marker; if (marker.replacedWith && (// Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = !0, marker.widgetNode = eltP("span", [ marker.replacedWith ], "CodeMirror-widget"), options.handleMouseEvents || marker.widgetNode.setAttribute("cm-ignore-events", "true"), options.insertLeft && (marker.widgetNode.insertLeft = !0)), marker.collapsed) { if (conflictingCollapsedRange(doc, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) throw Error("Inserting collapsed marker partially overlapping an existing one"); sawCollapsedSpans = !0; } marker.addToHistory && addChangeToHistory(doc, { from: from, to: to, origin: "markText" }, doc.sel, NaN); var updateMaxLine, curLine = from.line, cm = doc.cm; if (doc.iter(curLine, to.line + 1, function(line) { var span, op, inThisOp; cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine && (updateMaxLine = !0), marker.collapsed && curLine != from.line && updateLineHeight(line, 0), span = new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null), (inThisOp = (op = doc.cm && doc.cm.curOp) && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet()))) && inThisOp.has(line.markedSpans) ? line.markedSpans.push(span) : (line.markedSpans = line.markedSpans ? line.markedSpans.concat([ span ]) : [ span ], inThisOp && inThisOp.add(line.markedSpans)), span.marker.attachLine(line), ++curLine; }), marker.collapsed && doc.iter(from.line, to.line + 1, function(line) { lineIsHidden(doc, line) && updateLineHeight(line, 0); }), marker.clearOnEnter && on(marker, "beforeCursorEnter", function() { return marker.clear(); }), marker.readOnly && (sawReadOnlySpans = !0, (doc.history.done.length || doc.history.undone.length) && doc.clearHistory()), marker.collapsed && (marker.id = ++nextMarkerId, marker.atomic = !0), cm) { if (updateMaxLine && (cm.curOp.updateMaxLine = !0), marker.collapsed) regChange(cm, from.line, to.line + 1); else if (marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title) for(var i = from.line; i <= to.line; i++)regLineChange(cm, i, "text"); marker.atomic && reCheckSelection(cm.doc), signalLater(cm, "markerAdded", cm, marker); } return marker; } // Clear the marker. TextMarker.prototype.clear = function() { if (!this.explicitlyCleared) { var cm = this.doc.cm, withOp = cm && !cm.curOp; if (withOp && startOperation(cm), hasHandler(this, "clear")) { var found = this.find(); found && signalLater(this, "clear", found.from, found.to); } for(var min = null, max = null, i = 0; i < this.lines.length; ++i){ var line = this.lines[i], span = getMarkedSpanFor(line.markedSpans, this); cm && !this.collapsed ? regLineChange(cm, lineNo(line), "text") : cm && (null != span.to && (max = lineNo(line)), null != span.from && (min = lineNo(line))), line.markedSpans = // Remove a span from an array, returning undefined if no spans are // left (we don't store arrays for lines without spans). function(spans, span) { for(var r, i = 0; i < spans.length; ++i)spans[i] != span && (r || (r = [])).push(spans[i]); return r; }(line.markedSpans, span), null == span.from && this.collapsed && !lineIsHidden(this.doc, line) && cm && updateLineHeight(line, textHeight(cm.display)); } if (cm && this.collapsed && !cm.options.lineWrapping) for(var i$1 = 0; i$1 < this.lines.length; ++i$1){ var visual = visualLine(this.lines[i$1]), len = lineLength(visual); len > cm.display.maxLineLength && (cm.display.maxLine = visual, cm.display.maxLineLength = len, cm.display.maxLineChanged = !0); } null != min && cm && this.collapsed && regChange(cm, min, max + 1), this.lines.length = 0, this.explicitlyCleared = !0, this.atomic && this.doc.cantEdit && (this.doc.cantEdit = !1, cm && reCheckSelection(cm.doc)), cm && signalLater(cm, "markerCleared", cm, this, min, max), withOp && endOperation(cm), this.parent && this.parent.clear(); } }, // Find the position of the marker in the document. Returns a {from, // to} object by default. Side can be passed to get a specific side // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the // Pos objects returned contain a line object, rather than a line // number (used to prevent looking up the same line twice). TextMarker.prototype.find = function(side, lineObj) { null == side && "bookmark" == this.type && (side = 1); for(var from, to, i = 0; i < this.lines.length; ++i){ var line = this.lines[i], span = getMarkedSpanFor(line.markedSpans, this); if (null != span.from && (from = Pos(lineObj ? line : lineNo(line), span.from), -1 == side)) return from; if (null != span.to && (to = Pos(lineObj ? line : lineNo(line), span.to), 1 == side)) return to; } return from && { from: from, to: to }; }, // Signals that the marker's widget changed, and surrounding layout // should be recomputed. TextMarker.prototype.changed = function() { var this$1 = this, pos = this.find(-1, !0), widget = this, cm = this.doc.cm; pos && cm && runInOp(cm, function() { var line = pos.line, view = findViewForLine(cm, lineNo(pos.line)); if (view && (clearLineMeasurementCacheFor(view), cm.curOp.selectionChanged = cm.curOp.forceUpdate = !0), cm.curOp.updateMaxLine = !0, !lineIsHidden(widget.doc, line) && null != widget.height) { var oldHeight = widget.height; widget.height = null; var dHeight = widgetHeight(widget) - oldHeight; dHeight && updateLineHeight(line, line.height + dHeight); } signalLater(cm, "markerChanged", cm, this$1); }); }, TextMarker.prototype.attachLine = function(line) { if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; op.maybeHiddenMarkers && -1 != indexOf(op.maybeHiddenMarkers, this) || (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); } this.lines.push(line); }, TextMarker.prototype.detachLine = function(line) { if (this.lines.splice(indexOf(this.lines, line), 1), !this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); } }, eventMixin(TextMarker); // SHARED TEXTMARKERS // A shared marker spans multiple linked documents. It is // implemented as a meta-marker-object controlling multiple normal // markers. var SharedTextMarker = function(markers, primary) { this.markers = markers, this.primary = primary; for(var i = 0; i < markers.length; ++i)markers[i].parent = this; }; function findSharedMarkers(doc) { return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function(m) { return m.parent; }); } SharedTextMarker.prototype.clear = function() { if (!this.explicitlyCleared) { this.explicitlyCleared = !0; for(var i = 0; i < this.markers.length; ++i)this.markers[i].clear(); signalLater(this, "clear"); } }, SharedTextMarker.prototype.find = function(side, lineObj) { return this.primary.find(side, lineObj); }, eventMixin(SharedTextMarker); var nextDocId = 0, Doc = function(text, mode, firstLine, lineSep, direction) { if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep, direction); null == firstLine && (firstLine = 0), BranchChunk.call(this, [ new LeafChunk([ new Line("", null) ]) ]), this.first = firstLine, this.scrollTop = this.scrollLeft = 0, this.cantEdit = !1, this.cleanGeneration = 1, this.modeFrontier = this.highlightFrontier = firstLine; var start = Pos(firstLine, 0); this.sel = simpleSelection(start), this.history = new History(null), this.id = ++nextDocId, this.modeOption = mode, this.lineSep = lineSep, this.direction = "rtl" == direction ? "rtl" : "ltr", this.extend = !1, "string" == typeof text && (text = this.splitLines(text)), updateDoc(this, { from: start, to: start, text: text }), setSelection(this, simpleSelection(start), sel_dontScroll); }; Doc.prototype = createObj(BranchChunk.prototype, { constructor: Doc, // Iterate over the document. Supports two forms -- with only one // argument, it calls that for each line in the document. With // three, it iterates over the range given by the first two (with // the second being non-inclusive). iter: function(from, to, op) { op ? this.iterN(from - this.first, to - from, op) : this.iterN(this.first, this.first + this.size, from); }, // Non-public interface for adding and removing lines. insert: function(at, lines) { for(var height = 0, i = 0; i < lines.length; ++i)height += lines[i].height; this.insertInner(at - this.first, lines, height); }, remove: function(at, n) { this.removeInner(at - this.first, n); }, // From here, the methods are part of the public interface. Most // are also available from CodeMirror (editor) instances. getValue: function(lineSep) { var lines = getLines(this, this.first, this.first + this.size); return !1 === lineSep ? lines : lines.join(lineSep || this.lineSeparator()); }, setValue: docMethodOp(function(code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; makeChange(this, { from: top, to: Pos(last, getLine(this, last).text.length), text: this.splitLines(code), origin: "setValue", full: !0 }, !0), this.cm && scrollToCoords(this.cm, 0, 0), setSelection(this, simpleSelection(top), sel_dontScroll); }), replaceRange: function(code, from, to, origin) { from = clipPos(this, from), to = to ? clipPos(this, to) : from, replaceRange(this, code, from, to, origin); }, getRange: function(from, to, lineSep) { var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); return !1 === lineSep ? lines : "" === lineSep ? lines.join("") : lines.join(lineSep || this.lineSeparator()); }, getLine: function(line) { var l = this.getLineHandle(line); return l && l.text; }, getLineHandle: function(line) { if (isLine(this, line)) return getLine(this, line); }, getLineNumber: function(line) { return lineNo(line); }, getLineHandleVisualStart: function(line) { return "number" == typeof line && (line = getLine(this, line)), visualLine(line); }, lineCount: function() { return this.size; }, firstLine: function() { return this.first; }, lastLine: function() { return this.first + this.size - 1; }, clipPos: function(pos) { return clipPos(this, pos); }, getCursor: function(start) { var range = this.sel.primary(); return null == start || "head" == start ? range.head : "anchor" == start ? range.anchor : "end" == start || "to" == start || !1 === start ? range.to() : range.from(); }, listSelections: function() { return this.sel.ranges; }, somethingSelected: function() { return this.sel.somethingSelected(); }, setCursor: docMethodOp(function(line, ch, options) { setSelection(this, simpleSelection(clipPos(this, "number" == typeof line ? Pos(line, ch || 0) : line), null), options); }), setSelection: docMethodOp(function(anchor, head, options) { setSelection(this, simpleSelection(clipPos(this, anchor), clipPos(this, head || anchor)), options); }), extendSelection: docMethodOp(function(head, other, options) { extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); }), extendSelections: docMethodOp(function(heads, options) { extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function(f, options) { extendSelections(this, clipPosArray(this, map(this.sel.ranges, f)), options); }), setSelections: docMethodOp(function(ranges, primary, options) { if (ranges.length) { for(var out = [], i = 0; i < ranges.length; i++)out[i] = new Range(clipPos(this, ranges[i].anchor), clipPos(this, ranges[i].head || ranges[i].anchor)); null == primary && (primary = Math.min(ranges.length - 1, this.sel.primIndex)), setSelection(this, normalizeSelection(this.cm, out, primary), options); } }), addSelection: docMethodOp(function(anchor, head, options) { var ranges = this.sel.ranges.slice(0); ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))), setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options); }), getSelection: function(lineSep) { for(var lines, ranges = this.sel.ranges, i = 0; i < ranges.length; i++){ var sel = getBetween(this, ranges[i].from(), ranges[i].to()); lines = lines ? lines.concat(sel) : sel; } return !1 === lineSep ? lines : lines.join(lineSep || this.lineSeparator()); }, getSelections: function(lineSep) { for(var parts = [], ranges = this.sel.ranges, i = 0; i < ranges.length; i++){ var sel = getBetween(this, ranges[i].from(), ranges[i].to()); !1 !== lineSep && (sel = sel.join(lineSep || this.lineSeparator())), parts[i] = sel; } return parts; }, replaceSelection: function(code, collapse, origin) { for(var dup = [], i = 0; i < this.sel.ranges.length; i++)dup[i] = code; this.replaceSelections(dup, collapse, origin || "+input"); }, replaceSelections: docMethodOp(function(code, collapse, origin) { for(var changes = [], sel = this.sel, i = 0; i < sel.ranges.length; i++){ var range = sel.ranges[i]; changes[i] = { from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin }; } for(var newSel = collapse && "end" != collapse && // Used by replaceSelections to allow moving the selection to the // start or around the replaced test. Hint may be "start" or "around". function(doc, changes, hint) { for(var out = [], oldPrev = Pos(doc.first, 0), newPrev = oldPrev, i = 0; i < changes.length; i++){ var change = changes[i], from = offsetPos(change.from, oldPrev, newPrev), to = offsetPos(changeEnd(change), oldPrev, newPrev); if (oldPrev = change.to, newPrev = to, "around" == hint) { var range = doc.sel.ranges[i], inv = 0 > cmp(range.head, range.anchor); out[i] = new Range(inv ? to : from, inv ? from : to); } else out[i] = new Range(from, from); } return new Selection(out, doc.sel.primIndex); }(this, changes, collapse), i$1 = changes.length - 1; i$1 >= 0; i$1--)makeChange(this, changes[i$1]); newSel ? setSelectionReplaceHistory(this, newSel) : this.cm && ensureCursorVisible(this.cm); }), undo: docMethodOp(function() { makeChangeFromHistory(this, "undo"); }), redo: docMethodOp(function() { makeChangeFromHistory(this, "redo"); }), undoSelection: docMethodOp(function() { makeChangeFromHistory(this, "undo", !0); }), redoSelection: docMethodOp(function() { makeChangeFromHistory(this, "redo", !0); }), setExtending: function(val) { this.extend = val; }, getExtending: function() { return this.extend; }, historySize: function() { for(var hist = this.history, done = 0, undone = 0, i = 0; i < hist.done.length; i++)!hist.done[i].ranges && ++done; for(var i$1 = 0; i$1 < hist.undone.length; i$1++)!hist.undone[i$1].ranges && ++undone; return { undo: done, redo: undone }; }, clearHistory: function() { var this$1 = this; this.history = new History(this.history), linkedDocs(this, function(doc) { return doc.history = this$1.history; }, !0); }, markClean: function() { this.cleanGeneration = this.changeGeneration(!0); }, changeGeneration: function(forceSplit) { return forceSplit && (this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null), this.history.generation; }, isClean: function(gen) { return this.history.generation == (gen || this.cleanGeneration); }, getHistory: function() { return { done: copyHistoryArray(this.history.done), undone: copyHistoryArray(this.history.undone) }; }, setHistory: function(histData) { var hist = this.history = new History(this.history); hist.done = copyHistoryArray(histData.done.slice(0), null, !0), hist.undone = copyHistoryArray(histData.undone.slice(0), null, !0); }, setGutterMarker: docMethodOp(function(line, gutterID, value) { return changeLine(this, line, "gutter", function(line) { var markers = line.gutterMarkers || (line.gutterMarkers = {}); return markers[gutterID] = value, !value && isEmpty(markers) && (line.gutterMarkers = null), !0; }); }), clearGutter: docMethodOp(function(gutterID) { var this$1 = this; this.iter(function(line) { line.gutterMarkers && line.gutterMarkers[gutterID] && changeLine(this$1, line, "gutter", function() { return line.gutterMarkers[gutterID] = null, isEmpty(line.gutterMarkers) && (line.gutterMarkers = null), !0; }); }); }), lineInfo: function(line) { var n; if ("number" == typeof line) { if (!isLine(this, line) || (n = line, !(line = getLine(this, line)))) return null; } else if (null == (n = lineNo(line))) return null; return { line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, widgets: line.widgets }; }, addLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, "gutter" == where ? "gutter" : "class", function(line) { var prop = "text" == where ? "textClass" : "background" == where ? "bgClass" : "gutter" == where ? "gutterClass" : "wrapClass"; if (line[prop]) { if (classTest(cls).test(line[prop])) return !1; line[prop] += " " + cls; } else line[prop] = cls; return !0; }); }), removeLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, "gutter" == where ? "gutter" : "class", function(line) { var prop = "text" == where ? "textClass" : "background" == where ? "bgClass" : "gutter" == where ? "gutterClass" : "wrapClass", cur = line[prop]; if (!cur) return !1; if (null == cls) line[prop] = null; else { var found = cur.match(classTest(cls)); if (!found) return !1; var end = found.index + found[0].length; line[prop] = cur.slice(0, found.index) + (found.index && end != cur.length ? " " : "") + cur.slice(end) || null; } return !0; }); }), addLineWidget: docMethodOp(function(handle, node, options) { var doc, widget, cm; return doc = this, widget = new LineWidget(doc, node, options), (cm = doc.cm) && widget.noHScroll && (cm.display.alignWidgets = !0), changeLine(doc, handle, "widget", function(line) { var widgets = line.widgets || (line.widgets = []); if (null == widget.insertAt ? widgets.push(widget) : widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget), widget.line = line, cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; updateLineHeight(line, line.height + widgetHeight(widget)), aboveVisible && addToScrollTop(cm, widget.height), cm.curOp.forceUpdate = !0; } return !0; }), cm && signalLater(cm, "lineWidgetAdded", cm, widget, "number" == typeof handle ? handle : lineNo(handle)), widget; }), removeLineWidget: function(widget) { widget.clear(); }, markText: function(from, to, options) { return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range"); }, setBookmark: function(pos, options) { var realOpts = { replacedWith: options && (null == options.nodeType ? options.widget : options), insertLeft: options && options.insertLeft, clearWhenEmpty: !1, shared: options && options.shared, handleMouseEvents: options && options.handleMouseEvents }; return markText(this, pos = clipPos(this, pos), pos, realOpts, "bookmark"); }, findMarksAt: function(pos) { pos = clipPos(this, pos); var markers = [], spans = getLine(this, pos.line).markedSpans; if (spans) for(var i = 0; i < spans.length; ++i){ var span = spans[i]; (null == span.from || span.from <= pos.ch) && (null == span.to || span.to >= pos.ch) && markers.push(span.marker.parent || span.marker); } return markers; }, findMarks: function(from, to, filter) { from = clipPos(this, from), to = clipPos(this, to); var found = [], lineNo = from.line; return this.iter(from.line, to.line + 1, function(line) { var spans = line.markedSpans; if (spans) for(var i = 0; i < spans.length; i++){ var span = spans[i]; !(null != span.to && lineNo == from.line && from.ch >= span.to || null == span.from && lineNo != from.line || null != span.from && lineNo == to.line && span.from >= to.ch) && (!filter || filter(span.marker)) && found.push(span.marker.parent || span.marker); } ++lineNo; }), found; }, getAllMarks: function() { var markers = []; return this.iter(function(line) { var sps = line.markedSpans; if (sps) for(var i = 0; i < sps.length; ++i)null != sps[i].from && markers.push(sps[i].marker); }), markers; }, posFromIndex: function(off) { var ch, lineNo = this.first, sepSize = this.lineSeparator().length; return this.iter(function(line) { var sz = line.text.length + sepSize; if (sz > off) return ch = off, !0; off -= sz, ++lineNo; }), clipPos(this, Pos(lineNo, ch)); }, indexFromPos: function(coords) { var index = (coords = clipPos(this, coords)).ch; if (coords.line < this.first || coords.ch < 0) return 0; var sepSize = this.lineSeparator().length; return this.iter(this.first, coords.line, function(line) { // iter aborts when callback returns a truthy value index += line.text.length + sepSize; }), index; }, copy: function(copyHistory) { var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction); return doc.scrollTop = this.scrollTop, doc.scrollLeft = this.scrollLeft, doc.sel = this.sel, doc.extend = !1, copyHistory && (doc.history.undoDepth = this.history.undoDepth, doc.setHistory(this.getHistory())), doc; }, linkedDoc: function(options) { options || (options = {}); var from = this.first, to = this.first + this.size; null != options.from && options.from > from && (from = options.from), null != options.to && options.to < to && (to = options.to); var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction); return options.sharedHist && (copy.history = this.history), (this.linked || (this.linked = [])).push({ doc: copy, sharedHist: options.sharedHist }), copy.linked = [ { doc: this, isParent: !0, sharedHist: options.sharedHist } ], function(doc, markers) { for(var i = 0; i < markers.length; i++){ var marker = markers[i], pos = marker.find(), mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); if (cmp(mFrom, mTo)) { var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); marker.markers.push(subMark), subMark.parent = marker; } } }(copy, findSharedMarkers(this)), copy; }, unlinkDoc: function(other) { if (other instanceof CodeMirror && (other = other.doc), this.linked) { for(var i = 0; i < this.linked.length; ++i)if (this.linked[i].doc == other) { this.linked.splice(i, 1), other.unlinkDoc(this), function(markers) { for(var i = 0; i < markers.length; i++)!function(i) { var marker = markers[i], linked = [ marker.primary.doc ]; linkedDocs(marker.primary.doc, function(d) { return linked.push(d); }); for(var j = 0; j < marker.markers.length; j++){ var subMarker = marker.markers[j]; -1 == indexOf(linked, subMarker.doc) && (subMarker.parent = null, marker.markers.splice(j--, 1)); } }(i); }(findSharedMarkers(this)); break; } } // If the histories were shared, split them again if (other.history == this.history) { var splitIds = [ other.id ]; linkedDocs(other, function(doc) { return splitIds.push(doc.id); }, !0), other.history = new History(null), other.history.done = copyHistoryArray(this.history.done, splitIds), other.history.undone = copyHistoryArray(this.history.undone, splitIds); } }, iterLinkedDocs: function(f) { linkedDocs(this, f); }, getMode: function() { return this.mode; }, getEditor: function() { return this.cm; }, splitLines: function(str) { return this.lineSep ? str.split(this.lineSep) : splitLinesAuto(str); }, lineSeparator: function() { return this.lineSep || "\n"; }, setDirection: docMethodOp(function(dir) { if ("rtl" != dir && (dir = "ltr"), dir != this.direction && (this.direction = dir, this.iter(function(line) { return line.order = null; }), this.cm)) { var cm; runInOp(cm = this.cm, function() { setDirectionClass(cm), regChange(cm); }); } }) }), // Public alias. Doc.prototype.eachLine = Doc.prototype.iter; // Kludge to work around strange IE behavior where it'll sometimes // re-fire a series of drag-related events right after the drop (#1551) var lastDrop = 0; function onDrop(e) { var cm = this; if (clearDragCursor(cm), !(signalDOMEvent(cm, e) || eventInWidget(cm.display, e))) { e_preventDefault(e), ie && (lastDrop = +new Date()); var pos = posFromMouse(cm, e, !0), files = e.dataTransfer.files; if (!(!pos || cm.isReadOnly())) { // Might be a file drop, in which case we simply extract the text // and insert it. if (files && files.length && window.FileReader && window.File) for(var n = files.length, text = Array(n), read = 0, markAsReadAndPasteIfAllFilesAreRead = function() { ++read == n && operation(cm, function() { var change = { from: pos = clipPos(cm.doc, pos), to: pos, text: cm.doc.splitLines(text.filter(function(t) { return null != t; }).join(cm.doc.lineSeparator())), origin: "paste" }; makeChange(cm.doc, change), setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)))); })(); }, readTextFromFile = function(file, i) { if (cm.options.allowDropFileTypes && -1 == indexOf(cm.options.allowDropFileTypes, file.type)) { markAsReadAndPasteIfAllFilesAreRead(); return; } var reader = new FileReader(); reader.onerror = function() { return markAsReadAndPasteIfAllFilesAreRead(); }, reader.onload = function() { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { markAsReadAndPasteIfAllFilesAreRead(); return; } text[i] = content, markAsReadAndPasteIfAllFilesAreRead(); }, reader.readAsText(file); }, i = 0; i < files.length; i++)readTextFromFile(files[i], i); else { // Normal drop // Don't do a replace if the drop happened inside of the selected text. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { cm.state.draggingText(e), // Ensure the editor is re-focused setTimeout(function() { return cm.display.input.focus(); }, 20); return; } try { var selected, text$1 = e.dataTransfer.getData("Text"); if (text$1) { if (cm.state.draggingText && !cm.state.draggingText.copy && (selected = cm.listSelections()), setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)), selected) for(var i$1 = 0; i$1 < selected.length; ++i$1)replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); cm.replaceSelection(text$1, "around", "paste"), cm.display.input.focus(); } } catch (e$1) {} } } } } function clearDragCursor(cm) { cm.display.dragCursor && (cm.display.lineSpace.removeChild(cm.display.dragCursor), cm.display.dragCursor = null); } // These must be handled carefully, because naively registering a // handler for each editor will cause the editors to never be // garbage collected. function forEachCodeMirror(f) { if (document.getElementsByClassName) { for(var byClass = document.getElementsByClassName("CodeMirror"), editors = [], i = 0; i < byClass.length; i++){ var cm = byClass[i].CodeMirror; cm && editors.push(cm); } editors.length && editors[0].operation(function() { for(var i = 0; i < editors.length; i++)f(editors[i]); }); } } var globalsRegistered = !1; // Called when the window resizes function onResize(cm) { var d = cm.display; // Might be a text scaling operation, clear size caches. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null, d.scrollbarsClipped = !1, cm.setSize(); } // Number keys for(var keyNames = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" }, i = 0; i < 10; i++)keyNames[i + 48] = keyNames[i + 96] = String(i); // Alphabetic keys for(var i$1 = 65; i$1 <= 90; i$1++)keyNames[i$1] = String.fromCharCode(i$1); // Function keys for(var i$2 = 1; i$2 <= 12; i$2++)keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; var keyMap = {}; // KEYMAP DISPATCH function normalizeKeyName(name) { var alt, ctrl, shift, cmd, parts = name.split(/-(?!$)/); name = parts[parts.length - 1]; for(var i = 0; i < parts.length - 1; i++){ var mod = parts[i]; if (/^(cmd|meta|m)$/i.test(mod)) cmd = !0; else if (/^a(lt)?$/i.test(mod)) alt = !0; else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = !0; else if (/^s(hift)?$/i.test(mod)) shift = !0; else throw Error("Unrecognized modifier name: " + mod); } return alt && (name = "Alt-" + name), ctrl && (name = "Ctrl-" + name), cmd && (name = "Cmd-" + name), shift && (name = "Shift-" + name), name; } function lookupKey(key, map, handle, context) { var found = (map = getKeyMap(map)).call ? map.call(key, context) : map[key]; if (!1 === found) return "nothing"; if ("..." === found) return "multi"; if (null != found && handle(found)) return "handled"; if (map.fallthrough) { if ("[object Array]" != Object.prototype.toString.call(map.fallthrough)) return lookupKey(key, map.fallthrough, handle, context); for(var i = 0; i < map.fallthrough.length; i++){ var result = lookupKey(key, map.fallthrough[i], handle, context); if (result) return result; } } } // Modifier key presses don't count as 'real' key presses for the // purpose of keymap fallthrough. function isModifierKey(value) { var name = "string" == typeof value ? value : keyNames[value.keyCode]; return "Ctrl" == name || "Alt" == name || "Shift" == name || "Mod" == name; } function addModifierNames(name, event, noShift) { var base = name; return event.altKey && "Alt" != base && (name = "Alt-" + name), (flipCtrlCmd ? event.metaKey : event.ctrlKey) && "Ctrl" != base && (name = "Ctrl-" + name), (flipCtrlCmd ? event.ctrlKey : event.metaKey) && "Mod" != base && (name = "Cmd-" + name), !noShift && event.shiftKey && "Shift" != base && (name = "Shift-" + name), name; } // Look up the name of a key as indicated by an event object. function keyName(event, noShift) { if (presto && 34 == event.keyCode && event.char) return !1; var name = keyNames[event.keyCode]; return null != name && !event.altGraphKey && (3 == event.keyCode && event.code && (name = event.code), addModifierNames(name, event, noShift)); } function getKeyMap(val) { return "string" == typeof val ? keyMap[val] : val; } // Helper for deleting text near the selection(s), used to implement // backspace, delete, and similar functionality. function deleteNearSelection(cm, compute) { // Build up a set of ranges to kill first, merging overlapping // ranges. for(var ranges = cm.doc.sel.ranges, kill = [], i = 0; i < ranges.length; i++){ for(var toKill = compute(ranges[i]); kill.length && 0 >= cmp(toKill.from, lst(kill).to);){ var replaced = kill.pop(); if (0 > cmp(replaced.from, toKill.from)) { toKill.from = replaced.from; break; } } kill.push(toKill); } // Next, remove those actual ranges. runInOp(cm, function() { for(var i = kill.length - 1; i >= 0; i--)replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); ensureCursorVisible(cm); }); } function moveCharLogically(line, ch, dir) { var target = skipExtendingChars(line.text, ch + dir, dir); return target < 0 || target > line.text.length ? null : target; } function moveLogically(line, start, dir) { var ch = moveCharLogically(line, start.ch, dir); return null == ch ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before"); } function endOfLine(visually, cm, lineObj, lineNo, dir) { if (visually) { "rtl" == cm.doc.direction && (dir = -dir); var order = getOrder(lineObj, cm.doc.direction); if (order) { var ch, part = dir < 0 ? lst(order) : order[0], sticky = dir < 0 == (1 == part.level) ? "after" : "before"; // With a wrapped rtl chunk (possibly spanning multiple bidi parts), // it could be that the last bidi part is not on the last visual line, // since visual lines contain content order-consecutive chunks. // Thus, in rtl, we are looking for the first (content-order) character // in the rtl chunk that is on the last line (that is, the same line // as the last (content-order) character). if (part.level > 0 || "rtl" == cm.doc.direction) { var prep = prepareMeasureForLine(cm, lineObj), targetTop = measureCharPrepared(cm, prep, ch = dir < 0 ? lineObj.text.length - 1 : 0).top; ch = findFirst(function(ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, dir < 0 == (1 == part.level) ? part.from : part.to - 1, ch), "before" == sticky && (ch = moveCharLogically(lineObj, ch, 1)); } else ch = dir < 0 ? part.to : part.from; return new Pos(lineNo, ch, sticky); } } return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after"); } keyMap.basic = { Left: "goCharLeft", Right: "goCharRight", Up: "goLineUp", Down: "goLineDown", End: "goLineEnd", Home: "goLineStartSmart", PageUp: "goPageUp", PageDown: "goPageDown", Delete: "delCharAfter", Backspace: "delCharBefore", "Shift-Backspace": "delCharBefore", Tab: "defaultTab", "Shift-Tab": "indentAuto", Enter: "newlineAndIndent", Insert: "toggleOverwrite", Esc: "singleSelection" }, // Note that the save and find-related commands aren't defined by // default. User code or addons can define them. Unknown commands // are simply ignored. keyMap.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", fallthrough: "basic" }, // Very basic readline/emacs-style bindings, which are standard on Mac. keyMap.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine" }, keyMap.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", fallthrough: [ "basic", "emacsy" ] }, keyMap.default = mac ? keyMap.macDefault : keyMap.pcDefault; // Commands are parameter-less actions that can be performed on an // editor, mostly used for keybindings. var commands = { selectAll: selectAll, singleSelection: function(cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); }, killLine: function(cm) { return deleteNearSelection(cm, function(range) { if (!range.empty()) return { from: range.from(), to: range.to() }; var len = getLine(cm.doc, range.head.line).text.length; return range.head.ch == len && range.head.line < cm.lastLine() ? { from: range.head, to: Pos(range.head.line + 1, 0) } : { from: range.head, to: Pos(range.head.line, len) }; }); }, deleteLine: function(cm) { return deleteNearSelection(cm, function(range) { return { from: Pos(range.from().line, 0), to: clipPos(cm.doc, Pos(range.to().line + 1, 0)) }; }); }, delLineLeft: function(cm) { return deleteNearSelection(cm, function(range) { return { from: Pos(range.from().line, 0), to: range.from() }; }); }, delWrappedLineLeft: function(cm) { return deleteNearSelection(cm, function(range) { var top = cm.charCoords(range.head, "div").top + 5; return { from: cm.coordsChar({ left: 0, top: top }, "div"), to: range.from() }; }); }, delWrappedLineRight: function(cm) { return deleteNearSelection(cm, function(range) { var top = cm.charCoords(range.head, "div").top + 5, rightPos = cm.coordsChar({ left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div"); return { from: range.from(), to: rightPos }; }); }, undo: function(cm) { return cm.undo(); }, redo: function(cm) { return cm.redo(); }, undoSelection: function(cm) { return cm.undoSelection(); }, redoSelection: function(cm) { return cm.redoSelection(); }, goDocStart: function(cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); }, goDocEnd: function(cm) { return cm.extendSelection(Pos(cm.lastLine())); }, goLineStart: function(cm) { return cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, { origin: "+move", bias: 1 }); }, goLineStartSmart: function(cm) { return cm.extendSelectionsBy(function(range) { return lineStartSmart(cm, range.head); }, { origin: "+move", bias: 1 }); }, goLineEnd: function(cm) { return cm.extendSelectionsBy(function(range) { var lineN, line, visual; return lineN = range.head.line, (visual = function(line) { for(var merged; merged = collapsedSpanAtSide(line, !1);)line = merged.find(1, !0).line; return line; }(line = getLine(cm.doc, lineN))) != line && (lineN = lineNo(visual)), endOfLine(!0, cm, line, lineN, -1); }, { origin: "+move", bias: -1 }); }, goLineRight: function(cm) { return cm.extendSelectionsBy(function(range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({ left: cm.display.lineDiv.offsetWidth + 100, top: top }, "div"); }, sel_move); }, goLineLeft: function(cm) { return cm.extendSelectionsBy(function(range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({ left: 0, top: top }, "div"); }, sel_move); }, goLineLeftSmart: function(cm) { return cm.extendSelectionsBy(function(range) { var top = cm.cursorCoords(range.head, "div").top + 5, pos = cm.coordsChar({ left: 0, top: top }, "div"); return pos.ch < cm.getLine(pos.line).search(/\S/) ? lineStartSmart(cm, range.head) : pos; }, sel_move); }, goLineUp: function(cm) { return cm.moveV(-1, "line"); }, goLineDown: function(cm) { return cm.moveV(1, "line"); }, goPageUp: function(cm) { return cm.moveV(-1, "page"); }, goPageDown: function(cm) { return cm.moveV(1, "page"); }, goCharLeft: function(cm) { return cm.moveH(-1, "char"); }, goCharRight: function(cm) { return cm.moveH(1, "char"); }, goColumnLeft: function(cm) { return cm.moveH(-1, "column"); }, goColumnRight: function(cm) { return cm.moveH(1, "column"); }, goWordLeft: function(cm) { return cm.moveH(-1, "word"); }, goGroupRight: function(cm) { return cm.moveH(1, "group"); }, goGroupLeft: function(cm) { return cm.moveH(-1, "group"); }, goWordRight: function(cm) { return cm.moveH(1, "word"); }, delCharBefore: function(cm) { return cm.deleteH(-1, "codepoint"); }, delCharAfter: function(cm) { return cm.deleteH(1, "char"); }, delWordBefore: function(cm) { return cm.deleteH(-1, "word"); }, delWordAfter: function(cm) { return cm.deleteH(1, "word"); }, delGroupBefore: function(cm) { return cm.deleteH(-1, "group"); }, delGroupAfter: function(cm) { return cm.deleteH(1, "group"); }, indentAuto: function(cm) { return cm.indentSelection("smart"); }, indentMore: function(cm) { return cm.indentSelection("add"); }, indentLess: function(cm) { return cm.indentSelection("subtract"); }, insertTab: function(cm) { return cm.replaceSelection("\t"); }, insertSoftTab: function(cm) { for(var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize, i = 0; i < ranges.length; i++){ var pos = ranges[i].from(), col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); spaces.push(spaceStr(tabSize - col % tabSize)); } cm.replaceSelections(spaces); }, defaultTab: function(cm) { cm.somethingSelected() ? cm.indentSelection("add") : cm.execCommand("insertTab"); }, // Swap the two chars left and right of each selection's head. // Move cursor behind the two swapped characters afterwards. // // Doesn't consider line feeds a character. // Doesn't scan more than one line above to find a character. // Doesn't do anything on an empty line. // Doesn't do anything with non-empty selections. transposeChars: function(cm) { return runInOp(cm, function() { for(var ranges = cm.listSelections(), newSel = [], i = 0; i < ranges.length; i++)if (ranges[i].empty()) { var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; if (line) { if (cur.ch == line.length && (cur = new Pos(cur.line, cur.ch - 1)), cur.ch > 0) cur = new Pos(cur.line, cur.ch + 1), cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose"); else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; prev && (cur = new Pos(cur.line, 1), cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose")); } } newSel.push(new Range(cur, cur)); } cm.setSelections(newSel); }); }, newlineAndIndent: function(cm) { return runInOp(cm, function() { for(var sels = cm.listSelections(), i = sels.length - 1; i >= 0; i--)cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); sels = cm.listSelections(); for(var i$1 = 0; i$1 < sels.length; i$1++)cm.indentLine(sels[i$1].from().line, null, !0); ensureCursorVisible(cm); }); }, openLine: function(cm) { return cm.replaceSelection("\n", "start"); }, toggleOverwrite: function(cm) { return cm.toggleOverwrite(); } }; function lineStart(cm, lineN) { var line = getLine(cm.doc, lineN), visual = visualLine(line); return visual != line && (lineN = lineNo(visual)), endOfLine(!0, cm, visual, lineN, 1); } function lineStartSmart(cm, pos) { var start = lineStart(cm, pos.line), line = getLine(cm.doc, start.line), order = getOrder(line, cm.doc.direction); if (!order || 0 == order[0].level) { var firstNonWS = Math.max(start.ch, line.text.search(/\S/)), inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky); } return start; } // Run a handler that was bound to a key. function doHandleBinding(cm, bound, dropShift) { if ("string" == typeof bound && !(bound = commands[bound])) return !1; // Ensure previous input has been read, so that the handler sees a // consistent view of the document cm.display.input.ensurePolled(); var prevShift = cm.display.shift, done = !1; try { cm.isReadOnly() && (cm.state.suppressEdits = !0), dropShift && (cm.display.shift = !1), done = bound(cm) != Pass; } finally{ cm.display.shift = prevShift, cm.state.suppressEdits = !1; } return done; } // Note that, despite the name, this function is also used to check // for bound mouse clicks. var stopSeq = new Delayed(); function dispatchKey(cm, name, e, handle) { var seq = cm.state.keySeq; if (seq) { if (isModifierKey(name)) return "handled"; if (/\'$/.test(name) ? cm.state.keySeq = null : stopSeq.set(50, function() { cm.state.keySeq == seq && (cm.state.keySeq = null, cm.display.input.reset()); }), dispatchKeyInner(cm, seq + " " + name, e, handle)) return !0; } return dispatchKeyInner(cm, name, e, handle); } function dispatchKeyInner(cm, name, e, handle) { var result = function(cm, name, handle) { for(var i = 0; i < cm.state.keyMaps.length; i++){ var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); if (result) return result; } return cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm) || lookupKey(name, cm.options.keyMap, handle, cm); }(cm, name, handle); return "multi" == result && (cm.state.keySeq = name), "handled" == result && signalLater(cm, "keyHandled", cm, name, e), ("handled" == result || "multi" == result) && (e_preventDefault(e), restartBlink(cm)), !!result; } // Handle a key from the keydown event. function handleKeyBinding(cm, e) { var name = keyName(e, !0); return !!name && (e.shiftKey && !cm.state.keySeq ? dispatchKey(cm, "Shift-" + name, e, function(b) { return doHandleBinding(cm, b, !0); }) || dispatchKey(cm, name, e, function(b) { if ("string" == typeof b ? /^go[A-Z]/.test(b) : b.motion) return doHandleBinding(cm, b); }) : dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); })); } var lastStoppedKey = null; function onKeyDown(e) { if ((!e.target || e.target == this.display.input.getField()) && (this.curOp.focus = activeElt(), !signalDOMEvent(this, e))) { ie && ie_version < 11 && 27 == e.keyCode && (e.returnValue = !1); var code = e.keyCode; this.display.shift = 16 == code || e.shiftKey; var handled = handleKeyBinding(this, e); presto && (lastStoppedKey = handled ? code : null, !handled && 88 == code && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey) && this.replaceSelection("", null, "cut")), gecko && !mac && !handled && 46 == code && e.shiftKey && !e.ctrlKey && document.execCommand && document.execCommand("cut"), 18 != code || /\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className) || function(cm) { var lineDiv = cm.display.lineDiv; function up(e) { 18 != e.keyCode && e.altKey || (rmClass(lineDiv, "CodeMirror-crosshair"), off(document, "keyup", up), off(document, "mouseover", up)); } addClass(lineDiv, "CodeMirror-crosshair"), on(document, "keyup", up), on(document, "mouseover", up); }(this); } } function onKeyUp(e) { 16 == e.keyCode && (this.doc.sel.shift = !1), signalDOMEvent(this, e); } function onKeyPress(e) { if (!(e.target && e.target != this.display.input.getField() || eventInWidget(this.display, e) || signalDOMEvent(this, e)) && (!e.ctrlKey || e.altKey) && (!mac || !e.metaKey)) { var cm, keyCode = e.keyCode, charCode = e.charCode; if (presto && keyCode == lastStoppedKey) { lastStoppedKey = null, e_preventDefault(e); return; } if (!(presto && (!e.which || e.which < 10) && handleKeyBinding(this, e))) { var ch = String.fromCharCode(null == charCode ? keyCode : charCode); // Some browsers fire keypress events for backspace "\x08" != ch && (cm = this, dispatchKey(cm, "'" + ch + "'", e, function(b) { return doHandleBinding(cm, b, !0); }) || this.display.input.onKeyPress(e)); } } } var PastClick = function(time, pos, button) { this.time = time, this.pos = pos, this.button = button; }; // A mouse down can be a single click, double click, triple click, // start of selection drag, start of text drag, new cursor // (ctrl-click), rectangle drag (alt-drag), or xwin // middle-click-paste. Or it might be a click on something we should // not interfere with, such as a scrollbar or widget. function onMouseDown(e) { var cm, name, now, display = this.display; if (!(signalDOMEvent(this, e) || display.activeTouch && display.input.supportsTouch())) { if (display.input.ensurePolled(), display.shift = e.shiftKey, eventInWidget(display, e)) { webkit || (// Briefly turn off draggability, to allow widgets to do // normal dragging things. display.scroller.draggable = !1, setTimeout(function() { return display.scroller.draggable = !0; }, 100)); return; } if (!clickInGutter(this, e)) { var cm1, display1, moved, dragEnd, mouseMove, dragStart, option, value, contained, sel, pos = posFromMouse(this, e), button = e_button(e), repeat = pos ? (now = +new Date(), lastDoubleClick && lastDoubleClick.compare(now, pos, button) ? (lastClick = lastDoubleClick = null, "triple") : lastClick && lastClick.compare(now, pos, button) ? (lastDoubleClick = new PastClick(now, pos, button), lastClick = null, "double") : (lastClick = new PastClick(now, pos, button), lastDoubleClick = null, "single")) : "single"; window.focus(), 1 == button && this.state.selectingText && this.state.selectingText(e), pos && (cm = this, name = "Click", "double" == repeat ? name = "Double" + name : "triple" == repeat && (name = "Triple" + name), dispatchKey(cm, addModifierNames(name = (1 == button ? "Left" : 2 == button ? "Middle" : "Right") + name, e), e, function(bound) { if ("string" == typeof bound && (bound = commands[bound]), !bound) return !1; var done = !1; try { cm.isReadOnly() && (cm.state.suppressEdits = !0), done = bound(cm, pos) != Pass; } finally{ cm.state.suppressEdits = !1; } return done; })) || (1 == button ? pos ? (cm1 = this, ie ? setTimeout(bind(ensureFocus, cm1), 0) : cm1.curOp.focus = activeElt(), null == (value = (option = cm1.getOption("configureMouse")) ? option(cm1, repeat, e) : {}).unit && (value.unit = (chromeOS ? e.shiftKey && e.metaKey : e.altKey) ? "rectangle" : "single" == repeat ? "char" : "double" == repeat ? "word" : "line"), (null == value.extend || cm1.doc.extend) && (value.extend = cm1.doc.extend || e.shiftKey), null == value.addNew && (value.addNew = mac ? e.metaKey : e.ctrlKey), null == value.moveOnDrag && (value.moveOnDrag = !(mac ? e.altKey : e.ctrlKey)), sel = cm1.doc.sel, cm1.options.dragDrop && dragAndDrop && !cm1.isReadOnly() && "single" == repeat && (contained = sel.contains(pos)) > -1 && (0 > cmp((contained = sel.ranges[contained]).from(), pos) || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0) ? (display1 = cm1.display, moved = !1, dragEnd = operation(cm1, function(e) { webkit && (display1.scroller.draggable = !1), cm1.state.draggingText = !1, cm1.state.delayingBlurEvent && (cm1.hasFocus() ? cm1.state.delayingBlurEvent = !1 : delayBlurEvent(cm1)), off(display1.wrapper.ownerDocument, "mouseup", dragEnd), off(display1.wrapper.ownerDocument, "mousemove", mouseMove), off(display1.scroller, "dragstart", dragStart), off(display1.scroller, "drop", dragEnd), moved || (e_preventDefault(e), value.addNew || extendSelection(cm1.doc, pos, null, null, value.extend), webkit && !safari || ie && 9 == ie_version ? setTimeout(function() { display1.wrapper.ownerDocument.body.focus({ preventScroll: !0 }), display1.input.focus(); }, 20) : display1.input.focus()); }), mouseMove = function(e2) { moved = moved || Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) >= 10; }, dragStart = function() { return moved = !0; }, webkit && (display1.scroller.draggable = !0), cm1.state.draggingText = dragEnd, dragEnd.copy = !value.moveOnDrag, on(display1.wrapper.ownerDocument, "mouseup", dragEnd), on(display1.wrapper.ownerDocument, "mousemove", mouseMove), on(display1.scroller, "dragstart", dragStart), on(display1.scroller, "drop", dragEnd), cm1.state.delayingBlurEvent = !0, setTimeout(function() { return display1.input.focus(); }, 20), display1.scroller.dragDrop && display1.scroller.dragDrop()) : // Normal selection, as opposed to text dragging. function(cm, event, start, behavior) { ie && delayBlurEvent(cm); var display = cm.display, doc = cm.doc; e_preventDefault(event); var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; if (behavior.addNew && !behavior.extend ? ourRange = (ourIndex = doc.sel.contains(start)) > -1 ? ranges[ourIndex] : new Range(start, start) : (ourRange = doc.sel.primary(), ourIndex = doc.sel.primIndex), "rectangle" == behavior.unit) behavior.addNew || (ourRange = new Range(start, start)), start = posFromMouse(cm, event, !0, !0), ourIndex = -1; else { var range = rangeForUnit(cm, start, behavior.unit); ourRange = behavior.extend ? extendRange(ourRange, range.anchor, range.head, behavior.extend) : range; } behavior.addNew ? -1 == ourIndex ? (ourIndex = ranges.length, setSelection(doc, normalizeSelection(cm, ranges.concat([ ourRange ]), ourIndex), { scroll: !1, origin: "*mouse" })) : ranges.length > 1 && ranges[ourIndex].empty() && "char" == behavior.unit && !behavior.extend ? (setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), { scroll: !1, origin: "*mouse" }), startSel = doc.sel) : replaceOneSelection(doc, ourIndex, ourRange, sel_mouse) : (ourIndex = 0, setSelection(doc, new Selection([ ourRange ], 0), sel_mouse), startSel = doc.sel); var lastPos = start, editorSize = display.wrapper.getBoundingClientRect(), counter = 0; function done(e) { cm.state.selectingText = !1, counter = 1 / 0, e && (e_preventDefault(e), display.input.focus()), off(display.wrapper.ownerDocument, "mousemove", move), off(display.wrapper.ownerDocument, "mouseup", up), doc.history.lastSelOrigin = null; } var move = operation(cm, function(e) { 0 !== e.buttons && e_button(e) ? function extend(e) { var curCount = ++counter, cur = posFromMouse(cm, e, !0, "rectangle" == behavior.unit); if (cur) { if (0 != cmp(cur, lastPos)) { cm.curOp.focus = activeElt(), function(pos) { if (0 != cmp(lastPos, pos)) { if (lastPos = pos, "rectangle" == behavior.unit) { for(var ranges = [], tabSize = cm.options.tabSize, startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize), posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize), left = Math.min(startCol, posCol), right = Math.max(startCol, posCol), line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++){ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); left == right ? ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) : text.length > leftPos && ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } ranges.length || ranges.push(new Range(start, start)), setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), { origin: "*mouse", scroll: !1 }), cm.scrollIntoView(pos); } else { var head, oldRange = ourRange, range = rangeForUnit(cm, pos, behavior.unit), anchor = oldRange.anchor; cmp(range.anchor, anchor) > 0 ? (head = range.head, anchor = minPos(oldRange.from(), range.anchor)) : (head = range.anchor, anchor = maxPos(oldRange.to(), range.head)); var ranges$1 = startSel.ranges.slice(0); ranges$1[ourIndex] = // Used when mouse-selecting to adjust the anchor to the proper side // of a bidi jump depending on the visual position of the head. function(cm, range) { var leftSide, anchor = range.anchor, head = range.head, anchorLine = getLine(cm.doc, anchor.line); if (0 == cmp(anchor, head) && anchor.sticky == head.sticky) return range; var order = getOrder(anchorLine); if (!order) return range; var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]; if (part.from != anchor.ch && part.to != anchor.ch) return range; var boundary = index + +(part.from == anchor.ch != (1 != part.level)); if (0 == boundary || boundary == order.length) return range; if (head.line != anchor.line) leftSide = (head.line - anchor.line) * ("ltr" == cm.doc.direction ? 1 : -1) > 0; else { var headIndex = getBidiPartAt(order, head.ch, head.sticky), dir = headIndex - index || (head.ch - anchor.ch) * (1 == part.level ? -1 : 1); leftSide = headIndex == boundary - 1 || headIndex == boundary ? dir < 0 : dir > 0; } var usePart = order[boundary + (leftSide ? -1 : 0)], from = leftSide == (1 == usePart.level), ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"; return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head); }(cm, new Range(clipPos(doc, anchor), head)), setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse); } } }(cur); var visible = visibleLines(display, doc); (cur.line >= visible.to || cur.line < visible.from) && setTimeout(operation(cm, function() { counter == curCount && extend(e); }), 150); } else { var outside = e.clientY < editorSize.top ? -20 : 20 * (e.clientY > editorSize.bottom); outside && setTimeout(operation(cm, function() { counter == curCount && (display.scroller.scrollTop += outside, extend(e)); }), 50); } } }(e) : done(e); }), up = operation(cm, done); cm.state.selectingText = up, on(display.wrapper.ownerDocument, "mousemove", move), on(display.wrapper.ownerDocument, "mouseup", up); }(cm1, e, pos, value)) : e_target(e) == display.scroller && e_preventDefault(e) : 2 == button ? (pos && extendSelection(this.doc, pos), setTimeout(function() { return display.input.focus(); }, 20)) : 3 == button && (captureRightClick ? this.display.input.onContextMenu(e) : delayBlurEvent(this))); } } } function rangeForUnit(cm, pos, unit) { if ("char" == unit) return new Range(pos, pos); if ("word" == unit) return cm.findWordAt(pos); if ("line" == unit) return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); var result = unit(cm, pos); return new Range(result.from, result.to); } // Determines whether an event happened in the gutter, and fires the // handlers for the corresponding event. function gutterEvent(cm, e, type, prevent) { if (e.touches) mX = e.touches[0].clientX, mY = e.touches[0].clientY; else try { mX = e.clientX, mY = e.clientY; } catch (e$1) { return !1; } if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return !1; prevent && e_preventDefault(e); var mX, mY, display = cm.display, lineBox = display.lineDiv.getBoundingClientRect(); if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e); mY -= lineBox.top - display.viewOffset; for(var i = 0; i < cm.display.gutterSpecs.length; ++i){ var g = display.gutters.childNodes[i]; if (g && g.getBoundingClientRect().right >= mX) { var line = lineAtHeight(cm.doc, mY), gutter = cm.display.gutterSpecs[i]; return signal(cm, type, cm, line, gutter.className, e), e_defaultPrevented(e); } } } function clickInGutter(cm, e) { return gutterEvent(cm, e, "gutterClick", !0); } // CONTEXT MENU HANDLING // To make the context menu work, we need to briefly unhide the // textarea (making it as unobtrusive as possible) to let the // right-click take effect on it. function onContextMenu(cm, e) { !(eventInWidget(cm.display, e) || hasHandler(cm, "gutterContextMenu") && gutterEvent(cm, e, "gutterContextMenu", !1) || signalDOMEvent(cm, e, "contextmenu")) && (captureRightClick || cm.display.input.onContextMenu(e)); } function themeChanged(cm) { cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"), clearCaches(cm); } PastClick.prototype.compare = function(time, pos, button) { return this.time + 400 > time && 0 == cmp(pos, this.pos) && button == this.button; }; var Init = { toString: function() { return "CodeMirror.Init"; } }, defaults = {}, optionHandlers1 = {}; function dragDropChanged(cm, value, old) { if (!value != !(old && old != Init)) { var funcs = cm.display.dragFunctions, toggle = value ? on : off; toggle(cm.display.scroller, "dragstart", funcs.start), toggle(cm.display.scroller, "dragenter", funcs.enter), toggle(cm.display.scroller, "dragover", funcs.over), toggle(cm.display.scroller, "dragleave", funcs.leave), toggle(cm.display.scroller, "drop", funcs.drop); } } function wrappingChanged(cm) { cm.options.lineWrapping ? (addClass(cm.display.wrapper, "CodeMirror-wrap"), cm.display.sizer.style.minWidth = "", cm.display.sizerWidth = null) : (rmClass(cm.display.wrapper, "CodeMirror-wrap"), findMaxLine(cm)), estimateLineHeights(cm), regChange(cm), clearCaches(cm), setTimeout(function() { return updateScrollbars(cm); }, 100); } // A CodeMirror instance represents an editor. This is the object // that user code is usually dealing with. function CodeMirror(place, options) { var this$1 = this; if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); this.options = options = options ? copyObj(options) : {}, // Determine effective options based on given values and defaults. copyObj(defaults, options, !1); var doc = options.value; "string" == typeof doc ? doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction) : options.mode && (doc.modeOption = options.mode), this.doc = doc; var input = new CodeMirror.inputStyles[options.inputStyle](this), display = this.display = new Display(place, doc, input, options); for(var opt in display.wrapper.CodeMirror = this, themeChanged(this), options.lineWrapping && (this.display.wrapper.className += " CodeMirror-wrap"), initScrollbars(this), this.state = { keyMaps: [], overlays: [], modeGen: 0, overwrite: !1, delayingBlurEvent: !1, focused: !1, suppressEdits: !1, pasteIncoming: -1, cutIncoming: -1, selectingText: !1, draggingText: !1, highlight: new Delayed(), keySeq: null, specialChars: null }, options.autofocus && !mobile && display.input.focus(), ie && ie_version < 11 && setTimeout(function() { return this$1.display.input.reset(!0); }, 20), // Attach the necessary event handlers when initializing the editor function(cm) { var d = cm.display; on(d.scroller, "mousedown", operation(cm, onMouseDown)), ie && ie_version < 11 ? on(d.scroller, "dblclick", operation(cm, function(e) { if (!signalDOMEvent(cm, e)) { var pos = posFromMouse(cm, e); if (!(!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e))) { e_preventDefault(e); var word = cm.findWordAt(pos); extendSelection(cm.doc, word.anchor, word.head); } } })) : on(d.scroller, "dblclick", function(e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }), // Some browsers fire contextmenu *after* opening the menu, at // which point we can't mess with it anymore. Context menu is // handled in onMouseDown for these browsers. on(d.scroller, "contextmenu", function(e) { return onContextMenu(cm, e); }), on(d.input.getField(), "contextmenu", function(e) { d.scroller.contains(e.target) || onContextMenu(cm, e); }); // Used to suppress mouse event handling when a touch happens var touchFinished, prevTouch = { end: 0 }; function finishTouch() { d.activeTouch && (touchFinished = setTimeout(function() { return d.activeTouch = null; }, 1000), (prevTouch = d.activeTouch).end = +new Date()); } function farAway(touch, other) { if (null == other.left) return !0; var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 400; } on(d.scroller, "touchstart", function(e) { if (!signalDOMEvent(cm, e) && !function(e) { if (1 != e.touches.length) return !1; var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1; }(e) && !clickInGutter(cm, e)) { d.input.ensurePolled(), clearTimeout(touchFinished); var now = +new Date(); d.activeTouch = { start: now, moved: !1, prev: now - prevTouch.end <= 300 ? prevTouch : null }, 1 == e.touches.length && (d.activeTouch.left = e.touches[0].pageX, d.activeTouch.top = e.touches[0].pageY); } }), on(d.scroller, "touchmove", function() { d.activeTouch && (d.activeTouch.moved = !0); }), on(d.scroller, "touchend", function(e) { var touch = d.activeTouch; if (touch && !eventInWidget(d, e) && null != touch.left && !touch.moved && new Date() - touch.start < 300) { var range, pos = cm.coordsChar(d.activeTouch, "page"); // Single tap range = !touch.prev || farAway(touch, touch.prev) ? new Range(pos, pos) : !touch.prev.prev || farAway(touch, touch.prev.prev) ? cm.findWordAt(pos) : new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))), cm.setSelection(range.anchor, range.head), cm.focus(), e_preventDefault(e); } finishTouch(); }), on(d.scroller, "touchcancel", finishTouch), // Sync scrolling between fake scrollbars and real scrollable // area, ensure viewport is updated when scrolling. on(d.scroller, "scroll", function() { d.scroller.clientHeight && (updateScrollTop(cm, d.scroller.scrollTop), setScrollLeft(cm, d.scroller.scrollLeft, !0), signal(cm, "scroll", cm)); }), // Listen to wheel events in order to try and update the viewport on time. on(d.scroller, "mousewheel", function(e) { return onScrollWheel(cm, e); }), on(d.scroller, "DOMMouseScroll", function(e) { return onScrollWheel(cm, e); }), // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function() { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }), d.dragFunctions = { enter: function(e) { signalDOMEvent(cm, e) || e_stop(e); }, over: function(e) { signalDOMEvent(cm, e) || (function(cm, e) { var pos = posFromMouse(cm, e); if (pos) { var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag), cm.display.dragCursor || (cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors"), cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)), removeChildrenAndAdd(cm.display.dragCursor, frag); } }(cm, e), e_stop(e)); }, start: function(e) { return function(cm, e) { if (ie && (!cm.state.draggingText || +new Date() - lastDrop < 100)) { e_stop(e); return; } if (!(signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) && (e.dataTransfer.setData("Text", cm.getSelection()), e.dataTransfer.effectAllowed = "copyMove", e.dataTransfer.setDragImage && !safari)) { var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", presto && (img.width = img.height = 1, cm.display.wrapper.appendChild(img), // Force a relayout, or Opera won't use our image for some obscure reason img._top = img.offsetTop), e.dataTransfer.setDragImage(img, 0, 0), presto && img.parentNode.removeChild(img); } }(cm, e); }, drop: operation(cm, onDrop), leave: function(e) { signalDOMEvent(cm, e) || clearDragCursor(cm); } }; var inp = d.input.getField(); on(inp, "keyup", function(e) { return onKeyUp.call(cm, e); }), on(inp, "keydown", operation(cm, onKeyDown)), on(inp, "keypress", operation(cm, onKeyPress)), on(inp, "focus", function(e) { return onFocus(cm, e); }), on(inp, "blur", function(e) { return onBlur(cm, e); }); }(this), !function() { if (!globalsRegistered) { // When the window resizes, we need to refresh active editors. var resizeTimer; on(window, "resize", function() { null == resizeTimer && (resizeTimer = setTimeout(function() { resizeTimer = null, forEachCodeMirror(onResize); }, 100)); }), // When the window loses focus, we want to show the editor as blurred on(window, "blur", function() { return forEachCodeMirror(onBlur); }), globalsRegistered = !0; } }(), startOperation(this), this.curOp.forceUpdate = !0, attachDoc(this, doc), options.autofocus && !mobile || this.hasFocus() ? setTimeout(function() { this$1.hasFocus() && !this$1.state.focused && onFocus(this$1); }, 20) : onBlur(this), optionHandlers1)optionHandlers1.hasOwnProperty(opt) && optionHandlers1[opt](this, options[opt], Init); maybeUpdateLineNumberWidth(this), options.finishInit && options.finishInit(this); for(var i = 0; i < initHooks.length; ++i)initHooks[i](this); endOperation(this), webkit && options.lineWrapping && "optimizelegibility" == getComputedStyle(display.lineDiv).textRendering && (display.lineDiv.style.textRendering = "auto"); } // The default configuration options. CodeMirror.defaults = defaults, // Functions to run when options are changed. CodeMirror.optionHandlers = optionHandlers1; var initHooks = []; // Indent the given line. The how parameter can be "smart", // "add"/null, "subtract", or "prev". When aggressive is false // (typically set to true for forced single-line indents), empty // lines are not indented, and places where the mode returns Pass // are left alone. function indentLine(cm, n, how, aggressive) { var state, doc = cm.doc; null == how && (how = "add"), "smart" == how && (doc.mode.indent ? state = getContextBefore(cm, n).state : how = "prev"); var tabSize = cm.options.tabSize, line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); line.stateAfter && (line.stateAfter = null); var indentation, curSpaceString = line.text.match(/^\s*/)[0]; if (aggressive || /\S/.test(line.text)) { if ("smart" == how && ((indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)) == Pass || indentation > 150)) { if (!aggressive) return; how = "prev"; } } else indentation = 0, how = "not"; "prev" == how ? indentation = n > doc.first ? countColumn(getLine(doc, n - 1).text, null, tabSize) : 0 : "add" == how ? indentation = curSpace + cm.options.indentUnit : "subtract" == how ? indentation = curSpace - cm.options.indentUnit : "number" == typeof how && (indentation = curSpace + how), indentation = Math.max(0, indentation); var indentString = "", pos = 0; if (cm.options.indentWithTabs) for(var i = Math.floor(indentation / tabSize); i; --i)pos += tabSize, indentString += "\t"; if (pos < indentation && (indentString += spaceStr(indentation - pos)), indentString != curSpaceString) return replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"), line.stateAfter = null, !0; // Ensure that, if the cursor was in the whitespace at the start // of the line, it is moved to the end of that space. for(var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++){ var range = doc.sel.ranges[i$1]; if (range.head.line == n && range.head.ch < curSpaceString.length) { var pos$1 = Pos(n, curSpaceString.length); replaceOneSelection(doc, i$1, new Range(pos$1, pos$1)); break; } } } CodeMirror.defineInitHook = function(f) { return initHooks.push(f); }; // This will be set to a {lineWise: bool, text: [string]} object, so // that, when pasting, we know what kind of selections the copied // text was made out of. var lastCopied = null; function applyTextInput(cm, inserted, deleted, sel, origin) { var doc = cm.doc; cm.display.shift = !1, sel || (sel = doc.sel); var recent = +new Date() - 200, paste = "paste" == origin || cm.state.pasteIncoming > recent, textLines = splitLinesAuto(inserted), multiPaste = null; // When pasting N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { if (lastCopied && lastCopied.text.join("\n") == inserted) { if (sel.ranges.length % lastCopied.text.length == 0) { multiPaste = []; for(var i = 0; i < lastCopied.text.length; i++)multiPaste.push(doc.splitLines(lastCopied.text[i])); } } else textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection && (multiPaste = map(textLines, function(l) { return [ l ]; })); } // Normal behavior is to insert the new text into every selection for(var updateInput = cm.curOp.updateInput, i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--){ var range = sel.ranges[i$1], from = range.from(), to = range.to(); range.empty() && (deleted && deleted > 0 ? // Handle deletion from = Pos(from.line, from.ch - deleted) : cm.state.overwrite && !paste ? // Handle overwrite to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) : paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n") && (from = to = Pos(from.line, 0))); var changeEvent = { from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines, origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input") }; makeChange(cm.doc, changeEvent), signalLater(cm, "inputRead", cm, changeEvent); } inserted && !paste && triggerElectric(cm, inserted), ensureCursorVisible(cm), cm.curOp.updateInput < 2 && (cm.curOp.updateInput = updateInput), cm.curOp.typing = !0, cm.state.pasteIncoming = cm.state.cutIncoming = -1; } function handlePaste(e, cm) { var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) return e.preventDefault(), cm.isReadOnly() || cm.options.disableInput || runInOp(cm, function() { return applyTextInput(cm, pasted, 0, null, "paste"); }), !0; } function triggerElectric(cm, inserted) { // When an 'electric' character is inserted, immediately trigger a reindent if (cm.options.electricChars && cm.options.smartIndent) for(var sel = cm.doc.sel, i = sel.ranges.length - 1; i >= 0; i--){ var range = sel.ranges[i]; if (!(range.head.ch > 100) && (!i || sel.ranges[i - 1].head.line != range.head.line)) { var mode = cm.getModeAt(range.head), indented = !1; if (mode.electricChars) { for(var j = 0; j < mode.electricChars.length; j++)if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { indented = indentLine(cm, range.head.line, "smart"); break; } } else mode.electricInput && mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)) && (indented = indentLine(cm, range.head.line, "smart")); indented && signalLater(cm, "electricInput", cm, range.head.line); } } } function copyableRanges(cm) { for(var text = [], ranges = [], i = 0; i < cm.doc.sel.ranges.length; i++){ var line = cm.doc.sel.ranges[i].head.line, lineRange = { anchor: Pos(line, 0), head: Pos(line + 1, 0) }; ranges.push(lineRange), text.push(cm.getRange(lineRange.anchor, lineRange.head)); } return { text: text, ranges: ranges }; } function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { field.setAttribute("autocorrect", autocorrect ? "" : "off"), field.setAttribute("autocapitalize", autocapitalize ? "" : "off"), field.setAttribute("spellcheck", !!spellcheck); } function hiddenTextarea() { var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none"), div = elt("div", [ te ], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); return webkit ? te.style.width = "1000px" : te.setAttribute("wrap", "off"), ios && (te.style.border = "1px solid black"), disableBrowserMagic(te), div; } // Used for horizontal relative motion. Dir is -1 or 1 (left or // right), unit can be "codepoint", "char", "column" (like char, but // doesn't cross line boundaries), "word" (across next word), or // "group" (to the start of next group of word or // non-word-non-whitespace chars). The visually param controls // whether, in right-to-left text, direction 1 means to move towards // the next index in the string, or towards the character to the right // of the current position. The resulting position will have a // hitSide=true property if it reached the end of the document. function findPosH(doc, pos, dir, unit, visually) { var oldPos = pos, origDir = dir, lineObj = getLine(doc, pos.line), lineDir = visually && "rtl" == doc.direction ? -dir : dir; function moveOnce(boundToLine) { if ("codepoint" == unit) { var next, l, ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1)); if (isNaN(ch)) next = null; else { var astral = dir > 0 ? ch >= 0xd800 && ch < 0xdc00 : ch >= 0xdc00 && ch < 0xdfff; next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir); } } else next = visually ? function(cm, line, start, dir) { var prep, bidi = getOrder(line, cm.doc.direction); if (!bidi) return moveLogically(line, start, dir); start.ch >= line.text.length ? (start.ch = line.text.length, start.sticky = "before") : start.ch <= 0 && (start.ch = 0, start.sticky = "after"); var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]; if ("ltr" == cm.doc.direction && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines, // nothing interesting happens. return moveLogically(line, start, dir); var mv = function(pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }, getWrappedLineExtent = function(ch) { return cm.options.lineWrapping ? (prep = prep || prepareMeasureForLine(cm, line), wrappedLineExtentChar(cm, line, prep, ch)) : { begin: 0, end: line.text.length }; }, wrappedLineExtent = getWrappedLineExtent("before" == start.sticky ? mv(start, -1) : start.ch); if ("rtl" == cm.doc.direction || 1 == part.level) { var moveInStorageOrder = 1 == part.level == dir < 0, ch = mv(start, moveInStorageOrder ? 1 : -1); if (null != ch && (moveInStorageOrder ? ch <= part.to && ch <= wrappedLineExtent.end : ch >= part.from && ch >= wrappedLineExtent.begin)) return new Pos(start.line, ch, moveInStorageOrder ? "before" : "after"); } // Case 3: Could not move within this bidi part in this visual line, so leave // the current bidi part var searchInVisualLine = function(partPos, dir, wrappedLineExtent) { for(; partPos >= 0 && partPos < bidi.length; partPos += dir){ var ch, part = bidi[partPos], moveInStorageOrder = dir > 0 == (1 != part.level), ch1 = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); if (part.from <= ch1 && ch1 < part.to || (ch1 = moveInStorageOrder ? part.from : mv(part.to, -1), wrappedLineExtent.begin <= ch1 && ch1 < wrappedLineExtent.end)) return ch = ch1, moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after"); } }, res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent); if (res) return res; // Case 3b: Look for other bidi parts on the next visual line var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1); return null != nextCh && !(dir > 0 && nextCh == line.text.length) && (res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh))) ? res : null; }(doc.cm, lineObj, pos, dir) : moveLogically(lineObj, pos, dir); if (null == next) { if (!(!boundToLine && !((l = pos.line + lineDir) < doc.first) && !(l >= doc.first + doc.size) && (pos = new Pos(l, pos.ch, pos.sticky), lineObj = getLine(doc, l)))) return !1; pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); } else pos = next; return !0; } if ("char" == unit || "codepoint" == unit) moveOnce(); else if ("column" == unit) moveOnce(!0); else if ("word" == unit || "group" == unit) for(var sawType = null, group = "group" == unit, helper = doc.cm && doc.cm.getHelper(pos, "wordChars"), first = !0; !(dir < 0) || moveOnce(!first); first = !1){ var cur = lineObj.text.charAt(pos.ch) || "\n", type = isWordChar(cur, helper) ? "w" : group && "\n" == cur ? "n" : !group || /\s/.test(cur) ? null : "p"; if (!group || first || type || (type = "s"), sawType && sawType != type) { dir < 0 && (dir = 1, moveOnce(), pos.sticky = "after"); break; } if (type && (sawType = type), dir > 0 && !moveOnce(!first)) break; } var result = skipAtomic(doc, pos, oldPos, origDir, !0); return equalCursorPos(oldPos, result) && (result.hitSide = !0), result; } // For relative vertical movement. Dir may be -1 or 1. Unit can be // "page" or "line". The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosV(cm, pos, dir, unit) { var target, y, doc = cm.doc, x = pos.left; if ("page" == unit) { var moveAmount = Math.max(Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight) - 0.5 * textHeight(cm.display), 3); y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; } else "line" == unit && (y = dir > 0 ? pos.bottom + 3 : pos.top - 3); for(; (target = coordsChar(cm, x, y)).outside;){ if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = !0; break; } y += 5 * dir; } return target; } // CONTENTEDITABLE INPUT STYLE var ContentEditableInput = function(cm) { this.cm = cm, this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null, this.polling = new Delayed(), this.composing = null, this.gracePeriod = !1, this.readDOMTimeout = null; }; function posToDOM(cm, pos) { var view = findViewForLine(cm, pos.line); if (!view || view.hidden) return null; var line = getLine(cm.doc, pos.line), info = mapFromLineView(view, line, pos.line), order = getOrder(line, cm.doc.direction), side = "left"; order && (side = getBidiPartAt(order, pos.ch) % 2 ? "right" : "left"); var result = nodeAndOffsetInLineMap(info.map, pos.ch, side); return result.offset = "right" == result.collapse ? result.end : result.start, result; } function badPos(pos, bad) { return bad && (pos.bad = !0), pos; } function domToPos(cm, node, offset) { var lineNode; if (node == cm.display.lineDiv) { if (!(lineNode = cm.display.lineDiv.childNodes[offset])) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), !0); node = null, offset = 0; } else for(lineNode = node;; lineNode = lineNode.parentNode){ if (!lineNode || lineNode == cm.display.lineDiv) return null; if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break; } for(var i = 0; i < cm.display.view.length; i++){ var lineView = cm.display.view[i]; if (lineView.node == lineNode) return function(lineView, node, offset) { var wrapper = lineView.text.firstChild, bad = !1; if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), !0); if (node == wrapper && (bad = !0, node = wrapper.childNodes[offset], offset = 0, !node)) { var line = lineView.rest ? lst(lineView.rest) : lineView.line; return badPos(Pos(lineNo(line), line.text.length), bad); } var textNode = 3 == node.nodeType ? node : null, topNode = node; for(!textNode && 1 == node.childNodes.length && 3 == node.firstChild.nodeType && (textNode = node.firstChild, offset && (offset = textNode.nodeValue.length)); topNode.parentNode != wrapper;)topNode = topNode.parentNode; var measure = lineView.measure, maps = measure.maps; function find(textNode, topNode, offset) { for(var i = -1; i < (maps ? maps.length : 0); i++)for(var map = i < 0 ? measure.map : maps[i], j = 0; j < map.length; j += 3){ var curNode = map[j + 2]; if (curNode == textNode || curNode == topNode) { var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]), ch = map[j] + offset; return (offset < 0 || curNode != textNode) && (ch = map[j + +!!offset]), Pos(line, ch); } } } var found = find(textNode, topNode, offset); if (found) return badPos(found, bad); // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems for(var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling){ if (found = find(after, after.firstChild, 0)) return badPos(Pos(found.line, found.ch - dist), bad); dist += after.textContent.length; } for(var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling){ if (found = find(before, before.firstChild, -1)) return badPos(Pos(found.line, found.ch + dist$1), bad); dist$1 += before.textContent.length; } }(lineView, node, offset); } } ContentEditableInput.prototype.init = function(display) { var this$1 = this, input = this, cm = input.cm, div = input.div = display.lineDiv; function belongsToInput(e) { for(var t = e.target; t; t = t.parentNode){ if (t == div) return !0; if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) break; } return !1; } function onCopyCut(e) { if (!(!belongsToInput(e) || signalDOMEvent(cm, e))) { if (cm.somethingSelected()) lastCopied = { lineWise: !1, text: cm.getSelections() }, "cut" == e.type && cm.replaceSelection("", null, "cut"); else { if (!cm.options.lineWiseCopyCut) return; var ranges = copyableRanges(cm); lastCopied = { lineWise: !0, text: ranges.text }, "cut" == e.type && cm.operation(function() { cm.setSelections(ranges.ranges, 0, sel_dontScroll), cm.replaceSelection("", null, "cut"); }); } if (e.clipboardData) { e.clipboardData.clearData(); var content = lastCopied.text.join("\n"); if (// iOS exposes the clipboard API, but seems to discard content inserted into it e.clipboardData.setData("Text", content), e.clipboardData.getData("Text") == content) { e.preventDefault(); return; } } // Old-fashioned briefly-focus-a-textarea hack var kludge = hiddenTextarea(), te = kludge.firstChild; cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild), te.value = lastCopied.text.join("\n"); var hadFocus = activeElt(); selectInput(te), setTimeout(function() { cm.display.lineSpace.removeChild(kludge), hadFocus.focus(), hadFocus == div && input.showPrimarySelection(); }, 50); } } div.contentEditable = !0, disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize), on(div, "paste", function(e) { !(!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) && ie_version <= 11 && setTimeout(operation(cm, function() { return this$1.updateFromDOM(); }), 20); }), on(div, "compositionstart", function(e) { this$1.composing = { data: e.data, done: !1 }; }), on(div, "compositionupdate", function(e) { this$1.composing || (this$1.composing = { data: e.data, done: !1 }); }), on(div, "compositionend", function(e) { this$1.composing && (e.data != this$1.composing.data && this$1.readFromDOMSoon(), this$1.composing.done = !0); }), on(div, "touchstart", function() { return input.forceCompositionEnd(); }), on(div, "input", function() { this$1.composing || this$1.readFromDOMSoon(); }), on(div, "copy", onCopyCut), on(div, "cut", onCopyCut); }, ContentEditableInput.prototype.screenReaderLabelChanged = function(label) { // Label for screenreaders, accessibility label ? this.div.setAttribute("aria-label", label) : this.div.removeAttribute("aria-label"); }, ContentEditableInput.prototype.prepareSelection = function() { var result = prepareSelection(this.cm, !1); return result.focus = activeElt() == this.div, result; }, ContentEditableInput.prototype.showSelection = function(info, takeFocus) { info && this.cm.display.view.length && ((info.focus || takeFocus) && this.showPrimarySelection(), this.showMultipleSelections(info)); }, ContentEditableInput.prototype.getSelection = function() { return this.cm.display.wrapper.ownerDocument.getSelection(); }, ContentEditableInput.prototype.showPrimarySelection = function() { var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(), from = prim.from(), to = prim.to(); if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) { sel.removeAllRanges(); return; } var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset), curFocus = domToPos(cm, sel.focusNode, sel.focusOffset); if (!curAnchor || curAnchor.bad || !curFocus || curFocus.bad || 0 != cmp(minPos(curAnchor, curFocus), from) || 0 != cmp(maxPos(curAnchor, curFocus), to)) { var view = cm.display.view, start = from.line >= cm.display.viewFrom && posToDOM(cm, from) || { node: view[0].measure.map[2], offset: 0 }, end = to.line < cm.display.viewTo && posToDOM(cm, to); if (!end) { var measure = view[view.length - 1].measure, map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; end = { node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3] }; } if (!start || !end) { sel.removeAllRanges(); return; } var rng, old = sel.rangeCount && sel.getRangeAt(0); try { rng = range(start.node, start.offset, end.offset, end.node); } catch (e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible rng && (!gecko && cm.state.focused ? (sel.collapse(start.node, start.offset), rng.collapsed || (sel.removeAllRanges(), sel.addRange(rng))) : (sel.removeAllRanges(), sel.addRange(rng)), old && null == sel.anchorNode ? sel.addRange(old) : gecko && this.startGracePeriod()), this.rememberSelection(); } }, ContentEditableInput.prototype.startGracePeriod = function() { var this$1 = this; clearTimeout(this.gracePeriod), this.gracePeriod = setTimeout(function() { this$1.gracePeriod = !1, this$1.selectionChanged() && this$1.cm.operation(function() { return this$1.cm.curOp.selectionChanged = !0; }); }, 20); }, ContentEditableInput.prototype.showMultipleSelections = function(info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors), removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); }, ContentEditableInput.prototype.rememberSelection = function() { var sel = this.getSelection(); this.lastAnchorNode = sel.anchorNode, this.lastAnchorOffset = sel.anchorOffset, this.lastFocusNode = sel.focusNode, this.lastFocusOffset = sel.focusOffset; }, ContentEditableInput.prototype.selectionInEditor = function() { var sel = this.getSelection(); if (!sel.rangeCount) return !1; var node = sel.getRangeAt(0).commonAncestorContainer; return contains(this.div, node); }, ContentEditableInput.prototype.focus = function() { "nocursor" != this.cm.options.readOnly && (this.selectionInEditor() && activeElt() == this.div || this.showSelection(this.prepareSelection(), !0), this.div.focus()); }, ContentEditableInput.prototype.blur = function() { this.div.blur(); }, ContentEditableInput.prototype.getField = function() { return this.div; }, ContentEditableInput.prototype.supportsTouch = function() { return !0; }, ContentEditableInput.prototype.receivedFocus = function() { var this$1 = this, input = this; this.selectionInEditor() ? setTimeout(function() { return this$1.pollSelection(); }, 20) : runInOp(this.cm, function() { return input.cm.curOp.selectionChanged = !0; }), this.polling.set(this.cm.options.pollInterval, function poll() { input.cm.state.focused && (input.pollSelection(), input.polling.set(input.cm.options.pollInterval, poll)); }); }, ContentEditableInput.prototype.selectionChanged = function() { var sel = this.getSelection(); return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset; }, ContentEditableInput.prototype.pollSelection = function() { if (null == this.readDOMTimeout && !this.gracePeriod && this.selectionChanged()) { var sel = this.getSelection(), cm = this.cm; // On Android Chrome (version 56, at least), backspacing into an // uneditable block element will put the cursor in that element, // and then, because it's not editable, hide the virtual keyboard. // Because Android doesn't allow us to actually detect backspace // presses in a sane way, this code checks for when that happens // and simulates a backspace press in this case. if (android && chrome && this.cm.display.gutterSpecs.length && function(node) { for(var scan = node; scan; scan = scan.parentNode)if (/CodeMirror-gutter-wrapper/.test(scan.className)) return !0; return !1; }(sel.anchorNode)) { this.cm.triggerOnKeyDown({ type: "keydown", keyCode: 8, preventDefault: Math.abs }), this.blur(), this.focus(); return; } if (!this.composing) { this.rememberSelection(); var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset), head = domToPos(cm, sel.focusNode, sel.focusOffset); anchor && head && runInOp(cm, function() { setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll), (anchor.bad || head.bad) && (cm.curOp.selectionChanged = !0); }); } } }, ContentEditableInput.prototype.pollContent = function() { null != this.readDOMTimeout && (clearTimeout(this.readDOMTimeout), this.readDOMTimeout = null); var fromIndex, fromLine, fromNode, toLine, toNode, cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(), from = sel.from(), to = sel.to(); if (0 == from.ch && from.line > cm.firstLine() && (from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length)), to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine() && (to = Pos(to.line + 1, 0)), from.line < display.viewFrom || to.line > display.viewTo - 1) return !1; from.line == display.viewFrom || 0 == (fromIndex = findViewIndex(cm, from.line)) ? (fromLine = lineNo(display.view[0].line), fromNode = display.view[0].node) : (fromLine = lineNo(display.view[fromIndex].line), fromNode = display.view[fromIndex - 1].node.nextSibling); var toIndex = findViewIndex(cm, to.line); if (toIndex == display.view.length - 1 ? (toLine = display.viewTo - 1, toNode = display.lineDiv.lastChild) : (toLine = lineNo(display.view[toIndex + 1].line) - 1, toNode = display.view[toIndex + 1].node.previousSibling), !fromNode) return !1; for(var newText = cm.doc.splitLines(function(cm, from, to, fromLine, toLine) { var text = "", closing = !1, lineSep = cm.doc.lineSeparator(), extraLinebreak = !1; function close() { closing && (text += lineSep, extraLinebreak && (text += lineSep), closing = extraLinebreak = !1); } function addText(str) { str && (close(), text += str); } for(; function walk(node) { if (1 == node.nodeType) { var cmText = node.getAttribute("cm-text"); if (cmText) { addText(cmText); return; } var range, markerID = node.getAttribute("cm-marker"); if (markerID) { var id, found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), (id = +markerID, function(marker) { return marker.id == id; })); found.length && (range = found[0].find(0)) && addText(getBetween(cm.doc, range.from, range.to).join(lineSep)); return; } if ("false" != node.getAttribute("contenteditable")) { var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); if (/^br$/i.test(node.nodeName) || 0 != node.textContent.length) { isBlock && close(); for(var i = 0; i < node.childNodes.length; i++)walk(node.childNodes[i]); /^(pre|p)$/i.test(node.nodeName) && (extraLinebreak = !0), isBlock && (closing = !0); } } } else 3 == node.nodeType && addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); }(from), from != to;)from = from.nextSibling, extraLinebreak = !1; return text; }(cm, fromNode, toNode, fromLine, toLine)), oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); newText.length > 1 && oldText.length > 1;)if (lst(newText) == lst(oldText)) newText.pop(), oldText.pop(), toLine--; else if (newText[0] == oldText[0]) newText.shift(), oldText.shift(), fromLine++; else break; for(var cutFront = 0, cutEnd = 0, newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront);)++cutFront; for(var newBot = lst(newText), oldBot = lst(oldText), maxCutEnd = Math.min(newBot.length - (1 == newText.length ? cutFront : 0), oldBot.length - (1 == oldText.length ? cutFront : 0)); cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1);)++cutEnd; // Try to move start of change to start of selection if ambiguous if (1 == newText.length && 1 == oldText.length && fromLine == from.line) for(; cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1);)cutFront--, cutEnd++; newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, ""), newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, ""); var chFrom = Pos(fromLine, cutFront), chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) return replaceRange(cm.doc, newText, chFrom, chTo, "+input"), !0; }, ContentEditableInput.prototype.ensurePolled = function() { this.forceCompositionEnd(); }, ContentEditableInput.prototype.reset = function() { this.forceCompositionEnd(); }, ContentEditableInput.prototype.forceCompositionEnd = function() { this.composing && (clearTimeout(this.readDOMTimeout), this.composing = null, this.updateFromDOM(), this.div.blur(), this.div.focus()); }, ContentEditableInput.prototype.readFromDOMSoon = function() { var this$1 = this; null == this.readDOMTimeout && (this.readDOMTimeout = setTimeout(function() { if (this$1.readDOMTimeout = null, this$1.composing) { if (!this$1.composing.done) return; this$1.composing = null; } this$1.updateFromDOM(); }, 80)); }, ContentEditableInput.prototype.updateFromDOM = function() { var this$1 = this; (this.cm.isReadOnly() || !this.pollContent()) && runInOp(this.cm, function() { return regChange(this$1.cm); }); }, ContentEditableInput.prototype.setUneditable = function(node) { node.contentEditable = "false"; }, ContentEditableInput.prototype.onKeyPress = function(e) { 0 != e.charCode && !this.composing && (e.preventDefault(), this.cm.isReadOnly() || operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(null == e.charCode ? e.keyCode : e.charCode), 0)); }, ContentEditableInput.prototype.readOnlyChanged = function(val) { this.div.contentEditable = String("nocursor" != val); }, ContentEditableInput.prototype.onContextMenu = function() {}, ContentEditableInput.prototype.resetPosition = function() {}, ContentEditableInput.prototype.needsContentAttribute = !0; // TEXTAREA INPUT STYLE var TextareaInput = function(cm) { this.cm = cm, // See input.poll and input.reset this.prevInput = "", // Flag that indicates whether we expect input to appear real soon // now (after some event like 'keypress' or 'input') and are // polling intensively. this.pollingFast = !1, // Self-resetting timeout for the poller this.polling = new Delayed(), // Used to work around IE issue with selection being forgotten when focus moves away from textarea this.hasSelection = !1, this.composing = null; }; TextareaInput.prototype.init = function(display) { var this$1 = this, input = this, cm = this.cm; this.createField(display); var te = this.textarea; function prepareCopyCut(e) { if (!signalDOMEvent(cm, e)) { if (cm.somethingSelected()) lastCopied = { lineWise: !1, text: cm.getSelections() }; else { if (!cm.options.lineWiseCopyCut) return; var ranges = copyableRanges(cm); lastCopied = { lineWise: !0, text: ranges.text }, "cut" == e.type ? cm.setSelections(ranges.ranges, null, sel_dontScroll) : (input.prevInput = "", te.value = ranges.text.join("\n"), selectInput(te)); } "cut" == e.type && (cm.state.cutIncoming = +new Date()); } } display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild), ios && (te.style.width = "0px"), on(te, "input", function() { ie && ie_version >= 9 && this$1.hasSelection && (this$1.hasSelection = null), input.poll(); }), on(te, "paste", function(e) { signalDOMEvent(cm, e) || handlePaste(e, cm) || (cm.state.pasteIncoming = +new Date(), input.fastPoll()); }), on(te, "cut", prepareCopyCut), on(te, "copy", prepareCopyCut), on(display.scroller, "paste", function(e) { if (!(eventInWidget(display, e) || signalDOMEvent(cm, e))) { if (!te.dispatchEvent) { cm.state.pasteIncoming = +new Date(), input.focus(); return; } // Pass the `paste` event to the textarea so it's handled by its event listener. var event = new Event("paste"); event.clipboardData = e.clipboardData, te.dispatchEvent(event); } }), // Prevent normal selection in the editor (we handle our own) on(display.lineSpace, "selectstart", function(e) { eventInWidget(display, e) || e_preventDefault(e); }), on(te, "compositionstart", function() { var start = cm.getCursor("from"); input.composing && input.composing.range.clear(), input.composing = { start: start, range: cm.markText(start, cm.getCursor("to"), { className: "CodeMirror-composing" }) }; }), on(te, "compositionend", function() { input.composing && (input.poll(), input.composing.range.clear(), input.composing = null); }); }, TextareaInput.prototype.createField = function(_display) { // Wraps and hides input textarea this.wrapper = hiddenTextarea(), // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild; }, TextareaInput.prototype.screenReaderLabelChanged = function(label) { // Label for screenreaders, accessibility label ? this.textarea.setAttribute("aria-label", label) : this.textarea.removeAttribute("aria-label"); }, TextareaInput.prototype.prepareSelection = function() { // Redraw the selection and/or cursor var cm = this.cm, display = cm.display, doc = cm.doc, result = prepareSelection(cm); // Move the hidden textarea near the cursor to prevent scrolling artifacts if (cm.options.moveInputWithCursor) { var headPos = cursorCoords(cm, doc.sel.primary().head, "div"), wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top)), result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left)); } return result; }, TextareaInput.prototype.showSelection = function(drawn) { var display = this.cm.display; removeChildrenAndAdd(display.cursorDiv, drawn.cursors), removeChildrenAndAdd(display.selectionDiv, drawn.selection), null != drawn.teTop && (this.wrapper.style.top = drawn.teTop + "px", this.wrapper.style.left = drawn.teLeft + "px"); }, // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) TextareaInput.prototype.reset = function(typing) { if (!this.contextMenuPending && !this.composing) { var cm = this.cm; if (cm.somethingSelected()) { this.prevInput = ""; var content = cm.getSelection(); this.textarea.value = content, cm.state.focused && selectInput(this.textarea), ie && ie_version >= 9 && (this.hasSelection = content); } else !typing && (this.prevInput = this.textarea.value = "", ie && ie_version >= 9 && (this.hasSelection = null)); } }, TextareaInput.prototype.getField = function() { return this.textarea; }, TextareaInput.prototype.supportsTouch = function() { return !1; }, TextareaInput.prototype.focus = function() { if ("nocursor" != this.cm.options.readOnly && (!mobile || activeElt() != this.textarea)) try { this.textarea.focus(); } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM }, TextareaInput.prototype.blur = function() { this.textarea.blur(); }, TextareaInput.prototype.resetPosition = function() { this.wrapper.style.top = this.wrapper.style.left = 0; }, TextareaInput.prototype.receivedFocus = function() { this.slowPoll(); }, // Poll for input changes, using the normal rate of polling. This // runs as long as the editor is focused. TextareaInput.prototype.slowPoll = function() { var this$1 = this; this.pollingFast || this.polling.set(this.cm.options.pollInterval, function() { this$1.poll(), this$1.cm.state.focused && this$1.slowPoll(); }); }, // When an event has just come in that is likely to add or change // something in the input textarea, we poll faster, to ensure that // the change appears on the screen quickly. TextareaInput.prototype.fastPoll = function() { var missed = !1, input = this; input.pollingFast = !0, input.polling.set(20, function p() { input.poll() || missed ? (input.pollingFast = !1, input.slowPoll()) : (missed = !0, input.polling.set(60, p)); }); }, // Read input from the textarea, and update the document to match. // When something is selected, it is present in the textarea, and // selected (unless it is huge, in which case a placeholder is // used). When nothing is selected, the cursor sits after previously // seen text (can be empty), which is stored in prevInput (we must // not reset the textarea when typing, because that breaks IME). TextareaInput.prototype.poll = function() { var this$1 = this, cm = this.cm, input = this.textarea, prevInput = this.prevInput; // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if (this.contextMenuPending || !cm.state.focused || hasSelection(input) && !prevInput && !this.composing || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) return !1; var text = input.value; // If nothing changed, bail. if (text == prevInput && !cm.somethingSelected()) return !1; // Work around nonsensical selection resetting in IE9/10, and // inexplicable appearance of private area unicode characters on // some key combos in Mac (#2689). if (ie && ie_version >= 9 && this.hasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) return cm.display.input.reset(), !1; if (cm.doc.sel == cm.display.selForContextMenu) { var first = text.charCodeAt(0); if (0x200b != first || prevInput || (prevInput = "\u200b"), 0x21da == first) return this.reset(), this.cm.execCommand("undo"); } for(// Find the part of the input that is actually new var same = 0, l = Math.min(prevInput.length, text.length); same < l && prevInput.charCodeAt(same) == text.charCodeAt(same);)++same; return runInOp(cm, function() { applyTextInput(cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null), text.length > 1000 || text.indexOf("\n") > -1 ? input.value = this$1.prevInput = "" : this$1.prevInput = text, this$1.composing && (this$1.composing.range.clear(), this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), { className: "CodeMirror-composing" })); }), !0; }, TextareaInput.prototype.ensurePolled = function() { this.pollingFast && this.poll() && (this.pollingFast = !1); }, TextareaInput.prototype.onKeyPress = function() { ie && ie_version >= 9 && (this.hasSelection = null), this.fastPoll(); }, TextareaInput.prototype.onContextMenu = function(e) { var oldScrollY, input = this, cm = input.cm, display = cm.display, te = input.textarea; input.contextMenuPending && input.contextMenuPending(); var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; if (pos && !presto) { cm.options.resetSelectionOnContextMenu && -1 == cm.doc.sel.contains(pos) && operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText, wrapperBox = input.wrapper.offsetParent.getBoundingClientRect(); if (input.wrapper.style.cssText = "position: static", te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);", webkit && (oldScrollY = window.scrollY), display.input.focus(), webkit && window.scrollTo(null, oldScrollY), display.input.reset(), cm.somethingSelected() || (te.value = input.prevInput = " "), input.contextMenuPending = rehide, display.selForContextMenu = cm.doc.sel, clearTimeout(display.detectingSelectAll), ie && ie_version >= 9 && prepareSelectAllHack(), captureRightClick) { e_stop(e); var mouseup = function() { off(window, "mouseup", mouseup), setTimeout(rehide, 20); }; on(window, "mouseup", mouseup); } else setTimeout(rehide, 50); } // Opera is difficult. // Select-all will be greyed out if there's nothing to select, so // this adds a zero-width space so that we can later check whether // it got selected. function prepareSelectAllHack() { if (null != te.selectionStart) { var selected = cm.somethingSelected(), extval = "\u200b" + (selected ? te.value : ""); te.value = "\u21da", te.value = extval, input.prevInput = selected ? "" : "\u200b", te.selectionStart = 1, te.selectionEnd = extval.length, // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } } function rehide() { if (input.contextMenuPending == rehide && (input.contextMenuPending = !1, input.wrapper.style.cssText = oldWrapperCSS, te.style.cssText = oldCSS, ie && ie_version < 9 && display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos), null != te.selectionStart)) { (!ie || ie && ie_version < 9) && prepareSelectAllHack(); var i = 0, poll = function() { display.selForContextMenu == cm.doc.sel && 0 == te.selectionStart && te.selectionEnd > 0 && "\u200b" == input.prevInput ? operation(cm, selectAll)(cm) : i++ < 10 ? display.detectingSelectAll = setTimeout(poll, 500) : (display.selForContextMenu = null, display.input.reset()); }; display.detectingSelectAll = setTimeout(poll, 200); } } }, TextareaInput.prototype.readOnlyChanged = function(val) { val || this.reset(), this.textarea.disabled = "nocursor" == val, this.textarea.readOnly = !!val; }, TextareaInput.prototype.setUneditable = function() {}, TextareaInput.prototype.needsContentAttribute = !1, // EDITOR CONSTRUCTOR function(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; function option(name, deflt, handle, notOnInit) { CodeMirror.defaults[name] = deflt, handle && (optionHandlers[name] = notOnInit ? function(cm, val, old) { old != Init && handle(cm, val, old); } : handle); } CodeMirror.defineOption = option, // Passed to option handlers when there is no old value. CodeMirror.Init = Init, // These two are, on init, called from the constructor because they // have to be initialized before the editor can start at all. option("value", "", function(cm, val) { return cm.setValue(val); }, !0), option("mode", null, function(cm, val) { cm.doc.modeOption = val, loadMode(cm); }, !0), option("indentUnit", 2, loadMode, !0), option("indentWithTabs", !1), option("smartIndent", !0), option("tabSize", 4, function(cm) { resetModeState(cm), clearCaches(cm), regChange(cm); }, !0), option("lineSeparator", null, function(cm, val) { if (cm.doc.lineSep = val, val) { var newBreaks = [], lineNo = cm.doc.first; cm.doc.iter(function(line) { for(var pos = 0;;){ var found = line.text.indexOf(val, pos); if (-1 == found) break; pos = found + val.length, newBreaks.push(Pos(lineNo, found)); } lineNo++; }); for(var i = newBreaks.length - 1; i >= 0; i--)replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } }), option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function(cm, val, old) { cm.state.specialChars = RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"), old != Init && cm.refresh(); }), option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) { return cm.refresh(); }, !0), option("electricChars", !0), option("inputStyle", mobile ? "contenteditable" : "textarea", function() { throw Error("inputStyle can not (yet) be changed in a running editor"); // FIXME }, !0), option("spellcheck", !1, function(cm, val) { return cm.getInputField().spellcheck = val; }, !0), option("autocorrect", !1, function(cm, val) { return cm.getInputField().autocorrect = val; }, !0), option("autocapitalize", !1, function(cm, val) { return cm.getInputField().autocapitalize = val; }, !0), option("rtlMoveVisually", !windows), option("wholeLineUpdateBefore", !0), option("theme", "default", function(cm) { themeChanged(cm), updateGutters(cm); }, !0), option("keyMap", "default", function(cm, val, old) { var next = getKeyMap(val), prev = old != Init && getKeyMap(old); prev && prev.detach && prev.detach(cm, next), next.attach && next.attach(cm, prev || null); }), option("extraKeys", null), option("configureMouse", null), option("lineWrapping", !1, wrappingChanged, !0), option("gutters", [], function(cm, val) { cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers), updateGutters(cm); }, !0), option("fixedGutter", !0, function(cm, val) { cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0", cm.refresh(); }, !0), option("coverGutterNextToScrollbar", !1, function(cm) { return updateScrollbars(cm); }, !0), option("scrollbarStyle", "native", function(cm) { initScrollbars(cm), updateScrollbars(cm), cm.display.scrollbars.setScrollTop(cm.doc.scrollTop), cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); }, !0), option("lineNumbers", !1, function(cm, val) { cm.display.gutterSpecs = getGutters(cm.options.gutters, val), updateGutters(cm); }, !0), option("firstLineNumber", 1, updateGutters, !0), option("lineNumberFormatter", function(integer) { return integer; }, updateGutters, !0), option("showCursorWhenSelecting", !1, updateSelection, !0), option("resetSelectionOnContextMenu", !0), option("lineWiseCopyCut", !0), option("pasteLinesPerSelection", !0), option("selectionsMayTouch", !1), option("readOnly", !1, function(cm, val) { "nocursor" == val && (onBlur(cm), cm.display.input.blur()), cm.display.input.readOnlyChanged(val); }), option("screenReaderLabel", null, function(cm, val) { val = "" === val ? null : val, cm.display.input.screenReaderLabelChanged(val); }), option("disableInput", !1, function(cm, val) { val || cm.display.input.reset(); }, !0), option("dragDrop", !0, dragDropChanged), option("allowDropFileTypes", null), option("cursorBlinkRate", 530), option("cursorScrollMargin", 0), option("cursorHeight", 1, updateSelection, !0), option("singleCursorHeightPerLine", !0, updateSelection, !0), option("workTime", 100), option("workDelay", 100), option("flattenSpans", !0, resetModeState, !0), option("addModeClass", !1, resetModeState, !0), option("pollInterval", 100), option("undoDepth", 200, function(cm, val) { return cm.doc.history.undoDepth = val; }), option("historyEventDelay", 1250), option("viewportMargin", 10, function(cm) { return cm.refresh(); }, !0), option("maxHighlightLength", 10000, resetModeState, !0), option("moveInputWithCursor", !0, function(cm, val) { val || cm.display.input.resetPosition(); }), option("tabindex", null, function(cm, val) { return cm.display.input.getField().tabIndex = val || ""; }), option("autofocus", null), option("direction", "ltr", function(cm, val) { return cm.doc.setDirection(val); }, !0), option("phrases", null); }(CodeMirror), optionHandlers = CodeMirror.optionHandlers, helpers = CodeMirror.helpers = {}, CodeMirror.prototype = { constructor: CodeMirror, focus: function() { window.focus(), this.display.input.focus(); }, setOption: function(option, value) { var options = this.options, old = options[option]; (options[option] != value || "mode" == option) && (options[option] = value, optionHandlers.hasOwnProperty(option) && operation(this, optionHandlers[option])(this, value, old), signal(this, "optionChange", this, option)); }, getOption: function(option) { return this.options[option]; }, getDoc: function() { return this.doc; }, addKeyMap: function(map, bottom) { this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); }, removeKeyMap: function(map) { for(var maps = this.state.keyMaps, i = 0; i < maps.length; ++i)if (maps[i] == map || maps[i].name == map) return maps.splice(i, 1), !0; }, addOverlay: methodOp(function(spec, options) { var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); if (mode.startState) throw Error("Overlays may not be stateful."); (function(array, value, score) { for(var pos = 0, priority = score(value); pos < array.length && score(array[pos]) <= priority;)pos++; array.splice(pos, 0, value); })(this.state.overlays, { mode: mode, modeSpec: spec, opaque: options && options.opaque, priority: options && options.priority || 0 }, function(overlay) { return overlay.priority; }), this.state.modeGen++, regChange(this); }), removeOverlay: methodOp(function(spec) { for(var overlays = this.state.overlays, i = 0; i < overlays.length; ++i){ var cur = overlays[i].modeSpec; if (cur == spec || "string" == typeof spec && cur.name == spec) { overlays.splice(i, 1), this.state.modeGen++, regChange(this); return; } } }), indentLine: methodOp(function(n, dir, aggressive) { "string" != typeof dir && "number" != typeof dir && (dir = null == dir ? this.options.smartIndent ? "smart" : "prev" : dir ? "add" : "subtract"), isLine(this.doc, n) && indentLine(this, n, dir, aggressive); }), indentSelection: methodOp(function(how) { for(var ranges = this.doc.sel.ranges, end = -1, i = 0; i < ranges.length; i++){ var range = ranges[i]; if (range.empty()) range.head.line > end && (indentLine(this, range.head.line, how, !0), end = range.head.line, i == this.doc.sel.primIndex && ensureCursorVisible(this)); else { var from = range.from(), to = range.to(), start = Math.max(end, from.line); end = Math.min(this.lastLine(), to.line - +!to.ch) + 1; for(var j = start; j < end; ++j)indentLine(this, j, how); var newRanges = this.doc.sel.ranges; 0 == from.ch && ranges.length == newRanges.length && newRanges[i].from().ch > 0 && replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); } } }), // Fetch the parser token for a given character. Useful for hacks // that want to inspect the mode state (say, for completion). getTokenAt: function(pos, precise) { return takeToken(this, pos, precise); }, getLineTokens: function(line, precise) { return takeToken(this, Pos(line), precise, !0); }, getTokenTypeAt: function(pos) { pos = clipPos(this.doc, pos); var type, styles = getLineStyles(this, getLine(this.doc, pos.line)), before = 0, after = (styles.length - 1) / 2, ch = pos.ch; if (0 == ch) type = styles[2]; else for(;;){ var mid = before + after >> 1; if ((mid ? styles[2 * mid - 1] : 0) >= ch) after = mid; else if (styles[2 * mid + 1] < ch) before = mid + 1; else { type = styles[2 * mid + 2]; break; } } var cut = type ? type.indexOf("overlay ") : -1; return cut < 0 ? type : 0 == cut ? null : type.slice(0, cut - 1); }, getModeAt: function(pos) { var mode = this.doc.mode; return mode.innerMode ? CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode : mode; }, getHelper: function(pos, type) { return this.getHelpers(pos, type)[0]; }, getHelpers: function(pos, type) { var found = []; if (!helpers.hasOwnProperty(type)) return found; var help = helpers[type], mode = this.getModeAt(pos); if ("string" == typeof mode[type]) help[mode[type]] && found.push(help[mode[type]]); else if (mode[type]) for(var i = 0; i < mode[type].length; i++){ var val = help[mode[type][i]]; val && found.push(val); } else mode.helperType && help[mode.helperType] ? found.push(help[mode.helperType]) : help[mode.name] && found.push(help[mode.name]); for(var i$1 = 0; i$1 < help._global.length; i$1++){ var cur = help._global[i$1]; cur.pred(mode, this) && -1 == indexOf(found, cur.val) && found.push(cur.val); } return found; }, getStateAfter: function(line, precise) { var doc = this.doc; return getContextBefore(this, (line = clipLine(doc, null == line ? doc.first + doc.size - 1 : line)) + 1, precise).state; }, cursorCoords: function(start, mode) { var range = this.doc.sel.primary(); return cursorCoords(this, null == start ? range.head : "object" == typeof start ? clipPos(this.doc, start) : start ? range.from() : range.to(), mode || "page"); }, charCoords: function(pos, mode) { return charCoords(this, clipPos(this.doc, pos), mode || "page"); }, coordsChar: function(coords, mode) { return coordsChar(this, (coords = fromCoordSystem(this, coords, mode || "page")).left, coords.top); }, lineAtHeight: function(height, mode) { return height = fromCoordSystem(this, { top: height, left: 0 }, mode || "page").top, lineAtHeight(this.doc, height + this.display.viewOffset); }, heightAtLine: function(line, mode, includeWidgets) { var lineObj, end = !1; if ("number" == typeof line) { var last = this.doc.first + this.doc.size - 1; line < this.doc.first ? line = this.doc.first : line > last && (line = last, end = !0), lineObj = getLine(this.doc, line); } else lineObj = line; return intoCoordSystem(this, lineObj, { top: 0, left: 0 }, mode || "page", includeWidgets || end).top + (end ? this.doc.height - heightAtLine(lineObj) : 0); }, defaultTextHeight: function() { return textHeight(this.display); }, defaultCharWidth: function() { return charWidth(this.display); }, getViewport: function() { return { from: this.display.viewFrom, to: this.display.viewTo }; }, addWidget: function(pos, node, scroll, vert, horiz) { var scrollPos, display = this.display, top = (pos = cursorCoords(this, clipPos(this.doc, pos))).bottom, left = pos.left; if (node.style.position = "absolute", node.setAttribute("cm-ignore-events", "true"), this.display.input.setUneditable(node), display.sizer.appendChild(node), "over" == vert) top = pos.top; else if ("above" == vert || "near" == vert) { var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); ("above" == vert || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight ? top = pos.top - node.offsetHeight : pos.bottom + node.offsetHeight <= vspace && (top = pos.bottom), left + node.offsetWidth > hspace && (left = hspace - node.offsetWidth); } node.style.top = top + "px", node.style.left = node.style.right = "", "right" == horiz ? (left = display.sizer.clientWidth - node.offsetWidth, node.style.right = "0px") : ("left" == horiz ? left = 0 : "middle" == horiz && (left = (display.sizer.clientWidth - node.offsetWidth) / 2), node.style.left = left + "px"), scroll && (null != (scrollPos = calculateScrollPos(this, { left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight })).scrollTop && updateScrollTop(this, scrollPos.scrollTop), null != scrollPos.scrollLeft && setScrollLeft(this, scrollPos.scrollLeft)); }, triggerOnKeyDown: methodOp(onKeyDown), triggerOnKeyPress: methodOp(onKeyPress), triggerOnKeyUp: onKeyUp, triggerOnMouseDown: methodOp(onMouseDown), execCommand: function(cmd) { if (commands.hasOwnProperty(cmd)) return commands[cmd].call(null, this); }, triggerElectric: methodOp(function(text) { triggerElectric(this, text); }), findPosH: function(from, amount, unit, visually) { var dir = 1; amount < 0 && (dir = -1, amount = -amount); for(var cur = clipPos(this.doc, from), i = 0; i < amount && !(cur = findPosH(this.doc, cur, dir, unit, visually)).hitSide; ++i); return cur; }, moveH: methodOp(function(dir, unit) { var this$1 = this; this.extendSelectionsBy(function(range) { return this$1.display.shift || this$1.doc.extend || range.empty() ? findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) : dir < 0 ? range.from() : range.to(); }, sel_move); }), deleteH: methodOp(function(dir, unit) { var sel = this.doc.sel, doc = this.doc; sel.somethingSelected() ? doc.replaceSelection("", null, "+delete") : deleteNearSelection(this, function(range) { var other = findPosH(doc, range.head, dir, unit, !1); return dir < 0 ? { from: other, to: range.head } : { from: range.head, to: other }; }); }), findPosV: function(from, amount, unit, goalColumn) { var dir = 1, x = goalColumn; amount < 0 && (dir = -1, amount = -amount); for(var cur = clipPos(this.doc, from), i = 0; i < amount; ++i){ var coords = cursorCoords(this, cur, "div"); if (null == x ? x = coords.left : coords.left = x, (cur = findPosV(this, coords, dir, unit)).hitSide) break; } return cur; }, moveV: methodOp(function(dir, unit) { var this$1 = this, doc = this.doc, goals = [], collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected(); if (doc.extendSelectionsBy(function(range) { if (collapse) return dir < 0 ? range.from() : range.to(); var headPos = cursorCoords(this$1, range.head, "div"); null != range.goalColumn && (headPos.left = range.goalColumn), goals.push(headPos.left); var pos = findPosV(this$1, headPos, dir, unit); return "page" == unit && range == doc.sel.primary() && addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top), pos; }, sel_move), goals.length) for(var i = 0; i < doc.sel.ranges.length; i++)doc.sel.ranges[i].goalColumn = goals[i]; }), // Find the word at the given position (as returned by coordsChar). findWordAt: function(pos) { var line = getLine(this.doc, pos.line).text, start = pos.ch, end = pos.ch; if (line) { var helper = this.getHelper(pos, "wordChars"); ("before" == pos.sticky || end == line.length) && start ? --start : ++end; for(var startChar = line.charAt(start), check = isWordChar(startChar, helper) ? function(ch) { return isWordChar(ch, helper); } : /\s/.test(startChar) ? function(ch) { return /\s/.test(ch); } : function(ch) { return !/\s/.test(ch) && !isWordChar(ch); }; start > 0 && check(line.charAt(start - 1));)--start; for(; end < line.length && check(line.charAt(end));)++end; } return new Range(Pos(pos.line, start), Pos(pos.line, end)); }, toggleOverwrite: function(value) { (null == value || value != this.state.overwrite) && ((this.state.overwrite = !this.state.overwrite) ? addClass(this.display.cursorDiv, "CodeMirror-overwrite") : rmClass(this.display.cursorDiv, "CodeMirror-overwrite"), signal(this, "overwriteToggle", this, this.state.overwrite)); }, hasFocus: function() { return this.display.input.getField() == activeElt(); }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); }, scrollTo: methodOp(function(x, y) { scrollToCoords(this, x, y); }), getScrollInfo: function() { var scroller = this.display.scroller; return { left: scroller.scrollLeft, top: scroller.scrollTop, height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, clientHeight: displayHeight(this), clientWidth: displayWidth(this) }; }, scrollIntoView: methodOp(function(range, margin) { if (null == range ? (range = { from: this.doc.sel.primary().head, to: null }, null == margin && (margin = this.options.cursorScrollMargin)) : "number" == typeof range ? range = { from: Pos(range, 0), to: null } : null == range.from && (range = { from: range, to: null }), range.to || (range.to = range.from), range.margin = margin || 0, null != range.from.line) { var range1; range1 = range, resolveScrollToPos(this), this.curOp.scrollToPos = range1; } else scrollToCoordsRange(this, range.from, range.to, range.margin); }), setSize: methodOp(function(width, height) { var this$1 = this, interpret = function(val) { return "number" == typeof val || /^\d+$/.test(String(val)) ? val + "px" : val; }; null != width && (this.display.wrapper.style.width = interpret(width)), null != height && (this.display.wrapper.style.height = interpret(height)), this.options.lineWrapping && clearLineMeasurementCache(this); var lineNo = this.display.viewFrom; this.doc.iter(lineNo, this.display.viewTo, function(line) { if (line.widgets) { for(var i = 0; i < line.widgets.length; i++)if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break; } } ++lineNo; }), this.curOp.forceUpdate = !0, signal(this, "refresh", this); }), operation: function(f) { return runInOp(this, f); }, startOperation: function() { return startOperation(this); }, endOperation: function() { return endOperation(this); }, refresh: methodOp(function() { var oldHeight = this.display.cachedTextHeight; regChange(this), this.curOp.forceUpdate = !0, clearCaches(this), scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop), updateGutterSpace(this.display), (null == oldHeight || Math.abs(oldHeight - textHeight(this.display)) > 0.5 || this.options.lineWrapping) && estimateLineHeights(this), signal(this, "refresh", this); }), swapDoc: methodOp(function(doc) { var old = this.doc; return old.cm = null, this.state.selectingText && this.state.selectingText(), attachDoc(this, doc), clearCaches(this), this.display.input.reset(), scrollToCoords(this, doc.scrollLeft, doc.scrollTop), this.curOp.forceScroll = !0, signalLater(this, "swapDoc", this, old), old; }), phrase: function(phraseText) { var phrases = this.options.phrases; return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText; }, getInputField: function() { return this.display.input.getField(); }, getWrapperElement: function() { return this.display.wrapper; }, getScrollerElement: function() { return this.display.scroller; }, getGutterElement: function() { return this.display.gutters; } }, eventMixin(CodeMirror), CodeMirror.registerHelper = function(type, name, value) { helpers.hasOwnProperty(type) || (helpers[type] = CodeMirror[type] = { _global: [] }), helpers[type][name] = value; }, CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { CodeMirror.registerHelper(type, name, value), helpers[type]._global.push({ pred: predicate, val: value }); }; // Set up methods on CodeMirror's prototype to redirect to the editor's document. var dontDelegate = "iter insert remove copy getEditor constructor".split(" "); for(var prop in Doc.prototype)Doc.prototype.hasOwnProperty(prop) && 0 > indexOf(dontDelegate, prop) && (CodeMirror.prototype[prop] = function(method) { return function() { return method.apply(this.doc, arguments); }; }(Doc.prototype[prop])); return eventMixin(Doc), CodeMirror.inputStyles = { textarea: TextareaInput, contenteditable: ContentEditableInput }, // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) CodeMirror.defineMode = function(name /*, mode, …*/ ) { CodeMirror.defaults.mode || "null" == name || (CodeMirror.defaults.mode = name), defineMode.apply(this, arguments); }, CodeMirror.defineMIME = function(mime, spec) { mimeModes[mime] = spec; }, // Minimal default mode. CodeMirror.defineMode("null", function() { return { token: function(stream) { return stream.skipToEnd(); } }; }), CodeMirror.defineMIME("text/plain", "null"), // EXTENSIONS CodeMirror.defineExtension = function(name, func) { CodeMirror.prototype[name] = func; }, CodeMirror.defineDocExtension = function(name, func) { Doc.prototype[name] = func; }, CodeMirror.fromTextArea = function(textarea, options) { // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if ((options = options ? copyObj(options) : {}).value = textarea.value, !options.tabindex && textarea.tabIndex && (options.tabindex = textarea.tabIndex), !options.placeholder && textarea.placeholder && (options.placeholder = textarea.placeholder), null == options.autofocus) { var realSubmit, hasFocus = activeElt(); options.autofocus = hasFocus == textarea || null != textarea.getAttribute("autofocus") && hasFocus == document.body; } function save() { textarea.value = cm.getValue(); } if (textarea.form && (on(textarea.form, "submit", save), !options.leaveSubmitMethodAlone)) { var form = textarea.form; realSubmit = form.submit; try { var wrappedSubmit = form.submit = function() { save(), form.submit = realSubmit, form.submit(), form.submit = wrappedSubmit; }; } catch (e) {} } options.finishInit = function(cm) { cm.save = save, cm.getTextArea = function() { return textarea; }, cm.toTextArea = function() { cm.toTextArea = isNaN, save(), textarea.parentNode.removeChild(cm.getWrapperElement()), textarea.style.display = "", textarea.form && (off(textarea.form, "submit", save), options.leaveSubmitMethodAlone || "function" != typeof textarea.form.submit || (textarea.form.submit = realSubmit)); }; }, textarea.style.display = "none"; var cm = CodeMirror(function(node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); }, options); return cm; }, CodeMirror.off = off, CodeMirror.on = on, CodeMirror.wheelEventPixels = function(e) { var delta = wheelEventDelta(e); return delta.x *= wheelPixelsPerUnit, delta.y *= wheelPixelsPerUnit, delta; }, CodeMirror.Doc = Doc, CodeMirror.splitLines = splitLinesAuto, CodeMirror.countColumn = countColumn, CodeMirror.findColumn = findColumn, CodeMirror.isWordChar = isWordCharBasic, CodeMirror.Pass = Pass, CodeMirror.signal = signal, CodeMirror.Line = Line, CodeMirror.changeEnd = changeEnd, CodeMirror.scrollbarModel = scrollbarModel, CodeMirror.Pos = Pos, CodeMirror.cmpPos = cmp, CodeMirror.modes = modes, CodeMirror.mimeModes = mimeModes, CodeMirror.resolveMode = resolveMode, CodeMirror.getMode = getMode, CodeMirror.modeExtensions = modeExtensions, CodeMirror.extendMode = function(mode, properties) { copyObj(properties, modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : modeExtensions[mode] = {}); }, CodeMirror.copyState = copyState, CodeMirror.startState = startState, CodeMirror.innerMode = innerMode, CodeMirror.commands = commands, CodeMirror.keyMap = keyMap, CodeMirror.keyName = keyName, CodeMirror.isModifierKey = isModifierKey, CodeMirror.lookupKey = lookupKey, CodeMirror.normalizeKeyMap = // This is a kludge to keep keymaps mostly working as raw objects // (backwards compatibility) while at the same time support features // like normalization and multi-stroke key bindings. It compiles a // new normalized keymap, and then updates the old object to reflect // this. function(keymap) { var copy = {}; for(var keyname in keymap)if (keymap.hasOwnProperty(keyname)) { var value = keymap[keyname]; if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue; if ("..." == value) { delete keymap[keyname]; continue; } for(var keys = map(keyname.split(" "), normalizeKeyName), i = 0; i < keys.length; i++){ var val = void 0, name = void 0; i == keys.length - 1 ? (name = keys.join(" "), val = value) : (name = keys.slice(0, i + 1).join(" "), val = "..."); var prev = copy[name]; if (prev) { if (prev != val) throw Error("Inconsistent bindings for " + name); } else copy[name] = val; } delete keymap[keyname]; } for(var prop in copy)keymap[prop] = copy[prop]; return keymap; }, CodeMirror.StringStream = StringStream, CodeMirror.SharedTextMarker = SharedTextMarker, CodeMirror.TextMarker = TextMarker, CodeMirror.LineWidget = LineWidget, CodeMirror.e_preventDefault = e_preventDefault, CodeMirror.e_stopPropagation = e_stopPropagation, CodeMirror.e_stop = e_stop, CodeMirror.addClass = addClass, CodeMirror.contains = contains, CodeMirror.rmClass = rmClass, CodeMirror.keyNames = keyNames, CodeMirror.version = "5.65.1", CodeMirror; });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University