[
  {
    "path": ".eslintrc",
    "content": "{\n    \"extends\": \"standard\",\n    \"rules\": {\n        \"indent\": [\n            \"error\",\n            4\n        ],\n        \"space-before-function-paren\": [\n            \"error\",\n            \"never\"\n        ],\n        \"one-var\": 0,\n        \"no-undef\": 0,\n        \"eqeqeq\": 0,\n        \"no-mixed-operators\": 0,\n        \"camelcase\": 0,\n        \"no-return-assign\": 0\n    }\n}"
  },
  {
    "path": ".gitignore",
    "content": "/node_modules"
  },
  {
    "path": "README-CN.md",
    "content": "[English](./README.md) | 简体中文\n\n<a href=\"##qone\"><img src=\"./asset/qone.png\" alt=\"qone\"></a>\n==============================\n[![npm version](https://badge.fury.io/js/qone.svg)](https://www.npmjs.com/package/qone) \n\n.NET LINQ 在 javascript 中的实现\n\n## 缘由\n\n最近刚好修改了腾讯文档 Excel 表格公式的一些 bug，主要是修改公式的 parser 。比如下面的脚本怎么转成 javascript 运行？\n\n``` js\n= IF(SUM(J6:J7) + SUM(J6:J7) > 10, \"A2 是 foo\", \"A2 不是 foo\")\n```\n\n公式或一些脚本语言的实现包含几个主要步骤:\n\n    scanner > lexer > parser > ast > code string\n\n得到 code string 之后可以动态运行，比如 js 里使用 eval ，eval 能保留上下文信息，缺点是执行代码包含编译器代码，eval 的安全性等。\n得到 code string 之后也可直接使用生成的 code string 运行，缺点是依赖构建工具或者编辑器插件去动态替换源代码。\n\n比如 wind 同时支持 JIT 和 AOT, qone 的思路和上面类似，但不完全相同， qone 的如下:\n\n    scanner > lexer > parser > ast > method(ast)\n\n这个后面写原理时候再细说。\n\n总的来说，因为腾讯文档公式相关工作、早年的 kmdjs 开发 (uglify2) 和 .NET 开发，所以有了 qone 。    \n\n- [LINQ](#linq)\n- [qone 安装](#qone-安装)\n- [qone 关键字与运算符](#qone-关键字与运算符)\n- [qone 方法注入](#qone-方法注入)      \n- [qone select 输出](#qone-select-输出)   \n- [qone orderby](#qone-orderby)\n- [qone groupby](#qone-groupby)\n- [qone 多数据源](#qone-多数据源)\n- [qone 嵌套子数据源](#qone-嵌套子数据源)\n- [qone limit 与分页查询](#qone-limit-与分页查询)\n- [links](#star--fork--pr--repl--follow-me)\n---\n\n## LINQ\n\n LINQ (语言集成查询) 是 .NET Framework 3.5 版中引入的一项创新功能。在 Visual Studio 中，可以用 Visual Basic 或 C# 为以下数据源编写 LINQ 查询：SQL Server 数据库、XML 文档、ADO.NET 数据集，以及可枚举的 Objects(即 LINQ to Objects)。\n\nqone 是一款让 Web 前端工程师在 javascript 使用 .NET 平台下类似 LINQ 语法的前端库。qone 让 Web 前端工程师通过字符串的形式实现了 LINQ to Objects 的调用（下面统一叫做 qone to objects），Objects即 JSON 组成的 Array。举个简单的例子(qone 远比下面的例子强大):\n\n``` js\nvar list = [\n    { name: 'qone', age: 1 },\n    { name: 'linq', age: 18 },\n    { name: 'dntzhang', age: 28 }\n]\n\nvar result = qone({ list }).query(`\n            from n in list   \n            where n.age > 18\n            select n\n        `)\n\nassert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n```\n\n与 LINQ 一样，和 SQL 不同，qone 的 from 也在前面，为后面语句能够有智能提示，qone 是基于 string 的实时编译，不是 javasript 的原生语法，所以虽然 from 写在前面但不支持智能提示，但可以专门为 qone 写个编辑器插件去实现智能提示，所以 qone 语法设计上依然把 from 放在前面。\n\n从根本上说，qone to objects 表示一种新的处理集合的方法。 采用旧方法，您必须编写指定如何从集合检索数据的复杂的 foreach 循环。 而采用 qone 方法，您只需编写描述要检索的内容的声明性代码。\n另外，与传统的 foreach 循环相比，qone 查询具有三大优势：\n\n* 它们更简明、更易读，尤其在筛选多个条件时\n* 它们使用最少的应用程序代码提供强大的筛选、排序和分组功能\n* 无需修改或只需做很小的修改即可将它们移植到其他数据源\n\n通常，您要对数据执行的操作越复杂，就越能体会到 qone 相较于传统迭代技术的优势。\n\n## qone 安装\n\n``` bash\nnpm install qone\n```\n\nCDN:\n\n* [https://unpkg.com/qone@1.0.0/qone.js](https://unpkg.com/qone@1.0.0/qone.js)\n* [https://unpkg.com/qone@1.0.0/qone.min.js](https://unpkg.com/qone@1.0.0/qone.min.js)\n\n## qone 关键字与运算符\n\n* from\n* in\n* where\n* select\n* orderby \n* desc\n* asc\n* groupby\n* limit\n\n其中 from 和 in 一起使用，orderby 和 desc 或者 asc 一起使用。\n\nfrom 也可以把子属性作为 dataSource:\n\n``` js\nfrom n in data.list   \n```\n\nqone 支持下面三类运算符:\n\n* 括号：( )\n* 比较运算符： = , > , < , >= , <= , != \n* 与或非: && , || , !\n\n条件判断语句也支持 null, undefined, true, false。\n\n通过上面各种组合，你可以写出很复杂的查询条件。比如:\n\n``` js\nqone({ list }).query(`\n    from n in list   \n    where !(n.age > 17 || n.age < 2) && n.name != 'dntzhang'\n    select n\n`)\n```\n\n也支持 bool 类型的查询:\n\n``` js\nvar list = [\n    { name: 'qone', age: 1, isBaby: true },\n    { name: 'linq', age: 18 },\n    { name: 'dntzhang', age: 28 }]\n\nvar result = qone({ list }).query(`\n        from a in list       \n        where a.isBaby && n.name = 'qone'\n        select a\n    `)\n\nassert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }])\n```\n\n其中 isBaby 是 bool 类型，同样的写法:\na.isBaby = true   (等同于: a.isBaby)\na.isBaby = false  (等同于: !a.isBaby)\n\n## qone 方法注入\n\n通过上面介绍发现 qone 不支持加减乘除位求模运算？怎么才能图灵完备？方法注入搞定一切！如下所示:\n\n``` js\nQUnit.test(\"Method test 8\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    qone('sqrt', function (num) {\n        return Math.sqrt(num)\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  sqrt(n) >= 2 \n      select { squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }])\n})\n```\n\n方法也是支持多参数传入，所以可以写出任意的查询条件。其中select, where, orderby, groupby 语句都支持方法注入。\n\n## qone select 输出\n\n通过 select 可以输出各种格式和字段的数据:\n\n``` js\nQUnit.test(\"Select JSON test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age < 20\n                select {n.age, n.name}\n            `)\n\n    assert.deepEqual(result, [\n        { \"age\": 1 , \"name\": \"qone\" },\n        { \"age\": 18, \"name\": \"linq\" }\n    ])\n\n})\n``` \n\n把所有场景列举一下:\n\n* `select n` 输出源 item\n* `select n.name` 输出一维表\n* `select n.name, n.age` 输出二维表\n* `select { n.age, n.name }` 缺省方式输出 JSON Array(key自动使用 age 和 name)\n* `select { a: n.age, b: n.name }` 指定 key 输出 JSON Array\n* `select { a: methodName(n.age), b: n.name }` 注入方法\n* `select methodName(n.age), n.name` 注入方法\n* `select methodName(n.age, n.name, 1, true, 'abc')` 注入方法并传递参数\n\n\n## qone orderby\n\n\n``` js\nvar result = qone({ list }).query(`\n                from n in list   \n                where n.age > 0\n                orderby n.age asc, n.name desc\n                select n\n            `)\n\n``` \n\n如果没有标记 asc 或者 desc，使用默认排序 asc。\n\n## qone groupby\n\n``` js\nQUnit.test(\"Simple groupby test 1\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang1', age: 28 },\n        { name: 'dntzhang2', age: 28 },\n        { name: 'dntzhang3', age: 29 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 18\n                groupby n.age\n            `)\n\n    assert.deepEqual(result, [\n        [{ \"name\": \"dntzhang1\", \"age\": 28 }, { \"name\": \"dntzhang2\", \"age\": 28 }],\n        [{ \"name\": \"dntzhang3\", \"age\": 29 }]])\n\n})\n```\n\ngroupby 可以作为结束语句，不用跟着也不能跟着 select 语句，groupby 也可以支持方法注入。\n\n## qone 多数据源 \n\n``` js\nQUnit.test(\"Multi datasource with props condition\", function (assert) {\n\n    var listA = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n\n    var listB = [\n        { name: 'x', age: 11 },\n        { name: 'xx', age: 18 },\n        { name: 'xxx', age: 13 }\n    ]\n\n    var result = qone({ listA, listB }).query(`\n            from a in listA     \n            from b in listB      \n            where a.age = b.age\n            select a, b\n        `)\n\n    assert.deepEqual(result, [[{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 18 }]])\n})\n```\n\n多数据源会产生笛卡儿积。\n\n## qone 嵌套子数据源\n\n``` js\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            from c in a.colors   \n            from d in c.xx  \n            where d === 100\n            select a.name, c,d\n        `)\n\n    assert.deepEqual(result, [[\"linq\", { \"xx\": [100, 2, 3] }, 100]])\n})\n```\n\n也可以和自身的数据源会产生笛卡儿积。\n\n## qone limit 与分页查询\n\n通过 limit 可以应付最常见的两种查询场景 - top N 和 分页。\n\n查询top3:\n\n``` js\nQUnit.test(\"Limit top 3\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    select n\n                    limit 0, 3\n                `)\n\n\n    assert.deepEqual(result, [\n\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 }\n    ])\n\n})\n``` \n\n分页查询:\n\n``` js\nQUnit.test(\"Limit one page test\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    where n.age > 0\n                    select n\n                    limit ${pageIndex * pageSize}, ${pageSize}\n                `)\n\n\n    assert.deepEqual(result, [\n    { name: 'dntzhang5', age: 5 },\n    { name: 'dntzhang6', age: 6 },\n    { name: 'dntzhang7', age: 7 },\n    { name: 'dntzhang8', age: 8 }])\n\n})\n``` \n\n## star & fork & pr & repl & follow me\n\n* [https://github.com/dntzhang/qone](https://github.com/dntzhang/qone)\n* [https://dntzhang.github.io/qone](https://dntzhang.github.io/qone)\n* [https://github.com/dntzhang](https://github.com/dntzhang)\n"
  },
  {
    "path": "README.md",
    "content": "\nEnglish | [简体中文](./README-CN.md) \n\n\n<a href=\"##qone\"><img src=\"./asset/qone.png\" alt=\"qone\"></a>\n==============================\n[![npm version](https://badge.fury.io/js/qone.svg)](https://www.npmjs.com/package/qone) \n\n.NET LINQ in javascript\n\n\n## The reason\n\nRecently, it has just changed some bug of the Excel formula of the Tencent document, mainly modifying the parser of the formula.\n\nFor example, how can the following script be transformed to JavaScript?\n\n``` js\n= IF(SUM(J6:J7) + SUM(J6:J7) > 10, \"A2 is foo\", \"A2 is not foo\")\n```\n\nThe implementation of formulas or scripting languages includes several main steps:\n\nScanner > lexer > parser > ast > code string\n\nAfter getting code string, you can run (JIT) dynamically, such as using Eval in JS, Eval can retain context information, the disadvantage is that the execution code contains compiler code, and it is unsafe, and so on.\nAfter getting code string, you can also use the generated code string to run (AOT) directly, and the disadvantage is to rely on the build tool or editor plug-in to dynamically replace the source code.\n\nFor example, wind supports JIT and AOT at the same time. Qone's thinking is similar to that above, but not exactly the same. Qone is as follows:\n\nScanner > lexer > parser > ast > method(ast)\n\nThe detailed principles will be written later. In general, the reasons are the work of the Tencent document formula, early kmdjs development (uglify2) and.NET development, so there is Qone.\n\n- [LINQ](#linq)\n- [qone install](#qone-install)\n- [qone keyword and operator](#qone-keyword-and-operator)\n- [qone method](#qone-method)      \n- [qone select](#qone-select)   \n- [qone orderby](#qone-orderby)\n- [qone groupby](#qone-groupby) \n- [qone multiple data source](#qone-multiple-data-source)\n- [qone subdata source](#qone-subdata-source)\n- [qone limit and pagination](#qone-limit-and-pagination)\n- [links](#star--fork--pr--repl--follow-me)\n---\n\n## LINQ\n\nLINQ (language integrated query) is an innovative function introduced in.NET Framework 3.5. In Visual Studio, you can write LINQ queries with Visual Basic or C# for the following data sources: the SQL Server database, XML document, ADO.NET data set, and enumerable Objects.\n\nQone allows Web front-end engineers to use LINQ to Objects through js string or js template string, Objects is an array of JSON. Let me give you a simple example (Qone is much stronger than the following example):\n\n\n``` js\nvar list = [\n    { name: 'qone', age: 1 },\n    { name: 'linq', age: 18 },\n    { name: 'dntzhang', age: 28 }\n]\n\nvar result = qone({ list }).query(`\n            from n in list   \n            where n.age > 18\n            select n\n        `)\n\nassert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n```\n\nQone's `from` keyword is also in front like LINQ, with intelligent prompts for the later statements,but qone is real-time compilation based on string, not the native syntax of javasript, so although from is written in the front but does not support intelligent hints.\n\n## qone install\n\n``` bash\nnpm install qone\n```\n\nor get it by CDN:\n\n* [https://unpkg.com/qone@1.0.0/qone.js](https://unpkg.com/qone@1.0.0/qone.js)\n* [https://unpkg.com/qone@1.0.0/qone.min.js](https://unpkg.com/qone@1.0.0/qone.min.js)\n\n## qone keyword and operator\n\n* from\n* in\n* where\n* select\n* orderby \n* desc\n* asc\n* groupby\n* limit\n\nfrom and in are used together, orderby and desc or asc are used together.\n\nfrom can also take the sub attributes as dataSource:\n\n``` js\nfrom n in data.list   \n```\n\nQone supports the following three class operators:\n\n* brackets：( )\n* comparison operator： = , > , < , >= , <= , != \n* and or not: && , || , !\n\nConditional judgement also supports null, undefined, true, false.\n\nThrough the above combinations, you can write complex query conditions. For example:\n\n``` js\nqone({ list }).query(`\n    from n in list   \n    where !(n.age > 17 || n.age < 2) && n.name != 'dntzhang'\n    select n\n`)\n```\n\nThe bool type of query is also supported:\n\n``` js\nvar list = [\n    { name: 'qone', age: 1, isBaby: true },\n    { name: 'linq', age: 18 },\n    { name: 'dntzhang', age: 28 }]\n\nvar result = qone({ list }).query(`\n        from a in list       \n        where a.isBaby && n.name = 'qone'\n        select a\n    `)\n\nassert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }])\n```\n\nisBaby is the bool type, and the same way:\na.isBaby = true (equivalent to: a.isBaby)\na.isBaby = false (equivalent to: !a.isBaby)\n\n## qone method\n\nFrom the above, it is found that QOne does not support arithmetic operations of addition, subtraction, multiplication and division. How can be turing-complete ? Method injection to do everything! As shown below:\n\n``` js\nQUnit.test(\"Method test 8\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    qone('sqrt', function (num) {\n        return Math.sqrt(num)\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  sqrt(n) >= 2 \n      select { squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }])\n})\n```\n\nThe method also supports the introduction of multiple parameters, so it can write arbitrary query conditions. select, where, orderby, groupby statements support method injection.\n\n## qone select\n\nselect can output data of various formats and fields:\n\n``` js\nQUnit.test(\"Select JSON test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age < 20\n                select {n.age, n.name}\n            `)\n\n    assert.deepEqual(result, [\n        { \"age\": 1 , \"name\": \"qone\" },\n        { \"age\": 18, \"name\": \"linq\" }\n    ])\n\n})\n``` \n\nList all the scenes:\n\n* `select n` Output source item\n* `select n.name` Output one-dimensional table\n* `select n.name, n.age` Output two-dimensional table\n* `select { n.age, n.name }` Output JSON Array by default (key automatically uses age and name).\n* `select { a: n.age, b: n.name }` Specify the key output JSON Array\n* `select { a: methodName(n.age), b: n.name }` Injection method\n* `select methodName(n.age), n.name` Injection method\n* `select methodName(n.age, n.name, 1, true, 'abc')` Injection method and transfer parameters\n\n\n\n## qone orderby\n\n\n``` js\nvar result = qone({ list }).query(`\n                from n in list   \n                where n.age > 0\n                orderby n.age asc, n.name desc\n                select n\n            `)\n\n``` \n\nIf no asc or desc is marked, use the default sort asc.\n\n## qone groupby\n\n``` js\nQUnit.test(\"Simple groupby test 1\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang1', age: 28 },\n        { name: 'dntzhang2', age: 28 },\n        { name: 'dntzhang3', age: 29 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 18\n                groupby n.age\n            `)\n\n    assert.deepEqual(result, [\n        [{ \"name\": \"dntzhang1\", \"age\": 28 }, { \"name\": \"dntzhang2\", \"age\": 28 }],\n        [{ \"name\": \"dntzhang3\", \"age\": 29 }]])\n\n})\n```\n\ngroupby can be used as an ending statement, without following or following select statements. groupby can also support method injection.\n\n## qone multiple data source\n\n``` js\nQUnit.test(\"Multi datasource with props condition\", function (assert) {\n\n    var listA = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n\n    var listB = [\n        { name: 'x', age: 11 },\n        { name: 'xx', age: 18 },\n        { name: 'xxx', age: 13 }\n    ]\n\n    var result = qone({ listA, listB }).query(`\n            from a in listA     \n            from b in listB      \n            where a.age = b.age\n            select a, b\n        `)\n\n    assert.deepEqual(result, [[{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 18 }]])\n})\n```\n\nThe multi data source produces Cartesian product.\n\n## qone subdata source\n\n``` js\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            from c in a.colors   \n            from d in c.xx  \n            where d === 100\n            select a.name, c,d\n        `)\n\n    assert.deepEqual(result, [[\"linq\", { \"xx\": [100, 2, 3] }, 100]])\n})\n```\n\nIt can also produce Cartesian product with its own data source.\n\n## qone limit and pagination\n\nLimit can cope with the two most common query scenarios - top N and paging.\n\nQuery top3:\n\n``` js\nQUnit.test(\"Limit top 3\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    select n\n                    limit 0, 3\n                `)\n\n\n    assert.deepEqual(result, [\n\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 }\n    ])\n\n})\n``` \n\nPaging query:\n\n``` js\nQUnit.test(\"Limit one page test\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    where n.age > 0\n                    select n\n                    limit ${pageIndex * pageSize}, ${pageSize}\n                `)\n\n\n    assert.deepEqual(result, [\n    { name: 'dntzhang5', age: 5 },\n    { name: 'dntzhang6', age: 6 },\n    { name: 'dntzhang7', age: 7 },\n    { name: 'dntzhang8', age: 8 }])\n\n})\n``` \n\n## star & fork & pr & repl & follow me\n\n* [https://github.com/dntzhang/qone](https://github.com/dntzhang/qone)\n* [https://dntzhang.github.io/qone](https://dntzhang.github.io/qone)\n* [https://github.com/dntzhang](https://github.com/dntzhang)\n"
  },
  {
    "path": "asset/codemirror.css",
    "content": "/* BASICS */\n\n.CodeMirror {\n  /* Set height, width, borders, and global font properties here */\n  font-family: monospace;\n  height: 300px;\n  color: black;\n  direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n  padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre {\n  padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n  background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n  border-right: 1px solid #ddd;\n  background-color: #f7f7f7;\n  white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n  padding: 0 3px 0 5px;\n  min-width: 20px;\n  text-align: right;\n  color: #999;\n  white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n  border-left: 1px solid black;\n  border-right: none;\n  width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n  border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n  width: auto;\n  border: 0 !important;\n  background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n  z-index: 1;\n}\n.cm-fat-cursor-mark {\n  background-color: rgba(20, 255, 20, 0.5);\n  -webkit-animation: blink 1.06s steps(1) infinite;\n  -moz-animation: blink 1.06s steps(1) infinite;\n  animation: blink 1.06s steps(1) infinite;\n}\n.cm-animate-fat-cursor {\n  width: auto;\n  border: 0;\n  -webkit-animation: blink 1.06s steps(1) infinite;\n  -moz-animation: blink 1.06s steps(1) infinite;\n  animation: blink 1.06s steps(1) infinite;\n  background-color: #7e7;\n}\n@-moz-keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n@-webkit-keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n@keyframes blink {\n  0% {}\n  50% { background-color: transparent; }\n  100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n  position: absolute;\n  left: 0; right: 0; top: -50px; bottom: -20px;\n  overflow: hidden;\n}\n.CodeMirror-ruler {\n  border-left: 1px solid #ccc;\n  top: 0; bottom: 0;\n  position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n   the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n  position: relative;\n  overflow: hidden;\n  background: white;\n}\n\n.CodeMirror-scroll {\n  overflow: scroll !important; /* Things will break if this is overridden */\n  /* 30px is the magic margin used to hide the element's real scrollbars */\n  /* See overflow: hidden in .CodeMirror */\n  margin-bottom: -30px; margin-right: -30px;\n  padding-bottom: 30px;\n  height: 100%;\n  outline: none; /* Prevent dragging from highlighting the element */\n  position: relative;\n}\n.CodeMirror-sizer {\n  position: relative;\n  border-right: 30px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n   before actual scrolling happens, thus preventing shaking and\n   flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n  position: absolute;\n  z-index: 6;\n  display: none;\n}\n.CodeMirror-vscrollbar {\n  right: 0; top: 0;\n  overflow-x: hidden;\n  overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n  bottom: 0; left: 0;\n  overflow-y: hidden;\n  overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n  right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n  left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n  position: absolute; left: 0; top: 0;\n  min-height: 100%;\n  z-index: 3;\n}\n.CodeMirror-gutter {\n  white-space: normal;\n  height: 100%;\n  display: inline-block;\n  vertical-align: top;\n  margin-bottom: -30px;\n}\n.CodeMirror-gutter-wrapper {\n  position: absolute;\n  z-index: 4;\n  background: none !important;\n  border: none !important;\n}\n.CodeMirror-gutter-background {\n  position: absolute;\n  top: 0; bottom: 0;\n  z-index: 4;\n}\n.CodeMirror-gutter-elt {\n  position: absolute;\n  cursor: default;\n  z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n  cursor: text;\n  min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre {\n  /* Reset some styles that the rest of the page might have set */\n  -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n  border-width: 0;\n  background: transparent;\n  font-family: inherit;\n  font-size: inherit;\n  margin: 0;\n  white-space: pre;\n  word-wrap: normal;\n  line-height: inherit;\n  color: inherit;\n  z-index: 2;\n  position: relative;\n  overflow: visible;\n  -webkit-tap-highlight-color: transparent;\n  -webkit-font-variant-ligatures: contextual;\n  font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  word-break: normal;\n}\n\n.CodeMirror-linebackground {\n  position: absolute;\n  left: 0; right: 0; top: 0; bottom: 0;\n  z-index: 0;\n}\n\n.CodeMirror-linewidget {\n  position: relative;\n  z-index: 2;\n  padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n  outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n  position: absolute;\n  width: 100%;\n  height: 0;\n  overflow: hidden;\n  visibility: hidden;\n}\n\n.CodeMirror-cursor {\n  position: absolute;\n  pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n  visibility: hidden;\n  position: relative;\n  z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n  visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n  visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n  background-color: #ffa;\n  background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n  /* Hide the cursor when printing */\n  .CodeMirror div.CodeMirror-cursors {\n    visibility: hidden;\n  }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n"
  },
  {
    "path": "asset/codemirror.js",
    "content": "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http://codemirror.net/LICENSE\n\n// This is CodeMirror (http://codemirror.net), a code editor\n// implemented in JavaScript on top of the browser's DOM.\n//\n// You can find some technical background for some of the code below\n// at http://marijnhaverbeke.nl/blog/#cm-internals .\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.CodeMirror = factory());\n  }(this, (function () { 'use strict';\n  \n  // Kludges for bugs and behavior differences that can't be feature\n  // detected are enabled based on userAgent etc sniffing.\n  var userAgent = navigator.userAgent\n  var platform = navigator.platform\n  \n  var gecko = /gecko\\/\\d/i.test(userAgent)\n  var ie_upto10 = /MSIE \\d/.test(userAgent)\n  var ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(userAgent)\n  var ie = ie_upto10 || ie_11up\n  var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1])\n  var webkit = /WebKit\\//.test(userAgent)\n  var qtwebkit = webkit && /Qt\\/\\d+\\.\\d+/.test(userAgent)\n  var chrome = /Chrome\\//.test(userAgent)\n  var presto = /Opera\\//.test(userAgent)\n  var safari = /Apple Computer/.test(navigator.vendor)\n  var mac_geMountainLion = /Mac OS X 1\\d\\D([8-9]|\\d\\d)\\D/.test(userAgent)\n  var phantom = /PhantomJS/.test(userAgent)\n  \n  var ios = /AppleWebKit/.test(userAgent) && /Mobile\\/\\w+/.test(userAgent)\n  // This is woefully incomplete. Suggestions for alternative methods welcome.\n  var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)\n  var mac = ios || /Mac/.test(platform)\n  var chromeOS = /\\bCrOS\\b/.test(userAgent)\n  var windows = /win/i.test(platform)\n  \n  var presto_version = presto && userAgent.match(/Version\\/(\\d*\\.\\d*)/)\n  if (presto_version) { presto_version = Number(presto_version[1]) }\n  if (presto_version && presto_version >= 15) { presto = false; webkit = true }\n  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X\n  var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11))\n  var captureRightClick = gecko || (ie && ie_version >= 9)\n  \n  function classTest(cls) { return new RegExp(\"(^|\\\\s)\" + cls + \"(?:$|\\\\s)\\\\s*\") }\n  \n  var rmClass = function(node, cls) {\n\tvar current = node.className\n\tvar match = classTest(cls).exec(current)\n\tif (match) {\n\t  var after = current.slice(match.index + match[0].length)\n\t  node.className = current.slice(0, match.index) + (after ? match[1] + after : \"\")\n\t}\n  }\n  \n  function removeChildren(e) {\n\tfor (var count = e.childNodes.length; count > 0; --count)\n\t  { e.removeChild(e.firstChild) }\n\treturn e\n  }\n  \n  function removeChildrenAndAdd(parent, e) {\n\treturn removeChildren(parent).appendChild(e)\n  }\n  \n  function elt(tag, content, className, style) {\n\tvar e = document.createElement(tag)\n\tif (className) { e.className = className }\n\tif (style) { e.style.cssText = style }\n\tif (typeof content == \"string\") { e.appendChild(document.createTextNode(content)) }\n\telse if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }\n\treturn e\n  }\n  \n  var range\n  if (document.createRange) { range = function(node, start, end, endNode) {\n\tvar r = document.createRange()\n\tr.setEnd(endNode || node, end)\n\tr.setStart(node, start)\n\treturn r\n  } }\n  else { range = function(node, start, end) {\n\tvar r = document.body.createTextRange()\n\ttry { r.moveToElementText(node.parentNode) }\n\tcatch(e) { return r }\n\tr.collapse(true)\n\tr.moveEnd(\"character\", end)\n\tr.moveStart(\"character\", start)\n\treturn r\n  } }\n  \n  function contains(parent, child) {\n\tif (child.nodeType == 3) // Android browser always returns false when child is a textnode\n\t  { child = child.parentNode }\n\tif (parent.contains)\n\t  { return parent.contains(child) }\n\tdo {\n\t  if (child.nodeType == 11) { child = child.host }\n\t  if (child == parent) { return true }\n\t} while (child = child.parentNode)\n  }\n  \n  var activeElt = function() {\n\tvar activeElement = document.activeElement\n\twhile (activeElement && activeElement.root && activeElement.root.activeElement)\n\t  { activeElement = activeElement.root.activeElement }\n\treturn activeElement\n  }\n  // Older versions of IE throws unspecified error when touching\n  // document.activeElement in some cases (during loading, in iframe)\n  if (ie && ie_version < 11) { activeElt = function() {\n\ttry { return document.activeElement }\n\tcatch(e) { return document.body }\n  } }\n  \n  function addClass(node, cls) {\n\tvar current = node.className\n\tif (!classTest(cls).test(current)) { node.className += (current ? \" \" : \"\") + cls }\n  }\n  function joinClasses(a, b) {\n\tvar as = a.split(\" \")\n\tfor (var i = 0; i < as.length; i++)\n\t  { if (as[i] && !classTest(as[i]).test(b)) { b += \" \" + as[i] } }\n\treturn b\n  }\n  \n  var selectInput = function(node) { node.select() }\n  if (ios) // Mobile Safari apparently has a bug where select() is broken.\n\t{ selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length } }\n  else if (ie) // Suppress mysterious IE10 errors\n\t{ selectInput = function(node) { try { node.select() } catch(_e) {} } }\n  \n  function bind(f) {\n\tvar args = Array.prototype.slice.call(arguments, 1)\n\treturn function(){return f.apply(null, args)}\n  }\n  \n  function copyObj(obj, target, overwrite) {\n\tif (!target) { target = {} }\n\tfor (var prop in obj)\n\t  { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))\n\t\t{ target[prop] = obj[prop] } }\n\treturn target\n  }\n  \n  // Counts the column offset in a string, taking tabs into account.\n  // Used mostly to find indentation.\n  function countColumn(string, end, tabSize, startIndex, startValue) {\n\tif (end == null) {\n\t  end = string.search(/[^\\s\\u00a0]/)\n\t  if (end == -1) { end = string.length }\n\t}\n\tfor (var i = startIndex || 0, n = startValue || 0;;) {\n\t  var nextTab = string.indexOf(\"\\t\", i)\n\t  if (nextTab < 0 || nextTab >= end)\n\t\t{ return n + (end - i) }\n\t  n += nextTab - i\n\t  n += tabSize - (n % tabSize)\n\t  i = nextTab + 1\n\t}\n  }\n  \n  function Delayed() {this.id = null}\n  Delayed.prototype.set = function(ms, f) {\n\tclearTimeout(this.id)\n\tthis.id = setTimeout(f, ms)\n  }\n  \n  function indexOf(array, elt) {\n\tfor (var i = 0; i < array.length; ++i)\n\t  { if (array[i] == elt) { return i } }\n\treturn -1\n  }\n  \n  // Number of pixels added to scroller and sizer to hide scrollbar\n  var scrollerGap = 30\n  \n  // Returned or thrown by various protocols to signal 'I'm not\n  // handling this'.\n  var Pass = {toString: function(){return \"CodeMirror.Pass\"}}\n  \n  // Reused option objects for setSelection & friends\n  var sel_dontScroll = {scroll: false};\n  var sel_mouse = {origin: \"*mouse\"};\n  var sel_move = {origin: \"+move\"};\n  // The inverse of countColumn -- find the offset that corresponds to\n  // a particular column.\n  function findColumn(string, goal, tabSize) {\n\tfor (var pos = 0, col = 0;;) {\n\t  var nextTab = string.indexOf(\"\\t\", pos)\n\t  if (nextTab == -1) { nextTab = string.length }\n\t  var skipped = nextTab - pos\n\t  if (nextTab == string.length || col + skipped >= goal)\n\t\t{ return pos + Math.min(skipped, goal - col) }\n\t  col += nextTab - pos\n\t  col += tabSize - (col % tabSize)\n\t  pos = nextTab + 1\n\t  if (col >= goal) { return pos }\n\t}\n  }\n  \n  var spaceStrs = [\"\"]\n  function spaceStr(n) {\n\twhile (spaceStrs.length <= n)\n\t  { spaceStrs.push(lst(spaceStrs) + \" \") }\n\treturn spaceStrs[n]\n  }\n  \n  function lst(arr) { return arr[arr.length-1] }\n  \n  function map(array, f) {\n\tvar out = []\n\tfor (var i = 0; i < array.length; i++) { out[i] = f(array[i], i) }\n\treturn out\n  }\n  \n  function insertSorted(array, value, score) {\n\tvar pos = 0, priority = score(value)\n\twhile (pos < array.length && score(array[pos]) <= priority) { pos++ }\n\tarray.splice(pos, 0, value)\n  }\n  \n  function nothing() {}\n  \n  function createObj(base, props) {\n\tvar inst\n\tif (Object.create) {\n\t  inst = Object.create(base)\n\t} else {\n\t  nothing.prototype = base\n\t  inst = new nothing()\n\t}\n\tif (props) { copyObj(props, inst) }\n\treturn inst\n  }\n  \n  var nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/\n  function isWordCharBasic(ch) {\n\treturn /\\w/.test(ch) || ch > \"\\x80\" &&\n\t  (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))\n  }\n  function isWordChar(ch, helper) {\n\tif (!helper) { return isWordCharBasic(ch) }\n\tif (helper.source.indexOf(\"\\\\w\") > -1 && isWordCharBasic(ch)) { return true }\n\treturn helper.test(ch)\n  }\n  \n  function isEmpty(obj) {\n\tfor (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }\n\treturn true\n  }\n  \n  // Extending unicode characters. A series of a non-extending char +\n  // any number of extending chars is treated as a single unit as far\n  // as editing and measuring is concerned. This is not fully correct,\n  // since some scripts/fonts/browsers also treat other configurations\n  // of code points as a group.\n  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]/\n  function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }\n  \n  // The display handles the DOM integration, both for input reading\n  // and content drawing. It holds references to DOM nodes and\n  // display-related state.\n  \n  function Display(place, doc, input) {\n\tvar d = this\n\tthis.input = input\n  \n\t// Covers bottom-right square when both scrollbars are present.\n\td.scrollbarFiller = elt(\"div\", null, \"CodeMirror-scrollbar-filler\")\n\td.scrollbarFiller.setAttribute(\"cm-not-content\", \"true\")\n\t// Covers bottom of gutter when coverGutterNextToScrollbar is on\n\t// and h scrollbar is present.\n\td.gutterFiller = elt(\"div\", null, \"CodeMirror-gutter-filler\")\n\td.gutterFiller.setAttribute(\"cm-not-content\", \"true\")\n\t// Will contain the actual code, positioned to cover the viewport.\n\td.lineDiv = elt(\"div\", null, \"CodeMirror-code\")\n\t// Elements are added to these to represent selection and cursors.\n\td.selectionDiv = elt(\"div\", null, null, \"position: relative; z-index: 1\")\n\td.cursorDiv = elt(\"div\", null, \"CodeMirror-cursors\")\n\t// A visibility: hidden element used to find the size of things.\n\td.measure = elt(\"div\", null, \"CodeMirror-measure\")\n\t// When lines outside of the viewport are measured, they are drawn in this.\n\td.lineMeasure = elt(\"div\", null, \"CodeMirror-measure\")\n\t// Wraps everything that needs to exist inside the vertically-padded coordinate system\n\td.lineSpace = elt(\"div\", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],\n\t\t\t\t\t  null, \"position: relative; outline: none\")\n\t// Moved around its parent to cover visible view.\n\td.mover = elt(\"div\", [elt(\"div\", [d.lineSpace], \"CodeMirror-lines\")], null, \"position: relative\")\n\t// Set to the height of the document, allowing scrolling.\n\td.sizer = elt(\"div\", [d.mover], \"CodeMirror-sizer\")\n\td.sizerWidth = null\n\t// Behavior of elts with overflow: auto and padding is\n\t// inconsistent across browsers. This is used to ensure the\n\t// scrollable area is big enough.\n\td.heightForcer = elt(\"div\", null, null, \"position: absolute; height: \" + scrollerGap + \"px; width: 1px;\")\n\t// Will contain the gutters, if any.\n\td.gutters = elt(\"div\", null, \"CodeMirror-gutters\")\n\td.lineGutter = null\n\t// Actual scrollable element.\n\td.scroller = elt(\"div\", [d.sizer, d.heightForcer, d.gutters], \"CodeMirror-scroll\")\n\td.scroller.setAttribute(\"tabIndex\", \"-1\")\n\t// The element in which the editor lives.\n\td.wrapper = elt(\"div\", [d.scrollbarFiller, d.gutterFiller, d.scroller], \"CodeMirror\")\n  \n\t// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)\n\tif (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 }\n\tif (!webkit && !(gecko && mobile)) { d.scroller.draggable = true }\n  \n\tif (place) {\n\t  if (place.appendChild) { place.appendChild(d.wrapper) }\n\t  else { place(d.wrapper) }\n\t}\n  \n\t// Current rendered range (may be bigger than the view window).\n\td.viewFrom = d.viewTo = doc.first\n\td.reportedViewFrom = d.reportedViewTo = doc.first\n\t// Information about the rendered lines.\n\td.view = []\n\td.renderedView = null\n\t// Holds info about a single rendered line when it was rendered\n\t// for measurement, while not in view.\n\td.externalMeasured = null\n\t// Empty space (in pixels) above the view\n\td.viewOffset = 0\n\td.lastWrapHeight = d.lastWrapWidth = 0\n\td.updateLineNumbers = null\n  \n\td.nativeBarWidth = d.barHeight = d.barWidth = 0\n\td.scrollbarsClipped = false\n  \n\t// Used to only resize the line number gutter when necessary (when\n\t// the amount of lines crosses a boundary that makes its width change)\n\td.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null\n\t// Set to true when a non-horizontal-scrolling line widget is\n\t// added. As an optimization, line widget aligning is skipped when\n\t// this is false.\n\td.alignWidgets = false\n  \n\td.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null\n  \n\t// Tracks the maximum line length so that the horizontal scrollbar\n\t// can be kept static when scrolling.\n\td.maxLine = null\n\td.maxLineLength = 0\n\td.maxLineChanged = false\n  \n\t// Used for measuring wheel scrolling granularity\n\td.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null\n  \n\t// True when shift is held down.\n\td.shift = false\n  \n\t// Used to track whether anything happened since the context menu\n\t// was opened.\n\td.selForContextMenu = null\n  \n\td.activeTouch = null\n  \n\tinput.init(d)\n  }\n  \n  // Find the line object corresponding to the given line number.\n  function getLine(doc, n) {\n\tn -= doc.first\n\tif (n < 0 || n >= doc.size) { throw new Error(\"There is no line \" + (n + doc.first) + \" in the document.\") }\n\tvar chunk = doc\n\twhile (!chunk.lines) {\n\t  for (var i = 0;; ++i) {\n\t\tvar child = chunk.children[i], sz = child.chunkSize()\n\t\tif (n < sz) { chunk = child; break }\n\t\tn -= sz\n\t  }\n\t}\n\treturn chunk.lines[n]\n  }\n  \n  // Get the part of a document between two positions, as an array of\n  // strings.\n  function getBetween(doc, start, end) {\n\tvar out = [], n = start.line\n\tdoc.iter(start.line, end.line + 1, function (line) {\n\t  var text = line.text\n\t  if (n == end.line) { text = text.slice(0, end.ch) }\n\t  if (n == start.line) { text = text.slice(start.ch) }\n\t  out.push(text)\n\t  ++n\n\t})\n\treturn out\n  }\n  // Get the lines between from and to, as array of strings.\n  function getLines(doc, from, to) {\n\tvar out = []\n\tdoc.iter(from, to, function (line) { out.push(line.text) }) // iter aborts when callback returns truthy value\n\treturn out\n  }\n  \n  // Update the height of a line, propagating the height change\n  // upwards to parent nodes.\n  function updateLineHeight(line, height) {\n\tvar diff = height - line.height\n\tif (diff) { for (var n = line; n; n = n.parent) { n.height += diff } }\n  }\n  \n  // Given a line object, find its line number by walking up through\n  // its parent links.\n  function lineNo(line) {\n\tif (line.parent == null) { return null }\n\tvar cur = line.parent, no = indexOf(cur.lines, line)\n\tfor (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {\n\t  for (var i = 0;; ++i) {\n\t\tif (chunk.children[i] == cur) { break }\n\t\tno += chunk.children[i].chunkSize()\n\t  }\n\t}\n\treturn no + cur.first\n  }\n  \n  // Find the line at the given vertical position, using the height\n  // information in the document tree.\n  function lineAtHeight(chunk, h) {\n\tvar n = chunk.first\n\touter: do {\n\t  for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {\n\t\tvar child = chunk.children[i$1], ch = child.height\n\t\tif (h < ch) { chunk = child; continue outer }\n\t\th -= ch\n\t\tn += child.chunkSize()\n\t  }\n\t  return n\n\t} while (!chunk.lines)\n\tvar i = 0\n\tfor (; i < chunk.lines.length; ++i) {\n\t  var line = chunk.lines[i], lh = line.height\n\t  if (h < lh) { break }\n\t  h -= lh\n\t}\n\treturn n + i\n  }\n  \n  function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}\n  \n  function lineNumberFor(options, i) {\n\treturn String(options.lineNumberFormatter(i + options.firstLineNumber))\n  }\n  \n  // A Pos instance represents a position within the text.\n  function Pos (line, ch) {\n\tif (!(this instanceof Pos)) { return new Pos(line, ch) }\n\tthis.line = line; this.ch = ch\n  }\n  \n  // Compare two positions, return 0 if they are the same, a negative\n  // number when a is less, and a positive number otherwise.\n  function cmp(a, b) { return a.line - b.line || a.ch - b.ch }\n  \n  function copyPos(x) {return Pos(x.line, x.ch)}\n  function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }\n  function minPos(a, b) { return cmp(a, b) < 0 ? a : b }\n  \n  // Most of the external API clips given positions to make sure they\n  // actually exist within the document.\n  function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}\n  function clipPos(doc, pos) {\n\tif (pos.line < doc.first) { return Pos(doc.first, 0) }\n\tvar last = doc.first + doc.size - 1\n\tif (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }\n\treturn clipToLen(pos, getLine(doc, pos.line).text.length)\n  }\n  function clipToLen(pos, linelen) {\n\tvar ch = pos.ch\n\tif (ch == null || ch > linelen) { return Pos(pos.line, linelen) }\n\telse if (ch < 0) { return Pos(pos.line, 0) }\n\telse { return pos }\n  }\n  function clipPosArray(doc, array) {\n\tvar out = []\n\tfor (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]) }\n\treturn out\n  }\n  \n  // Optimize some code when these features are not used.\n  var sawReadOnlySpans = false;\n  var sawCollapsedSpans = false;\n  function seeReadOnlySpans() {\n\tsawReadOnlySpans = true\n  }\n  \n  function seeCollapsedSpans() {\n\tsawCollapsedSpans = true\n  }\n  \n  // TEXTMARKER SPANS\n  \n  function MarkedSpan(marker, from, to) {\n\tthis.marker = marker\n\tthis.from = from; this.to = to\n  }\n  \n  // Search an array of spans for a span matching the given marker.\n  function getMarkedSpanFor(spans, marker) {\n\tif (spans) { for (var i = 0; i < spans.length; ++i) {\n\t  var span = spans[i]\n\t  if (span.marker == marker) { return span }\n\t} }\n  }\n  // Remove a span from an array, returning undefined if no spans are\n  // left (we don't store arrays for lines without spans).\n  function removeMarkedSpan(spans, span) {\n\tvar r\n\tfor (var i = 0; i < spans.length; ++i)\n\t  { if (spans[i] != span) { (r || (r = [])).push(spans[i]) } }\n\treturn r\n  }\n  // Add a span to a line.\n  function addMarkedSpan(line, span) {\n\tline.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]\n\tspan.marker.attachLine(line)\n  }\n  \n  // Used for the algorithm that adjusts markers for a change in the\n  // document. These functions cut an array of spans at a given\n  // character position, returning an array of remaining chunks (or\n  // undefined if nothing remains).\n  function markedSpansBefore(old, startCh, isInsert) {\n\tvar nw\n\tif (old) { for (var i = 0; i < old.length; ++i) {\n\t  var span = old[i], marker = span.marker\n\t  var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh)\n\t  if (startsBefore || span.from == startCh && marker.type == \"bookmark\" && (!isInsert || !span.marker.insertLeft)) {\n\t\tvar endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)\n\t\t;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to))\n\t  }\n\t} }\n\treturn nw\n  }\n  function markedSpansAfter(old, endCh, isInsert) {\n\tvar nw\n\tif (old) { for (var i = 0; i < old.length; ++i) {\n\t  var span = old[i], marker = span.marker\n\t  var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh)\n\t  if (endsAfter || span.from == endCh && marker.type == \"bookmark\" && (!isInsert || span.marker.insertLeft)) {\n\t\tvar startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)\n\t\t;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,\n\t\t\t\t\t\t\t\t\t\t\t  span.to == null ? null : span.to - endCh))\n\t  }\n\t} }\n\treturn nw\n  }\n  \n  // Given a change object, compute the new set of marker spans that\n  // cover the line in which the change took place. Removes spans\n  // entirely within the change, reconnects spans belonging to the\n  // same marker that appear on both sides of the change, and cuts off\n  // spans partially within the change. Returns an array of span\n  // arrays with one element for each line in (after) the change.\n  function stretchSpansOverChange(doc, change) {\n\tif (change.full) { return null }\n\tvar oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans\n\tvar oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans\n\tif (!oldFirst && !oldLast) { return null }\n  \n\tvar startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0\n\t// Get the spans that 'stick out' on both sides\n\tvar first = markedSpansBefore(oldFirst, startCh, isInsert)\n\tvar last = markedSpansAfter(oldLast, endCh, isInsert)\n  \n\t// Next, merge those two ends\n\tvar sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0)\n\tif (first) {\n\t  // Fix up .to properties of first\n\t  for (var i = 0; i < first.length; ++i) {\n\t\tvar span = first[i]\n\t\tif (span.to == null) {\n\t\t  var found = getMarkedSpanFor(last, span.marker)\n\t\t  if (!found) { span.to = startCh }\n\t\t  else if (sameLine) { span.to = found.to == null ? null : found.to + offset }\n\t\t}\n\t  }\n\t}\n\tif (last) {\n\t  // Fix up .from in last (or move them into first in case of sameLine)\n\t  for (var i$1 = 0; i$1 < last.length; ++i$1) {\n\t\tvar span$1 = last[i$1]\n\t\tif (span$1.to != null) { span$1.to += offset }\n\t\tif (span$1.from == null) {\n\t\t  var found$1 = getMarkedSpanFor(first, span$1.marker)\n\t\t  if (!found$1) {\n\t\t\tspan$1.from = offset\n\t\t\tif (sameLine) { (first || (first = [])).push(span$1) }\n\t\t  }\n\t\t} else {\n\t\t  span$1.from += offset\n\t\t  if (sameLine) { (first || (first = [])).push(span$1) }\n\t\t}\n\t  }\n\t}\n\t// Make sure we didn't create any zero-length spans\n\tif (first) { first = clearEmptySpans(first) }\n\tif (last && last != first) { last = clearEmptySpans(last) }\n  \n\tvar newMarkers = [first]\n\tif (!sameLine) {\n\t  // Fill gap with whole-line-spans\n\t  var gap = change.text.length - 2, gapMarkers\n\t  if (gap > 0 && first)\n\t\t{ for (var i$2 = 0; i$2 < first.length; ++i$2)\n\t\t  { if (first[i$2].to == null)\n\t\t\t{ (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)) } } }\n\t  for (var i$3 = 0; i$3 < gap; ++i$3)\n\t\t{ newMarkers.push(gapMarkers) }\n\t  newMarkers.push(last)\n\t}\n\treturn newMarkers\n  }\n  \n  // Remove spans that are empty and don't have a clearWhenEmpty\n  // option of false.\n  function clearEmptySpans(spans) {\n\tfor (var i = 0; i < spans.length; ++i) {\n\t  var span = spans[i]\n\t  if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)\n\t\t{ spans.splice(i--, 1) }\n\t}\n\tif (!spans.length) { return null }\n\treturn spans\n  }\n  \n  // Used to 'clip' out readOnly ranges when making a change.\n  function removeReadOnlyRanges(doc, from, to) {\n\tvar markers = null\n\tdoc.iter(from.line, to.line + 1, function (line) {\n\t  if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {\n\t\tvar mark = line.markedSpans[i].marker\n\t\tif (mark.readOnly && (!markers || indexOf(markers, mark) == -1))\n\t\t  { (markers || (markers = [])).push(mark) }\n\t  } }\n\t})\n\tif (!markers) { return null }\n\tvar parts = [{from: from, to: to}]\n\tfor (var i = 0; i < markers.length; ++i) {\n\t  var mk = markers[i], m = mk.find(0)\n\t  for (var j = 0; j < parts.length; ++j) {\n\t\tvar p = parts[j]\n\t\tif (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }\n\t\tvar newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to)\n\t\tif (dfrom < 0 || !mk.inclusiveLeft && !dfrom)\n\t\t  { newParts.push({from: p.from, to: m.from}) }\n\t\tif (dto > 0 || !mk.inclusiveRight && !dto)\n\t\t  { newParts.push({from: m.to, to: p.to}) }\n\t\tparts.splice.apply(parts, newParts)\n\t\tj += newParts.length - 1\n\t  }\n\t}\n\treturn parts\n  }\n  \n  // Connect or disconnect spans from a line.\n  function detachMarkedSpans(line) {\n\tvar spans = line.markedSpans\n\tif (!spans) { return }\n\tfor (var i = 0; i < spans.length; ++i)\n\t  { spans[i].marker.detachLine(line) }\n\tline.markedSpans = null\n  }\n  function attachMarkedSpans(line, spans) {\n\tif (!spans) { return }\n\tfor (var i = 0; i < spans.length; ++i)\n\t  { spans[i].marker.attachLine(line) }\n\tline.markedSpans = spans\n  }\n  \n  // Helpers used when computing which overlapping collapsed span\n  // counts as the larger one.\n  function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }\n  function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }\n  \n  // Returns a number indicating which of two overlapping collapsed\n  // spans is larger (and thus includes the other). Falls back to\n  // comparing ids when the spans cover exactly the same range.\n  function compareCollapsedMarkers(a, b) {\n\tvar lenDiff = a.lines.length - b.lines.length\n\tif (lenDiff != 0) { return lenDiff }\n\tvar aPos = a.find(), bPos = b.find()\n\tvar fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b)\n\tif (fromCmp) { return -fromCmp }\n\tvar toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b)\n\tif (toCmp) { return toCmp }\n\treturn b.id - a.id\n  }\n  \n  // Find out whether a line ends or starts in a collapsed span. If\n  // so, return the marker for that span.\n  function collapsedSpanAtSide(line, start) {\n\tvar sps = sawCollapsedSpans && line.markedSpans, found\n\tif (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) {\n\t  sp = sps[i]\n\t  if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&\n\t\t  (!found || compareCollapsedMarkers(found, sp.marker) < 0))\n\t\t{ found = sp.marker }\n\t} }\n\treturn found\n  }\n  function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }\n  function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }\n  \n  // Test whether there exists a collapsed span that partially\n  // overlaps (covers the start or end, but not both) of a new span.\n  // Such overlap is not allowed.\n  function conflictingCollapsedRange(doc, lineNo, from, to, marker) {\n\tvar line = getLine(doc, lineNo)\n\tvar sps = sawCollapsedSpans && line.markedSpans\n\tif (sps) { for (var i = 0; i < sps.length; ++i) {\n\t  var sp = sps[i]\n\t  if (!sp.marker.collapsed) { continue }\n\t  var found = sp.marker.find(0)\n\t  var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker)\n\t  var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker)\n\t  if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }\n\t  if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||\n\t\t  fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))\n\t\t{ return true }\n\t} }\n  }\n  \n  // A visual line is a line as drawn on the screen. Folding, for\n  // example, can cause multiple logical lines to appear on the same\n  // visual line. This finds the start of the visual line that the\n  // given line is part of (usually that is the line itself).\n  function visualLine(line) {\n\tvar merged\n\twhile (merged = collapsedSpanAtStart(line))\n\t  { line = merged.find(-1, true).line }\n\treturn line\n  }\n  \n  // Returns an array of logical lines that continue the visual line\n  // started by the argument, or undefined if there are no such lines.\n  function visualLineContinued(line) {\n\tvar merged, lines\n\twhile (merged = collapsedSpanAtEnd(line)) {\n\t  line = merged.find(1, true).line\n\t  ;(lines || (lines = [])).push(line)\n\t}\n\treturn lines\n  }\n  \n  // Get the line number of the start of the visual line that the\n  // given line number is part of.\n  function visualLineNo(doc, lineN) {\n\tvar line = getLine(doc, lineN), vis = visualLine(line)\n\tif (line == vis) { return lineN }\n\treturn lineNo(vis)\n  }\n  \n  // Get the line number of the start of the next visual line after\n  // the given line.\n  function visualLineEndNo(doc, lineN) {\n\tif (lineN > doc.lastLine()) { return lineN }\n\tvar line = getLine(doc, lineN), merged\n\tif (!lineIsHidden(doc, line)) { return lineN }\n\twhile (merged = collapsedSpanAtEnd(line))\n\t  { line = merged.find(1, true).line }\n\treturn lineNo(line) + 1\n  }\n  \n  // Compute whether a line is hidden. Lines count as hidden when they\n  // are part of a visual line that starts with another line, or when\n  // they are entirely covered by collapsed, non-widget span.\n  function lineIsHidden(doc, line) {\n\tvar sps = sawCollapsedSpans && line.markedSpans\n\tif (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) {\n\t  sp = sps[i]\n\t  if (!sp.marker.collapsed) { continue }\n\t  if (sp.from == null) { return true }\n\t  if (sp.marker.widgetNode) { continue }\n\t  if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))\n\t\t{ return true }\n\t} }\n  }\n  function lineIsHiddenInner(doc, line, span) {\n\tif (span.to == null) {\n\t  var end = span.marker.find(1, true)\n\t  return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))\n\t}\n\tif (span.marker.inclusiveRight && span.to == line.text.length)\n\t  { return true }\n\tfor (var sp = void 0, i = 0; i < line.markedSpans.length; ++i) {\n\t  sp = line.markedSpans[i]\n\t  if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&\n\t\t  (sp.to == null || sp.to != span.from) &&\n\t\t  (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&\n\t\t  lineIsHiddenInner(doc, line, sp)) { return true }\n\t}\n  }\n  \n  // Find the height above the given line.\n  function heightAtLine(lineObj) {\n\tlineObj = visualLine(lineObj)\n  \n\tvar h = 0, chunk = lineObj.parent\n\tfor (var i = 0; i < chunk.lines.length; ++i) {\n\t  var line = chunk.lines[i]\n\t  if (line == lineObj) { break }\n\t  else { h += line.height }\n\t}\n\tfor (var p = chunk.parent; p; chunk = p, p = chunk.parent) {\n\t  for (var i$1 = 0; i$1 < p.children.length; ++i$1) {\n\t\tvar cur = p.children[i$1]\n\t\tif (cur == chunk) { break }\n\t\telse { h += cur.height }\n\t  }\n\t}\n\treturn h\n  }\n  \n  // Compute the character length of a line, taking into account\n  // collapsed ranges (see markText) that might hide parts, and join\n  // other lines onto it.\n  function lineLength(line) {\n\tif (line.height == 0) { return 0 }\n\tvar len = line.text.length, merged, cur = line\n\twhile (merged = collapsedSpanAtStart(cur)) {\n\t  var found = merged.find(0, true)\n\t  cur = found.from.line\n\t  len += found.from.ch - found.to.ch\n\t}\n\tcur = line\n\twhile (merged = collapsedSpanAtEnd(cur)) {\n\t  var found$1 = merged.find(0, true)\n\t  len -= cur.text.length - found$1.from.ch\n\t  cur = found$1.to.line\n\t  len += cur.text.length - found$1.to.ch\n\t}\n\treturn len\n  }\n  \n  // Find the longest line in the document.\n  function findMaxLine(cm) {\n\tvar d = cm.display, doc = cm.doc\n\td.maxLine = getLine(doc, doc.first)\n\td.maxLineLength = lineLength(d.maxLine)\n\td.maxLineChanged = true\n\tdoc.iter(function (line) {\n\t  var len = lineLength(line)\n\t  if (len > d.maxLineLength) {\n\t\td.maxLineLength = len\n\t\td.maxLine = line\n\t  }\n\t})\n  }\n  \n  // BIDI HELPERS\n  \n  function iterateBidiSections(order, from, to, f) {\n\tif (!order) { return f(from, to, \"ltr\") }\n\tvar found = false\n\tfor (var i = 0; i < order.length; ++i) {\n\t  var part = order[i]\n\t  if (part.from < to && part.to > from || from == to && part.to == from) {\n\t\tf(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? \"rtl\" : \"ltr\")\n\t\tfound = true\n\t  }\n\t}\n\tif (!found) { f(from, to, \"ltr\") }\n  }\n  \n  function bidiLeft(part) { return part.level % 2 ? part.to : part.from }\n  function bidiRight(part) { return part.level % 2 ? part.from : part.to }\n  \n  function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0 }\n  function lineRight(line) {\n\tvar order = getOrder(line)\n\tif (!order) { return line.text.length }\n\treturn bidiRight(lst(order))\n  }\n  \n  function compareBidiLevel(order, a, b) {\n\tvar linedir = order[0].level\n\tif (a == linedir) { return true }\n\tif (b == linedir) { return false }\n\treturn a < b\n  }\n  \n  var bidiOther = null\n  function getBidiPartAt(order, pos) {\n\tvar found\n\tbidiOther = null\n\tfor (var i = 0; i < order.length; ++i) {\n\t  var cur = order[i]\n\t  if (cur.from < pos && cur.to > pos) { return i }\n\t  if ((cur.from == pos || cur.to == pos)) {\n\t\tif (found == null) {\n\t\t  found = i\n\t\t} else if (compareBidiLevel(order, cur.level, order[found].level)) {\n\t\t  if (cur.from != cur.to) { bidiOther = found }\n\t\t  return i\n\t\t} else {\n\t\t  if (cur.from != cur.to) { bidiOther = i }\n\t\t  return found\n\t\t}\n\t  }\n\t}\n\treturn found\n  }\n  \n  function moveInLine(line, pos, dir, byUnit) {\n\tif (!byUnit) { return pos + dir }\n\tdo { pos += dir }\n\twhile (pos > 0 && isExtendingChar(line.text.charAt(pos)))\n\treturn pos\n  }\n  \n  // This is needed in order to move 'visually' through bi-directional\n  // text -- i.e., pressing left should make the cursor go left, even\n  // when in RTL text. The tricky part is the 'jumps', where RTL and\n  // LTR text touch each other. This often requires the cursor offset\n  // to move more than one unit, in order to visually move one unit.\n  function moveVisually(line, start, dir, byUnit) {\n\tvar bidi = getOrder(line)\n\tif (!bidi) { return moveLogically(line, start, dir, byUnit) }\n\tvar pos = getBidiPartAt(bidi, start), part = bidi[pos]\n\tvar target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit)\n  \n\tfor (;;) {\n\t  if (target > part.from && target < part.to) { return target }\n\t  if (target == part.from || target == part.to) {\n\t\tif (getBidiPartAt(bidi, target) == pos) { return target }\n\t\tpart = bidi[pos += dir]\n\t\treturn (dir > 0) == part.level % 2 ? part.to : part.from\n\t  } else {\n\t\tpart = bidi[pos += dir]\n\t\tif (!part) { return null }\n\t\tif ((dir > 0) == part.level % 2)\n\t\t  { target = moveInLine(line, part.to, -1, byUnit) }\n\t\telse\n\t\t  { target = moveInLine(line, part.from, 1, byUnit) }\n\t  }\n\t}\n  }\n  \n  function moveLogically(line, start, dir, byUnit) {\n\tvar target = start + dir\n\tif (byUnit) { while (target > 0 && isExtendingChar(line.text.charAt(target))) { target += dir } }\n\treturn target < 0 || target > line.text.length ? null : target\n  }\n  \n  // Bidirectional ordering algorithm\n  // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm\n  // that this (partially) implements.\n  \n  // One-char codes used for character types:\n  // L (L):   Left-to-Right\n  // R (R):   Right-to-Left\n  // r (AL):  Right-to-Left Arabic\n  // 1 (EN):  European Number\n  // + (ES):  European Number Separator\n  // % (ET):  European Number Terminator\n  // n (AN):  Arabic Number\n  // , (CS):  Common Number Separator\n  // m (NSM): Non-Spacing Mark\n  // b (BN):  Boundary Neutral\n  // s (B):   Paragraph Separator\n  // t (S):   Segment Separator\n  // w (WS):  Whitespace\n  // N (ON):  Other Neutrals\n  \n  // Returns null if characters are ordered as they appear\n  // (left-to-right), or an array of sections ({from, to, level}\n  // objects) in the order in which they occur visually.\n  var bidiOrdering = (function() {\n\t// Character types for codepoints 0 to 0xff\n\tvar lowTypes = \"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN\"\n\t// Character types for codepoints 0x600 to 0x6ff\n\tvar arabicTypes = \"rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm\"\n\tfunction charType(code) {\n\t  if (code <= 0xf7) { return lowTypes.charAt(code) }\n\t  else if (0x590 <= code && code <= 0x5f4) { return \"R\" }\n\t  else if (0x600 <= code && code <= 0x6ed) { return arabicTypes.charAt(code - 0x600) }\n\t  else if (0x6ee <= code && code <= 0x8ac) { return \"r\" }\n\t  else if (0x2000 <= code && code <= 0x200b) { return \"w\" }\n\t  else if (code == 0x200c) { return \"b\" }\n\t  else { return \"L\" }\n\t}\n  \n\tvar bidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/\n\tvar isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/\n\t// Browsers seem to always treat the boundaries of block elements as being L.\n\tvar outerType = \"L\"\n  \n\tfunction BidiSpan(level, from, to) {\n\t  this.level = level\n\t  this.from = from; this.to = to\n\t}\n  \n\treturn function(str) {\n\t  if (!bidiRE.test(str)) { return false }\n\t  var len = str.length, types = []\n\t  for (var i = 0; i < len; ++i)\n\t\t{ types.push(charType(str.charCodeAt(i))) }\n  \n\t  // W1. Examine each non-spacing mark (NSM) in the level run, and\n\t  // change the type of the NSM to the type of the previous\n\t  // character. If the NSM is at the start of the level run, it will\n\t  // get the type of sor.\n\t  for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {\n\t\tvar type = types[i$1]\n\t\tif (type == \"m\") { types[i$1] = prev }\n\t\telse { prev = type }\n\t  }\n  \n\t  // W2. Search backwards from each instance of a European number\n\t  // until the first strong type (R, L, AL, or sor) is found. If an\n\t  // AL is found, change the type of the European number to Arabic\n\t  // number.\n\t  // W3. Change all ALs to R.\n\t  for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {\n\t\tvar type$1 = types[i$2]\n\t\tif (type$1 == \"1\" && cur == \"r\") { types[i$2] = \"n\" }\n\t\telse if (isStrong.test(type$1)) { cur = type$1; if (type$1 == \"r\") { types[i$2] = \"R\" } }\n\t  }\n  \n\t  // W4. A single European separator between two European numbers\n\t  // changes to a European number. A single common separator between\n\t  // two numbers of the same type changes to that type.\n\t  for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {\n\t\tvar type$2 = types[i$3]\n\t\tif (type$2 == \"+\" && prev$1 == \"1\" && types[i$3+1] == \"1\") { types[i$3] = \"1\" }\n\t\telse if (type$2 == \",\" && prev$1 == types[i$3+1] &&\n\t\t\t\t (prev$1 == \"1\" || prev$1 == \"n\")) { types[i$3] = prev$1 }\n\t\tprev$1 = type$2\n\t  }\n  \n\t  // W5. A sequence of European terminators adjacent to European\n\t  // numbers changes to all European numbers.\n\t  // W6. Otherwise, separators and terminators change to Other\n\t  // Neutral.\n\t  for (var i$4 = 0; i$4 < len; ++i$4) {\n\t\tvar type$3 = types[i$4]\n\t\tif (type$3 == \",\") { types[i$4] = \"N\" }\n\t\telse if (type$3 == \"%\") {\n\t\t  var end = void 0\n\t\t  for (end = i$4 + 1; end < len && types[end] == \"%\"; ++end) {}\n\t\t  var replace = (i$4 && types[i$4-1] == \"!\") || (end < len && types[end] == \"1\") ? \"1\" : \"N\"\n\t\t  for (var j = i$4; j < end; ++j) { types[j] = replace }\n\t\t  i$4 = end - 1\n\t\t}\n\t  }\n  \n\t  // W7. Search backwards from each instance of a European number\n\t  // until the first strong type (R, L, or sor) is found. If an L is\n\t  // found, then change the type of the European number to L.\n\t  for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {\n\t\tvar type$4 = types[i$5]\n\t\tif (cur$1 == \"L\" && type$4 == \"1\") { types[i$5] = \"L\" }\n\t\telse if (isStrong.test(type$4)) { cur$1 = type$4 }\n\t  }\n  \n\t  // N1. A sequence of neutrals takes the direction of the\n\t  // surrounding strong text if the text on both sides has the same\n\t  // direction. European and Arabic numbers act as if they were R in\n\t  // terms of their influence on neutrals. Start-of-level-run (sor)\n\t  // and end-of-level-run (eor) are used at level run boundaries.\n\t  // N2. Any remaining neutrals take the embedding direction.\n\t  for (var i$6 = 0; i$6 < len; ++i$6) {\n\t\tif (isNeutral.test(types[i$6])) {\n\t\t  var end$1 = void 0\n\t\t  for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}\n\t\t  var before = (i$6 ? types[i$6-1] : outerType) == \"L\"\n\t\t  var after = (end$1 < len ? types[end$1] : outerType) == \"L\"\n\t\t  var replace$1 = before || after ? \"L\" : \"R\"\n\t\t  for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }\n\t\t  i$6 = end$1 - 1\n\t\t}\n\t  }\n  \n\t  // Here we depart from the documented algorithm, in order to avoid\n\t  // building up an actual levels array. Since there are only three\n\t  // levels (0, 1, 2) in an implementation that doesn't take\n\t  // explicit embedding into account, we can build up the order on\n\t  // the fly, without following the level-based algorithm.\n\t  var order = [], m\n\t  for (var i$7 = 0; i$7 < len;) {\n\t\tif (countsAsLeft.test(types[i$7])) {\n\t\t  var start = i$7\n\t\t  for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}\n\t\t  order.push(new BidiSpan(0, start, i$7))\n\t\t} else {\n\t\t  var pos = i$7, at = order.length\n\t\t  for (++i$7; i$7 < len && types[i$7] != \"L\"; ++i$7) {}\n\t\t  for (var j$2 = pos; j$2 < i$7;) {\n\t\t\tif (countsAsNum.test(types[j$2])) {\n\t\t\t  if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)) }\n\t\t\t  var nstart = j$2\n\t\t\t  for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}\n\t\t\t  order.splice(at, 0, new BidiSpan(2, nstart, j$2))\n\t\t\t  pos = j$2\n\t\t\t} else { ++j$2 }\n\t\t  }\n\t\t  if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)) }\n\t\t}\n\t  }\n\t  if (order[0].level == 1 && (m = str.match(/^\\s+/))) {\n\t\torder[0].from = m[0].length\n\t\torder.unshift(new BidiSpan(0, 0, m[0].length))\n\t  }\n\t  if (lst(order).level == 1 && (m = str.match(/\\s+$/))) {\n\t\tlst(order).to -= m[0].length\n\t\torder.push(new BidiSpan(0, len - m[0].length, len))\n\t  }\n\t  if (order[0].level == 2)\n\t\t{ order.unshift(new BidiSpan(1, order[0].to, order[0].to)) }\n\t  if (order[0].level != lst(order).level)\n\t\t{ order.push(new BidiSpan(order[0].level, len, len)) }\n  \n\t  return order\n\t}\n  })()\n  \n  // Get the bidi ordering for the given line (and cache it). Returns\n  // false for lines that are fully left-to-right, and an array of\n  // BidiSpan objects otherwise.\n  function getOrder(line) {\n\tvar order = line.order\n\tif (order == null) { order = line.order = bidiOrdering(line.text) }\n\treturn order\n  }\n  \n  // EVENT HANDLING\n  \n  // Lightweight event framework. on/off also work on DOM nodes,\n  // registering native DOM handlers.\n  \n  var on = function(emitter, type, f) {\n\tif (emitter.addEventListener)\n\t  { emitter.addEventListener(type, f, false) }\n\telse if (emitter.attachEvent)\n\t  { emitter.attachEvent(\"on\" + type, f) }\n\telse {\n\t  var map = emitter._handlers || (emitter._handlers = {})\n\t  var arr = map[type] || (map[type] = [])\n\t  arr.push(f)\n\t}\n  }\n  \n  var noHandlers = []\n  function getHandlers(emitter, type, copy) {\n\tvar arr = emitter._handlers && emitter._handlers[type]\n\tif (copy) { return arr && arr.length > 0 ? arr.slice() : noHandlers }\n\telse { return arr || noHandlers }\n  }\n  \n  function off(emitter, type, f) {\n\tif (emitter.removeEventListener)\n\t  { emitter.removeEventListener(type, f, false) }\n\telse if (emitter.detachEvent)\n\t  { emitter.detachEvent(\"on\" + type, f) }\n\telse {\n\t  var handlers = getHandlers(emitter, type, false)\n\t  for (var i = 0; i < handlers.length; ++i)\n\t\t{ if (handlers[i] == f) { handlers.splice(i, 1); break } }\n\t}\n  }\n  \n  function signal(emitter, type /*, values...*/) {\n\tvar handlers = getHandlers(emitter, type, true)\n\tif (!handlers.length) { return }\n\tvar args = Array.prototype.slice.call(arguments, 2)\n\tfor (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }\n  }\n  \n  // The DOM events that CodeMirror handles can be overridden by\n  // registering a (non-DOM) handler on the editor for the event name,\n  // and preventDefault-ing the event in that handler.\n  function signalDOMEvent(cm, e, override) {\n\tif (typeof e == \"string\")\n\t  { e = {type: e, preventDefault: function() { this.defaultPrevented = true }} }\n\tsignal(cm, override || e.type, cm, e)\n\treturn e_defaultPrevented(e) || e.codemirrorIgnore\n  }\n  \n  function signalCursorActivity(cm) {\n\tvar arr = cm._handlers && cm._handlers.cursorActivity\n\tif (!arr) { return }\n\tvar set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = [])\n\tfor (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)\n\t  { set.push(arr[i]) } }\n  }\n  \n  function hasHandler(emitter, type) {\n\treturn getHandlers(emitter, type).length > 0\n  }\n  \n  // Add on and off methods to a constructor's prototype, to make\n  // registering events on such objects more convenient.\n  function eventMixin(ctor) {\n\tctor.prototype.on = function(type, f) {on(this, type, f)}\n\tctor.prototype.off = function(type, f) {off(this, type, f)}\n  }\n  \n  // Due to the fact that we still support jurassic IE versions, some\n  // compatibility wrappers are needed.\n  \n  function e_preventDefault(e) {\n\tif (e.preventDefault) { e.preventDefault() }\n\telse { e.returnValue = false }\n  }\n  function e_stopPropagation(e) {\n\tif (e.stopPropagation) { e.stopPropagation() }\n\telse { e.cancelBubble = true }\n  }\n  function e_defaultPrevented(e) {\n\treturn e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false\n  }\n  function e_stop(e) {e_preventDefault(e); e_stopPropagation(e)}\n  \n  function e_target(e) {return e.target || e.srcElement}\n  function e_button(e) {\n\tvar b = e.which\n\tif (b == null) {\n\t  if (e.button & 1) { b = 1 }\n\t  else if (e.button & 2) { b = 3 }\n\t  else if (e.button & 4) { b = 2 }\n\t}\n\tif (mac && e.ctrlKey && b == 1) { b = 3 }\n\treturn b\n  }\n  \n  // Detect drag-and-drop\n  var dragAndDrop = function() {\n\t// There is *some* kind of drag-and-drop support in IE6-8, but I\n\t// couldn't get it to work yet.\n\tif (ie && ie_version < 9) { return false }\n\tvar div = elt('div')\n\treturn \"draggable\" in div || \"dragDrop\" in div\n  }()\n  \n  var zwspSupported\n  function zeroWidthElement(measure) {\n\tif (zwspSupported == null) {\n\t  var test = elt(\"span\", \"\\u200b\")\n\t  removeChildrenAndAdd(measure, elt(\"span\", [test, document.createTextNode(\"x\")]))\n\t  if (measure.firstChild.offsetHeight != 0)\n\t\t{ zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8) }\n\t}\n\tvar node = zwspSupported ? elt(\"span\", \"\\u200b\") :\n\t  elt(\"span\", \"\\u00a0\", null, \"display: inline-block; width: 1px; margin-right: -1px\")\n\tnode.setAttribute(\"cm-text\", \"\")\n\treturn node\n  }\n  \n  // Feature-detect IE's crummy client rect reporting for bidi text\n  var badBidiRects\n  function hasBadBidiRects(measure) {\n\tif (badBidiRects != null) { return badBidiRects }\n\tvar txt = removeChildrenAndAdd(measure, document.createTextNode(\"A\\u062eA\"))\n\tvar r0 = range(txt, 0, 1).getBoundingClientRect()\n\tvar r1 = range(txt, 1, 2).getBoundingClientRect()\n\tremoveChildren(measure)\n\tif (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)\n\treturn badBidiRects = (r1.right - r0.right < 3)\n  }\n  \n  // See if \"\".split is the broken IE version, if so, provide an\n  // alternative way to split lines.\n  var splitLinesAuto = \"\\n\\nb\".split(/\\n/).length != 3 ? function (string) {\n\tvar pos = 0, result = [], l = string.length\n\twhile (pos <= l) {\n\t  var nl = string.indexOf(\"\\n\", pos)\n\t  if (nl == -1) { nl = string.length }\n\t  var line = string.slice(pos, string.charAt(nl - 1) == \"\\r\" ? nl - 1 : nl)\n\t  var rt = line.indexOf(\"\\r\")\n\t  if (rt != -1) {\n\t\tresult.push(line.slice(0, rt))\n\t\tpos += rt + 1\n\t  } else {\n\t\tresult.push(line)\n\t\tpos = nl + 1\n\t  }\n\t}\n\treturn result\n  } : function (string) { return string.split(/\\r\\n?|\\n/); }\n  \n  var hasSelection = window.getSelection ? function (te) {\n\ttry { return te.selectionStart != te.selectionEnd }\n\tcatch(e) { return false }\n  } : function (te) {\n\tvar range\n\ttry {range = te.ownerDocument.selection.createRange()}\n\tcatch(e) {}\n\tif (!range || range.parentElement() != te) { return false }\n\treturn range.compareEndPoints(\"StartToEnd\", range) != 0\n  }\n  \n  var hasCopyEvent = (function () {\n\tvar e = elt(\"div\")\n\tif (\"oncopy\" in e) { return true }\n\te.setAttribute(\"oncopy\", \"return;\")\n\treturn typeof e.oncopy == \"function\"\n  })()\n  \n  var badZoomedRects = null\n  function hasBadZoomedRects(measure) {\n\tif (badZoomedRects != null) { return badZoomedRects }\n\tvar node = removeChildrenAndAdd(measure, elt(\"span\", \"x\"))\n\tvar normal = node.getBoundingClientRect()\n\tvar fromRange = range(node, 0, 1).getBoundingClientRect()\n\treturn badZoomedRects = Math.abs(normal.left - fromRange.left) > 1\n  }\n  \n  var modes = {};\n  var mimeModes = {};\n  // Extra arguments are stored as the mode's dependencies, which is\n  // used by (legacy) mechanisms like loadmode.js to automatically\n  // load a mode. (Preferred mechanism is the require/define calls.)\n  function defineMode(name, mode) {\n\tif (arguments.length > 2)\n\t  { mode.dependencies = Array.prototype.slice.call(arguments, 2) }\n\tmodes[name] = mode\n  }\n  \n  function defineMIME(mime, spec) {\n\tmimeModes[mime] = spec\n  }\n  \n  // Given a MIME type, a {name, ...options} config object, or a name\n  // string, return a mode config object.\n  function resolveMode(spec) {\n\tif (typeof spec == \"string\" && mimeModes.hasOwnProperty(spec)) {\n\t  spec = mimeModes[spec]\n\t} else if (spec && typeof spec.name == \"string\" && mimeModes.hasOwnProperty(spec.name)) {\n\t  var found = mimeModes[spec.name]\n\t  if (typeof found == \"string\") { found = {name: found} }\n\t  spec = createObj(found, spec)\n\t  spec.name = found.name\n\t} else if (typeof spec == \"string\" && /^[\\w\\-]+\\/[\\w\\-]+\\+xml$/.test(spec)) {\n\t  return resolveMode(\"application/xml\")\n\t} else if (typeof spec == \"string\" && /^[\\w\\-]+\\/[\\w\\-]+\\+json$/.test(spec)) {\n\t  return resolveMode(\"application/json\")\n\t}\n\tif (typeof spec == \"string\") { return {name: spec} }\n\telse { return spec || {name: \"null\"} }\n  }\n  \n  // Given a mode spec (anything that resolveMode accepts), find and\n  // initialize an actual mode object.\n  function getMode(options, spec) {\n\tspec = resolveMode(spec)\n\tvar mfactory = modes[spec.name]\n\tif (!mfactory) { return getMode(options, \"text/plain\") }\n\tvar modeObj = mfactory(options, spec)\n\tif (modeExtensions.hasOwnProperty(spec.name)) {\n\t  var exts = modeExtensions[spec.name]\n\t  for (var prop in exts) {\n\t\tif (!exts.hasOwnProperty(prop)) { continue }\n\t\tif (modeObj.hasOwnProperty(prop)) { modeObj[\"_\" + prop] = modeObj[prop] }\n\t\tmodeObj[prop] = exts[prop]\n\t  }\n\t}\n\tmodeObj.name = spec.name\n\tif (spec.helperType) { modeObj.helperType = spec.helperType }\n\tif (spec.modeProps) { for (var prop$1 in spec.modeProps)\n\t  { modeObj[prop$1] = spec.modeProps[prop$1] } }\n  \n\treturn modeObj\n  }\n  \n  // This can be used to attach properties to mode objects from\n  // outside the actual mode definition.\n  var modeExtensions = {}\n  function extendMode(mode, properties) {\n\tvar exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {})\n\tcopyObj(properties, exts)\n  }\n  \n  function copyState(mode, state) {\n\tif (state === true) { return state }\n\tif (mode.copyState) { return mode.copyState(state) }\n\tvar nstate = {}\n\tfor (var n in state) {\n\t  var val = state[n]\n\t  if (val instanceof Array) { val = val.concat([]) }\n\t  nstate[n] = val\n\t}\n\treturn nstate\n  }\n  \n  // Given a mode and a state (for that mode), find the inner mode and\n  // state at the position that the state refers to.\n  function innerMode(mode, state) {\n\tvar info\n\twhile (mode.innerMode) {\n\t  info = mode.innerMode(state)\n\t  if (!info || info.mode == mode) { break }\n\t  state = info.state\n\t  mode = info.mode\n\t}\n\treturn info || {mode: mode, state: state}\n  }\n  \n  function startState(mode, a1, a2) {\n\treturn mode.startState ? mode.startState(a1, a2) : true\n  }\n  \n  // STRING STREAM\n  \n  // Fed to the mode parsers, provides helper functions to make\n  // parsers more succinct.\n  \n  var StringStream = function(string, tabSize) {\n\tthis.pos = this.start = 0\n\tthis.string = string\n\tthis.tabSize = tabSize || 8\n\tthis.lastColumnPos = this.lastColumnValue = 0\n\tthis.lineStart = 0\n  }\n  \n  StringStream.prototype = {\n\teol: function() {return this.pos >= this.string.length},\n\tsol: function() {return this.pos == this.lineStart},\n\tpeek: function() {return this.string.charAt(this.pos) || undefined},\n\tnext: function() {\n\t  if (this.pos < this.string.length)\n\t\t{ return this.string.charAt(this.pos++) }\n\t},\n\teat: function(match) {\n\t  var ch = this.string.charAt(this.pos)\n\t  var ok\n\t  if (typeof match == \"string\") { ok = ch == match }\n\t  else { ok = ch && (match.test ? match.test(ch) : match(ch)) }\n\t  if (ok) {++this.pos; return ch}\n\t},\n\teatWhile: function(match) {\n\t  var start = this.pos\n\t  while (this.eat(match)){}\n\t  return this.pos > start\n\t},\n\teatSpace: function() {\n\t  var this$1 = this;\n  \n\t  var start = this.pos\n\t  while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }\n\t  return this.pos > start\n\t},\n\tskipToEnd: function() {this.pos = this.string.length},\n\tskipTo: function(ch) {\n\t  var found = this.string.indexOf(ch, this.pos)\n\t  if (found > -1) {this.pos = found; return true}\n\t},\n\tbackUp: function(n) {this.pos -= n},\n\tcolumn: function() {\n\t  if (this.lastColumnPos < this.start) {\n\t\tthis.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)\n\t\tthis.lastColumnPos = this.start\n\t  }\n\t  return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)\n\t},\n\tindentation: function() {\n\t  return countColumn(this.string, null, this.tabSize) -\n\t\t(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)\n\t},\n\tmatch: function(pattern, consume, caseInsensitive) {\n\t  if (typeof pattern == \"string\") {\n\t\tvar cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }\n\t\tvar substr = this.string.substr(this.pos, pattern.length)\n\t\tif (cased(substr) == cased(pattern)) {\n\t\t  if (consume !== false) { this.pos += pattern.length }\n\t\t  return true\n\t\t}\n\t  } else {\n\t\tvar match = this.string.slice(this.pos).match(pattern)\n\t\tif (match && match.index > 0) { return null }\n\t\tif (match && consume !== false) { this.pos += match[0].length }\n\t\treturn match\n\t  }\n\t},\n\tcurrent: function(){return this.string.slice(this.start, this.pos)},\n\thideFirstChars: function(n, inner) {\n\t  this.lineStart += n\n\t  try { return inner() }\n\t  finally { this.lineStart -= n }\n\t}\n  }\n  \n  // Compute a style array (an array starting with a mode generation\n  // -- for invalidation -- followed by pairs of end positions and\n  // style strings), which is used to highlight the tokens on the\n  // line.\n  function highlightLine(cm, line, state, forceToEnd) {\n\t// A styles array always starts with a number identifying the\n\t// mode/overlays that it is based on (for easy invalidation).\n\tvar st = [cm.state.modeGen], lineClasses = {}\n\t// Compute the base array of styles\n\trunMode(cm, line.text, cm.doc.mode, state, function (end, style) { return st.push(end, style); },\n\t  lineClasses, forceToEnd)\n  \n\t// Run overlays, adjust style array.\n\tvar loop = function ( o ) {\n\t  var overlay = cm.state.overlays[o], i = 1, at = 0\n\t  runMode(cm, line.text, overlay.mode, true, function (end, style) {\n\t\tvar start = i\n\t\t// Ensure there's a token end at the current position, and that i points at it\n\t\twhile (at < end) {\n\t\t  var i_end = st[i]\n\t\t  if (i_end > end)\n\t\t\t{ st.splice(i, 1, end, st[i+1], i_end) }\n\t\t  i += 2\n\t\t  at = Math.min(end, i_end)\n\t\t}\n\t\tif (!style) { return }\n\t\tif (overlay.opaque) {\n\t\t  st.splice(start, i - start, end, \"overlay \" + style)\n\t\t  i = start + 2\n\t\t} else {\n\t\t  for (; start < i; start += 2) {\n\t\t\tvar cur = st[start+1]\n\t\t\tst[start+1] = (cur ? cur + \" \" : \"\") + \"overlay \" + style\n\t\t  }\n\t\t}\n\t  }, lineClasses)\n\t};\n  \n\tfor (var o = 0; o < cm.state.overlays.length; ++o) loop( o );\n  \n\treturn {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}\n  }\n  \n  function getLineStyles(cm, line, updateFrontier) {\n\tif (!line.styles || line.styles[0] != cm.state.modeGen) {\n\t  var state = getStateBefore(cm, lineNo(line))\n\t  var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state)\n\t  line.stateAfter = state\n\t  line.styles = result.styles\n\t  if (result.classes) { line.styleClasses = result.classes }\n\t  else if (line.styleClasses) { line.styleClasses = null }\n\t  if (updateFrontier === cm.doc.frontier) { cm.doc.frontier++ }\n\t}\n\treturn line.styles\n  }\n  \n  function getStateBefore(cm, n, precise) {\n\tvar doc = cm.doc, display = cm.display\n\tif (!doc.mode.startState) { return true }\n\tvar pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter\n\tif (!state) { state = startState(doc.mode) }\n\telse { state = copyState(doc.mode, state) }\n\tdoc.iter(pos, n, function (line) {\n\t  processLine(cm, line.text, state)\n\t  var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo\n\t  line.stateAfter = save ? copyState(doc.mode, state) : null\n\t  ++pos\n\t})\n\tif (precise) { doc.frontier = pos }\n\treturn state\n  }\n  \n  // Lightweight form of highlight -- proceed over this line and\n  // update state, but don't save a style array. Used for lines that\n  // aren't currently visible.\n  function processLine(cm, text, state, startAt) {\n\tvar mode = cm.doc.mode\n\tvar stream = new StringStream(text, cm.options.tabSize)\n\tstream.start = stream.pos = startAt || 0\n\tif (text == \"\") { callBlankLine(mode, state) }\n\twhile (!stream.eol()) {\n\t  readToken(mode, stream, state)\n\t  stream.start = stream.pos\n\t}\n  }\n  \n  function callBlankLine(mode, state) {\n\tif (mode.blankLine) { return mode.blankLine(state) }\n\tif (!mode.innerMode) { return }\n\tvar inner = innerMode(mode, state)\n\tif (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }\n  }\n  \n  function readToken(mode, stream, state, inner) {\n\tfor (var i = 0; i < 10; i++) {\n\t  if (inner) { inner[0] = innerMode(mode, state).mode }\n\t  var style = mode.token(stream, state)\n\t  if (stream.pos > stream.start) { return style }\n\t}\n\tthrow new Error(\"Mode \" + mode.name + \" failed to advance stream.\")\n  }\n  \n  // Utility for getTokenAt and getLineTokens\n  function takeToken(cm, pos, precise, asArray) {\n\tvar getObj = function (copy) { return ({\n\t  start: stream.start, end: stream.pos,\n\t  string: stream.current(),\n\t  type: style || null,\n\t  state: copy ? copyState(doc.mode, state) : state\n\t}); }\n  \n\tvar doc = cm.doc, mode = doc.mode, style\n\tpos = clipPos(doc, pos)\n\tvar line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise)\n\tvar stream = new StringStream(line.text, cm.options.tabSize), tokens\n\tif (asArray) { tokens = [] }\n\twhile ((asArray || stream.pos < pos.ch) && !stream.eol()) {\n\t  stream.start = stream.pos\n\t  style = readToken(mode, stream, state)\n\t  if (asArray) { tokens.push(getObj(true)) }\n\t}\n\treturn asArray ? tokens : getObj()\n  }\n  \n  function extractLineClasses(type, output) {\n\tif (type) { for (;;) {\n\t  var lineClass = type.match(/(?:^|\\s+)line-(background-)?(\\S+)/)\n\t  if (!lineClass) { break }\n\t  type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)\n\t  var prop = lineClass[1] ? \"bgClass\" : \"textClass\"\n\t  if (output[prop] == null)\n\t\t{ output[prop] = lineClass[2] }\n\t  else if (!(new RegExp(\"(?:^|\\s)\" + lineClass[2] + \"(?:$|\\s)\")).test(output[prop]))\n\t\t{ output[prop] += \" \" + lineClass[2] }\n\t} }\n\treturn type\n  }\n  \n  // Run the given mode's parser over a line, calling f for each token.\n  function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {\n\tvar flattenSpans = mode.flattenSpans\n\tif (flattenSpans == null) { flattenSpans = cm.options.flattenSpans }\n\tvar curStart = 0, curStyle = null\n\tvar stream = new StringStream(text, cm.options.tabSize), style\n\tvar inner = cm.options.addModeClass && [null]\n\tif (text == \"\") { extractLineClasses(callBlankLine(mode, state), lineClasses) }\n\twhile (!stream.eol()) {\n\t  if (stream.pos > cm.options.maxHighlightLength) {\n\t\tflattenSpans = false\n\t\tif (forceToEnd) { processLine(cm, text, state, stream.pos) }\n\t\tstream.pos = text.length\n\t\tstyle = null\n\t  } else {\n\t\tstyle = extractLineClasses(readToken(mode, stream, state, inner), lineClasses)\n\t  }\n\t  if (inner) {\n\t\tvar mName = inner[0].name\n\t\tif (mName) { style = \"m-\" + (style ? mName + \" \" + style : mName) }\n\t  }\n\t  if (!flattenSpans || curStyle != style) {\n\t\twhile (curStart < stream.start) {\n\t\t  curStart = Math.min(stream.start, curStart + 5000)\n\t\t  f(curStart, curStyle)\n\t\t}\n\t\tcurStyle = style\n\t  }\n\t  stream.start = stream.pos\n\t}\n\twhile (curStart < stream.pos) {\n\t  // Webkit seems to refuse to render text nodes longer than 57444\n\t  // characters, and returns inaccurate measurements in nodes\n\t  // starting around 5000 chars.\n\t  var pos = Math.min(stream.pos, curStart + 5000)\n\t  f(pos, curStyle)\n\t  curStart = pos\n\t}\n  }\n  \n  // Finds the line to start with when starting a parse. Tries to\n  // find a line with a stateAfter, so that it can start with a\n  // valid state. If that fails, it returns the line with the\n  // smallest indentation, which tends to need the least context to\n  // parse correctly.\n  function findStartLine(cm, n, precise) {\n\tvar minindent, minline, doc = cm.doc\n\tvar lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100)\n\tfor (var search = n; search > lim; --search) {\n\t  if (search <= doc.first) { return doc.first }\n\t  var line = getLine(doc, search - 1)\n\t  if (line.stateAfter && (!precise || search <= doc.frontier)) { return search }\n\t  var indented = countColumn(line.text, null, cm.options.tabSize)\n\t  if (minline == null || minindent > indented) {\n\t\tminline = search - 1\n\t\tminindent = indented\n\t  }\n\t}\n\treturn minline\n  }\n  \n  // LINE DATA STRUCTURE\n  \n  // Line objects. These hold state related to a line, including\n  // highlighting info (the styles array).\n  function Line(text, markedSpans, estimateHeight) {\n\tthis.text = text\n\tattachMarkedSpans(this, markedSpans)\n\tthis.height = estimateHeight ? estimateHeight(this) : 1\n  }\n  eventMixin(Line)\n  Line.prototype.lineNo = function() { return lineNo(this) }\n  \n  // Change the content (text, markers) of a line. Automatically\n  // invalidates cached information and tries to re-estimate the\n  // line's height.\n  function updateLine(line, text, markedSpans, estimateHeight) {\n\tline.text = text\n\tif (line.stateAfter) { line.stateAfter = null }\n\tif (line.styles) { line.styles = null }\n\tif (line.order != null) { line.order = null }\n\tdetachMarkedSpans(line)\n\tattachMarkedSpans(line, markedSpans)\n\tvar estHeight = estimateHeight ? estimateHeight(line) : 1\n\tif (estHeight != line.height) { updateLineHeight(line, estHeight) }\n  }\n  \n  // Detach a line from the document tree and its markers.\n  function cleanUpLine(line) {\n\tline.parent = null\n\tdetachMarkedSpans(line)\n  }\n  \n  // Convert a style as returned by a mode (either null, or a string\n  // containing one or more styles) to a CSS style. This is cached,\n  // and also looks for line-wide styles.\n  var styleToClassCache = {};\n  var styleToClassCacheWithMode = {};\n  function interpretTokenStyle(style, options) {\n\tif (!style || /^\\s*$/.test(style)) { return null }\n\tvar cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache\n\treturn cache[style] ||\n\t  (cache[style] = style.replace(/\\S+/g, \"cm-$&\"))\n  }\n  \n  // Render the DOM representation of the text of a line. Also builds\n  // up a 'line map', which points at the DOM nodes that represent\n  // specific stretches of text, and is used by the measuring code.\n  // The returned object contains the DOM node, this map, and\n  // information about line-wide styles that were set by the mode.\n  function buildLineContent(cm, lineView) {\n\t// The padding-right forces the element to have a 'border', which\n\t// is needed on Webkit to be able to get line-level bounding\n\t// rectangles for it (in measureChar).\n\tvar content = elt(\"span\", null, null, webkit ? \"padding-right: .1px\" : null)\n\tvar builder = {pre: elt(\"pre\", [content], \"CodeMirror-line\"), content: content,\n\t\t\t\t   col: 0, pos: 0, cm: cm,\n\t\t\t\t   trailingSpace: false,\n\t\t\t\t   splitSpaces: (ie || webkit) && cm.getOption(\"lineWrapping\")}\n\tlineView.measure = {}\n  \n\t// Iterate over the logical lines that make up this visual line.\n\tfor (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {\n\t  var line = i ? lineView.rest[i - 1] : lineView.line, order = void 0\n\t  builder.pos = 0\n\t  builder.addToken = buildToken\n\t  // Optionally wire in some hacks into the token-rendering\n\t  // algorithm, to deal with browser quirks.\n\t  if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))\n\t\t{ builder.addToken = buildTokenBadBidi(builder.addToken, order) }\n\t  builder.map = []\n\t  var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)\n\t  insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate))\n\t  if (line.styleClasses) {\n\t\tif (line.styleClasses.bgClass)\n\t\t  { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || \"\") }\n\t\tif (line.styleClasses.textClass)\n\t\t  { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || \"\") }\n\t  }\n  \n\t  // Ensure at least a single node is present, for measuring.\n\t  if (builder.map.length == 0)\n\t\t{ builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))) }\n  \n\t  // Store the map and a cache object for the current logical line\n\t  if (i == 0) {\n\t\tlineView.measure.map = builder.map\n\t\tlineView.measure.cache = {}\n\t  } else {\n\t\t;(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)\n\t\t;(lineView.measure.caches || (lineView.measure.caches = [])).push({})\n\t  }\n\t}\n  \n\t// See issue #2901\n\tif (webkit) {\n\t  var last = builder.content.lastChild\n\t  if (/\\bcm-tab\\b/.test(last.className) || (last.querySelector && last.querySelector(\".cm-tab\")))\n\t\t{ builder.content.className = \"cm-tab-wrap-hack\" }\n\t}\n  \n\tsignal(cm, \"renderLine\", cm, lineView.line, builder.pre)\n\tif (builder.pre.className)\n\t  { builder.textClass = joinClasses(builder.pre.className, builder.textClass || \"\") }\n  \n\treturn builder\n  }\n  \n  function defaultSpecialCharPlaceholder(ch) {\n\tvar token = elt(\"span\", \"\\u2022\", \"cm-invalidchar\")\n\ttoken.title = \"\\\\u\" + ch.charCodeAt(0).toString(16)\n\ttoken.setAttribute(\"aria-label\", token.title)\n\treturn token\n  }\n  \n  // Build up the DOM representation for a single token, and add it to\n  // the line map. Takes care to render special characters separately.\n  function buildToken(builder, text, style, startStyle, endStyle, title, css) {\n\tif (!text) { return }\n\tvar displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text\n\tvar special = builder.cm.state.specialChars, mustWrap = false\n\tvar content\n\tif (!special.test(text)) {\n\t  builder.col += text.length\n\t  content = document.createTextNode(displayText)\n\t  builder.map.push(builder.pos, builder.pos + text.length, content)\n\t  if (ie && ie_version < 9) { mustWrap = true }\n\t  builder.pos += text.length\n\t} else {\n\t  content = document.createDocumentFragment()\n\t  var pos = 0\n\t  while (true) {\n\t\tspecial.lastIndex = pos\n\t\tvar m = special.exec(text)\n\t\tvar skipped = m ? m.index - pos : text.length - pos\n\t\tif (skipped) {\n\t\t  var txt = document.createTextNode(displayText.slice(pos, pos + skipped))\n\t\t  if (ie && ie_version < 9) { content.appendChild(elt(\"span\", [txt])) }\n\t\t  else { content.appendChild(txt) }\n\t\t  builder.map.push(builder.pos, builder.pos + skipped, txt)\n\t\t  builder.col += skipped\n\t\t  builder.pos += skipped\n\t\t}\n\t\tif (!m) { break }\n\t\tpos += skipped + 1\n\t\tvar txt$1 = void 0\n\t\tif (m[0] == \"\\t\") {\n\t\t  var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize\n\t\t  txt$1 = content.appendChild(elt(\"span\", spaceStr(tabWidth), \"cm-tab\"))\n\t\t  txt$1.setAttribute(\"role\", \"presentation\")\n\t\t  txt$1.setAttribute(\"cm-text\", \"\\t\")\n\t\t  builder.col += tabWidth\n\t\t} else if (m[0] == \"\\r\" || m[0] == \"\\n\") {\n\t\t  txt$1 = content.appendChild(elt(\"span\", m[0] == \"\\r\" ? \"\\u240d\" : \"\\u2424\", \"cm-invalidchar\"))\n\t\t  txt$1.setAttribute(\"cm-text\", m[0])\n\t\t  builder.col += 1\n\t\t} else {\n\t\t  txt$1 = builder.cm.options.specialCharPlaceholder(m[0])\n\t\t  txt$1.setAttribute(\"cm-text\", m[0])\n\t\t  if (ie && ie_version < 9) { content.appendChild(elt(\"span\", [txt$1])) }\n\t\t  else { content.appendChild(txt$1) }\n\t\t  builder.col += 1\n\t\t}\n\t\tbuilder.map.push(builder.pos, builder.pos + 1, txt$1)\n\t\tbuilder.pos++\n\t  }\n\t}\n\tbuilder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32\n\tif (style || startStyle || endStyle || mustWrap || css) {\n\t  var fullStyle = style || \"\"\n\t  if (startStyle) { fullStyle += startStyle }\n\t  if (endStyle) { fullStyle += endStyle }\n\t  var token = elt(\"span\", [content], fullStyle, css)\n\t  if (title) { token.title = title }\n\t  return builder.content.appendChild(token)\n\t}\n\tbuilder.content.appendChild(content)\n  }\n  \n  function splitSpaces(text, trailingBefore) {\n\tif (text.length > 1 && !/  /.test(text)) { return text }\n\tvar spaceBefore = trailingBefore, result = \"\"\n\tfor (var i = 0; i < text.length; i++) {\n\t  var ch = text.charAt(i)\n\t  if (ch == \" \" && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))\n\t\t{ ch = \"\\u00a0\" }\n\t  result += ch\n\t  spaceBefore = ch == \" \"\n\t}\n\treturn result\n  }\n  \n  // Work around nonsense dimensions being reported for stretches of\n  // right-to-left text.\n  function buildTokenBadBidi(inner, order) {\n\treturn function (builder, text, style, startStyle, endStyle, title, css) {\n\t  style = style ? style + \" cm-force-border\" : \"cm-force-border\"\n\t  var start = builder.pos, end = start + text.length\n\t  for (;;) {\n\t\t// Find the part that overlaps with the start of this text\n\t\tvar part = void 0\n\t\tfor (var i = 0; i < order.length; i++) {\n\t\t  part = order[i]\n\t\t  if (part.to > start && part.from <= start) { break }\n\t\t}\n\t\tif (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }\n\t\tinner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css)\n\t\tstartStyle = null\n\t\ttext = text.slice(part.to - start)\n\t\tstart = part.to\n\t  }\n\t}\n  }\n  \n  function buildCollapsedSpan(builder, size, marker, ignoreWidget) {\n\tvar widget = !ignoreWidget && marker.widgetNode\n\tif (widget) { builder.map.push(builder.pos, builder.pos + size, widget) }\n\tif (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {\n\t  if (!widget)\n\t\t{ widget = builder.content.appendChild(document.createElement(\"span\")) }\n\t  widget.setAttribute(\"cm-marker\", marker.id)\n\t}\n\tif (widget) {\n\t  builder.cm.display.input.setUneditable(widget)\n\t  builder.content.appendChild(widget)\n\t}\n\tbuilder.pos += size\n\tbuilder.trailingSpace = false\n  }\n  \n  // Outputs a number of spans to make up a line, taking highlighting\n  // and marked text into account.\n  function insertLineContent(line, builder, styles) {\n\tvar spans = line.markedSpans, allText = line.text, at = 0\n\tif (!spans) {\n\t  for (var i$1 = 1; i$1 < styles.length; i$1+=2)\n\t\t{ builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)) }\n\t  return\n\t}\n  \n\tvar len = allText.length, pos = 0, i = 1, text = \"\", style, css\n\tvar nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed\n\tfor (;;) {\n\t  if (nextChange == pos) { // Update current marker set\n\t\tspanStyle = spanEndStyle = spanStartStyle = title = css = \"\"\n\t\tcollapsed = null; nextChange = Infinity\n\t\tvar foundBookmarks = [], endStyles = void 0\n\t\tfor (var j = 0; j < spans.length; ++j) {\n\t\t  var sp = spans[j], m = sp.marker\n\t\t  if (m.type == \"bookmark\" && sp.from == pos && m.widgetNode) {\n\t\t\tfoundBookmarks.push(m)\n\t\t  } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {\n\t\t\tif (sp.to != null && sp.to != pos && nextChange > sp.to) {\n\t\t\t  nextChange = sp.to\n\t\t\t  spanEndStyle = \"\"\n\t\t\t}\n\t\t\tif (m.className) { spanStyle += \" \" + m.className }\n\t\t\tif (m.css) { css = (css ? css + \";\" : \"\") + m.css }\n\t\t\tif (m.startStyle && sp.from == pos) { spanStartStyle += \" \" + m.startStyle }\n\t\t\tif (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to) }\n\t\t\tif (m.title && !title) { title = m.title }\n\t\t\tif (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))\n\t\t\t  { collapsed = sp }\n\t\t  } else if (sp.from > pos && nextChange > sp.from) {\n\t\t\tnextChange = sp.from\n\t\t  }\n\t\t}\n\t\tif (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)\n\t\t  { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += \" \" + endStyles[j$1] } } }\n  \n\t\tif (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)\n\t\t  { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]) } }\n\t\tif (collapsed && (collapsed.from || 0) == pos) {\n\t\t  buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,\n\t\t\t\t\t\t\t collapsed.marker, collapsed.from == null)\n\t\t  if (collapsed.to == null) { return }\n\t\t  if (collapsed.to == pos) { collapsed = false }\n\t\t}\n\t  }\n\t  if (pos >= len) { break }\n  \n\t  var upto = Math.min(len, nextChange)\n\t  while (true) {\n\t\tif (text) {\n\t\t  var end = pos + text.length\n\t\t  if (!collapsed) {\n\t\t\tvar tokenText = end > upto ? text.slice(0, upto - pos) : text\n\t\t\tbuilder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,\n\t\t\t\t\t\t\t spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : \"\", title, css)\n\t\t  }\n\t\t  if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}\n\t\t  pos = end\n\t\t  spanStartStyle = \"\"\n\t\t}\n\t\ttext = allText.slice(at, at = styles[i++])\n\t\tstyle = interpretTokenStyle(styles[i++], builder.cm.options)\n\t  }\n\t}\n  }\n  \n  \n  // These objects are used to represent the visible (currently drawn)\n  // part of the document. A LineView may correspond to multiple\n  // logical lines, if those are connected by collapsed ranges.\n  function LineView(doc, line, lineN) {\n\t// The starting line\n\tthis.line = line\n\t// Continuing lines, if any\n\tthis.rest = visualLineContinued(line)\n\t// Number of logical lines in this visual line\n\tthis.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1\n\tthis.node = this.text = null\n\tthis.hidden = lineIsHidden(doc, line)\n  }\n  \n  // Create a range of LineView objects for the given lines.\n  function buildViewArray(cm, from, to) {\n\tvar array = [], nextPos\n\tfor (var pos = from; pos < to; pos = nextPos) {\n\t  var view = new LineView(cm.doc, getLine(cm.doc, pos), pos)\n\t  nextPos = pos + view.size\n\t  array.push(view)\n\t}\n\treturn array\n  }\n  \n  var operationGroup = null\n  \n  function pushOperation(op) {\n\tif (operationGroup) {\n\t  operationGroup.ops.push(op)\n\t} else {\n\t  op.ownsGroup = operationGroup = {\n\t\tops: [op],\n\t\tdelayedCallbacks: []\n\t  }\n\t}\n  }\n  \n  function fireCallbacksForOps(group) {\n\t// Calls delayed callbacks and cursorActivity handlers until no\n\t// new ones appear\n\tvar callbacks = group.delayedCallbacks, i = 0\n\tdo {\n\t  for (; i < callbacks.length; i++)\n\t\t{ callbacks[i].call(null) }\n\t  for (var j = 0; j < group.ops.length; j++) {\n\t\tvar op = group.ops[j]\n\t\tif (op.cursorActivityHandlers)\n\t\t  { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)\n\t\t\t{ op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm) } }\n\t  }\n\t} while (i < callbacks.length)\n  }\n  \n  function finishOperation(op, endCb) {\n\tvar group = op.ownsGroup\n\tif (!group) { return }\n  \n\ttry { fireCallbacksForOps(group) }\n\tfinally {\n\t  operationGroup = null\n\t  endCb(group)\n\t}\n  }\n  \n  var orphanDelayedCallbacks = null\n  \n  // Often, we want to signal events at a point where we are in the\n  // middle of some work, but don't want the handler to start calling\n  // other methods on the editor, which might be in an inconsistent\n  // state or simply not expect any other events to happen.\n  // signalLater looks whether there are any handlers, and schedules\n  // them to be executed when the last operation ends, or, if no\n  // operation is active, when a timeout fires.\n  function signalLater(emitter, type /*, values...*/) {\n\tvar arr = getHandlers(emitter, type, false)\n\tif (!arr.length) { return }\n\tvar args = Array.prototype.slice.call(arguments, 2), list\n\tif (operationGroup) {\n\t  list = operationGroup.delayedCallbacks\n\t} else if (orphanDelayedCallbacks) {\n\t  list = orphanDelayedCallbacks\n\t} else {\n\t  list = orphanDelayedCallbacks = []\n\t  setTimeout(fireOrphanDelayed, 0)\n\t}\n\tvar loop = function ( i ) {\n\t  list.push(function () { return arr[i].apply(null, args); })\n\t};\n  \n\tfor (var i = 0; i < arr.length; ++i)\n\t  loop( i );\n  }\n  \n  function fireOrphanDelayed() {\n\tvar delayed = orphanDelayedCallbacks\n\torphanDelayedCallbacks = null\n\tfor (var i = 0; i < delayed.length; ++i) { delayed[i]() }\n  }\n  \n  // When an aspect of a line changes, a string is added to\n  // lineView.changes. This updates the relevant part of the line's\n  // DOM structure.\n  function updateLineForChanges(cm, lineView, lineN, dims) {\n\tfor (var j = 0; j < lineView.changes.length; j++) {\n\t  var type = lineView.changes[j]\n\t  if (type == \"text\") { updateLineText(cm, lineView) }\n\t  else if (type == \"gutter\") { updateLineGutter(cm, lineView, lineN, dims) }\n\t  else if (type == \"class\") { updateLineClasses(lineView) }\n\t  else if (type == \"widget\") { updateLineWidgets(cm, lineView, dims) }\n\t}\n\tlineView.changes = null\n  }\n  \n  // Lines with gutter elements, widgets or a background class need to\n  // be wrapped, and have the extra elements added to the wrapper div\n  function ensureLineWrapped(lineView) {\n\tif (lineView.node == lineView.text) {\n\t  lineView.node = elt(\"div\", null, null, \"position: relative\")\n\t  if (lineView.text.parentNode)\n\t\t{ lineView.text.parentNode.replaceChild(lineView.node, lineView.text) }\n\t  lineView.node.appendChild(lineView.text)\n\t  if (ie && ie_version < 8) { lineView.node.style.zIndex = 2 }\n\t}\n\treturn lineView.node\n  }\n  \n  function updateLineBackground(lineView) {\n\tvar cls = lineView.bgClass ? lineView.bgClass + \" \" + (lineView.line.bgClass || \"\") : lineView.line.bgClass\n\tif (cls) { cls += \" CodeMirror-linebackground\" }\n\tif (lineView.background) {\n\t  if (cls) { lineView.background.className = cls }\n\t  else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null }\n\t} else if (cls) {\n\t  var wrap = ensureLineWrapped(lineView)\n\t  lineView.background = wrap.insertBefore(elt(\"div\", null, cls), wrap.firstChild)\n\t}\n  }\n  \n  // Wrapper around buildLineContent which will reuse the structure\n  // in display.externalMeasured when possible.\n  function getLineContent(cm, lineView) {\n\tvar ext = cm.display.externalMeasured\n\tif (ext && ext.line == lineView.line) {\n\t  cm.display.externalMeasured = null\n\t  lineView.measure = ext.measure\n\t  return ext.built\n\t}\n\treturn buildLineContent(cm, lineView)\n  }\n  \n  // Redraw the line's text. Interacts with the background and text\n  // classes because the mode may output tokens that influence these\n  // classes.\n  function updateLineText(cm, lineView) {\n\tvar cls = lineView.text.className\n\tvar built = getLineContent(cm, lineView)\n\tif (lineView.text == lineView.node) { lineView.node = built.pre }\n\tlineView.text.parentNode.replaceChild(built.pre, lineView.text)\n\tlineView.text = built.pre\n\tif (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {\n\t  lineView.bgClass = built.bgClass\n\t  lineView.textClass = built.textClass\n\t  updateLineClasses(lineView)\n\t} else if (cls) {\n\t  lineView.text.className = cls\n\t}\n  }\n  \n  function updateLineClasses(lineView) {\n\tupdateLineBackground(lineView)\n\tif (lineView.line.wrapClass)\n\t  { ensureLineWrapped(lineView).className = lineView.line.wrapClass }\n\telse if (lineView.node != lineView.text)\n\t  { lineView.node.className = \"\" }\n\tvar textClass = lineView.textClass ? lineView.textClass + \" \" + (lineView.line.textClass || \"\") : lineView.line.textClass\n\tlineView.text.className = textClass || \"\"\n  }\n  \n  function updateLineGutter(cm, lineView, lineN, dims) {\n\tif (lineView.gutter) {\n\t  lineView.node.removeChild(lineView.gutter)\n\t  lineView.gutter = null\n\t}\n\tif (lineView.gutterBackground) {\n\t  lineView.node.removeChild(lineView.gutterBackground)\n\t  lineView.gutterBackground = null\n\t}\n\tif (lineView.line.gutterClass) {\n\t  var wrap = ensureLineWrapped(lineView)\n\t  lineView.gutterBackground = elt(\"div\", null, \"CodeMirror-gutter-background \" + lineView.line.gutterClass,\n\t\t\t\t\t\t\t\t\t  (\"left: \" + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + \"px; width: \" + (dims.gutterTotalWidth) + \"px\"))\n\t  wrap.insertBefore(lineView.gutterBackground, lineView.text)\n\t}\n\tvar markers = lineView.line.gutterMarkers\n\tif (cm.options.lineNumbers || markers) {\n\t  var wrap$1 = ensureLineWrapped(lineView)\n\t  var gutterWrap = lineView.gutter = elt(\"div\", null, \"CodeMirror-gutter-wrapper\", (\"left: \" + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + \"px\"))\n\t  cm.display.input.setUneditable(gutterWrap)\n\t  wrap$1.insertBefore(gutterWrap, lineView.text)\n\t  if (lineView.line.gutterClass)\n\t\t{ gutterWrap.className += \" \" + lineView.line.gutterClass }\n\t  if (cm.options.lineNumbers && (!markers || !markers[\"CodeMirror-linenumbers\"]))\n\t\t{ lineView.lineNumber = gutterWrap.appendChild(\n\t\t  elt(\"div\", lineNumberFor(cm.options, lineN),\n\t\t\t  \"CodeMirror-linenumber CodeMirror-gutter-elt\",\n\t\t\t  (\"left: \" + (dims.gutterLeft[\"CodeMirror-linenumbers\"]) + \"px; width: \" + (cm.display.lineNumInnerWidth) + \"px\"))) }\n\t  if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {\n\t\tvar id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]\n\t\tif (found)\n\t\t  { gutterWrap.appendChild(elt(\"div\", [found], \"CodeMirror-gutter-elt\",\n\t\t\t\t\t\t\t\t\t (\"left: \" + (dims.gutterLeft[id]) + \"px; width: \" + (dims.gutterWidth[id]) + \"px\"))) }\n\t  } }\n\t}\n  }\n  \n  function updateLineWidgets(cm, lineView, dims) {\n\tif (lineView.alignable) { lineView.alignable = null }\n\tfor (var node = lineView.node.firstChild, next = void 0; node; node = next) {\n\t  next = node.nextSibling\n\t  if (node.className == \"CodeMirror-linewidget\")\n\t\t{ lineView.node.removeChild(node) }\n\t}\n\tinsertLineWidgets(cm, lineView, dims)\n  }\n  \n  // Build a line's DOM representation from scratch\n  function buildLineElement(cm, lineView, lineN, dims) {\n\tvar built = getLineContent(cm, lineView)\n\tlineView.text = lineView.node = built.pre\n\tif (built.bgClass) { lineView.bgClass = built.bgClass }\n\tif (built.textClass) { lineView.textClass = built.textClass }\n  \n\tupdateLineClasses(lineView)\n\tupdateLineGutter(cm, lineView, lineN, dims)\n\tinsertLineWidgets(cm, lineView, dims)\n\treturn lineView.node\n  }\n  \n  // A lineView may contain multiple logical lines (when merged by\n  // collapsed spans). The widgets for all of them need to be drawn.\n  function insertLineWidgets(cm, lineView, dims) {\n\tinsertLineWidgetsFor(cm, lineView.line, lineView, dims, true)\n\tif (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)\n\t  { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false) } }\n  }\n  \n  function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {\n\tif (!line.widgets) { return }\n\tvar wrap = ensureLineWrapped(lineView)\n\tfor (var i = 0, ws = line.widgets; i < ws.length; ++i) {\n\t  var widget = ws[i], node = elt(\"div\", [widget.node], \"CodeMirror-linewidget\")\n\t  if (!widget.handleMouseEvents) { node.setAttribute(\"cm-ignore-events\", \"true\") }\n\t  positionLineWidget(widget, node, lineView, dims)\n\t  cm.display.input.setUneditable(node)\n\t  if (allowAbove && widget.above)\n\t\t{ wrap.insertBefore(node, lineView.gutter || lineView.text) }\n\t  else\n\t\t{ wrap.appendChild(node) }\n\t  signalLater(widget, \"redraw\")\n\t}\n  }\n  \n  function positionLineWidget(widget, node, lineView, dims) {\n\tif (widget.noHScroll) {\n\t  ;(lineView.alignable || (lineView.alignable = [])).push(node)\n\t  var width = dims.wrapperWidth\n\t  node.style.left = dims.fixedPos + \"px\"\n\t  if (!widget.coverGutter) {\n\t\twidth -= dims.gutterTotalWidth\n\t\tnode.style.paddingLeft = dims.gutterTotalWidth + \"px\"\n\t  }\n\t  node.style.width = width + \"px\"\n\t}\n\tif (widget.coverGutter) {\n\t  node.style.zIndex = 5\n\t  node.style.position = \"relative\"\n\t  if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + \"px\" }\n\t}\n  }\n  \n  function widgetHeight(widget) {\n\tif (widget.height != null) { return widget.height }\n\tvar cm = widget.doc.cm\n\tif (!cm) { return 0 }\n\tif (!contains(document.body, widget.node)) {\n\t  var parentStyle = \"position: relative;\"\n\t  if (widget.coverGutter)\n\t\t{ parentStyle += \"margin-left: -\" + cm.display.gutters.offsetWidth + \"px;\" }\n\t  if (widget.noHScroll)\n\t\t{ parentStyle += \"width: \" + cm.display.wrapper.clientWidth + \"px;\" }\n\t  removeChildrenAndAdd(cm.display.measure, elt(\"div\", [widget.node], null, parentStyle))\n\t}\n\treturn widget.height = widget.node.parentNode.offsetHeight\n  }\n  \n  // Return true when the given mouse event happened in a widget\n  function eventInWidget(display, e) {\n\tfor (var n = e_target(e); n != display.wrapper; n = n.parentNode) {\n\t  if (!n || (n.nodeType == 1 && n.getAttribute(\"cm-ignore-events\") == \"true\") ||\n\t\t  (n.parentNode == display.sizer && n != display.mover))\n\t\t{ return true }\n\t}\n  }\n  \n  // POSITION MEASUREMENT\n  \n  function paddingTop(display) {return display.lineSpace.offsetTop}\n  function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}\n  function paddingH(display) {\n\tif (display.cachedPaddingH) { return display.cachedPaddingH }\n\tvar e = removeChildrenAndAdd(display.measure, elt(\"pre\", \"x\"))\n\tvar style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle\n\tvar data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}\n\tif (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data }\n\treturn data\n  }\n  \n  function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }\n  function displayWidth(cm) {\n\treturn cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth\n  }\n  function displayHeight(cm) {\n\treturn cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight\n  }\n  \n  // Ensure the lineView.wrapping.heights array is populated. This is\n  // an array of bottom offsets for the lines that make up a drawn\n  // line. When lineWrapping is on, there might be more than one\n  // height.\n  function ensureLineHeights(cm, lineView, rect) {\n\tvar wrapping = cm.options.lineWrapping\n\tvar curWidth = wrapping && displayWidth(cm)\n\tif (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {\n\t  var heights = lineView.measure.heights = []\n\t  if (wrapping) {\n\t\tlineView.measure.width = curWidth\n\t\tvar rects = lineView.text.firstChild.getClientRects()\n\t\tfor (var i = 0; i < rects.length - 1; i++) {\n\t\t  var cur = rects[i], next = rects[i + 1]\n\t\t  if (Math.abs(cur.bottom - next.bottom) > 2)\n\t\t\t{ heights.push((cur.bottom + next.top) / 2 - rect.top) }\n\t\t}\n\t  }\n\t  heights.push(rect.bottom - rect.top)\n\t}\n  }\n  \n  // Find a line map (mapping character offsets to text nodes) and a\n  // measurement cache for the given line number. (A line view might\n  // contain multiple lines when collapsed ranges are present.)\n  function mapFromLineView(lineView, line, lineN) {\n\tif (lineView.line == line)\n\t  { return {map: lineView.measure.map, cache: lineView.measure.cache} }\n\tfor (var i = 0; i < lineView.rest.length; i++)\n\t  { if (lineView.rest[i] == line)\n\t\t{ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }\n\tfor (var i$1 = 0; i$1 < lineView.rest.length; i$1++)\n\t  { if (lineNo(lineView.rest[i$1]) > lineN)\n\t\t{ return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }\n  }\n  \n  // Render a line into the hidden node display.externalMeasured. Used\n  // when measurement is needed for a line that's not in the viewport.\n  function updateExternalMeasurement(cm, line) {\n\tline = visualLine(line)\n\tvar lineN = lineNo(line)\n\tvar view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN)\n\tview.lineN = lineN\n\tvar built = view.built = buildLineContent(cm, view)\n\tview.text = built.pre\n\tremoveChildrenAndAdd(cm.display.lineMeasure, built.pre)\n\treturn view\n  }\n  \n  // Get a {top, bottom, left, right} box (in line-local coordinates)\n  // for a given character.\n  function measureChar(cm, line, ch, bias) {\n\treturn measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)\n  }\n  \n  // Find a line view that corresponds to the given line number.\n  function findViewForLine(cm, lineN) {\n\tif (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n\t  { return cm.display.view[findViewIndex(cm, lineN)] }\n\tvar ext = cm.display.externalMeasured\n\tif (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n\t  { return ext }\n  }\n  \n  // Measurement can be split in two steps, the set-up work that\n  // applies to the whole line, and the measurement of the actual\n  // character. Functions like coordsChar, that need to do a lot of\n  // measurements in a row, can thus ensure that the set-up work is\n  // only done once.\n  function prepareMeasureForLine(cm, line) {\n\tvar lineN = lineNo(line)\n\tvar view = findViewForLine(cm, lineN)\n\tif (view && !view.text) {\n\t  view = null\n\t} else if (view && view.changes) {\n\t  updateLineForChanges(cm, view, lineN, getDimensions(cm))\n\t  cm.curOp.forceUpdate = true\n\t}\n\tif (!view)\n\t  { view = updateExternalMeasurement(cm, line) }\n  \n\tvar info = mapFromLineView(view, line, lineN)\n\treturn {\n\t  line: line, view: view, rect: null,\n\t  map: info.map, cache: info.cache, before: info.before,\n\t  hasHeights: false\n\t}\n  }\n  \n  // Given a prepared measurement object, measures the position of an\n  // actual character (or fetches it from the cache).\n  function measureCharPrepared(cm, prepared, ch, bias, varHeight) {\n\tif (prepared.before) { ch = -1 }\n\tvar key = ch + (bias || \"\"), found\n\tif (prepared.cache.hasOwnProperty(key)) {\n\t  found = prepared.cache[key]\n\t} else {\n\t  if (!prepared.rect)\n\t\t{ prepared.rect = prepared.view.text.getBoundingClientRect() }\n\t  if (!prepared.hasHeights) {\n\t\tensureLineHeights(cm, prepared.view, prepared.rect)\n\t\tprepared.hasHeights = true\n\t  }\n\t  found = measureCharInner(cm, prepared, ch, bias)\n\t  if (!found.bogus) { prepared.cache[key] = found }\n\t}\n\treturn {left: found.left, right: found.right,\n\t\t\ttop: varHeight ? found.rtop : found.top,\n\t\t\tbottom: varHeight ? found.rbottom : found.bottom}\n  }\n  \n  var nullRect = {left: 0, right: 0, top: 0, bottom: 0}\n  \n  function nodeAndOffsetInLineMap(map, ch, bias) {\n\tvar node, start, end, collapse, mStart, mEnd\n\t// First, search the line map for the text node corresponding to,\n\t// or closest to, the target character.\n\tfor (var i = 0; i < map.length; i += 3) {\n\t  mStart = map[i]\n\t  mEnd = map[i + 1]\n\t  if (ch < mStart) {\n\t\tstart = 0; end = 1\n\t\tcollapse = \"left\"\n\t  } else if (ch < mEnd) {\n\t\tstart = ch - mStart\n\t\tend = start + 1\n\t  } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {\n\t\tend = mEnd - mStart\n\t\tstart = end - 1\n\t\tif (ch >= mEnd) { collapse = \"right\" }\n\t  }\n\t  if (start != null) {\n\t\tnode = map[i + 2]\n\t\tif (mStart == mEnd && bias == (node.insertLeft ? \"left\" : \"right\"))\n\t\t  { collapse = bias }\n\t\tif (bias == \"left\" && start == 0)\n\t\t  { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {\n\t\t\tnode = map[(i -= 3) + 2]\n\t\t\tcollapse = \"left\"\n\t\t  } }\n\t\tif (bias == \"right\" && start == mEnd - mStart)\n\t\t  { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {\n\t\t\tnode = map[(i += 3) + 2]\n\t\t\tcollapse = \"right\"\n\t\t  } }\n\t\tbreak\n\t  }\n\t}\n\treturn {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}\n  }\n  \n  function getUsefulRect(rects, bias) {\n\tvar rect = nullRect\n\tif (bias == \"left\") { for (var i = 0; i < rects.length; i++) {\n\t  if ((rect = rects[i]).left != rect.right) { break }\n\t} } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {\n\t  if ((rect = rects[i$1]).left != rect.right) { break }\n\t} }\n\treturn rect\n  }\n  \n  function measureCharInner(cm, prepared, ch, bias) {\n\tvar place = nodeAndOffsetInLineMap(prepared.map, ch, bias)\n\tvar node = place.node, start = place.start, end = place.end, collapse = place.collapse\n  \n\tvar rect\n\tif (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.\n\t  for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned\n\t\twhile (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start }\n\t\twhile (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end }\n\t\tif (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)\n\t\t  { rect = node.parentNode.getBoundingClientRect() }\n\t\telse\n\t\t  { rect = getUsefulRect(range(node, start, end).getClientRects(), bias) }\n\t\tif (rect.left || rect.right || start == 0) { break }\n\t\tend = start\n\t\tstart = start - 1\n\t\tcollapse = \"right\"\n\t  }\n\t  if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect) }\n\t} else { // If it is a widget, simply get the box for the whole widget.\n\t  if (start > 0) { collapse = bias = \"right\" }\n\t  var rects\n\t  if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)\n\t\t{ rect = rects[bias == \"right\" ? rects.length - 1 : 0] }\n\t  else\n\t\t{ rect = node.getBoundingClientRect() }\n\t}\n\tif (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {\n\t  var rSpan = node.parentNode.getClientRects()[0]\n\t  if (rSpan)\n\t\t{ rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom} }\n\t  else\n\t\t{ rect = nullRect }\n\t}\n  \n\tvar rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top\n\tvar mid = (rtop + rbot) / 2\n\tvar heights = prepared.view.measure.heights\n\tvar i = 0\n\tfor (; i < heights.length - 1; i++)\n\t  { if (mid < heights[i]) { break } }\n\tvar top = i ? heights[i - 1] : 0, bot = heights[i]\n\tvar result = {left: (collapse == \"right\" ? rect.right : rect.left) - prepared.rect.left,\n\t\t\t\t  right: (collapse == \"left\" ? rect.left : rect.right) - prepared.rect.left,\n\t\t\t\t  top: top, bottom: bot}\n\tif (!rect.left && !rect.right) { result.bogus = true }\n\tif (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot }\n  \n\treturn result\n  }\n  \n  // Work around problem with bounding client rects on ranges being\n  // returned incorrectly when zoomed on IE10 and below.\n  function maybeUpdateRectForZooming(measure, rect) {\n\tif (!window.screen || screen.logicalXDPI == null ||\n\t\tscreen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))\n\t  { return rect }\n\tvar scaleX = screen.logicalXDPI / screen.deviceXDPI\n\tvar scaleY = screen.logicalYDPI / screen.deviceYDPI\n\treturn {left: rect.left * scaleX, right: rect.right * scaleX,\n\t\t\ttop: rect.top * scaleY, bottom: rect.bottom * scaleY}\n  }\n  \n  function clearLineMeasurementCacheFor(lineView) {\n\tif (lineView.measure) {\n\t  lineView.measure.cache = {}\n\t  lineView.measure.heights = null\n\t  if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)\n\t\t{ lineView.measure.caches[i] = {} } }\n\t}\n  }\n  \n  function clearLineMeasurementCache(cm) {\n\tcm.display.externalMeasure = null\n\tremoveChildren(cm.display.lineMeasure)\n\tfor (var i = 0; i < cm.display.view.length; i++)\n\t  { clearLineMeasurementCacheFor(cm.display.view[i]) }\n  }\n  \n  function clearCaches(cm) {\n\tclearLineMeasurementCache(cm)\n\tcm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null\n\tif (!cm.options.lineWrapping) { cm.display.maxLineChanged = true }\n\tcm.display.lineNumChars = null\n  }\n  \n  function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft }\n  function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop }\n  \n  // Converts a {top, bottom, left, right} box from line-local\n  // coordinates into another coordinate system. Context may be one of\n  // \"line\", \"div\" (display.lineDiv), \"local\"./null (editor), \"window\",\n  // or \"page\".\n  function intoCoordSystem(cm, lineObj, rect, context) {\n\tif (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) {\n\t  var size = widgetHeight(lineObj.widgets[i])\n\t  rect.top += size; rect.bottom += size\n\t} } }\n\tif (context == \"line\") { return rect }\n\tif (!context) { context = \"local\" }\n\tvar yOff = heightAtLine(lineObj)\n\tif (context == \"local\") { yOff += paddingTop(cm.display) }\n\telse { yOff -= cm.display.viewOffset }\n\tif (context == \"page\" || context == \"window\") {\n\t  var lOff = cm.display.lineSpace.getBoundingClientRect()\n\t  yOff += lOff.top + (context == \"window\" ? 0 : pageScrollY())\n\t  var xOff = lOff.left + (context == \"window\" ? 0 : pageScrollX())\n\t  rect.left += xOff; rect.right += xOff\n\t}\n\trect.top += yOff; rect.bottom += yOff\n\treturn rect\n  }\n  \n  // Coverts a box from \"div\" coords to another coordinate system.\n  // Context may be \"window\", \"page\", \"div\", or \"local\"./null.\n  function fromCoordSystem(cm, coords, context) {\n\tif (context == \"div\") { return coords }\n\tvar left = coords.left, top = coords.top\n\t// First move into \"page\" coordinate system\n\tif (context == \"page\") {\n\t  left -= pageScrollX()\n\t  top -= pageScrollY()\n\t} else if (context == \"local\" || !context) {\n\t  var localBox = cm.display.sizer.getBoundingClientRect()\n\t  left += localBox.left\n\t  top += localBox.top\n\t}\n  \n\tvar lineSpaceBox = cm.display.lineSpace.getBoundingClientRect()\n\treturn {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}\n  }\n  \n  function charCoords(cm, pos, context, lineObj, bias) {\n\tif (!lineObj) { lineObj = getLine(cm.doc, pos.line) }\n\treturn intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)\n  }\n  \n  // Returns a box for a given cursor position, which may have an\n  // 'other' property containing the position of the secondary cursor\n  // on a bidi boundary.\n  function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {\n\tlineObj = lineObj || getLine(cm.doc, pos.line)\n\tif (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }\n\tfunction get(ch, right) {\n\t  var m = measureCharPrepared(cm, preparedMeasure, ch, right ? \"right\" : \"left\", varHeight)\n\t  if (right) { m.left = m.right; } else { m.right = m.left }\n\t  return intoCoordSystem(cm, lineObj, m, context)\n\t}\n\tfunction getBidi(ch, partPos) {\n\t  var part = order[partPos], right = part.level % 2\n\t  if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {\n\t\tpart = order[--partPos]\n\t\tch = bidiRight(part) - (part.level % 2 ? 0 : 1)\n\t\tright = true\n\t  } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {\n\t\tpart = order[++partPos]\n\t\tch = bidiLeft(part) - part.level % 2\n\t\tright = false\n\t  }\n\t  if (right && ch == part.to && ch > part.from) { return get(ch - 1) }\n\t  return get(ch, right)\n\t}\n\tvar order = getOrder(lineObj), ch = pos.ch\n\tif (!order) { return get(ch) }\n\tvar partPos = getBidiPartAt(order, ch)\n\tvar val = getBidi(ch, partPos)\n\tif (bidiOther != null) { val.other = getBidi(ch, bidiOther) }\n\treturn val\n  }\n  \n  // Used to cheaply estimate the coordinates for a position. Used for\n  // intermediate scroll updates.\n  function estimateCoords(cm, pos) {\n\tvar left = 0\n\tpos = clipPos(cm.doc, pos)\n\tif (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch }\n\tvar lineObj = getLine(cm.doc, pos.line)\n\tvar top = heightAtLine(lineObj) + paddingTop(cm.display)\n\treturn {left: left, right: left, top: top, bottom: top + lineObj.height}\n  }\n  \n  // Positions returned by coordsChar contain some extra information.\n  // xRel is the relative x position of the input coordinates compared\n  // to the found position (so xRel > 0 means the coordinates are to\n  // the right of the character position, for example). When outside\n  // is true, that means the coordinates lie outside the line's\n  // vertical range.\n  function PosWithInfo(line, ch, outside, xRel) {\n\tvar pos = Pos(line, ch)\n\tpos.xRel = xRel\n\tif (outside) { pos.outside = true }\n\treturn pos\n  }\n  \n  // Compute the character position closest to the given coordinates.\n  // Input must be lineSpace-local (\"div\" coordinate system).\n  function coordsChar(cm, x, y) {\n\tvar doc = cm.doc\n\ty += cm.display.viewOffset\n\tif (y < 0) { return PosWithInfo(doc.first, 0, true, -1) }\n\tvar lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1\n\tif (lineN > last)\n\t  { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1) }\n\tif (x < 0) { x = 0 }\n  \n\tvar lineObj = getLine(doc, lineN)\n\tfor (;;) {\n\t  var found = coordsCharInner(cm, lineObj, lineN, x, y)\n\t  var merged = collapsedSpanAtEnd(lineObj)\n\t  var mergedPos = merged && merged.find(0, true)\n\t  if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))\n\t\t{ lineN = lineNo(lineObj = mergedPos.to.line) }\n\t  else\n\t\t{ return found }\n\t}\n  }\n  \n  function coordsCharInner(cm, lineObj, lineNo, x, y) {\n\tvar innerOff = y - heightAtLine(lineObj)\n\tvar wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth\n\tvar preparedMeasure = prepareMeasureForLine(cm, lineObj)\n  \n\tfunction getX(ch) {\n\t  var sp = cursorCoords(cm, Pos(lineNo, ch), \"line\", lineObj, preparedMeasure)\n\t  wrongLine = true\n\t  if (innerOff > sp.bottom) { return sp.left - adjust }\n\t  else if (innerOff < sp.top) { return sp.left + adjust }\n\t  else { wrongLine = false }\n\t  return sp.left\n\t}\n  \n\tvar bidi = getOrder(lineObj), dist = lineObj.text.length\n\tvar from = lineLeft(lineObj), to = lineRight(lineObj)\n\tvar fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine\n  \n\tif (x > toX) { return PosWithInfo(lineNo, to, toOutside, 1) }\n\t// Do a binary search between these bounds.\n\tfor (;;) {\n\t  if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {\n\t\tvar ch = x < fromX || x - fromX <= toX - x ? from : to\n\t\tvar outside = ch == from ? fromOutside : toOutside\n\t\tvar xDiff = x - (ch == from ? fromX : toX)\n\t\t// This is a kludge to handle the case where the coordinates\n\t\t// are after a line-wrapped line. We should replace it with a\n\t\t// more general handling of cursor positions around line\n\t\t// breaks. (Issue #4078)\n\t\tif (toOutside && !bidi && !/\\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&\n\t\t\tch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {\n\t\t  var charSize = measureCharPrepared(cm, preparedMeasure, ch, \"right\")\n\t\t  if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {\n\t\t\toutside = false\n\t\t\tch++\n\t\t\txDiff = x - charSize.right\n\t\t  }\n\t\t}\n\t\twhile (isExtendingChar(lineObj.text.charAt(ch))) { ++ch }\n\t\tvar pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0)\n\t\treturn pos\n\t  }\n\t  var step = Math.ceil(dist / 2), middle = from + step\n\t  if (bidi) {\n\t\tmiddle = from\n\t\tfor (var i = 0; i < step; ++i) { middle = moveVisually(lineObj, middle, 1) }\n\t  }\n\t  var middleX = getX(middle)\n\t  if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) { toX += 1000; } dist = step}\n\t  else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step}\n\t}\n  }\n  \n  var measureText\n  // Compute the default text height.\n  function textHeight(display) {\n\tif (display.cachedTextHeight != null) { return display.cachedTextHeight }\n\tif (measureText == null) {\n\t  measureText = elt(\"pre\")\n\t  // Measure a bunch of lines, for browsers that compute\n\t  // fractional heights.\n\t  for (var i = 0; i < 49; ++i) {\n\t\tmeasureText.appendChild(document.createTextNode(\"x\"))\n\t\tmeasureText.appendChild(elt(\"br\"))\n\t  }\n\t  measureText.appendChild(document.createTextNode(\"x\"))\n\t}\n\tremoveChildrenAndAdd(display.measure, measureText)\n\tvar height = measureText.offsetHeight / 50\n\tif (height > 3) { display.cachedTextHeight = height }\n\tremoveChildren(display.measure)\n\treturn height || 1\n  }\n  \n  // Compute the default character width.\n  function charWidth(display) {\n\tif (display.cachedCharWidth != null) { return display.cachedCharWidth }\n\tvar anchor = elt(\"span\", \"xxxxxxxxxx\")\n\tvar pre = elt(\"pre\", [anchor])\n\tremoveChildrenAndAdd(display.measure, pre)\n\tvar rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10\n\tif (width > 2) { display.cachedCharWidth = width }\n\treturn width || 10\n  }\n  \n  // Do a bulk-read of the DOM positions and sizes needed to draw the\n  // view, so that we don't interleave reading and writing to the DOM.\n  function getDimensions(cm) {\n\tvar d = cm.display, left = {}, width = {}\n\tvar gutterLeft = d.gutters.clientLeft\n\tfor (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {\n\t  left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft\n\t  width[cm.options.gutters[i]] = n.clientWidth\n\t}\n\treturn {fixedPos: compensateForHScroll(d),\n\t\t\tgutterTotalWidth: d.gutters.offsetWidth,\n\t\t\tgutterLeft: left,\n\t\t\tgutterWidth: width,\n\t\t\twrapperWidth: d.wrapper.clientWidth}\n  }\n  \n  // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,\n  // but using getBoundingClientRect to get a sub-pixel-accurate\n  // result.\n  function compensateForHScroll(display) {\n\treturn display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left\n  }\n  \n  // Returns a function that estimates the height of a line, to use as\n  // first approximation until the line becomes visible (and is thus\n  // properly measurable).\n  function estimateHeight(cm) {\n\tvar th = textHeight(cm.display), wrapping = cm.options.lineWrapping\n\tvar perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3)\n\treturn function (line) {\n\t  if (lineIsHidden(cm.doc, line)) { return 0 }\n  \n\t  var widgetsHeight = 0\n\t  if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {\n\t\tif (line.widgets[i].height) { widgetsHeight += line.widgets[i].height }\n\t  } }\n  \n\t  if (wrapping)\n\t\t{ return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }\n\t  else\n\t\t{ return widgetsHeight + th }\n\t}\n  }\n  \n  function estimateLineHeights(cm) {\n\tvar doc = cm.doc, est = estimateHeight(cm)\n\tdoc.iter(function (line) {\n\t  var estHeight = est(line)\n\t  if (estHeight != line.height) { updateLineHeight(line, estHeight) }\n\t})\n  }\n  \n  // Given a mouse event, find the corresponding position. If liberal\n  // is false, it checks whether a gutter or scrollbar was clicked,\n  // and returns null if it was. forRect is used by rectangular\n  // selections, and tries to estimate a character position even for\n  // coordinates beyond the right of the text.\n  function posFromMouse(cm, e, liberal, forRect) {\n\tvar display = cm.display\n\tif (!liberal && e_target(e).getAttribute(\"cm-not-content\") == \"true\") { return null }\n  \n\tvar x, y, space = display.lineSpace.getBoundingClientRect()\n\t// Fails unpredictably on IE[67] when mouse is dragged around quickly.\n\ttry { x = e.clientX - space.left; y = e.clientY - space.top }\n\tcatch (e) { return null }\n\tvar coords = coordsChar(cm, x, y), line\n\tif (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {\n\t  var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length\n\t  coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff))\n\t}\n\treturn coords\n  }\n  \n  // Find the view element corresponding to a given line. Return null\n  // when the line isn't visible.\n  function findViewIndex(cm, n) {\n\tif (n >= cm.display.viewTo) { return null }\n\tn -= cm.display.viewFrom\n\tif (n < 0) { return null }\n\tvar view = cm.display.view\n\tfor (var i = 0; i < view.length; i++) {\n\t  n -= view[i].size\n\t  if (n < 0) { return i }\n\t}\n  }\n  \n  function updateSelection(cm) {\n\tcm.display.input.showSelection(cm.display.input.prepareSelection())\n  }\n  \n  function prepareSelection(cm, primary) {\n\tvar doc = cm.doc, result = {}\n\tvar curFragment = result.cursors = document.createDocumentFragment()\n\tvar selFragment = result.selection = document.createDocumentFragment()\n  \n\tfor (var i = 0; i < doc.sel.ranges.length; i++) {\n\t  if (primary === false && i == doc.sel.primIndex) { continue }\n\t  var range = doc.sel.ranges[i]\n\t  if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }\n\t  var collapsed = range.empty()\n\t  if (collapsed || cm.options.showCursorWhenSelecting)\n\t\t{ drawSelectionCursor(cm, range.head, curFragment) }\n\t  if (!collapsed)\n\t\t{ drawSelectionRange(cm, range, selFragment) }\n\t}\n\treturn result\n  }\n  \n  // Draws a cursor for the given range\n  function drawSelectionCursor(cm, head, output) {\n\tvar pos = cursorCoords(cm, head, \"div\", null, null, !cm.options.singleCursorHeightPerLine)\n  \n\tvar cursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor\"))\n\tcursor.style.left = pos.left + \"px\"\n\tcursor.style.top = pos.top + \"px\"\n\tcursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + \"px\"\n  \n\tif (pos.other) {\n\t  // Secondary cursor, shown when on a 'jump' in bi-directional text\n\t  var otherCursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor CodeMirror-secondarycursor\"))\n\t  otherCursor.style.display = \"\"\n\t  otherCursor.style.left = pos.other.left + \"px\"\n\t  otherCursor.style.top = pos.other.top + \"px\"\n\t  otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + \"px\"\n\t}\n  }\n  \n  // Draws the given range as a highlighted selection\n  function drawSelectionRange(cm, range, output) {\n\tvar display = cm.display, doc = cm.doc\n\tvar fragment = document.createDocumentFragment()\n\tvar padding = paddingH(cm.display), leftSide = padding.left\n\tvar rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right\n  \n\tfunction add(left, top, width, bottom) {\n\t  if (top < 0) { top = 0 }\n\t  top = Math.round(top)\n\t  bottom = Math.round(bottom)\n\t  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\")))\n\t}\n  \n\tfunction drawForLine(line, fromArg, toArg) {\n\t  var lineObj = getLine(doc, line)\n\t  var lineLen = lineObj.text.length\n\t  var start, end\n\t  function coords(ch, bias) {\n\t\treturn charCoords(cm, Pos(line, ch), \"div\", lineObj, bias)\n\t  }\n  \n\t  iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) {\n\t\tvar leftPos = coords(from, \"left\"), rightPos, left, right\n\t\tif (from == to) {\n\t\t  rightPos = leftPos\n\t\t  left = right = leftPos.left\n\t\t} else {\n\t\t  rightPos = coords(to - 1, \"right\")\n\t\t  if (dir == \"rtl\") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp }\n\t\t  left = leftPos.left\n\t\t  right = rightPos.right\n\t\t}\n\t\tif (fromArg == null && from == 0) { left = leftSide }\n\t\tif (rightPos.top - leftPos.top > 3) { // Different lines, draw top part\n\t\t  add(left, leftPos.top, null, leftPos.bottom)\n\t\t  left = leftSide\n\t\t  if (leftPos.bottom < rightPos.top) { add(left, leftPos.bottom, null, rightPos.top) }\n\t\t}\n\t\tif (toArg == null && to == lineLen) { right = rightSide }\n\t\tif (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)\n\t\t  { start = leftPos }\n\t\tif (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)\n\t\t  { end = rightPos }\n\t\tif (left < leftSide + 1) { left = leftSide }\n\t\tadd(left, rightPos.top, right - left, rightPos.bottom)\n\t  })\n\t  return {start: start, end: end}\n\t}\n  \n\tvar sFrom = range.from(), sTo = range.to()\n\tif (sFrom.line == sTo.line) {\n\t  drawForLine(sFrom.line, sFrom.ch, sTo.ch)\n\t} else {\n\t  var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line)\n\t  var singleVLine = visualLine(fromLine) == visualLine(toLine)\n\t  var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end\n\t  var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start\n\t  if (singleVLine) {\n\t\tif (leftEnd.top < rightStart.top - 2) {\n\t\t  add(leftEnd.right, leftEnd.top, null, leftEnd.bottom)\n\t\t  add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)\n\t\t} else {\n\t\t  add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)\n\t\t}\n\t  }\n\t  if (leftEnd.bottom < rightStart.top)\n\t\t{ add(leftSide, leftEnd.bottom, null, rightStart.top) }\n\t}\n  \n\toutput.appendChild(fragment)\n  }\n  \n  // Cursor-blinking\n  function restartBlink(cm) {\n\tif (!cm.state.focused) { return }\n\tvar display = cm.display\n\tclearInterval(display.blinker)\n\tvar on = true\n\tdisplay.cursorDiv.style.visibility = \"\"\n\tif (cm.options.cursorBlinkRate > 0)\n\t  { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? \"\" : \"hidden\"; },\n\t\tcm.options.cursorBlinkRate) }\n\telse if (cm.options.cursorBlinkRate < 0)\n\t  { display.cursorDiv.style.visibility = \"hidden\" }\n  }\n  \n  function ensureFocus(cm) {\n\tif (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) }\n  }\n  \n  function delayBlurEvent(cm) {\n\tcm.state.delayingBlurEvent = true\n\tsetTimeout(function () { if (cm.state.delayingBlurEvent) {\n\t  cm.state.delayingBlurEvent = false\n\t  onBlur(cm)\n\t} }, 100)\n  }\n  \n  function onFocus(cm, e) {\n\tif (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false }\n  \n\tif (cm.options.readOnly == \"nocursor\") { return }\n\tif (!cm.state.focused) {\n\t  signal(cm, \"focus\", cm, e)\n\t  cm.state.focused = true\n\t  addClass(cm.display.wrapper, \"CodeMirror-focused\")\n\t  // This test prevents this from firing when a context\n\t  // menu is closed (since the input reset would kill the\n\t  // select-all detection hack)\n\t  if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {\n\t\tcm.display.input.reset()\n\t\tif (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20) } // Issue #1730\n\t  }\n\t  cm.display.input.receivedFocus()\n\t}\n\trestartBlink(cm)\n  }\n  function onBlur(cm, e) {\n\tif (cm.state.delayingBlurEvent) { return }\n  \n\tif (cm.state.focused) {\n\t  signal(cm, \"blur\", cm, e)\n\t  cm.state.focused = false\n\t  rmClass(cm.display.wrapper, \"CodeMirror-focused\")\n\t}\n\tclearInterval(cm.display.blinker)\n\tsetTimeout(function () { if (!cm.state.focused) { cm.display.shift = false } }, 150)\n  }\n  \n  // Re-align line numbers and gutter marks to compensate for\n  // horizontal scrolling.\n  function alignHorizontally(cm) {\n\tvar display = cm.display, view = display.view\n\tif (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }\n\tvar comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft\n\tvar gutterW = display.gutters.offsetWidth, left = comp + \"px\"\n\tfor (var i = 0; i < view.length; i++) { if (!view[i].hidden) {\n\t  if (cm.options.fixedGutter) {\n\t\tif (view[i].gutter)\n\t\t  { view[i].gutter.style.left = left }\n\t\tif (view[i].gutterBackground)\n\t\t  { view[i].gutterBackground.style.left = left }\n\t  }\n\t  var align = view[i].alignable\n\t  if (align) { for (var j = 0; j < align.length; j++)\n\t\t{ align[j].style.left = left } }\n\t} }\n\tif (cm.options.fixedGutter)\n\t  { display.gutters.style.left = (comp + gutterW) + \"px\" }\n  }\n  \n  // Used to ensure that the line number gutter is still the right\n  // size for the current document size. Returns true when an update\n  // is needed.\n  function maybeUpdateLineNumberWidth(cm) {\n\tif (!cm.options.lineNumbers) { return false }\n\tvar doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display\n\tif (last.length != display.lineNumChars) {\n\t  var test = display.measure.appendChild(elt(\"div\", [elt(\"div\", last)],\n\t\t\t\t\t\t\t\t\t\t\t\t \"CodeMirror-linenumber CodeMirror-gutter-elt\"))\n\t  var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW\n\t  display.lineGutter.style.width = \"\"\n\t  display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1\n\t  display.lineNumWidth = display.lineNumInnerWidth + padding\n\t  display.lineNumChars = display.lineNumInnerWidth ? last.length : -1\n\t  display.lineGutter.style.width = display.lineNumWidth + \"px\"\n\t  updateGutterSpace(cm)\n\t  return true\n\t}\n\treturn false\n  }\n  \n  // Read the actual heights of the rendered lines, and update their\n  // stored heights to match.\n  function updateHeightsInViewport(cm) {\n\tvar display = cm.display\n\tvar prevBottom = display.lineDiv.offsetTop\n\tfor (var i = 0; i < display.view.length; i++) {\n\t  var cur = display.view[i], height = void 0\n\t  if (cur.hidden) { continue }\n\t  if (ie && ie_version < 8) {\n\t\tvar bot = cur.node.offsetTop + cur.node.offsetHeight\n\t\theight = bot - prevBottom\n\t\tprevBottom = bot\n\t  } else {\n\t\tvar box = cur.node.getBoundingClientRect()\n\t\theight = box.bottom - box.top\n\t  }\n\t  var diff = cur.line.height - height\n\t  if (height < 2) { height = textHeight(display) }\n\t  if (diff > .001 || diff < -.001) {\n\t\tupdateLineHeight(cur.line, height)\n\t\tupdateWidgetHeight(cur.line)\n\t\tif (cur.rest) { for (var j = 0; j < cur.rest.length; j++)\n\t\t  { updateWidgetHeight(cur.rest[j]) } }\n\t  }\n\t}\n  }\n  \n  // Read and store the height of line widgets associated with the\n  // given line.\n  function updateWidgetHeight(line) {\n\tif (line.widgets) { for (var i = 0; i < line.widgets.length; ++i)\n\t  { line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight } }\n  }\n  \n  // Compute the lines that are visible in a given viewport (defaults\n  // the the current scroll position). viewport may contain top,\n  // height, and ensure (see op.scrollToPos) properties.\n  function visibleLines(display, doc, viewport) {\n\tvar top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop\n\ttop = Math.floor(top - paddingTop(display))\n\tvar bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight\n  \n\tvar from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom)\n\t// Ensure is a {from: {line, ch}, to: {line, ch}} object, and\n\t// forces those lines into the viewport (if possible).\n\tif (viewport && viewport.ensure) {\n\t  var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line\n\t  if (ensureFrom < from) {\n\t\tfrom = ensureFrom\n\t\tto = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)\n\t  } else if (Math.min(ensureTo, doc.lastLine()) >= to) {\n\t\tfrom = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight)\n\t\tto = ensureTo\n\t  }\n\t}\n\treturn {from: from, to: Math.max(to, from + 1)}\n  }\n  \n  // Sync the scrollable area and scrollbars, ensure the viewport\n  // covers the visible area.\n  function setScrollTop(cm, val) {\n\tif (Math.abs(cm.doc.scrollTop - val) < 2) { return }\n\tcm.doc.scrollTop = val\n\tif (!gecko) { updateDisplaySimple(cm, {top: val}) }\n\tif (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val }\n\tcm.display.scrollbars.setScrollTop(val)\n\tif (gecko) { updateDisplaySimple(cm) }\n\tstartWorker(cm, 100)\n  }\n  // Sync scroller and scrollbar, ensure the gutter elements are\n  // aligned.\n  function setScrollLeft(cm, val, isScroller) {\n\tif (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) { return }\n\tval = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)\n\tcm.doc.scrollLeft = val\n\talignHorizontally(cm)\n\tif (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val }\n\tcm.display.scrollbars.setScrollLeft(val)\n  }\n  \n  // Since the delta values reported on mouse wheel events are\n  // unstandardized between browsers and even browser versions, and\n  // generally horribly unpredictable, this code starts by measuring\n  // the scroll effect that the first few mouse wheel events have,\n  // and, from that, detects the way it can convert deltas to pixel\n  // offsets afterwards.\n  //\n  // The reason we want to know the amount a wheel event will scroll\n  // is that it gives us a chance to update the display before the\n  // actual scrolling happens, reducing flickering.\n  \n  var wheelSamples = 0;\n  var wheelPixelsPerUnit = null;\n  // Fill in a browser-detected starting value on browsers where we\n  // know one. These don't have to be accurate -- the result of them\n  // being wrong would just be a slight flicker on the first wheel\n  // scroll (if it is large enough).\n  if (ie) { wheelPixelsPerUnit = -.53 }\n  else if (gecko) { wheelPixelsPerUnit = 15 }\n  else if (chrome) { wheelPixelsPerUnit = -.7 }\n  else if (safari) { wheelPixelsPerUnit = -1/3 }\n  \n  function wheelEventDelta(e) {\n\tvar dx = e.wheelDeltaX, dy = e.wheelDeltaY\n\tif (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail }\n\tif (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail }\n\telse if (dy == null) { dy = e.wheelDelta }\n\treturn {x: dx, y: dy}\n  }\n  function wheelEventPixels(e) {\n\tvar delta = wheelEventDelta(e)\n\tdelta.x *= wheelPixelsPerUnit\n\tdelta.y *= wheelPixelsPerUnit\n\treturn delta\n  }\n  \n  function onScrollWheel(cm, e) {\n\tvar delta = wheelEventDelta(e), dx = delta.x, dy = delta.y\n  \n\tvar display = cm.display, scroll = display.scroller\n\t// Quit if there's nothing to scroll here\n\tvar canScrollX = scroll.scrollWidth > scroll.clientWidth\n\tvar canScrollY = scroll.scrollHeight > scroll.clientHeight\n\tif (!(dx && canScrollX || dy && canScrollY)) { return }\n  \n\t// Webkit browsers on OS X abort momentum scrolls when the target\n\t// of the scroll event is removed from the scrollable element.\n\t// This hack (see related code in patchDisplay) makes sure the\n\t// element is kept around.\n\tif (dy && mac && webkit) {\n\t  outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {\n\t\tfor (var i = 0; i < view.length; i++) {\n\t\t  if (view[i].node == cur) {\n\t\t\tcm.display.currentWheelTarget = cur\n\t\t\tbreak outer\n\t\t  }\n\t\t}\n\t  }\n\t}\n  \n\t// On some browsers, horizontal scrolling will cause redraws to\n\t// happen before the gutter has been realigned, causing it to\n\t// wriggle around in a most unseemly way. When we have an\n\t// estimated pixels/delta value, we just handle horizontal\n\t// scrolling entirely here. It'll be slightly off from native, but\n\t// better than glitching out.\n\tif (dx && !gecko && !presto && wheelPixelsPerUnit != null) {\n\t  if (dy && canScrollY)\n\t\t{ setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))) }\n\t  setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)))\n\t  // Only prevent default scrolling if vertical scrolling is\n\t  // actually possible. Otherwise, it causes vertical scroll\n\t  // jitter on OSX trackpads when deltaX is small and deltaY\n\t  // is large (issue #3579)\n\t  if (!dy || (dy && canScrollY))\n\t\t{ e_preventDefault(e) }\n\t  display.wheelStartX = null // Abort measurement, if in progress\n\t  return\n\t}\n  \n\t// 'Project' the visible viewport to cover the area that is being\n\t// scrolled into view (if we know enough to estimate it).\n\tif (dy && wheelPixelsPerUnit != null) {\n\t  var pixels = dy * wheelPixelsPerUnit\n\t  var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight\n\t  if (pixels < 0) { top = Math.max(0, top + pixels - 50) }\n\t  else { bot = Math.min(cm.doc.height, bot + pixels + 50) }\n\t  updateDisplaySimple(cm, {top: top, bottom: bot})\n\t}\n  \n\tif (wheelSamples < 20) {\n\t  if (display.wheelStartX == null) {\n\t\tdisplay.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop\n\t\tdisplay.wheelDX = dx; display.wheelDY = dy\n\t\tsetTimeout(function () {\n\t\t  if (display.wheelStartX == null) { return }\n\t\t  var movedX = scroll.scrollLeft - display.wheelStartX\n\t\t  var movedY = scroll.scrollTop - display.wheelStartY\n\t\t  var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||\n\t\t\t(movedX && display.wheelDX && movedX / display.wheelDX)\n\t\t  display.wheelStartX = display.wheelStartY = null\n\t\t  if (!sample) { return }\n\t\t  wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1)\n\t\t  ++wheelSamples\n\t\t}, 200)\n\t  } else {\n\t\tdisplay.wheelDX += dx; display.wheelDY += dy\n\t  }\n\t}\n  }\n  \n  // SCROLLBARS\n  \n  // Prepare DOM reads needed to update the scrollbars. Done in one\n  // shot to minimize update/measure roundtrips.\n  function measureForScrollbars(cm) {\n\tvar d = cm.display, gutterW = d.gutters.offsetWidth\n\tvar docH = Math.round(cm.doc.height + paddingVert(cm.display))\n\treturn {\n\t  clientHeight: d.scroller.clientHeight,\n\t  viewHeight: d.wrapper.clientHeight,\n\t  scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,\n\t  viewWidth: d.wrapper.clientWidth,\n\t  barLeft: cm.options.fixedGutter ? gutterW : 0,\n\t  docHeight: docH,\n\t  scrollHeight: docH + scrollGap(cm) + d.barHeight,\n\t  nativeBarWidth: d.nativeBarWidth,\n\t  gutterWidth: gutterW\n\t}\n  }\n  \n  function NativeScrollbars(place, scroll, cm) {\n\tthis.cm = cm\n\tvar vert = this.vert = elt(\"div\", [elt(\"div\", null, null, \"min-width: 1px\")], \"CodeMirror-vscrollbar\")\n\tvar horiz = this.horiz = elt(\"div\", [elt(\"div\", null, null, \"height: 100%; min-height: 1px\")], \"CodeMirror-hscrollbar\")\n\tplace(vert); place(horiz)\n  \n\ton(vert, \"scroll\", function () {\n\t  if (vert.clientHeight) { scroll(vert.scrollTop, \"vertical\") }\n\t})\n\ton(horiz, \"scroll\", function () {\n\t  if (horiz.clientWidth) { scroll(horiz.scrollLeft, \"horizontal\") }\n\t})\n  \n\tthis.checkedZeroWidth = false\n\t// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).\n\tif (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = \"18px\" }\n  }\n  \n  NativeScrollbars.prototype = copyObj({\n\tupdate: function(measure) {\n\t  var needsH = measure.scrollWidth > measure.clientWidth + 1\n\t  var needsV = measure.scrollHeight > measure.clientHeight + 1\n\t  var sWidth = measure.nativeBarWidth\n  \n\t  if (needsV) {\n\t\tthis.vert.style.display = \"block\"\n\t\tthis.vert.style.bottom = needsH ? sWidth + \"px\" : \"0\"\n\t\tvar totalHeight = measure.viewHeight - (needsH ? sWidth : 0)\n\t\t// A bug in IE8 can cause this value to be negative, so guard it.\n\t\tthis.vert.firstChild.style.height =\n\t\t  Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + \"px\"\n\t  } else {\n\t\tthis.vert.style.display = \"\"\n\t\tthis.vert.firstChild.style.height = \"0\"\n\t  }\n  \n\t  if (needsH) {\n\t\tthis.horiz.style.display = \"block\"\n\t\tthis.horiz.style.right = needsV ? sWidth + \"px\" : \"0\"\n\t\tthis.horiz.style.left = measure.barLeft + \"px\"\n\t\tvar totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)\n\t\tthis.horiz.firstChild.style.width =\n\t\t  (measure.scrollWidth - measure.clientWidth + totalWidth) + \"px\"\n\t  } else {\n\t\tthis.horiz.style.display = \"\"\n\t\tthis.horiz.firstChild.style.width = \"0\"\n\t  }\n  \n\t  if (!this.checkedZeroWidth && measure.clientHeight > 0) {\n\t\tif (sWidth == 0) { this.zeroWidthHack() }\n\t\tthis.checkedZeroWidth = true\n\t  }\n  \n\t  return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}\n\t},\n\tsetScrollLeft: function(pos) {\n\t  if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }\n\t  if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }\n\t},\n\tsetScrollTop: function(pos) {\n\t  if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }\n\t  if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }\n\t},\n\tzeroWidthHack: function() {\n\t  var w = mac && !mac_geMountainLion ? \"12px\" : \"18px\"\n\t  this.horiz.style.height = this.vert.style.width = w\n\t  this.horiz.style.pointerEvents = this.vert.style.pointerEvents = \"none\"\n\t  this.disableHoriz = new Delayed\n\t  this.disableVert = new Delayed\n\t},\n\tenableZeroWidthBar: function(bar, delay) {\n\t  bar.style.pointerEvents = \"auto\"\n\t  function maybeDisable() {\n\t\t// To find out whether the scrollbar is still visible, we\n\t\t// check whether the element under the pixel in the bottom\n\t\t// left corner of the scrollbar box is the scrollbar box\n\t\t// itself (when the bar is still visible) or its filler child\n\t\t// (when the bar is hidden). If it is still visible, we keep\n\t\t// it enabled, if it's hidden, we disable pointer events.\n\t\tvar box = bar.getBoundingClientRect()\n\t\tvar elt = document.elementFromPoint(box.left + 1, box.bottom - 1)\n\t\tif (elt != bar) { bar.style.pointerEvents = \"none\" }\n\t\telse { delay.set(1000, maybeDisable) }\n\t  }\n\t  delay.set(1000, maybeDisable)\n\t},\n\tclear: function() {\n\t  var parent = this.horiz.parentNode\n\t  parent.removeChild(this.horiz)\n\t  parent.removeChild(this.vert)\n\t}\n  }, NativeScrollbars.prototype)\n  \n  function NullScrollbars() {}\n  \n  NullScrollbars.prototype = copyObj({\n\tupdate: function() { return {bottom: 0, right: 0} },\n\tsetScrollLeft: function() {},\n\tsetScrollTop: function() {},\n\tclear: function() {}\n  }, NullScrollbars.prototype)\n  \n  function updateScrollbars(cm, measure) {\n\tif (!measure) { measure = measureForScrollbars(cm) }\n\tvar startWidth = cm.display.barWidth, startHeight = cm.display.barHeight\n\tupdateScrollbarsInner(cm, measure)\n\tfor (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {\n\t  if (startWidth != cm.display.barWidth && cm.options.lineWrapping)\n\t\t{ updateHeightsInViewport(cm) }\n\t  updateScrollbarsInner(cm, measureForScrollbars(cm))\n\t  startWidth = cm.display.barWidth; startHeight = cm.display.barHeight\n\t}\n  }\n  \n  // Re-synchronize the fake scrollbars with the actual size of the\n  // content.\n  function updateScrollbarsInner(cm, measure) {\n\tvar d = cm.display\n\tvar sizes = d.scrollbars.update(measure)\n  \n\td.sizer.style.paddingRight = (d.barWidth = sizes.right) + \"px\"\n\td.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + \"px\"\n\td.heightForcer.style.borderBottom = sizes.bottom + \"px solid transparent\"\n  \n\tif (sizes.right && sizes.bottom) {\n\t  d.scrollbarFiller.style.display = \"block\"\n\t  d.scrollbarFiller.style.height = sizes.bottom + \"px\"\n\t  d.scrollbarFiller.style.width = sizes.right + \"px\"\n\t} else { d.scrollbarFiller.style.display = \"\" }\n\tif (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {\n\t  d.gutterFiller.style.display = \"block\"\n\t  d.gutterFiller.style.height = sizes.bottom + \"px\"\n\t  d.gutterFiller.style.width = measure.gutterWidth + \"px\"\n\t} else { d.gutterFiller.style.display = \"\" }\n  }\n  \n  var scrollbarModel = {\"native\": NativeScrollbars, \"null\": NullScrollbars}\n  \n  function initScrollbars(cm) {\n\tif (cm.display.scrollbars) {\n\t  cm.display.scrollbars.clear()\n\t  if (cm.display.scrollbars.addClass)\n\t\t{ rmClass(cm.display.wrapper, cm.display.scrollbars.addClass) }\n\t}\n  \n\tcm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {\n\t  cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller)\n\t  // Prevent clicks in the scrollbars from killing focus\n\t  on(node, \"mousedown\", function () {\n\t\tif (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0) }\n\t  })\n\t  node.setAttribute(\"cm-not-content\", \"true\")\n\t}, function (pos, axis) {\n\t  if (axis == \"horizontal\") { setScrollLeft(cm, pos) }\n\t  else { setScrollTop(cm, pos) }\n\t}, cm)\n\tif (cm.display.scrollbars.addClass)\n\t  { addClass(cm.display.wrapper, cm.display.scrollbars.addClass) }\n  }\n  \n  // SCROLLING THINGS INTO VIEW\n  \n  // If an editor sits on the top or bottom of the window, partially\n  // scrolled out of view, this ensures that the cursor is visible.\n  function maybeScrollWindow(cm, coords) {\n\tif (signalDOMEvent(cm, \"scrollCursorIntoView\")) { return }\n  \n\tvar display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null\n\tif (coords.top + box.top < 0) { doScroll = true }\n\telse if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false }\n\tif (doScroll != null && !phantom) {\n\t  var scrollNode = elt(\"div\", \"\\u200b\", null, (\"position: absolute;\\n                         top: \" + (coords.top - display.viewOffset - paddingTop(cm.display)) + \"px;\\n                         height: \" + (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + \"px;\\n                         left: \" + (coords.left) + \"px; width: 2px;\"))\n\t  cm.display.lineSpace.appendChild(scrollNode)\n\t  scrollNode.scrollIntoView(doScroll)\n\t  cm.display.lineSpace.removeChild(scrollNode)\n\t}\n  }\n  \n  // Scroll a given position into view (immediately), verifying that\n  // it actually became visible (as line heights are accurately\n  // measured, the position of something may 'drift' during drawing).\n  function scrollPosIntoView(cm, pos, end, margin) {\n\tif (margin == null) { margin = 0 }\n\tvar coords\n\tfor (var limit = 0; limit < 5; limit++) {\n\t  var changed = false\n\t  coords = cursorCoords(cm, pos)\n\t  var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)\n\t  var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),\n\t\t\t\t\t\t\t\t\t\t Math.min(coords.top, endCoords.top) - margin,\n\t\t\t\t\t\t\t\t\t\t Math.max(coords.left, endCoords.left),\n\t\t\t\t\t\t\t\t\t\t Math.max(coords.bottom, endCoords.bottom) + margin)\n\t  var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft\n\t  if (scrollPos.scrollTop != null) {\n\t\tsetScrollTop(cm, scrollPos.scrollTop)\n\t\tif (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true }\n\t  }\n\t  if (scrollPos.scrollLeft != null) {\n\t\tsetScrollLeft(cm, scrollPos.scrollLeft)\n\t\tif (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true }\n\t  }\n\t  if (!changed) { break }\n\t}\n\treturn coords\n  }\n  \n  // Scroll a given set of coordinates into view (immediately).\n  function scrollIntoView(cm, x1, y1, x2, y2) {\n\tvar scrollPos = calculateScrollPos(cm, x1, y1, x2, y2)\n\tif (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop) }\n\tif (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }\n  }\n  \n  // Calculate a new scroll position needed to scroll the given\n  // rectangle into view. Returns an object with scrollTop and\n  // scrollLeft properties. When these are undefined, the\n  // vertical/horizontal position does not need to be adjusted.\n  function calculateScrollPos(cm, x1, y1, x2, y2) {\n\tvar display = cm.display, snapMargin = textHeight(cm.display)\n\tif (y1 < 0) { y1 = 0 }\n\tvar screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop\n\tvar screen = displayHeight(cm), result = {}\n\tif (y2 - y1 > screen) { y2 = y1 + screen }\n\tvar docBottom = cm.doc.height + paddingVert(display)\n\tvar atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin\n\tif (y1 < screentop) {\n\t  result.scrollTop = atTop ? 0 : y1\n\t} else if (y2 > screentop + screen) {\n\t  var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen)\n\t  if (newTop != screentop) { result.scrollTop = newTop }\n\t}\n  \n\tvar screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft\n\tvar screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)\n\tvar tooWide = x2 - x1 > screenw\n\tif (tooWide) { x2 = x1 + screenw }\n\tif (x1 < 10)\n\t  { result.scrollLeft = 0 }\n\telse if (x1 < screenleft)\n\t  { result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)) }\n\telse if (x2 > screenw + screenleft - 3)\n\t  { result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw }\n\treturn result\n  }\n  \n  // Store a relative adjustment to the scroll position in the current\n  // operation (to be applied when the operation finishes).\n  function addToScrollPos(cm, left, top) {\n\tif (left != null || top != null) { resolveScrollToPos(cm) }\n\tif (left != null)\n\t  { cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left }\n\tif (top != null)\n\t  { cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top }\n  }\n  \n  // Make sure that at the end of the operation the current cursor is\n  // shown.\n  function ensureCursorVisible(cm) {\n\tresolveScrollToPos(cm)\n\tvar cur = cm.getCursor(), from = cur, to = cur\n\tif (!cm.options.lineWrapping) {\n\t  from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur\n\t  to = Pos(cur.line, cur.ch + 1)\n\t}\n\tcm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}\n  }\n  \n  // When an operation has its scrollToPos property set, and another\n  // scroll action is applied before the end of the operation, this\n  // 'simulates' scrolling that position into view in a cheap way, so\n  // that the effect of intermediate scroll commands is not ignored.\n  function resolveScrollToPos(cm) {\n\tvar range = cm.curOp.scrollToPos\n\tif (range) {\n\t  cm.curOp.scrollToPos = null\n\t  var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)\n\t  var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),\n\t\t\t\t\t\t\t\t\tMath.min(from.top, to.top) - range.margin,\n\t\t\t\t\t\t\t\t\tMath.max(from.right, to.right),\n\t\t\t\t\t\t\t\t\tMath.max(from.bottom, to.bottom) + range.margin)\n\t  cm.scrollTo(sPos.scrollLeft, sPos.scrollTop)\n\t}\n  }\n  \n  // Operations are used to wrap a series of changes to the editor\n  // state in such a way that each change won't have to update the\n  // cursor and display (which would be awkward, slow, and\n  // error-prone). Instead, display updates are batched and then all\n  // combined and executed at once.\n  \n  var nextOpId = 0\n  // Start a new operation.\n  function startOperation(cm) {\n\tcm.curOp = {\n\t  cm: cm,\n\t  viewChanged: false,      // Flag that indicates that lines might need to be redrawn\n\t  startHeight: cm.doc.height, // Used to detect need to update scrollbar\n\t  forceUpdate: false,      // Used to force a redraw\n\t  updateInput: null,       // Whether to reset the input textarea\n\t  typing: false,           // Whether this reset should be careful to leave existing text (for compositing)\n\t  changeObjs: null,        // Accumulated changes, for firing change events\n\t  cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on\n\t  cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already\n\t  selectionChanged: false, // Whether the selection needs to be redrawn\n\t  updateMaxLine: false,    // Set when the widest line needs to be determined anew\n\t  scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet\n\t  scrollToPos: null,       // Used to scroll to a specific position\n\t  focus: false,\n\t  id: ++nextOpId           // Unique ID\n\t}\n\tpushOperation(cm.curOp)\n  }\n  \n  // Finish an operation, updating the display and signalling delayed events\n  function endOperation(cm) {\n\tvar op = cm.curOp\n\tfinishOperation(op, function (group) {\n\t  for (var i = 0; i < group.ops.length; i++)\n\t\t{ group.ops[i].cm.curOp = null }\n\t  endOperations(group)\n\t})\n  }\n  \n  // The DOM updates done when an operation finishes are batched so\n  // that the minimum number of relayouts are required.\n  function endOperations(group) {\n\tvar ops = group.ops\n\tfor (var i = 0; i < ops.length; i++) // Read DOM\n\t  { endOperation_R1(ops[i]) }\n\tfor (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)\n\t  { endOperation_W1(ops[i$1]) }\n\tfor (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM\n\t  { endOperation_R2(ops[i$2]) }\n\tfor (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)\n\t  { endOperation_W2(ops[i$3]) }\n\tfor (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM\n\t  { endOperation_finish(ops[i$4]) }\n  }\n  \n  function endOperation_R1(op) {\n\tvar cm = op.cm, display = cm.display\n\tmaybeClipScrollbars(cm)\n\tif (op.updateMaxLine) { findMaxLine(cm) }\n  \n\top.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||\n\t  op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||\n\t\t\t\t\t\t op.scrollToPos.to.line >= display.viewTo) ||\n\t  display.maxLineChanged && cm.options.lineWrapping\n\top.update = op.mustUpdate &&\n\t  new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate)\n  }\n  \n  function endOperation_W1(op) {\n\top.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update)\n  }\n  \n  function endOperation_R2(op) {\n\tvar cm = op.cm, display = cm.display\n\tif (op.updatedDisplay) { updateHeightsInViewport(cm) }\n  \n\top.barMeasure = measureForScrollbars(cm)\n  \n\t// If the max line changed since it was last measured, measure it,\n\t// and ensure the document's width matches it.\n\t// updateDisplay_W2 will use these properties to do the actual resizing\n\tif (display.maxLineChanged && !cm.options.lineWrapping) {\n\t  op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3\n\t  cm.display.sizerWidth = op.adjustWidthTo\n\t  op.barMeasure.scrollWidth =\n\t\tMath.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth)\n\t  op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm))\n\t}\n  \n\tif (op.updatedDisplay || op.selectionChanged)\n\t  { op.preparedSelection = display.input.prepareSelection(op.focus) }\n  }\n  \n  function endOperation_W2(op) {\n\tvar cm = op.cm\n  \n\tif (op.adjustWidthTo != null) {\n\t  cm.display.sizer.style.minWidth = op.adjustWidthTo + \"px\"\n\t  if (op.maxScrollLeft < cm.doc.scrollLeft)\n\t\t{ setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true) }\n\t  cm.display.maxLineChanged = false\n\t}\n  \n\tvar takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())\n\tif (op.preparedSelection)\n\t  { cm.display.input.showSelection(op.preparedSelection, takeFocus) }\n\tif (op.updatedDisplay || op.startHeight != cm.doc.height)\n\t  { updateScrollbars(cm, op.barMeasure) }\n\tif (op.updatedDisplay)\n\t  { setDocumentHeight(cm, op.barMeasure) }\n  \n\tif (op.selectionChanged) { restartBlink(cm) }\n  \n\tif (cm.state.focused && op.updateInput)\n\t  { cm.display.input.reset(op.typing) }\n\tif (takeFocus) { ensureFocus(op.cm) }\n  }\n  \n  function endOperation_finish(op) {\n\tvar cm = op.cm, display = cm.display, doc = cm.doc\n  \n\tif (op.updatedDisplay) { postUpdateDisplay(cm, op.update) }\n  \n\t// Abort mouse wheel delta measurement, when scrolling explicitly\n\tif (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))\n\t  { display.wheelStartX = display.wheelStartY = null }\n  \n\t// Propagate the scroll position to the actual DOM scroller\n\tif (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {\n\t  doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop))\n\t  display.scrollbars.setScrollTop(doc.scrollTop)\n\t  display.scroller.scrollTop = doc.scrollTop\n\t}\n\tif (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {\n\t  doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft))\n\t  display.scrollbars.setScrollLeft(doc.scrollLeft)\n\t  display.scroller.scrollLeft = doc.scrollLeft\n\t  alignHorizontally(cm)\n\t}\n\t// If we need to scroll a specific position into view, do so.\n\tif (op.scrollToPos) {\n\t  var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),\n\t\t\t\t\t\t\t\t\t clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin)\n\t  if (op.scrollToPos.isCursor && cm.state.focused) { maybeScrollWindow(cm, coords) }\n\t}\n  \n\t// Fire events for markers that are hidden/unidden by editing or\n\t// undoing\n\tvar hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers\n\tif (hidden) { for (var i = 0; i < hidden.length; ++i)\n\t  { if (!hidden[i].lines.length) { signal(hidden[i], \"hide\") } } }\n\tif (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)\n\t  { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], \"unhide\") } } }\n  \n\tif (display.wrapper.offsetHeight)\n\t  { doc.scrollTop = cm.display.scroller.scrollTop }\n  \n\t// Fire change events, and delayed event handlers\n\tif (op.changeObjs)\n\t  { signal(cm, \"changes\", cm, op.changeObjs) }\n\tif (op.update)\n\t  { op.update.finish() }\n  }\n  \n  // Run the given function in an operation\n  function runInOp(cm, f) {\n\tif (cm.curOp) { return f() }\n\tstartOperation(cm)\n\ttry { return f() }\n\tfinally { endOperation(cm) }\n  }\n  // Wraps a function in an operation. Returns the wrapped function.\n  function operation(cm, f) {\n\treturn function() {\n\t  if (cm.curOp) { return f.apply(cm, arguments) }\n\t  startOperation(cm)\n\t  try { return f.apply(cm, arguments) }\n\t  finally { endOperation(cm) }\n\t}\n  }\n  // Used to add methods to editor and doc instances, wrapping them in\n  // operations.\n  function methodOp(f) {\n\treturn function() {\n\t  if (this.curOp) { return f.apply(this, arguments) }\n\t  startOperation(this)\n\t  try { return f.apply(this, arguments) }\n\t  finally { endOperation(this) }\n\t}\n  }\n  function docMethodOp(f) {\n\treturn function() {\n\t  var cm = this.cm\n\t  if (!cm || cm.curOp) { return f.apply(this, arguments) }\n\t  startOperation(cm)\n\t  try { return f.apply(this, arguments) }\n\t  finally { endOperation(cm) }\n\t}\n  }\n  \n  // Updates the display.view data structure for a given change to the\n  // document. From and to are in pre-change coordinates. Lendiff is\n  // the amount of lines added or subtracted by the change. This is\n  // used for changes that span multiple lines, or change the way\n  // lines are divided into visual lines. regLineChange (below)\n  // registers single-line changes.\n  function regChange(cm, from, to, lendiff) {\n\tif (from == null) { from = cm.doc.first }\n\tif (to == null) { to = cm.doc.first + cm.doc.size }\n\tif (!lendiff) { lendiff = 0 }\n  \n\tvar display = cm.display\n\tif (lendiff && to < display.viewTo &&\n\t\t(display.updateLineNumbers == null || display.updateLineNumbers > from))\n\t  { display.updateLineNumbers = from }\n  \n\tcm.curOp.viewChanged = true\n  \n\tif (from >= display.viewTo) { // Change after\n\t  if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)\n\t\t{ resetView(cm) }\n\t} else if (to <= display.viewFrom) { // Change before\n\t  if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {\n\t\tresetView(cm)\n\t  } else {\n\t\tdisplay.viewFrom += lendiff\n\t\tdisplay.viewTo += lendiff\n\t  }\n\t} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap\n\t  resetView(cm)\n\t} else if (from <= display.viewFrom) { // Top overlap\n\t  var cut = viewCuttingPoint(cm, to, to + lendiff, 1)\n\t  if (cut) {\n\t\tdisplay.view = display.view.slice(cut.index)\n\t\tdisplay.viewFrom = cut.lineN\n\t\tdisplay.viewTo += lendiff\n\t  } else {\n\t\tresetView(cm)\n\t  }\n\t} else if (to >= display.viewTo) { // Bottom overlap\n\t  var cut$1 = viewCuttingPoint(cm, from, from, -1)\n\t  if (cut$1) {\n\t\tdisplay.view = display.view.slice(0, cut$1.index)\n\t\tdisplay.viewTo = cut$1.lineN\n\t  } else {\n\t\tresetView(cm)\n\t  }\n\t} else { // Gap in the middle\n\t  var cutTop = viewCuttingPoint(cm, from, from, -1)\n\t  var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1)\n\t  if (cutTop && cutBot) {\n\t\tdisplay.view = display.view.slice(0, cutTop.index)\n\t\t  .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))\n\t\t  .concat(display.view.slice(cutBot.index))\n\t\tdisplay.viewTo += lendiff\n\t  } else {\n\t\tresetView(cm)\n\t  }\n\t}\n  \n\tvar ext = display.externalMeasured\n\tif (ext) {\n\t  if (to < ext.lineN)\n\t\t{ ext.lineN += lendiff }\n\t  else if (from < ext.lineN + ext.size)\n\t\t{ display.externalMeasured = null }\n\t}\n  }\n  \n  // Register a change to a single line. Type must be one of \"text\",\n  // \"gutter\", \"class\", \"widget\"\n  function regLineChange(cm, line, type) {\n\tcm.curOp.viewChanged = true\n\tvar display = cm.display, ext = cm.display.externalMeasured\n\tif (ext && line >= ext.lineN && line < ext.lineN + ext.size)\n\t  { display.externalMeasured = null }\n  \n\tif (line < display.viewFrom || line >= display.viewTo) { return }\n\tvar lineView = display.view[findViewIndex(cm, line)]\n\tif (lineView.node == null) { return }\n\tvar arr = lineView.changes || (lineView.changes = [])\n\tif (indexOf(arr, type) == -1) { arr.push(type) }\n  }\n  \n  // Clear the view.\n  function resetView(cm) {\n\tcm.display.viewFrom = cm.display.viewTo = cm.doc.first\n\tcm.display.view = []\n\tcm.display.viewOffset = 0\n  }\n  \n  function viewCuttingPoint(cm, oldN, newN, dir) {\n\tvar index = findViewIndex(cm, oldN), diff, view = cm.display.view\n\tif (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)\n\t  { return {index: index, lineN: newN} }\n\tvar n = cm.display.viewFrom\n\tfor (var i = 0; i < index; i++)\n\t  { n += view[i].size }\n\tif (n != oldN) {\n\t  if (dir > 0) {\n\t\tif (index == view.length - 1) { return null }\n\t\tdiff = (n + view[index].size) - oldN\n\t\tindex++\n\t  } else {\n\t\tdiff = n - oldN\n\t  }\n\t  oldN += diff; newN += diff\n\t}\n\twhile (visualLineNo(cm.doc, newN) != newN) {\n\t  if (index == (dir < 0 ? 0 : view.length - 1)) { return null }\n\t  newN += dir * view[index - (dir < 0 ? 1 : 0)].size\n\t  index += dir\n\t}\n\treturn {index: index, lineN: newN}\n  }\n  \n  // Force the view to cover a given range, adding empty view element\n  // or clipping off existing ones as needed.\n  function adjustView(cm, from, to) {\n\tvar display = cm.display, view = display.view\n\tif (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {\n\t  display.view = buildViewArray(cm, from, to)\n\t  display.viewFrom = from\n\t} else {\n\t  if (display.viewFrom > from)\n\t\t{ display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view) }\n\t  else if (display.viewFrom < from)\n\t\t{ display.view = display.view.slice(findViewIndex(cm, from)) }\n\t  display.viewFrom = from\n\t  if (display.viewTo < to)\n\t\t{ display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)) }\n\t  else if (display.viewTo > to)\n\t\t{ display.view = display.view.slice(0, findViewIndex(cm, to)) }\n\t}\n\tdisplay.viewTo = to\n  }\n  \n  // Count the number of lines in the view whose DOM representation is\n  // out of date (or nonexistent).\n  function countDirtyView(cm) {\n\tvar view = cm.display.view, dirty = 0\n\tfor (var i = 0; i < view.length; i++) {\n\t  var lineView = view[i]\n\t  if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty }\n\t}\n\treturn dirty\n  }\n  \n  // HIGHLIGHT WORKER\n  \n  function startWorker(cm, time) {\n\tif (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)\n\t  { cm.state.highlight.set(time, bind(highlightWorker, cm)) }\n  }\n  \n  function highlightWorker(cm) {\n\tvar doc = cm.doc\n\tif (doc.frontier < doc.first) { doc.frontier = doc.first }\n\tif (doc.frontier >= cm.display.viewTo) { return }\n\tvar end = +new Date + cm.options.workTime\n\tvar state = copyState(doc.mode, getStateBefore(cm, doc.frontier))\n\tvar changedLines = []\n  \n\tdoc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {\n\t  if (doc.frontier >= cm.display.viewFrom) { // Visible\n\t\tvar oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength\n\t\tvar highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true)\n\t\tline.styles = highlighted.styles\n\t\tvar oldCls = line.styleClasses, newCls = highlighted.classes\n\t\tif (newCls) { line.styleClasses = newCls }\n\t\telse if (oldCls) { line.styleClasses = null }\n\t\tvar ischange = !oldStyles || oldStyles.length != line.styles.length ||\n\t\t  oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass)\n\t\tfor (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i] }\n\t\tif (ischange) { changedLines.push(doc.frontier) }\n\t\tline.stateAfter = tooLong ? state : copyState(doc.mode, state)\n\t  } else {\n\t\tif (line.text.length <= cm.options.maxHighlightLength)\n\t\t  { processLine(cm, line.text, state) }\n\t\tline.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null\n\t  }\n\t  ++doc.frontier\n\t  if (+new Date > end) {\n\t\tstartWorker(cm, cm.options.workDelay)\n\t\treturn true\n\t  }\n\t})\n\tif (changedLines.length) { runInOp(cm, function () {\n\t  for (var i = 0; i < changedLines.length; i++)\n\t\t{ regLineChange(cm, changedLines[i], \"text\") }\n\t}) }\n  }\n  \n  // DISPLAY DRAWING\n  \n  function DisplayUpdate(cm, viewport, force) {\n\tvar display = cm.display\n  \n\tthis.viewport = viewport\n\t// Store some values that we'll need later (but don't want to force a relayout for)\n\tthis.visible = visibleLines(display, cm.doc, viewport)\n\tthis.editorIsHidden = !display.wrapper.offsetWidth\n\tthis.wrapperHeight = display.wrapper.clientHeight\n\tthis.wrapperWidth = display.wrapper.clientWidth\n\tthis.oldDisplayWidth = displayWidth(cm)\n\tthis.force = force\n\tthis.dims = getDimensions(cm)\n\tthis.events = []\n  }\n  \n  DisplayUpdate.prototype.signal = function(emitter, type) {\n\tif (hasHandler(emitter, type))\n\t  { this.events.push(arguments) }\n  }\n  DisplayUpdate.prototype.finish = function() {\n\tvar this$1 = this;\n  \n\tfor (var i = 0; i < this.events.length; i++)\n\t  { signal.apply(null, this$1.events[i]) }\n  }\n  \n  function maybeClipScrollbars(cm) {\n\tvar display = cm.display\n\tif (!display.scrollbarsClipped && display.scroller.offsetWidth) {\n\t  display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth\n\t  display.heightForcer.style.height = scrollGap(cm) + \"px\"\n\t  display.sizer.style.marginBottom = -display.nativeBarWidth + \"px\"\n\t  display.sizer.style.borderRightWidth = scrollGap(cm) + \"px\"\n\t  display.scrollbarsClipped = true\n\t}\n  }\n  \n  // Does the actual updating of the line display. Bails out\n  // (returning false) when there is nothing to be done and forced is\n  // false.\n  function updateDisplayIfNeeded(cm, update) {\n\tvar display = cm.display, doc = cm.doc\n  \n\tif (update.editorIsHidden) {\n\t  resetView(cm)\n\t  return false\n\t}\n  \n\t// Bail out if the visible area is already rendered and nothing changed.\n\tif (!update.force &&\n\t\tupdate.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&\n\t\t(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&\n\t\tdisplay.renderedView == display.view && countDirtyView(cm) == 0)\n\t  { return false }\n  \n\tif (maybeUpdateLineNumberWidth(cm)) {\n\t  resetView(cm)\n\t  update.dims = getDimensions(cm)\n\t}\n  \n\t// Compute a suitable new viewport (from & to)\n\tvar end = doc.first + doc.size\n\tvar from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first)\n\tvar to = Math.min(end, update.visible.to + cm.options.viewportMargin)\n\tif (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom) }\n\tif (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo) }\n\tif (sawCollapsedSpans) {\n\t  from = visualLineNo(cm.doc, from)\n\t  to = visualLineEndNo(cm.doc, to)\n\t}\n  \n\tvar different = from != display.viewFrom || to != display.viewTo ||\n\t  display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth\n\tadjustView(cm, from, to)\n  \n\tdisplay.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom))\n\t// Position the mover div to align with the current scroll position\n\tcm.display.mover.style.top = display.viewOffset + \"px\"\n  \n\tvar toUpdate = countDirtyView(cm)\n\tif (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&\n\t\t(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))\n\t  { return false }\n  \n\t// For big changes, we hide the enclosing element during the\n\t// update, since that speeds up the operations on most browsers.\n\tvar focused = activeElt()\n\tif (toUpdate > 4) { display.lineDiv.style.display = \"none\" }\n\tpatchDisplay(cm, display.updateLineNumbers, update.dims)\n\tif (toUpdate > 4) { display.lineDiv.style.display = \"\" }\n\tdisplay.renderedView = display.view\n\t// There might have been a widget with a focused element that got\n\t// hidden or updated, if so re-focus it.\n\tif (focused && activeElt() != focused && focused.offsetHeight) { focused.focus() }\n  \n\t// Prevent selection and cursors from interfering with the scroll\n\t// width and height.\n\tremoveChildren(display.cursorDiv)\n\tremoveChildren(display.selectionDiv)\n\tdisplay.gutters.style.height = display.sizer.style.minHeight = 0\n  \n\tif (different) {\n\t  display.lastWrapHeight = update.wrapperHeight\n\t  display.lastWrapWidth = update.wrapperWidth\n\t  startWorker(cm, 400)\n\t}\n  \n\tdisplay.updateLineNumbers = null\n  \n\treturn true\n  }\n  \n  function postUpdateDisplay(cm, update) {\n\tvar viewport = update.viewport\n  \n\tfor (var first = true;; first = false) {\n\t  if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {\n\t\t// Clip forced viewport to actual scrollable area.\n\t\tif (viewport && viewport.top != null)\n\t\t  { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)} }\n\t\t// Updated line heights might result in the drawn area not\n\t\t// actually covering the viewport. Keep looping until it does.\n\t\tupdate.visible = visibleLines(cm.display, cm.doc, viewport)\n\t\tif (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)\n\t\t  { break }\n\t  }\n\t  if (!updateDisplayIfNeeded(cm, update)) { break }\n\t  updateHeightsInViewport(cm)\n\t  var barMeasure = measureForScrollbars(cm)\n\t  updateSelection(cm)\n\t  updateScrollbars(cm, barMeasure)\n\t  setDocumentHeight(cm, barMeasure)\n\t}\n  \n\tupdate.signal(cm, \"update\", cm)\n\tif (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {\n\t  update.signal(cm, \"viewportChange\", cm, cm.display.viewFrom, cm.display.viewTo)\n\t  cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo\n\t}\n  }\n  \n  function updateDisplaySimple(cm, viewport) {\n\tvar update = new DisplayUpdate(cm, viewport)\n\tif (updateDisplayIfNeeded(cm, update)) {\n\t  updateHeightsInViewport(cm)\n\t  postUpdateDisplay(cm, update)\n\t  var barMeasure = measureForScrollbars(cm)\n\t  updateSelection(cm)\n\t  updateScrollbars(cm, barMeasure)\n\t  setDocumentHeight(cm, barMeasure)\n\t  update.finish()\n\t}\n  }\n  \n  // Sync the actual display DOM structure with display.view, removing\n  // nodes for lines that are no longer in view, and creating the ones\n  // that are not there yet, and updating the ones that are out of\n  // date.\n  function patchDisplay(cm, updateNumbersFrom, dims) {\n\tvar display = cm.display, lineNumbers = cm.options.lineNumbers\n\tvar container = display.lineDiv, cur = container.firstChild\n  \n\tfunction rm(node) {\n\t  var next = node.nextSibling\n\t  // Works around a throw-scroll bug in OS X Webkit\n\t  if (webkit && mac && cm.display.currentWheelTarget == node)\n\t\t{ node.style.display = \"none\" }\n\t  else\n\t\t{ node.parentNode.removeChild(node) }\n\t  return next\n\t}\n  \n\tvar view = display.view, lineN = display.viewFrom\n\t// Loop over the elements in the view, syncing cur (the DOM nodes\n\t// in display.lineDiv) with the view as we go.\n\tfor (var i = 0; i < view.length; i++) {\n\t  var lineView = view[i]\n\t  if (lineView.hidden) {\n\t  } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet\n\t\tvar node = buildLineElement(cm, lineView, lineN, dims)\n\t\tcontainer.insertBefore(node, cur)\n\t  } else { // Already drawn\n\t\twhile (cur != lineView.node) { cur = rm(cur) }\n\t\tvar updateNumber = lineNumbers && updateNumbersFrom != null &&\n\t\t  updateNumbersFrom <= lineN && lineView.lineNumber\n\t\tif (lineView.changes) {\n\t\t  if (indexOf(lineView.changes, \"gutter\") > -1) { updateNumber = false }\n\t\t  updateLineForChanges(cm, lineView, lineN, dims)\n\t\t}\n\t\tif (updateNumber) {\n\t\t  removeChildren(lineView.lineNumber)\n\t\t  lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))\n\t\t}\n\t\tcur = lineView.node.nextSibling\n\t  }\n\t  lineN += lineView.size\n\t}\n\twhile (cur) { cur = rm(cur) }\n  }\n  \n  function updateGutterSpace(cm) {\n\tvar width = cm.display.gutters.offsetWidth\n\tcm.display.sizer.style.marginLeft = width + \"px\"\n  }\n  \n  function setDocumentHeight(cm, measure) {\n\tcm.display.sizer.style.minHeight = measure.docHeight + \"px\"\n\tcm.display.heightForcer.style.top = measure.docHeight + \"px\"\n\tcm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + \"px\"\n  }\n  \n  // Rebuild the gutter elements, ensure the margin to the left of the\n  // code matches their width.\n  function updateGutters(cm) {\n\tvar gutters = cm.display.gutters, specs = cm.options.gutters\n\tremoveChildren(gutters)\n\tvar i = 0\n\tfor (; i < specs.length; ++i) {\n\t  var gutterClass = specs[i]\n\t  var gElt = gutters.appendChild(elt(\"div\", null, \"CodeMirror-gutter \" + gutterClass))\n\t  if (gutterClass == \"CodeMirror-linenumbers\") {\n\t\tcm.display.lineGutter = gElt\n\t\tgElt.style.width = (cm.display.lineNumWidth || 1) + \"px\"\n\t  }\n\t}\n\tgutters.style.display = i ? \"\" : \"none\"\n\tupdateGutterSpace(cm)\n  }\n  \n  // Make sure the gutters options contains the element\n  // \"CodeMirror-linenumbers\" when the lineNumbers option is true.\n  function setGuttersForLineNumbers(options) {\n\tvar found = indexOf(options.gutters, \"CodeMirror-linenumbers\")\n\tif (found == -1 && options.lineNumbers) {\n\t  options.gutters = options.gutters.concat([\"CodeMirror-linenumbers\"])\n\t} else if (found > -1 && !options.lineNumbers) {\n\t  options.gutters = options.gutters.slice(0)\n\t  options.gutters.splice(found, 1)\n\t}\n  }\n  \n  // Selection objects are immutable. A new one is created every time\n  // the selection changes. A selection is one or more non-overlapping\n  // (and non-touching) ranges, sorted, and an integer that indicates\n  // which one is the primary selection (the one that's scrolled into\n  // view, that getCursor returns, etc).\n  function Selection(ranges, primIndex) {\n\tthis.ranges = ranges\n\tthis.primIndex = primIndex\n  }\n  \n  Selection.prototype = {\n\tprimary: function() { return this.ranges[this.primIndex] },\n\tequals: function(other) {\n\t  var this$1 = this;\n  \n\t  if (other == this) { return true }\n\t  if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }\n\t  for (var i = 0; i < this.ranges.length; i++) {\n\t\tvar here = this$1.ranges[i], there = other.ranges[i]\n\t\tif (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) { return false }\n\t  }\n\t  return true\n\t},\n\tdeepCopy: function() {\n\t  var this$1 = this;\n  \n\t  var out = []\n\t  for (var i = 0; i < this.ranges.length; i++)\n\t\t{ out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }\n\t  return new Selection(out, this.primIndex)\n\t},\n\tsomethingSelected: function() {\n\t  var this$1 = this;\n  \n\t  for (var i = 0; i < this.ranges.length; i++)\n\t\t{ if (!this$1.ranges[i].empty()) { return true } }\n\t  return false\n\t},\n\tcontains: function(pos, end) {\n\t  var this$1 = this;\n  \n\t  if (!end) { end = pos }\n\t  for (var i = 0; i < this.ranges.length; i++) {\n\t\tvar range = this$1.ranges[i]\n\t\tif (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)\n\t\t  { return i }\n\t  }\n\t  return -1\n\t}\n  }\n  \n  function Range(anchor, head) {\n\tthis.anchor = anchor; this.head = head\n  }\n  \n  Range.prototype = {\n\tfrom: function() { return minPos(this.anchor, this.head) },\n\tto: function() { return maxPos(this.anchor, this.head) },\n\tempty: function() {\n\t  return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch\n\t}\n  }\n  \n  // Take an unsorted, potentially overlapping set of ranges, and\n  // build a selection out of it. 'Consumes' ranges array (modifying\n  // it).\n  function normalizeSelection(ranges, primIndex) {\n\tvar prim = ranges[primIndex]\n\tranges.sort(function (a, b) { return cmp(a.from(), b.from()); })\n\tprimIndex = indexOf(ranges, prim)\n\tfor (var i = 1; i < ranges.length; i++) {\n\t  var cur = ranges[i], prev = ranges[i - 1]\n\t  if (cmp(prev.to(), cur.from()) >= 0) {\n\t\tvar from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to())\n\t\tvar inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head\n\t\tif (i <= primIndex) { --primIndex }\n\t\tranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to))\n\t  }\n\t}\n\treturn new Selection(ranges, primIndex)\n  }\n  \n  function simpleSelection(anchor, head) {\n\treturn new Selection([new Range(anchor, head || anchor)], 0)\n  }\n  \n  // Compute the position of the end of a change (its 'to' property\n  // refers to the pre-change end).\n  function changeEnd(change) {\n\tif (!change.text) { return change.to }\n\treturn Pos(change.from.line + change.text.length - 1,\n\t\t\t   lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))\n  }\n  \n  // Adjust a position to refer to the post-change position of the\n  // same text, or the end of the change if the change covers it.\n  function adjustForChange(pos, change) {\n\tif (cmp(pos, change.from) < 0) { return pos }\n\tif (cmp(pos, change.to) <= 0) { return changeEnd(change) }\n  \n\tvar line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch\n\tif (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch }\n\treturn Pos(line, ch)\n  }\n  \n  function computeSelAfterChange(doc, change) {\n\tvar out = []\n\tfor (var i = 0; i < doc.sel.ranges.length; i++) {\n\t  var range = doc.sel.ranges[i]\n\t  out.push(new Range(adjustForChange(range.anchor, change),\n\t\t\t\t\t\t adjustForChange(range.head, change)))\n\t}\n\treturn normalizeSelection(out, doc.sel.primIndex)\n  }\n  \n  function offsetPos(pos, old, nw) {\n\tif (pos.line == old.line)\n\t  { return Pos(nw.line, pos.ch - old.ch + nw.ch) }\n\telse\n\t  { return Pos(nw.line + (pos.line - old.line), pos.ch) }\n  }\n  \n  // Used by replaceSelections to allow moving the selection to the\n  // start or around the replaced test. Hint may be \"start\" or \"around\".\n  function computeReplacedSel(doc, changes, hint) {\n\tvar out = []\n\tvar oldPrev = Pos(doc.first, 0), newPrev = oldPrev\n\tfor (var i = 0; i < changes.length; i++) {\n\t  var change = changes[i]\n\t  var from = offsetPos(change.from, oldPrev, newPrev)\n\t  var to = offsetPos(changeEnd(change), oldPrev, newPrev)\n\t  oldPrev = change.to\n\t  newPrev = to\n\t  if (hint == \"around\") {\n\t\tvar range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0\n\t\tout[i] = new Range(inv ? to : from, inv ? from : to)\n\t  } else {\n\t\tout[i] = new Range(from, from)\n\t  }\n\t}\n\treturn new Selection(out, doc.sel.primIndex)\n  }\n  \n  // Used to get the editor into a consistent state again when options change.\n  \n  function loadMode(cm) {\n\tcm.doc.mode = getMode(cm.options, cm.doc.modeOption)\n\tresetModeState(cm)\n  }\n  \n  function resetModeState(cm) {\n\tcm.doc.iter(function (line) {\n\t  if (line.stateAfter) { line.stateAfter = null }\n\t  if (line.styles) { line.styles = null }\n\t})\n\tcm.doc.frontier = cm.doc.first\n\tstartWorker(cm, 100)\n\tcm.state.modeGen++\n\tif (cm.curOp) { regChange(cm) }\n  }\n  \n  // DOCUMENT DATA STRUCTURE\n  \n  // By default, updates that start and end at the beginning of a line\n  // are treated specially, in order to make the association of line\n  // widgets and marker elements with the text behave more intuitive.\n  function isWholeLineUpdate(doc, change) {\n\treturn change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == \"\" &&\n\t  (!doc.cm || doc.cm.options.wholeLineUpdateBefore)\n  }\n  \n  // Perform a change on the document data structure.\n  function updateDoc(doc, change, markedSpans, estimateHeight) {\n\tfunction spansFor(n) {return markedSpans ? markedSpans[n] : null}\n\tfunction update(line, text, spans) {\n\t  updateLine(line, text, spans, estimateHeight)\n\t  signalLater(line, \"change\", line, change)\n\t}\n\tfunction linesFor(start, end) {\n\t  var result = []\n\t  for (var i = start; i < end; ++i)\n\t\t{ result.push(new Line(text[i], spansFor(i), estimateHeight)) }\n\t  return result\n\t}\n  \n\tvar from = change.from, to = change.to, text = change.text\n\tvar firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line)\n\tvar lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line\n  \n\t// Adjust the line structure\n\tif (change.full) {\n\t  doc.insert(0, linesFor(0, text.length))\n\t  doc.remove(text.length, doc.size - text.length)\n\t} else if (isWholeLineUpdate(doc, change)) {\n\t  // This is a whole-line replace. Treated specially to make\n\t  // sure line objects move the way they are supposed to.\n\t  var added = linesFor(0, text.length - 1)\n\t  update(lastLine, lastLine.text, lastSpans)\n\t  if (nlines) { doc.remove(from.line, nlines) }\n\t  if (added.length) { doc.insert(from.line, added) }\n\t} else if (firstLine == lastLine) {\n\t  if (text.length == 1) {\n\t\tupdate(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans)\n\t  } else {\n\t\tvar added$1 = linesFor(1, text.length - 1)\n\t\tadded$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight))\n\t\tupdate(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))\n\t\tdoc.insert(from.line + 1, added$1)\n\t  }\n\t} else if (text.length == 1) {\n\t  update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0))\n\t  doc.remove(from.line + 1, nlines)\n\t} else {\n\t  update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))\n\t  update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans)\n\t  var added$2 = linesFor(1, text.length - 1)\n\t  if (nlines > 1) { doc.remove(from.line + 1, nlines - 1) }\n\t  doc.insert(from.line + 1, added$2)\n\t}\n  \n\tsignalLater(doc, \"change\", doc, change)\n  }\n  \n  // Call f for all linked documents.\n  function linkedDocs(doc, f, sharedHistOnly) {\n\tfunction propagate(doc, skip, sharedHist) {\n\t  if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {\n\t\tvar rel = doc.linked[i]\n\t\tif (rel.doc == skip) { continue }\n\t\tvar shared = sharedHist && rel.sharedHist\n\t\tif (sharedHistOnly && !shared) { continue }\n\t\tf(rel.doc, shared)\n\t\tpropagate(rel.doc, doc, shared)\n\t  } }\n\t}\n\tpropagate(doc, null, true)\n  }\n  \n  // Attach a document to an editor.\n  function attachDoc(cm, doc) {\n\tif (doc.cm) { throw new Error(\"This document is already in use.\") }\n\tcm.doc = doc\n\tdoc.cm = cm\n\testimateLineHeights(cm)\n\tloadMode(cm)\n\tif (!cm.options.lineWrapping) { findMaxLine(cm) }\n\tcm.options.mode = doc.modeOption\n\tregChange(cm)\n  }\n  \n  function History(startGen) {\n\t// Arrays of change events and selections. Doing something adds an\n\t// event to done and clears undo. Undoing moves events from done\n\t// to undone, redoing moves them in the other direction.\n\tthis.done = []; this.undone = []\n\tthis.undoDepth = Infinity\n\t// Used to track when changes can be merged into a single undo\n\t// event\n\tthis.lastModTime = this.lastSelTime = 0\n\tthis.lastOp = this.lastSelOp = null\n\tthis.lastOrigin = this.lastSelOrigin = null\n\t// Used by the isClean() method\n\tthis.generation = this.maxGeneration = startGen || 1\n  }\n  \n  // Create a history change event from an updateDoc-style change\n  // object.\n  function historyChangeFromChange(doc, change) {\n\tvar histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}\n\tattachLocalSpans(doc, histChange, change.from.line, change.to.line + 1)\n\tlinkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true)\n\treturn histChange\n  }\n  \n  // Pop all selection events off the end of a history array. Stop at\n  // a change event.\n  function clearSelectionEvents(array) {\n\twhile (array.length) {\n\t  var last = lst(array)\n\t  if (last.ranges) { array.pop() }\n\t  else { break }\n\t}\n  }\n  \n  // Find the top change event in the history. Pop off selection\n  // events that are in the way.\n  function lastChangeEvent(hist, force) {\n\tif (force) {\n\t  clearSelectionEvents(hist.done)\n\t  return lst(hist.done)\n\t} else if (hist.done.length && !lst(hist.done).ranges) {\n\t  return lst(hist.done)\n\t} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {\n\t  hist.done.pop()\n\t  return lst(hist.done)\n\t}\n  }\n  \n  // Register a change in the history. Merges changes that are within\n  // a single operation, or are close together with an origin that\n  // allows merging (starting with \"+\") into a single event.\n  function addChangeToHistory(doc, change, selAfter, opId) {\n\tvar hist = doc.history\n\thist.undone.length = 0\n\tvar time = +new Date, cur\n\tvar last\n  \n\tif ((hist.lastOp == opId ||\n\t\t hist.lastOrigin == change.origin && change.origin &&\n\t\t ((change.origin.charAt(0) == \"+\" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||\n\t\t  change.origin.charAt(0) == \"*\")) &&\n\t\t(cur = lastChangeEvent(hist, hist.lastOp == opId))) {\n\t  // Merge this change into the last event\n\t  last = lst(cur.changes)\n\t  if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {\n\t\t// Optimized case for simple insertion -- don't want to add\n\t\t// new changesets for every character typed\n\t\tlast.to = changeEnd(change)\n\t  } else {\n\t\t// Add new sub-event\n\t\tcur.changes.push(historyChangeFromChange(doc, change))\n\t  }\n\t} else {\n\t  // Can not be merged, start a new event.\n\t  var before = lst(hist.done)\n\t  if (!before || !before.ranges)\n\t\t{ pushSelectionToHistory(doc.sel, hist.done) }\n\t  cur = {changes: [historyChangeFromChange(doc, change)],\n\t\t\t generation: hist.generation}\n\t  hist.done.push(cur)\n\t  while (hist.done.length > hist.undoDepth) {\n\t\thist.done.shift()\n\t\tif (!hist.done[0].ranges) { hist.done.shift() }\n\t  }\n\t}\n\thist.done.push(selAfter)\n\thist.generation = ++hist.maxGeneration\n\thist.lastModTime = hist.lastSelTime = time\n\thist.lastOp = hist.lastSelOp = opId\n\thist.lastOrigin = hist.lastSelOrigin = change.origin\n  \n\tif (!last) { signal(doc, \"historyAdded\") }\n  }\n  \n  function selectionEventCanBeMerged(doc, origin, prev, sel) {\n\tvar ch = origin.charAt(0)\n\treturn ch == \"*\" ||\n\t  ch == \"+\" &&\n\t  prev.ranges.length == sel.ranges.length &&\n\t  prev.somethingSelected() == sel.somethingSelected() &&\n\t  new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)\n  }\n  \n  // Called whenever the selection changes, sets the new selection as\n  // the pending selection in the history, and pushes the old pending\n  // selection into the 'done' array when it was significantly\n  // different (in number of selected ranges, emptiness, or time).\n  function addSelectionToHistory(doc, sel, opId, options) {\n\tvar hist = doc.history, origin = options && options.origin\n  \n\t// A new event is started when the previous origin does not match\n\t// the current, or the origins don't allow matching. Origins\n\t// starting with * are always merged, those starting with + are\n\t// merged when similar and close together in time.\n\tif (opId == hist.lastSelOp ||\n\t\t(origin && hist.lastSelOrigin == origin &&\n\t\t (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||\n\t\t  selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))\n\t  { hist.done[hist.done.length - 1] = sel }\n\telse\n\t  { pushSelectionToHistory(sel, hist.done) }\n  \n\thist.lastSelTime = +new Date\n\thist.lastSelOrigin = origin\n\thist.lastSelOp = opId\n\tif (options && options.clearRedo !== false)\n\t  { clearSelectionEvents(hist.undone) }\n  }\n  \n  function pushSelectionToHistory(sel, dest) {\n\tvar top = lst(dest)\n\tif (!(top && top.ranges && top.equals(sel)))\n\t  { dest.push(sel) }\n  }\n  \n  // Used to store marked span information in the history.\n  function attachLocalSpans(doc, change, from, to) {\n\tvar existing = change[\"spans_\" + doc.id], n = 0\n\tdoc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {\n\t  if (line.markedSpans)\n\t\t{ (existing || (existing = change[\"spans_\" + doc.id] = {}))[n] = line.markedSpans }\n\t  ++n\n\t})\n  }\n  \n  // When un/re-doing restores text containing marked spans, those\n  // that have been explicitly cleared should not be restored.\n  function removeClearedSpans(spans) {\n\tif (!spans) { return null }\n\tvar out\n\tfor (var i = 0; i < spans.length; ++i) {\n\t  if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i) } }\n\t  else if (out) { out.push(spans[i]) }\n\t}\n\treturn !out ? spans : out.length ? out : null\n  }\n  \n  // Retrieve and filter the old marked spans stored in a change event.\n  function getOldSpans(doc, change) {\n\tvar found = change[\"spans_\" + doc.id]\n\tif (!found) { return null }\n\tvar nw = []\n\tfor (var i = 0; i < change.text.length; ++i)\n\t  { nw.push(removeClearedSpans(found[i])) }\n\treturn nw\n  }\n  \n  // Used for un/re-doing changes from the history. Combines the\n  // result of computing the existing spans with the set of spans that\n  // existed in the history (so that deleting around a span and then\n  // undoing brings back the span).\n  function mergeOldSpans(doc, change) {\n\tvar old = getOldSpans(doc, change)\n\tvar stretched = stretchSpansOverChange(doc, change)\n\tif (!old) { return stretched }\n\tif (!stretched) { return old }\n  \n\tfor (var i = 0; i < old.length; ++i) {\n\t  var oldCur = old[i], stretchCur = stretched[i]\n\t  if (oldCur && stretchCur) {\n\t\tspans: for (var j = 0; j < stretchCur.length; ++j) {\n\t\t  var span = stretchCur[j]\n\t\t  for (var k = 0; k < oldCur.length; ++k)\n\t\t\t{ if (oldCur[k].marker == span.marker) { continue spans } }\n\t\t  oldCur.push(span)\n\t\t}\n\t  } else if (stretchCur) {\n\t\told[i] = stretchCur\n\t  }\n\t}\n\treturn old\n  }\n  \n  // Used both to provide a JSON-safe object in .getHistory, and, when\n  // detaching a document, to split the history in two\n  function copyHistoryArray(events, newGroup, instantiateSel) {\n\tvar copy = []\n\tfor (var i = 0; i < events.length; ++i) {\n\t  var event = events[i]\n\t  if (event.ranges) {\n\t\tcopy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event)\n\t\tcontinue\n\t  }\n\t  var changes = event.changes, newChanges = []\n\t  copy.push({changes: newChanges})\n\t  for (var j = 0; j < changes.length; ++j) {\n\t\tvar change = changes[j], m = void 0\n\t\tnewChanges.push({from: change.from, to: change.to, text: change.text})\n\t\tif (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\\d+)$/)) {\n\t\t  if (indexOf(newGroup, Number(m[1])) > -1) {\n\t\t\tlst(newChanges)[prop] = change[prop]\n\t\t\tdelete change[prop]\n\t\t  }\n\t\t} } }\n\t  }\n\t}\n\treturn copy\n  }\n  \n  // The 'scroll' parameter given to many of these indicated whether\n  // the new cursor position should be scrolled into view after\n  // modifying the selection.\n  \n  // If shift is held or the extend flag is set, extends a range to\n  // include a given position (and optionally a second position).\n  // Otherwise, simply returns the range between the given positions.\n  // Used for cursor motion and such.\n  function extendRange(doc, range, head, other) {\n\tif (doc.cm && doc.cm.display.shift || doc.extend) {\n\t  var anchor = range.anchor\n\t  if (other) {\n\t\tvar posBefore = cmp(head, anchor) < 0\n\t\tif (posBefore != (cmp(other, anchor) < 0)) {\n\t\t  anchor = head\n\t\t  head = other\n\t\t} else if (posBefore != (cmp(head, other) < 0)) {\n\t\t  head = other\n\t\t}\n\t  }\n\t  return new Range(anchor, head)\n\t} else {\n\t  return new Range(other || head, head)\n\t}\n  }\n  \n  // Extend the primary selection range, discard the rest.\n  function extendSelection(doc, head, other, options) {\n\tsetSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options)\n  }\n  \n  // Extend all selections (pos is an array of selections with length\n  // equal the number of selections)\n  function extendSelections(doc, heads, options) {\n\tvar out = []\n\tfor (var i = 0; i < doc.sel.ranges.length; i++)\n\t  { out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null) }\n\tvar newSel = normalizeSelection(out, doc.sel.primIndex)\n\tsetSelection(doc, newSel, options)\n  }\n  \n  // Updates a single range in the selection.\n  function replaceOneSelection(doc, i, range, options) {\n\tvar ranges = doc.sel.ranges.slice(0)\n\tranges[i] = range\n\tsetSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options)\n  }\n  \n  // Reset the selection to a single range.\n  function setSimpleSelection(doc, anchor, head, options) {\n\tsetSelection(doc, simpleSelection(anchor, head), options)\n  }\n  \n  // Give beforeSelectionChange handlers a change to influence a\n  // selection update.\n  function filterSelectionChange(doc, sel, options) {\n\tvar obj = {\n\t  ranges: sel.ranges,\n\t  update: function(ranges) {\n\t\tvar this$1 = this;\n  \n\t\tthis.ranges = []\n\t\tfor (var i = 0; i < ranges.length; i++)\n\t\t  { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),\n\t\t\t\t\t\t\t\t\t clipPos(doc, ranges[i].head)) }\n\t  },\n\t  origin: options && options.origin\n\t}\n\tsignal(doc, \"beforeSelectionChange\", doc, obj)\n\tif (doc.cm) { signal(doc.cm, \"beforeSelectionChange\", doc.cm, obj) }\n\tif (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }\n\telse { return sel }\n  }\n  \n  function setSelectionReplaceHistory(doc, sel, options) {\n\tvar done = doc.history.done, last = lst(done)\n\tif (last && last.ranges) {\n\t  done[done.length - 1] = sel\n\t  setSelectionNoUndo(doc, sel, options)\n\t} else {\n\t  setSelection(doc, sel, options)\n\t}\n  }\n  \n  // Set a new selection.\n  function setSelection(doc, sel, options) {\n\tsetSelectionNoUndo(doc, sel, options)\n\taddSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options)\n  }\n  \n  function setSelectionNoUndo(doc, sel, options) {\n\tif (hasHandler(doc, \"beforeSelectionChange\") || doc.cm && hasHandler(doc.cm, \"beforeSelectionChange\"))\n\t  { sel = filterSelectionChange(doc, sel, options) }\n  \n\tvar bias = options && options.bias ||\n\t  (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1)\n\tsetSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true))\n  \n\tif (!(options && options.scroll === false) && doc.cm)\n\t  { ensureCursorVisible(doc.cm) }\n  }\n  \n  function setSelectionInner(doc, sel) {\n\tif (sel.equals(doc.sel)) { return }\n  \n\tdoc.sel = sel\n  \n\tif (doc.cm) {\n\t  doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true\n\t  signalCursorActivity(doc.cm)\n\t}\n\tsignalLater(doc, \"cursorActivity\", doc)\n  }\n  \n  // Verify that the selection does not partially select any atomic\n  // marked ranges.\n  function reCheckSelection(doc) {\n\tsetSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll)\n  }\n  \n  // Return a selection that does not partially select any atomic\n  // ranges.\n  function skipAtomicInSelection(doc, sel, bias, mayClear) {\n\tvar out\n\tfor (var i = 0; i < sel.ranges.length; i++) {\n\t  var range = sel.ranges[i]\n\t  var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]\n\t  var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear)\n\t  var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear)\n\t  if (out || newAnchor != range.anchor || newHead != range.head) {\n\t\tif (!out) { out = sel.ranges.slice(0, i) }\n\t\tout[i] = new Range(newAnchor, newHead)\n\t  }\n\t}\n\treturn out ? normalizeSelection(out, sel.primIndex) : sel\n  }\n  \n  function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {\n\tvar line = getLine(doc, pos.line)\n\tif (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {\n\t  var sp = line.markedSpans[i], m = sp.marker\n\t  if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&\n\t\t  (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {\n\t\tif (mayClear) {\n\t\t  signal(m, \"beforeCursorEnter\")\n\t\t  if (m.explicitlyCleared) {\n\t\t\tif (!line.markedSpans) { break }\n\t\t\telse {--i; continue}\n\t\t  }\n\t\t}\n\t\tif (!m.atomic) { continue }\n  \n\t\tif (oldPos) {\n\t\t  var near = m.find(dir < 0 ? 1 : -1), diff = void 0\n\t\t  if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)\n\t\t\t{ near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }\n\t\t  if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))\n\t\t\t{ return skipAtomicInner(doc, near, pos, dir, mayClear) }\n\t\t}\n  \n\t\tvar far = m.find(dir < 0 ? -1 : 1)\n\t\tif (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)\n\t\t  { far = movePos(doc, far, dir, far.line == pos.line ? line : null) }\n\t\treturn far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null\n\t  }\n\t} }\n\treturn pos\n  }\n  \n  // Ensure a given position is not inside an atomic range.\n  function skipAtomic(doc, pos, oldPos, bias, mayClear) {\n\tvar dir = bias || 1\n\tvar found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||\n\t\t(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||\n\t\tskipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||\n\t\t(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true))\n\tif (!found) {\n\t  doc.cantEdit = true\n\t  return Pos(doc.first, 0)\n\t}\n\treturn found\n  }\n  \n  function movePos(doc, pos, dir, line) {\n\tif (dir < 0 && pos.ch == 0) {\n\t  if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }\n\t  else { return null }\n\t} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {\n\t  if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }\n\t  else { return null }\n\t} else {\n\t  return new Pos(pos.line, pos.ch + dir)\n\t}\n  }\n  \n  function selectAll(cm) {\n\tcm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll)\n  }\n  \n  // UPDATING\n  \n  // Allow \"beforeChange\" event handlers to influence a change\n  function filterChange(doc, change, update) {\n\tvar obj = {\n\t  canceled: false,\n\t  from: change.from,\n\t  to: change.to,\n\t  text: change.text,\n\t  origin: change.origin,\n\t  cancel: function () { return obj.canceled = true; }\n\t}\n\tif (update) { obj.update = function (from, to, text, origin) {\n\t  if (from) { obj.from = clipPos(doc, from) }\n\t  if (to) { obj.to = clipPos(doc, to) }\n\t  if (text) { obj.text = text }\n\t  if (origin !== undefined) { obj.origin = origin }\n\t} }\n\tsignal(doc, \"beforeChange\", doc, obj)\n\tif (doc.cm) { signal(doc.cm, \"beforeChange\", doc.cm, obj) }\n  \n\tif (obj.canceled) { return null }\n\treturn {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}\n  }\n  \n  // Apply a change to a document, and add it to the document's\n  // history, and propagating it to all linked documents.\n  function makeChange(doc, change, ignoreReadOnly) {\n\tif (doc.cm) {\n\t  if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }\n\t  if (doc.cm.state.suppressEdits) { return }\n\t}\n  \n\tif (hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\")) {\n\t  change = filterChange(doc, change, true)\n\t  if (!change) { return }\n\t}\n  \n\t// Possibly split or suppress the update based on the presence\n\t// of read-only spans in its range.\n\tvar split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)\n\tif (split) {\n\t  for (var i = split.length - 1; i >= 0; --i)\n\t\t{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [\"\"] : change.text}) }\n\t} else {\n\t  makeChangeInner(doc, change)\n\t}\n  }\n  \n  function makeChangeInner(doc, change) {\n\tif (change.text.length == 1 && change.text[0] == \"\" && cmp(change.from, change.to) == 0) { return }\n\tvar selAfter = computeSelAfterChange(doc, change)\n\taddChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN)\n  \n\tmakeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change))\n\tvar rebased = []\n  \n\tlinkedDocs(doc, function (doc, sharedHist) {\n\t  if (!sharedHist && indexOf(rebased, doc.history) == -1) {\n\t\trebaseHist(doc.history, change)\n\t\trebased.push(doc.history)\n\t  }\n\t  makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change))\n\t})\n  }\n  \n  // Revert a change stored in a document's history.\n  function makeChangeFromHistory(doc, type, allowSelectionOnly) {\n\tif (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) { return }\n  \n\tvar hist = doc.history, event, selAfter = doc.sel\n\tvar source = type == \"undo\" ? hist.done : hist.undone, dest = type == \"undo\" ? hist.undone : hist.done\n  \n\t// Verify that there is a useable event (so that ctrl-z won't\n\t// needlessly clear selection events)\n\tvar i = 0\n\tfor (; i < source.length; i++) {\n\t  event = source[i]\n\t  if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)\n\t\t{ break }\n\t}\n\tif (i == source.length) { return }\n\thist.lastOrigin = hist.lastSelOrigin = null\n  \n\tfor (;;) {\n\t  event = source.pop()\n\t  if (event.ranges) {\n\t\tpushSelectionToHistory(event, dest)\n\t\tif (allowSelectionOnly && !event.equals(doc.sel)) {\n\t\t  setSelection(doc, event, {clearRedo: false})\n\t\t  return\n\t\t}\n\t\tselAfter = event\n\t  }\n\t  else { break }\n\t}\n  \n\t// Build up a reverse change object to add to the opposite history\n\t// stack (redo when undoing, and vice versa).\n\tvar antiChanges = []\n\tpushSelectionToHistory(selAfter, dest)\n\tdest.push({changes: antiChanges, generation: hist.generation})\n\thist.generation = event.generation || ++hist.maxGeneration\n  \n\tvar filter = hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\")\n  \n\tvar loop = function ( i ) {\n\t  var change = event.changes[i]\n\t  change.origin = type\n\t  if (filter && !filterChange(doc, change, false)) {\n\t\tsource.length = 0\n\t\treturn {}\n\t  }\n  \n\t  antiChanges.push(historyChangeFromChange(doc, change))\n  \n\t  var after = i ? computeSelAfterChange(doc, change) : lst(source)\n\t  makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change))\n\t  if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}) }\n\t  var rebased = []\n  \n\t  // Propagate to the linked documents\n\t  linkedDocs(doc, function (doc, sharedHist) {\n\t\tif (!sharedHist && indexOf(rebased, doc.history) == -1) {\n\t\t  rebaseHist(doc.history, change)\n\t\t  rebased.push(doc.history)\n\t\t}\n\t\tmakeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change))\n\t  })\n\t};\n  \n\tfor (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {\n\t  var returned = loop( i$1 );\n  \n\t  if ( returned ) return returned.v;\n\t}\n  }\n  \n  // Sub-views need their line numbers shifted when text is added\n  // above or below them in the parent document.\n  function shiftDoc(doc, distance) {\n\tif (distance == 0) { return }\n\tdoc.first += distance\n\tdoc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(\n\t  Pos(range.anchor.line + distance, range.anchor.ch),\n\t  Pos(range.head.line + distance, range.head.ch)\n\t); }), doc.sel.primIndex)\n\tif (doc.cm) {\n\t  regChange(doc.cm, doc.first, doc.first - distance, distance)\n\t  for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)\n\t\t{ regLineChange(doc.cm, l, \"gutter\") }\n\t}\n  }\n  \n  // More lower-level change function, handling only a single document\n  // (not linked ones).\n  function makeChangeSingleDoc(doc, change, selAfter, spans) {\n\tif (doc.cm && !doc.cm.curOp)\n\t  { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }\n  \n\tif (change.to.line < doc.first) {\n\t  shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line))\n\t  return\n\t}\n\tif (change.from.line > doc.lastLine()) { return }\n  \n\t// Clip the change to the size of this doc\n\tif (change.from.line < doc.first) {\n\t  var shift = change.text.length - 1 - (doc.first - change.from.line)\n\t  shiftDoc(doc, shift)\n\t  change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),\n\t\t\t\ttext: [lst(change.text)], origin: change.origin}\n\t}\n\tvar last = doc.lastLine()\n\tif (change.to.line > last) {\n\t  change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),\n\t\t\t\ttext: [change.text[0]], origin: change.origin}\n\t}\n  \n\tchange.removed = getBetween(doc, change.from, change.to)\n  \n\tif (!selAfter) { selAfter = computeSelAfterChange(doc, change) }\n\tif (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans) }\n\telse { updateDoc(doc, change, spans) }\n\tsetSelectionNoUndo(doc, selAfter, sel_dontScroll)\n  }\n  \n  // Handle the interaction of a change to a document with the editor\n  // that this document is part of.\n  function makeChangeSingleDocInEditor(cm, change, spans) {\n\tvar doc = cm.doc, display = cm.display, from = change.from, to = change.to\n  \n\tvar recomputeMaxLength = false, checkWidthStart = from.line\n\tif (!cm.options.lineWrapping) {\n\t  checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))\n\t  doc.iter(checkWidthStart, to.line + 1, function (line) {\n\t\tif (line == display.maxLine) {\n\t\t  recomputeMaxLength = true\n\t\t  return true\n\t\t}\n\t  })\n\t}\n  \n\tif (doc.sel.contains(change.from, change.to) > -1)\n\t  { signalCursorActivity(cm) }\n  \n\tupdateDoc(doc, change, spans, estimateHeight(cm))\n  \n\tif (!cm.options.lineWrapping) {\n\t  doc.iter(checkWidthStart, from.line + change.text.length, function (line) {\n\t\tvar len = lineLength(line)\n\t\tif (len > display.maxLineLength) {\n\t\t  display.maxLine = line\n\t\t  display.maxLineLength = len\n\t\t  display.maxLineChanged = true\n\t\t  recomputeMaxLength = false\n\t\t}\n\t  })\n\t  if (recomputeMaxLength) { cm.curOp.updateMaxLine = true }\n\t}\n  \n\t// Adjust frontier, schedule worker\n\tdoc.frontier = Math.min(doc.frontier, from.line)\n\tstartWorker(cm, 400)\n  \n\tvar lendiff = change.text.length - (to.line - from.line) - 1\n\t// Remember that these lines changed, for updating the display\n\tif (change.full)\n\t  { regChange(cm) }\n\telse if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))\n\t  { regLineChange(cm, from.line, \"text\") }\n\telse\n\t  { regChange(cm, from.line, to.line + 1, lendiff) }\n  \n\tvar changesHandler = hasHandler(cm, \"changes\"), changeHandler = hasHandler(cm, \"change\")\n\tif (changeHandler || changesHandler) {\n\t  var obj = {\n\t\tfrom: from, to: to,\n\t\ttext: change.text,\n\t\tremoved: change.removed,\n\t\torigin: change.origin\n\t  }\n\t  if (changeHandler) { signalLater(cm, \"change\", cm, obj) }\n\t  if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj) }\n\t}\n\tcm.display.selForContextMenu = null\n  }\n  \n  function replaceRange(doc, code, from, to, origin) {\n\tif (!to) { to = from }\n\tif (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp }\n\tif (typeof code == \"string\") { code = doc.splitLines(code) }\n\tmakeChange(doc, {from: from, to: to, text: code, origin: origin})\n  }\n  \n  // Rebasing/resetting history to deal with externally-sourced changes\n  \n  function rebaseHistSelSingle(pos, from, to, diff) {\n\tif (to < pos.line) {\n\t  pos.line += diff\n\t} else if (from < pos.line) {\n\t  pos.line = from\n\t  pos.ch = 0\n\t}\n  }\n  \n  // Tries to rebase an array of history events given a change in the\n  // document. If the change touches the same lines as the event, the\n  // event, and everything 'behind' it, is discarded. If the change is\n  // before the event, the event's positions are updated. Uses a\n  // copy-on-write scheme for the positions, to avoid having to\n  // reallocate them all on every rebase, but also avoid problems with\n  // shared position objects being unsafely updated.\n  function rebaseHistArray(array, from, to, diff) {\n\tfor (var i = 0; i < array.length; ++i) {\n\t  var sub = array[i], ok = true\n\t  if (sub.ranges) {\n\t\tif (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }\n\t\tfor (var j = 0; j < sub.ranges.length; j++) {\n\t\t  rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)\n\t\t  rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)\n\t\t}\n\t\tcontinue\n\t  }\n\t  for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {\n\t\tvar cur = sub.changes[j$1]\n\t\tif (to < cur.from.line) {\n\t\t  cur.from = Pos(cur.from.line + diff, cur.from.ch)\n\t\t  cur.to = Pos(cur.to.line + diff, cur.to.ch)\n\t\t} else if (from <= cur.to.line) {\n\t\t  ok = false\n\t\t  break\n\t\t}\n\t  }\n\t  if (!ok) {\n\t\tarray.splice(0, i + 1)\n\t\ti = 0\n\t  }\n\t}\n  }\n  \n  function rebaseHist(hist, change) {\n\tvar from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1\n\trebaseHistArray(hist.done, from, to, diff)\n\trebaseHistArray(hist.undone, from, to, diff)\n  }\n  \n  // Utility for applying a change to a line by handle or number,\n  // returning the number and optionally registering the line as\n  // changed.\n  function changeLine(doc, handle, changeType, op) {\n\tvar no = handle, line = handle\n\tif (typeof handle == \"number\") { line = getLine(doc, clipLine(doc, handle)) }\n\telse { no = lineNo(handle) }\n\tif (no == null) { return null }\n\tif (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType) }\n\treturn line\n  }\n  \n  // The document is represented as a BTree consisting of leaves, with\n  // chunk of lines in them, and branches, with up to ten leaves or\n  // other branch nodes below them. The top node is always a branch\n  // node, and is the document object itself (meaning it has\n  // additional methods and properties).\n  //\n  // All nodes have parent links. The tree is used both to go from\n  // line numbers to line objects, and to go from objects to numbers.\n  // It also indexes by height, and is used to convert between height\n  // and line object, and to find the total height of the document.\n  //\n  // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html\n  \n  function LeafChunk(lines) {\n\tvar this$1 = this;\n  \n\tthis.lines = lines\n\tthis.parent = null\n\tvar height = 0\n\tfor (var i = 0; i < lines.length; ++i) {\n\t  lines[i].parent = this$1\n\t  height += lines[i].height\n\t}\n\tthis.height = height\n  }\n  \n  LeafChunk.prototype = {\n\tchunkSize: function() { return this.lines.length },\n\t// Remove the n lines at offset 'at'.\n\tremoveInner: function(at, n) {\n\t  var this$1 = this;\n  \n\t  for (var i = at, e = at + n; i < e; ++i) {\n\t\tvar line = this$1.lines[i]\n\t\tthis$1.height -= line.height\n\t\tcleanUpLine(line)\n\t\tsignalLater(line, \"delete\")\n\t  }\n\t  this.lines.splice(at, n)\n\t},\n\t// Helper used to collapse a small branch into a single leaf.\n\tcollapse: function(lines) {\n\t  lines.push.apply(lines, this.lines)\n\t},\n\t// Insert the given array of lines at offset 'at', count them as\n\t// having the given height.\n\tinsertInner: function(at, lines, height) {\n\t  var this$1 = this;\n  \n\t  this.height += height\n\t  this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))\n\t  for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }\n\t},\n\t// Used to iterate over a part of the tree.\n\titerN: function(at, n, op) {\n\t  var this$1 = this;\n  \n\t  for (var e = at + n; at < e; ++at)\n\t\t{ if (op(this$1.lines[at])) { return true } }\n\t}\n  }\n  \n  function BranchChunk(children) {\n\tvar this$1 = this;\n  \n\tthis.children = children\n\tvar size = 0, height = 0\n\tfor (var i = 0; i < children.length; ++i) {\n\t  var ch = children[i]\n\t  size += ch.chunkSize(); height += ch.height\n\t  ch.parent = this$1\n\t}\n\tthis.size = size\n\tthis.height = height\n\tthis.parent = null\n  }\n  \n  BranchChunk.prototype = {\n\tchunkSize: function() { return this.size },\n\tremoveInner: function(at, n) {\n\t  var this$1 = this;\n  \n\t  this.size -= n\n\t  for (var i = 0; i < this.children.length; ++i) {\n\t\tvar child = this$1.children[i], sz = child.chunkSize()\n\t\tif (at < sz) {\n\t\t  var rm = Math.min(n, sz - at), oldHeight = child.height\n\t\t  child.removeInner(at, rm)\n\t\t  this$1.height -= oldHeight - child.height\n\t\t  if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }\n\t\t  if ((n -= rm) == 0) { break }\n\t\t  at = 0\n\t\t} else { at -= sz }\n\t  }\n\t  // If the result is smaller than 25 lines, ensure that it is a\n\t  // single leaf node.\n\t  if (this.size - n < 25 &&\n\t\t  (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {\n\t\tvar lines = []\n\t\tthis.collapse(lines)\n\t\tthis.children = [new LeafChunk(lines)]\n\t\tthis.children[0].parent = this\n\t  }\n\t},\n\tcollapse: function(lines) {\n\t  var this$1 = this;\n  \n\t  for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }\n\t},\n\tinsertInner: function(at, lines, height) {\n\t  var this$1 = this;\n  \n\t  this.size += lines.length\n\t  this.height += height\n\t  for (var i = 0; i < this.children.length; ++i) {\n\t\tvar child = this$1.children[i], sz = child.chunkSize()\n\t\tif (at <= sz) {\n\t\t  child.insertInner(at, lines, height)\n\t\t  if (child.lines && child.lines.length > 50) {\n\t\t\t// To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.\n\t\t\t// Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.\n\t\t\tvar remaining = child.lines.length % 25 + 25\n\t\t\tfor (var pos = remaining; pos < child.lines.length;) {\n\t\t\t  var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))\n\t\t\t  child.height -= leaf.height\n\t\t\t  this$1.children.splice(++i, 0, leaf)\n\t\t\t  leaf.parent = this$1\n\t\t\t}\n\t\t\tchild.lines = child.lines.slice(0, remaining)\n\t\t\tthis$1.maybeSpill()\n\t\t  }\n\t\t  break\n\t\t}\n\t\tat -= sz\n\t  }\n\t},\n\t// When a node has grown, check whether it should be split.\n\tmaybeSpill: function() {\n\t  if (this.children.length <= 10) { return }\n\t  var me = this\n\t  do {\n\t\tvar spilled = me.children.splice(me.children.length - 5, 5)\n\t\tvar sibling = new BranchChunk(spilled)\n\t\tif (!me.parent) { // Become the parent node\n\t\t  var copy = new BranchChunk(me.children)\n\t\t  copy.parent = me\n\t\t  me.children = [copy, sibling]\n\t\t  me = copy\n\t   } else {\n\t\t  me.size -= sibling.size\n\t\t  me.height -= sibling.height\n\t\t  var myIndex = indexOf(me.parent.children, me)\n\t\t  me.parent.children.splice(myIndex + 1, 0, sibling)\n\t\t}\n\t\tsibling.parent = me.parent\n\t  } while (me.children.length > 10)\n\t  me.parent.maybeSpill()\n\t},\n\titerN: function(at, n, op) {\n\t  var this$1 = this;\n  \n\t  for (var i = 0; i < this.children.length; ++i) {\n\t\tvar child = this$1.children[i], sz = child.chunkSize()\n\t\tif (at < sz) {\n\t\t  var used = Math.min(n, sz - at)\n\t\t  if (child.iterN(at, used, op)) { return true }\n\t\t  if ((n -= used) == 0) { break }\n\t\t  at = 0\n\t\t} else { at -= sz }\n\t  }\n\t}\n  }\n  \n  // Line widgets are block elements displayed above or below a line.\n  \n  function LineWidget(doc, node, options) {\n\tvar this$1 = this;\n  \n\tif (options) { for (var opt in options) { if (options.hasOwnProperty(opt))\n\t  { this$1[opt] = options[opt] } } }\n\tthis.doc = doc\n\tthis.node = node\n  }\n  eventMixin(LineWidget)\n  \n  function adjustScrollWhenAboveVisible(cm, line, diff) {\n\tif (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))\n\t  { addToScrollPos(cm, null, diff) }\n  }\n  \n  LineWidget.prototype.clear = function() {\n\tvar this$1 = this;\n  \n\tvar cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)\n\tif (no == null || !ws) { return }\n\tfor (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1) } }\n\tif (!ws.length) { line.widgets = null }\n\tvar height = widgetHeight(this)\n\tupdateLineHeight(line, Math.max(0, line.height - height))\n\tif (cm) { runInOp(cm, function () {\n\t  adjustScrollWhenAboveVisible(cm, line, -height)\n\t  regLineChange(cm, no, \"widget\")\n\t}) }\n  }\n  LineWidget.prototype.changed = function() {\n\tvar oldH = this.height, cm = this.doc.cm, line = this.line\n\tthis.height = null\n\tvar diff = widgetHeight(this) - oldH\n\tif (!diff) { return }\n\tupdateLineHeight(line, line.height + diff)\n\tif (cm) { runInOp(cm, function () {\n\t  cm.curOp.forceUpdate = true\n\t  adjustScrollWhenAboveVisible(cm, line, diff)\n\t}) }\n  }\n  \n  function addLineWidget(doc, handle, node, options) {\n\tvar widget = new LineWidget(doc, node, options)\n\tvar cm = doc.cm\n\tif (cm && widget.noHScroll) { cm.display.alignWidgets = true }\n\tchangeLine(doc, handle, \"widget\", function (line) {\n\t  var widgets = line.widgets || (line.widgets = [])\n\t  if (widget.insertAt == null) { widgets.push(widget) }\n\t  else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget) }\n\t  widget.line = line\n\t  if (cm && !lineIsHidden(doc, line)) {\n\t\tvar aboveVisible = heightAtLine(line) < doc.scrollTop\n\t\tupdateLineHeight(line, line.height + widgetHeight(widget))\n\t\tif (aboveVisible) { addToScrollPos(cm, null, widget.height) }\n\t\tcm.curOp.forceUpdate = true\n\t  }\n\t  return true\n\t})\n\treturn widget\n  }\n  \n  // TEXTMARKERS\n  \n  // Created with markText and setBookmark methods. A TextMarker is a\n  // handle that can be used to clear or find a marked position in the\n  // document. Line objects hold arrays (markedSpans) containing\n  // {from, to, marker} object pointing to such marker objects, and\n  // indicating that such a marker is present on that line. Multiple\n  // lines may point to the same marker when it spans across lines.\n  // The spans will have null for their from/to properties when the\n  // marker continues beyond the start/end of the line. Markers have\n  // links back to the lines they currently touch.\n  \n  // Collapsed markers have unique ids, in order to be able to order\n  // them, which is needed for uniquely determining an outer marker\n  // when they overlap (they may nest, but not partially overlap).\n  var nextMarkerId = 0\n  \n  function TextMarker(doc, type) {\n\tthis.lines = []\n\tthis.type = type\n\tthis.doc = doc\n\tthis.id = ++nextMarkerId\n  }\n  eventMixin(TextMarker)\n  \n  // Clear the marker.\n  TextMarker.prototype.clear = function() {\n\tvar this$1 = this;\n  \n\tif (this.explicitlyCleared) { return }\n\tvar cm = this.doc.cm, withOp = cm && !cm.curOp\n\tif (withOp) { startOperation(cm) }\n\tif (hasHandler(this, \"clear\")) {\n\t  var found = this.find()\n\t  if (found) { signalLater(this, \"clear\", found.from, found.to) }\n\t}\n\tvar min = null, max = null\n\tfor (var i = 0; i < this.lines.length; ++i) {\n\t  var line = this$1.lines[i]\n\t  var span = getMarkedSpanFor(line.markedSpans, this$1)\n\t  if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), \"text\") }\n\t  else if (cm) {\n\t\tif (span.to != null) { max = lineNo(line) }\n\t\tif (span.from != null) { min = lineNo(line) }\n\t  }\n\t  line.markedSpans = removeMarkedSpan(line.markedSpans, span)\n\t  if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)\n\t\t{ updateLineHeight(line, textHeight(cm.display)) }\n\t}\n\tif (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {\n\t  var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual)\n\t  if (len > cm.display.maxLineLength) {\n\t\tcm.display.maxLine = visual\n\t\tcm.display.maxLineLength = len\n\t\tcm.display.maxLineChanged = true\n\t  }\n\t} }\n  \n\tif (min != null && cm && this.collapsed) { regChange(cm, min, max + 1) }\n\tthis.lines.length = 0\n\tthis.explicitlyCleared = true\n\tif (this.atomic && this.doc.cantEdit) {\n\t  this.doc.cantEdit = false\n\t  if (cm) { reCheckSelection(cm.doc) }\n\t}\n\tif (cm) { signalLater(cm, \"markerCleared\", cm, this) }\n\tif (withOp) { endOperation(cm) }\n\tif (this.parent) { this.parent.clear() }\n  }\n  \n  // Find the position of the marker in the document. Returns a {from,\n  // to} object by default. Side can be passed to get a specific side\n  // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the\n  // Pos objects returned contain a line object, rather than a line\n  // number (used to prevent looking up the same line twice).\n  TextMarker.prototype.find = function(side, lineObj) {\n\tvar this$1 = this;\n  \n\tif (side == null && this.type == \"bookmark\") { side = 1 }\n\tvar from, to\n\tfor (var i = 0; i < this.lines.length; ++i) {\n\t  var line = this$1.lines[i]\n\t  var span = getMarkedSpanFor(line.markedSpans, this$1)\n\t  if (span.from != null) {\n\t\tfrom = Pos(lineObj ? line : lineNo(line), span.from)\n\t\tif (side == -1) { return from }\n\t  }\n\t  if (span.to != null) {\n\t\tto = Pos(lineObj ? line : lineNo(line), span.to)\n\t\tif (side == 1) { return to }\n\t  }\n\t}\n\treturn from && {from: from, to: to}\n  }\n  \n  // Signals that the marker's widget changed, and surrounding layout\n  // should be recomputed.\n  TextMarker.prototype.changed = function() {\n\tvar pos = this.find(-1, true), widget = this, cm = this.doc.cm\n\tif (!pos || !cm) { return }\n\trunInOp(cm, function () {\n\t  var line = pos.line, lineN = lineNo(pos.line)\n\t  var view = findViewForLine(cm, lineN)\n\t  if (view) {\n\t\tclearLineMeasurementCacheFor(view)\n\t\tcm.curOp.selectionChanged = cm.curOp.forceUpdate = true\n\t  }\n\t  cm.curOp.updateMaxLine = true\n\t  if (!lineIsHidden(widget.doc, line) && widget.height != null) {\n\t\tvar oldHeight = widget.height\n\t\twidget.height = null\n\t\tvar dHeight = widgetHeight(widget) - oldHeight\n\t\tif (dHeight)\n\t\t  { updateLineHeight(line, line.height + dHeight) }\n\t  }\n\t})\n  }\n  \n  TextMarker.prototype.attachLine = function(line) {\n\tif (!this.lines.length && this.doc.cm) {\n\t  var op = this.doc.cm.curOp\n\t  if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)\n\t\t{ (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }\n\t}\n\tthis.lines.push(line)\n  }\n  TextMarker.prototype.detachLine = function(line) {\n\tthis.lines.splice(indexOf(this.lines, line), 1)\n\tif (!this.lines.length && this.doc.cm) {\n\t  var op = this.doc.cm.curOp\n\t  ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)\n\t}\n  }\n  \n  // Create a marker, wire it up to the right lines, and\n  function markText(doc, from, to, options, type) {\n\t// Shared markers (across linked documents) are handled separately\n\t// (markTextShared will call out to this again, once per\n\t// document).\n\tif (options && options.shared) { return markTextShared(doc, from, to, options, type) }\n\t// Ensure we are in an operation.\n\tif (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }\n  \n\tvar marker = new TextMarker(doc, type), diff = cmp(from, to)\n\tif (options) { copyObj(options, marker, false) }\n\t// Don't connect empty markers unless clearWhenEmpty is false\n\tif (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)\n\t  { return marker }\n\tif (marker.replacedWith) {\n\t  // Showing up as a widget implies collapsed (widget replaces text)\n\t  marker.collapsed = true\n\t  marker.widgetNode = elt(\"span\", [marker.replacedWith], \"CodeMirror-widget\")\n\t  if (!options.handleMouseEvents) { marker.widgetNode.setAttribute(\"cm-ignore-events\", \"true\") }\n\t  if (options.insertLeft) { marker.widgetNode.insertLeft = true }\n\t}\n\tif (marker.collapsed) {\n\t  if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||\n\t\t  from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))\n\t\t{ throw new Error(\"Inserting collapsed marker partially overlapping an existing one\") }\n\t  seeCollapsedSpans()\n\t}\n  \n\tif (marker.addToHistory)\n\t  { addChangeToHistory(doc, {from: from, to: to, origin: \"markText\"}, doc.sel, NaN) }\n  \n\tvar curLine = from.line, cm = doc.cm, updateMaxLine\n\tdoc.iter(curLine, to.line + 1, function (line) {\n\t  if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)\n\t\t{ updateMaxLine = true }\n\t  if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0) }\n\t  addMarkedSpan(line, new MarkedSpan(marker,\n\t\t\t\t\t\t\t\t\t\t curLine == from.line ? from.ch : null,\n\t\t\t\t\t\t\t\t\t\t curLine == to.line ? to.ch : null))\n\t  ++curLine\n\t})\n\t// lineIsHidden depends on the presence of the spans, so needs a second pass\n\tif (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {\n\t  if (lineIsHidden(doc, line)) { updateLineHeight(line, 0) }\n\t}) }\n  \n\tif (marker.clearOnEnter) { on(marker, \"beforeCursorEnter\", function () { return marker.clear(); }) }\n  \n\tif (marker.readOnly) {\n\t  seeReadOnlySpans()\n\t  if (doc.history.done.length || doc.history.undone.length)\n\t\t{ doc.clearHistory() }\n\t}\n\tif (marker.collapsed) {\n\t  marker.id = ++nextMarkerId\n\t  marker.atomic = true\n\t}\n\tif (cm) {\n\t  // Sync editor state\n\t  if (updateMaxLine) { cm.curOp.updateMaxLine = true }\n\t  if (marker.collapsed)\n\t\t{ regChange(cm, from.line, to.line + 1) }\n\t  else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)\n\t\t{ for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, \"text\") } }\n\t  if (marker.atomic) { reCheckSelection(cm.doc) }\n\t  signalLater(cm, \"markerAdded\", cm, marker)\n\t}\n\treturn marker\n  }\n  \n  // SHARED TEXTMARKERS\n  \n  // A shared marker spans multiple linked documents. It is\n  // implemented as a meta-marker-object controlling multiple normal\n  // markers.\n  function SharedTextMarker(markers, primary) {\n\tvar this$1 = this;\n  \n\tthis.markers = markers\n\tthis.primary = primary\n\tfor (var i = 0; i < markers.length; ++i)\n\t  { markers[i].parent = this$1 }\n  }\n  eventMixin(SharedTextMarker)\n  \n  SharedTextMarker.prototype.clear = function() {\n\tvar this$1 = this;\n  \n\tif (this.explicitlyCleared) { return }\n\tthis.explicitlyCleared = true\n\tfor (var i = 0; i < this.markers.length; ++i)\n\t  { this$1.markers[i].clear() }\n\tsignalLater(this, \"clear\")\n  }\n  SharedTextMarker.prototype.find = function(side, lineObj) {\n\treturn this.primary.find(side, lineObj)\n  }\n  \n  function markTextShared(doc, from, to, options, type) {\n\toptions = copyObj(options)\n\toptions.shared = false\n\tvar markers = [markText(doc, from, to, options, type)], primary = markers[0]\n\tvar widget = options.widgetNode\n\tlinkedDocs(doc, function (doc) {\n\t  if (widget) { options.widgetNode = widget.cloneNode(true) }\n\t  markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type))\n\t  for (var i = 0; i < doc.linked.length; ++i)\n\t\t{ if (doc.linked[i].isParent) { return } }\n\t  primary = lst(markers)\n\t})\n\treturn new SharedTextMarker(markers, primary)\n  }\n  \n  function findSharedMarkers(doc) {\n\treturn doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })\n  }\n  \n  function copySharedMarkers(doc, markers) {\n\tfor (var i = 0; i < markers.length; i++) {\n\t  var marker = markers[i], pos = marker.find()\n\t  var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to)\n\t  if (cmp(mFrom, mTo)) {\n\t\tvar subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type)\n\t\tmarker.markers.push(subMark)\n\t\tsubMark.parent = marker\n\t  }\n\t}\n  }\n  \n  function detachSharedMarkers(markers) {\n\tvar loop = function ( i ) {\n\t  var marker = markers[i], linked = [marker.primary.doc]\n\t  linkedDocs(marker.primary.doc, function (d) { return linked.push(d); })\n\t  for (var j = 0; j < marker.markers.length; j++) {\n\t\tvar subMarker = marker.markers[j]\n\t\tif (indexOf(linked, subMarker.doc) == -1) {\n\t\t  subMarker.parent = null\n\t\t  marker.markers.splice(j--, 1)\n\t\t}\n\t  }\n\t};\n  \n\tfor (var i = 0; i < markers.length; i++) loop( i );\n  }\n  \n  var nextDocId = 0\n  var Doc = function(text, mode, firstLine, lineSep) {\n\tif (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep) }\n\tif (firstLine == null) { firstLine = 0 }\n  \n\tBranchChunk.call(this, [new LeafChunk([new Line(\"\", null)])])\n\tthis.first = firstLine\n\tthis.scrollTop = this.scrollLeft = 0\n\tthis.cantEdit = false\n\tthis.cleanGeneration = 1\n\tthis.frontier = firstLine\n\tvar start = Pos(firstLine, 0)\n\tthis.sel = simpleSelection(start)\n\tthis.history = new History(null)\n\tthis.id = ++nextDocId\n\tthis.modeOption = mode\n\tthis.lineSep = lineSep\n\tthis.extend = false\n  \n\tif (typeof text == \"string\") { text = this.splitLines(text) }\n\tupdateDoc(this, {from: start, to: start, text: text})\n\tsetSelection(this, simpleSelection(start), sel_dontScroll)\n  }\n  \n  Doc.prototype = createObj(BranchChunk.prototype, {\n\tconstructor: Doc,\n\t// Iterate over the document. Supports two forms -- with only one\n\t// argument, it calls that for each line in the document. With\n\t// three, it iterates over the range given by the first two (with\n\t// the second being non-inclusive).\n\titer: function(from, to, op) {\n\t  if (op) { this.iterN(from - this.first, to - from, op) }\n\t  else { this.iterN(this.first, this.first + this.size, from) }\n\t},\n  \n\t// Non-public interface for adding and removing lines.\n\tinsert: function(at, lines) {\n\t  var height = 0\n\t  for (var i = 0; i < lines.length; ++i) { height += lines[i].height }\n\t  this.insertInner(at - this.first, lines, height)\n\t},\n\tremove: function(at, n) { this.removeInner(at - this.first, n) },\n  \n\t// From here, the methods are part of the public interface. Most\n\t// are also available from CodeMirror (editor) instances.\n  \n\tgetValue: function(lineSep) {\n\t  var lines = getLines(this, this.first, this.first + this.size)\n\t  if (lineSep === false) { return lines }\n\t  return lines.join(lineSep || this.lineSeparator())\n\t},\n\tsetValue: docMethodOp(function(code) {\n\t  var top = Pos(this.first, 0), last = this.first + this.size - 1\n\t  makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),\n\t\t\t\t\t\ttext: this.splitLines(code), origin: \"setValue\", full: true}, true)\n\t  setSelection(this, simpleSelection(top))\n\t}),\n\treplaceRange: function(code, from, to, origin) {\n\t  from = clipPos(this, from)\n\t  to = to ? clipPos(this, to) : from\n\t  replaceRange(this, code, from, to, origin)\n\t},\n\tgetRange: function(from, to, lineSep) {\n\t  var lines = getBetween(this, clipPos(this, from), clipPos(this, to))\n\t  if (lineSep === false) { return lines }\n\t  return lines.join(lineSep || this.lineSeparator())\n\t},\n  \n\tgetLine: function(line) {var l = this.getLineHandle(line); return l && l.text},\n  \n\tgetLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},\n\tgetLineNumber: function(line) {return lineNo(line)},\n  \n\tgetLineHandleVisualStart: function(line) {\n\t  if (typeof line == \"number\") { line = getLine(this, line) }\n\t  return visualLine(line)\n\t},\n  \n\tlineCount: function() {return this.size},\n\tfirstLine: function() {return this.first},\n\tlastLine: function() {return this.first + this.size - 1},\n  \n\tclipPos: function(pos) {return clipPos(this, pos)},\n  \n\tgetCursor: function(start) {\n\t  var range = this.sel.primary(), pos\n\t  if (start == null || start == \"head\") { pos = range.head }\n\t  else if (start == \"anchor\") { pos = range.anchor }\n\t  else if (start == \"end\" || start == \"to\" || start === false) { pos = range.to() }\n\t  else { pos = range.from() }\n\t  return pos\n\t},\n\tlistSelections: function() { return this.sel.ranges },\n\tsomethingSelected: function() {return this.sel.somethingSelected()},\n  \n\tsetCursor: docMethodOp(function(line, ch, options) {\n\t  setSimpleSelection(this, clipPos(this, typeof line == \"number\" ? Pos(line, ch || 0) : line), null, options)\n\t}),\n\tsetSelection: docMethodOp(function(anchor, head, options) {\n\t  setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options)\n\t}),\n\textendSelection: docMethodOp(function(head, other, options) {\n\t  extendSelection(this, clipPos(this, head), other && clipPos(this, other), options)\n\t}),\n\textendSelections: docMethodOp(function(heads, options) {\n\t  extendSelections(this, clipPosArray(this, heads), options)\n\t}),\n\textendSelectionsBy: docMethodOp(function(f, options) {\n\t  var heads = map(this.sel.ranges, f)\n\t  extendSelections(this, clipPosArray(this, heads), options)\n\t}),\n\tsetSelections: docMethodOp(function(ranges, primary, options) {\n\t  var this$1 = this;\n  \n\t  if (!ranges.length) { return }\n\t  var out = []\n\t  for (var i = 0; i < ranges.length; i++)\n\t\t{ out[i] = new Range(clipPos(this$1, ranges[i].anchor),\n\t\t\t\t\t\t   clipPos(this$1, ranges[i].head)) }\n\t  if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex) }\n\t  setSelection(this, normalizeSelection(out, primary), options)\n\t}),\n\taddSelection: docMethodOp(function(anchor, head, options) {\n\t  var ranges = this.sel.ranges.slice(0)\n\t  ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)))\n\t  setSelection(this, normalizeSelection(ranges, ranges.length - 1), options)\n\t}),\n  \n\tgetSelection: function(lineSep) {\n\t  var this$1 = this;\n  \n\t  var ranges = this.sel.ranges, lines\n\t  for (var i = 0; i < ranges.length; i++) {\n\t\tvar sel = getBetween(this$1, ranges[i].from(), ranges[i].to())\n\t\tlines = lines ? lines.concat(sel) : sel\n\t  }\n\t  if (lineSep === false) { return lines }\n\t  else { return lines.join(lineSep || this.lineSeparator()) }\n\t},\n\tgetSelections: function(lineSep) {\n\t  var this$1 = this;\n  \n\t  var parts = [], ranges = this.sel.ranges\n\t  for (var i = 0; i < ranges.length; i++) {\n\t\tvar sel = getBetween(this$1, ranges[i].from(), ranges[i].to())\n\t\tif (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()) }\n\t\tparts[i] = sel\n\t  }\n\t  return parts\n\t},\n\treplaceSelection: function(code, collapse, origin) {\n\t  var dup = []\n\t  for (var i = 0; i < this.sel.ranges.length; i++)\n\t\t{ dup[i] = code }\n\t  this.replaceSelections(dup, collapse, origin || \"+input\")\n\t},\n\treplaceSelections: docMethodOp(function(code, collapse, origin) {\n\t  var this$1 = this;\n  \n\t  var changes = [], sel = this.sel\n\t  for (var i = 0; i < sel.ranges.length; i++) {\n\t\tvar range = sel.ranges[i]\n\t\tchanges[i] = {from: range.from(), to: range.to(), text: this$1.splitLines(code[i]), origin: origin}\n\t  }\n\t  var newSel = collapse && collapse != \"end\" && computeReplacedSel(this, changes, collapse)\n\t  for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)\n\t\t{ makeChange(this$1, changes[i$1]) }\n\t  if (newSel) { setSelectionReplaceHistory(this, newSel) }\n\t  else if (this.cm) { ensureCursorVisible(this.cm) }\n\t}),\n\tundo: docMethodOp(function() {makeChangeFromHistory(this, \"undo\")}),\n\tredo: docMethodOp(function() {makeChangeFromHistory(this, \"redo\")}),\n\tundoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"undo\", true)}),\n\tredoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"redo\", true)}),\n  \n\tsetExtending: function(val) {this.extend = val},\n\tgetExtending: function() {return this.extend},\n  \n\thistorySize: function() {\n\t  var hist = this.history, done = 0, undone = 0\n\t  for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done } }\n\t  for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone } }\n\t  return {undo: done, redo: undone}\n\t},\n\tclearHistory: function() {this.history = new History(this.history.maxGeneration)},\n  \n\tmarkClean: function() {\n\t  this.cleanGeneration = this.changeGeneration(true)\n\t},\n\tchangeGeneration: function(forceSplit) {\n\t  if (forceSplit)\n\t\t{ this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null }\n\t  return this.history.generation\n\t},\n\tisClean: function (gen) {\n\t  return this.history.generation == (gen || this.cleanGeneration)\n\t},\n  \n\tgetHistory: function() {\n\t  return {done: copyHistoryArray(this.history.done),\n\t\t\t  undone: copyHistoryArray(this.history.undone)}\n\t},\n\tsetHistory: function(histData) {\n\t  var hist = this.history = new History(this.history.maxGeneration)\n\t  hist.done = copyHistoryArray(histData.done.slice(0), null, true)\n\t  hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)\n\t},\n  \n\taddLineClass: docMethodOp(function(handle, where, cls) {\n\t  return changeLine(this, handle, where == \"gutter\" ? \"gutter\" : \"class\", function (line) {\n\t\tvar prop = where == \"text\" ? \"textClass\"\n\t\t\t\t : where == \"background\" ? \"bgClass\"\n\t\t\t\t : where == \"gutter\" ? \"gutterClass\" : \"wrapClass\"\n\t\tif (!line[prop]) { line[prop] = cls }\n\t\telse if (classTest(cls).test(line[prop])) { return false }\n\t\telse { line[prop] += \" \" + cls }\n\t\treturn true\n\t  })\n\t}),\n\tremoveLineClass: docMethodOp(function(handle, where, cls) {\n\t  return changeLine(this, handle, where == \"gutter\" ? \"gutter\" : \"class\", function (line) {\n\t\tvar prop = where == \"text\" ? \"textClass\"\n\t\t\t\t : where == \"background\" ? \"bgClass\"\n\t\t\t\t : where == \"gutter\" ? \"gutterClass\" : \"wrapClass\"\n\t\tvar cur = line[prop]\n\t\tif (!cur) { return false }\n\t\telse if (cls == null) { line[prop] = null }\n\t\telse {\n\t\t  var found = cur.match(classTest(cls))\n\t\t  if (!found) { return false }\n\t\t  var end = found.index + found[0].length\n\t\t  line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? \"\" : \" \") + cur.slice(end) || null\n\t\t}\n\t\treturn true\n\t  })\n\t}),\n  \n\taddLineWidget: docMethodOp(function(handle, node, options) {\n\t  return addLineWidget(this, handle, node, options)\n\t}),\n\tremoveLineWidget: function(widget) { widget.clear() },\n  \n\tmarkText: function(from, to, options) {\n\t  return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || \"range\")\n\t},\n\tsetBookmark: function(pos, options) {\n\t  var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),\n\t\t\t\t\t  insertLeft: options && options.insertLeft,\n\t\t\t\t\t  clearWhenEmpty: false, shared: options && options.shared,\n\t\t\t\t\t  handleMouseEvents: options && options.handleMouseEvents}\n\t  pos = clipPos(this, pos)\n\t  return markText(this, pos, pos, realOpts, \"bookmark\")\n\t},\n\tfindMarksAt: function(pos) {\n\t  pos = clipPos(this, pos)\n\t  var markers = [], spans = getLine(this, pos.line).markedSpans\n\t  if (spans) { for (var i = 0; i < spans.length; ++i) {\n\t\tvar span = spans[i]\n\t\tif ((span.from == null || span.from <= pos.ch) &&\n\t\t\t(span.to == null || span.to >= pos.ch))\n\t\t  { markers.push(span.marker.parent || span.marker) }\n\t  } }\n\t  return markers\n\t},\n\tfindMarks: function(from, to, filter) {\n\t  from = clipPos(this, from); to = clipPos(this, to)\n\t  var found = [], lineNo = from.line\n\t  this.iter(from.line, to.line + 1, function (line) {\n\t\tvar spans = line.markedSpans\n\t\tif (spans) { for (var i = 0; i < spans.length; i++) {\n\t\t  var span = spans[i]\n\t\t  if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||\n\t\t\t\tspan.from == null && lineNo != from.line ||\n\t\t\t\tspan.from != null && lineNo == to.line && span.from >= to.ch) &&\n\t\t\t  (!filter || filter(span.marker)))\n\t\t\t{ found.push(span.marker.parent || span.marker) }\n\t\t} }\n\t\t++lineNo\n\t  })\n\t  return found\n\t},\n\tgetAllMarks: function() {\n\t  var markers = []\n\t  this.iter(function (line) {\n\t\tvar sps = line.markedSpans\n\t\tif (sps) { for (var i = 0; i < sps.length; ++i)\n\t\t  { if (sps[i].from != null) { markers.push(sps[i].marker) } } }\n\t  })\n\t  return markers\n\t},\n  \n\tposFromIndex: function(off) {\n\t  var ch, lineNo = this.first, sepSize = this.lineSeparator().length\n\t  this.iter(function (line) {\n\t\tvar sz = line.text.length + sepSize\n\t\tif (sz > off) { ch = off; return true }\n\t\toff -= sz\n\t\t++lineNo\n\t  })\n\t  return clipPos(this, Pos(lineNo, ch))\n\t},\n\tindexFromPos: function (coords) {\n\t  coords = clipPos(this, coords)\n\t  var index = coords.ch\n\t  if (coords.line < this.first || coords.ch < 0) { return 0 }\n\t  var sepSize = this.lineSeparator().length\n\t  this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value\n\t\tindex += line.text.length + sepSize\n\t  })\n\t  return index\n\t},\n  \n\tcopy: function(copyHistory) {\n\t  var doc = new Doc(getLines(this, this.first, this.first + this.size),\n\t\t\t\t\t\tthis.modeOption, this.first, this.lineSep)\n\t  doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft\n\t  doc.sel = this.sel\n\t  doc.extend = false\n\t  if (copyHistory) {\n\t\tdoc.history.undoDepth = this.history.undoDepth\n\t\tdoc.setHistory(this.getHistory())\n\t  }\n\t  return doc\n\t},\n  \n\tlinkedDoc: function(options) {\n\t  if (!options) { options = {} }\n\t  var from = this.first, to = this.first + this.size\n\t  if (options.from != null && options.from > from) { from = options.from }\n\t  if (options.to != null && options.to < to) { to = options.to }\n\t  var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep)\n\t  if (options.sharedHist) { copy.history = this.history\n\t  ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})\n\t  copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]\n\t  copySharedMarkers(copy, findSharedMarkers(this))\n\t  return copy\n\t},\n\tunlinkDoc: function(other) {\n\t  var this$1 = this;\n  \n\t  if (other instanceof CodeMirror) { other = other.doc }\n\t  if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {\n\t\tvar link = this$1.linked[i]\n\t\tif (link.doc != other) { continue }\n\t\tthis$1.linked.splice(i, 1)\n\t\tother.unlinkDoc(this$1)\n\t\tdetachSharedMarkers(findSharedMarkers(this$1))\n\t\tbreak\n\t  } }\n\t  // If the histories were shared, split them again\n\t  if (other.history == this.history) {\n\t\tvar splitIds = [other.id]\n\t\tlinkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true)\n\t\tother.history = new History(null)\n\t\tother.history.done = copyHistoryArray(this.history.done, splitIds)\n\t\tother.history.undone = copyHistoryArray(this.history.undone, splitIds)\n\t  }\n\t},\n\titerLinkedDocs: function(f) {linkedDocs(this, f)},\n  \n\tgetMode: function() {return this.mode},\n\tgetEditor: function() {return this.cm},\n  \n\tsplitLines: function(str) {\n\t  if (this.lineSep) { return str.split(this.lineSep) }\n\t  return splitLinesAuto(str)\n\t},\n\tlineSeparator: function() { return this.lineSep || \"\\n\" }\n  })\n  \n  // Public alias.\n  Doc.prototype.eachLine = Doc.prototype.iter\n  \n  // Kludge to work around strange IE behavior where it'll sometimes\n  // re-fire a series of drag-related events right after the drop (#1551)\n  var lastDrop = 0\n  \n  function onDrop(e) {\n\tvar cm = this\n\tclearDragCursor(cm)\n\tif (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))\n\t  { return }\n\te_preventDefault(e)\n\tif (ie) { lastDrop = +new Date }\n\tvar pos = posFromMouse(cm, e, true), files = e.dataTransfer.files\n\tif (!pos || cm.isReadOnly()) { return }\n\t// Might be a file drop, in which case we simply extract the text\n\t// and insert it.\n\tif (files && files.length && window.FileReader && window.File) {\n\t  var n = files.length, text = Array(n), read = 0\n\t  var loadFile = function (file, i) {\n\t\tif (cm.options.allowDropFileTypes &&\n\t\t\tindexOf(cm.options.allowDropFileTypes, file.type) == -1)\n\t\t  { return }\n  \n\t\tvar reader = new FileReader\n\t\treader.onload = operation(cm, function () {\n\t\t  var content = reader.result\n\t\t  if (/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(content)) { content = \"\" }\n\t\t  text[i] = content\n\t\t  if (++read == n) {\n\t\t\tpos = clipPos(cm.doc, pos)\n\t\t\tvar change = {from: pos, to: pos,\n\t\t\t\t\t\t  text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),\n\t\t\t\t\t\t  origin: \"paste\"}\n\t\t\tmakeChange(cm.doc, change)\n\t\t\tsetSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)))\n\t\t  }\n\t\t})\n\t\treader.readAsText(file)\n\t  }\n\t  for (var i = 0; i < n; ++i) { loadFile(files[i], i) }\n\t} else { // Normal drop\n\t  // Don't do a replace if the drop happened inside of the selected text.\n\t  if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {\n\t\tcm.state.draggingText(e)\n\t\t// Ensure the editor is re-focused\n\t\tsetTimeout(function () { return cm.display.input.focus(); }, 20)\n\t\treturn\n\t  }\n\t  try {\n\t\tvar text$1 = e.dataTransfer.getData(\"Text\")\n\t\tif (text$1) {\n\t\t  var selected\n\t\t  if (cm.state.draggingText && !cm.state.draggingText.copy)\n\t\t\t{ selected = cm.listSelections() }\n\t\t  setSelectionNoUndo(cm.doc, simpleSelection(pos, pos))\n\t\t  if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)\n\t\t\t{ replaceRange(cm.doc, \"\", selected[i$1].anchor, selected[i$1].head, \"drag\") } }\n\t\t  cm.replaceSelection(text$1, \"around\", \"paste\")\n\t\t  cm.display.input.focus()\n\t\t}\n\t  }\n\t  catch(e){}\n\t}\n  }\n  \n  function onDragStart(cm, e) {\n\tif (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }\n\tif (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }\n  \n\te.dataTransfer.setData(\"Text\", cm.getSelection())\n\te.dataTransfer.effectAllowed = \"copyMove\"\n  \n\t// Use dummy image instead of default browsers image.\n\t// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.\n\tif (e.dataTransfer.setDragImage && !safari) {\n\t  var img = elt(\"img\", null, null, \"position: fixed; left: 0; top: 0;\")\n\t  img.src = \"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\"\n\t  if (presto) {\n\t\timg.width = img.height = 1\n\t\tcm.display.wrapper.appendChild(img)\n\t\t// Force a relayout, or Opera won't use our image for some obscure reason\n\t\timg._top = img.offsetTop\n\t  }\n\t  e.dataTransfer.setDragImage(img, 0, 0)\n\t  if (presto) { img.parentNode.removeChild(img) }\n\t}\n  }\n  \n  function onDragOver(cm, e) {\n\tvar pos = posFromMouse(cm, e)\n\tif (!pos) { return }\n\tvar frag = document.createDocumentFragment()\n\tdrawSelectionCursor(cm, pos, frag)\n\tif (!cm.display.dragCursor) {\n\t  cm.display.dragCursor = elt(\"div\", null, \"CodeMirror-cursors CodeMirror-dragcursors\")\n\t  cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)\n\t}\n\tremoveChildrenAndAdd(cm.display.dragCursor, frag)\n  }\n  \n  function clearDragCursor(cm) {\n\tif (cm.display.dragCursor) {\n\t  cm.display.lineSpace.removeChild(cm.display.dragCursor)\n\t  cm.display.dragCursor = null\n\t}\n  }\n  \n  // These must be handled carefully, because naively registering a\n  // handler for each editor will cause the editors to never be\n  // garbage collected.\n  \n  function forEachCodeMirror(f) {\n\tif (!document.body.getElementsByClassName) { return }\n\tvar byClass = document.body.getElementsByClassName(\"CodeMirror\")\n\tfor (var i = 0; i < byClass.length; i++) {\n\t  var cm = byClass[i].CodeMirror\n\t  if (cm) { f(cm) }\n\t}\n  }\n  \n  var globalsRegistered = false\n  function ensureGlobalHandlers() {\n\tif (globalsRegistered) { return }\n\tregisterGlobalHandlers()\n\tglobalsRegistered = true\n  }\n  function registerGlobalHandlers() {\n\t// When the window resizes, we need to refresh active editors.\n\tvar resizeTimer\n\ton(window, \"resize\", function () {\n\t  if (resizeTimer == null) { resizeTimer = setTimeout(function () {\n\t\tresizeTimer = null\n\t\tforEachCodeMirror(onResize)\n\t  }, 100) }\n\t})\n\t// When the window loses focus, we want to show the editor as blurred\n\ton(window, \"blur\", function () { return forEachCodeMirror(onBlur); })\n  }\n  // Called when the window resizes\n  function onResize(cm) {\n\tvar d = cm.display\n\tif (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)\n\t  { return }\n\t// Might be a text scaling operation, clear size caches.\n\td.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null\n\td.scrollbarsClipped = false\n\tcm.setSize()\n  }\n  \n  var keyNames = {\n\t3: \"Enter\", 8: \"Backspace\", 9: \"Tab\", 13: \"Enter\", 16: \"Shift\", 17: \"Ctrl\", 18: \"Alt\",\n\t19: \"Pause\", 20: \"CapsLock\", 27: \"Esc\", 32: \"Space\", 33: \"PageUp\", 34: \"PageDown\", 35: \"End\",\n\t36: \"Home\", 37: \"Left\", 38: \"Up\", 39: \"Right\", 40: \"Down\", 44: \"PrintScrn\", 45: \"Insert\",\n\t46: \"Delete\", 59: \";\", 61: \"=\", 91: \"Mod\", 92: \"Mod\", 93: \"Mod\",\n\t106: \"*\", 107: \"=\", 109: \"-\", 110: \".\", 111: \"/\", 127: \"Delete\",\n\t173: \"-\", 186: \";\", 187: \"=\", 188: \",\", 189: \"-\", 190: \".\", 191: \"/\", 192: \"`\", 219: \"[\", 220: \"\\\\\",\n\t221: \"]\", 222: \"'\", 63232: \"Up\", 63233: \"Down\", 63234: \"Left\", 63235: \"Right\", 63272: \"Delete\",\n\t63273: \"Home\", 63275: \"End\", 63276: \"PageUp\", 63277: \"PageDown\", 63302: \"Insert\"\n  }\n  \n  // Number keys\n  for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i) }\n  // Alphabetic keys\n  for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1) }\n  // Function keys\n  for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = \"F\" + i$2 }\n  \n  var keyMap = {}\n  \n  keyMap.basic = {\n\t\"Left\": \"goCharLeft\", \"Right\": \"goCharRight\", \"Up\": \"goLineUp\", \"Down\": \"goLineDown\",\n\t\"End\": \"goLineEnd\", \"Home\": \"goLineStartSmart\", \"PageUp\": \"goPageUp\", \"PageDown\": \"goPageDown\",\n\t\"Delete\": \"delCharAfter\", \"Backspace\": \"delCharBefore\", \"Shift-Backspace\": \"delCharBefore\",\n\t\"Tab\": \"defaultTab\", \"Shift-Tab\": \"indentAuto\",\n\t\"Enter\": \"newlineAndIndent\", \"Insert\": \"toggleOverwrite\",\n\t\"Esc\": \"singleSelection\"\n  }\n  // Note that the save and find-related commands aren't defined by\n  // default. User code or addons can define them. Unknown commands\n  // are simply ignored.\n  keyMap.pcDefault = {\n\t\"Ctrl-A\": \"selectAll\", \"Ctrl-D\": \"deleteLine\", \"Ctrl-Z\": \"undo\", \"Shift-Ctrl-Z\": \"redo\", \"Ctrl-Y\": \"redo\",\n\t\"Ctrl-Home\": \"goDocStart\", \"Ctrl-End\": \"goDocEnd\", \"Ctrl-Up\": \"goLineUp\", \"Ctrl-Down\": \"goLineDown\",\n\t\"Ctrl-Left\": \"goGroupLeft\", \"Ctrl-Right\": \"goGroupRight\", \"Alt-Left\": \"goLineStart\", \"Alt-Right\": \"goLineEnd\",\n\t\"Ctrl-Backspace\": \"delGroupBefore\", \"Ctrl-Delete\": \"delGroupAfter\", \"Ctrl-S\": \"save\", \"Ctrl-F\": \"find\",\n\t\"Ctrl-G\": \"findNext\", \"Shift-Ctrl-G\": \"findPrev\", \"Shift-Ctrl-F\": \"replace\", \"Shift-Ctrl-R\": \"replaceAll\",\n\t\"Ctrl-[\": \"indentLess\", \"Ctrl-]\": \"indentMore\",\n\t\"Ctrl-U\": \"undoSelection\", \"Shift-Ctrl-U\": \"redoSelection\", \"Alt-U\": \"redoSelection\",\n\tfallthrough: \"basic\"\n  }\n  // Very basic readline/emacs-style bindings, which are standard on Mac.\n  keyMap.emacsy = {\n\t\"Ctrl-F\": \"goCharRight\", \"Ctrl-B\": \"goCharLeft\", \"Ctrl-P\": \"goLineUp\", \"Ctrl-N\": \"goLineDown\",\n\t\"Alt-F\": \"goWordRight\", \"Alt-B\": \"goWordLeft\", \"Ctrl-A\": \"goLineStart\", \"Ctrl-E\": \"goLineEnd\",\n\t\"Ctrl-V\": \"goPageDown\", \"Shift-Ctrl-V\": \"goPageUp\", \"Ctrl-D\": \"delCharAfter\", \"Ctrl-H\": \"delCharBefore\",\n\t\"Alt-D\": \"delWordAfter\", \"Alt-Backspace\": \"delWordBefore\", \"Ctrl-K\": \"killLine\", \"Ctrl-T\": \"transposeChars\",\n\t\"Ctrl-O\": \"openLine\"\n  }\n  keyMap.macDefault = {\n\t\"Cmd-A\": \"selectAll\", \"Cmd-D\": \"deleteLine\", \"Cmd-Z\": \"undo\", \"Shift-Cmd-Z\": \"redo\", \"Cmd-Y\": \"redo\",\n\t\"Cmd-Home\": \"goDocStart\", \"Cmd-Up\": \"goDocStart\", \"Cmd-End\": \"goDocEnd\", \"Cmd-Down\": \"goDocEnd\", \"Alt-Left\": \"goGroupLeft\",\n\t\"Alt-Right\": \"goGroupRight\", \"Cmd-Left\": \"goLineLeft\", \"Cmd-Right\": \"goLineRight\", \"Alt-Backspace\": \"delGroupBefore\",\n\t\"Ctrl-Alt-Backspace\": \"delGroupAfter\", \"Alt-Delete\": \"delGroupAfter\", \"Cmd-S\": \"save\", \"Cmd-F\": \"find\",\n\t\"Cmd-G\": \"findNext\", \"Shift-Cmd-G\": \"findPrev\", \"Cmd-Alt-F\": \"replace\", \"Shift-Cmd-Alt-F\": \"replaceAll\",\n\t\"Cmd-[\": \"indentLess\", \"Cmd-]\": \"indentMore\", \"Cmd-Backspace\": \"delWrappedLineLeft\", \"Cmd-Delete\": \"delWrappedLineRight\",\n\t\"Cmd-U\": \"undoSelection\", \"Shift-Cmd-U\": \"redoSelection\", \"Ctrl-Up\": \"goDocStart\", \"Ctrl-Down\": \"goDocEnd\",\n\tfallthrough: [\"basic\", \"emacsy\"]\n  }\n  keyMap[\"default\"] = mac ? keyMap.macDefault : keyMap.pcDefault\n  \n  // KEYMAP DISPATCH\n  \n  function normalizeKeyName(name) {\n\tvar parts = name.split(/-(?!$)/)\n\tname = parts[parts.length - 1]\n\tvar alt, ctrl, shift, cmd\n\tfor (var i = 0; i < parts.length - 1; i++) {\n\t  var mod = parts[i]\n\t  if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true }\n\t  else if (/^a(lt)?$/i.test(mod)) { alt = true }\n\t  else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true }\n\t  else if (/^s(hift)?$/i.test(mod)) { shift = true }\n\t  else { throw new Error(\"Unrecognized modifier name: \" + mod) }\n\t}\n\tif (alt) { name = \"Alt-\" + name }\n\tif (ctrl) { name = \"Ctrl-\" + name }\n\tif (cmd) { name = \"Cmd-\" + name }\n\tif (shift) { name = \"Shift-\" + name }\n\treturn name\n  }\n  \n  // This is a kludge to keep keymaps mostly working as raw objects\n  // (backwards compatibility) while at the same time support features\n  // like normalization and multi-stroke key bindings. It compiles a\n  // new normalized keymap, and then updates the old object to reflect\n  // this.\n  function normalizeKeyMap(keymap) {\n\tvar copy = {}\n\tfor (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {\n\t  var value = keymap[keyname]\n\t  if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }\n\t  if (value == \"...\") { delete keymap[keyname]; continue }\n  \n\t  var keys = map(keyname.split(\" \"), normalizeKeyName)\n\t  for (var i = 0; i < keys.length; i++) {\n\t\tvar val = void 0, name = void 0\n\t\tif (i == keys.length - 1) {\n\t\t  name = keys.join(\" \")\n\t\t  val = value\n\t\t} else {\n\t\t  name = keys.slice(0, i + 1).join(\" \")\n\t\t  val = \"...\"\n\t\t}\n\t\tvar prev = copy[name]\n\t\tif (!prev) { copy[name] = val }\n\t\telse if (prev != val) { throw new Error(\"Inconsistent bindings for \" + name) }\n\t  }\n\t  delete keymap[keyname]\n\t} }\n\tfor (var prop in copy) { keymap[prop] = copy[prop] }\n\treturn keymap\n  }\n  \n  function lookupKey(key, map, handle, context) {\n\tmap = getKeyMap(map)\n\tvar found = map.call ? map.call(key, context) : map[key]\n\tif (found === false) { return \"nothing\" }\n\tif (found === \"...\") { return \"multi\" }\n\tif (found != null && handle(found)) { return \"handled\" }\n  \n\tif (map.fallthrough) {\n\t  if (Object.prototype.toString.call(map.fallthrough) != \"[object Array]\")\n\t\t{ return lookupKey(key, map.fallthrough, handle, context) }\n\t  for (var i = 0; i < map.fallthrough.length; i++) {\n\t\tvar result = lookupKey(key, map.fallthrough[i], handle, context)\n\t\tif (result) { return result }\n\t  }\n\t}\n  }\n  \n  // Modifier key presses don't count as 'real' key presses for the\n  // purpose of keymap fallthrough.\n  function isModifierKey(value) {\n\tvar name = typeof value == \"string\" ? value : keyNames[value.keyCode]\n\treturn name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n  }\n  \n  // Look up the name of a key as indicated by an event object.\n  function keyName(event, noShift) {\n\tif (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n\tvar base = keyNames[event.keyCode], name = base\n\tif (name == null || event.altGraphKey) { return false }\n\tif (event.altKey && base != \"Alt\") { name = \"Alt-\" + name }\n\tif ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != \"Ctrl\") { name = \"Ctrl-\" + name }\n\tif ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != \"Cmd\") { name = \"Cmd-\" + name }\n\tif (!noShift && event.shiftKey && base != \"Shift\") { name = \"Shift-\" + name }\n\treturn name\n  }\n  \n  function getKeyMap(val) {\n\treturn typeof val == \"string\" ? keyMap[val] : val\n  }\n  \n  // Helper for deleting text near the selection(s), used to implement\n  // backspace, delete, and similar functionality.\n  function deleteNearSelection(cm, compute) {\n\tvar ranges = cm.doc.sel.ranges, kill = []\n\t// Build up a set of ranges to kill first, merging overlapping\n\t// ranges.\n\tfor (var i = 0; i < ranges.length; i++) {\n\t  var toKill = compute(ranges[i])\n\t  while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {\n\t\tvar replaced = kill.pop()\n\t\tif (cmp(replaced.from, toKill.from) < 0) {\n\t\t  toKill.from = replaced.from\n\t\t  break\n\t\t}\n\t  }\n\t  kill.push(toKill)\n\t}\n\t// Next, remove those actual ranges.\n\trunInOp(cm, function () {\n\t  for (var i = kill.length - 1; i >= 0; i--)\n\t\t{ replaceRange(cm.doc, \"\", kill[i].from, kill[i].to, \"+delete\") }\n\t  ensureCursorVisible(cm)\n\t})\n  }\n  \n  // Commands are parameter-less actions that can be performed on an\n  // editor, mostly used for keybindings.\n  var commands = {\n\tselectAll: selectAll,\n\tsingleSelection: function (cm) { return cm.setSelection(cm.getCursor(\"anchor\"), cm.getCursor(\"head\"), sel_dontScroll); },\n\tkillLine: function (cm) { return deleteNearSelection(cm, function (range) {\n\t  if (range.empty()) {\n\t\tvar len = getLine(cm.doc, range.head.line).text.length\n\t\tif (range.head.ch == len && range.head.line < cm.lastLine())\n\t\t  { return {from: range.head, to: Pos(range.head.line + 1, 0)} }\n\t\telse\n\t\t  { return {from: range.head, to: Pos(range.head.line, len)} }\n\t  } else {\n\t\treturn {from: range.from(), to: range.to()}\n\t  }\n\t}); },\n\tdeleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({\n\t  from: Pos(range.from().line, 0),\n\t  to: clipPos(cm.doc, Pos(range.to().line + 1, 0))\n\t}); }); },\n\tdelLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({\n\t  from: Pos(range.from().line, 0), to: range.from()\n\t}); }); },\n\tdelWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {\n\t  var top = cm.charCoords(range.head, \"div\").top + 5\n\t  var leftPos = cm.coordsChar({left: 0, top: top}, \"div\")\n\t  return {from: leftPos, to: range.from()}\n\t}); },\n\tdelWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {\n\t  var top = cm.charCoords(range.head, \"div\").top + 5\n\t  var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, \"div\")\n\t  return {from: range.from(), to: rightPos }\n\t}); },\n\tundo: function (cm) { return cm.undo(); },\n\tredo: function (cm) { return cm.redo(); },\n\tundoSelection: function (cm) { return cm.undoSelection(); },\n\tredoSelection: function (cm) { return cm.redoSelection(); },\n\tgoDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },\n\tgoDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },\n\tgoLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },\n\t  {origin: \"+move\", bias: 1}\n\t); },\n\tgoLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },\n\t  {origin: \"+move\", bias: 1}\n\t); },\n\tgoLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },\n\t  {origin: \"+move\", bias: -1}\n\t); },\n\tgoLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {\n\t  var top = cm.charCoords(range.head, \"div\").top + 5\n\t  return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, \"div\")\n\t}, sel_move); },\n\tgoLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {\n\t  var top = cm.charCoords(range.head, \"div\").top + 5\n\t  return cm.coordsChar({left: 0, top: top}, \"div\")\n\t}, sel_move); },\n\tgoLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {\n\t  var top = cm.charCoords(range.head, \"div\").top + 5\n\t  var pos = cm.coordsChar({left: 0, top: top}, \"div\")\n\t  if (pos.ch < cm.getLine(pos.line).search(/\\S/)) { return lineStartSmart(cm, range.head) }\n\t  return pos\n\t}, sel_move); },\n\tgoLineUp: function (cm) { return cm.moveV(-1, \"line\"); },\n\tgoLineDown: function (cm) { return cm.moveV(1, \"line\"); },\n\tgoPageUp: function (cm) { return cm.moveV(-1, \"page\"); },\n\tgoPageDown: function (cm) { return cm.moveV(1, \"page\"); },\n\tgoCharLeft: function (cm) { return cm.moveH(-1, \"char\"); },\n\tgoCharRight: function (cm) { return cm.moveH(1, \"char\"); },\n\tgoColumnLeft: function (cm) { return cm.moveH(-1, \"column\"); },\n\tgoColumnRight: function (cm) { return cm.moveH(1, \"column\"); },\n\tgoWordLeft: function (cm) { return cm.moveH(-1, \"word\"); },\n\tgoGroupRight: function (cm) { return cm.moveH(1, \"group\"); },\n\tgoGroupLeft: function (cm) { return cm.moveH(-1, \"group\"); },\n\tgoWordRight: function (cm) { return cm.moveH(1, \"word\"); },\n\tdelCharBefore: function (cm) { return cm.deleteH(-1, \"char\"); },\n\tdelCharAfter: function (cm) { return cm.deleteH(1, \"char\"); },\n\tdelWordBefore: function (cm) { return cm.deleteH(-1, \"word\"); },\n\tdelWordAfter: function (cm) { return cm.deleteH(1, \"word\"); },\n\tdelGroupBefore: function (cm) { return cm.deleteH(-1, \"group\"); },\n\tdelGroupAfter: function (cm) { return cm.deleteH(1, \"group\"); },\n\tindentAuto: function (cm) { return cm.indentSelection(\"smart\"); },\n\tindentMore: function (cm) { return cm.indentSelection(\"add\"); },\n\tindentLess: function (cm) { return cm.indentSelection(\"subtract\"); },\n\tinsertTab: function (cm) { return cm.replaceSelection(\"\\t\"); },\n\tinsertSoftTab: function (cm) {\n\t  var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize\n\t  for (var i = 0; i < ranges.length; i++) {\n\t\tvar pos = ranges[i].from()\n\t\tvar col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)\n\t\tspaces.push(spaceStr(tabSize - col % tabSize))\n\t  }\n\t  cm.replaceSelections(spaces)\n\t},\n\tdefaultTab: function (cm) {\n\t  if (cm.somethingSelected()) { cm.indentSelection(\"add\") }\n\t  else { cm.execCommand(\"insertTab\") }\n\t},\n\t// Swap the two chars left and right of each selection's head.\n\t// Move cursor behind the two swapped characters afterwards.\n\t//\n\t// Doesn't consider line feeds a character.\n\t// Doesn't scan more than one line above to find a character.\n\t// Doesn't do anything on an empty line.\n\t// Doesn't do anything with non-empty selections.\n\ttransposeChars: function (cm) { return runInOp(cm, function () {\n\t  var ranges = cm.listSelections(), newSel = []\n\t  for (var i = 0; i < ranges.length; i++) {\n\t\tif (!ranges[i].empty()) { continue }\n\t\tvar cur = ranges[i].head, line = getLine(cm.doc, cur.line).text\n\t\tif (line) {\n\t\t  if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1) }\n\t\t  if (cur.ch > 0) {\n\t\t\tcur = new Pos(cur.line, cur.ch + 1)\n\t\t\tcm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),\n\t\t\t\t\t\t\tPos(cur.line, cur.ch - 2), cur, \"+transpose\")\n\t\t  } else if (cur.line > cm.doc.first) {\n\t\t\tvar prev = getLine(cm.doc, cur.line - 1).text\n\t\t\tif (prev) {\n\t\t\t  cur = new Pos(cur.line, 1)\n\t\t\t  cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +\n\t\t\t\t\t\t\t  prev.charAt(prev.length - 1),\n\t\t\t\t\t\t\t  Pos(cur.line - 1, prev.length - 1), cur, \"+transpose\")\n\t\t\t}\n\t\t  }\n\t\t}\n\t\tnewSel.push(new Range(cur, cur))\n\t  }\n\t  cm.setSelections(newSel)\n\t}); },\n\tnewlineAndIndent: function (cm) { return runInOp(cm, function () {\n\t  var sels = cm.listSelections()\n\t  for (var i = sels.length - 1; i >= 0; i--)\n\t\t{ cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, \"+input\") }\n\t  sels = cm.listSelections()\n\t  for (var i$1 = 0; i$1 < sels.length; i$1++)\n\t\t{ cm.indentLine(sels[i$1].from().line, null, true) }\n\t  ensureCursorVisible(cm)\n\t}); },\n\topenLine: function (cm) { return cm.replaceSelection(\"\\n\", \"start\"); },\n\ttoggleOverwrite: function (cm) { return cm.toggleOverwrite(); }\n  }\n  \n  \n  function lineStart(cm, lineN) {\n\tvar line = getLine(cm.doc, lineN)\n\tvar visual = visualLine(line)\n\tif (visual != line) { lineN = lineNo(visual) }\n\tvar order = getOrder(visual)\n\tvar ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual)\n\treturn Pos(lineN, ch)\n  }\n  function lineEnd(cm, lineN) {\n\tvar merged, line = getLine(cm.doc, lineN)\n\twhile (merged = collapsedSpanAtEnd(line)) {\n\t  line = merged.find(1, true).line\n\t  lineN = null\n\t}\n\tvar order = getOrder(line)\n\tvar ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line)\n\treturn Pos(lineN == null ? lineNo(line) : lineN, ch)\n  }\n  function lineStartSmart(cm, pos) {\n\tvar start = lineStart(cm, pos.line)\n\tvar line = getLine(cm.doc, start.line)\n\tvar order = getOrder(line)\n\tif (!order || order[0].level == 0) {\n\t  var firstNonWS = Math.max(0, line.text.search(/\\S/))\n\t  var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch\n\t  return Pos(start.line, inWS ? 0 : firstNonWS)\n\t}\n\treturn start\n  }\n  \n  // Run a handler that was bound to a key.\n  function doHandleBinding(cm, bound, dropShift) {\n\tif (typeof bound == \"string\") {\n\t  bound = commands[bound]\n\t  if (!bound) { return false }\n\t}\n\t// Ensure previous input has been read, so that the handler sees a\n\t// consistent view of the document\n\tcm.display.input.ensurePolled()\n\tvar prevShift = cm.display.shift, done = false\n\ttry {\n\t  if (cm.isReadOnly()) { cm.state.suppressEdits = true }\n\t  if (dropShift) { cm.display.shift = false }\n\t  done = bound(cm) != Pass\n\t} finally {\n\t  cm.display.shift = prevShift\n\t  cm.state.suppressEdits = false\n\t}\n\treturn done\n  }\n  \n  function lookupKeyForEditor(cm, name, handle) {\n\tfor (var i = 0; i < cm.state.keyMaps.length; i++) {\n\t  var result = lookupKey(name, cm.state.keyMaps[i], handle, cm)\n\t  if (result) { return result }\n\t}\n\treturn (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))\n\t  || lookupKey(name, cm.options.keyMap, handle, cm)\n  }\n  \n  var stopSeq = new Delayed\n  function dispatchKey(cm, name, e, handle) {\n\tvar seq = cm.state.keySeq\n\tif (seq) {\n\t  if (isModifierKey(name)) { return \"handled\" }\n\t  stopSeq.set(50, function () {\n\t\tif (cm.state.keySeq == seq) {\n\t\t  cm.state.keySeq = null\n\t\t  cm.display.input.reset()\n\t\t}\n\t  })\n\t  name = seq + \" \" + name\n\t}\n\tvar result = lookupKeyForEditor(cm, name, handle)\n  \n\tif (result == \"multi\")\n\t  { cm.state.keySeq = name }\n\tif (result == \"handled\")\n\t  { signalLater(cm, \"keyHandled\", cm, name, e) }\n  \n\tif (result == \"handled\" || result == \"multi\") {\n\t  e_preventDefault(e)\n\t  restartBlink(cm)\n\t}\n  \n\tif (seq && !result && /\\'$/.test(name)) {\n\t  e_preventDefault(e)\n\t  return true\n\t}\n\treturn !!result\n  }\n  \n  // Handle a key from the keydown event.\n  function handleKeyBinding(cm, e) {\n\tvar name = keyName(e, true)\n\tif (!name) { return false }\n  \n\tif (e.shiftKey && !cm.state.keySeq) {\n\t  // First try to resolve full name (including 'Shift-'). Failing\n\t  // that, see if there is a cursor-motion command (starting with\n\t  // 'go') bound to the keyname without 'Shift-'.\n\t  return dispatchKey(cm, \"Shift-\" + name, e, function (b) { return doHandleBinding(cm, b, true); })\n\t\t  || dispatchKey(cm, name, e, function (b) {\n\t\t\t   if (typeof b == \"string\" ? /^go[A-Z]/.test(b) : b.motion)\n\t\t\t\t { return doHandleBinding(cm, b) }\n\t\t\t })\n\t} else {\n\t  return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })\n\t}\n  }\n  \n  // Handle a key from the keypress event\n  function handleCharBinding(cm, e, ch) {\n\treturn dispatchKey(cm, \"'\" + ch + \"'\", e, function (b) { return doHandleBinding(cm, b, true); })\n  }\n  \n  var lastStoppedKey = null\n  function onKeyDown(e) {\n\tvar cm = this\n\tcm.curOp.focus = activeElt()\n\tif (signalDOMEvent(cm, e)) { return }\n\t// IE does strange things with escape.\n\tif (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false }\n\tvar code = e.keyCode\n\tcm.display.shift = code == 16 || e.shiftKey\n\tvar handled = handleKeyBinding(cm, e)\n\tif (presto) {\n\t  lastStoppedKey = handled ? code : null\n\t  // Opera has no cut event... we try to at least catch the key combo\n\t  if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))\n\t\t{ cm.replaceSelection(\"\", null, \"cut\") }\n\t}\n  \n\t// Turn mouse into crosshair when Alt is held on Mac.\n\tif (code == 18 && !/\\bCodeMirror-crosshair\\b/.test(cm.display.lineDiv.className))\n\t  { showCrossHair(cm) }\n  }\n  \n  function showCrossHair(cm) {\n\tvar lineDiv = cm.display.lineDiv\n\taddClass(lineDiv, \"CodeMirror-crosshair\")\n  \n\tfunction up(e) {\n\t  if (e.keyCode == 18 || !e.altKey) {\n\t\trmClass(lineDiv, \"CodeMirror-crosshair\")\n\t\toff(document, \"keyup\", up)\n\t\toff(document, \"mouseover\", up)\n\t  }\n\t}\n\ton(document, \"keyup\", up)\n\ton(document, \"mouseover\", up)\n  }\n  \n  function onKeyUp(e) {\n\tif (e.keyCode == 16) { this.doc.sel.shift = false }\n\tsignalDOMEvent(this, e)\n  }\n  \n  function onKeyPress(e) {\n\tvar cm = this\n\tif (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }\n\tvar keyCode = e.keyCode, charCode = e.charCode\n\tif (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}\n\tif ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }\n\tvar ch = String.fromCharCode(charCode == null ? keyCode : charCode)\n\t// Some browsers fire keypress events for backspace\n\tif (ch == \"\\x08\") { return }\n\tif (handleCharBinding(cm, e, ch)) { return }\n\tcm.display.input.onKeyPress(e)\n  }\n  \n  // A mouse down can be a single click, double click, triple click,\n  // start of selection drag, start of text drag, new cursor\n  // (ctrl-click), rectangle drag (alt-drag), or xwin\n  // middle-click-paste. Or it might be a click on something we should\n  // not interfere with, such as a scrollbar or widget.\n  function onMouseDown(e) {\n\tvar cm = this, display = cm.display\n\tif (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }\n\tdisplay.shift = e.shiftKey\n  \n\tif (eventInWidget(display, e)) {\n\t  if (!webkit) {\n\t\t// Briefly turn off draggability, to allow widgets to do\n\t\t// normal dragging things.\n\t\tdisplay.scroller.draggable = false\n\t\tsetTimeout(function () { return display.scroller.draggable = true; }, 100)\n\t  }\n\t  return\n\t}\n\tif (clickInGutter(cm, e)) { return }\n\tvar start = posFromMouse(cm, e)\n\twindow.focus()\n  \n\tswitch (e_button(e)) {\n\tcase 1:\n\t  // #3261: make sure, that we're not starting a second selection\n\t  if (cm.state.selectingText)\n\t\t{ cm.state.selectingText(e) }\n\t  else if (start)\n\t\t{ leftButtonDown(cm, e, start) }\n\t  else if (e_target(e) == display.scroller)\n\t\t{ e_preventDefault(e) }\n\t  break\n\tcase 2:\n\t  if (webkit) { cm.state.lastMiddleDown = +new Date }\n\t  if (start) { extendSelection(cm.doc, start) }\n\t  setTimeout(function () { return display.input.focus(); }, 20)\n\t  e_preventDefault(e)\n\t  break\n\tcase 3:\n\t  if (captureRightClick) { onContextMenu(cm, e) }\n\t  else { delayBlurEvent(cm) }\n\t  break\n\t}\n  }\n  \n  var lastClick;\n  var lastDoubleClick;\n  function leftButtonDown(cm, e, start) {\n\tif (ie) { setTimeout(bind(ensureFocus, cm), 0) }\n\telse { cm.curOp.focus = activeElt() }\n  \n\tvar now = +new Date, type\n\tif (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {\n\t  type = \"triple\"\n\t} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {\n\t  type = \"double\"\n\t  lastDoubleClick = {time: now, pos: start}\n\t} else {\n\t  type = \"single\"\n\t  lastClick = {time: now, pos: start}\n\t}\n  \n\tvar sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained\n\tif (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&\n\t\ttype == \"single\" && (contained = sel.contains(start)) > -1 &&\n\t\t(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&\n\t\t(cmp(contained.to(), start) > 0 || start.xRel < 0))\n\t  { leftButtonStartDrag(cm, e, start, modifier) }\n\telse\n\t  { leftButtonSelect(cm, e, start, type, modifier) }\n  }\n  \n  // Start a text drag. When it ends, see if any dragging actually\n  // happen, and treat as a click if it didn't.\n  function leftButtonStartDrag(cm, e, start, modifier) {\n\tvar display = cm.display, startTime = +new Date\n\tvar dragEnd = operation(cm, function (e2) {\n\t  if (webkit) { display.scroller.draggable = false }\n\t  cm.state.draggingText = false\n\t  off(document, \"mouseup\", dragEnd)\n\t  off(display.scroller, \"drop\", dragEnd)\n\t  if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {\n\t\te_preventDefault(e2)\n\t\tif (!modifier && +new Date - 200 < startTime)\n\t\t  { extendSelection(cm.doc, start) }\n\t\t// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)\n\t\tif (webkit || ie && ie_version == 9)\n\t\t  { setTimeout(function () {document.body.focus(); display.input.focus()}, 20) }\n\t\telse\n\t\t  { display.input.focus() }\n\t  }\n\t})\n\t// Let the drag handler handle this.\n\tif (webkit) { display.scroller.draggable = true }\n\tcm.state.draggingText = dragEnd\n\tdragEnd.copy = mac ? e.altKey : e.ctrlKey\n\t// IE's approach to draggable\n\tif (display.scroller.dragDrop) { display.scroller.dragDrop() }\n\ton(document, \"mouseup\", dragEnd)\n\ton(display.scroller, \"drop\", dragEnd)\n  }\n  \n  // Normal selection, as opposed to text dragging.\n  function leftButtonSelect(cm, e, start, type, addNew) {\n\tvar display = cm.display, doc = cm.doc\n\te_preventDefault(e)\n  \n\tvar ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges\n\tif (addNew && !e.shiftKey) {\n\t  ourIndex = doc.sel.contains(start)\n\t  if (ourIndex > -1)\n\t\t{ ourRange = ranges[ourIndex] }\n\t  else\n\t\t{ ourRange = new Range(start, start) }\n\t} else {\n\t  ourRange = doc.sel.primary()\n\t  ourIndex = doc.sel.primIndex\n\t}\n  \n\tif (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {\n\t  type = \"rect\"\n\t  if (!addNew) { ourRange = new Range(start, start) }\n\t  start = posFromMouse(cm, e, true, true)\n\t  ourIndex = -1\n\t} else if (type == \"double\") {\n\t  var word = cm.findWordAt(start)\n\t  if (cm.display.shift || doc.extend)\n\t\t{ ourRange = extendRange(doc, ourRange, word.anchor, word.head) }\n\t  else\n\t\t{ ourRange = word }\n\t} else if (type == \"triple\") {\n\t  var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)))\n\t  if (cm.display.shift || doc.extend)\n\t\t{ ourRange = extendRange(doc, ourRange, line.anchor, line.head) }\n\t  else\n\t\t{ ourRange = line }\n\t} else {\n\t  ourRange = extendRange(doc, ourRange, start)\n\t}\n  \n\tif (!addNew) {\n\t  ourIndex = 0\n\t  setSelection(doc, new Selection([ourRange], 0), sel_mouse)\n\t  startSel = doc.sel\n\t} else if (ourIndex == -1) {\n\t  ourIndex = ranges.length\n\t  setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),\n\t\t\t\t   {scroll: false, origin: \"*mouse\"})\n\t} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == \"single\" && !e.shiftKey) {\n\t  setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),\n\t\t\t\t   {scroll: false, origin: \"*mouse\"})\n\t  startSel = doc.sel\n\t} else {\n\t  replaceOneSelection(doc, ourIndex, ourRange, sel_mouse)\n\t}\n  \n\tvar lastPos = start\n\tfunction extendTo(pos) {\n\t  if (cmp(lastPos, pos) == 0) { return }\n\t  lastPos = pos\n  \n\t  if (type == \"rect\") {\n\t\tvar ranges = [], tabSize = cm.options.tabSize\n\t\tvar startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize)\n\t\tvar posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize)\n\t\tvar left = Math.min(startCol, posCol), right = Math.max(startCol, posCol)\n\t\tfor (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));\n\t\t\t line <= end; line++) {\n\t\t  var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize)\n\t\t  if (left == right)\n\t\t\t{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) }\n\t\t  else if (text.length > leftPos)\n\t\t\t{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))) }\n\t\t}\n\t\tif (!ranges.length) { ranges.push(new Range(start, start)) }\n\t\tsetSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),\n\t\t\t\t\t {origin: \"*mouse\", scroll: false})\n\t\tcm.scrollIntoView(pos)\n\t  } else {\n\t\tvar oldRange = ourRange\n\t\tvar anchor = oldRange.anchor, head = pos\n\t\tif (type != \"single\") {\n\t\t  var range\n\t\t  if (type == \"double\")\n\t\t\t{ range = cm.findWordAt(pos) }\n\t\t  else\n\t\t\t{ range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))) }\n\t\t  if (cmp(range.anchor, anchor) > 0) {\n\t\t\thead = range.head\n\t\t\tanchor = minPos(oldRange.from(), range.anchor)\n\t\t  } else {\n\t\t\thead = range.anchor\n\t\t\tanchor = maxPos(oldRange.to(), range.head)\n\t\t  }\n\t\t}\n\t\tvar ranges$1 = startSel.ranges.slice(0)\n\t\tranges$1[ourIndex] = new Range(clipPos(doc, anchor), head)\n\t\tsetSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse)\n\t  }\n\t}\n  \n\tvar editorSize = display.wrapper.getBoundingClientRect()\n\t// Used to ensure timeout re-tries don't fire when another extend\n\t// happened in the meantime (clearTimeout isn't reliable -- at\n\t// least on Chrome, the timeouts still happen even when cleared,\n\t// if the clear happens after their scheduled firing time).\n\tvar counter = 0\n  \n\tfunction extend(e) {\n\t  var curCount = ++counter\n\t  var cur = posFromMouse(cm, e, true, type == \"rect\")\n\t  if (!cur) { return }\n\t  if (cmp(cur, lastPos) != 0) {\n\t\tcm.curOp.focus = activeElt()\n\t\textendTo(cur)\n\t\tvar visible = visibleLines(display, doc)\n\t\tif (cur.line >= visible.to || cur.line < visible.from)\n\t\t  { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e) }}), 150) }\n\t  } else {\n\t\tvar outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0\n\t\tif (outside) { setTimeout(operation(cm, function () {\n\t\t  if (counter != curCount) { return }\n\t\t  display.scroller.scrollTop += outside\n\t\t  extend(e)\n\t\t}), 50) }\n\t  }\n\t}\n  \n\tfunction done(e) {\n\t  cm.state.selectingText = false\n\t  counter = Infinity\n\t  e_preventDefault(e)\n\t  display.input.focus()\n\t  off(document, \"mousemove\", move)\n\t  off(document, \"mouseup\", up)\n\t  doc.history.lastSelOrigin = null\n\t}\n  \n\tvar move = operation(cm, function (e) {\n\t  if (!e_button(e)) { done(e) }\n\t  else { extend(e) }\n\t})\n\tvar up = operation(cm, done)\n\tcm.state.selectingText = up\n\ton(document, \"mousemove\", move)\n\ton(document, \"mouseup\", up)\n  }\n  \n  \n  // Determines whether an event happened in the gutter, and fires the\n  // handlers for the corresponding event.\n  function gutterEvent(cm, e, type, prevent) {\n\tvar mX, mY\n\ttry { mX = e.clientX; mY = e.clientY }\n\tcatch(e) { return false }\n\tif (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }\n\tif (prevent) { e_preventDefault(e) }\n  \n\tvar display = cm.display\n\tvar lineBox = display.lineDiv.getBoundingClientRect()\n  \n\tif (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }\n\tmY -= lineBox.top - display.viewOffset\n  \n\tfor (var i = 0; i < cm.options.gutters.length; ++i) {\n\t  var g = display.gutters.childNodes[i]\n\t  if (g && g.getBoundingClientRect().right >= mX) {\n\t\tvar line = lineAtHeight(cm.doc, mY)\n\t\tvar gutter = cm.options.gutters[i]\n\t\tsignal(cm, type, cm, line, gutter, e)\n\t\treturn e_defaultPrevented(e)\n\t  }\n\t}\n  }\n  \n  function clickInGutter(cm, e) {\n\treturn gutterEvent(cm, e, \"gutterClick\", true)\n  }\n  \n  // CONTEXT MENU HANDLING\n  \n  // To make the context menu work, we need to briefly unhide the\n  // textarea (making it as unobtrusive as possible) to let the\n  // right-click take effect on it.\n  function onContextMenu(cm, e) {\n\tif (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }\n\tif (signalDOMEvent(cm, e, \"contextmenu\")) { return }\n\tcm.display.input.onContextMenu(e)\n  }\n  \n  function contextMenuInGutter(cm, e) {\n\tif (!hasHandler(cm, \"gutterContextMenu\")) { return false }\n\treturn gutterEvent(cm, e, \"gutterContextMenu\", false)\n  }\n  \n  function themeChanged(cm) {\n\tcm.display.wrapper.className = cm.display.wrapper.className.replace(/\\s*cm-s-\\S+/g, \"\") +\n\t  cm.options.theme.replace(/(^|\\s)\\s*/g, \" cm-s-\")\n\tclearCaches(cm)\n  }\n  \n  var Init = {toString: function(){return \"CodeMirror.Init\"}}\n  \n  var defaults = {}\n  var optionHandlers = {}\n  \n  function defineOptions(CodeMirror) {\n\tvar optionHandlers = CodeMirror.optionHandlers\n  \n\tfunction option(name, deflt, handle, notOnInit) {\n\t  CodeMirror.defaults[name] = deflt\n\t  if (handle) { optionHandlers[name] =\n\t\tnotOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old) }} : handle }\n\t}\n  \n\tCodeMirror.defineOption = option\n  \n\t// Passed to option handlers when there is no old value.\n\tCodeMirror.Init = Init\n  \n\t// These two are, on init, called from the constructor because they\n\t// have to be initialized before the editor can start at all.\n\toption(\"value\", \"\", function (cm, val) { return cm.setValue(val); }, true)\n\toption(\"mode\", null, function (cm, val) {\n\t  cm.doc.modeOption = val\n\t  loadMode(cm)\n\t}, true)\n  \n\toption(\"indentUnit\", 2, loadMode, true)\n\toption(\"indentWithTabs\", false)\n\toption(\"smartIndent\", true)\n\toption(\"tabSize\", 4, function (cm) {\n\t  resetModeState(cm)\n\t  clearCaches(cm)\n\t  regChange(cm)\n\t}, true)\n\toption(\"lineSeparator\", null, function (cm, val) {\n\t  cm.doc.lineSep = val\n\t  if (!val) { return }\n\t  var newBreaks = [], lineNo = cm.doc.first\n\t  cm.doc.iter(function (line) {\n\t\tfor (var pos = 0;;) {\n\t\t  var found = line.text.indexOf(val, pos)\n\t\t  if (found == -1) { break }\n\t\t  pos = found + val.length\n\t\t  newBreaks.push(Pos(lineNo, found))\n\t\t}\n\t\tlineNo++\n\t  })\n\t  for (var i = newBreaks.length - 1; i >= 0; i--)\n\t\t{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }\n\t})\n\toption(\"specialChars\", /[\\u0000-\\u001f\\u007f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]/g, function (cm, val, old) {\n\t  cm.state.specialChars = new RegExp(val.source + (val.test(\"\\t\") ? \"\" : \"|\\t\"), \"g\")\n\t  if (old != Init) { cm.refresh() }\n\t})\n\toption(\"specialCharPlaceholder\", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true)\n\toption(\"electricChars\", true)\n\toption(\"inputStyle\", mobile ? \"contenteditable\" : \"textarea\", function () {\n\t  throw new Error(\"inputStyle can not (yet) be changed in a running editor\") // FIXME\n\t}, true)\n\toption(\"spellcheck\", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true)\n\toption(\"rtlMoveVisually\", !windows)\n\toption(\"wholeLineUpdateBefore\", true)\n  \n\toption(\"theme\", \"default\", function (cm) {\n\t  themeChanged(cm)\n\t  guttersChanged(cm)\n\t}, true)\n\toption(\"keyMap\", \"default\", function (cm, val, old) {\n\t  var next = getKeyMap(val)\n\t  var prev = old != Init && getKeyMap(old)\n\t  if (prev && prev.detach) { prev.detach(cm, next) }\n\t  if (next.attach) { next.attach(cm, prev || null) }\n\t})\n\toption(\"extraKeys\", null)\n  \n\toption(\"lineWrapping\", false, wrappingChanged, true)\n\toption(\"gutters\", [], function (cm) {\n\t  setGuttersForLineNumbers(cm.options)\n\t  guttersChanged(cm)\n\t}, true)\n\toption(\"fixedGutter\", true, function (cm, val) {\n\t  cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + \"px\" : \"0\"\n\t  cm.refresh()\n\t}, true)\n\toption(\"coverGutterNextToScrollbar\", false, function (cm) { return updateScrollbars(cm); }, true)\n\toption(\"scrollbarStyle\", \"native\", function (cm) {\n\t  initScrollbars(cm)\n\t  updateScrollbars(cm)\n\t  cm.display.scrollbars.setScrollTop(cm.doc.scrollTop)\n\t  cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)\n\t}, true)\n\toption(\"lineNumbers\", false, function (cm) {\n\t  setGuttersForLineNumbers(cm.options)\n\t  guttersChanged(cm)\n\t}, true)\n\toption(\"firstLineNumber\", 1, guttersChanged, true)\n\toption(\"lineNumberFormatter\", function (integer) { return integer; }, guttersChanged, true)\n\toption(\"showCursorWhenSelecting\", false, updateSelection, true)\n  \n\toption(\"resetSelectionOnContextMenu\", true)\n\toption(\"lineWiseCopyCut\", true)\n  \n\toption(\"readOnly\", false, function (cm, val) {\n\t  if (val == \"nocursor\") {\n\t\tonBlur(cm)\n\t\tcm.display.input.blur()\n\t\tcm.display.disabled = true\n\t  } else {\n\t\tcm.display.disabled = false\n\t  }\n\t  cm.display.input.readOnlyChanged(val)\n\t})\n\toption(\"disableInput\", false, function (cm, val) {if (!val) { cm.display.input.reset() }}, true)\n\toption(\"dragDrop\", true, dragDropChanged)\n\toption(\"allowDropFileTypes\", null)\n  \n\toption(\"cursorBlinkRate\", 530)\n\toption(\"cursorScrollMargin\", 0)\n\toption(\"cursorHeight\", 1, updateSelection, true)\n\toption(\"singleCursorHeightPerLine\", true, updateSelection, true)\n\toption(\"workTime\", 100)\n\toption(\"workDelay\", 100)\n\toption(\"flattenSpans\", true, resetModeState, true)\n\toption(\"addModeClass\", false, resetModeState, true)\n\toption(\"pollInterval\", 100)\n\toption(\"undoDepth\", 200, function (cm, val) { return cm.doc.history.undoDepth = val; })\n\toption(\"historyEventDelay\", 1250)\n\toption(\"viewportMargin\", 10, function (cm) { return cm.refresh(); }, true)\n\toption(\"maxHighlightLength\", 10000, resetModeState, true)\n\toption(\"moveInputWithCursor\", true, function (cm, val) {\n\t  if (!val) { cm.display.input.resetPosition() }\n\t})\n  \n\toption(\"tabindex\", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || \"\"; })\n\toption(\"autofocus\", null)\n  }\n  \n  function guttersChanged(cm) {\n\tupdateGutters(cm)\n\tregChange(cm)\n\tsetTimeout(function () { return alignHorizontally(cm); }, 20)\n  }\n  \n  function dragDropChanged(cm, value, old) {\n\tvar wasOn = old && old != Init\n\tif (!value != !wasOn) {\n\t  var funcs = cm.display.dragFunctions\n\t  var toggle = value ? on : off\n\t  toggle(cm.display.scroller, \"dragstart\", funcs.start)\n\t  toggle(cm.display.scroller, \"dragenter\", funcs.enter)\n\t  toggle(cm.display.scroller, \"dragover\", funcs.over)\n\t  toggle(cm.display.scroller, \"dragleave\", funcs.leave)\n\t  toggle(cm.display.scroller, \"drop\", funcs.drop)\n\t}\n  }\n  \n  function wrappingChanged(cm) {\n\tif (cm.options.lineWrapping) {\n\t  addClass(cm.display.wrapper, \"CodeMirror-wrap\")\n\t  cm.display.sizer.style.minWidth = \"\"\n\t  cm.display.sizerWidth = null\n\t} else {\n\t  rmClass(cm.display.wrapper, \"CodeMirror-wrap\")\n\t  findMaxLine(cm)\n\t}\n\testimateLineHeights(cm)\n\tregChange(cm)\n\tclearCaches(cm)\n\tsetTimeout(function () { return updateScrollbars(cm); }, 100)\n  }\n  \n  // A CodeMirror instance represents an editor. This is the object\n  // that user code is usually dealing with.\n  \n  function CodeMirror(place, options) {\n\tvar this$1 = this;\n  \n\tif (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }\n  \n\tthis.options = options = options ? copyObj(options) : {}\n\t// Determine effective options based on given values and defaults.\n\tcopyObj(defaults, options, false)\n\tsetGuttersForLineNumbers(options)\n  \n\tvar doc = options.value\n\tif (typeof doc == \"string\") { doc = new Doc(doc, options.mode, null, options.lineSeparator) }\n\tthis.doc = doc\n  \n\tvar input = new CodeMirror.inputStyles[options.inputStyle](this)\n\tvar display = this.display = new Display(place, doc, input)\n\tdisplay.wrapper.CodeMirror = this\n\tupdateGutters(this)\n\tthemeChanged(this)\n\tif (options.lineWrapping)\n\t  { this.display.wrapper.className += \" CodeMirror-wrap\" }\n\tif (options.autofocus && !mobile) { display.input.focus() }\n\tinitScrollbars(this)\n  \n\tthis.state = {\n\t  keyMaps: [],  // stores maps added by addKeyMap\n\t  overlays: [], // highlighting overlays, as added by addOverlay\n\t  modeGen: 0,   // bumped when mode/overlay changes, used to invalidate highlighting info\n\t  overwrite: false,\n\t  delayingBlurEvent: false,\n\t  focused: false,\n\t  suppressEdits: false, // used to disable editing during key handlers when in readOnly mode\n\t  pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll\n\t  selectingText: false,\n\t  draggingText: false,\n\t  highlight: new Delayed(), // stores highlight worker timeout\n\t  keySeq: null,  // Unfinished key sequence\n\t  specialChars: null\n\t}\n  \n\t// Override magic textarea content restore that IE sometimes does\n\t// on our hidden textarea on reload\n\tif (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }\n  \n\tregisterEventHandlers(this)\n\tensureGlobalHandlers()\n  \n\tstartOperation(this)\n\tthis.curOp.forceUpdate = true\n\tattachDoc(this, doc)\n  \n\tif ((options.autofocus && !mobile) || this.hasFocus())\n\t  { setTimeout(bind(onFocus, this), 20) }\n\telse\n\t  { onBlur(this) }\n  \n\tfor (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))\n\t  { optionHandlers[opt](this$1, options[opt], Init) } }\n\tmaybeUpdateLineNumberWidth(this)\n\tif (options.finishInit) { options.finishInit(this) }\n\tfor (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1) }\n\tendOperation(this)\n\t// Suppress optimizelegibility in Webkit, since it breaks text\n\t// measuring on line wrapping boundaries.\n\tif (webkit && options.lineWrapping &&\n\t\tgetComputedStyle(display.lineDiv).textRendering == \"optimizelegibility\")\n\t  { display.lineDiv.style.textRendering = \"auto\" }\n  }\n  \n  // The default configuration options.\n  CodeMirror.defaults = defaults\n  // Functions to run when options are changed.\n  CodeMirror.optionHandlers = optionHandlers\n  \n  // Attach the necessary event handlers when initializing the editor\n  function registerEventHandlers(cm) {\n\tvar d = cm.display\n\ton(d.scroller, \"mousedown\", operation(cm, onMouseDown))\n\t// Older IE's will not fire a second mousedown for a double click\n\tif (ie && ie_version < 11)\n\t  { on(d.scroller, \"dblclick\", operation(cm, function (e) {\n\t\tif (signalDOMEvent(cm, e)) { return }\n\t\tvar pos = posFromMouse(cm, e)\n\t\tif (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }\n\t\te_preventDefault(e)\n\t\tvar word = cm.findWordAt(pos)\n\t\textendSelection(cm.doc, word.anchor, word.head)\n\t  })) }\n\telse\n\t  { on(d.scroller, \"dblclick\", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }) }\n\t// Some browsers fire contextmenu *after* opening the menu, at\n\t// which point we can't mess with it anymore. Context menu is\n\t// handled in onMouseDown for these browsers.\n\tif (!captureRightClick) { on(d.scroller, \"contextmenu\", function (e) { return onContextMenu(cm, e); }) }\n  \n\t// Used to suppress mouse event handling when a touch happens\n\tvar touchFinished, prevTouch = {end: 0}\n\tfunction finishTouch() {\n\t  if (d.activeTouch) {\n\t\ttouchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000)\n\t\tprevTouch = d.activeTouch\n\t\tprevTouch.end = +new Date\n\t  }\n\t}\n\tfunction isMouseLikeTouchEvent(e) {\n\t  if (e.touches.length != 1) { return false }\n\t  var touch = e.touches[0]\n\t  return touch.radiusX <= 1 && touch.radiusY <= 1\n\t}\n\tfunction farAway(touch, other) {\n\t  if (other.left == null) { return true }\n\t  var dx = other.left - touch.left, dy = other.top - touch.top\n\t  return dx * dx + dy * dy > 20 * 20\n\t}\n\ton(d.scroller, \"touchstart\", function (e) {\n\t  if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {\n\t\tclearTimeout(touchFinished)\n\t\tvar now = +new Date\n\t\td.activeTouch = {start: now, moved: false,\n\t\t\t\t\t\t prev: now - prevTouch.end <= 300 ? prevTouch : null}\n\t\tif (e.touches.length == 1) {\n\t\t  d.activeTouch.left = e.touches[0].pageX\n\t\t  d.activeTouch.top = e.touches[0].pageY\n\t\t}\n\t  }\n\t})\n\ton(d.scroller, \"touchmove\", function () {\n\t  if (d.activeTouch) { d.activeTouch.moved = true }\n\t})\n\ton(d.scroller, \"touchend\", function (e) {\n\t  var touch = d.activeTouch\n\t  if (touch && !eventInWidget(d, e) && touch.left != null &&\n\t\t  !touch.moved && new Date - touch.start < 300) {\n\t\tvar pos = cm.coordsChar(d.activeTouch, \"page\"), range\n\t\tif (!touch.prev || farAway(touch, touch.prev)) // Single tap\n\t\t  { range = new Range(pos, pos) }\n\t\telse if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap\n\t\t  { range = cm.findWordAt(pos) }\n\t\telse // Triple tap\n\t\t  { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }\n\t\tcm.setSelection(range.anchor, range.head)\n\t\tcm.focus()\n\t\te_preventDefault(e)\n\t  }\n\t  finishTouch()\n\t})\n\ton(d.scroller, \"touchcancel\", finishTouch)\n  \n\t// Sync scrolling between fake scrollbars and real scrollable\n\t// area, ensure viewport is updated when scrolling.\n\ton(d.scroller, \"scroll\", function () {\n\t  if (d.scroller.clientHeight) {\n\t\tsetScrollTop(cm, d.scroller.scrollTop)\n\t\tsetScrollLeft(cm, d.scroller.scrollLeft, true)\n\t\tsignal(cm, \"scroll\", cm)\n\t  }\n\t})\n  \n\t// Listen to wheel events in order to try and update the viewport on time.\n\ton(d.scroller, \"mousewheel\", function (e) { return onScrollWheel(cm, e); })\n\ton(d.scroller, \"DOMMouseScroll\", function (e) { return onScrollWheel(cm, e); })\n  \n\t// Prevent wrapper from ever scrolling\n\ton(d.wrapper, \"scroll\", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; })\n  \n\td.dragFunctions = {\n\t  enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e) }},\n\t  over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},\n\t  start: function (e) { return onDragStart(cm, e); },\n\t  drop: operation(cm, onDrop),\n\t  leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}\n\t}\n  \n\tvar inp = d.input.getField()\n\ton(inp, \"keyup\", function (e) { return onKeyUp.call(cm, e); })\n\ton(inp, \"keydown\", operation(cm, onKeyDown))\n\ton(inp, \"keypress\", operation(cm, onKeyPress))\n\ton(inp, \"focus\", function (e) { return onFocus(cm, e); })\n\ton(inp, \"blur\", function (e) { return onBlur(cm, e); })\n  }\n  \n  var initHooks = []\n  CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }\n  \n  // Indent the given line. The how parameter can be \"smart\",\n  // \"add\"/null, \"subtract\", or \"prev\". When aggressive is false\n  // (typically set to true for forced single-line indents), empty\n  // lines are not indented, and places where the mode returns Pass\n  // are left alone.\n  function indentLine(cm, n, how, aggressive) {\n\tvar doc = cm.doc, state\n\tif (how == null) { how = \"add\" }\n\tif (how == \"smart\") {\n\t  // Fall back to \"prev\" when the mode doesn't have an indentation\n\t  // method.\n\t  if (!doc.mode.indent) { how = \"prev\" }\n\t  else { state = getStateBefore(cm, n) }\n\t}\n  \n\tvar tabSize = cm.options.tabSize\n\tvar line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize)\n\tif (line.stateAfter) { line.stateAfter = null }\n\tvar curSpaceString = line.text.match(/^\\s*/)[0], indentation\n\tif (!aggressive && !/\\S/.test(line.text)) {\n\t  indentation = 0\n\t  how = \"not\"\n\t} else if (how == \"smart\") {\n\t  indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)\n\t  if (indentation == Pass || indentation > 150) {\n\t\tif (!aggressive) { return }\n\t\thow = \"prev\"\n\t  }\n\t}\n\tif (how == \"prev\") {\n\t  if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize) }\n\t  else { indentation = 0 }\n\t} else if (how == \"add\") {\n\t  indentation = curSpace + cm.options.indentUnit\n\t} else if (how == \"subtract\") {\n\t  indentation = curSpace - cm.options.indentUnit\n\t} else if (typeof how == \"number\") {\n\t  indentation = curSpace + how\n\t}\n\tindentation = Math.max(0, indentation)\n  \n\tvar indentString = \"\", pos = 0\n\tif (cm.options.indentWithTabs)\n\t  { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += \"\\t\"} }\n\tif (pos < indentation) { indentString += spaceStr(indentation - pos) }\n  \n\tif (indentString != curSpaceString) {\n\t  replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), \"+input\")\n\t  line.stateAfter = null\n\t  return true\n\t} else {\n\t  // Ensure that, if the cursor was in the whitespace at the start\n\t  // of the line, it is moved to the end of that space.\n\t  for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {\n\t\tvar range = doc.sel.ranges[i$1]\n\t\tif (range.head.line == n && range.head.ch < curSpaceString.length) {\n\t\t  var pos$1 = Pos(n, curSpaceString.length)\n\t\t  replaceOneSelection(doc, i$1, new Range(pos$1, pos$1))\n\t\t  break\n\t\t}\n\t  }\n\t}\n  }\n  \n  // This will be set to a {lineWise: bool, text: [string]} object, so\n  // that, when pasting, we know what kind of selections the copied\n  // text was made out of.\n  var lastCopied = null\n  \n  function setLastCopied(newLastCopied) {\n\tlastCopied = newLastCopied\n  }\n  \n  function applyTextInput(cm, inserted, deleted, sel, origin) {\n\tvar doc = cm.doc\n\tcm.display.shift = false\n\tif (!sel) { sel = doc.sel }\n  \n\tvar paste = cm.state.pasteIncoming || origin == \"paste\"\n\tvar textLines = splitLinesAuto(inserted), multiPaste = null\n\t// When pasing N lines into N selections, insert one line per selection\n\tif (paste && sel.ranges.length > 1) {\n\t  if (lastCopied && lastCopied.text.join(\"\\n\") == inserted) {\n\t\tif (sel.ranges.length % lastCopied.text.length == 0) {\n\t\t  multiPaste = []\n\t\t  for (var i = 0; i < lastCopied.text.length; i++)\n\t\t\t{ multiPaste.push(doc.splitLines(lastCopied.text[i])) }\n\t\t}\n\t  } else if (textLines.length == sel.ranges.length) {\n\t\tmultiPaste = map(textLines, function (l) { return [l]; })\n\t  }\n\t}\n  \n\tvar updateInput\n\t// Normal behavior is to insert the new text into every selection\n\tfor (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {\n\t  var range = sel.ranges[i$1]\n\t  var from = range.from(), to = range.to()\n\t  if (range.empty()) {\n\t\tif (deleted && deleted > 0) // Handle deletion\n\t\t  { from = Pos(from.line, from.ch - deleted) }\n\t\telse if (cm.state.overwrite && !paste) // Handle overwrite\n\t\t  { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) }\n\t\telse if (lastCopied && lastCopied.lineWise && lastCopied.text.join(\"\\n\") == inserted)\n\t\t  { from = to = Pos(from.line, 0) }\n\t  }\n\t  updateInput = cm.curOp.updateInput\n\t  var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,\n\t\t\t\t\t\t origin: origin || (paste ? \"paste\" : cm.state.cutIncoming ? \"cut\" : \"+input\")}\n\t  makeChange(cm.doc, changeEvent)\n\t  signalLater(cm, \"inputRead\", cm, changeEvent)\n\t}\n\tif (inserted && !paste)\n\t  { triggerElectric(cm, inserted) }\n  \n\tensureCursorVisible(cm)\n\tcm.curOp.updateInput = updateInput\n\tcm.curOp.typing = true\n\tcm.state.pasteIncoming = cm.state.cutIncoming = false\n  }\n  \n  function handlePaste(e, cm) {\n\tvar pasted = e.clipboardData && e.clipboardData.getData(\"Text\")\n\tif (pasted) {\n\t  e.preventDefault()\n\t  if (!cm.isReadOnly() && !cm.options.disableInput)\n\t\t{ runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, \"paste\"); }) }\n\t  return true\n\t}\n  }\n  \n  function triggerElectric(cm, inserted) {\n\t// When an 'electric' character is inserted, immediately trigger a reindent\n\tif (!cm.options.electricChars || !cm.options.smartIndent) { return }\n\tvar sel = cm.doc.sel\n  \n\tfor (var i = sel.ranges.length - 1; i >= 0; i--) {\n\t  var range = sel.ranges[i]\n\t  if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }\n\t  var mode = cm.getModeAt(range.head)\n\t  var indented = false\n\t  if (mode.electricChars) {\n\t\tfor (var j = 0; j < mode.electricChars.length; j++)\n\t\t  { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {\n\t\t\tindented = indentLine(cm, range.head.line, \"smart\")\n\t\t\tbreak\n\t\t  } }\n\t  } else if (mode.electricInput) {\n\t\tif (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))\n\t\t  { indented = indentLine(cm, range.head.line, \"smart\") }\n\t  }\n\t  if (indented) { signalLater(cm, \"electricInput\", cm, range.head.line) }\n\t}\n  }\n  \n  function copyableRanges(cm) {\n\tvar text = [], ranges = []\n\tfor (var i = 0; i < cm.doc.sel.ranges.length; i++) {\n\t  var line = cm.doc.sel.ranges[i].head.line\n\t  var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}\n\t  ranges.push(lineRange)\n\t  text.push(cm.getRange(lineRange.anchor, lineRange.head))\n\t}\n\treturn {text: text, ranges: ranges}\n  }\n  \n  function disableBrowserMagic(field, spellcheck) {\n\tfield.setAttribute(\"autocorrect\", \"off\")\n\tfield.setAttribute(\"autocapitalize\", \"off\")\n\tfield.setAttribute(\"spellcheck\", !!spellcheck)\n  }\n  \n  function hiddenTextarea() {\n\tvar te = elt(\"textarea\", null, null, \"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none\")\n\tvar div = elt(\"div\", [te], null, \"overflow: hidden; position: relative; width: 3px; height: 0px;\")\n\t// The textarea is kept positioned near the cursor to prevent the\n\t// fact that it'll be scrolled into view on input from scrolling\n\t// our fake cursor out of view. On webkit, when wrap=off, paste is\n\t// very slow. So make the area wide instead.\n\tif (webkit) { te.style.width = \"1000px\" }\n\telse { te.setAttribute(\"wrap\", \"off\") }\n\t// If border: 0; -- iOS fails to open keyboard (issue #1287)\n\tif (ios) { te.style.border = \"1px solid black\" }\n\tdisableBrowserMagic(te)\n\treturn div\n  }\n  \n  // The publicly visible API. Note that methodOp(f) means\n  // 'wrap f in an operation, performed on its `this` parameter'.\n  \n  // This is not the complete set of editor methods. Most of the\n  // methods defined on the Doc type are also injected into\n  // CodeMirror.prototype, for backwards compatibility and\n  // convenience.\n  \n  function addEditorMethods(CodeMirror) {\n\tvar optionHandlers = CodeMirror.optionHandlers\n  \n\tvar helpers = CodeMirror.helpers = {}\n  \n\tCodeMirror.prototype = {\n\t  constructor: CodeMirror,\n\t  focus: function(){window.focus(); this.display.input.focus()},\n  \n\t  setOption: function(option, value) {\n\t\tvar options = this.options, old = options[option]\n\t\tif (options[option] == value && option != \"mode\") { return }\n\t\toptions[option] = value\n\t\tif (optionHandlers.hasOwnProperty(option))\n\t\t  { operation(this, optionHandlers[option])(this, value, old) }\n\t  },\n  \n\t  getOption: function(option) {return this.options[option]},\n\t  getDoc: function() {return this.doc},\n  \n\t  addKeyMap: function(map, bottom) {\n\t\tthis.state.keyMaps[bottom ? \"push\" : \"unshift\"](getKeyMap(map))\n\t  },\n\t  removeKeyMap: function(map) {\n\t\tvar maps = this.state.keyMaps\n\t\tfor (var i = 0; i < maps.length; ++i)\n\t\t  { if (maps[i] == map || maps[i].name == map) {\n\t\t\tmaps.splice(i, 1)\n\t\t\treturn true\n\t\t  } }\n\t  },\n  \n\t  addOverlay: methodOp(function(spec, options) {\n\t\tvar mode = spec.token ? spec : CodeMirror.getMode(this.options, spec)\n\t\tif (mode.startState) { throw new Error(\"Overlays may not be stateful.\") }\n\t\tinsertSorted(this.state.overlays,\n\t\t\t\t\t {mode: mode, modeSpec: spec, opaque: options && options.opaque,\n\t\t\t\t\t  priority: (options && options.priority) || 0},\n\t\t\t\t\t function (overlay) { return overlay.priority; })\n\t\tthis.state.modeGen++\n\t\tregChange(this)\n\t  }),\n\t  removeOverlay: methodOp(function(spec) {\n\t\tvar this$1 = this;\n  \n\t\tvar overlays = this.state.overlays\n\t\tfor (var i = 0; i < overlays.length; ++i) {\n\t\t  var cur = overlays[i].modeSpec\n\t\t  if (cur == spec || typeof spec == \"string\" && cur.name == spec) {\n\t\t\toverlays.splice(i, 1)\n\t\t\tthis$1.state.modeGen++\n\t\t\tregChange(this$1)\n\t\t\treturn\n\t\t  }\n\t\t}\n\t  }),\n  \n\t  indentLine: methodOp(function(n, dir, aggressive) {\n\t\tif (typeof dir != \"string\" && typeof dir != \"number\") {\n\t\t  if (dir == null) { dir = this.options.smartIndent ? \"smart\" : \"prev\" }\n\t\t  else { dir = dir ? \"add\" : \"subtract\" }\n\t\t}\n\t\tif (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive) }\n\t  }),\n\t  indentSelection: methodOp(function(how) {\n\t\tvar this$1 = this;\n  \n\t\tvar ranges = this.doc.sel.ranges, end = -1\n\t\tfor (var i = 0; i < ranges.length; i++) {\n\t\t  var range = ranges[i]\n\t\t  if (!range.empty()) {\n\t\t\tvar from = range.from(), to = range.to()\n\t\t\tvar start = Math.max(end, from.line)\n\t\t\tend = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1\n\t\t\tfor (var j = start; j < end; ++j)\n\t\t\t  { indentLine(this$1, j, how) }\n\t\t\tvar newRanges = this$1.doc.sel.ranges\n\t\t\tif (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)\n\t\t\t  { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll) }\n\t\t  } else if (range.head.line > end) {\n\t\t\tindentLine(this$1, range.head.line, how, true)\n\t\t\tend = range.head.line\n\t\t\tif (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1) }\n\t\t  }\n\t\t}\n\t  }),\n  \n\t  // Fetch the parser token for a given character. Useful for hacks\n\t  // that want to inspect the mode state (say, for completion).\n\t  getTokenAt: function(pos, precise) {\n\t\treturn takeToken(this, pos, precise)\n\t  },\n  \n\t  getLineTokens: function(line, precise) {\n\t\treturn takeToken(this, Pos(line), precise, true)\n\t  },\n  \n\t  getTokenTypeAt: function(pos) {\n\t\tpos = clipPos(this.doc, pos)\n\t\tvar styles = getLineStyles(this, getLine(this.doc, pos.line))\n\t\tvar before = 0, after = (styles.length - 1) / 2, ch = pos.ch\n\t\tvar type\n\t\tif (ch == 0) { type = styles[2] }\n\t\telse { for (;;) {\n\t\t  var mid = (before + after) >> 1\n\t\t  if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid }\n\t\t  else if (styles[mid * 2 + 1] < ch) { before = mid + 1 }\n\t\t  else { type = styles[mid * 2 + 2]; break }\n\t\t} }\n\t\tvar cut = type ? type.indexOf(\"overlay \") : -1\n\t\treturn cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)\n\t  },\n  \n\t  getModeAt: function(pos) {\n\t\tvar mode = this.doc.mode\n\t\tif (!mode.innerMode) { return mode }\n\t\treturn CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode\n\t  },\n  \n\t  getHelper: function(pos, type) {\n\t\treturn this.getHelpers(pos, type)[0]\n\t  },\n  \n\t  getHelpers: function(pos, type) {\n\t\tvar this$1 = this;\n  \n\t\tvar found = []\n\t\tif (!helpers.hasOwnProperty(type)) { return found }\n\t\tvar help = helpers[type], mode = this.getModeAt(pos)\n\t\tif (typeof mode[type] == \"string\") {\n\t\t  if (help[mode[type]]) { found.push(help[mode[type]]) }\n\t\t} else if (mode[type]) {\n\t\t  for (var i = 0; i < mode[type].length; i++) {\n\t\t\tvar val = help[mode[type][i]]\n\t\t\tif (val) { found.push(val) }\n\t\t  }\n\t\t} else if (mode.helperType && help[mode.helperType]) {\n\t\t  found.push(help[mode.helperType])\n\t\t} else if (help[mode.name]) {\n\t\t  found.push(help[mode.name])\n\t\t}\n\t\tfor (var i$1 = 0; i$1 < help._global.length; i$1++) {\n\t\t  var cur = help._global[i$1]\n\t\t  if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)\n\t\t\t{ found.push(cur.val) }\n\t\t}\n\t\treturn found\n\t  },\n  \n\t  getStateAfter: function(line, precise) {\n\t\tvar doc = this.doc\n\t\tline = clipLine(doc, line == null ? doc.first + doc.size - 1: line)\n\t\treturn getStateBefore(this, line + 1, precise)\n\t  },\n  \n\t  cursorCoords: function(start, mode) {\n\t\tvar pos, range = this.doc.sel.primary()\n\t\tif (start == null) { pos = range.head }\n\t\telse if (typeof start == \"object\") { pos = clipPos(this.doc, start) }\n\t\telse { pos = start ? range.from() : range.to() }\n\t\treturn cursorCoords(this, pos, mode || \"page\")\n\t  },\n  \n\t  charCoords: function(pos, mode) {\n\t\treturn charCoords(this, clipPos(this.doc, pos), mode || \"page\")\n\t  },\n  \n\t  coordsChar: function(coords, mode) {\n\t\tcoords = fromCoordSystem(this, coords, mode || \"page\")\n\t\treturn coordsChar(this, coords.left, coords.top)\n\t  },\n  \n\t  lineAtHeight: function(height, mode) {\n\t\theight = fromCoordSystem(this, {top: height, left: 0}, mode || \"page\").top\n\t\treturn lineAtHeight(this.doc, height + this.display.viewOffset)\n\t  },\n\t  heightAtLine: function(line, mode) {\n\t\tvar end = false, lineObj\n\t\tif (typeof line == \"number\") {\n\t\t  var last = this.doc.first + this.doc.size - 1\n\t\t  if (line < this.doc.first) { line = this.doc.first }\n\t\t  else if (line > last) { line = last; end = true }\n\t\t  lineObj = getLine(this.doc, line)\n\t\t} else {\n\t\t  lineObj = line\n\t\t}\n\t\treturn intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || \"page\").top +\n\t\t  (end ? this.doc.height - heightAtLine(lineObj) : 0)\n\t  },\n  \n\t  defaultTextHeight: function() { return textHeight(this.display) },\n\t  defaultCharWidth: function() { return charWidth(this.display) },\n  \n\t  setGutterMarker: methodOp(function(line, gutterID, value) {\n\t\treturn changeLine(this.doc, line, \"gutter\", function (line) {\n\t\t  var markers = line.gutterMarkers || (line.gutterMarkers = {})\n\t\t  markers[gutterID] = value\n\t\t  if (!value && isEmpty(markers)) { line.gutterMarkers = null }\n\t\t  return true\n\t\t})\n\t  }),\n  \n\t  clearGutter: methodOp(function(gutterID) {\n\t\tvar this$1 = this;\n  \n\t\tvar doc = this.doc, i = doc.first\n\t\tdoc.iter(function (line) {\n\t\t  if (line.gutterMarkers && line.gutterMarkers[gutterID]) {\n\t\t\tline.gutterMarkers[gutterID] = null\n\t\t\tregLineChange(this$1, i, \"gutter\")\n\t\t\tif (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }\n\t\t  }\n\t\t  ++i\n\t\t})\n\t  }),\n  \n\t  lineInfo: function(line) {\n\t\tvar n\n\t\tif (typeof line == \"number\") {\n\t\t  if (!isLine(this.doc, line)) { return null }\n\t\t  n = line\n\t\t  line = getLine(this.doc, line)\n\t\t  if (!line) { return null }\n\t\t} else {\n\t\t  n = lineNo(line)\n\t\t  if (n == null) { return null }\n\t\t}\n\t\treturn {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,\n\t\t\t\ttextClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,\n\t\t\t\twidgets: line.widgets}\n\t  },\n  \n\t  getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},\n  \n\t  addWidget: function(pos, node, scroll, vert, horiz) {\n\t\tvar display = this.display\n\t\tpos = cursorCoords(this, clipPos(this.doc, pos))\n\t\tvar top = pos.bottom, left = pos.left\n\t\tnode.style.position = \"absolute\"\n\t\tnode.setAttribute(\"cm-ignore-events\", \"true\")\n\t\tthis.display.input.setUneditable(node)\n\t\tdisplay.sizer.appendChild(node)\n\t\tif (vert == \"over\") {\n\t\t  top = pos.top\n\t\t} else if (vert == \"above\" || vert == \"near\") {\n\t\t  var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),\n\t\t  hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth)\n\t\t  // Default to positioning above (if specified and possible); otherwise default to positioning below\n\t\t  if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)\n\t\t\t{ top = pos.top - node.offsetHeight }\n\t\t  else if (pos.bottom + node.offsetHeight <= vspace)\n\t\t\t{ top = pos.bottom }\n\t\t  if (left + node.offsetWidth > hspace)\n\t\t\t{ left = hspace - node.offsetWidth }\n\t\t}\n\t\tnode.style.top = top + \"px\"\n\t\tnode.style.left = node.style.right = \"\"\n\t\tif (horiz == \"right\") {\n\t\t  left = display.sizer.clientWidth - node.offsetWidth\n\t\t  node.style.right = \"0px\"\n\t\t} else {\n\t\t  if (horiz == \"left\") { left = 0 }\n\t\t  else if (horiz == \"middle\") { left = (display.sizer.clientWidth - node.offsetWidth) / 2 }\n\t\t  node.style.left = left + \"px\"\n\t\t}\n\t\tif (scroll)\n\t\t  { scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight) }\n\t  },\n  \n\t  triggerOnKeyDown: methodOp(onKeyDown),\n\t  triggerOnKeyPress: methodOp(onKeyPress),\n\t  triggerOnKeyUp: onKeyUp,\n  \n\t  execCommand: function(cmd) {\n\t\tif (commands.hasOwnProperty(cmd))\n\t\t  { return commands[cmd].call(null, this) }\n\t  },\n  \n\t  triggerElectric: methodOp(function(text) { triggerElectric(this, text) }),\n  \n\t  findPosH: function(from, amount, unit, visually) {\n\t\tvar this$1 = this;\n  \n\t\tvar dir = 1\n\t\tif (amount < 0) { dir = -1; amount = -amount }\n\t\tvar cur = clipPos(this.doc, from)\n\t\tfor (var i = 0; i < amount; ++i) {\n\t\t  cur = findPosH(this$1.doc, cur, dir, unit, visually)\n\t\t  if (cur.hitSide) { break }\n\t\t}\n\t\treturn cur\n\t  },\n  \n\t  moveH: methodOp(function(dir, unit) {\n\t\tvar this$1 = this;\n  \n\t\tthis.extendSelectionsBy(function (range) {\n\t\t  if (this$1.display.shift || this$1.doc.extend || range.empty())\n\t\t\t{ return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) }\n\t\t  else\n\t\t\t{ return dir < 0 ? range.from() : range.to() }\n\t\t}, sel_move)\n\t  }),\n  \n\t  deleteH: methodOp(function(dir, unit) {\n\t\tvar sel = this.doc.sel, doc = this.doc\n\t\tif (sel.somethingSelected())\n\t\t  { doc.replaceSelection(\"\", null, \"+delete\") }\n\t\telse\n\t\t  { deleteNearSelection(this, function (range) {\n\t\t\tvar other = findPosH(doc, range.head, dir, unit, false)\n\t\t\treturn dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}\n\t\t  }) }\n\t  }),\n  \n\t  findPosV: function(from, amount, unit, goalColumn) {\n\t\tvar this$1 = this;\n  \n\t\tvar dir = 1, x = goalColumn\n\t\tif (amount < 0) { dir = -1; amount = -amount }\n\t\tvar cur = clipPos(this.doc, from)\n\t\tfor (var i = 0; i < amount; ++i) {\n\t\t  var coords = cursorCoords(this$1, cur, \"div\")\n\t\t  if (x == null) { x = coords.left }\n\t\t  else { coords.left = x }\n\t\t  cur = findPosV(this$1, coords, dir, unit)\n\t\t  if (cur.hitSide) { break }\n\t\t}\n\t\treturn cur\n\t  },\n  \n\t  moveV: methodOp(function(dir, unit) {\n\t\tvar this$1 = this;\n  \n\t\tvar doc = this.doc, goals = []\n\t\tvar collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected()\n\t\tdoc.extendSelectionsBy(function (range) {\n\t\t  if (collapse)\n\t\t\t{ return dir < 0 ? range.from() : range.to() }\n\t\t  var headPos = cursorCoords(this$1, range.head, \"div\")\n\t\t  if (range.goalColumn != null) { headPos.left = range.goalColumn }\n\t\t  goals.push(headPos.left)\n\t\t  var pos = findPosV(this$1, headPos, dir, unit)\n\t\t  if (unit == \"page\" && range == doc.sel.primary())\n\t\t\t{ addToScrollPos(this$1, null, charCoords(this$1, pos, \"div\").top - headPos.top) }\n\t\t  return pos\n\t\t}, sel_move)\n\t\tif (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)\n\t\t  { doc.sel.ranges[i].goalColumn = goals[i] } }\n\t  }),\n  \n\t  // Find the word at the given position (as returned by coordsChar).\n\t  findWordAt: function(pos) {\n\t\tvar doc = this.doc, line = getLine(doc, pos.line).text\n\t\tvar start = pos.ch, end = pos.ch\n\t\tif (line) {\n\t\t  var helper = this.getHelper(pos, \"wordChars\")\n\t\t  if ((pos.xRel < 0 || end == line.length) && start) { --start; } else { ++end }\n\t\t  var startChar = line.charAt(start)\n\t\t  var check = isWordChar(startChar, helper)\n\t\t\t? function (ch) { return isWordChar(ch, helper); }\n\t\t\t: /\\s/.test(startChar) ? function (ch) { return /\\s/.test(ch); }\n\t\t\t: function (ch) { return (!/\\s/.test(ch) && !isWordChar(ch)); }\n\t\t  while (start > 0 && check(line.charAt(start - 1))) { --start }\n\t\t  while (end < line.length && check(line.charAt(end))) { ++end }\n\t\t}\n\t\treturn new Range(Pos(pos.line, start), Pos(pos.line, end))\n\t  },\n  \n\t  toggleOverwrite: function(value) {\n\t\tif (value != null && value == this.state.overwrite) { return }\n\t\tif (this.state.overwrite = !this.state.overwrite)\n\t\t  { addClass(this.display.cursorDiv, \"CodeMirror-overwrite\") }\n\t\telse\n\t\t  { rmClass(this.display.cursorDiv, \"CodeMirror-overwrite\") }\n  \n\t\tsignal(this, \"overwriteToggle\", this, this.state.overwrite)\n\t  },\n\t  hasFocus: function() { return this.display.input.getField() == activeElt() },\n\t  isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },\n  \n\t  scrollTo: methodOp(function(x, y) {\n\t\tif (x != null || y != null) { resolveScrollToPos(this) }\n\t\tif (x != null) { this.curOp.scrollLeft = x }\n\t\tif (y != null) { this.curOp.scrollTop = y }\n\t  }),\n\t  getScrollInfo: function() {\n\t\tvar scroller = this.display.scroller\n\t\treturn {left: scroller.scrollLeft, top: scroller.scrollTop,\n\t\t\t\theight: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,\n\t\t\t\twidth: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,\n\t\t\t\tclientHeight: displayHeight(this), clientWidth: displayWidth(this)}\n\t  },\n  \n\t  scrollIntoView: methodOp(function(range, margin) {\n\t\tif (range == null) {\n\t\t  range = {from: this.doc.sel.primary().head, to: null}\n\t\t  if (margin == null) { margin = this.options.cursorScrollMargin }\n\t\t} else if (typeof range == \"number\") {\n\t\t  range = {from: Pos(range, 0), to: null}\n\t\t} else if (range.from == null) {\n\t\t  range = {from: range, to: null}\n\t\t}\n\t\tif (!range.to) { range.to = range.from }\n\t\trange.margin = margin || 0\n  \n\t\tif (range.from.line != null) {\n\t\t  resolveScrollToPos(this)\n\t\t  this.curOp.scrollToPos = range\n\t\t} else {\n\t\t  var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),\n\t\t\t\t\t\t\t\t\t\tMath.min(range.from.top, range.to.top) - range.margin,\n\t\t\t\t\t\t\t\t\t\tMath.max(range.from.right, range.to.right),\n\t\t\t\t\t\t\t\t\t\tMath.max(range.from.bottom, range.to.bottom) + range.margin)\n\t\t  this.scrollTo(sPos.scrollLeft, sPos.scrollTop)\n\t\t}\n\t  }),\n  \n\t  setSize: methodOp(function(width, height) {\n\t\tvar this$1 = this;\n  \n\t\tvar interpret = function (val) { return typeof val == \"number\" || /^\\d+$/.test(String(val)) ? val + \"px\" : val; }\n\t\tif (width != null) { this.display.wrapper.style.width = interpret(width) }\n\t\tif (height != null) { this.display.wrapper.style.height = interpret(height) }\n\t\tif (this.options.lineWrapping) { clearLineMeasurementCache(this) }\n\t\tvar lineNo = this.display.viewFrom\n\t\tthis.doc.iter(lineNo, this.display.viewTo, function (line) {\n\t\t  if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)\n\t\t\t{ if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, \"widget\"); break } } }\n\t\t  ++lineNo\n\t\t})\n\t\tthis.curOp.forceUpdate = true\n\t\tsignal(this, \"refresh\", this)\n\t  }),\n  \n\t  operation: function(f){return runInOp(this, f)},\n  \n\t  refresh: methodOp(function() {\n\t\tvar oldHeight = this.display.cachedTextHeight\n\t\tregChange(this)\n\t\tthis.curOp.forceUpdate = true\n\t\tclearCaches(this)\n\t\tthis.scrollTo(this.doc.scrollLeft, this.doc.scrollTop)\n\t\tupdateGutterSpace(this)\n\t\tif (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)\n\t\t  { estimateLineHeights(this) }\n\t\tsignal(this, \"refresh\", this)\n\t  }),\n  \n\t  swapDoc: methodOp(function(doc) {\n\t\tvar old = this.doc\n\t\told.cm = null\n\t\tattachDoc(this, doc)\n\t\tclearCaches(this)\n\t\tthis.display.input.reset()\n\t\tthis.scrollTo(doc.scrollLeft, doc.scrollTop)\n\t\tthis.curOp.forceScroll = true\n\t\tsignalLater(this, \"swapDoc\", this, old)\n\t\treturn old\n\t  }),\n  \n\t  getInputField: function(){return this.display.input.getField()},\n\t  getWrapperElement: function(){return this.display.wrapper},\n\t  getScrollerElement: function(){return this.display.scroller},\n\t  getGutterElement: function(){return this.display.gutters}\n\t}\n\teventMixin(CodeMirror)\n  \n\tCodeMirror.registerHelper = function(type, name, value) {\n\t  if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []} }\n\t  helpers[type][name] = value\n\t}\n\tCodeMirror.registerGlobalHelper = function(type, name, predicate, value) {\n\t  CodeMirror.registerHelper(type, name, value)\n\t  helpers[type]._global.push({pred: predicate, val: value})\n\t}\n  }\n  \n  // Used for horizontal relative motion. Dir is -1 or 1 (left or\n  // right), unit can be \"char\", \"column\" (like char, but doesn't\n  // cross line boundaries), \"word\" (across next word), or \"group\" (to\n  // the start of next group of word or non-word-non-whitespace\n  // chars). The visually param controls whether, in right-to-left\n  // text, direction 1 means to move towards the next index in the\n  // string, or towards the character to the right of the current\n  // position. The resulting position will have a hitSide=true\n  // property if it reached the end of the document.\n  function findPosH(doc, pos, dir, unit, visually) {\n\tvar line = pos.line, ch = pos.ch, origDir = dir\n\tvar lineObj = getLine(doc, line)\n\tfunction findNextLine() {\n\t  var l = line + dir\n\t  if (l < doc.first || l >= doc.first + doc.size) { return false }\n\t  line = l\n\t  return lineObj = getLine(doc, l)\n\t}\n\tfunction moveOnce(boundToLine) {\n\t  var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true)\n\t  if (next == null) {\n\t\tif (!boundToLine && findNextLine()) {\n\t\t  if (visually) { ch = (dir < 0 ? lineRight : lineLeft)(lineObj) }\n\t\t  else { ch = dir < 0 ? lineObj.text.length : 0 }\n\t\t} else { return false }\n\t  } else { ch = next }\n\t  return true\n\t}\n  \n\tif (unit == \"char\") {\n\t  moveOnce()\n\t} else if (unit == \"column\") {\n\t  moveOnce(true)\n\t} else if (unit == \"word\" || unit == \"group\") {\n\t  var sawType = null, group = unit == \"group\"\n\t  var helper = doc.cm && doc.cm.getHelper(pos, \"wordChars\")\n\t  for (var first = true;; first = false) {\n\t\tif (dir < 0 && !moveOnce(!first)) { break }\n\t\tvar cur = lineObj.text.charAt(ch) || \"\\n\"\n\t\tvar type = isWordChar(cur, helper) ? \"w\"\n\t\t  : group && cur == \"\\n\" ? \"n\"\n\t\t  : !group || /\\s/.test(cur) ? null\n\t\t  : \"p\"\n\t\tif (group && !first && !type) { type = \"s\" }\n\t\tif (sawType && sawType != type) {\n\t\t  if (dir < 0) {dir = 1; moveOnce()}\n\t\t  break\n\t\t}\n  \n\t\tif (type) { sawType = type }\n\t\tif (dir > 0 && !moveOnce(!first)) { break }\n\t  }\n\t}\n\tvar result = skipAtomic(doc, Pos(line, ch), pos, origDir, true)\n\tif (!cmp(pos, result)) { result.hitSide = true }\n\treturn result\n  }\n  \n  // For relative vertical movement. Dir may be -1 or 1. Unit can be\n  // \"page\" or \"line\". The resulting position will have a hitSide=true\n  // property if it reached the end of the document.\n  function findPosV(cm, pos, dir, unit) {\n\tvar doc = cm.doc, x = pos.left, y\n\tif (unit == \"page\") {\n\t  var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight)\n\t  var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3)\n\t  y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount\n  \n\t} else if (unit == \"line\") {\n\t  y = dir > 0 ? pos.bottom + 3 : pos.top - 3\n\t}\n\tvar target\n\tfor (;;) {\n\t  target = coordsChar(cm, x, y)\n\t  if (!target.outside) { break }\n\t  if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }\n\t  y += dir * 5\n\t}\n\treturn target\n  }\n  \n  // CONTENTEDITABLE INPUT STYLE\n  \n  function ContentEditableInput(cm) {\n\tthis.cm = cm\n\tthis.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null\n\tthis.polling = new Delayed()\n\tthis.gracePeriod = false\n  }\n  \n  ContentEditableInput.prototype = copyObj({\n\tinit: function(display) {\n\t  var input = this, cm = input.cm\n\t  var div = input.div = display.lineDiv\n\t  disableBrowserMagic(div, cm.options.spellcheck)\n  \n\t  on(div, \"paste\", function (e) {\n\t\tif (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }\n\t\t// IE doesn't fire input events, so we schedule a read for the pasted content in this way\n\t\tif (ie_version <= 11) { setTimeout(operation(cm, function () {\n\t\t  if (!input.pollContent()) { regChange(cm) }\n\t\t}), 20) }\n\t  })\n  \n\t  on(div, \"compositionstart\", function (e) {\n\t\tvar data = e.data\n\t\tinput.composing = {sel: cm.doc.sel, data: data, startData: data}\n\t\tif (!data) { return }\n\t\tvar prim = cm.doc.sel.primary()\n\t\tvar line = cm.getLine(prim.head.line)\n\t\tvar found = line.indexOf(data, Math.max(0, prim.head.ch - data.length))\n\t\tif (found > -1 && found <= prim.head.ch)\n\t\t  { input.composing.sel = simpleSelection(Pos(prim.head.line, found),\n\t\t\t\t\t\t\t\t\t\t\t\tPos(prim.head.line, found + data.length)) }\n\t  })\n\t  on(div, \"compositionupdate\", function (e) { return input.composing.data = e.data; })\n\t  on(div, \"compositionend\", function (e) {\n\t\tvar ours = input.composing\n\t\tif (!ours) { return }\n\t\tif (e.data != ours.startData && !/\\u200b/.test(e.data))\n\t\t  { ours.data = e.data }\n\t\t// Need a small delay to prevent other code (input event,\n\t\t// selection polling) from doing damage when fired right after\n\t\t// compositionend.\n\t\tsetTimeout(function () {\n\t\t  if (!ours.handled)\n\t\t\t{ input.applyComposition(ours) }\n\t\t  if (input.composing == ours)\n\t\t\t{ input.composing = null }\n\t\t}, 50)\n\t  })\n  \n\t  on(div, \"touchstart\", function () { return input.forceCompositionEnd(); })\n  \n\t  on(div, \"input\", function () {\n\t\tif (input.composing) { return }\n\t\tif (cm.isReadOnly() || !input.pollContent())\n\t\t  { runInOp(input.cm, function () { return regChange(cm); }) }\n\t  })\n  \n\t  function onCopyCut(e) {\n\t\tif (signalDOMEvent(cm, e)) { return }\n\t\tif (cm.somethingSelected()) {\n\t\t  setLastCopied({lineWise: false, text: cm.getSelections()})\n\t\t  if (e.type == \"cut\") { cm.replaceSelection(\"\", null, \"cut\") }\n\t\t} else if (!cm.options.lineWiseCopyCut) {\n\t\t  return\n\t\t} else {\n\t\t  var ranges = copyableRanges(cm)\n\t\t  setLastCopied({lineWise: true, text: ranges.text})\n\t\t  if (e.type == \"cut\") {\n\t\t\tcm.operation(function () {\n\t\t\t  cm.setSelections(ranges.ranges, 0, sel_dontScroll)\n\t\t\t  cm.replaceSelection(\"\", null, \"cut\")\n\t\t\t})\n\t\t  }\n\t\t}\n\t\tif (e.clipboardData) {\n\t\t  e.clipboardData.clearData()\n\t\t  var content = lastCopied.text.join(\"\\n\")\n\t\t  // iOS exposes the clipboard API, but seems to discard content inserted into it\n\t\t  e.clipboardData.setData(\"Text\", content)\n\t\t  if (e.clipboardData.getData(\"Text\") == content) {\n\t\t\te.preventDefault()\n\t\t\treturn\n\t\t  }\n\t\t}\n\t\t// Old-fashioned briefly-focus-a-textarea hack\n\t\tvar kludge = hiddenTextarea(), te = kludge.firstChild\n\t\tcm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)\n\t\tte.value = lastCopied.text.join(\"\\n\")\n\t\tvar hadFocus = document.activeElement\n\t\tselectInput(te)\n\t\tsetTimeout(function () {\n\t\t  cm.display.lineSpace.removeChild(kludge)\n\t\t  hadFocus.focus()\n\t\t  if (hadFocus == div) { input.showPrimarySelection() }\n\t\t}, 50)\n\t  }\n\t  on(div, \"copy\", onCopyCut)\n\t  on(div, \"cut\", onCopyCut)\n\t},\n  \n\tprepareSelection: function() {\n\t  var result = prepareSelection(this.cm, false)\n\t  result.focus = this.cm.state.focused\n\t  return result\n\t},\n  \n\tshowSelection: function(info, takeFocus) {\n\t  if (!info || !this.cm.display.view.length) { return }\n\t  if (info.focus || takeFocus) { this.showPrimarySelection() }\n\t  this.showMultipleSelections(info)\n\t},\n  \n\tshowPrimarySelection: function() {\n\t  var sel = window.getSelection(), prim = this.cm.doc.sel.primary()\n\t  var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset)\n\t  var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset)\n\t  if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&\n\t\t  cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&\n\t\t  cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)\n\t\t{ return }\n  \n\t  var start = posToDOM(this.cm, prim.from())\n\t  var end = posToDOM(this.cm, prim.to())\n\t  if (!start && !end) { return }\n  \n\t  var view = this.cm.display.view\n\t  var old = sel.rangeCount && sel.getRangeAt(0)\n\t  if (!start) {\n\t\tstart = {node: view[0].measure.map[2], offset: 0}\n\t  } else if (!end) { // FIXME dangerously hacky\n\t\tvar measure = view[view.length - 1].measure\n\t\tvar map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map\n\t\tend = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}\n\t  }\n  \n\t  var rng\n\t  try { rng = range(start.node, start.offset, end.offset, end.node) }\n\t  catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible\n\t  if (rng) {\n\t\tif (!gecko && this.cm.state.focused) {\n\t\t  sel.collapse(start.node, start.offset)\n\t\t  if (!rng.collapsed) {\n\t\t\tsel.removeAllRanges()\n\t\t\tsel.addRange(rng)\n\t\t  }\n\t\t} else {\n\t\t  sel.removeAllRanges()\n\t\t  sel.addRange(rng)\n\t\t}\n\t\tif (old && sel.anchorNode == null) { sel.addRange(old) }\n\t\telse if (gecko) { this.startGracePeriod() }\n\t  }\n\t  this.rememberSelection()\n\t},\n  \n\tstartGracePeriod: function() {\n\t  var this$1 = this;\n  \n\t  clearTimeout(this.gracePeriod)\n\t  this.gracePeriod = setTimeout(function () {\n\t\tthis$1.gracePeriod = false\n\t\tif (this$1.selectionChanged())\n\t\t  { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }\n\t  }, 20)\n\t},\n  \n\tshowMultipleSelections: function(info) {\n\t  removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)\n\t  removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)\n\t},\n  \n\trememberSelection: function() {\n\t  var sel = window.getSelection()\n\t  this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset\n\t  this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset\n\t},\n  \n\tselectionInEditor: function() {\n\t  var sel = window.getSelection()\n\t  if (!sel.rangeCount) { return false }\n\t  var node = sel.getRangeAt(0).commonAncestorContainer\n\t  return contains(this.div, node)\n\t},\n  \n\tfocus: function() {\n\t  if (this.cm.options.readOnly != \"nocursor\") { this.div.focus() }\n\t},\n\tblur: function() { this.div.blur() },\n\tgetField: function() { return this.div },\n  \n\tsupportsTouch: function() { return true },\n  \n\treceivedFocus: function() {\n\t  var input = this\n\t  if (this.selectionInEditor())\n\t\t{ this.pollSelection() }\n\t  else\n\t\t{ runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }\n  \n\t  function poll() {\n\t\tif (input.cm.state.focused) {\n\t\t  input.pollSelection()\n\t\t  input.polling.set(input.cm.options.pollInterval, poll)\n\t\t}\n\t  }\n\t  this.polling.set(this.cm.options.pollInterval, poll)\n\t},\n  \n\tselectionChanged: function() {\n\t  var sel = window.getSelection()\n\t  return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||\n\t\tsel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset\n\t},\n  \n\tpollSelection: function() {\n\t  if (!this.composing && !this.gracePeriod && this.selectionChanged()) {\n\t\tvar sel = window.getSelection(), cm = this.cm\n\t\tthis.rememberSelection()\n\t\tvar anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)\n\t\tvar head = domToPos(cm, sel.focusNode, sel.focusOffset)\n\t\tif (anchor && head) { runInOp(cm, function () {\n\t\t  setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)\n\t\t  if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }\n\t\t}) }\n\t  }\n\t},\n  \n\tpollContent: function() {\n\t  var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()\n\t  var from = sel.from(), to = sel.to()\n\t  if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }\n  \n\t  var fromIndex, fromLine, fromNode\n\t  if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {\n\t\tfromLine = lineNo(display.view[0].line)\n\t\tfromNode = display.view[0].node\n\t  } else {\n\t\tfromLine = lineNo(display.view[fromIndex].line)\n\t\tfromNode = display.view[fromIndex - 1].node.nextSibling\n\t  }\n\t  var toIndex = findViewIndex(cm, to.line)\n\t  var toLine, toNode\n\t  if (toIndex == display.view.length - 1) {\n\t\ttoLine = display.viewTo - 1\n\t\ttoNode = display.lineDiv.lastChild\n\t  } else {\n\t\ttoLine = lineNo(display.view[toIndex + 1].line) - 1\n\t\ttoNode = display.view[toIndex + 1].node.previousSibling\n\t  }\n  \n\t  var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))\n\t  var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))\n\t  while (newText.length > 1 && oldText.length > 1) {\n\t\tif (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }\n\t\telse if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }\n\t\telse { break }\n\t  }\n  \n\t  var cutFront = 0, cutEnd = 0\n\t  var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)\n\t  while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))\n\t\t{ ++cutFront }\n\t  var newBot = lst(newText), oldBot = lst(oldText)\n\t  var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),\n\t\t\t\t\t\t\t   oldBot.length - (oldText.length == 1 ? cutFront : 0))\n\t  while (cutEnd < maxCutEnd &&\n\t\t\t newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))\n\t\t{ ++cutEnd }\n  \n\t  newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd)\n\t  newText[0] = newText[0].slice(cutFront)\n  \n\t  var chFrom = Pos(fromLine, cutFront)\n\t  var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)\n\t  if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {\n\t\treplaceRange(cm.doc, newText, chFrom, chTo, \"+input\")\n\t\treturn true\n\t  }\n\t},\n  \n\tensurePolled: function() {\n\t  this.forceCompositionEnd()\n\t},\n\treset: function() {\n\t  this.forceCompositionEnd()\n\t},\n\tforceCompositionEnd: function() {\n\t  if (!this.composing || this.composing.handled) { return }\n\t  this.applyComposition(this.composing)\n\t  this.composing.handled = true\n\t  this.div.blur()\n\t  this.div.focus()\n\t},\n\tapplyComposition: function(composing) {\n\t  if (this.cm.isReadOnly())\n\t\t{ operation(this.cm, regChange)(this.cm) }\n\t  else if (composing.data && composing.data != composing.startData)\n\t\t{ operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel) }\n\t},\n  \n\tsetUneditable: function(node) {\n\t  node.contentEditable = \"false\"\n\t},\n  \n\tonKeyPress: function(e) {\n\t  e.preventDefault()\n\t  if (!this.cm.isReadOnly())\n\t\t{ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }\n\t},\n  \n\treadOnlyChanged: function(val) {\n\t  this.div.contentEditable = String(val != \"nocursor\")\n\t},\n  \n\tonContextMenu: nothing,\n\tresetPosition: nothing,\n  \n\tneedsContentAttribute: true\n\t}, ContentEditableInput.prototype)\n  \n  function posToDOM(cm, pos) {\n\tvar view = findViewForLine(cm, pos.line)\n\tif (!view || view.hidden) { return null }\n\tvar line = getLine(cm.doc, pos.line)\n\tvar info = mapFromLineView(view, line, pos.line)\n  \n\tvar order = getOrder(line), side = \"left\"\n\tif (order) {\n\t  var partPos = getBidiPartAt(order, pos.ch)\n\t  side = partPos % 2 ? \"right\" : \"left\"\n\t}\n\tvar result = nodeAndOffsetInLineMap(info.map, pos.ch, side)\n\tresult.offset = result.collapse == \"right\" ? result.end : result.start\n\treturn result\n  }\n  \n  function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }\n  \n  function domTextBetween(cm, from, to, fromLine, toLine) {\n\tvar text = \"\", closing = false, lineSep = cm.doc.lineSeparator()\n\tfunction recognizeMarker(id) { return function (marker) { return marker.id == id; } }\n\tfunction walk(node) {\n\t  if (node.nodeType == 1) {\n\t\tvar cmText = node.getAttribute(\"cm-text\")\n\t\tif (cmText != null) {\n\t\t  if (cmText == \"\") { cmText = node.textContent.replace(/\\u200b/g, \"\") }\n\t\t  text += cmText\n\t\t  return\n\t\t}\n\t\tvar markerID = node.getAttribute(\"cm-marker\"), range\n\t\tif (markerID) {\n\t\t  var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))\n\t\t  if (found.length && (range = found[0].find()))\n\t\t\t{ text += getBetween(cm.doc, range.from, range.to).join(lineSep) }\n\t\t  return\n\t\t}\n\t\tif (node.getAttribute(\"contenteditable\") == \"false\") { return }\n\t\tfor (var i = 0; i < node.childNodes.length; i++)\n\t\t  { walk(node.childNodes[i]) }\n\t\tif (/^(pre|div|p)$/i.test(node.nodeName))\n\t\t  { closing = true }\n\t  } else if (node.nodeType == 3) {\n\t\tvar val = node.nodeValue\n\t\tif (!val) { return }\n\t\tif (closing) {\n\t\t  text += lineSep\n\t\t  closing = false\n\t\t}\n\t\ttext += val\n\t  }\n\t}\n\tfor (;;) {\n\t  walk(from)\n\t  if (from == to) { break }\n\t  from = from.nextSibling\n\t}\n\treturn text\n  }\n  \n  function domToPos(cm, node, offset) {\n\tvar lineNode\n\tif (node == cm.display.lineDiv) {\n\t  lineNode = cm.display.lineDiv.childNodes[offset]\n\t  if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }\n\t  node = null; offset = 0\n\t} else {\n\t  for (lineNode = node;; lineNode = lineNode.parentNode) {\n\t\tif (!lineNode || lineNode == cm.display.lineDiv) { return null }\n\t\tif (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }\n\t  }\n\t}\n\tfor (var i = 0; i < cm.display.view.length; i++) {\n\t  var lineView = cm.display.view[i]\n\t  if (lineView.node == lineNode)\n\t\t{ return locateNodeInLineView(lineView, node, offset) }\n\t}\n  }\n  \n  function locateNodeInLineView(lineView, node, offset) {\n\tvar wrapper = lineView.text.firstChild, bad = false\n\tif (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }\n\tif (node == wrapper) {\n\t  bad = true\n\t  node = wrapper.childNodes[offset]\n\t  offset = 0\n\t  if (!node) {\n\t\tvar line = lineView.rest ? lst(lineView.rest) : lineView.line\n\t\treturn badPos(Pos(lineNo(line), line.text.length), bad)\n\t  }\n\t}\n  \n\tvar textNode = node.nodeType == 3 ? node : null, topNode = node\n\tif (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {\n\t  textNode = node.firstChild\n\t  if (offset) { offset = textNode.nodeValue.length }\n\t}\n\twhile (topNode.parentNode != wrapper) { topNode = topNode.parentNode }\n\tvar measure = lineView.measure, maps = measure.maps\n  \n\tfunction find(textNode, topNode, offset) {\n\t  for (var i = -1; i < (maps ? maps.length : 0); i++) {\n\t\tvar map = i < 0 ? measure.map : maps[i]\n\t\tfor (var j = 0; j < map.length; j += 3) {\n\t\t  var curNode = map[j + 2]\n\t\t  if (curNode == textNode || curNode == topNode) {\n\t\t\tvar line = lineNo(i < 0 ? lineView.line : lineView.rest[i])\n\t\t\tvar ch = map[j] + offset\n\t\t\tif (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)] }\n\t\t\treturn Pos(line, ch)\n\t\t  }\n\t\t}\n\t  }\n\t}\n\tvar found = find(textNode, topNode, offset)\n\tif (found) { return badPos(found, bad) }\n  \n\t// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems\n\tfor (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {\n\t  found = find(after, after.firstChild, 0)\n\t  if (found)\n\t\t{ return badPos(Pos(found.line, found.ch - dist), bad) }\n\t  else\n\t\t{ dist += after.textContent.length }\n\t}\n\tfor (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {\n\t  found = find(before, before.firstChild, -1)\n\t  if (found)\n\t\t{ return badPos(Pos(found.line, found.ch + dist$1), bad) }\n\t  else\n\t\t{ dist$1 += before.textContent.length }\n\t}\n  }\n  \n  // TEXTAREA INPUT STYLE\n  \n  function TextareaInput(cm) {\n\tthis.cm = cm\n\t// See input.poll and input.reset\n\tthis.prevInput = \"\"\n  \n\t// Flag that indicates whether we expect input to appear real soon\n\t// now (after some event like 'keypress' or 'input') and are\n\t// polling intensively.\n\tthis.pollingFast = false\n\t// Self-resetting timeout for the poller\n\tthis.polling = new Delayed()\n\t// Tracks when input.reset has punted to just putting a short\n\t// string into the textarea instead of the full selection.\n\tthis.inaccurateSelection = false\n\t// Used to work around IE issue with selection being forgotten when focus moves away from textarea\n\tthis.hasSelection = false\n\tthis.composing = null\n  }\n  \n  TextareaInput.prototype = copyObj({\n\tinit: function(display) {\n\t  var this$1 = this;\n  \n\t  var input = this, cm = this.cm\n  \n\t  // Wraps and hides input textarea\n\t  var div = this.wrapper = hiddenTextarea()\n\t  // The semihidden textarea that is focused when the editor is\n\t  // focused, and receives input.\n\t  var te = this.textarea = div.firstChild\n\t  display.wrapper.insertBefore(div, display.wrapper.firstChild)\n  \n\t  // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)\n\t  if (ios) { te.style.width = \"0px\" }\n  \n\t  on(te, \"input\", function () {\n\t\tif (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }\n\t\tinput.poll()\n\t  })\n  \n\t  on(te, \"paste\", function (e) {\n\t\tif (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }\n  \n\t\tcm.state.pasteIncoming = true\n\t\tinput.fastPoll()\n\t  })\n  \n\t  function prepareCopyCut(e) {\n\t\tif (signalDOMEvent(cm, e)) { return }\n\t\tif (cm.somethingSelected()) {\n\t\t  setLastCopied({lineWise: false, text: cm.getSelections()})\n\t\t  if (input.inaccurateSelection) {\n\t\t\tinput.prevInput = \"\"\n\t\t\tinput.inaccurateSelection = false\n\t\t\tte.value = lastCopied.text.join(\"\\n\")\n\t\t\tselectInput(te)\n\t\t  }\n\t\t} else if (!cm.options.lineWiseCopyCut) {\n\t\t  return\n\t\t} else {\n\t\t  var ranges = copyableRanges(cm)\n\t\t  setLastCopied({lineWise: true, text: ranges.text})\n\t\t  if (e.type == \"cut\") {\n\t\t\tcm.setSelections(ranges.ranges, null, sel_dontScroll)\n\t\t  } else {\n\t\t\tinput.prevInput = \"\"\n\t\t\tte.value = ranges.text.join(\"\\n\")\n\t\t\tselectInput(te)\n\t\t  }\n\t\t}\n\t\tif (e.type == \"cut\") { cm.state.cutIncoming = true }\n\t  }\n\t  on(te, \"cut\", prepareCopyCut)\n\t  on(te, \"copy\", prepareCopyCut)\n  \n\t  on(display.scroller, \"paste\", function (e) {\n\t\tif (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }\n\t\tcm.state.pasteIncoming = true\n\t\tinput.focus()\n\t  })\n  \n\t  // Prevent normal selection in the editor (we handle our own)\n\t  on(display.lineSpace, \"selectstart\", function (e) {\n\t\tif (!eventInWidget(display, e)) { e_preventDefault(e) }\n\t  })\n  \n\t  on(te, \"compositionstart\", function () {\n\t\tvar start = cm.getCursor(\"from\")\n\t\tif (input.composing) { input.composing.range.clear() }\n\t\tinput.composing = {\n\t\t  start: start,\n\t\t  range: cm.markText(start, cm.getCursor(\"to\"), {className: \"CodeMirror-composing\"})\n\t\t}\n\t  })\n\t  on(te, \"compositionend\", function () {\n\t\tif (input.composing) {\n\t\t  input.poll()\n\t\t  input.composing.range.clear()\n\t\t  input.composing = null\n\t\t}\n\t  })\n\t},\n  \n\tprepareSelection: function() {\n\t  // Redraw the selection and/or cursor\n\t  var cm = this.cm, display = cm.display, doc = cm.doc\n\t  var result = prepareSelection(cm)\n  \n\t  // Move the hidden textarea near the cursor to prevent scrolling artifacts\n\t  if (cm.options.moveInputWithCursor) {\n\t\tvar headPos = cursorCoords(cm, doc.sel.primary().head, \"div\")\n\t\tvar wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()\n\t\tresult.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,\n\t\t\t\t\t\t\t\t\t\t\theadPos.top + lineOff.top - wrapOff.top))\n\t\tresult.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,\n\t\t\t\t\t\t\t\t\t\t\t headPos.left + lineOff.left - wrapOff.left))\n\t  }\n  \n\t  return result\n\t},\n  \n\tshowSelection: function(drawn) {\n\t  var cm = this.cm, display = cm.display\n\t  removeChildrenAndAdd(display.cursorDiv, drawn.cursors)\n\t  removeChildrenAndAdd(display.selectionDiv, drawn.selection)\n\t  if (drawn.teTop != null) {\n\t\tthis.wrapper.style.top = drawn.teTop + \"px\"\n\t\tthis.wrapper.style.left = drawn.teLeft + \"px\"\n\t  }\n\t},\n  \n\t// Reset the input to correspond to the selection (or to be empty,\n\t// when not typing and nothing is selected)\n\treset: function(typing) {\n\t  if (this.contextMenuPending) { return }\n\t  var minimal, selected, cm = this.cm, doc = cm.doc\n\t  if (cm.somethingSelected()) {\n\t\tthis.prevInput = \"\"\n\t\tvar range = doc.sel.primary()\n\t\tminimal = hasCopyEvent &&\n\t\t  (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)\n\t\tvar content = minimal ? \"-\" : selected || cm.getSelection()\n\t\tthis.textarea.value = content\n\t\tif (cm.state.focused) { selectInput(this.textarea) }\n\t\tif (ie && ie_version >= 9) { this.hasSelection = content }\n\t  } else if (!typing) {\n\t\tthis.prevInput = this.textarea.value = \"\"\n\t\tif (ie && ie_version >= 9) { this.hasSelection = null }\n\t  }\n\t  this.inaccurateSelection = minimal\n\t},\n  \n\tgetField: function() { return this.textarea },\n  \n\tsupportsTouch: function() { return false },\n  \n\tfocus: function() {\n\t  if (this.cm.options.readOnly != \"nocursor\" && (!mobile || activeElt() != this.textarea)) {\n\t\ttry { this.textarea.focus() }\n\t\tcatch (e) {} // IE8 will throw if the textarea is display: none or not in DOM\n\t  }\n\t},\n  \n\tblur: function() { this.textarea.blur() },\n  \n\tresetPosition: function() {\n\t  this.wrapper.style.top = this.wrapper.style.left = 0\n\t},\n  \n\treceivedFocus: function() { this.slowPoll() },\n  \n\t// Poll for input changes, using the normal rate of polling. This\n\t// runs as long as the editor is focused.\n\tslowPoll: function() {\n\t  var this$1 = this;\n  \n\t  if (this.pollingFast) { return }\n\t  this.polling.set(this.cm.options.pollInterval, function () {\n\t\tthis$1.poll()\n\t\tif (this$1.cm.state.focused) { this$1.slowPoll() }\n\t  })\n\t},\n  \n\t// When an event has just come in that is likely to add or change\n\t// something in the input textarea, we poll faster, to ensure that\n\t// the change appears on the screen quickly.\n\tfastPoll: function() {\n\t  var missed = false, input = this\n\t  input.pollingFast = true\n\t  function p() {\n\t\tvar changed = input.poll()\n\t\tif (!changed && !missed) {missed = true; input.polling.set(60, p)}\n\t\telse {input.pollingFast = false; input.slowPoll()}\n\t  }\n\t  input.polling.set(20, p)\n\t},\n  \n\t// Read input from the textarea, and update the document to match.\n\t// When something is selected, it is present in the textarea, and\n\t// selected (unless it is huge, in which case a placeholder is\n\t// used). When nothing is selected, the cursor sits after previously\n\t// seen text (can be empty), which is stored in prevInput (we must\n\t// not reset the textarea when typing, because that breaks IME).\n\tpoll: function() {\n\t  var this$1 = this;\n  \n\t  var cm = this.cm, input = this.textarea, prevInput = this.prevInput\n\t  // Since this is called a *lot*, try to bail out as cheaply as\n\t  // possible when it is clear that nothing happened. hasSelection\n\t  // will be the case when there is a lot of text in the textarea,\n\t  // in which case reading its value would be expensive.\n\t  if (this.contextMenuPending || !cm.state.focused ||\n\t\t  (hasSelection(input) && !prevInput && !this.composing) ||\n\t\t  cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)\n\t\t{ return false }\n  \n\t  var text = input.value\n\t  // If nothing changed, bail.\n\t  if (text == prevInput && !cm.somethingSelected()) { return false }\n\t  // Work around nonsensical selection resetting in IE9/10, and\n\t  // inexplicable appearance of private area unicode characters on\n\t  // some key combos in Mac (#2689).\n\t  if (ie && ie_version >= 9 && this.hasSelection === text ||\n\t\t  mac && /[\\uf700-\\uf7ff]/.test(text)) {\n\t\tcm.display.input.reset()\n\t\treturn false\n\t  }\n  \n\t  if (cm.doc.sel == cm.display.selForContextMenu) {\n\t\tvar first = text.charCodeAt(0)\n\t\tif (first == 0x200b && !prevInput) { prevInput = \"\\u200b\" }\n\t\tif (first == 0x21da) { this.reset(); return this.cm.execCommand(\"undo\") }\n\t  }\n\t  // Find the part of the input that is actually new\n\t  var same = 0, l = Math.min(prevInput.length, text.length)\n\t  while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }\n  \n\t  runInOp(cm, function () {\n\t\tapplyTextInput(cm, text.slice(same), prevInput.length - same,\n\t\t\t\t\t   null, this$1.composing ? \"*compose\" : null)\n  \n\t\t// Don't leave long text in the textarea, since it makes further polling slow\n\t\tif (text.length > 1000 || text.indexOf(\"\\n\") > -1) { input.value = this$1.prevInput = \"\" }\n\t\telse { this$1.prevInput = text }\n  \n\t\tif (this$1.composing) {\n\t\t  this$1.composing.range.clear()\n\t\t  this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor(\"to\"),\n\t\t\t\t\t\t\t\t\t\t\t {className: \"CodeMirror-composing\"})\n\t\t}\n\t  })\n\t  return true\n\t},\n  \n\tensurePolled: function() {\n\t  if (this.pollingFast && this.poll()) { this.pollingFast = false }\n\t},\n  \n\tonKeyPress: function() {\n\t  if (ie && ie_version >= 9) { this.hasSelection = null }\n\t  this.fastPoll()\n\t},\n  \n\tonContextMenu: function(e) {\n\t  var input = this, cm = input.cm, display = cm.display, te = input.textarea\n\t  var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop\n\t  if (!pos || presto) { return } // Opera is difficult.\n  \n\t  // Reset the current text selection only if the click is done outside of the selection\n\t  // and 'resetSelectionOnContextMenu' option is true.\n\t  var reset = cm.options.resetSelectionOnContextMenu\n\t  if (reset && cm.doc.sel.contains(pos) == -1)\n\t\t{ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }\n  \n\t  var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText\n\t  input.wrapper.style.cssText = \"position: absolute\"\n\t  var wrapperBox = input.wrapper.getBoundingClientRect()\n\t  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);\"\n\t  var oldScrollY\n\t  if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)\n\t  display.input.focus()\n\t  if (webkit) { window.scrollTo(null, oldScrollY) }\n\t  display.input.reset()\n\t  // Adds \"Select all\" to context menu in FF\n\t  if (!cm.somethingSelected()) { te.value = input.prevInput = \" \" }\n\t  input.contextMenuPending = true\n\t  display.selForContextMenu = cm.doc.sel\n\t  clearTimeout(display.detectingSelectAll)\n  \n\t  // Select-all will be greyed out if there's nothing to select, so\n\t  // this adds a zero-width space so that we can later check whether\n\t  // it got selected.\n\t  function prepareSelectAllHack() {\n\t\tif (te.selectionStart != null) {\n\t\t  var selected = cm.somethingSelected()\n\t\t  var extval = \"\\u200b\" + (selected ? te.value : \"\")\n\t\t  te.value = \"\\u21da\" // Used to catch context-menu undo\n\t\t  te.value = extval\n\t\t  input.prevInput = selected ? \"\" : \"\\u200b\"\n\t\t  te.selectionStart = 1; te.selectionEnd = extval.length\n\t\t  // Re-set this, in case some other handler touched the\n\t\t  // selection in the meantime.\n\t\t  display.selForContextMenu = cm.doc.sel\n\t\t}\n\t  }\n\t  function rehide() {\n\t\tinput.contextMenuPending = false\n\t\tinput.wrapper.style.cssText = oldWrapperCSS\n\t\tte.style.cssText = oldCSS\n\t\tif (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }\n  \n\t\t// Try to detect the user choosing select-all\n\t\tif (te.selectionStart != null) {\n\t\t  if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }\n\t\t  var i = 0, poll = function () {\n\t\t\tif (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&\n\t\t\t\tte.selectionEnd > 0 && input.prevInput == \"\\u200b\")\n\t\t\t  { operation(cm, selectAll)(cm) }\n\t\t\telse if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500) }\n\t\t\telse { display.input.reset() }\n\t\t  }\n\t\t  display.detectingSelectAll = setTimeout(poll, 200)\n\t\t}\n\t  }\n  \n\t  if (ie && ie_version >= 9) { prepareSelectAllHack() }\n\t  if (captureRightClick) {\n\t\te_stop(e)\n\t\tvar mouseup = function () {\n\t\t  off(window, \"mouseup\", mouseup)\n\t\t  setTimeout(rehide, 20)\n\t\t}\n\t\ton(window, \"mouseup\", mouseup)\n\t  } else {\n\t\tsetTimeout(rehide, 50)\n\t  }\n\t},\n  \n\treadOnlyChanged: function(val) {\n\t  if (!val) { this.reset() }\n\t},\n  \n\tsetUneditable: nothing,\n  \n\tneedsContentAttribute: false\n  }, TextareaInput.prototype)\n  \n  function fromTextArea(textarea, options) {\n\toptions = options ? copyObj(options) : {}\n\toptions.value = textarea.value\n\tif (!options.tabindex && textarea.tabIndex)\n\t  { options.tabindex = textarea.tabIndex }\n\tif (!options.placeholder && textarea.placeholder)\n\t  { options.placeholder = textarea.placeholder }\n\t// Set autofocus to true if this textarea is focused, or if it has\n\t// autofocus and no other element is focused.\n\tif (options.autofocus == null) {\n\t  var hasFocus = activeElt()\n\t  options.autofocus = hasFocus == textarea ||\n\t\ttextarea.getAttribute(\"autofocus\") != null && hasFocus == document.body\n\t}\n  \n\tfunction save() {textarea.value = cm.getValue()}\n  \n\tvar realSubmit\n\tif (textarea.form) {\n\t  on(textarea.form, \"submit\", save)\n\t  // Deplorable hack to make the submit method do the right thing.\n\t  if (!options.leaveSubmitMethodAlone) {\n\t\tvar form = textarea.form\n\t\trealSubmit = form.submit\n\t\ttry {\n\t\t  var wrappedSubmit = form.submit = function () {\n\t\t\tsave()\n\t\t\tform.submit = realSubmit\n\t\t\tform.submit()\n\t\t\tform.submit = wrappedSubmit\n\t\t  }\n\t\t} catch(e) {}\n\t  }\n\t}\n  \n\toptions.finishInit = function (cm) {\n\t  cm.save = save\n\t  cm.getTextArea = function () { return textarea; }\n\t  cm.toTextArea = function () {\n\t\tcm.toTextArea = isNaN // Prevent this from being ran twice\n\t\tsave()\n\t\ttextarea.parentNode.removeChild(cm.getWrapperElement())\n\t\ttextarea.style.display = \"\"\n\t\tif (textarea.form) {\n\t\t  off(textarea.form, \"submit\", save)\n\t\t  if (typeof textarea.form.submit == \"function\")\n\t\t\t{ textarea.form.submit = realSubmit }\n\t\t}\n\t  }\n\t}\n  \n\ttextarea.style.display = \"none\"\n\tvar cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },\n\t  options)\n\treturn cm\n  }\n  \n  function addLegacyProps(CodeMirror) {\n\tCodeMirror.off = off\n\tCodeMirror.on = on\n\tCodeMirror.wheelEventPixels = wheelEventPixels\n\tCodeMirror.Doc = Doc\n\tCodeMirror.splitLines = splitLinesAuto\n\tCodeMirror.countColumn = countColumn\n\tCodeMirror.findColumn = findColumn\n\tCodeMirror.isWordChar = isWordCharBasic\n\tCodeMirror.Pass = Pass\n\tCodeMirror.signal = signal\n\tCodeMirror.Line = Line\n\tCodeMirror.changeEnd = changeEnd\n\tCodeMirror.scrollbarModel = scrollbarModel\n\tCodeMirror.Pos = Pos\n\tCodeMirror.cmpPos = cmp\n\tCodeMirror.modes = modes\n\tCodeMirror.mimeModes = mimeModes\n\tCodeMirror.resolveMode = resolveMode\n\tCodeMirror.getMode = getMode\n\tCodeMirror.modeExtensions = modeExtensions\n\tCodeMirror.extendMode = extendMode\n\tCodeMirror.copyState = copyState\n\tCodeMirror.startState = startState\n\tCodeMirror.innerMode = innerMode\n\tCodeMirror.commands = commands\n\tCodeMirror.keyMap = keyMap\n\tCodeMirror.keyName = keyName\n\tCodeMirror.isModifierKey = isModifierKey\n\tCodeMirror.lookupKey = lookupKey\n\tCodeMirror.normalizeKeyMap = normalizeKeyMap\n\tCodeMirror.StringStream = StringStream\n\tCodeMirror.SharedTextMarker = SharedTextMarker\n\tCodeMirror.TextMarker = TextMarker\n\tCodeMirror.LineWidget = LineWidget\n\tCodeMirror.e_preventDefault = e_preventDefault\n\tCodeMirror.e_stopPropagation = e_stopPropagation\n\tCodeMirror.e_stop = e_stop\n\tCodeMirror.addClass = addClass\n\tCodeMirror.contains = contains\n\tCodeMirror.rmClass = rmClass\n\tCodeMirror.keyNames = keyNames\n  }\n  \n  // EDITOR CONSTRUCTOR\n  \n  defineOptions(CodeMirror)\n  \n  addEditorMethods(CodeMirror)\n  \n  // Set up methods on CodeMirror's prototype to redirect to the editor's document.\n  var dontDelegate = \"iter insert remove copy getEditor constructor\".split(\" \")\n  for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)\n\t{ CodeMirror.prototype[prop] = (function(method) {\n\t  return function() {return method.apply(this.doc, arguments)}\n\t})(Doc.prototype[prop]) } }\n  \n  eventMixin(Doc)\n  \n  // INPUT HANDLING\n  \n  CodeMirror.inputStyles = {\"textarea\": TextareaInput, \"contenteditable\": ContentEditableInput}\n  \n  // MODE DEFINITION AND QUERYING\n  \n  // Extra arguments are stored as the mode's dependencies, which is\n  // used by (legacy) mechanisms like loadmode.js to automatically\n  // load a mode. (Preferred mechanism is the require/define calls.)\n  CodeMirror.defineMode = function(name/*, mode, …*/) {\n\tif (!CodeMirror.defaults.mode && name != \"null\") { CodeMirror.defaults.mode = name }\n\tdefineMode.apply(this, arguments)\n  }\n  \n  CodeMirror.defineMIME = defineMIME\n  \n  // Minimal default mode.\n  CodeMirror.defineMode(\"null\", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); })\n  CodeMirror.defineMIME(\"text/plain\", \"null\")\n  \n  // EXTENSIONS\n  \n  CodeMirror.defineExtension = function (name, func) {\n\tCodeMirror.prototype[name] = func\n  }\n  CodeMirror.defineDocExtension = function (name, func) {\n\tDoc.prototype[name] = func\n  }\n  \n  CodeMirror.fromTextArea = fromTextArea\n  \n  addLegacyProps(CodeMirror)\n  \n  CodeMirror.version = \"5.20.2\"\n  \n  return CodeMirror;\n  \n  })));"
  },
  {
    "path": "asset/show-hint.js",
    "content": "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http://codemirror.net/LICENSE\n\n(function(mod) {\n  if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n    mod(require(\"../../lib/codemirror\"));\n  else if (typeof define == \"function\" && define.amd) // AMD\n    define([\"../../lib/codemirror\"], mod);\n  else // Plain browser env\n    mod(CodeMirror);\n})(function(CodeMirror) {\n  \"use strict\";\n\n  var HINT_ELEMENT_CLASS        = \"CodeMirror-hint\";\n  var ACTIVE_HINT_ELEMENT_CLASS = \"CodeMirror-hint-active\";\n\n  // This is the old interface, kept around for now to stay\n  // backwards-compatible.\n  CodeMirror.showHint = function(cm, getHints, options) {\n    if (!getHints) return cm.showHint(options);\n    if (options && options.async) getHints.async = true;\n    var newOpts = {hint: getHints};\n    if (options) for (var prop in options) newOpts[prop] = options[prop];\n    return cm.showHint(newOpts);\n  };\n\n  CodeMirror.defineExtension(\"showHint\", function(options) {\n    options = parseOptions(this, this.getCursor(\"start\"), options);\n    var selections = this.listSelections()\n    if (selections.length > 1) return;\n    // By default, don't allow completion when something is selected.\n    // A hint function can have a `supportsSelection` property to\n    // indicate that it can handle selections.\n    if (this.somethingSelected()) {\n      if (!options.hint.supportsSelection) return;\n      // Don't try with cross-line selections\n      for (var i = 0; i < selections.length; i++)\n        if (selections[i].head.line != selections[i].anchor.line) return;\n    }\n\n    if (this.state.completionActive) this.state.completionActive.close();\n    var completion = this.state.completionActive = new Completion(this, options);\n    if (!completion.options.hint) return;\n\n    CodeMirror.signal(this, \"startCompletion\", this);\n    completion.update(true);\n  });\n\n  function Completion(cm, options) {\n    this.cm = cm;\n    this.options = options;\n    this.widget = null;\n    this.debounce = 0;\n    this.tick = 0;\n    this.startPos = this.cm.getCursor(\"start\");\n    this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;\n\n    var self = this;\n    cm.on(\"cursorActivity\", this.activityFunc = function() { self.cursorActivity(); });\n  }\n\n  var requestAnimationFrame = window.requestAnimationFrame || function(fn) {\n    return setTimeout(fn, 1000/60);\n  };\n  var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;\n\n  Completion.prototype = {\n    close: function() {\n      if (!this.active()) return;\n      this.cm.state.completionActive = null;\n      this.tick = null;\n      this.cm.off(\"cursorActivity\", this.activityFunc);\n\n      if (this.widget && this.data) CodeMirror.signal(this.data, \"close\");\n      if (this.widget) this.widget.close();\n      CodeMirror.signal(this.cm, \"endCompletion\", this.cm);\n    },\n\n    active: function() {\n      return this.cm.state.completionActive == this;\n    },\n\n    pick: function(data, i) {\n      var completion = data.list[i];\n      if (completion.hint) completion.hint(this.cm, data, completion);\n      else this.cm.replaceRange(getText(completion), completion.from || data.from,\n                                completion.to || data.to, \"complete\");\n      CodeMirror.signal(data, \"pick\", completion);\n      this.close();\n    },\n\n    cursorActivity: function() {\n      if (this.debounce) {\n        cancelAnimationFrame(this.debounce);\n        this.debounce = 0;\n      }\n\n      var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);\n      if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||\n          pos.ch < this.startPos.ch || this.cm.somethingSelected() ||\n          (pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {\n        this.close();\n      } else {\n        var self = this;\n        this.debounce = requestAnimationFrame(function() {self.update();});\n        if (this.widget) this.widget.disable();\n      }\n    },\n\n    update: function(first) {\n      if (this.tick == null) return\n      var self = this, myTick = ++this.tick\n      fetchHints(this.options.hint, this.cm, this.options, function(data) {\n        if (self.tick == myTick) self.finishUpdate(data, first)\n      })\n    },\n\n    finishUpdate: function(data, first) {\n      if (this.data) CodeMirror.signal(this.data, \"update\");\n\n      var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);\n      if (this.widget) this.widget.close();\n\n      this.data = data;\n\n      if (data && data.list.length) {\n        if (picked && data.list.length == 1) {\n          this.pick(data, 0);\n        } else {\n          this.widget = new Widget(this, data);\n          CodeMirror.signal(data, \"shown\");\n        }\n      }\n    }\n  };\n\n  function parseOptions(cm, pos, options) {\n    var editor = cm.options.hintOptions;\n    var out = {};\n    for (var prop in defaultOptions) out[prop] = defaultOptions[prop];\n    if (editor) for (var prop in editor)\n      if (editor[prop] !== undefined) out[prop] = editor[prop];\n    if (options) for (var prop in options)\n      if (options[prop] !== undefined) out[prop] = options[prop];\n    if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)\n    return out;\n  }\n\n  function getText(completion) {\n    if (typeof completion == \"string\") return completion;\n    else return completion.text;\n  }\n\n  function buildKeyMap(completion, handle) {\n    var baseMap = {\n      Up: function() {handle.moveFocus(-1);},\n      Down: function() {handle.moveFocus(1);},\n      PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},\n      PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},\n      Home: function() {handle.setFocus(0);},\n      End: function() {handle.setFocus(handle.length - 1);},\n      Enter: handle.pick,\n      Tab: handle.pick,\n      Esc: handle.close\n    };\n    var custom = completion.options.customKeys;\n    var ourMap = custom ? {} : baseMap;\n    function addBinding(key, val) {\n      var bound;\n      if (typeof val != \"string\")\n        bound = function(cm) { return val(cm, handle); };\n      // This mechanism is deprecated\n      else if (baseMap.hasOwnProperty(val))\n        bound = baseMap[val];\n      else\n        bound = val;\n      ourMap[key] = bound;\n    }\n    if (custom)\n      for (var key in custom) if (custom.hasOwnProperty(key))\n        addBinding(key, custom[key]);\n    var extra = completion.options.extraKeys;\n    if (extra)\n      for (var key in extra) if (extra.hasOwnProperty(key))\n        addBinding(key, extra[key]);\n    return ourMap;\n  }\n\n  function getHintElement(hintsElement, el) {\n    while (el && el != hintsElement) {\n      if (el.nodeName.toUpperCase() === \"LI\" && el.parentNode == hintsElement) return el;\n      el = el.parentNode;\n    }\n  }\n\n  function Widget(completion, data) {\n    this.completion = completion;\n    this.data = data;\n    this.picked = false;\n    var widget = this, cm = completion.cm;\n\n    var hints = this.hints = document.createElement(\"ul\");\n    hints.className = \"CodeMirror-hints\";\n    this.selectedHint = data.selectedHint || 0;\n\n    var completions = data.list;\n    for (var i = 0; i < completions.length; ++i) {\n      var elt = hints.appendChild(document.createElement(\"li\")), cur = completions[i];\n      var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? \"\" : \" \" + ACTIVE_HINT_ELEMENT_CLASS);\n      if (cur.className != null) className = cur.className + \" \" + className;\n      elt.className = className;\n      if (cur.render) cur.render(elt, data, cur);\n      else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));\n      elt.hintId = i;\n    }\n\n    var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);\n    var left = pos.left, top = pos.bottom, below = true;\n    hints.style.left = left + \"px\";\n    hints.style.top = top + \"px\";\n    // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.\n    var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);\n    var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);\n    (completion.options.container || document.body).appendChild(hints);\n    var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;\n    var scrolls = hints.scrollHeight > hints.clientHeight + 1\n    var startScroll = cm.getScrollInfo();\n\n    if (overlapY > 0) {\n      var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);\n      if (curTop - height > 0) { // Fits above cursor\n        hints.style.top = (top = pos.top - height) + \"px\";\n        below = false;\n      } else if (height > winH) {\n        hints.style.height = (winH - 5) + \"px\";\n        hints.style.top = (top = pos.bottom - box.top) + \"px\";\n        var cursor = cm.getCursor();\n        if (data.from.ch != cursor.ch) {\n          pos = cm.cursorCoords(cursor);\n          hints.style.left = (left = pos.left) + \"px\";\n          box = hints.getBoundingClientRect();\n        }\n      }\n    }\n    var overlapX = box.right - winW;\n    if (overlapX > 0) {\n      if (box.right - box.left > winW) {\n        hints.style.width = (winW - 5) + \"px\";\n        overlapX -= (box.right - box.left) - winW;\n      }\n      hints.style.left = (left = pos.left - overlapX) + \"px\";\n    }\n    if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)\n      node.style.paddingRight = cm.display.nativeBarWidth + \"px\"\n\n    cm.addKeyMap(this.keyMap = buildKeyMap(completion, {\n      moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },\n      setFocus: function(n) { widget.changeActive(n); },\n      menuSize: function() { return widget.screenAmount(); },\n      length: completions.length,\n      close: function() { completion.close(); },\n      pick: function() { widget.pick(); },\n      data: data\n    }));\n\n    if (completion.options.closeOnUnfocus) {\n      var closingOnBlur;\n      cm.on(\"blur\", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });\n      cm.on(\"focus\", this.onFocus = function() { clearTimeout(closingOnBlur); });\n    }\n\n    cm.on(\"scroll\", this.onScroll = function() {\n      var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();\n      var newTop = top + startScroll.top - curScroll.top;\n      var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);\n      if (!below) point += hints.offsetHeight;\n      if (point <= editor.top || point >= editor.bottom) return completion.close();\n      hints.style.top = newTop + \"px\";\n      hints.style.left = (left + startScroll.left - curScroll.left) + \"px\";\n    });\n\n    CodeMirror.on(hints, \"dblclick\", function(e) {\n      var t = getHintElement(hints, e.target || e.srcElement);\n      if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}\n    });\n\n    CodeMirror.on(hints, \"click\", function(e) {\n      var t = getHintElement(hints, e.target || e.srcElement);\n      if (t && t.hintId != null) {\n        widget.changeActive(t.hintId);\n        if (completion.options.completeOnSingleClick) widget.pick();\n      }\n    });\n\n    CodeMirror.on(hints, \"mousedown\", function() {\n      setTimeout(function(){cm.focus();}, 20);\n    });\n\n    CodeMirror.signal(data, \"select\", completions[this.selectedHint], hints.childNodes[this.selectedHint]);\n    return true;\n  }\n\n  Widget.prototype = {\n    close: function() {\n      if (this.completion.widget != this) return;\n      this.completion.widget = null;\n      this.hints.parentNode.removeChild(this.hints);\n      this.completion.cm.removeKeyMap(this.keyMap);\n\n      var cm = this.completion.cm;\n      if (this.completion.options.closeOnUnfocus) {\n        cm.off(\"blur\", this.onBlur);\n        cm.off(\"focus\", this.onFocus);\n      }\n      cm.off(\"scroll\", this.onScroll);\n    },\n\n    disable: function() {\n      this.completion.cm.removeKeyMap(this.keyMap);\n      var widget = this;\n      this.keyMap = {Enter: function() { widget.picked = true; }};\n      this.completion.cm.addKeyMap(this.keyMap);\n    },\n\n    pick: function() {\n      this.completion.pick(this.data, this.selectedHint);\n    },\n\n    changeActive: function(i, avoidWrap) {\n      if (i >= this.data.list.length)\n        i = avoidWrap ? this.data.list.length - 1 : 0;\n      else if (i < 0)\n        i = avoidWrap ? 0  : this.data.list.length - 1;\n      if (this.selectedHint == i) return;\n      var node = this.hints.childNodes[this.selectedHint];\n      node.className = node.className.replace(\" \" + ACTIVE_HINT_ELEMENT_CLASS, \"\");\n      node = this.hints.childNodes[this.selectedHint = i];\n      node.className += \" \" + ACTIVE_HINT_ELEMENT_CLASS;\n      if (node.offsetTop < this.hints.scrollTop)\n        this.hints.scrollTop = node.offsetTop - 3;\n      else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)\n        this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;\n      CodeMirror.signal(this.data, \"select\", this.data.list[this.selectedHint], node);\n    },\n\n    screenAmount: function() {\n      return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;\n    }\n  };\n\n  function applicableHelpers(cm, helpers) {\n    if (!cm.somethingSelected()) return helpers\n    var result = []\n    for (var i = 0; i < helpers.length; i++)\n      if (helpers[i].supportsSelection) result.push(helpers[i])\n    return result\n  }\n\n  function fetchHints(hint, cm, options, callback) {\n    if (hint.async) {\n      hint(cm, callback, options)\n    } else {\n      var result = hint(cm, options)\n      if (result && result.then) result.then(callback)\n      else callback(result)\n    }\n  }\n\n  function resolveAutoHints(cm, pos) {\n    var helpers = cm.getHelpers(pos, \"hint\"), words\n    if (helpers.length) {\n      var resolved = function(cm, callback, options) {\n        var app = applicableHelpers(cm, helpers);\n        function run(i) {\n          if (i == app.length) return callback(null)\n          fetchHints(app[i], cm, options, function(result) {\n            if (result && result.list.length > 0) callback(result)\n            else run(i + 1)\n          })\n        }\n        run(0)\n      }\n      resolved.async = true\n      resolved.supportsSelection = true\n      return resolved\n    } else if (words = cm.getHelper(cm.getCursor(), \"hintWords\")) {\n      return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }\n    } else if (CodeMirror.hint.anyword) {\n      return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }\n    } else {\n      return function() {}\n    }\n  }\n\n  CodeMirror.registerHelper(\"hint\", \"auto\", {\n    resolve: resolveAutoHints\n  });\n\n  CodeMirror.registerHelper(\"hint\", \"fromList\", function(cm, options) {\n    var cur = cm.getCursor(), token = cm.getTokenAt(cur)\n    var term, from = CodeMirror.Pos(cur.line, token.start), to = cur\n    if (token.start < cur.ch && /\\w/.test(token.string.charAt(cur.ch - token.start - 1))) {\n      term = token.string.substr(0, cur.ch - token.start)\n    } else {\n      term = \"\"\n      from = cur\n    }\n    var found = [];\n    for (var i = 0; i < options.words.length; i++) {\n      var word = options.words[i];\n      if (word.slice(0, term.length) == term)\n        found.push(word);\n    }\n\n    if (found.length) return {list: found, from: from, to: to};\n  });\n\n  CodeMirror.commands.autocomplete = CodeMirror.showHint;\n\n  var defaultOptions = {\n    hint: CodeMirror.hint.auto,\n    completeSingle: true,\n    alignWithWord: true,\n    closeCharacters: /[\\s()\\[\\]{};:>,]/,\n    closeOnUnfocus: true,\n    completeOnSingleClick: true,\n    container: null,\n    customKeys: null,\n    extraKeys: null\n  };\n\n  CodeMirror.defineOption(\"hintOptions\", null);\n});\n"
  },
  {
    "path": "asset/sql-hint.js",
    "content": "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http://codemirror.net/LICENSE\n\n(function(mod) {\n  if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n    mod(require(\"../../lib/codemirror\"), require(\"../../mode/sql/sql\"));\n  else if (typeof define == \"function\" && define.amd) // AMD\n    define([\"../../lib/codemirror\", \"../../mode/sql/sql\"], mod);\n  else // Plain browser env\n    mod(CodeMirror);\n})(function(CodeMirror) {\n  \"use strict\";\n\n  var tables;\n  var defaultTable;\n  var keywords;\n  var identifierQuote;\n  var CONS = {\n    QUERY_DIV: \";\",\n    ALIAS_KEYWORD: \"AS\"\n  };\n  var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;\n\n  function isArray(val) { return Object.prototype.toString.call(val) == \"[object Array]\" }\n\n  function getKeywords(editor) {\n    var mode = editor.doc.modeOption;\n    if (mode === \"sql\") mode = \"text/x-sql\";\n    return CodeMirror.resolveMode(mode).keywords;\n  }\n\n  function getIdentifierQuote(editor) {\n    var mode = editor.doc.modeOption;\n    if (mode === \"sql\") mode = \"text/x-sql\";\n    return CodeMirror.resolveMode(mode).identifierQuote || \"`\";\n  }\n\n  function getText(item) {\n    return typeof item == \"string\" ? item : item.text;\n  }\n\n  function wrapTable(name, value) {\n    if (isArray(value)) value = {columns: value}\n    if (!value.text) value.text = name\n    return value\n  }\n\n  function parseTables(input) {\n    var result = {}\n    if (isArray(input)) {\n      for (var i = input.length - 1; i >= 0; i--) {\n        var item = input[i]\n        result[getText(item).toUpperCase()] = wrapTable(getText(item), item)\n      }\n    } else if (input) {\n      for (var name in input)\n        result[name.toUpperCase()] = wrapTable(name, input[name])\n    }\n    return result\n  }\n\n  function getTable(name) {\n    return tables[name.toUpperCase()]\n  }\n\n  function shallowClone(object) {\n    var result = {};\n    for (var key in object) if (object.hasOwnProperty(key))\n      result[key] = object[key];\n    return result;\n  }\n\n  function match(string, word) {\n    var len = string.length;\n    var sub = getText(word).substr(0, len);\n    return string.toUpperCase() === sub.toUpperCase();\n  }\n\n  function addMatches(result, search, wordlist, formatter) {\n    if (isArray(wordlist)) {\n      for (var i = 0; i < wordlist.length; i++)\n        if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))\n    } else {\n      for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {\n        var val = wordlist[word]\n        if (!val || val === true)\n          val = word\n        else\n          val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text\n        if (match(search, val)) result.push(formatter(val))\n      }\n    }\n  }\n\n  function cleanName(name) {\n    // Get rid name from identifierQuote and preceding dot(.)\n    if (name.charAt(0) == \".\") {\n      name = name.substr(1);\n    }\n    // replace doublicated identifierQuotes with single identifierQuotes\n    // and remove single identifierQuotes\n    var nameParts = name.split(identifierQuote+identifierQuote);\n    for (var i = 0; i < nameParts.length; i++)\n      nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,\"g\"), \"\");\n    return nameParts.join(identifierQuote);\n  }\n\n  function insertIdentifierQuotes(name) {\n    var nameParts = getText(name).split(\".\");\n    for (var i = 0; i < nameParts.length; i++)\n      nameParts[i] = identifierQuote +\n        // doublicate identifierQuotes\n        nameParts[i].replace(new RegExp(identifierQuote,\"g\"), identifierQuote+identifierQuote) +\n        identifierQuote;\n    var escaped = nameParts.join(\".\");\n    if (typeof name == \"string\") return escaped;\n    name = shallowClone(name);\n    name.text = escaped;\n    return name;\n  }\n\n  function nameCompletion(cur, token, result, editor) {\n    // Try to complete table, column names and return start position of completion\n    var useIdentifierQuotes = false;\n    var nameParts = [];\n    var start = token.start;\n    var cont = true;\n    while (cont) {\n      cont = (token.string.charAt(0) == \".\");\n      useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote);\n\n      start = token.start;\n      nameParts.unshift(cleanName(token.string));\n\n      token = editor.getTokenAt(Pos(cur.line, token.start));\n      if (token.string == \".\") {\n        cont = true;\n        token = editor.getTokenAt(Pos(cur.line, token.start));\n      }\n    }\n\n    // Try to complete table names\n    var string = nameParts.join(\".\");\n    addMatches(result, string, tables, function(w) {\n      return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;\n    });\n\n    // Try to complete columns from defaultTable\n    addMatches(result, string, defaultTable, function(w) {\n      return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;\n    });\n\n    // Try to complete columns\n    string = nameParts.pop();\n    var table = nameParts.join(\".\");\n\n    var alias = false;\n    var aliasTable = table;\n    // Check if table is available. If not, find table by Alias\n    if (!getTable(table)) {\n      var oldTable = table;\n      table = findTableByAlias(table, editor);\n      if (table !== oldTable) alias = true;\n    }\n\n    var columns = getTable(table);\n    if (columns && columns.columns)\n      columns = columns.columns;\n\n    if (columns) {\n      addMatches(result, string, columns, function(w) {\n        var tableInsert = table;\n        if (alias == true) tableInsert = aliasTable;\n        if (typeof w == \"string\") {\n          w = tableInsert + \".\" + w;\n        } else {\n          w = shallowClone(w);\n          w.text = tableInsert + \".\" + w.text;\n        }\n        return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;\n      });\n    }\n\n    return start;\n  }\n\n  function eachWord(lineText, f) {\n    var words = lineText.split(/\\s+/)\n    for (var i = 0; i < words.length; i++)\n      if (words[i]) f(words[i].replace(/[,;]/g, ''))\n  }\n\n  function findTableByAlias(alias, editor) {\n    var doc = editor.doc;\n    var fullQuery = doc.getValue();\n    var aliasUpperCase = alias.toUpperCase();\n    var previousWord = \"\";\n    var table = \"\";\n    var separator = [];\n    var validRange = {\n      start: Pos(0, 0),\n      end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)\n    };\n\n    //add separator\n    var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);\n    while(indexOfSeparator != -1) {\n      separator.push(doc.posFromIndex(indexOfSeparator));\n      indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);\n    }\n    separator.unshift(Pos(0, 0));\n    separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));\n\n    //find valid range\n    var prevItem = null;\n    var current = editor.getCursor()\n    for (var i = 0; i < separator.length; i++) {\n      if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {\n        validRange = {start: prevItem, end: separator[i]};\n        break;\n      }\n      prevItem = separator[i];\n    }\n\n    if (validRange.start) {\n      var query = doc.getRange(validRange.start, validRange.end, false);\n\n      for (var i = 0; i < query.length; i++) {\n        var lineText = query[i];\n        eachWord(lineText, function(word) {\n          var wordUpperCase = word.toUpperCase();\n          if (wordUpperCase === aliasUpperCase && getTable(previousWord))\n            table = previousWord;\n          if (wordUpperCase !== CONS.ALIAS_KEYWORD)\n            previousWord = word;\n        });\n        if (table) break;\n      }\n    }\n    return table;\n  }\n\n  CodeMirror.registerHelper(\"hint\", \"sql\", function(editor, options) {\n    tables = parseTables(options && options.tables)\n    var defaultTableName = options && options.defaultTable;\n    var disableKeywords = options && options.disableKeywords;\n    defaultTable = defaultTableName && getTable(defaultTableName);\n    keywords = getKeywords(editor);\n    identifierQuote = getIdentifierQuote(editor);\n\n    if (defaultTableName && !defaultTable)\n      defaultTable = findTableByAlias(defaultTableName, editor);\n\n    defaultTable = defaultTable || [];\n\n    if (defaultTable.columns)\n      defaultTable = defaultTable.columns;\n\n    var cur = editor.getCursor();\n    var result = [];\n    var token = editor.getTokenAt(cur), start, end, search;\n    if (token.end > cur.ch) {\n      token.end = cur.ch;\n      token.string = token.string.slice(0, cur.ch - token.start);\n    }\n\n    if (token.string.match(/^[.`\"\\w@]\\w*$/)) {\n      search = token.string;\n      start = token.start;\n      end = token.end;\n    } else {\n      start = end = cur.ch;\n      search = \"\";\n    }\n    if (search.charAt(0) == \".\" || search.charAt(0) == identifierQuote) {\n      start = nameCompletion(cur, token, result, editor);\n    } else {\n      addMatches(result, search, defaultTable, function(w) {return {text:w, className: \"CodeMirror-hint-table CodeMirror-hint-default-table\"};});\n      addMatches(\n          result,\n          search,\n          tables,\n          function(w) {\n              if (typeof w === 'object') {\n                  w.className =  \"CodeMirror-hint-table\";\n              } else {\n                  w = {text: w, className: \"CodeMirror-hint-table\"};\n              }\n\n              return w;\n          }\n      );\n      if (!disableKeywords)\n        addMatches(result, search, keywords, function(w) {return {text: w.toUpperCase(), className: \"CodeMirror-hint-keyword\"};});\n    }\n\n    return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};\n  });\n});\n"
  },
  {
    "path": "asset/sql-qone.js",
    "content": "// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: http://codemirror.net/LICENSE\n\n(function(mod) {\n  if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n    mod(require(\"../../lib/codemirror\"));\n  else if (typeof define == \"function\" && define.amd) // AMD\n    define([\"../../lib/codemirror\"], mod);\n  else // Plain browser env\n    mod(CodeMirror);\n})(function(CodeMirror) {\n\"use strict\";\n\nCodeMirror.defineMode(\"sql\", function(config, parserConfig) {\n  \"use strict\";\n\n  var client         = parserConfig.client || {},\n      atoms          = parserConfig.atoms || {\"false\": true, \"true\": true, \"null\": true},\n      builtin        = parserConfig.builtin || {},\n      keywords       = parserConfig.keywords || {},\n      operatorChars  = parserConfig.operatorChars || /^[*+\\-%<>!=&|~^]/,\n      support        = parserConfig.support || {},\n      hooks          = parserConfig.hooks || {},\n      dateSQL        = parserConfig.dateSQL || {\"date\" : true, \"time\" : true, \"timestamp\" : true},\n      backslashStringEscapes = parserConfig.backslashStringEscapes !== false,\n      brackets       = parserConfig.brackets || /^[\\{}\\(\\)\\[\\]]/,\n      punctuation    = parserConfig.punctuation || /^[;.,:]/\n\n  function tokenBase(stream, state) {\n    var ch = stream.next();\n\n    // call hooks from the mime type\n    if (hooks[ch]) {\n      var result = hooks[ch](stream, state);\n      if (result !== false) return result;\n    }\n\n    if (support.hexNumber &&\n      ((ch == \"0\" && stream.match(/^[xX][0-9a-fA-F]+/))\n      || (ch == \"x\" || ch == \"X\") && stream.match(/^'[0-9a-fA-F]+'/))) {\n      // hex\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html\n      return \"number\";\n    } else if (support.binaryNumber &&\n      (((ch == \"b\" || ch == \"B\") && stream.match(/^'[01]+'/))\n      || (ch == \"0\" && stream.match(/^b[01]+/)))) {\n      // bitstring\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/bit-field-literals.html\n      return \"number\";\n    } else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {\n      // numbers\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html\n      stream.match(/^[0-9]*(\\.[0-9]+)?([eE][-+]?[0-9]+)?/);\n      support.decimallessFloat && stream.match(/^\\.(?!\\.)/);\n      return \"number\";\n    } else if (ch == \"?\" && (stream.eatSpace() || stream.eol() || stream.eat(\";\"))) {\n      // placeholders\n      return \"variable-3\";\n    } else if (ch == \"'\" || (ch == '\"' && support.doubleQuote)) {\n      // strings\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html\n      state.tokenize = tokenLiteral(ch);\n      return state.tokenize(stream, state);\n    } else if ((((support.nCharCast && (ch == \"n\" || ch == \"N\"))\n        || (support.charsetCast && ch == \"_\" && stream.match(/[a-z][a-z0-9]*/i)))\n        && (stream.peek() == \"'\" || stream.peek() == '\"'))) {\n      // charset casting: _utf8'str', N'str', n'str'\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html\n      return \"keyword\";\n    } else if (support.commentSlashSlash && ch == \"/\" && stream.eat(\"/\")) {\n      // 1-line comment\n      stream.skipToEnd();\n      return \"comment\";\n    } else if ((support.commentHash && ch == \"#\")\n        || (ch == \"-\" && stream.eat(\"-\") && (!support.commentSpaceRequired || stream.eat(\" \")))) {\n      // 1-line comments\n      // ref: https://kb.askmonty.org/en/comment-syntax/\n      stream.skipToEnd();\n      return \"comment\";\n    } else if (ch == \"/\" && stream.eat(\"*\")) {\n      // multi-line comments\n      // ref: https://kb.askmonty.org/en/comment-syntax/\n      state.tokenize = tokenComment(1);\n      return state.tokenize(stream, state);\n    } else if (ch == \".\") {\n      // .1 for 0.1\n      if (support.zerolessFloat && stream.match(/^(?:\\d+(?:e[+-]?\\d+)?)/i))\n        return \"number\";\n      if (stream.match(/^\\.+/))\n        return null\n      // .table_name (ODBC)\n      // // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html\n      if (support.ODBCdotTable && stream.match(/^[\\w\\d_]+/))\n        return \"variable-2\";\n    } else if (operatorChars.test(ch)) {\n      // operators\n      stream.eatWhile(operatorChars);\n      return \"operator\";\n    } else if (brackets.test(ch)) {\n      // brackets\n      stream.eatWhile(brackets);\n      return \"bracket\";\n    } else if (punctuation.test(ch)) {\n      // punctuation\n      stream.eatWhile(punctuation);\n      return \"punctuation\";\n    } else if (ch == '{' &&\n        (stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*\"[^\"]*\"( )*}/))) {\n      // dates (weird ODBC syntax)\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html\n      return \"number\";\n    } else {\n      stream.eatWhile(/^[_\\w\\d]/);\n      var word = stream.current().toLowerCase();\n      // dates (standard SQL syntax)\n      // ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html\n      if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+\"[^\"]*\"/)))\n        return \"number\";\n      if (atoms.hasOwnProperty(word)) return \"atom\";\n      if (builtin.hasOwnProperty(word)) return \"builtin\";\n      if (keywords.hasOwnProperty(word)) return \"keyword\";\n      if (client.hasOwnProperty(word)) return \"string-2\";\n      return null;\n    }\n  }\n\n  // 'string', with char specified in quote escaped by '\\'\n  function tokenLiteral(quote) {\n    return function(stream, state) {\n      var escaped = false, ch;\n      while ((ch = stream.next()) != null) {\n        if (ch == quote && !escaped) {\n          state.tokenize = tokenBase;\n          break;\n        }\n        escaped = backslashStringEscapes && !escaped && ch == \"\\\\\";\n      }\n      return \"string\";\n    };\n  }\n  function tokenComment(depth) {\n    return function(stream, state) {\n      var m = stream.match(/^.*?(\\/\\*|\\*\\/)/)\n      if (!m) stream.skipToEnd()\n      else if (m[1] == \"/*\") state.tokenize = tokenComment(depth + 1)\n      else if (depth > 1) state.tokenize = tokenComment(depth - 1)\n      else state.tokenize = tokenBase\n      return \"comment\"\n    }\n  }\n\n  function pushContext(stream, state, type) {\n    state.context = {\n      prev: state.context,\n      indent: stream.indentation(),\n      col: stream.column(),\n      type: type\n    };\n  }\n\n  function popContext(state) {\n    state.indent = state.context.indent;\n    state.context = state.context.prev;\n  }\n\n  return {\n    startState: function() {\n      return {tokenize: tokenBase, context: null};\n    },\n\n    token: function(stream, state) {\n      if (stream.sol()) {\n        if (state.context && state.context.align == null)\n          state.context.align = false;\n      }\n      if (state.tokenize == tokenBase && stream.eatSpace()) return null;\n\n      var style = state.tokenize(stream, state);\n      if (style == \"comment\") return style;\n\n      if (state.context && state.context.align == null)\n        state.context.align = true;\n\n      var tok = stream.current();\n      if (tok == \"(\")\n        pushContext(stream, state, \")\");\n      else if (tok == \"[\")\n        pushContext(stream, state, \"]\");\n      else if (state.context && state.context.type == tok)\n        popContext(state);\n      return style;\n    },\n\n    indent: function(state, textAfter) {\n      var cx = state.context;\n      if (!cx) return CodeMirror.Pass;\n      var closing = textAfter.charAt(0) == cx.type;\n      if (cx.align) return cx.col + (closing ? 0 : 1);\n      else return cx.indent + (closing ? 0 : config.indentUnit);\n    },\n\n    blockCommentStart: \"/*\",\n    blockCommentEnd: \"*/\",\n    lineComment: support.commentSlashSlash ? \"//\" : support.commentHash ? \"#\" : \"--\",\n    closeBrackets: \"()[]{}''\\\"\\\"``\"\n  };\n});\n\n(function() {\n  \"use strict\";\n\n  // `identifier`\n  function hookIdentifier(stream) {\n    // MySQL/MariaDB identifiers\n    // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html\n    var ch;\n    while ((ch = stream.next()) != null) {\n      if (ch == \"`\" && !stream.eat(\"`\")) return \"variable-2\";\n    }\n    stream.backUp(stream.current().length - 1);\n    return stream.eatWhile(/\\w/) ? \"variable-2\" : null;\n  }\n\n  // \"identifier\"\n  function hookIdentifierDoublequote(stream) {\n    // Standard SQL /SQLite identifiers\n    // ref: http://web.archive.org/web/20160813185132/http://savage.net.au/SQL/sql-99.bnf.html#delimited%20identifier\n    // ref: http://sqlite.org/lang_keywords.html\n    var ch;\n    while ((ch = stream.next()) != null) {\n      if (ch == \"\\\"\" && !stream.eat(\"\\\"\")) return \"variable-2\";\n    }\n    stream.backUp(stream.current().length - 1);\n    return stream.eatWhile(/\\w/) ? \"variable-2\" : null;\n  }\n\n  // variable token\n  function hookVar(stream) {\n    // variables\n    // @@prefix.varName @varName\n    // varName can be quoted with ` or ' or \"\n    // ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html\n    if (stream.eat(\"@\")) {\n      stream.match(/^session\\./);\n      stream.match(/^local\\./);\n      stream.match(/^global\\./);\n    }\n\n    if (stream.eat(\"'\")) {\n      stream.match(/^.*'/);\n      return \"variable-2\";\n    } else if (stream.eat('\"')) {\n      stream.match(/^.*\"/);\n      return \"variable-2\";\n    } else if (stream.eat(\"`\")) {\n      stream.match(/^.*`/);\n      return \"variable-2\";\n    } else if (stream.match(/^[0-9a-zA-Z$\\.\\_]+/)) {\n      return \"variable-2\";\n    }\n    return null;\n  };\n\n  // short client keyword token\n  function hookClient(stream) {\n    // \\N means NULL\n    // ref: http://dev.mysql.com/doc/refman/5.5/en/null-values.html\n    if (stream.eat(\"N\")) {\n        return \"atom\";\n    }\n    // \\g, etc\n    // ref: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html\n    return stream.match(/^[a-zA-Z.#!?]/) ? \"variable-2\" : null;\n  }\n\n  // these keywords are used by all SQL dialects (however, a mode can still overwrite it)\n  var sqlKeywords = \"asc desc from in select where limit \";\n\n  // turn a space-separated list into an array\n  function set(str) {\n    var obj = {}, words = str.split(\" \");\n    for (var i = 0; i < words.length; ++i) obj[words[i]] = true;\n    return obj;\n  }\n\n\n    CodeMirror.defineMIME(\"text/qone\", {\n        name: \"sql\",\n        keywords: set(sqlKeywords + \"groupby orderby \"),\n        builtin: set(\"bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric\"),\n        atoms: set(\"false true null undefined\"),\n        operatorChars: /^[*+\\-%<>!=]/,\n        dateSQL: set(\"date time timestamp\"),\n        support: set(\"ODBCdotTable doubleQuote binaryNumber hexNumber\")\n    });\n}());\n\n});\n\n/*\n  How Properties of Mime Types are used by SQL Mode\n  =================================================\n\n  keywords:\n    A list of keywords you want to be highlighted.\n  builtin:\n    A list of builtin types you want to be highlighted (if you want types to be of class \"builtin\" instead of \"keyword\").\n  operatorChars:\n    All characters that must be handled as operators.\n  client:\n    Commands parsed and executed by the client (not the server).\n  support:\n    A list of supported syntaxes which are not common, but are supported by more than 1 DBMS.\n    * ODBCdotTable: .tableName\n    * zerolessFloat: .1\n    * doubleQuote\n    * nCharCast: N'string'\n    * charsetCast: _utf8'string'\n    * commentHash: use # char for comments\n    * commentSlashSlash: use // for comments\n    * commentSpaceRequired: require a space after -- for comments\n  atoms:\n    Keywords that must be highlighted as atoms,. Some DBMS's support more atoms than others:\n    UNKNOWN, INFINITY, UNDERFLOW, NaN...\n  dateSQL:\n    Used for date/time SQL standard syntax, because not all DBMS's support same temporal types.\n*/"
  },
  {
    "path": "index.html",
    "content": "<!doctype html>\n<html>\n<head>\n    <meta id=\"viewport\" name=\"viewport\" content=\"width=device-width,initial-scale=1.0, maximum-scale=1,user-scalable=no\">\n    <title>Qone - .NET LINQ in javascript.</title>\n    <link rel=\"icon\" href=\"data:image/x-icon;base64,AAABAAEAQEAAAAEAIAAoQgAAFgAAACgAAABAAAAAgAAAAAEAIAAAAAAAAEAAAMMOAADDDgAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/f////////////////////////////7//v/9/v3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/v3////////////+//7//v/+/////v/+//7//v/+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/P/+//7////////////v+e7/yOvE/8rsxf/l9uP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/////////////////t+Ov/uOWz/3fObf+H1H7/yuzF//7//v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/9/v3////////////w+e//uea0/4PSe/9Yw03/d85t/8jrxP/+//7///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/f/////////////////u+e3/t+Wy/3rPcP9mx1v/g9J7/7jls//v+e7////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/v3////////////u+e3/u+a2/4DRd/9wy2b/es9w/7nmtP/t+Oz///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/P/+//7////////////v+e7/tuSx/37Qdf9Wwkr/gNF3/7flsv/w+e/////////////+/v3//f79//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/////////////////u+e7/uua1/3rPcf90zWr/ftB1/7vmtv/u+e3////////////+//7///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/9/v3////////////w+e//uea1/4PSe/9fxVT/es9x/7bksf/u+e3//////////////////f78//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/f/////////////////u+e3/t+Wx/3nPcP9kx1r/g9J7/7rmtf/w+e7////////////9/v3//v/+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7////////////u+e3/u+a2/4DRd/9wzGb/ec9w/7nmtP/u+e3//////////////////v/+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3+/P/+//7////////////w+e7/tuSx/3/Qdv9Wwkr/gNF3/7flsf/w+e/////////////+/v3//f79//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/////////////////u+e3/uua1/3rPcf9zzWr/f9B2/7vmtv/u+e3////////////+//7////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7//////////////////////////////////f/9//b89f/x+vD/7fns//D67//w+u//8Pru//P78v/5/fj//v/+/////////////////////////////v/+//////////////////7//v/9/v3////////////w+e//uea0/4PSe/9fxVT/es9x/7bksf/u+e3//////////////////f78//////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v///////////////////////P78//D57//j9eL/2vLY/83uyv+757f/r+Kp/6ngo/+s4ab/q+Gl/6zhpv+05K7/xOrA/9bw0//i9eD/7fns//r9+f////////////////////////////z+/P/////////////////u+e3/t+Wx/3rPcP9kx1n/g9J7/7rmtf/w+e7////////////9/v3//v/+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7/9Pvy/9ny1v+55rX/mNqR/4vVg/+E03z/hdN8/4LSef+A0Xf/gdF4/4DRd/+B0nj/g9J6/4PTev+L1YP/mNqQ/7Pkrf/S787/7vns//n9+f/////////////////9/v3////////////u+e3/u+a2/4DRd/9xzGf/es9w/7nmtP/u+e3//////////////////v/+/////////////////////////////////////////////////////////////////////////////////////////////////////////////f79//////////////////7//v/5/fj/2fHX/7jmtP+T2Yv/dM1q/1DARP9Nv0D/WsRO/3XNa/9/0Xb/hdN8/4XTff+G1H7/hNN8/3nPcP9hxlb/UsFG/1TBR/9uy2P/jdaE/6jgov/I68T/7vns//7//v/////////////////v+e7/tuSx/3/Rdv9Vwkr/gNF3/7flsf/w+e/////////////+//7//f79///////////////////////////////////////////////////////+//7//v/+//////////////////////////////////////////////////////////////////7//v/m9+X/v+i7/5PYi/91zWv/c81q/33QdP+A0nj/i9WD/6Ddmf+55rT/w+q//8vsx//M7cj/ze7K/8vtx/++57n/pt+f/5DXiP+E03z/gNF3/3nPcP9nyVz/fNBz/6nho//m9uT/+v36///////v+e7/u+a2/3rPcf9zzGn/f9F2/7vmtv/u+e3////////////+//7//////////////////////////////////////////////////v/+/////////////////////////////////////////////////////////////v/+//7//v////////////v9+v/d89v/quGk/3nPcP9qyWD/X8VU/3/Rdf+q4aP/z+7L/9ry1//m9uT/7/nu//T78//3/Pf/+P33//j9+P/3/ff/8frw/+j35v/c89r/z+7M/7Pkrv+P1of/X8VT/1vET/9xzGf/r+Kp/9Huzf/j9eH/vee5/4vVg/9fxVT/es9x/7bksf/u+e3//////////////////f78//////////////////////////////////////////////////7//v///////////////////////////////////////////////////////v/+//////////////////r9+f/b8tj/j9eH/2LHV/9Zw03/iNSA/6bfoP/O7cr/7fnr//7//v////////////////////////////////////////////////////////////3+/f/y+vH/1/DT/7XlsP+O1ob/aclf/3LMaP+R14j/ntyX/4fUf/970HL/i9WD/7vmtv/w+e7////////////9/v3//v/+/////////////////////////////////////////////f79//7//v////////////////////////////////////////////////////////////////////////////n9+P/Q7sz/ndyW/2nJXv9myFv/htN9/8Pqvv/s+Or/+v35//////////////////////////////////////////////////////////////////////////////////v++//z+/L/0O7N/5rbk/91zGv/eM5u/3bObP95z3D/h9R//73nuf/v+e7//////////////////v/+//////////////////////////////////////////////////7//v///////////////////////////////////////////////////////v/+//////////////////3+/P/f9Nz/kNeI/1XCSf9fxlP/l9qQ/9jx1f/2/PX////////////////////////////+//7///////////////////////////////////////7//v////////////////////////////z+/P/l9eP/mdqR/2HGVv9Jvjz/eM5v/5/cmP/j9eH//v/+///////9/v3//P78/////////////////////////////////////////////v7+//3+/f////////////////////////////////////////////////////////////7//v////////////7//v/e89v/ndyV/23KY/9gxlX/oN2Z/9zz2f/8/vz//////////////////////////////////////////////////////////////////////////////////////////////////////////////////f79/9ry1/+U2Y3/YMZV/3bObf+Q14j/0e/N//v++v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7////////////r+On/qeCj/17FUv9oyF3/jdaE/9vy1//9/vz//////////////////v/+//7//v/////////////////////////////////////////////////////////////////////////////////////////////////+//7/2vLX/5PYi/9symL/b8tk/7Djqv/l9uP//v/+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7/vv/yOvE/33QdP9Nv0H/jtaF/9Lvz//6/fn//////////////////v/+//////////////////////////////////////////////////////////////////////////////////////////////////7//v/9/v3///////3+/P/h9N//ktiK/2XIWv9zzWn/rOKm//H68P////////////7//v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////9/v3/5PXh/6Hdmv94zm7/dM1q/7jls//w+u///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+/////////////f79/87uy/+M1oT/XcVR/4LSeP/Q783//f/9///////+//7//////////////////////////////////////////////////////////////////////////////////////////////////v/+//7//v//////9/z3/7/ouv9symH/aMle/6Lem//p9+f//v7+/////////////v7+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7////////////z+/P/teWw/2DFVP9rymD/ruKp//L78f/////////////////////////////////+//7//////////////////////////////////////////////////////////////////////////////////////+n35/+h3Zr/XMRR/3HMZ//E6r//+/77///////+//7/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/76/9fw0/+P1of/eM9v/4zWhP/R787/+v35//////////////////////////////////////////////////////////////////////////////////////////////////////////////////z++//S787/jNaE/2bIXP+P14b/3/Pc//7//v///////v/+//7//v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////y+vH/suOt/33Qdf9symH/suOs/+357P/////////////////////////////////////////////////////////////////////////////////////////////////////////////////v+e3/s+Su/33QdP+E03z/uea0//P68v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P78/9Hvzv+J1YH/V8JK/5fakP/h9N//////////////////////////////////////////////////////////////////////////////////////////////////////////////////4PTe/53cl/9uy2T/kNeI/9DuzP/8/vz////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////h9N//mdqS/1nDTf+K1YL/1fDR//7//v///////////////////////////////////////////////////////////////////////////////////////////////////////v/+/9Pv0P+H1H//XsVS/5rbkv/m9uP//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+////////////7Pjq/67hqP9myFv/g9N7/8jrxP/7/vv///////////////////////////////////////////////////////////////////////////////////////////////////////7//v/L7Mf/fNBy/1nDTP+g3Zr/7Pjr//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////D67/+857f/d85t/4TTfP+757b/9vz1///////////////////////////////////////////////////////////////////////////////////////////////////////+//7/xOrA/3TNav9Yw0z/p+Ch/+/57v///////////////v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0+/P/w+m//3/Rdf+C0nn/sOOq//L78f///////////////////////////////////////////////////////////////////////////////////////////////////////v/+/8Hpvv91zWv/Y8dX/7Hjq//x+vD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9vz1/8jrxP+D0nr/gNJ4/6vhpf/v+e3///////////////////////////////////////////////////////////////////////////////////////////////////////7//v/B6b3/ds5s/2bHW/+05K7/8vrx//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////j99//L7cj/hdN8/4HReP+r4ab/8Pru///////////////////////////////////////////////////////////////////////////////////////////////////////+//7/wem8/3LMaP9fxlT/sOKq//H68P/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4/fj/ze3J/4fUfv+A0Xf/qeCj/+357P///////////////////////////////////////////////////////////////////////////////////////////////////////v/+/8brwf91zWv/V8NL/6Xfnv/u+e3/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9Pvz/8Ppvv9/0XX/gtJ5/6/iqf/x+vD///////////////////////////////////////////////////////////////////////////////////////////////////////7//v/O7cr/f9F1/1nETf+e3Jf/6ffn/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+757f+45bP/dc1r/4XTfP+757f/9vz1///////////////////////////////////////////////////////////////////////////////////////////////////////+//7/2fHW/5HYif9lx1r/l9mP/9702//+//7////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7////////////n9uX/ot6b/1vEUP+E03z/ze7K//3+/f/////////////////+//7//////////////////////////////////////////////////////////////////////////////////////+b25P+n36D/dM1q/4rVgv/F68H/+v35////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3PPa/4/Xh/9QwEP/itWC/9ny1//////////////////////////////////////////////////////////////////////////////////////////////////////////////////1+/T/v+i6/4PTe/95z3H/qOCj/+v46v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f79/9Hvzf+E03r/UsFF/5jakf/j9eH////////////+//7//////////////////////////////////////////////////////////////////////////////////////////////////f79/9ny1v+U2Yz/Z8hc/4jUgP/V8NL//v/+//////////7//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+/////////////////+z46v+p4KL/fdB0/3XOa/+55rX/8Pnv///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v+u7/pd+f/1zEUP9uy2T/vee4//X89f///////v/+/////v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v////////////n9+f/K7Mb/fM9y/3PNav+U2Y3/2fLW//z+/P///////////////////////////////////////////////////////////////////////////////////////////////////////v/+////////////+f35/8jsxP93zm3/aclf/4zWhf/W8dP//////////////////f79//////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/////////////////s+Or/o96d/1rDTv9vy2X/tuWx//T78v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/s+ev/q+Gl/33QdP9pyF7/pt+f/+b25P////////////7//v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////2/PX/xOq//4nVgf9lx1r/itSB/9Tv0f/+//7//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+/9ry2P+P14f/UsBF/37RdP+55rP/8vrw/////////////v/+//3+/f////////////////////////////////////////////////////////////////////////////////////////////7+/v/////////////////7/vr/1fDR/4fUfv9cxVH/d85u/7nmtP/3/Pf////////////+//7////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7////////////x+u//uOaz/3XObP9wy2b/gdF3/8Ppvv/y+vD//////////////////////////////////////////////////////////////////////////////////////////////////v/+///////////////////////8/vz/1vDT/5LYiv9myFv/Y8dY/6rhpP/m9+X//v/+//////////7///////////////////////////////////////7//v///////////////////////////////////////////////////////////////////////v/+/////////////////+X24/+e3Jf/acle/1/FU/+S14r/w+m///L68P////////////7//v////////////////////////////////////////////////////////////////////////////7//v/+//7////////////6/fr/2fHW/53clv9cxVH/acle/4/XiP/e89z//f/9//////////7//v/+///////////////////////////////////////9/v3//////////////////////////////////////////////////////////////////////////////////v/+///////7/vv/4PXf/5rbk/9oyV3/YsZW/4LSeP+55rT/5/fm///////////////////////////////////////////////////////////////+//////////////////////////////////7+/v/w+e//0u/P/43Whf9hxlb/VsJK/53clv/b8tj/+v36///////////////////////////////////////////////////////////////////////+//7///////////////////////////////////////////////////////////////////////7//v////////////3//f/Z8tb/nt2X/23LYv9xzGf/f9F2/6ngo//X8dX/9fz1//3+/f///////////////////////////////////////////////////////////////////////v/+//v++//p9+f/uOWz/47Whf9oyF3/bstk/5HXiP/Q7sz/+v36/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f79/+T14v+g3Zn/ds5s/1TBSP9symL/jteH/7znuP/U8NL/6/jq//r9+f/+//7////////////////////////////////////////////8/vz/8/ry/97z3P/E6sD/o96c/3XNa/9Ov0H/XcVS/5zclf/f9Nz/+P34//////////////////3+/f////////////////////////////////////////////////////////////7//v/+//7////////////////////////////////////////////////////////////////////////////////////////////7/vv/5fbj/7jms/+O1ob/fNBy/2jJXv9vy2X/iNSA/6jgov/F6sH/3vPb/+n35//u+e3/8frw//L68f/x+vD/7/nu/+z46//m9uP/0O7M/7nmtP+O14b/ccxn/2jJXf92zm3/fNBz/6ngo//e89v//f78/////////////v/+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////x+u//1fDS/6Tfnv90zWn/XcVR/2jJXf95z3D/idSB/5bZjv+e3Jf/pd+e/7Diqv+05K7/seOr/6fgof+g3Zr/mtuT/4/Xh/+D0nr/Zshc/1zEUf9oyF3/m9uT/8XqwP/r+Or//v/+//////////////////7//v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+//7//v////////////3+/P/m9uT/xerA/6bfn/+V2Yz/htN9/3fObv9myFz/WcRN/1fDSv9fxlT/Zsdb/2PHV/9Yw0z/WMNM/13FUf9uy2T/gNJ4/5HXiP+i3Zv/uua0/9/z3P/6/fn///////////////////////7//v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v/+//n9+P/v+e3/2fLV/8Tqv/+t4qf/ldmM/37RdP90zWr/csxo/3bObP91zWv/dM1q/3zQcv+G1H3/n92Y/7rntv/Z8tb/6/jp//b89f/9/vz///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v/+//7///////////////////////7//f/4/ff/6/jp/9vy2f/N7cn/xerB/8HpvP/B6b3/wem+/8TqwP/L7Mf/0u/P/+H03//z+/L//v/+///////////////////////+//7//v/+//7//v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+//7//v/+//7//v/+//7//v/+//7//v/+//7//v/+//7//v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7//v//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\">\n    <meta charset=\"utf-8\" />\n    <style>\n        body,\n        html {\n            margin: 0;\n            padding: 0;\n            height: 100%;\n        }\n\n        * {\n            box-sizing: border-box;\n        }\n\n        body {\n            background: #f8f8f8;\n            font-family: Helvetica, Arial, sans-serif;\n            line-height: 1.5;\n        }\n\n        pre,\n        code {\n            line-height: 20px;\n        }\n\n        pre {\n            padding-left: 15px;\n            border-left: 2px solid #ddd;\n        }\n\n        code {\n            padding: 0 2px;\n        }\n\n\n\n\n        .head {\n            font-size: 16px;\n            font-weight: bold;\n        }\n\n        .describe {\n            font-size: 12px;\n        }\n\n\n        article {\n            min-height: 100%;\n            max-width: 700px;\n            margin: 0 auto;\n            background-color: #fff;\n            padding: 20px;\n            border-left: 1px solid #ddd;\n            border-right: 1px solid #ddd;\n        }\n\n        button {\n            border: 0;\n            border-radius: 2px;\n            color: #fff;\n            cursor: pointer;\n            font-size: .875em;\n            background-color: rgb(66, 133, 244);\n            margin: 0;\n            padding: 10px 24px;\n            transition: box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);\n            user-select: none;\n        }\n\n        button:hover {\n            box-shadow: 1px 1px 1px #cccccc;\n            background-color: rgb(49, 131, 220);\n\n        }\n\n        button:active {\n            background-color: rgb(31, 91, 220);\n\n        }\n    </style>\n    <link rel=\"stylesheet\" href=\"./asset/codemirror.css\" />\n    <style>\n        .CodeMirror {\n            border-top: 1px solid black;\n            border-bottom: 1px solid black;\n            height: 100px;\n        }\n\n        @media screen and (max-width:640px) {\n            .describe {\n                width: 255px;\n            }\n        }\n    </style>\n</head>\n\n<body>\n\n\n\n    <article>\n        <div class=\"head\">\n            Qone\n\n        </div>\n\n        <div class=\"describe\">.NET LINQ in javascript.</div>\n\n\n        <pre style=\"height:160px;\"><code>var list = [\n    { name: 'qone', age: 1 },\n    { name: 'linq', age: 18 },\n    { name: 'tencent', age: 20 },\n    { name: 'dntzhang', age: 28 }\n]\n\nvar result = qone({ list }).query(`\n</code>\n    </pre>\n        <form>\n            <textarea id=\"code\" name=\"code\">    from n in list   \n    where n.age > 10 && n.name != 'linq'\n    orderby n.age desc\n    select n\n</textarea>\n        </form>\n        <pre style=\"height: 60px;\"><code>`)\n\nconsole.log(result)\n    </code>\n        </pre>\n        </p>\n\n        <button id='runBtn'>\n            Modify the code and click me to rerun →\n        </button>\n\n        <pre class=\"result\" id=\"result\"><code>  </code></pre>\n    </article>\n    <a href=\"https://github.com/dntzhang/qone\" target=\"_blank\" style=\"position: absolute; right: 0; top: 0;\">\n        <img src=\"//alloyteam.github.io/github.png\" alt=\"\" />\n    </a>\n\n\n\n    <script src=\"./asset/codemirror.js\"></script>\n    <script src=\"./asset/sql-qone.js\"></script>\n    <script src=\"./qone.min.js\"></script>\n    <script src=\"./asset/show-hint.js\"></script>\n    <script src=\"./asset/sql-hint.js\"></script>\n    <script>\n\n\n        var editor = CodeMirror.fromTextArea(document.getElementById('code'), {\n            mode: 'text/qone',\n            indentWithTabs: true,\n            smartIndent: true,\n            lineNumbers: true,\n            matchBrackets: true,\n            autofocus: true,\n            extraKeys: { \"Ctrl-Space\": \"autocomplete\" },\n            hintOptions: {\n                tables: {\n                    users: [\"name\", \"score\", \"birthDate\"],\n                    countries: [\"name\", \"population\", \"size\"]\n                }\n            }\n        }),\n            list = [\n                { name: 'qone', age: 1 },\n                { name: 'linq', age: 18 },\n                { name: 'tencent', age: 20 },\n                { name: 'dntzhang', age: 28 }\n            ],\n            resultEle = document.getElementById('result'),\n            runBtn = document.getElementById('runBtn')\n\n        runBtn.addEventListener('click', function () {\n            var result = qone({ list }).query(editor.getValue())\n            resultEle.innerHTML = JSON.stringify(result, null, 2)\n        })\n\n        runBtn.click()\n\n    </script>\n</body>\n\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"qone\",\n  \"version\": \"2.0.0\",\n  \"main\": \"qone.js\",\n  \"description\": \"Next-generation web query language, extend .NET LINQ for javascript.\",\n  \"scripts\": {\n    \"lint\": \"eslint qone.js --fix\",\n    \"build\": \"uglifyjs -o qone.min.js --ie8 --compress --mangle -- qone.js\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/dntzhang/qone\"\n  },\n  \"keywords\": [\n    \"qone\",\n    \"linq\",\n    \"query\"\n  ],\n  \"dependencies\": {},\n  \"devDependencies\": {\n    \"eslint\": \"^4.3.0\",\n    \"eslint-config-standard\": \"^10.2.1\",\n    \"eslint-plugin-import\": \"^2.7.0\",\n    \"eslint-plugin-node\": \"^5.1.1\",\n    \"eslint-plugin-promise\": \"^3.5.0\",\n    \"eslint-plugin-standard\": \"^3.0.1\",\n    \"uglifyjs\": \"^2.4.11\"\n  },\n  \"author\": \"dntzhang\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/dntzhang/qone/issues/new\"\n  },\n  \"homepage\": \"https://dntzhang.github.io/qone/\"\n}\n"
  },
  {
    "path": "qone.js",
    "content": "/* qone v2.0.0 - Next-generation web query language, extend .NET LINQ for javascript.\n * By dntzhang https://github.com/dntzhang\n * Github: https://github.com/dntzhang/qone\n * MIT Licensed.\n */\n\n; (function(root, factory) {\n    if (typeof module === 'object' && module.exports) {\n        module.exports = factory()\n    } else {\n        root.qone = factory()\n    }\n}(this, function() {\n    var WHITESPACE_CHARS = array2hash(characters(' \\r\\t\\u200b'))\n    var OPERATOR_CHARS = array2hash(characters('+-*&%=<>!?|~^'))\n    var PUNC_CHARS = array2hash(characters('[]{}(),;:'))\n    var PUNC_BEFORE_EXPRESSION = array2hash(characters('[{}(,.;:'))\n    var KEYWORDS_ATOM = array2hash([\n        'false',\n        'null',\n        'true',\n        'undefined'\n    ])\n    var atomMapping = { 'null': null, 'undefined': undefined, 'true': true, 'false': false }\n    function HOP(obj, prop) {\n        return Object.prototype.hasOwnProperty.call(obj, prop)\n    }\n\n    function isArray(item) {\n        return Object.prototype.toString.call(item) === '[object Array]'\n    }\n\n    function isObject(obj) {\n        return obj !== null && typeof obj === 'object' && !Array.isArray(obj);\n    }\n\n    function obj2keys(obj) {\n        var keys = []\n        for (var key in obj) keys.push(key)\n        return keys\n    }\n\n    function array2hash(a) {\n        var ret = {}\n        for (var i = 0; i < a.length; ++i) {\n            ret[a[i]] = true\n        }\n        return ret\n    }\n\n    function isDigit(ch) {\n        ch = ch.charCodeAt(0)\n        return ch >= 48 && ch <= 57 // XXX: find out if \"UnicodeDigit\" means something else than 0..9\n    }\n\n    function isAlphanumericChar(ch) {\n        return isDigit(ch) || isLetter(ch)\n    }\n\n    function characters(str) {\n        return str.split('')\n    }\n\n    var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i\n    var RE_OCT_NUMBER = /^0[0-7]+$/\n    var RE_DEC_NUMBER = /^\\d*\\.?\\d*(?:e[+-]?\\d*(?:\\d\\.?|\\.?\\d)\\d*)?$/i\n\n    function parseJsNumber(num) {\n        if (RE_HEX_NUMBER.test(num)) {\n            return parseInt(num.substr(2), 16)\n        } else if (RE_OCT_NUMBER.test(num)) {\n            return parseInt(num.substr(1), 8)\n        } else if (RE_DEC_NUMBER.test(num)) {\n            return parseFloat(num)\n        }\n    }\n\n    var KEYWORD = array2hash(['from', 'in', 'where', 'select', 'orderby', 'desc', 'asc', 'groupby', 'limit'])\n    var UNICODE = {\n        letter: new RegExp('[\\\\u0041-\\\\u005A\\\\u0061-\\\\u007A\\\\u00AA\\\\u00B5\\\\u00BA\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02C1\\\\u02C6-\\\\u02D1\\\\u02E0-\\\\u02E4\\\\u02EC\\\\u02EE\\\\u0370-\\\\u0374\\\\u0376\\\\u0377\\\\u037A-\\\\u037D\\\\u0386\\\\u0388-\\\\u038A\\\\u038C\\\\u038E-\\\\u03A1\\\\u03A3-\\\\u03F5\\\\u03F7-\\\\u0481\\\\u048A-\\\\u0523\\\\u0531-\\\\u0556\\\\u0559\\\\u0561-\\\\u0587\\\\u05D0-\\\\u05EA\\\\u05F0-\\\\u05F2\\\\u0621-\\\\u064A\\\\u066E\\\\u066F\\\\u0671-\\\\u06D3\\\\u06D5\\\\u06E5\\\\u06E6\\\\u06EE\\\\u06EF\\\\u06FA-\\\\u06FC\\\\u06FF\\\\u0710\\\\u0712-\\\\u072F\\\\u074D-\\\\u07A5\\\\u07B1\\\\u07CA-\\\\u07EA\\\\u07F4\\\\u07F5\\\\u07FA\\\\u0904-\\\\u0939\\\\u093D\\\\u0950\\\\u0958-\\\\u0961\\\\u0971\\\\u0972\\\\u097B-\\\\u097F\\\\u0985-\\\\u098C\\\\u098F\\\\u0990\\\\u0993-\\\\u09A8\\\\u09AA-\\\\u09B0\\\\u09B2\\\\u09B6-\\\\u09B9\\\\u09BD\\\\u09CE\\\\u09DC\\\\u09DD\\\\u09DF-\\\\u09E1\\\\u09F0\\\\u09F1\\\\u0A05-\\\\u0A0A\\\\u0A0F\\\\u0A10\\\\u0A13-\\\\u0A28\\\\u0A2A-\\\\u0A30\\\\u0A32\\\\u0A33\\\\u0A35\\\\u0A36\\\\u0A38\\\\u0A39\\\\u0A59-\\\\u0A5C\\\\u0A5E\\\\u0A72-\\\\u0A74\\\\u0A85-\\\\u0A8D\\\\u0A8F-\\\\u0A91\\\\u0A93-\\\\u0AA8\\\\u0AAA-\\\\u0AB0\\\\u0AB2\\\\u0AB3\\\\u0AB5-\\\\u0AB9\\\\u0ABD\\\\u0AD0\\\\u0AE0\\\\u0AE1\\\\u0B05-\\\\u0B0C\\\\u0B0F\\\\u0B10\\\\u0B13-\\\\u0B28\\\\u0B2A-\\\\u0B30\\\\u0B32\\\\u0B33\\\\u0B35-\\\\u0B39\\\\u0B3D\\\\u0B5C\\\\u0B5D\\\\u0B5F-\\\\u0B61\\\\u0B71\\\\u0B83\\\\u0B85-\\\\u0B8A\\\\u0B8E-\\\\u0B90\\\\u0B92-\\\\u0B95\\\\u0B99\\\\u0B9A\\\\u0B9C\\\\u0B9E\\\\u0B9F\\\\u0BA3\\\\u0BA4\\\\u0BA8-\\\\u0BAA\\\\u0BAE-\\\\u0BB9\\\\u0BD0\\\\u0C05-\\\\u0C0C\\\\u0C0E-\\\\u0C10\\\\u0C12-\\\\u0C28\\\\u0C2A-\\\\u0C33\\\\u0C35-\\\\u0C39\\\\u0C3D\\\\u0C58\\\\u0C59\\\\u0C60\\\\u0C61\\\\u0C85-\\\\u0C8C\\\\u0C8E-\\\\u0C90\\\\u0C92-\\\\u0CA8\\\\u0CAA-\\\\u0CB3\\\\u0CB5-\\\\u0CB9\\\\u0CBD\\\\u0CDE\\\\u0CE0\\\\u0CE1\\\\u0D05-\\\\u0D0C\\\\u0D0E-\\\\u0D10\\\\u0D12-\\\\u0D28\\\\u0D2A-\\\\u0D39\\\\u0D3D\\\\u0D60\\\\u0D61\\\\u0D7A-\\\\u0D7F\\\\u0D85-\\\\u0D96\\\\u0D9A-\\\\u0DB1\\\\u0DB3-\\\\u0DBB\\\\u0DBD\\\\u0DC0-\\\\u0DC6\\\\u0E01-\\\\u0E30\\\\u0E32\\\\u0E33\\\\u0E40-\\\\u0E46\\\\u0E81\\\\u0E82\\\\u0E84\\\\u0E87\\\\u0E88\\\\u0E8A\\\\u0E8D\\\\u0E94-\\\\u0E97\\\\u0E99-\\\\u0E9F\\\\u0EA1-\\\\u0EA3\\\\u0EA5\\\\u0EA7\\\\u0EAA\\\\u0EAB\\\\u0EAD-\\\\u0EB0\\\\u0EB2\\\\u0EB3\\\\u0EBD\\\\u0EC0-\\\\u0EC4\\\\u0EC6\\\\u0EDC\\\\u0EDD\\\\u0F00\\\\u0F40-\\\\u0F47\\\\u0F49-\\\\u0F6C\\\\u0F88-\\\\u0F8B\\\\u1000-\\\\u102A\\\\u103F\\\\u1050-\\\\u1055\\\\u105A-\\\\u105D\\\\u1061\\\\u1065\\\\u1066\\\\u106E-\\\\u1070\\\\u1075-\\\\u1081\\\\u108E\\\\u10A0-\\\\u10C5\\\\u10D0-\\\\u10FA\\\\u10FC\\\\u1100-\\\\u1159\\\\u115F-\\\\u11A2\\\\u11A8-\\\\u11F9\\\\u1200-\\\\u1248\\\\u124A-\\\\u124D\\\\u1250-\\\\u1256\\\\u1258\\\\u125A-\\\\u125D\\\\u1260-\\\\u1288\\\\u128A-\\\\u128D\\\\u1290-\\\\u12B0\\\\u12B2-\\\\u12B5\\\\u12B8-\\\\u12BE\\\\u12C0\\\\u12C2-\\\\u12C5\\\\u12C8-\\\\u12D6\\\\u12D8-\\\\u1310\\\\u1312-\\\\u1315\\\\u1318-\\\\u135A\\\\u1380-\\\\u138F\\\\u13A0-\\\\u13F4\\\\u1401-\\\\u166C\\\\u166F-\\\\u1676\\\\u1681-\\\\u169A\\\\u16A0-\\\\u16EA\\\\u1700-\\\\u170C\\\\u170E-\\\\u1711\\\\u1720-\\\\u1731\\\\u1740-\\\\u1751\\\\u1760-\\\\u176C\\\\u176E-\\\\u1770\\\\u1780-\\\\u17B3\\\\u17D7\\\\u17DC\\\\u1820-\\\\u1877\\\\u1880-\\\\u18A8\\\\u18AA\\\\u1900-\\\\u191C\\\\u1950-\\\\u196D\\\\u1970-\\\\u1974\\\\u1980-\\\\u19A9\\\\u19C1-\\\\u19C7\\\\u1A00-\\\\u1A16\\\\u1B05-\\\\u1B33\\\\u1B45-\\\\u1B4B\\\\u1B83-\\\\u1BA0\\\\u1BAE\\\\u1BAF\\\\u1C00-\\\\u1C23\\\\u1C4D-\\\\u1C4F\\\\u1C5A-\\\\u1C7D\\\\u1D00-\\\\u1DBF\\\\u1E00-\\\\u1F15\\\\u1F18-\\\\u1F1D\\\\u1F20-\\\\u1F45\\\\u1F48-\\\\u1F4D\\\\u1F50-\\\\u1F57\\\\u1F59\\\\u1F5B\\\\u1F5D\\\\u1F5F-\\\\u1F7D\\\\u1F80-\\\\u1FB4\\\\u1FB6-\\\\u1FBC\\\\u1FBE\\\\u1FC2-\\\\u1FC4\\\\u1FC6-\\\\u1FCC\\\\u1FD0-\\\\u1FD3\\\\u1FD6-\\\\u1FDB\\\\u1FE0-\\\\u1FEC\\\\u1FF2-\\\\u1FF4\\\\u1FF6-\\\\u1FFC\\\\u2071\\\\u207F\\\\u2090-\\\\u2094\\\\u2102\\\\u2107\\\\u210A-\\\\u2113\\\\u2115\\\\u2119-\\\\u211D\\\\u2124\\\\u2126\\\\u2128\\\\u212A-\\\\u212D\\\\u212F-\\\\u2139\\\\u213C-\\\\u213F\\\\u2145-\\\\u2149\\\\u214E\\\\u2183\\\\u2184\\\\u2C00-\\\\u2C2E\\\\u2C30-\\\\u2C5E\\\\u2C60-\\\\u2C6F\\\\u2C71-\\\\u2C7D\\\\u2C80-\\\\u2CE4\\\\u2D00-\\\\u2D25\\\\u2D30-\\\\u2D65\\\\u2D6F\\\\u2D80-\\\\u2D96\\\\u2DA0-\\\\u2DA6\\\\u2DA8-\\\\u2DAE\\\\u2DB0-\\\\u2DB6\\\\u2DB8-\\\\u2DBE\\\\u2DC0-\\\\u2DC6\\\\u2DC8-\\\\u2DCE\\\\u2DD0-\\\\u2DD6\\\\u2DD8-\\\\u2DDE\\\\u2E2F\\\\u3005\\\\u3006\\\\u3031-\\\\u3035\\\\u303B\\\\u303C\\\\u3041-\\\\u3096\\\\u309D-\\\\u309F\\\\u30A1-\\\\u30FA\\\\u30FC-\\\\u30FF\\\\u3105-\\\\u312D\\\\u3131-\\\\u318E\\\\u31A0-\\\\u31B7\\\\u31F0-\\\\u31FF\\\\u3400\\\\u4DB5\\\\u4E00\\\\u9FC3\\\\uA000-\\\\uA48C\\\\uA500-\\\\uA60C\\\\uA610-\\\\uA61F\\\\uA62A\\\\uA62B\\\\uA640-\\\\uA65F\\\\uA662-\\\\uA66E\\\\uA67F-\\\\uA697\\\\uA717-\\\\uA71F\\\\uA722-\\\\uA788\\\\uA78B\\\\uA78C\\\\uA7FB-\\\\uA801\\\\uA803-\\\\uA805\\\\uA807-\\\\uA80A\\\\uA80C-\\\\uA822\\\\uA840-\\\\uA873\\\\uA882-\\\\uA8B3\\\\uA90A-\\\\uA925\\\\uA930-\\\\uA946\\\\uAA00-\\\\uAA28\\\\uAA40-\\\\uAA42\\\\uAA44-\\\\uAA4B\\\\uAC00\\\\uD7A3\\\\uF900-\\\\uFA2D\\\\uFA30-\\\\uFA6A\\\\uFA70-\\\\uFAD9\\\\uFB00-\\\\uFB06\\\\uFB13-\\\\uFB17\\\\uFB1D\\\\uFB1F-\\\\uFB28\\\\uFB2A-\\\\uFB36\\\\uFB38-\\\\uFB3C\\\\uFB3E\\\\uFB40\\\\uFB41\\\\uFB43\\\\uFB44\\\\uFB46-\\\\uFBB1\\\\uFBD3-\\\\uFD3D\\\\uFD50-\\\\uFD8F\\\\uFD92-\\\\uFDC7\\\\uFDF0-\\\\uFDFB\\\\uFE70-\\\\uFE74\\\\uFE76-\\\\uFEFC\\\\uFF21-\\\\uFF3A\\\\uFF41-\\\\uFF5A\\\\uFF66-\\\\uFFBE\\\\uFFC2-\\\\uFFC7\\\\uFFCA-\\\\uFFCF\\\\uFFD2-\\\\uFFD7\\\\uFFDA-\\\\uFFDC]'),\n        non_spacing_mark: new RegExp('[\\\\u0300-\\\\u036F\\\\u0483-\\\\u0487\\\\u0591-\\\\u05BD\\\\u05BF\\\\u05C1\\\\u05C2\\\\u05C4\\\\u05C5\\\\u05C7\\\\u0610-\\\\u061A\\\\u064B-\\\\u065E\\\\u0670\\\\u06D6-\\\\u06DC\\\\u06DF-\\\\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\\\\u09C1-\\\\u09C4\\\\u09CD\\\\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\\\\u0B3F\\\\u0B41-\\\\u0B44\\\\u0B4D\\\\u0B56\\\\u0B62\\\\u0B63\\\\u0B82\\\\u0BC0\\\\u0BCD\\\\u0C3E-\\\\u0C40\\\\u0C46-\\\\u0C48\\\\u0C4A-\\\\u0C4D\\\\u0C55\\\\u0C56\\\\u0C62\\\\u0C63\\\\u0CBC\\\\u0CBF\\\\u0CC6\\\\u0CCC\\\\u0CCD\\\\u0CE2\\\\u0CE3\\\\u0D41-\\\\u0D44\\\\u0D4D\\\\u0D62\\\\u0D63\\\\u0DCA\\\\u0DD2-\\\\u0DD4\\\\u0DD6\\\\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\\\\u20D0-\\\\u20DC\\\\u20E1\\\\u20E5-\\\\u20F0\\\\u2CEF-\\\\u2CF1\\\\u2DE0-\\\\u2DFF\\\\u302A-\\\\u302F\\\\u3099\\\\u309A\\\\uA66F\\\\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\\\\uFB1E\\\\uFE00-\\\\uFE0F\\\\uFE20-\\\\uFE26]'),\n        space_combining_mark: new RegExp('[\\\\u0903\\\\u093E-\\\\u0940\\\\u0949-\\\\u094C\\\\u094E\\\\u0982\\\\u0983\\\\u09BE-\\\\u09C0\\\\u09C7\\\\u09C8\\\\u09CB\\\\u09CC\\\\u09D7\\\\u0A03\\\\u0A3E-\\\\u0A40\\\\u0A83\\\\u0ABE-\\\\u0AC0\\\\u0AC9\\\\u0ACB\\\\u0ACC\\\\u0B02\\\\u0B03\\\\u0B3E\\\\u0B40\\\\u0B47\\\\u0B48\\\\u0B4B\\\\u0B4C\\\\u0B57\\\\u0BBE\\\\u0BBF\\\\u0BC1\\\\u0BC2\\\\u0BC6-\\\\u0BC8\\\\u0BCA-\\\\u0BCC\\\\u0BD7\\\\u0C01-\\\\u0C03\\\\u0C41-\\\\u0C44\\\\u0C82\\\\u0C83\\\\u0CBE\\\\u0CC0-\\\\u0CC4\\\\u0CC7\\\\u0CC8\\\\u0CCA\\\\u0CCB\\\\u0CD5\\\\u0CD6\\\\u0D02\\\\u0D03\\\\u0D3E-\\\\u0D40\\\\u0D46-\\\\u0D48\\\\u0D4A-\\\\u0D4C\\\\u0D57\\\\u0D82\\\\u0D83\\\\u0DCF-\\\\u0DD1\\\\u0DD8-\\\\u0DDF\\\\u0DF2\\\\u0DF3\\\\u0F3E\\\\u0F3F\\\\u0F7F\\\\u102B\\\\u102C\\\\u1031\\\\u1038\\\\u103B\\\\u103C\\\\u1056\\\\u1057\\\\u1062-\\\\u1064\\\\u1067-\\\\u106D\\\\u1083\\\\u1084\\\\u1087-\\\\u108C\\\\u108F\\\\u109A-\\\\u109C\\\\u17B6\\\\u17BE-\\\\u17C5\\\\u17C7\\\\u17C8\\\\u1923-\\\\u1926\\\\u1929-\\\\u192B\\\\u1930\\\\u1931\\\\u1933-\\\\u1938\\\\u19B0-\\\\u19C0\\\\u19C8\\\\u19C9\\\\u1A19-\\\\u1A1B\\\\u1A55\\\\u1A57\\\\u1A61\\\\u1A63\\\\u1A64\\\\u1A6D-\\\\u1A72\\\\u1B04\\\\u1B35\\\\u1B3B\\\\u1B3D-\\\\u1B41\\\\u1B43\\\\u1B44\\\\u1B82\\\\u1BA1\\\\u1BA6\\\\u1BA7\\\\u1BAA\\\\u1C24-\\\\u1C2B\\\\u1C34\\\\u1C35\\\\u1CE1\\\\u1CF2\\\\uA823\\\\uA824\\\\uA827\\\\uA880\\\\uA881\\\\uA8B4-\\\\uA8C3\\\\uA952\\\\uA953\\\\uA983\\\\uA9B4\\\\uA9B5\\\\uA9BA\\\\uA9BB\\\\uA9BD-\\\\uA9C0\\\\uAA2F\\\\uAA30\\\\uAA33\\\\uAA34\\\\uAA4D\\\\uAA7B\\\\uABE3\\\\uABE4\\\\uABE6\\\\uABE7\\\\uABE9\\\\uABEA\\\\uABEC]'),\n        connector_punctuation: new RegExp('[\\\\u005F\\\\u203F\\\\u2040\\\\u2054\\\\uFE33\\\\uFE34\\\\uFE4D-\\\\uFE4F\\\\uFF3F]')\n    }\n\n    function isLetter(ch) {\n        return UNICODE.letter.test(ch) || ch==='_'\n    }\n\n    // deep-equal from npm\n\n    var deepEqual = function(actual, expected, opts) {\n        if (!opts) opts = {}\n        // 7.1. All identical values are equivalent, as determined by ===.\n        if (actual === expected) {\n            return true\n        } else if (actual instanceof Date && expected instanceof Date) {\n            return actual.getTime() === expected.getTime()\n\n            // 7.3. Other pairs that do not both pass typeof value == 'object',\n            // equivalence is determined by ==.\n        } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {\n            return opts.strict ? actual === expected : actual == expected\n\n            // 7.4. For all other Object pairs, including Array objects, equivalence is\n            // determined by having the same number of owned properties (as verified\n            // with Object.prototype.hasOwnProperty.call), the same set of keys\n            // (although not necessarily the same order), equivalent values for every\n            // corresponding key, and an identical 'prototype' property. Note: this\n            // accounts for both named and indexed properties on Arrays.\n        } else {\n            return objEquiv(actual, expected, opts)\n        }\n    }\n\n    function isUndefinedOrNull(value) {\n        return value === null || value === undefined\n    }\n\n    function objEquiv(a, b, opts) {\n        var i, key\n        if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) { return false }\n        // an identical 'prototype' property.\n        if (a.prototype !== b.prototype) return false\n        // ~~~I've managed to break Object.keys through screwy arguments passing.\n        //   Converting to array solves the problem.\n\n        try {\n            var ka = obj2keys(a),\n                kb = obj2keys(b)\n        } catch (e) { // happens when one is a string literal and the other isn't\n            return false\n        }\n        // having the same number of owned properties (keys incorporates\n        // hasOwnProperty)\n        if (ka.length != kb.length) { return false }\n        // the same set of keys (although not necessarily the same order),\n        ka.sort()\n        kb.sort()\n        // ~~~cheap key test\n        for (i = ka.length - 1; i >= 0; i--) {\n            if (ka[i] != kb[i]) { return false }\n        }\n        // equivalent values for every corresponding key, and\n        // ~~~possibly expensive deep test\n        for (i = ka.length - 1; i >= 0; i--) {\n            key = ka[i]\n            if (!deepEqual(a[key], b[key], opts)) return false\n        }\n        return typeof a === typeof b\n    }\n\n    /*\n    object-assign\n    (c) Sindre Sorhus\n    @license MIT\n    */\n\n    var getOwnPropertySymbols = Object.getOwnPropertySymbols\n    var hasOwnProperty = Object.prototype.hasOwnProperty\n    var propIsEnumerable = Object.prototype.propertyIsEnumerable\n\n    function toObject(val) {\n        if (val === null || val === undefined) {\n            throw new TypeError('Object.assign cannot be called with null or undefined')\n        }\n\n        return Object(val)\n    }\n\n    function shouldUseNative() {\n        try {\n            if (!Object.assign) {\n                return false\n            }\n\n            // Detect buggy property enumeration order in older V8 versions.\n\n            // https://bugs.chromium.org/p/v8/issues/detail?id=4118\n            var test1 = new String('abc') // eslint-disable-line no-new-wrappers\n            test1[5] = 'de'\n            if (Object.getOwnPropertyNames(test1)[0] === '5') {\n                return false\n            }\n\n            // https://bugs.chromium.org/p/v8/issues/detail?id=3056\n            var test2 = {}\n            for (var i = 0; i < 10; i++) {\n                test2['_' + String.fromCharCode(i)] = i\n            }\n            var order2 = Object.getOwnPropertyNames(test2).map(function(n) {\n                return test2[n]\n            })\n            if (order2.join('') !== '0123456789') {\n                return false\n            }\n\n            // https://bugs.chromium.org/p/v8/issues/detail?id=3056\n            var test3 = {}\n            'abcdefghijklmnopqrst'.split('').forEach(function(letter) {\n                test3[letter] = letter\n            })\n            if (Object.keys(Object.assign({}, test3)).join('') !==\n                'abcdefghijklmnopqrst') {\n                return false\n            }\n\n            return true\n        } catch (err) {\n            // We don't expect any of the above to throw, but better to be safe.\n            return false\n        }\n    }\n\n    var objAssign = shouldUseNative() ? Object.assign : function(target, source) {\n        var from\n        var to = toObject(target)\n        var symbols\n\n        for (var s = 1; s < arguments.length; s++) {\n            from = Object(arguments[s])\n\n            for (var key in from) {\n                if (hasOwnProperty.call(from, key)) {\n                    to[key] = from[key]\n                }\n            }\n\n            if (getOwnPropertySymbols) {\n                symbols = getOwnPropertySymbols(from)\n                for (var i = 0; i < symbols.length; i++) {\n                    if (propIsEnumerable.call(from, symbols[i])) {\n                        to[symbols[i]] = from[symbols[i]]\n                    }\n                }\n            }\n        }\n\n        return to\n    }\n\n    var Lexer = function(text) {\n        this.line = 0\n        this.pos = 0\n        this.col = 0\n        this.text = text\n        this.list = []\n    }\n\n    Lexer.prototype = {\n        readNum: function(prefix) {\n            var has_e = false, after_e = false, has_x = false, has_dot = prefix == '.'\n            var num = this.readWhile(function(ch, i) {\n                if (ch == 'x' || ch == 'X') {\n                    if (has_x) return false\n                    return has_x = true\n                }\n                if (!has_x && (ch == 'E' || ch == 'e')) {\n                    if (has_e) return false\n                    return has_e = after_e = true\n                }\n                if (ch == '-') {\n                    if (after_e || (i == 0 && !prefix)) return true\n                    return false\n                }\n                if (ch == '+') return after_e\n                after_e = false\n                if (ch == '.') {\n                    if (!has_dot && !has_x) { return has_dot = true }\n                    return false\n                }\n                return isAlphanumericChar(ch)\n            })\n            if (prefix) { num = prefix + num }\n            return {\n                value: parseJsNumber(num),\n                type: 'number'\n            }\n        },\n\n        readWhile: function(pred) {\n            var ret = '', ch = this.peek(), i = 0\n            while (ch && pred(ch, i++)) {\n                ret += this.next()\n                ch = this.peek()\n            }\n            return ret\n        },\n\n        readName: function() {\n            var name = '', ch\n            while ((ch = this.peek()) != null) {\n                if (isLetter(ch) || isDigit(ch)) {\n                    name += this.next()\n                } else {\n                    break\n                }\n            }\n            return name\n        },\n\n        readString: function() {\n            var quote = this.next(), ret = ''\n            for (; ;) {\n                var ch = this.next()\n                // if (ch == \"\\\\\") ch = read_escaped_char();\n                if (ch == quote) break\n                ret += ch\n            }\n            return {\n                type: 'string',\n                value: ret,\n                line: this.line,\n                pos: this.pos,\n                col: this.col\n            }\n        },\n\n        readWord: function() {\n            var word = this.readName()\n            if (HOP(KEYWORD, word)) {\n                return {\n                    type: 'keyword',\n                    value: word,\n                    line: this.line,\n                    pos: this.pos,\n                    col: this.col\n                }\n            } else if (HOP(KEYWORDS_ATOM, word)) {\n                return {\n                    type: 'atom',\n                    value: word,\n                    line: this.line,\n                    pos: this.pos,\n                    col: this.col\n                }\n            } else {\n                return {\n                    type: 'name',\n                    value: word,\n                    line: this.line,\n                    pos: this.pos,\n                    col: this.col\n                }\n            }\n        },\n\n        next: function() {\n            var ch = this.text.charAt(this.pos++)\n\n            if (ch == '\\n') {\n                this.line++\n                this.col = 0\n            } else {\n                this.col++\n            }\n            return ch\n        },\n\n        peek: function() {\n            return this.text.charAt(this.pos)\n        },\n\n        skipWhitespace: function() {\n            while (HOP(WHITESPACE_CHARS, this.peek())) {\n                this.next()\n            }\n        },\n\n        scan: function() {\n            this.skipWhitespace()\n            var ch = this.peek()\n\n            if (isLetter(ch)) {\n                return this.readWord()\n            } else if (HOP(PUNC_CHARS, ch)) {\n                return {\n                    type: 'punc',\n                    value: this.next()\n                }\n            } else if (HOP(PUNC_BEFORE_EXPRESSION, ch)) {\n                return {\n                    type: 'punc',\n                    value: this.next()\n                }\n            } else if (HOP(OPERATOR_CHARS, ch)) {\n                if (ch === '&' && this.text.charAt(this.pos + 1) === '&') {\n                    this.col += 2\n                    this.pos += 2\n                    return {\n                        type: 'operator',\n                        value: '&&'\n                    }\n                } else if (ch === '|' && this.text.charAt(this.pos + 1) === '|') {\n                    this.col += 2\n                    this.pos += 2\n                    return {\n                        type: 'operator',\n                        value: '||'\n                    }\n                } else if (ch === '!' && this.text.charAt(this.pos + 1) === '=') {\n                    if (this.text.charAt(this.pos + 2) === '=') {\n                        this.col += 3\n                        this.pos += 3\n                    } else {\n                        this.col += 2\n                        this.pos += 2\n                    }\n\n                    return {\n                        type: 'operator',\n                        value: '!='\n                    }\n                } else if (ch === '<' && this.text.charAt(this.pos + 1) === '>') {\n                    this.col += 2\n                    this.pos += 2\n                    return {\n                        type: 'operator',\n                        value: '!='\n                    }\n                } else if (ch === '=' && this.text.charAt(this.pos + 1) === '=') {\n                    if (this.text.charAt(this.pos + 2) === '=') {\n                        this.col += 3\n                        this.pos += 3\n                    } else {\n                        this.col += 2\n                        this.pos += 2\n                    }\n                    return {\n                        type: 'operator',\n                        value: '='\n                    }\n                } else if (ch === '>' && this.text.charAt(this.pos + 1) === '=') {\n                    this.col += 2\n                    this.pos += 2\n\n                    return {\n                        type: 'operator',\n                        value: '>='\n                    }\n                } else if (ch === '<' && this.text.charAt(this.pos + 1) === '=') {\n                    this.col += 2\n                    this.pos += 2\n\n                    return {\n                        type: 'operator',\n                        value: '<='\n                    }\n                }\n\n                return {\n                    type: 'operator',\n                    value: this.next()\n                }\n            } else if (isDigit(ch)) {\n                return this.readNum()\n            } else if (ch == '\\n') {\n                return {\n                    type: 'br',\n                    value: this.next()\n                }\n            } else if (ch == '\"' || ch == \"'\") {\n                return this.readString()\n            }\n        },\n\n        start: function() {\n            var t = this.scan()\n            if (t !== undefined) {\n                this.list.push(t)\n                this.start()\n            }\n        }\n    }\n\n    var Parser = function(tokens) {\n        this.tokens = tokens\n        this.index = 0\n        this.ast = []\n    }\n\n    Parser.prototype = {\n        start: function() {\n            this.parse()\n        },\n\n        _isKeyword: function(item) {\n            return item.type === 'keyword' && (item.value === 'from' || item.value === 'where' || item.value === 'select' || item.value === 'orderby' || item.value === 'groupby' || item.value === 'limit')\n        },\n\n        _conditions: function() {\n            var exp = []\n\n            var item = this.tokens[this.index]\n            while (!this._isKeyword(item)) {\n                if (this._is('punc', '(')) {\n                    this.index++\n                    exp.push([this._conditionBlock()])\n                } else if (item.value === '&&' || item.value === '||') {\n                    this.index++\n                    exp.push(item.value)\n                    exp.push(this._condition())\n                } else if (this._is(item, 'operator', '!')) {\n                    var next = this.tokens[this.index + 1]\n                    if (this._is(next, 'punc', '(')) {\n                        this.index += 2\n\n                        exp.push(['!', this._conditionBlock()])\n                    } else if (next.type === 'name') {\n                        this.index++\n                        exp.push(['!', this._prop()])\n                    }\n                } else {\n                    var arr = this._condition()\n                    if (arr.length > 0) {\n                        exp.push(arr)\n                    }\n                }\n\n                this.index++\n                item = this.tokens[this.index]\n            }\n\n            return exp\n        },\n\n        _conditionBlock: function() {\n            var exp = []\n            var item = this.tokens[this.index]\n            while (!(this._is(item, 'punc', ')') || this._isKeyword(item))) {\n                if (this._is(item, 'punc', '(')) {\n                    this.index++\n                    exp.push(this._conditionBlock())\n                } else if (item.value === '&&' || item.value === '||') {\n                    this.index++\n                    exp.push(item.value)\n                    exp.push(this._condition())\n                } else if (this._is(item, 'operator', '!')) {\n                    var next = this.tokens[this.index + 1]\n                    if (this._is(next, 'punc', '(')) {\n                        this.index += 2\n                        exp.push(['!', this._conditionBlock()])\n                    } else if (next.type === 'name') {\n                        this.index++\n                        exp.push(['!', this._prop()])\n                    }\n                } else {\n                    exp.push(this._condition())\n                }\n                this.index++\n                item = this.tokens[this.index]\n            }\n            return exp\n        },\n\n        _condition: function() {\n            var exp = []\n            var item = this.tokens[this.index]\n            while (!(\n                this._is(item, 'punc', ')') ||\n                ((item.value === '&&' || item.value === '||') && item.type === 'operator') ||\n                this._isKeyword(item)\n            )) {\n                if (this._is(item, 'punc', '(')) {\n                    this.index++\n                    exp.push(this._conditionBlock())\n                } else if (item.type === 'name') {\n                    exp.push(this._prop())\n                } else if (this._is(item, 'operator', '!')) {\n                    var next = this.tokens[this.index + 1]\n                    if (this._is(next, 'punc', '(')) {\n                        this.index += 2\n                        exp.push(['!', this._conditionBlock()])\n                    } else if (next.type === 'name') {\n                        this.index++\n                        exp.push(['!', this._prop()])\n                    }\n                } else if (item.type === 'atom') {\n                    exp.push(atomMapping[item.value])\n                } else if (item.type !== 'br') {\n                    exp.push(item.value)\n                }\n                this.index++\n                item = this.tokens[this.index]\n            }\n            this.index--\n            return exp\n        },\n\n        _prop: function() {\n            var result = []\n            var item = this.tokens[this.index]\n            if (item.type === 'name' &&this.tokens[this.index + 1] && this._is(this.tokens[this.index + 1], 'punc', '(')) {\n                this.index += 2\n                result = { name: item.value, args: this._args() }\n            } else {\n                while (item&&(item.type === 'string' || item.type === 'number' || item.type === 'name' || item.type === 'atom' ||\n                    (item.type === 'punc' &&\n                        (item.value === '.' || item.value === '[' || item.value === ']')))) {\n                    if (!(item.type === 'punc' &&\n                        (item.value === '.' || item.value === '[' || item.value === ']'))) {\n                        if (result.length > 0 || item.type === 'name') {\n                            result.push(item.value)\n                        } else {\n                            result = item\n                        }\n                    }\n                    this.index++\n                    item = this.tokens[this.index]\n                }\n                this.index--\n            }\n\n            return result\n        },\n\n        _parseCondition: function(preCond) {\n            var cond = this._splitArray(preCond, '||'),\n                self = this\n\n            cond.forEach(function(item, index) {\n                if (isArray(item)) {\n                    cond[index] = self._parseCondition(item)\n                }\n            })\n\n            return cond\n        },\n\n        _splitArray: function(array, key) {\n            if (array.indexOf(key) === -1) {\n                return array\n            }\n\n            var result = [],\n                current = []\n\n            array.forEach(function(item) {\n                if (item !== key) {\n                    current.push(item)\n                } else {\n                    result.push(current)\n                    result.push(key)\n                    current = []\n                }\n            })\n            result.push(current)\n            return result\n        },\n\n        _select: function() {\n            var item = this.tokens[this.index]\n            if (item.value === '{') {\n                this.index++\n                if (this.tokens[this.index + 1].value === ':') {\n                    return this._json()\n                } else {\n                    return this._simpleJson()\n                }\n            } else {\n                return this._propList()\n            }\n        },\n\n        _json: function() {\n            var result = []\n            var item = this.tokens[this.index],\n                current = {}\n\n            while (item.value !== '}') {\n                if (this.tokens[this.index + 1].value === ':') {\n                    current.key = this._prop()[0]\n                }\n                if (item.value === ':') {\n                    this.index++\n                    current.value = this._prop()\n                } else if (item.value === ',') {\n                    this.index++\n                    result.push(current)\n                    current = {}\n                    current.key = this._prop()[0]\n                }\n\n                this.index++\n                item = this.tokens[this.index]\n            }\n            result.push(current)\n            this.index--\n            return { json: result }\n        },\n\n        _simpleJson: function() {\n            var result = []\n            var item = this.tokens[this.index]\n\n            while (item.value !== '}') {\n                result = this._propList()\n                item = this.tokens[this.index]\n            }\n            this.index--\n            var jsonArr = []\n            result.forEach(function(item) {\n                jsonArr.push({ key: item[item.length - 1], value: item })\n            })\n            return { json: jsonArr }\n        },\n\n        _propList: function() {\n            var result = []\n            var item = this.tokens[this.index]\n\n            while (item && item.value !== '}' && !this._isKeyword(item)) {\n                if (item.value === ',' || item.type === 'br') {\n                    this.index++\n                } else {\n                    result.push(this._prop())\n                    this.index++\n                }\n                item = this.tokens[this.index]\n            }\n\n            return result\n        },\n\n        _is: function(item, type, value) {\n            return item.type === type && item.value === value\n        },\n\n        _args: function() {\n            var result = [],\n                item = this.tokens[this.index]\n            while (!(this._is(item, 'punc', ')'))) {\n                if (this._is(this.tokens[this.index], 'punc', ',')) {\n                    this.index++\n                }\n\n                var exp = this._prop()\n\n                result.push(exp)\n\n                this.index++\n                item = this.tokens[this.index]\n            }\n\n            return result\n        },\n\n        _orderby: function() {\n            var prop = []\n            var item = this.tokens[this.index]\n            var current = { desc: false }\n            while (!(item.type === 'keyword' && item.value !== 'desc' && item.value !== 'asc')) {\n                if (item.type === 'name') {\n                    current.prop = this._prop()\n                } else if (this._is(item, 'keyword', 'desc')) {\n                    current.desc = true\n                    prop.push(current)\n                    current = { desc: false }\n                } else if (this._is(item, 'punc', ',')) {\n                    if (current.prop) {\n                        prop.push(current)\n                    }\n                    current = { desc: false }\n                }\n                this.index++\n                item = this.tokens[this.index]\n            }\n            if (current.prop) {\n                prop.push(current)\n            }\n            return prop\n        },\n\n        _limit: function() {\n            var result = []\n            var item = this.tokens[this.index]\n            while (item && !this._isKeyword(item)) {\n                if (item.type === 'number') {\n                    result.push(item.value)\n                }\n                this.index++\n                item = this.tokens[this.index]\n            }\n            return result\n        },\n\n        parse: function() {\n            var item = this.tokens[this.index]\n            if (!item) {\n                return\n            }\n\n            switch (item.type) {\n            case 'keyword':\n                switch (item.value) {\n                case 'from':\n                    var key = this.tokens[this.index + 1].value\n                    this.index += 3\n                    this.ast.push(['from', [key, this._prop()]])\n                    this.index += 1\n                    this.parse()\n                    break\n\n                case 'where':\n                    this.index++\n                    this.ast.push(['where', this._parseCondition(this._conditions())])\n                    this.parse()\n                    break\n\n                case 'select':\n                    this.index++\n                    this.ast.push(['select', this._select()])\n                    this.parse()\n                    break\n\n                case 'orderby':\n                    this.index++\n                    this.ast.push(['orderby', this._orderby()])\n                    this.parse()\n                    break\n\n                case 'groupby':\n                    this.index++\n                    this.ast.push(['groupby', this._propList()])\n                    this.parse()\n                    break\n\n                case 'limit':\n                    this.index++\n                    this.ast.push(['limit', this._limit()])\n                    this.parse()\n                    break\n                }\n                break\n            case 'br':\n                this.index++\n                this.parse()\n                break\n            }\n        }\n    }\n\n    var Qone = function(data) {\n        this.data = this.extend(data)\n        this.ast = null\n        this.keyMap = {}\n    }\n\n    Qone.methodMap = {}\n\n    Qone.prototype = {\n        extend: function(from, to) {\n            if (from == null || typeof from != 'object') return from\n            if (from.constructor != Object && from.constructor != Array) return from\n            if (from.constructor == Date || from.constructor == RegExp || from.constructor == Function ||\n                from.constructor == String || from.constructor == Number || from.constructor == Boolean) { return new from.constructor(from) }\n\n            to = to || new from.constructor()\n\n            for (var name in from) {\n                to[name] = typeof to[name] == 'undefined' ? this.extend(from[name], null) : to[name]\n            }\n\n            return to\n        },\n\n        query: function(text) {\n            var lexer = new Lexer(text)\n            lexer.start()\n            var parser = new Parser(lexer.list)\n            parser.start()\n            this.ast = parser.ast\n            this.exce()\n\n            return this.result\n        },\n\n        preprocessData: function(key, list) {\n            list.forEach(function(subItem, index, self) {\n                self[index] = {}\n                self[index][key] = subItem\n            })\n        },\n\n        productSelf: function(key, path) {\n            var self = this,\n                newCp = []\n            this.cp.forEach(function(item) {\n                var list = JSON.parse(JSON.stringify(self._getDataByPath(item, path)))\n                self.preprocessData(key, list)\n                self.productOut([item], list, newCp)\n            })\n            this.cp = newCp\n        },\n\n        exce: function() {\n            var ast = this.ast,\n                key\n\n            var i = 0, len = ast.length\n            for (; i < len; i++) {\n                var cmd = ast[i]\n                switch (cmd[0]) {\n                case 'from':\n                    var topName = cmd[1][1][0]\n                    if (this.keyMap[topName]) {\n                        this.keyMap[cmd[1][0]] = cmd[1][1]\n                        this.productSelf(cmd[1][0], cmd[1][1], this.keyMap, this.cp)\n                    } else {\n                        key = cmd[1][0]\n                        var list = this._getDataByPath(this.data, cmd[1][1])\n                        this.preprocessData(key, list)\n                        if (this.cp) {\n                            this.cp = this.product(this.cp, list)\n                        } else {\n                            this.cp = list\n                        }\n                        this.keyMap[cmd[1][0]] = cmd[1][1]\n                    }\n\n                    if (ast[i + 1][0] === 'where') {\n                        this.filter(ast[i + 1][1])\n                        i++\n                    }\n                    break\n\n                case 'where':\n                    this.filter(ast[i][1])\n                    break\n\n                case 'select':\n                    this.select(cmd[1])\n                    break\n\n                case 'orderby':\n                    var keys = []\n                    var orders = []\n                    cmd[1].forEach(function(item) {\n                        keys.push(item.prop)\n                        orders.push(item.desc ? 'desc' : 'asc')\n                    })\n                    this._orderby(this.cp, keys, orders)\n                    break\n\n                case 'groupby':\n                    this.groupby(this.cp, cmd[1])\n                    key = obj2keys(this.keyMap)[0]\n                    this.result.forEach(function(arr) {\n                        arr.forEach(function(item, index, scope) {\n                            scope[index] = item[key]\n                        })\n                    })\n                    break\n\n                case 'limit':\n                    this.limitData(cmd[1])\n                    break\n                }\n            }\n        },\n\n        limitData: function(arr) {\n            this.result = this.result.splice(arr[0], arr[1])\n        },\n\n        // grouper from npm\n        groupby: function(arr, props, opts) {\n            var comparator,\n                self = this\n            if (typeof props === 'function') {\n                comparator = props\n            } else {\n                if (isObject(props)) { // argument shuffling for grouping by object value\n                    opts = props\n                    props = []\n                }\n                opts = opts || {}\n                if (typeof opts.strict === 'undefined') {\n                    opts.strict = true // default to strict `===`\n                }\n                props = [].concat(props).filter(Boolean)\n                var propsLen = props.length\n                if (propsLen === 0) {\n                    comparator = function(a, b) {\n                        return deepEqual(a, b, opts)\n                    }\n                } else {\n                    comparator = function(a, b) {\n                        var k = -1\n                        while (++k < propsLen) {\n                            // check if `a` has the same values as `b` for every property in `props`\n                            var prop = props[k],\n                                left,\n                                right\n\n                            if (isArray(prop)) {\n                                left = self._getDataByPath(a, prop)\n                                right = self._getDataByPath(b, prop)\n                            } else {\n                                left = self.callMethod(a, prop.name, prop.args)\n                                right = self.callMethod(b, prop.name, prop.args)\n                            }\n                            if (!deepEqual(left, right, opts)) {\n                                return false\n                            }\n                        }\n                        return true\n                    }\n                }\n            }\n\n            var result = []\n            var arrLen = arr.length\n            var i = -1\n            // for every `arr[i]` in `arr`...\n            while (++i < arrLen) {\n                var wasAdded = false\n                var resultLen = result.length\n                var j = -1\n                // for every `result[j]` group in `result`...\n                while (++j < resultLen) {\n                    // check if `arr[i]` belongs to the `result[j]` group\n                    if (comparator(arr[i], result[j][0])) {\n                        result[j].push(arr[i])\n                        wasAdded = true\n                    }\n                }\n                // if `arr[i]` was not added to any group, create a new group containing only\n                // `arr[i]` and add it to `result`\n                if (!wasAdded) {\n                    result.push([arr[i]])\n                }\n            }\n\n            this.result = result\n        },\n\n        callMethod: function(scope, name, args) {\n            var argsValue = [],\n                self = this\n\n            args.forEach(function(arg) {\n                if (isArray(arg)) {\n                    argsValue.push(self._getDataByPath(scope, arg))\n                } else {\n                    argsValue.push(arg.value)\n                }\n            })\n\n            return Qone.methodMap[name].apply(null, argsValue)\n        },\n\n        select: function(cmd) {\n            var result = [],\n                self = this,\n                json = cmd.json,\n                data = null\n\n            if (json) {\n                this.cp.forEach(function(item) {\n                    var obj = {}\n                    if (json.length === 1) {\n                        var prop = json[0]\n                        if (isArray(prop.value)) {\n                            data = self._getDataByPath(item, prop.value)\n                        } else {\n                            data = self.callMethod(item, prop.value.name, prop.value.args)\n                        }\n                        obj[prop.key] = data\n                        result.push(obj)\n                    } else {\n                        json.forEach(function(prop) {\n                            if (isArray(prop.value)) {\n                                data = self._getDataByPath(item, prop.value)\n                            } else {\n                                data = self.callMethod(item, prop.value.name, prop.value.args)\n                            }\n                            obj[prop.key] = data\n                        })\n                        result.push(obj)\n                    }\n                })\n            } else {\n                this.cp.forEach(function(item) {\n                    if (cmd.length === 1) {\n                        var prop = cmd[0]\n\n                        if (isArray(prop)) {\n                            data = self._getDataByPath(item, prop)\n                        } else {\n                            data = self.callMethod(item, prop.name, prop.args)\n                        }\n                        result.push(data)\n                    } else {\n                        var arr = []\n                        cmd.forEach(function(prop) {\n                            if (isArray(prop)) {\n                                data = self._getDataByPath(item, prop)\n                            } else {\n                                data = self.callMethod(item, prop.name, prop.args)\n                            }\n\n                            arr.push(data)\n                        })\n                        result.push(arr)\n                    }\n                })\n            }\n            this.result = result\n        },\n\n        filter: function(where) {\n            var self = this\n\n            var result = []\n            this.cp.forEach(function(item) {\n                if (self._check(item, where)) {\n                    result.push(item)\n                }\n            })\n\n            this.result = result\n            this.cp = result\n        },\n\n        product: function(a, b) {\n            var result = []\n            a.forEach(function(itemA) {\n                b.forEach(function(itemB) {\n                    result.push(objAssign({}, itemA, itemB))\n                })\n            })\n            return result\n        },\n\n        productOut: function(a, b, out) {\n            a.forEach(function(itemA) {\n                b.forEach(function(itemB) {\n                    out.push(objAssign({}, itemA, itemB))\n                })\n            })\n        },\n\n        _isBool: function(cond) {\n            var result = true,\n                i = 0,\n                len = cond.length\n            for (; i < len; i++) {\n                if (typeof cond[i] === 'object') {\n                    result = false\n                    break\n                }\n            }\n\n            return result\n        },\n\n        _check: function(item, cond) {\n            var self = this\n            var len = cond.length\n\n            if (len === 1 && isArray(cond)) {\n                return this._check(item, cond[0])\n            } else if (len === 2 && cond[0] === '!') {\n                return !this._check(item, cond[1])\n            } else if (this._isBool(cond)) {\n                if (isArray(cond)) {\n                    return this._getDataByPath(item, cond)\n                } else {\n                    return this.callMethod(item, cond.name, cond.args)\n                }\n            } else if (len === 3 && (cond[1] !== '||' && cond[1] !== '&&')) {\n                return this._checkCond(item, cond)\n            } else {\n                var i = 0,\n                    result = true\n                while (i < len) {\n                    var condItem = cond[i]\n                    result = self._check(item, condItem)\n                    i++\n                    if (result) {\n                        if (cond[i] === '||') {\n                            return true\n                        }\n                    } else {\n                        if (cond[i] === '&&') {\n                            return false\n                        }\n                    }\n\n                    i++\n                }\n\n                return result\n            }\n        },\n\n        _checkCond: function(item, cond) {\n            var result = true,\n                left = cond[0],\n                right = cond[2]\n\n            if (isArray(left)) {\n                left = this._getDataByPath(item, left)\n            } else if (isObject(left)) {\n                left = this.callMethod(item, left.name, left.args)\n            }\n\n            if (isArray(right)) {\n                right = this._getDataByPath(item, right)\n            } else if (isObject(right)) {\n                right = this.callMethod(item, right.name, right.args)\n            }\n            if (!this._cond(left, cond[1], right)) {\n                result = false\n            }\n            return result\n        },\n\n        _cond: function(a, op, b) {\n            switch (op) {\n            case '>':\n                return a > b\n            case '<':\n                return a < b\n            case '>=':\n                return a >= b\n            case '<=':\n                return a <= b\n            case '=':\n                return a === b\n            case '!=':\n                return a !== b\n            }\n        },\n\n        _getDataByPath: function(root, arr) {\n            var current = root\n            arr.forEach(function(prop, index) {\n                current = current[prop]\n            })\n            return current\n        },\n\n        // ipe from https://gist.github.com/finom/727b971ca5d62d25a228\n        _orderby: function(arr, keys, orders) {\n            var defaultOrder = 'asc',\n                commonOrder,\n                self = this,\n                left,\n                right\n\n            if ('length' in arr && typeof arr == 'object') {\n                if (!(orders instanceof Array)) {\n                    commonOrder = orders || defaultOrder\n                }\n\n                keys = keys instanceof Array ? keys : [keys]\n\n                return arr.sort(function(a, b) {\n                    var length = keys.length,\n                        i,\n                        order,\n                        key\n\n                    if (a && b) {\n                        for (i = 0; i < length; i++) {\n                            key = keys[i]\n                            order = (commonOrder || orders[i] || defaultOrder) == 'asc' ? -1 : 1\n\n                            if (isArray(key)) {\n                                left = self._getDataByPath(a, key)\n                                right = self._getDataByPath(b, key)\n                            } else {\n                                left = self.callMethod(a, key.name, key.args)\n                                right = self.callMethod(b, key.name, key.args)\n                            }\n\n                            if (left > right) {\n                                return -order\n                            } else if (left < right) {\n                                return order\n                            }\n                        }\n                    }\n\n                    return 0\n                })\n            } else {\n                return []\n            }\n        }\n    }\n\n    var qone = function qone(data) {\n        if (arguments.length === 2) {\n            var methodName = arguments[0]\n            if (Qone.methodMap[methodName]) {\n                console.warn('[' + methodName + '] method has been defined. you will rewrite it.')\n            }\n            Qone.methodMap[methodName] = arguments[1]\n        } else {\n            return new Qone(data)\n        }\n    }\n\n    return qone\n}))"
  },
  {
    "path": "test/clone.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n\n</head>\n\n<body>\n  <div id=\"aa\">aa</div>\n  <script>\n\n    var S = function (num) {\n      this.num = num\n    }\n\n    S.prototype = {\n      a: function () {\n\n      }\n    }\n\n    function extend(from, to) {\n      if (from == null || typeof from != \"object\") return from;\n      if (from.constructor != Object && from.constructor != Array) return from;\n      if (from.constructor == Date || from.constructor == RegExp || from.constructor == Function ||\n        from.constructor == String || from.constructor == Number || from.constructor == Boolean)\n        return new from.constructor(from);\n\n      to = to || new from.constructor();\n\n      for (var name in from) {\n        to[name] = typeof to[name] == \"undefined\" ? extend(from[name], null) : to[name];\n      }\n\n      return to;\n    }\n\n    var obj =\n      {\n        aaa: Symbol(11),\n        s: new S(1),\n        S: S,\n        a: true,\n        b: false,\n        c: null,\n        d: undefined,\n        dom: document.getElementById('aa'),\n        date: new Date(),\n        func: function (q) { return 1 + q; },\n        num: 123,\n        text: \"asdasd\",\n        array: [1, \"asd\"],\n        array2: [{ a: 11 }, \"asd\"],\n        regex: new RegExp(/aaa/i),\n        subobj:\n          {\n            num: 234,\n            text: \"asdsaD\"\n          }\n      }\n\n    var clone = extend(obj);\n\n    console.log(clone.aaa === obj.aaa)\n    console.log(clone.date === obj.date)\n    console.log(clone.dom === obj.dom)\n    console.log('---------')\n    console.log(clone.array === obj.array)\n    console.log(obj === clone)\n\n\n  </script>\n</body>\n\n</html>"
  },
  {
    "path": "test/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n  <meta charset=\"utf-8\">\n  <link rel=\"icon\" type=\"images/png\"  href=\"../asset/qone.ico\">\n  <meta name=\"viewport\" content=\"width=device-width\">\n  <title>Qone Unit Testing</title>\n  <link rel=\"stylesheet\" href=\"./lib/qunit.css\">\n</head>\n\n<body>\n  <div id=\"qunit\"></div>\n  <div id=\"qunit-fixture\"></div>\n  <script src=\"./lib/qunit.js\"></script>\n  <script src=\"../qone.min.js\"></script>\n  <script src=\"test.js\"></script>\n\n</body>\n\n</html>"
  },
  {
    "path": "test/index.ie.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n  <meta charset=\"utf-8\">\n  <link rel=\"icon\" type=\"images/png\" href=\"../asset/qone.ico\">\n  <meta name=\"viewport\" content=\"width=device-width\">\n  <title>Qone Unit Testing</title>\n\n</head>\n\n<body>\n  <!--[if lt IE 9]><script type=\"text/javascript\" crossorigin=\"anonymous\" src=\"//s.url.cn/qqun/xiaoqu/buluo/p/js/es5-sham-es5-sham.min.77c4325f.js\"></script><![endif]-->\n\n  </script>\n  <div id=\"qunit\"></div>\n  <div id=\"qunit-fixture\"></div>\n  <script>\n\n    var JSON = JSON || {};\n\n    // implement JSON.stringify serialization\n    JSON.stringify = JSON.stringify || function (obj) {\n\n      var t = typeof (obj);\n      if (t != \"object\" || obj === null) {\n\n        // simple data type\n        if (t == \"string\") obj = '\"' + obj + '\"';\n        return String(obj);\n\n      }\n      else {\n\n        // recurse array or object\n        var n, v, json = [], arr = (obj && obj.constructor == Array);\n\n        for (n in obj) {\n          v = obj[n]; t = typeof (v);\n\n          if (t == \"string\") v = '\"' + v + '\"';\n          else if (t == \"object\" && v !== null) v = JSON.stringify(v);\n\n          json.push((arr ? \"\" : '\"' + n + '\":') + String(v));\n        }\n\n        return (arr ? \"[\" : \"{\") + String(json) + (arr ? \"]\" : \"}\");\n      }\n    };\n\n    // implement JSON.parse de-serialization\n    JSON.parse = JSON.parse || function (str) {\n      if (str === \"\") str = '\"\"';\n      eval(\"var p=\" + str + \";\");\n      return p;\n    };\n\n    var QUnit = {}\n    QUnit.test = function (name, fn) {\n      console.log('------' + name + '------')\n      fn({\n        equal: function (a, b) {\n          var result = a === b\n          console.log(result)\n          if (!result) throw name\n        },\n        deepEqual: function (a, b) {\n          var result = JSON.stringify(a) === JSON.stringify(b)\n          console.log(result)\n          if (!result) throw name\n        }\n      })\n    }\n\n  </script>\n  <script src=\"../qone.min.js\"></script>\n  <script src=\"test.ie.js\"></script>\n\n</body>\n\n</html>"
  },
  {
    "path": "test/lib/qunit.css",
    "content": "/*!\n * QUnit 2.6.1-pre\n * https://qunitjs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2018-03-27T02:25Z\n */\n\n/** Font Family and Sizes */\n\n#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {\n\tfont-family: \"Helvetica Neue Light\", \"HelveticaNeue-Light\", \"Helvetica Neue\", Calibri, Helvetica, Arial, sans-serif;\n}\n\n#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }\n#qunit-tests { font-size: smaller; }\n\n\n/** Resets */\n\n#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {\n\tmargin: 0;\n\tpadding: 0;\n}\n\n\n/** Header (excluding toolbar) */\n\n#qunit-header {\n\tpadding: 0.5em 0 0.5em 1em;\n\n\tcolor: #8699A4;\n\tbackground-color: #0D3349;\n\n\tfont-size: 1.5em;\n\tline-height: 1em;\n\tfont-weight: 400;\n\n\tborder-radius: 5px 5px 0 0;\n}\n\n#qunit-header a {\n\ttext-decoration: none;\n\tcolor: #C2CCD1;\n}\n\n#qunit-header a:hover,\n#qunit-header a:focus {\n\tcolor: #FFF;\n}\n\n#qunit-banner {\n\theight: 5px;\n}\n\n#qunit-filteredTest {\n\tpadding: 0.5em 1em 0.5em 1em;\n\tcolor: #366097;\n\tbackground-color: #F4FF77;\n}\n\n#qunit-userAgent {\n\tpadding: 0.5em 1em 0.5em 1em;\n\tcolor: #FFF;\n\tbackground-color: #2B81AF;\n\ttext-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;\n}\n\n\n/** Toolbar */\n\n#qunit-testrunner-toolbar {\n\tpadding: 0.5em 1em 0.5em 1em;\n\tcolor: #5E740B;\n\tbackground-color: #EEE;\n}\n\n#qunit-testrunner-toolbar .clearfix {\n\theight: 0;\n\tclear: both;\n}\n\n#qunit-testrunner-toolbar label {\n\tdisplay: inline-block;\n}\n\n#qunit-testrunner-toolbar input[type=checkbox],\n#qunit-testrunner-toolbar input[type=radio] {\n\tmargin: 3px;\n\tvertical-align: -2px;\n}\n\n#qunit-testrunner-toolbar input[type=text] {\n\tbox-sizing: border-box;\n\theight: 1.6em;\n}\n\n.qunit-url-config,\n.qunit-filter,\n#qunit-modulefilter {\n\tdisplay: inline-block;\n\tline-height: 2.1em;\n}\n\n.qunit-filter,\n#qunit-modulefilter {\n\tfloat: right;\n\tposition: relative;\n\tmargin-left: 1em;\n}\n\n.qunit-url-config label {\n\tmargin-right: 0.5em;\n}\n\n#qunit-modulefilter-search {\n\tbox-sizing: border-box;\n\twidth: 400px;\n}\n\n#qunit-modulefilter-search-container:after {\n\tposition: absolute;\n\tright: 0.3em;\n\tcontent: \"\\25bc\";\n\tcolor: black;\n}\n\n#qunit-modulefilter-dropdown {\n\t/* align with #qunit-modulefilter-search */\n\tbox-sizing: border-box;\n\twidth: 400px;\n\tposition: absolute;\n\tright: 0;\n\ttop: 50%;\n\tmargin-top: 0.8em;\n\n\tborder: 1px solid #D3D3D3;\n\tborder-top: none;\n\tborder-radius: 0 0 .25em .25em;\n\tcolor: #000;\n\tbackground-color: #F5F5F5;\n\tz-index: 99;\n}\n\n#qunit-modulefilter-dropdown a {\n\tcolor: inherit;\n\ttext-decoration: none;\n}\n\n#qunit-modulefilter-dropdown .clickable.checked {\n\tfont-weight: bold;\n\tcolor: #000;\n\tbackground-color: #D2E0E6;\n}\n\n#qunit-modulefilter-dropdown .clickable:hover {\n\tcolor: #FFF;\n\tbackground-color: #0D3349;\n}\n\n#qunit-modulefilter-actions {\n\tdisplay: block;\n\toverflow: auto;\n\n\t/* align with #qunit-modulefilter-dropdown-list */\n\tfont: smaller/1.5em sans-serif;\n}\n\n#qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {\n\tbox-sizing: border-box;\n\tmax-height: 2.8em;\n\tdisplay: block;\n\tpadding: 0.4em;\n}\n\n#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {\n\tfloat: right;\n\tfont: inherit;\n}\n\n#qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child {\n\t/* insert padding to align with checkbox margins */\n\tpadding-left: 3px;\n}\n\n#qunit-modulefilter-dropdown-list {\n\tmax-height: 200px;\n\toverflow-y: auto;\n\tmargin: 0;\n\tborder-top: 2px groove threedhighlight;\n\tpadding: 0.4em 0 0;\n\tfont: smaller/1.5em sans-serif;\n}\n\n#qunit-modulefilter-dropdown-list li {\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n#qunit-modulefilter-dropdown-list .clickable {\n\tdisplay: block;\n\tpadding-left: 0.15em;\n}\n\n\n/** Tests: Pass/Fail */\n\n#qunit-tests {\n\tlist-style-position: inside;\n}\n\n#qunit-tests li {\n\tpadding: 0.4em 1em 0.4em 1em;\n\tborder-bottom: 1px solid #FFF;\n\tlist-style-position: inside;\n}\n\n#qunit-tests > li {\n\tdisplay: none;\n}\n\n#qunit-tests li.running,\n#qunit-tests li.pass,\n#qunit-tests li.fail,\n#qunit-tests li.skipped,\n#qunit-tests li.aborted {\n\tdisplay: list-item;\n}\n\n#qunit-tests.hidepass {\n\tposition: relative;\n}\n\n#qunit-tests.hidepass li.running,\n#qunit-tests.hidepass li.pass:not(.todo) {\n\tvisibility: hidden;\n\tposition: absolute;\n\twidth:   0;\n\theight:  0;\n\tpadding: 0;\n\tborder:  0;\n\tmargin:  0;\n}\n\n#qunit-tests li strong {\n\tcursor: pointer;\n}\n\n#qunit-tests li.skipped strong {\n\tcursor: default;\n}\n\n#qunit-tests li a {\n\tpadding: 0.5em;\n\tcolor: #C2CCD1;\n\ttext-decoration: none;\n}\n\n#qunit-tests li p a {\n\tpadding: 0.25em;\n\tcolor: #6B6464;\n}\n#qunit-tests li a:hover,\n#qunit-tests li a:focus {\n\tcolor: #000;\n}\n\n#qunit-tests li .runtime {\n\tfloat: right;\n\tfont-size: smaller;\n}\n\n.qunit-assert-list {\n\tmargin-top: 0.5em;\n\tpadding: 0.5em;\n\n\tbackground-color: #FFF;\n\n\tborder-radius: 5px;\n}\n\n.qunit-source {\n\tmargin: 0.6em 0 0.3em;\n}\n\n.qunit-collapsed {\n\tdisplay: none;\n}\n\n#qunit-tests table {\n\tborder-collapse: collapse;\n\tmargin-top: 0.2em;\n}\n\n#qunit-tests th {\n\ttext-align: right;\n\tvertical-align: top;\n\tpadding: 0 0.5em 0 0;\n}\n\n#qunit-tests td {\n\tvertical-align: top;\n}\n\n#qunit-tests pre {\n\tmargin: 0;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n}\n\n#qunit-tests del {\n\tcolor: #374E0C;\n\tbackground-color: #E0F2BE;\n\ttext-decoration: none;\n}\n\n#qunit-tests ins {\n\tcolor: #500;\n\tbackground-color: #FFCACA;\n\ttext-decoration: none;\n}\n\n/*** Test Counts */\n\n#qunit-tests b.counts                       { color: #000; }\n#qunit-tests b.passed                       { color: #5E740B; }\n#qunit-tests b.failed                       { color: #710909; }\n\n#qunit-tests li li {\n\tpadding: 5px;\n\tbackground-color: #FFF;\n\tborder-bottom: none;\n\tlist-style-position: inside;\n}\n\n/*** Passing Styles */\n\n#qunit-tests li li.pass {\n\tcolor: #3C510C;\n\tbackground-color: #FFF;\n\tborder-left: 10px solid #C6E746;\n}\n\n#qunit-tests .pass                          { color: #528CE0; background-color: #D2E0E6; }\n#qunit-tests .pass .test-name               { color: #366097; }\n\n#qunit-tests .pass .test-actual,\n#qunit-tests .pass .test-expected           { color: #999; }\n\n#qunit-banner.qunit-pass                    { background-color: #C6E746; }\n\n/*** Failing Styles */\n\n#qunit-tests li li.fail {\n\tcolor: #710909;\n\tbackground-color: #FFF;\n\tborder-left: 10px solid #EE5757;\n\twhite-space: pre;\n}\n\n#qunit-tests > li:last-child {\n\tborder-radius: 0 0 5px 5px;\n}\n\n#qunit-tests .fail                          { color: #000; background-color: #EE5757; }\n#qunit-tests .fail .test-name,\n#qunit-tests .fail .module-name             { color: #000; }\n\n#qunit-tests .fail .test-actual             { color: #EE5757; }\n#qunit-tests .fail .test-expected           { color: #008000; }\n\n#qunit-banner.qunit-fail                    { background-color: #EE5757; }\n\n\n/*** Aborted tests */\n#qunit-tests .aborted { color: #000; background-color: orange; }\n/*** Skipped tests */\n\n#qunit-tests .skipped {\n\tbackground-color: #EBECE9;\n}\n\n#qunit-tests .qunit-todo-label,\n#qunit-tests .qunit-skipped-label {\n\tbackground-color: #F4FF77;\n\tdisplay: inline-block;\n\tfont-style: normal;\n\tcolor: #366097;\n\tline-height: 1.8em;\n\tpadding: 0 0.5em;\n\tmargin: -0.4em 0.4em -0.4em 0;\n}\n\n#qunit-tests .qunit-todo-label {\n\tbackground-color: #EEE;\n}\n\n/** Result */\n\n#qunit-testresult {\n\tcolor: #2B81AF;\n\tbackground-color: #D2E0E6;\n\n\tborder-bottom: 1px solid #FFF;\n}\n#qunit-testresult .clearfix {\n\theight: 0;\n\tclear: both;\n}\n#qunit-testresult .module-name {\n\tfont-weight: 700;\n}\n#qunit-testresult-display {\n\tpadding: 0.5em 1em 0.5em 1em;\n\twidth: 85%;\n\tfloat:left;\n}\n#qunit-testresult-controls {\n\tpadding: 0.5em 1em 0.5em 1em;\n  width: 10%;\n\tfloat:left;\n}\n\n/** Fixture */\n\n#qunit-fixture {\n\tposition: absolute;\n\ttop: -10000px;\n\tleft: -10000px;\n\twidth: 1000px;\n\theight: 1000px;\n}\n"
  },
  {
    "path": "test/lib/qunit.js",
    "content": "/*!\n * QUnit 2.6.1-pre\n * https://qunitjs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2018-03-27T02:25Z\n */\n(function (global$1) {\n  'use strict';\n\n  global$1 = global$1 && global$1.hasOwnProperty('default') ? global$1['default'] : global$1;\n\n  var window = global$1.window;\n  var self$1 = global$1.self;\n  var console = global$1.console;\n  var setTimeout = global$1.setTimeout;\n  var clearTimeout = global$1.clearTimeout;\n\n  var document = window && window.document;\n  var navigator = window && window.navigator;\n\n  var localSessionStorage = function () {\n  \tvar x = \"qunit-test-string\";\n  \ttry {\n  \t\tglobal$1.sessionStorage.setItem(x, x);\n  \t\tglobal$1.sessionStorage.removeItem(x);\n  \t\treturn global$1.sessionStorage;\n  \t} catch (e) {\n  \t\treturn undefined;\n  \t}\n  }();\n\n  var _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n    return typeof obj;\n  } : function (obj) {\n    return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n  };\n\n\n\n\n\n\n\n\n\n\n\n  var classCallCheck = function (instance, Constructor) {\n    if (!(instance instanceof Constructor)) {\n      throw new TypeError(\"Cannot call a class as a function\");\n    }\n  };\n\n  var createClass = function () {\n    function defineProperties(target, props) {\n      for (var i = 0; i < props.length; i++) {\n        var descriptor = props[i];\n        descriptor.enumerable = descriptor.enumerable || false;\n        descriptor.configurable = true;\n        if (\"value\" in descriptor) descriptor.writable = true;\n        Object.defineProperty(target, descriptor.key, descriptor);\n      }\n    }\n\n    return function (Constructor, protoProps, staticProps) {\n      if (protoProps) defineProperties(Constructor.prototype, protoProps);\n      if (staticProps) defineProperties(Constructor, staticProps);\n      return Constructor;\n    };\n  }();\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  var toConsumableArray = function (arr) {\n    if (Array.isArray(arr)) {\n      for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];\n\n      return arr2;\n    } else {\n      return Array.from(arr);\n    }\n  };\n\n  var toString = Object.prototype.toString;\n  var hasOwn = Object.prototype.hasOwnProperty;\n  var now = Date.now || function () {\n  \treturn new Date().getTime();\n  };\n\n  var defined = {\n  \tdocument: window && window.document !== undefined,\n  \tsetTimeout: setTimeout !== undefined\n  };\n\n  // Returns a new Array with the elements that are in a but not in b\n  function diff(a, b) {\n  \tvar i,\n  \t    j,\n  \t    result = a.slice();\n\n  \tfor (i = 0; i < result.length; i++) {\n  \t\tfor (j = 0; j < b.length; j++) {\n  \t\t\tif (result[i] === b[j]) {\n  \t\t\t\tresult.splice(i, 1);\n  \t\t\t\ti--;\n  \t\t\t\tbreak;\n  \t\t\t}\n  \t\t}\n  \t}\n  \treturn result;\n  }\n\n  /**\n   * Determines whether an element exists in a given array or not.\n   *\n   * @method inArray\n   * @param {Any} elem\n   * @param {Array} array\n   * @return {Boolean}\n   */\n  function inArray(elem, array) {\n  \treturn array.indexOf(elem) !== -1;\n  }\n\n  /**\n   * Makes a clone of an object using only Array or Object as base,\n   * and copies over the own enumerable properties.\n   *\n   * @param {Object} obj\n   * @return {Object} New object with only the own properties (recursively).\n   */\n  function objectValues(obj) {\n  \tvar key,\n  \t    val,\n  \t    vals = is(\"array\", obj) ? [] : {};\n  \tfor (key in obj) {\n  \t\tif (hasOwn.call(obj, key)) {\n  \t\t\tval = obj[key];\n  \t\t\tvals[key] = val === Object(val) ? objectValues(val) : val;\n  \t\t}\n  \t}\n  \treturn vals;\n  }\n\n  function extend(a, b, undefOnly) {\n  \tfor (var prop in b) {\n  \t\tif (hasOwn.call(b, prop)) {\n  \t\t\tif (b[prop] === undefined) {\n  \t\t\t\tdelete a[prop];\n  \t\t\t} else if (!(undefOnly && typeof a[prop] !== \"undefined\")) {\n  \t\t\t\ta[prop] = b[prop];\n  \t\t\t}\n  \t\t}\n  \t}\n\n  \treturn a;\n  }\n\n  function objectType(obj) {\n  \tif (typeof obj === \"undefined\") {\n  \t\treturn \"undefined\";\n  \t}\n\n  \t// Consider: typeof null === object\n  \tif (obj === null) {\n  \t\treturn \"null\";\n  \t}\n\n  \tvar match = toString.call(obj).match(/^\\[object\\s(.*)\\]$/),\n  \t    type = match && match[1];\n\n  \tswitch (type) {\n  \t\tcase \"Number\":\n  \t\t\tif (isNaN(obj)) {\n  \t\t\t\treturn \"nan\";\n  \t\t\t}\n  \t\t\treturn \"number\";\n  \t\tcase \"String\":\n  \t\tcase \"Boolean\":\n  \t\tcase \"Array\":\n  \t\tcase \"Set\":\n  \t\tcase \"Map\":\n  \t\tcase \"Date\":\n  \t\tcase \"RegExp\":\n  \t\tcase \"Function\":\n  \t\tcase \"Symbol\":\n  \t\t\treturn type.toLowerCase();\n  \t\tdefault:\n  \t\t\treturn typeof obj === \"undefined\" ? \"undefined\" : _typeof(obj);\n  \t}\n  }\n\n  // Safe object type checking\n  function is(type, obj) {\n  \treturn objectType(obj) === type;\n  }\n\n  // Based on Java's String.hashCode, a simple but not\n  // rigorously collision resistant hashing function\n  function generateHash(module, testName) {\n  \tvar str = module + \"\\x1C\" + testName;\n  \tvar hash = 0;\n\n  \tfor (var i = 0; i < str.length; i++) {\n  \t\thash = (hash << 5) - hash + str.charCodeAt(i);\n  \t\thash |= 0;\n  \t}\n\n  \t// Convert the possibly negative integer hash code into an 8 character hex string, which isn't\n  \t// strictly necessary but increases user understanding that the id is a SHA-like hash\n  \tvar hex = (0x100000000 + hash).toString(16);\n  \tif (hex.length < 8) {\n  \t\thex = \"0000000\" + hex;\n  \t}\n\n  \treturn hex.slice(-8);\n  }\n\n  // Test for equality any JavaScript type.\n  // Authors: Philippe Rathé <prathe@gmail.com>, David Chan <david@troi.org>\n  var equiv = (function () {\n\n  \t// Value pairs queued for comparison. Used for breadth-first processing order, recursion\n  \t// detection and avoiding repeated comparison (see below for details).\n  \t// Elements are { a: val, b: val }.\n  \tvar pairs = [];\n\n  \tvar getProto = Object.getPrototypeOf || function (obj) {\n  \t\treturn obj.__proto__;\n  \t};\n\n  \tfunction useStrictEquality(a, b) {\n\n  \t\t// This only gets called if a and b are not strict equal, and is used to compare on\n  \t\t// the primitive values inside object wrappers. For example:\n  \t\t// `var i = 1;`\n  \t\t// `var j = new Number(1);`\n  \t\t// Neither a nor b can be null, as a !== b and they have the same type.\n  \t\tif ((typeof a === \"undefined\" ? \"undefined\" : _typeof(a)) === \"object\") {\n  \t\t\ta = a.valueOf();\n  \t\t}\n  \t\tif ((typeof b === \"undefined\" ? \"undefined\" : _typeof(b)) === \"object\") {\n  \t\t\tb = b.valueOf();\n  \t\t}\n\n  \t\treturn a === b;\n  \t}\n\n  \tfunction compareConstructors(a, b) {\n  \t\tvar protoA = getProto(a);\n  \t\tvar protoB = getProto(b);\n\n  \t\t// Comparing constructors is more strict than using `instanceof`\n  \t\tif (a.constructor === b.constructor) {\n  \t\t\treturn true;\n  \t\t}\n\n  \t\t// Ref #851\n  \t\t// If the obj prototype descends from a null constructor, treat it\n  \t\t// as a null prototype.\n  \t\tif (protoA && protoA.constructor === null) {\n  \t\t\tprotoA = null;\n  \t\t}\n  \t\tif (protoB && protoB.constructor === null) {\n  \t\t\tprotoB = null;\n  \t\t}\n\n  \t\t// Allow objects with no prototype to be equivalent to\n  \t\t// objects with Object as their constructor.\n  \t\tif (protoA === null && protoB === Object.prototype || protoB === null && protoA === Object.prototype) {\n  \t\t\treturn true;\n  \t\t}\n\n  \t\treturn false;\n  \t}\n\n  \tfunction getRegExpFlags(regexp) {\n  \t\treturn \"flags\" in regexp ? regexp.flags : regexp.toString().match(/[gimuy]*$/)[0];\n  \t}\n\n  \tfunction isContainer(val) {\n  \t\treturn [\"object\", \"array\", \"map\", \"set\"].indexOf(objectType(val)) !== -1;\n  \t}\n\n  \tfunction breadthFirstCompareChild(a, b) {\n\n  \t\t// If a is a container not reference-equal to b, postpone the comparison to the\n  \t\t// end of the pairs queue -- unless (a, b) has been seen before, in which case skip\n  \t\t// over the pair.\n  \t\tif (a === b) {\n  \t\t\treturn true;\n  \t\t}\n  \t\tif (!isContainer(a)) {\n  \t\t\treturn typeEquiv(a, b);\n  \t\t}\n  \t\tif (pairs.every(function (pair) {\n  \t\t\treturn pair.a !== a || pair.b !== b;\n  \t\t})) {\n\n  \t\t\t// Not yet started comparing this pair\n  \t\t\tpairs.push({ a: a, b: b });\n  \t\t}\n  \t\treturn true;\n  \t}\n\n  \tvar callbacks = {\n  \t\t\"string\": useStrictEquality,\n  \t\t\"boolean\": useStrictEquality,\n  \t\t\"number\": useStrictEquality,\n  \t\t\"null\": useStrictEquality,\n  \t\t\"undefined\": useStrictEquality,\n  \t\t\"symbol\": useStrictEquality,\n  \t\t\"date\": useStrictEquality,\n\n  \t\t\"nan\": function nan() {\n  \t\t\treturn true;\n  \t\t},\n\n  \t\t\"regexp\": function regexp(a, b) {\n  \t\t\treturn a.source === b.source &&\n\n  \t\t\t// Include flags in the comparison\n  \t\t\tgetRegExpFlags(a) === getRegExpFlags(b);\n  \t\t},\n\n  \t\t// abort (identical references / instance methods were skipped earlier)\n  \t\t\"function\": function _function() {\n  \t\t\treturn false;\n  \t\t},\n\n  \t\t\"array\": function array(a, b) {\n  \t\t\tvar i, len;\n\n  \t\t\tlen = a.length;\n  \t\t\tif (len !== b.length) {\n\n  \t\t\t\t// Safe and faster\n  \t\t\t\treturn false;\n  \t\t\t}\n\n  \t\t\tfor (i = 0; i < len; i++) {\n\n  \t\t\t\t// Compare non-containers; queue non-reference-equal containers\n  \t\t\t\tif (!breadthFirstCompareChild(a[i], b[i])) {\n  \t\t\t\t\treturn false;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\treturn true;\n  \t\t},\n\n  \t\t// Define sets a and b to be equivalent if for each element aVal in a, there\n  \t\t// is some element bVal in b such that aVal and bVal are equivalent. Element\n  \t\t// repetitions are not counted, so these are equivalent:\n  \t\t// a = new Set( [ {}, [], [] ] );\n  \t\t// b = new Set( [ {}, {}, [] ] );\n  \t\t\"set\": function set$$1(a, b) {\n  \t\t\tvar innerEq,\n  \t\t\t    outerEq = true;\n\n  \t\t\tif (a.size !== b.size) {\n\n  \t\t\t\t// This optimization has certain quirks because of the lack of\n  \t\t\t\t// repetition counting. For instance, adding the same\n  \t\t\t\t// (reference-identical) element to two equivalent sets can\n  \t\t\t\t// make them non-equivalent.\n  \t\t\t\treturn false;\n  \t\t\t}\n\n  \t\t\ta.forEach(function (aVal) {\n\n  \t\t\t\t// Short-circuit if the result is already known. (Using for...of\n  \t\t\t\t// with a break clause would be cleaner here, but it would cause\n  \t\t\t\t// a syntax error on older Javascript implementations even if\n  \t\t\t\t// Set is unused)\n  \t\t\t\tif (!outerEq) {\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n\n  \t\t\t\tinnerEq = false;\n\n  \t\t\t\tb.forEach(function (bVal) {\n  \t\t\t\t\tvar parentPairs;\n\n  \t\t\t\t\t// Likewise, short-circuit if the result is already known\n  \t\t\t\t\tif (innerEq) {\n  \t\t\t\t\t\treturn;\n  \t\t\t\t\t}\n\n  \t\t\t\t\t// Swap out the global pairs list, as the nested call to\n  \t\t\t\t\t// innerEquiv will clobber its contents\n  \t\t\t\t\tparentPairs = pairs;\n  \t\t\t\t\tif (innerEquiv(bVal, aVal)) {\n  \t\t\t\t\t\tinnerEq = true;\n  \t\t\t\t\t}\n\n  \t\t\t\t\t// Replace the global pairs list\n  \t\t\t\t\tpairs = parentPairs;\n  \t\t\t\t});\n\n  \t\t\t\tif (!innerEq) {\n  \t\t\t\t\touterEq = false;\n  \t\t\t\t}\n  \t\t\t});\n\n  \t\t\treturn outerEq;\n  \t\t},\n\n  \t\t// Define maps a and b to be equivalent if for each key-value pair (aKey, aVal)\n  \t\t// in a, there is some key-value pair (bKey, bVal) in b such that\n  \t\t// [ aKey, aVal ] and [ bKey, bVal ] are equivalent. Key repetitions are not\n  \t\t// counted, so these are equivalent:\n  \t\t// a = new Map( [ [ {}, 1 ], [ {}, 1 ], [ [], 1 ] ] );\n  \t\t// b = new Map( [ [ {}, 1 ], [ [], 1 ], [ [], 1 ] ] );\n  \t\t\"map\": function map(a, b) {\n  \t\t\tvar innerEq,\n  \t\t\t    outerEq = true;\n\n  \t\t\tif (a.size !== b.size) {\n\n  \t\t\t\t// This optimization has certain quirks because of the lack of\n  \t\t\t\t// repetition counting. For instance, adding the same\n  \t\t\t\t// (reference-identical) key-value pair to two equivalent maps\n  \t\t\t\t// can make them non-equivalent.\n  \t\t\t\treturn false;\n  \t\t\t}\n\n  \t\t\ta.forEach(function (aVal, aKey) {\n\n  \t\t\t\t// Short-circuit if the result is already known. (Using for...of\n  \t\t\t\t// with a break clause would be cleaner here, but it would cause\n  \t\t\t\t// a syntax error on older Javascript implementations even if\n  \t\t\t\t// Map is unused)\n  \t\t\t\tif (!outerEq) {\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n\n  \t\t\t\tinnerEq = false;\n\n  \t\t\t\tb.forEach(function (bVal, bKey) {\n  \t\t\t\t\tvar parentPairs;\n\n  \t\t\t\t\t// Likewise, short-circuit if the result is already known\n  \t\t\t\t\tif (innerEq) {\n  \t\t\t\t\t\treturn;\n  \t\t\t\t\t}\n\n  \t\t\t\t\t// Swap out the global pairs list, as the nested call to\n  \t\t\t\t\t// innerEquiv will clobber its contents\n  \t\t\t\t\tparentPairs = pairs;\n  \t\t\t\t\tif (innerEquiv([bVal, bKey], [aVal, aKey])) {\n  \t\t\t\t\t\tinnerEq = true;\n  \t\t\t\t\t}\n\n  \t\t\t\t\t// Replace the global pairs list\n  \t\t\t\t\tpairs = parentPairs;\n  \t\t\t\t});\n\n  \t\t\t\tif (!innerEq) {\n  \t\t\t\t\touterEq = false;\n  \t\t\t\t}\n  \t\t\t});\n\n  \t\t\treturn outerEq;\n  \t\t},\n\n  \t\t\"object\": function object(a, b) {\n  \t\t\tvar i,\n  \t\t\t    aProperties = [],\n  \t\t\t    bProperties = [];\n\n  \t\t\tif (compareConstructors(a, b) === false) {\n  \t\t\t\treturn false;\n  \t\t\t}\n\n  \t\t\t// Be strict: don't ensure hasOwnProperty and go deep\n  \t\t\tfor (i in a) {\n\n  \t\t\t\t// Collect a's properties\n  \t\t\t\taProperties.push(i);\n\n  \t\t\t\t// Skip OOP methods that look the same\n  \t\t\t\tif (a.constructor !== Object && typeof a.constructor !== \"undefined\" && typeof a[i] === \"function\" && typeof b[i] === \"function\" && a[i].toString() === b[i].toString()) {\n  \t\t\t\t\tcontinue;\n  \t\t\t\t}\n\n  \t\t\t\t// Compare non-containers; queue non-reference-equal containers\n  \t\t\t\tif (!breadthFirstCompareChild(a[i], b[i])) {\n  \t\t\t\t\treturn false;\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\tfor (i in b) {\n\n  \t\t\t\t// Collect b's properties\n  \t\t\t\tbProperties.push(i);\n  \t\t\t}\n\n  \t\t\t// Ensures identical properties name\n  \t\t\treturn typeEquiv(aProperties.sort(), bProperties.sort());\n  \t\t}\n  \t};\n\n  \tfunction typeEquiv(a, b) {\n  \t\tvar type = objectType(a);\n\n  \t\t// Callbacks for containers will append to the pairs queue to achieve breadth-first\n  \t\t// search order. The pairs queue is also used to avoid reprocessing any pair of\n  \t\t// containers that are reference-equal to a previously visited pair (a special case\n  \t\t// this being recursion detection).\n  \t\t//\n  \t\t// Because of this approach, once typeEquiv returns a false value, it should not be\n  \t\t// called again without clearing the pair queue else it may wrongly report a visited\n  \t\t// pair as being equivalent.\n  \t\treturn objectType(b) === type && callbacks[type](a, b);\n  \t}\n\n  \tfunction innerEquiv(a, b) {\n  \t\tvar i, pair;\n\n  \t\t// We're done when there's nothing more to compare\n  \t\tif (arguments.length < 2) {\n  \t\t\treturn true;\n  \t\t}\n\n  \t\t// Clear the global pair queue and add the top-level values being compared\n  \t\tpairs = [{ a: a, b: b }];\n\n  \t\tfor (i = 0; i < pairs.length; i++) {\n  \t\t\tpair = pairs[i];\n\n  \t\t\t// Perform type-specific comparison on any pairs that are not strictly\n  \t\t\t// equal. For container types, that comparison will postpone comparison\n  \t\t\t// of any sub-container pair to the end of the pair queue. This gives\n  \t\t\t// breadth-first search order. It also avoids the reprocessing of\n  \t\t\t// reference-equal siblings, cousins etc, which can have a significant speed\n  \t\t\t// impact when comparing a container of small objects each of which has a\n  \t\t\t// reference to the same (singleton) large object.\n  \t\t\tif (pair.a !== pair.b && !typeEquiv(pair.a, pair.b)) {\n  \t\t\t\treturn false;\n  \t\t\t}\n  \t\t}\n\n  \t\t// ...across all consecutive argument pairs\n  \t\treturn arguments.length === 2 || innerEquiv.apply(this, [].slice.call(arguments, 1));\n  \t}\n\n  \treturn function () {\n  \t\tvar result = innerEquiv.apply(undefined, arguments);\n\n  \t\t// Release any retained objects\n  \t\tpairs.length = 0;\n  \t\treturn result;\n  \t};\n  })();\n\n  /**\n   * Config object: Maintain internal state\n   * Later exposed as QUnit.config\n   * `config` initialized at top of scope\n   */\n  var config = {\n\n  \t// The queue of tests to run\n  \tqueue: [],\n\n  \t// Block until document ready\n  \tblocking: true,\n\n  \t// By default, run previously failed tests first\n  \t// very useful in combination with \"Hide passed tests\" checked\n  \treorder: true,\n\n  \t// By default, modify document.title when suite is done\n  \taltertitle: true,\n\n  \t// HTML Reporter: collapse every test except the first failing test\n  \t// If false, all failing tests will be expanded\n  \tcollapse: true,\n\n  \t// By default, scroll to top of the page when suite is done\n  \tscrolltop: true,\n\n  \t// Depth up-to which object will be dumped\n  \tmaxDepth: 5,\n\n  \t// When enabled, all tests must call expect()\n  \trequireExpects: false,\n\n  \t// Placeholder for user-configurable form-exposed URL parameters\n  \turlConfig: [],\n\n  \t// Set of all modules.\n  \tmodules: [],\n\n  \t// The first unnamed module\n  \tcurrentModule: {\n  \t\tname: \"\",\n  \t\ttests: [],\n  \t\tchildModules: [],\n  \t\ttestsRun: 0,\n  \t\tunskippedTestsRun: 0,\n  \t\thooks: {\n  \t\t\tbefore: [],\n  \t\t\tbeforeEach: [],\n  \t\t\tafterEach: [],\n  \t\t\tafter: []\n  \t\t}\n  \t},\n\n  \tcallbacks: {},\n\n  \t// The storage module to use for reordering tests\n  \tstorage: localSessionStorage\n  };\n\n  // take a predefined QUnit.config and extend the defaults\n  var globalConfig = window && window.QUnit && window.QUnit.config;\n\n  // only extend the global config if there is no QUnit overload\n  if (window && window.QUnit && !window.QUnit.version) {\n  \textend(config, globalConfig);\n  }\n\n  // Push a loose unnamed module to the modules collection\n  config.modules.push(config.currentModule);\n\n  // Based on jsDump by Ariel Flesler\n  // http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html\n  var dump = (function () {\n  \tfunction quote(str) {\n  \t\treturn \"\\\"\" + str.toString().replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, \"\\\\\\\"\") + \"\\\"\";\n  \t}\n  \tfunction literal(o) {\n  \t\treturn o + \"\";\n  \t}\n  \tfunction join(pre, arr, post) {\n  \t\tvar s = dump.separator(),\n  \t\t    base = dump.indent(),\n  \t\t    inner = dump.indent(1);\n  \t\tif (arr.join) {\n  \t\t\tarr = arr.join(\",\" + s + inner);\n  \t\t}\n  \t\tif (!arr) {\n  \t\t\treturn pre + post;\n  \t\t}\n  \t\treturn [pre, inner + arr, base + post].join(s);\n  \t}\n  \tfunction array(arr, stack) {\n  \t\tvar i = arr.length,\n  \t\t    ret = new Array(i);\n\n  \t\tif (dump.maxDepth && dump.depth > dump.maxDepth) {\n  \t\t\treturn \"[object Array]\";\n  \t\t}\n\n  \t\tthis.up();\n  \t\twhile (i--) {\n  \t\t\tret[i] = this.parse(arr[i], undefined, stack);\n  \t\t}\n  \t\tthis.down();\n  \t\treturn join(\"[\", ret, \"]\");\n  \t}\n\n  \tfunction isArray(obj) {\n  \t\treturn (\n\n  \t\t\t//Native Arrays\n  \t\t\ttoString.call(obj) === \"[object Array]\" ||\n\n  \t\t\t// NodeList objects\n  \t\t\ttypeof obj.length === \"number\" && obj.item !== undefined && (obj.length ? obj.item(0) === obj[0] : obj.item(0) === null && obj[0] === undefined)\n  \t\t);\n  \t}\n\n  \tvar reName = /^function (\\w+)/,\n  \t    dump = {\n\n  \t\t// The objType is used mostly internally, you can fix a (custom) type in advance\n  \t\tparse: function parse(obj, objType, stack) {\n  \t\t\tstack = stack || [];\n  \t\t\tvar res,\n  \t\t\t    parser,\n  \t\t\t    parserType,\n  \t\t\t    objIndex = stack.indexOf(obj);\n\n  \t\t\tif (objIndex !== -1) {\n  \t\t\t\treturn \"recursion(\" + (objIndex - stack.length) + \")\";\n  \t\t\t}\n\n  \t\t\tobjType = objType || this.typeOf(obj);\n  \t\t\tparser = this.parsers[objType];\n  \t\t\tparserType = typeof parser === \"undefined\" ? \"undefined\" : _typeof(parser);\n\n  \t\t\tif (parserType === \"function\") {\n  \t\t\t\tstack.push(obj);\n  \t\t\t\tres = parser.call(this, obj, stack);\n  \t\t\t\tstack.pop();\n  \t\t\t\treturn res;\n  \t\t\t}\n  \t\t\treturn parserType === \"string\" ? parser : this.parsers.error;\n  \t\t},\n  \t\ttypeOf: function typeOf(obj) {\n  \t\t\tvar type;\n\n  \t\t\tif (obj === null) {\n  \t\t\t\ttype = \"null\";\n  \t\t\t} else if (typeof obj === \"undefined\") {\n  \t\t\t\ttype = \"undefined\";\n  \t\t\t} else if (is(\"regexp\", obj)) {\n  \t\t\t\ttype = \"regexp\";\n  \t\t\t} else if (is(\"date\", obj)) {\n  \t\t\t\ttype = \"date\";\n  \t\t\t} else if (is(\"function\", obj)) {\n  \t\t\t\ttype = \"function\";\n  \t\t\t} else if (obj.setInterval !== undefined && obj.document !== undefined && obj.nodeType === undefined) {\n  \t\t\t\ttype = \"window\";\n  \t\t\t} else if (obj.nodeType === 9) {\n  \t\t\t\ttype = \"document\";\n  \t\t\t} else if (obj.nodeType) {\n  \t\t\t\ttype = \"node\";\n  \t\t\t} else if (isArray(obj)) {\n  \t\t\t\ttype = \"array\";\n  \t\t\t} else if (obj.constructor === Error.prototype.constructor) {\n  \t\t\t\ttype = \"error\";\n  \t\t\t} else {\n  \t\t\t\ttype = typeof obj === \"undefined\" ? \"undefined\" : _typeof(obj);\n  \t\t\t}\n  \t\t\treturn type;\n  \t\t},\n\n  \t\tseparator: function separator() {\n  \t\t\tif (this.multiline) {\n  \t\t\t\treturn this.HTML ? \"<br />\" : \"\\n\";\n  \t\t\t} else {\n  \t\t\t\treturn this.HTML ? \"&#160;\" : \" \";\n  \t\t\t}\n  \t\t},\n\n  \t\t// Extra can be a number, shortcut for increasing-calling-decreasing\n  \t\tindent: function indent(extra) {\n  \t\t\tif (!this.multiline) {\n  \t\t\t\treturn \"\";\n  \t\t\t}\n  \t\t\tvar chr = this.indentChar;\n  \t\t\tif (this.HTML) {\n  \t\t\t\tchr = chr.replace(/\\t/g, \"   \").replace(/ /g, \"&#160;\");\n  \t\t\t}\n  \t\t\treturn new Array(this.depth + (extra || 0)).join(chr);\n  \t\t},\n  \t\tup: function up(a) {\n  \t\t\tthis.depth += a || 1;\n  \t\t},\n  \t\tdown: function down(a) {\n  \t\t\tthis.depth -= a || 1;\n  \t\t},\n  \t\tsetParser: function setParser(name, parser) {\n  \t\t\tthis.parsers[name] = parser;\n  \t\t},\n\n  \t\t// The next 3 are exposed so you can use them\n  \t\tquote: quote,\n  \t\tliteral: literal,\n  \t\tjoin: join,\n  \t\tdepth: 1,\n  \t\tmaxDepth: config.maxDepth,\n\n  \t\t// This is the list of parsers, to modify them, use dump.setParser\n  \t\tparsers: {\n  \t\t\twindow: \"[Window]\",\n  \t\t\tdocument: \"[Document]\",\n  \t\t\terror: function error(_error) {\n  \t\t\t\treturn \"Error(\\\"\" + _error.message + \"\\\")\";\n  \t\t\t},\n  \t\t\tunknown: \"[Unknown]\",\n  \t\t\t\"null\": \"null\",\n  \t\t\t\"undefined\": \"undefined\",\n  \t\t\t\"function\": function _function(fn) {\n  \t\t\t\tvar ret = \"function\",\n\n\n  \t\t\t\t// Functions never have name in IE\n  \t\t\t\tname = \"name\" in fn ? fn.name : (reName.exec(fn) || [])[1];\n\n  \t\t\t\tif (name) {\n  \t\t\t\t\tret += \" \" + name;\n  \t\t\t\t}\n  \t\t\t\tret += \"(\";\n\n  \t\t\t\tret = [ret, dump.parse(fn, \"functionArgs\"), \"){\"].join(\"\");\n  \t\t\t\treturn join(ret, dump.parse(fn, \"functionCode\"), \"}\");\n  \t\t\t},\n  \t\t\tarray: array,\n  \t\t\tnodelist: array,\n  \t\t\t\"arguments\": array,\n  \t\t\tobject: function object(map, stack) {\n  \t\t\t\tvar keys,\n  \t\t\t\t    key,\n  \t\t\t\t    val,\n  \t\t\t\t    i,\n  \t\t\t\t    nonEnumerableProperties,\n  \t\t\t\t    ret = [];\n\n  \t\t\t\tif (dump.maxDepth && dump.depth > dump.maxDepth) {\n  \t\t\t\t\treturn \"[object Object]\";\n  \t\t\t\t}\n\n  \t\t\t\tdump.up();\n  \t\t\t\tkeys = [];\n  \t\t\t\tfor (key in map) {\n  \t\t\t\t\tkeys.push(key);\n  \t\t\t\t}\n\n  \t\t\t\t// Some properties are not always enumerable on Error objects.\n  \t\t\t\tnonEnumerableProperties = [\"message\", \"name\"];\n  \t\t\t\tfor (i in nonEnumerableProperties) {\n  \t\t\t\t\tkey = nonEnumerableProperties[i];\n  \t\t\t\t\tif (key in map && !inArray(key, keys)) {\n  \t\t\t\t\t\tkeys.push(key);\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t\tkeys.sort();\n  \t\t\t\tfor (i = 0; i < keys.length; i++) {\n  \t\t\t\t\tkey = keys[i];\n  \t\t\t\t\tval = map[key];\n  \t\t\t\t\tret.push(dump.parse(key, \"key\") + \": \" + dump.parse(val, undefined, stack));\n  \t\t\t\t}\n  \t\t\t\tdump.down();\n  \t\t\t\treturn join(\"{\", ret, \"}\");\n  \t\t\t},\n  \t\t\tnode: function node(_node) {\n  \t\t\t\tvar len,\n  \t\t\t\t    i,\n  \t\t\t\t    val,\n  \t\t\t\t    open = dump.HTML ? \"&lt;\" : \"<\",\n  \t\t\t\t    close = dump.HTML ? \"&gt;\" : \">\",\n  \t\t\t\t    tag = _node.nodeName.toLowerCase(),\n  \t\t\t\t    ret = open + tag,\n  \t\t\t\t    attrs = _node.attributes;\n\n  \t\t\t\tif (attrs) {\n  \t\t\t\t\tfor (i = 0, len = attrs.length; i < len; i++) {\n  \t\t\t\t\t\tval = attrs[i].nodeValue;\n\n  \t\t\t\t\t\t// IE6 includes all attributes in .attributes, even ones not explicitly\n  \t\t\t\t\t\t// set. Those have values like undefined, null, 0, false, \"\" or\n  \t\t\t\t\t\t// \"inherit\".\n  \t\t\t\t\t\tif (val && val !== \"inherit\") {\n  \t\t\t\t\t\t\tret += \" \" + attrs[i].nodeName + \"=\" + dump.parse(val, \"attribute\");\n  \t\t\t\t\t\t}\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t\tret += close;\n\n  \t\t\t\t// Show content of TextNode or CDATASection\n  \t\t\t\tif (_node.nodeType === 3 || _node.nodeType === 4) {\n  \t\t\t\t\tret += _node.nodeValue;\n  \t\t\t\t}\n\n  \t\t\t\treturn ret + open + \"/\" + tag + close;\n  \t\t\t},\n\n  \t\t\t// Function calls it internally, it's the arguments part of the function\n  \t\t\tfunctionArgs: function functionArgs(fn) {\n  \t\t\t\tvar args,\n  \t\t\t\t    l = fn.length;\n\n  \t\t\t\tif (!l) {\n  \t\t\t\t\treturn \"\";\n  \t\t\t\t}\n\n  \t\t\t\targs = new Array(l);\n  \t\t\t\twhile (l--) {\n\n  \t\t\t\t\t// 97 is 'a'\n  \t\t\t\t\targs[l] = String.fromCharCode(97 + l);\n  \t\t\t\t}\n  \t\t\t\treturn \" \" + args.join(\", \") + \" \";\n  \t\t\t},\n\n  \t\t\t// Object calls it internally, the key part of an item in a map\n  \t\t\tkey: quote,\n\n  \t\t\t// Function calls it internally, it's the content of the function\n  \t\t\tfunctionCode: \"[code]\",\n\n  \t\t\t// Node calls it internally, it's a html attribute value\n  \t\t\tattribute: quote,\n  \t\t\tstring: quote,\n  \t\t\tdate: quote,\n  \t\t\tregexp: literal,\n  \t\t\tnumber: literal,\n  \t\t\t\"boolean\": literal,\n  \t\t\tsymbol: function symbol(sym) {\n  \t\t\t\treturn sym.toString();\n  \t\t\t}\n  \t\t},\n\n  \t\t// If true, entities are escaped ( <, >, \\t, space and \\n )\n  \t\tHTML: false,\n\n  \t\t// Indentation unit\n  \t\tindentChar: \"  \",\n\n  \t\t// If true, items in a collection, are separated by a \\n, else just a space.\n  \t\tmultiline: true\n  \t};\n\n  \treturn dump;\n  })();\n\n  var LISTENERS = Object.create(null);\n  var SUPPORTED_EVENTS = [\"runStart\", \"suiteStart\", \"testStart\", \"assertion\", \"testEnd\", \"suiteEnd\", \"runEnd\"];\n\n  /**\n   * Emits an event with the specified data to all currently registered listeners.\n   * Callbacks will fire in the order in which they are registered (FIFO). This\n   * function is not exposed publicly; it is used by QUnit internals to emit\n   * logging events.\n   *\n   * @private\n   * @method emit\n   * @param {String} eventName\n   * @param {Object} data\n   * @return {Void}\n   */\n  function emit(eventName, data) {\n  \tif (objectType(eventName) !== \"string\") {\n  \t\tthrow new TypeError(\"eventName must be a string when emitting an event\");\n  \t}\n\n  \t// Clone the callbacks in case one of them registers a new callback\n  \tvar originalCallbacks = LISTENERS[eventName];\n  \tvar callbacks = originalCallbacks ? [].concat(toConsumableArray(originalCallbacks)) : [];\n\n  \tfor (var i = 0; i < callbacks.length; i++) {\n  \t\tcallbacks[i](data);\n  \t}\n  }\n\n  /**\n   * Registers a callback as a listener to the specified event.\n   *\n   * @public\n   * @method on\n   * @param {String} eventName\n   * @param {Function} callback\n   * @return {Void}\n   */\n  function on(eventName, callback) {\n  \tif (objectType(eventName) !== \"string\") {\n  \t\tthrow new TypeError(\"eventName must be a string when registering a listener\");\n  \t} else if (!inArray(eventName, SUPPORTED_EVENTS)) {\n  \t\tvar events = SUPPORTED_EVENTS.join(\", \");\n  \t\tthrow new Error(\"\\\"\" + eventName + \"\\\" is not a valid event; must be one of: \" + events + \".\");\n  \t} else if (objectType(callback) !== \"function\") {\n  \t\tthrow new TypeError(\"callback must be a function when registering a listener\");\n  \t}\n\n  \tif (!LISTENERS[eventName]) {\n  \t\tLISTENERS[eventName] = [];\n  \t}\n\n  \t// Don't register the same callback more than once\n  \tif (!inArray(callback, LISTENERS[eventName])) {\n  \t\tLISTENERS[eventName].push(callback);\n  \t}\n  }\n\n  // Register logging callbacks\n  function registerLoggingCallbacks(obj) {\n  \tvar i,\n  \t    l,\n  \t    key,\n  \t    callbackNames = [\"begin\", \"done\", \"log\", \"testStart\", \"testDone\", \"moduleStart\", \"moduleDone\"];\n\n  \tfunction registerLoggingCallback(key) {\n  \t\tvar loggingCallback = function loggingCallback(callback) {\n  \t\t\tif (objectType(callback) !== \"function\") {\n  \t\t\t\tthrow new Error(\"QUnit logging methods require a callback function as their first parameters.\");\n  \t\t\t}\n\n  \t\t\tconfig.callbacks[key].push(callback);\n  \t\t};\n\n  \t\treturn loggingCallback;\n  \t}\n\n  \tfor (i = 0, l = callbackNames.length; i < l; i++) {\n  \t\tkey = callbackNames[i];\n\n  \t\t// Initialize key collection of logging callback\n  \t\tif (objectType(config.callbacks[key]) === \"undefined\") {\n  \t\t\tconfig.callbacks[key] = [];\n  \t\t}\n\n  \t\tobj[key] = registerLoggingCallback(key);\n  \t}\n  }\n\n  function runLoggingCallbacks(key, args) {\n  \tvar i, l, callbacks;\n\n  \tcallbacks = config.callbacks[key];\n  \tfor (i = 0, l = callbacks.length; i < l; i++) {\n  \t\tcallbacks[i](args);\n  \t}\n  }\n\n  // Doesn't support IE9, it will return undefined on these browsers\n  // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack\n  var fileName = (sourceFromStacktrace(0) || \"\").replace(/(:\\d+)+\\)?/, \"\").replace(/.+\\//, \"\");\n\n  function extractStacktrace(e, offset) {\n  \toffset = offset === undefined ? 4 : offset;\n\n  \tvar stack, include, i;\n\n  \tif (e && e.stack) {\n  \t\tstack = e.stack.split(\"\\n\");\n  \t\tif (/^error$/i.test(stack[0])) {\n  \t\t\tstack.shift();\n  \t\t}\n  \t\tif (fileName) {\n  \t\t\tinclude = [];\n  \t\t\tfor (i = offset; i < stack.length; i++) {\n  \t\t\t\tif (stack[i].indexOf(fileName) !== -1) {\n  \t\t\t\t\tbreak;\n  \t\t\t\t}\n  \t\t\t\tinclude.push(stack[i]);\n  \t\t\t}\n  \t\t\tif (include.length) {\n  \t\t\t\treturn include.join(\"\\n\");\n  \t\t\t}\n  \t\t}\n  \t\treturn stack[offset];\n  \t}\n  }\n\n  function sourceFromStacktrace(offset) {\n  \tvar error = new Error();\n\n  \t// Support: Safari <=7 only, IE <=10 - 11 only\n  \t// Not all browsers generate the `stack` property for `new Error()`, see also #636\n  \tif (!error.stack) {\n  \t\ttry {\n  \t\t\tthrow error;\n  \t\t} catch (err) {\n  \t\t\terror = err;\n  \t\t}\n  \t}\n\n  \treturn extractStacktrace(error, offset);\n  }\n\n  var priorityCount = 0;\n  var unitSampler = void 0;\n\n  // This is a queue of functions that are tasks within a single test.\n  // After tests are dequeued from config.queue they are expanded into\n  // a set of tasks in this queue.\n  var taskQueue = [];\n\n  /**\n   * Advances the taskQueue to the next task. If the taskQueue is empty,\n   * process the testQueue\n   */\n  function advance() {\n  \tadvanceTaskQueue();\n\n  \tif (!taskQueue.length) {\n  \t\tadvanceTestQueue();\n  \t}\n  }\n\n  /**\n   * Advances the taskQueue to the next task if it is ready and not empty.\n   */\n  function advanceTaskQueue() {\n  \tvar start = now();\n  \tconfig.depth = (config.depth || 0) + 1;\n\n  \twhile (taskQueue.length && !config.blocking) {\n  \t\tvar elapsedTime = now() - start;\n\n  \t\tif (!defined.setTimeout || config.updateRate <= 0 || elapsedTime < config.updateRate) {\n  \t\t\tvar task = taskQueue.shift();\n  \t\t\ttask();\n  \t\t} else {\n  \t\t\tsetTimeout(advance);\n  \t\t\tbreak;\n  \t\t}\n  \t}\n\n  \tconfig.depth--;\n  }\n\n  /**\n   * Advance the testQueue to the next test to process. Call done() if testQueue completes.\n   */\n  function advanceTestQueue() {\n  \tif (!config.blocking && !config.queue.length && config.depth === 0) {\n  \t\tdone();\n  \t\treturn;\n  \t}\n\n  \tvar testTasks = config.queue.shift();\n  \taddToTaskQueue(testTasks());\n\n  \tif (priorityCount > 0) {\n  \t\tpriorityCount--;\n  \t}\n\n  \tadvance();\n  }\n\n  /**\n   * Enqueue the tasks for a test into the task queue.\n   * @param {Array} tasksArray\n   */\n  function addToTaskQueue(tasksArray) {\n  \ttaskQueue.push.apply(taskQueue, toConsumableArray(tasksArray));\n  }\n\n  /**\n   * Return the number of tasks remaining in the task queue to be processed.\n   * @return {Number}\n   */\n  function taskQueueLength() {\n  \treturn taskQueue.length;\n  }\n\n  /**\n   * Adds a test to the TestQueue for execution.\n   * @param {Function} testTasksFunc\n   * @param {Boolean} prioritize\n   * @param {String} seed\n   */\n  function addToTestQueue(testTasksFunc, prioritize, seed) {\n  \tif (prioritize) {\n  \t\tconfig.queue.splice(priorityCount++, 0, testTasksFunc);\n  \t} else if (seed) {\n  \t\tif (!unitSampler) {\n  \t\t\tunitSampler = unitSamplerGenerator(seed);\n  \t\t}\n\n  \t\t// Insert into a random position after all prioritized items\n  \t\tvar index = Math.floor(unitSampler() * (config.queue.length - priorityCount + 1));\n  \t\tconfig.queue.splice(priorityCount + index, 0, testTasksFunc);\n  \t} else {\n  \t\tconfig.queue.push(testTasksFunc);\n  \t}\n  }\n\n  /**\n   * Creates a seeded \"sample\" generator which is used for randomizing tests.\n   */\n  function unitSamplerGenerator(seed) {\n\n  \t// 32-bit xorshift, requires only a nonzero seed\n  \t// http://excamera.com/sphinx/article-xorshift.html\n  \tvar sample = parseInt(generateHash(seed), 16) || -1;\n  \treturn function () {\n  \t\tsample ^= sample << 13;\n  \t\tsample ^= sample >>> 17;\n  \t\tsample ^= sample << 5;\n\n  \t\t// ECMAScript has no unsigned number type\n  \t\tif (sample < 0) {\n  \t\t\tsample += 0x100000000;\n  \t\t}\n\n  \t\treturn sample / 0x100000000;\n  \t};\n  }\n\n  /**\n   * This function is called when the ProcessingQueue is done processing all\n   * items. It handles emitting the final run events.\n   */\n  function done() {\n  \tvar storage = config.storage;\n\n  \tProcessingQueue.finished = true;\n\n  \tvar runtime = now() - config.started;\n  \tvar passed = config.stats.all - config.stats.bad;\n\n  \tif (config.stats.all === 0) {\n\n  \t\tif (config.filter && config.filter.length) {\n  \t\t\tthrow new Error(\"No tests matched the filter \\\"\" + config.filter + \"\\\".\");\n  \t\t}\n\n  \t\tif (config.module && config.module.length) {\n  \t\t\tthrow new Error(\"No tests matched the module \\\"\" + config.module + \"\\\".\");\n  \t\t}\n\n  \t\tif (config.moduleId && config.moduleId.length) {\n  \t\t\tthrow new Error(\"No tests matched the moduleId \\\"\" + config.moduleId + \"\\\".\");\n  \t\t}\n\n  \t\tif (config.testId && config.testId.length) {\n  \t\t\tthrow new Error(\"No tests matched the testId \\\"\" + config.testId + \"\\\".\");\n  \t\t}\n\n  \t\tthrow new Error(\"No tests were run.\");\n  \t}\n\n  \temit(\"runEnd\", globalSuite.end(true));\n  \trunLoggingCallbacks(\"done\", {\n  \t\tpassed: passed,\n  \t\tfailed: config.stats.bad,\n  \t\ttotal: config.stats.all,\n  \t\truntime: runtime\n  \t});\n\n  \t// Clear own storage items if all tests passed\n  \tif (storage && config.stats.bad === 0) {\n  \t\tfor (var i = storage.length - 1; i >= 0; i--) {\n  \t\t\tvar key = storage.key(i);\n\n  \t\t\tif (key.indexOf(\"qunit-test-\") === 0) {\n  \t\t\t\tstorage.removeItem(key);\n  \t\t\t}\n  \t\t}\n  \t}\n  }\n\n  var ProcessingQueue = {\n  \tfinished: false,\n  \tadd: addToTestQueue,\n  \tadvance: advance,\n  \ttaskCount: taskQueueLength\n  };\n\n  var TestReport = function () {\n  \tfunction TestReport(name, suite, options) {\n  \t\tclassCallCheck(this, TestReport);\n\n  \t\tthis.name = name;\n  \t\tthis.suiteName = suite.name;\n  \t\tthis.fullName = suite.fullName.concat(name);\n  \t\tthis.runtime = 0;\n  \t\tthis.assertions = [];\n\n  \t\tthis.skipped = !!options.skip;\n  \t\tthis.todo = !!options.todo;\n\n  \t\tthis.valid = options.valid;\n\n  \t\tthis._startTime = 0;\n  \t\tthis._endTime = 0;\n\n  \t\tsuite.pushTest(this);\n  \t}\n\n  \tcreateClass(TestReport, [{\n  \t\tkey: \"start\",\n  \t\tvalue: function start(recordTime) {\n  \t\t\tif (recordTime) {\n  \t\t\t\tthis._startTime = Date.now();\n  \t\t\t}\n\n  \t\t\treturn {\n  \t\t\t\tname: this.name,\n  \t\t\t\tsuiteName: this.suiteName,\n  \t\t\t\tfullName: this.fullName.slice()\n  \t\t\t};\n  \t\t}\n  \t}, {\n  \t\tkey: \"end\",\n  \t\tvalue: function end(recordTime) {\n  \t\t\tif (recordTime) {\n  \t\t\t\tthis._endTime = Date.now();\n  \t\t\t}\n\n  \t\t\treturn extend(this.start(), {\n  \t\t\t\truntime: this.getRuntime(),\n  \t\t\t\tstatus: this.getStatus(),\n  \t\t\t\terrors: this.getFailedAssertions(),\n  \t\t\t\tassertions: this.getAssertions()\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"pushAssertion\",\n  \t\tvalue: function pushAssertion(assertion) {\n  \t\t\tthis.assertions.push(assertion);\n  \t\t}\n  \t}, {\n  \t\tkey: \"getRuntime\",\n  \t\tvalue: function getRuntime() {\n  \t\t\treturn this._endTime - this._startTime;\n  \t\t}\n  \t}, {\n  \t\tkey: \"getStatus\",\n  \t\tvalue: function getStatus() {\n  \t\t\tif (this.skipped) {\n  \t\t\t\treturn \"skipped\";\n  \t\t\t}\n\n  \t\t\tvar testPassed = this.getFailedAssertions().length > 0 ? this.todo : !this.todo;\n\n  \t\t\tif (!testPassed) {\n  \t\t\t\treturn \"failed\";\n  \t\t\t} else if (this.todo) {\n  \t\t\t\treturn \"todo\";\n  \t\t\t} else {\n  \t\t\t\treturn \"passed\";\n  \t\t\t}\n  \t\t}\n  \t}, {\n  \t\tkey: \"getFailedAssertions\",\n  \t\tvalue: function getFailedAssertions() {\n  \t\t\treturn this.assertions.filter(function (assertion) {\n  \t\t\t\treturn !assertion.passed;\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"getAssertions\",\n  \t\tvalue: function getAssertions() {\n  \t\t\treturn this.assertions.slice();\n  \t\t}\n\n  \t\t// Remove actual and expected values from assertions. This is to prevent\n  \t\t// leaking memory throughout a test suite.\n\n  \t}, {\n  \t\tkey: \"slimAssertions\",\n  \t\tvalue: function slimAssertions() {\n  \t\t\tthis.assertions = this.assertions.map(function (assertion) {\n  \t\t\t\tdelete assertion.actual;\n  \t\t\t\tdelete assertion.expected;\n  \t\t\t\treturn assertion;\n  \t\t\t});\n  \t\t}\n  \t}]);\n  \treturn TestReport;\n  }();\n\n  var focused$1 = false;\n\n  function Test(settings) {\n  \tvar i, l;\n\n  \t++Test.count;\n\n  \tthis.expected = null;\n  \tthis.assertions = [];\n  \tthis.semaphore = 0;\n  \tthis.module = config.currentModule;\n  \tthis.stack = sourceFromStacktrace(3);\n  \tthis.steps = [];\n  \tthis.timeout = undefined;\n\n  \t// If a module is skipped, all its tests and the tests of the child suites\n  \t// should be treated as skipped even if they are defined as `only` or `todo`.\n  \t// As for `todo` module, all its tests will be treated as `todo` except for\n  \t// tests defined as `skip` which will be left intact.\n  \t//\n  \t// So, if a test is defined as `todo` and is inside a skipped module, we should\n  \t// then treat that test as if was defined as `skip`.\n  \tif (this.module.skip) {\n  \t\tsettings.skip = true;\n  \t\tsettings.todo = false;\n\n  \t\t// Skipped tests should be left intact\n  \t} else if (this.module.todo && !settings.skip) {\n  \t\tsettings.todo = true;\n  \t}\n\n  \textend(this, settings);\n\n  \tthis.testReport = new TestReport(settings.testName, this.module.suiteReport, {\n  \t\ttodo: settings.todo,\n  \t\tskip: settings.skip,\n  \t\tvalid: this.valid()\n  \t});\n\n  \t// Register unique strings\n  \tfor (i = 0, l = this.module.tests; i < l.length; i++) {\n  \t\tif (this.module.tests[i].name === this.testName) {\n  \t\t\tthis.testName += \" \";\n  \t\t}\n  \t}\n\n  \tthis.testId = generateHash(this.module.name, this.testName);\n\n  \tthis.module.tests.push({\n  \t\tname: this.testName,\n  \t\ttestId: this.testId,\n  \t\tskip: !!settings.skip\n  \t});\n\n  \tif (settings.skip) {\n\n  \t\t// Skipped tests will fully ignore any sent callback\n  \t\tthis.callback = function () {};\n  \t\tthis.async = false;\n  \t\tthis.expected = 0;\n  \t} else {\n  \t\tif (typeof this.callback !== \"function\") {\n  \t\t\tvar method = this.todo ? \"todo\" : \"test\";\n\n  \t\t\t// eslint-disable-next-line max-len\n  \t\t\tthrow new TypeError(\"You must provide a function as a test callback to QUnit.\" + method + \"(\\\"\" + settings.testName + \"\\\")\");\n  \t\t}\n\n  \t\tthis.assert = new Assert(this);\n  \t}\n  }\n\n  Test.count = 0;\n\n  function getNotStartedModules(startModule) {\n  \tvar module = startModule,\n  \t    modules = [];\n\n  \twhile (module && module.testsRun === 0) {\n  \t\tmodules.push(module);\n  \t\tmodule = module.parentModule;\n  \t}\n\n  \treturn modules;\n  }\n\n  Test.prototype = {\n  \tbefore: function before() {\n  \t\tvar i,\n  \t\t    startModule,\n  \t\t    module = this.module,\n  \t\t    notStartedModules = getNotStartedModules(module);\n\n  \t\tfor (i = notStartedModules.length - 1; i >= 0; i--) {\n  \t\t\tstartModule = notStartedModules[i];\n  \t\t\tstartModule.stats = { all: 0, bad: 0, started: now() };\n  \t\t\temit(\"suiteStart\", startModule.suiteReport.start(true));\n  \t\t\trunLoggingCallbacks(\"moduleStart\", {\n  \t\t\t\tname: startModule.name,\n  \t\t\t\ttests: startModule.tests\n  \t\t\t});\n  \t\t}\n\n  \t\tconfig.current = this;\n\n  \t\tthis.testEnvironment = extend({}, module.testEnvironment);\n\n  \t\tthis.started = now();\n  \t\temit(\"testStart\", this.testReport.start(true));\n  \t\trunLoggingCallbacks(\"testStart\", {\n  \t\t\tname: this.testName,\n  \t\t\tmodule: module.name,\n  \t\t\ttestId: this.testId,\n  \t\t\tpreviousFailure: this.previousFailure\n  \t\t});\n\n  \t\tif (!config.pollution) {\n  \t\t\tsaveGlobal();\n  \t\t}\n  \t},\n\n  \trun: function run() {\n  \t\tvar promise;\n\n  \t\tconfig.current = this;\n\n  \t\tthis.callbackStarted = now();\n\n  \t\tif (config.notrycatch) {\n  \t\t\trunTest(this);\n  \t\t\treturn;\n  \t\t}\n\n  \t\ttry {\n  \t\t\trunTest(this);\n  \t\t} catch (e) {\n  \t\t\tthis.pushFailure(\"Died on test #\" + (this.assertions.length + 1) + \" \" + this.stack + \": \" + (e.message || e), extractStacktrace(e, 0));\n\n  \t\t\t// Else next test will carry the responsibility\n  \t\t\tsaveGlobal();\n\n  \t\t\t// Restart the tests if they're blocking\n  \t\t\tif (config.blocking) {\n  \t\t\t\tinternalRecover(this);\n  \t\t\t}\n  \t\t}\n\n  \t\tfunction runTest(test) {\n  \t\t\tpromise = test.callback.call(test.testEnvironment, test.assert);\n  \t\t\ttest.resolvePromise(promise);\n\n  \t\t\t// If the test has a \"lock\" on it, but the timeout is 0, then we push a\n  \t\t\t// failure as the test should be synchronous.\n  \t\t\tif (test.timeout === 0 && test.semaphore !== 0) {\n  \t\t\t\tpushFailure(\"Test did not finish synchronously even though assert.timeout( 0 ) was used.\", sourceFromStacktrace(2));\n  \t\t\t}\n  \t\t}\n  \t},\n\n  \tafter: function after() {\n  \t\tcheckPollution();\n  \t},\n\n  \tqueueHook: function queueHook(hook, hookName, hookOwner) {\n  \t\tvar _this = this;\n\n  \t\tvar callHook = function callHook() {\n  \t\t\tvar promise = hook.call(_this.testEnvironment, _this.assert);\n  \t\t\t_this.resolvePromise(promise, hookName);\n  \t\t};\n\n  \t\tvar runHook = function runHook() {\n  \t\t\tif (hookName === \"before\") {\n  \t\t\t\tif (hookOwner.unskippedTestsRun !== 0) {\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n\n  \t\t\t\t_this.preserveEnvironment = true;\n  \t\t\t}\n\n  \t\t\t// The 'after' hook should only execute when there are not tests left and\n  \t\t\t// when the 'after' and 'finish' tasks are the only tasks left to process\n  \t\t\tif (hookName === \"after\" && hookOwner.unskippedTestsRun !== numberOfUnskippedTests(hookOwner) - 1 && (config.queue.length > 0 || ProcessingQueue.taskCount() > 2)) {\n  \t\t\t\treturn;\n  \t\t\t}\n\n  \t\t\tconfig.current = _this;\n  \t\t\tif (config.notrycatch) {\n  \t\t\t\tcallHook();\n  \t\t\t\treturn;\n  \t\t\t}\n  \t\t\ttry {\n  \t\t\t\tcallHook();\n  \t\t\t} catch (error) {\n  \t\t\t\t_this.pushFailure(hookName + \" failed on \" + _this.testName + \": \" + (error.message || error), extractStacktrace(error, 0));\n  \t\t\t}\n  \t\t};\n\n  \t\treturn runHook;\n  \t},\n\n\n  \t// Currently only used for module level hooks, can be used to add global level ones\n  \thooks: function hooks(handler) {\n  \t\tvar hooks = [];\n\n  \t\tfunction processHooks(test, module) {\n  \t\t\tif (module.parentModule) {\n  \t\t\t\tprocessHooks(test, module.parentModule);\n  \t\t\t}\n\n  \t\t\tif (module.hooks[handler].length) {\n  \t\t\t\tfor (var i = 0; i < module.hooks[handler].length; i++) {\n  \t\t\t\t\thooks.push(test.queueHook(module.hooks[handler][i], handler, module));\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\t// Hooks are ignored on skipped tests\n  \t\tif (!this.skip) {\n  \t\t\tprocessHooks(this, this.module);\n  \t\t}\n\n  \t\treturn hooks;\n  \t},\n\n\n  \tfinish: function finish() {\n  \t\tconfig.current = this;\n\n  \t\tif (this.steps.length) {\n  \t\t\tvar stepsList = this.steps.join(\", \");\n  \t\t\tthis.pushFailure(\"Expected assert.verifySteps() to be called before end of test \" + (\"after using assert.step(). Unverified steps: \" + stepsList), this.stack);\n  \t\t}\n\n  \t\tif (config.requireExpects && this.expected === null) {\n  \t\t\tthis.pushFailure(\"Expected number of assertions to be defined, but expect() was \" + \"not called.\", this.stack);\n  \t\t} else if (this.expected !== null && this.expected !== this.assertions.length) {\n  \t\t\tthis.pushFailure(\"Expected \" + this.expected + \" assertions, but \" + this.assertions.length + \" were run\", this.stack);\n  \t\t} else if (this.expected === null && !this.assertions.length) {\n  \t\t\tthis.pushFailure(\"Expected at least one assertion, but none were run - call \" + \"expect(0) to accept zero assertions.\", this.stack);\n  \t\t}\n\n  \t\tvar i,\n  \t\t    module = this.module,\n  \t\t    moduleName = module.name,\n  \t\t    testName = this.testName,\n  \t\t    skipped = !!this.skip,\n  \t\t    todo = !!this.todo,\n  \t\t    bad = 0,\n  \t\t    storage = config.storage;\n\n  \t\tthis.runtime = now() - this.started;\n\n  \t\tconfig.stats.all += this.assertions.length;\n  \t\tmodule.stats.all += this.assertions.length;\n\n  \t\tfor (i = 0; i < this.assertions.length; i++) {\n  \t\t\tif (!this.assertions[i].result) {\n  \t\t\t\tbad++;\n  \t\t\t\tconfig.stats.bad++;\n  \t\t\t\tmodule.stats.bad++;\n  \t\t\t}\n  \t\t}\n\n  \t\tnotifyTestsRan(module, skipped);\n\n  \t\t// Store result when possible\n  \t\tif (storage) {\n  \t\t\tif (bad) {\n  \t\t\t\tstorage.setItem(\"qunit-test-\" + moduleName + \"-\" + testName, bad);\n  \t\t\t} else {\n  \t\t\t\tstorage.removeItem(\"qunit-test-\" + moduleName + \"-\" + testName);\n  \t\t\t}\n  \t\t}\n\n  \t\t// After emitting the js-reporters event we cleanup the assertion data to\n  \t\t// avoid leaking it. It is not used by the legacy testDone callbacks.\n  \t\temit(\"testEnd\", this.testReport.end(true));\n  \t\tthis.testReport.slimAssertions();\n\n  \t\trunLoggingCallbacks(\"testDone\", {\n  \t\t\tname: testName,\n  \t\t\tmodule: moduleName,\n  \t\t\tskipped: skipped,\n  \t\t\ttodo: todo,\n  \t\t\tfailed: bad,\n  \t\t\tpassed: this.assertions.length - bad,\n  \t\t\ttotal: this.assertions.length,\n  \t\t\truntime: skipped ? 0 : this.runtime,\n\n  \t\t\t// HTML Reporter use\n  \t\t\tassertions: this.assertions,\n  \t\t\ttestId: this.testId,\n\n  \t\t\t// Source of Test\n  \t\t\tsource: this.stack\n  \t\t});\n\n  \t\tif (module.testsRun === numberOfTests(module)) {\n  \t\t\tlogSuiteEnd(module);\n\n  \t\t\t// Check if the parent modules, iteratively, are done. If that the case,\n  \t\t\t// we emit the `suiteEnd` event and trigger `moduleDone` callback.\n  \t\t\tvar parent = module.parentModule;\n  \t\t\twhile (parent && parent.testsRun === numberOfTests(parent)) {\n  \t\t\t\tlogSuiteEnd(parent);\n  \t\t\t\tparent = parent.parentModule;\n  \t\t\t}\n  \t\t}\n\n  \t\tconfig.current = undefined;\n\n  \t\tfunction logSuiteEnd(module) {\n  \t\t\temit(\"suiteEnd\", module.suiteReport.end(true));\n  \t\t\trunLoggingCallbacks(\"moduleDone\", {\n  \t\t\t\tname: module.name,\n  \t\t\t\ttests: module.tests,\n  \t\t\t\tfailed: module.stats.bad,\n  \t\t\t\tpassed: module.stats.all - module.stats.bad,\n  \t\t\t\ttotal: module.stats.all,\n  \t\t\t\truntime: now() - module.stats.started\n  \t\t\t});\n  \t\t}\n  \t},\n\n  \tpreserveTestEnvironment: function preserveTestEnvironment() {\n  \t\tif (this.preserveEnvironment) {\n  \t\t\tthis.module.testEnvironment = this.testEnvironment;\n  \t\t\tthis.testEnvironment = extend({}, this.module.testEnvironment);\n  \t\t}\n  \t},\n\n  \tqueue: function queue() {\n  \t\tvar test = this;\n\n  \t\tif (!this.valid()) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\tfunction runTest() {\n  \t\t\treturn [function () {\n  \t\t\t\ttest.before();\n  \t\t\t}].concat(toConsumableArray(test.hooks(\"before\")), [function () {\n  \t\t\t\ttest.preserveTestEnvironment();\n  \t\t\t}], toConsumableArray(test.hooks(\"beforeEach\")), [function () {\n  \t\t\t\ttest.run();\n  \t\t\t}], toConsumableArray(test.hooks(\"afterEach\").reverse()), toConsumableArray(test.hooks(\"after\").reverse()), [function () {\n  \t\t\t\ttest.after();\n  \t\t\t}, function () {\n  \t\t\t\ttest.finish();\n  \t\t\t}]);\n  \t\t}\n\n  \t\tvar previousFailCount = config.storage && +config.storage.getItem(\"qunit-test-\" + this.module.name + \"-\" + this.testName);\n\n  \t\t// Prioritize previously failed tests, detected from storage\n  \t\tvar prioritize = config.reorder && !!previousFailCount;\n\n  \t\tthis.previousFailure = !!previousFailCount;\n\n  \t\tProcessingQueue.add(runTest, prioritize, config.seed);\n\n  \t\t// If the queue has already finished, we manually process the new test\n  \t\tif (ProcessingQueue.finished) {\n  \t\t\tProcessingQueue.advance();\n  \t\t}\n  \t},\n\n\n  \tpushResult: function pushResult(resultInfo) {\n  \t\tif (this !== config.current) {\n  \t\t\tthrow new Error(\"Assertion occurred after test had finished.\");\n  \t\t}\n\n  \t\t// Destructure of resultInfo = { result, actual, expected, message, negative }\n  \t\tvar source,\n  \t\t    details = {\n  \t\t\tmodule: this.module.name,\n  \t\t\tname: this.testName,\n  \t\t\tresult: resultInfo.result,\n  \t\t\tmessage: resultInfo.message,\n  \t\t\tactual: resultInfo.actual,\n  \t\t\ttestId: this.testId,\n  \t\t\tnegative: resultInfo.negative || false,\n  \t\t\truntime: now() - this.started,\n  \t\t\ttodo: !!this.todo\n  \t\t};\n\n  \t\tif (hasOwn.call(resultInfo, \"expected\")) {\n  \t\t\tdetails.expected = resultInfo.expected;\n  \t\t}\n\n  \t\tif (!resultInfo.result) {\n  \t\t\tsource = resultInfo.source || sourceFromStacktrace();\n\n  \t\t\tif (source) {\n  \t\t\t\tdetails.source = source;\n  \t\t\t}\n  \t\t}\n\n  \t\tthis.logAssertion(details);\n\n  \t\tthis.assertions.push({\n  \t\t\tresult: !!resultInfo.result,\n  \t\t\tmessage: resultInfo.message\n  \t\t});\n  \t},\n\n  \tpushFailure: function pushFailure(message, source, actual) {\n  \t\tif (!(this instanceof Test)) {\n  \t\t\tthrow new Error(\"pushFailure() assertion outside test context, was \" + sourceFromStacktrace(2));\n  \t\t}\n\n  \t\tthis.pushResult({\n  \t\t\tresult: false,\n  \t\t\tmessage: message || \"error\",\n  \t\t\tactual: actual || null,\n  \t\t\tsource: source\n  \t\t});\n  \t},\n\n  \t/**\n    * Log assertion details using both the old QUnit.log interface and\n    * QUnit.on( \"assertion\" ) interface.\n    *\n    * @private\n    */\n  \tlogAssertion: function logAssertion(details) {\n  \t\trunLoggingCallbacks(\"log\", details);\n\n  \t\tvar assertion = {\n  \t\t\tpassed: details.result,\n  \t\t\tactual: details.actual,\n  \t\t\texpected: details.expected,\n  \t\t\tmessage: details.message,\n  \t\t\tstack: details.source,\n  \t\t\ttodo: details.todo\n  \t\t};\n  \t\tthis.testReport.pushAssertion(assertion);\n  \t\temit(\"assertion\", assertion);\n  \t},\n\n\n  \tresolvePromise: function resolvePromise(promise, phase) {\n  \t\tvar then,\n  \t\t    resume,\n  \t\t    message,\n  \t\t    test = this;\n  \t\tif (promise != null) {\n  \t\t\tthen = promise.then;\n  \t\t\tif (objectType(then) === \"function\") {\n  \t\t\t\tresume = internalStop(test);\n  \t\t\t\tif (config.notrycatch) {\n  \t\t\t\t\tthen.call(promise, function () {\n  \t\t\t\t\t\tresume();\n  \t\t\t\t\t});\n  \t\t\t\t} else {\n  \t\t\t\t\tthen.call(promise, function () {\n  \t\t\t\t\t\tresume();\n  \t\t\t\t\t}, function (error) {\n  \t\t\t\t\t\tmessage = \"Promise rejected \" + (!phase ? \"during\" : phase.replace(/Each$/, \"\")) + \" \\\"\" + test.testName + \"\\\": \" + (error && error.message || error);\n  \t\t\t\t\t\ttest.pushFailure(message, extractStacktrace(error, 0));\n\n  \t\t\t\t\t\t// Else next test will carry the responsibility\n  \t\t\t\t\t\tsaveGlobal();\n\n  \t\t\t\t\t\t// Unblock\n  \t\t\t\t\t\tinternalRecover(test);\n  \t\t\t\t\t});\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n  \t},\n\n  \tvalid: function valid() {\n  \t\tvar filter = config.filter,\n  \t\t    regexFilter = /^(!?)\\/([\\w\\W]*)\\/(i?$)/.exec(filter),\n  \t\t    module = config.module && config.module.toLowerCase(),\n  \t\t    fullName = this.module.name + \": \" + this.testName;\n\n  \t\tfunction moduleChainNameMatch(testModule) {\n  \t\t\tvar testModuleName = testModule.name ? testModule.name.toLowerCase() : null;\n  \t\t\tif (testModuleName === module) {\n  \t\t\t\treturn true;\n  \t\t\t} else if (testModule.parentModule) {\n  \t\t\t\treturn moduleChainNameMatch(testModule.parentModule);\n  \t\t\t} else {\n  \t\t\t\treturn false;\n  \t\t\t}\n  \t\t}\n\n  \t\tfunction moduleChainIdMatch(testModule) {\n  \t\t\treturn inArray(testModule.moduleId, config.moduleId) || testModule.parentModule && moduleChainIdMatch(testModule.parentModule);\n  \t\t}\n\n  \t\t// Internally-generated tests are always valid\n  \t\tif (this.callback && this.callback.validTest) {\n  \t\t\treturn true;\n  \t\t}\n\n  \t\tif (config.moduleId && config.moduleId.length > 0 && !moduleChainIdMatch(this.module)) {\n\n  \t\t\treturn false;\n  \t\t}\n\n  \t\tif (config.testId && config.testId.length > 0 && !inArray(this.testId, config.testId)) {\n\n  \t\t\treturn false;\n  \t\t}\n\n  \t\tif (module && !moduleChainNameMatch(this.module)) {\n  \t\t\treturn false;\n  \t\t}\n\n  \t\tif (!filter) {\n  \t\t\treturn true;\n  \t\t}\n\n  \t\treturn regexFilter ? this.regexFilter(!!regexFilter[1], regexFilter[2], regexFilter[3], fullName) : this.stringFilter(filter, fullName);\n  \t},\n\n  \tregexFilter: function regexFilter(exclude, pattern, flags, fullName) {\n  \t\tvar regex = new RegExp(pattern, flags);\n  \t\tvar match = regex.test(fullName);\n\n  \t\treturn match !== exclude;\n  \t},\n\n  \tstringFilter: function stringFilter(filter, fullName) {\n  \t\tfilter = filter.toLowerCase();\n  \t\tfullName = fullName.toLowerCase();\n\n  \t\tvar include = filter.charAt(0) !== \"!\";\n  \t\tif (!include) {\n  \t\t\tfilter = filter.slice(1);\n  \t\t}\n\n  \t\t// If the filter matches, we need to honour include\n  \t\tif (fullName.indexOf(filter) !== -1) {\n  \t\t\treturn include;\n  \t\t}\n\n  \t\t// Otherwise, do the opposite\n  \t\treturn !include;\n  \t}\n  };\n\n  function pushFailure() {\n  \tif (!config.current) {\n  \t\tthrow new Error(\"pushFailure() assertion outside test context, in \" + sourceFromStacktrace(2));\n  \t}\n\n  \t// Gets current test obj\n  \tvar currentTest = config.current;\n\n  \treturn currentTest.pushFailure.apply(currentTest, arguments);\n  }\n\n  function saveGlobal() {\n  \tconfig.pollution = [];\n\n  \tif (config.noglobals) {\n  \t\tfor (var key in global$1) {\n  \t\t\tif (hasOwn.call(global$1, key)) {\n\n  \t\t\t\t// In Opera sometimes DOM element ids show up here, ignore them\n  \t\t\t\tif (/^qunit-test-output/.test(key)) {\n  \t\t\t\t\tcontinue;\n  \t\t\t\t}\n  \t\t\t\tconfig.pollution.push(key);\n  \t\t\t}\n  \t\t}\n  \t}\n  }\n\n  function checkPollution() {\n  \tvar newGlobals,\n  \t    deletedGlobals,\n  \t    old = config.pollution;\n\n  \tsaveGlobal();\n\n  \tnewGlobals = diff(config.pollution, old);\n  \tif (newGlobals.length > 0) {\n  \t\tpushFailure(\"Introduced global variable(s): \" + newGlobals.join(\", \"));\n  \t}\n\n  \tdeletedGlobals = diff(old, config.pollution);\n  \tif (deletedGlobals.length > 0) {\n  \t\tpushFailure(\"Deleted global variable(s): \" + deletedGlobals.join(\", \"));\n  \t}\n  }\n\n  // Will be exposed as QUnit.test\n  function test(testName, callback) {\n  \tif (focused$1) {\n  \t\treturn;\n  \t}\n\n  \tvar newTest = new Test({\n  \t\ttestName: testName,\n  \t\tcallback: callback\n  \t});\n\n  \tnewTest.queue();\n  }\n\n  function todo(testName, callback) {\n  \tif (focused$1) {\n  \t\treturn;\n  \t}\n\n  \tvar newTest = new Test({\n  \t\ttestName: testName,\n  \t\tcallback: callback,\n  \t\ttodo: true\n  \t});\n\n  \tnewTest.queue();\n  }\n\n  // Will be exposed as QUnit.skip\n  function skip(testName) {\n  \tif (focused$1) {\n  \t\treturn;\n  \t}\n\n  \tvar test = new Test({\n  \t\ttestName: testName,\n  \t\tskip: true\n  \t});\n\n  \ttest.queue();\n  }\n\n  // Will be exposed as QUnit.only\n  function only(testName, callback) {\n  \tif (focused$1) {\n  \t\treturn;\n  \t}\n\n  \tconfig.queue.length = 0;\n  \tfocused$1 = true;\n\n  \tvar newTest = new Test({\n  \t\ttestName: testName,\n  \t\tcallback: callback\n  \t});\n\n  \tnewTest.queue();\n  }\n\n  // Put a hold on processing and return a function that will release it.\n  function internalStop(test) {\n  \ttest.semaphore += 1;\n  \tconfig.blocking = true;\n\n  \t// Set a recovery timeout, if so configured.\n  \tif (defined.setTimeout) {\n  \t\tvar timeoutDuration = void 0;\n\n  \t\tif (typeof test.timeout === \"number\") {\n  \t\t\ttimeoutDuration = test.timeout;\n  \t\t} else if (typeof config.testTimeout === \"number\") {\n  \t\t\ttimeoutDuration = config.testTimeout;\n  \t\t}\n\n  \t\tif (typeof timeoutDuration === \"number\" && timeoutDuration > 0) {\n  \t\t\tclearTimeout(config.timeout);\n  \t\t\tconfig.timeout = setTimeout(function () {\n  \t\t\t\tpushFailure(\"Test took longer than \" + timeoutDuration + \"ms; test timed out.\", sourceFromStacktrace(2));\n  \t\t\t\tinternalRecover(test);\n  \t\t\t}, timeoutDuration);\n  \t\t}\n  \t}\n\n  \tvar released = false;\n  \treturn function resume() {\n  \t\tif (released) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\treleased = true;\n  \t\ttest.semaphore -= 1;\n  \t\tinternalStart(test);\n  \t};\n  }\n\n  // Forcefully release all processing holds.\n  function internalRecover(test) {\n  \ttest.semaphore = 0;\n  \tinternalStart(test);\n  }\n\n  // Release a processing hold, scheduling a resumption attempt if no holds remain.\n  function internalStart(test) {\n\n  \t// If semaphore is non-numeric, throw error\n  \tif (isNaN(test.semaphore)) {\n  \t\ttest.semaphore = 0;\n\n  \t\tpushFailure(\"Invalid value on test.semaphore\", sourceFromStacktrace(2));\n  \t\treturn;\n  \t}\n\n  \t// Don't start until equal number of stop-calls\n  \tif (test.semaphore > 0) {\n  \t\treturn;\n  \t}\n\n  \t// Throw an Error if start is called more often than stop\n  \tif (test.semaphore < 0) {\n  \t\ttest.semaphore = 0;\n\n  \t\tpushFailure(\"Tried to restart test while already started (test's semaphore was 0 already)\", sourceFromStacktrace(2));\n  \t\treturn;\n  \t}\n\n  \t// Add a slight delay to allow more assertions etc.\n  \tif (defined.setTimeout) {\n  \t\tif (config.timeout) {\n  \t\t\tclearTimeout(config.timeout);\n  \t\t}\n  \t\tconfig.timeout = setTimeout(function () {\n  \t\t\tif (test.semaphore > 0) {\n  \t\t\t\treturn;\n  \t\t\t}\n\n  \t\t\tif (config.timeout) {\n  \t\t\t\tclearTimeout(config.timeout);\n  \t\t\t}\n\n  \t\t\tbegin();\n  \t\t});\n  \t} else {\n  \t\tbegin();\n  \t}\n  }\n\n  function collectTests(module) {\n  \tvar tests = [].concat(module.tests);\n  \tvar modules = [].concat(toConsumableArray(module.childModules));\n\n  \t// Do a breadth-first traversal of the child modules\n  \twhile (modules.length) {\n  \t\tvar nextModule = modules.shift();\n  \t\ttests.push.apply(tests, nextModule.tests);\n  \t\tmodules.push.apply(modules, toConsumableArray(nextModule.childModules));\n  \t}\n\n  \treturn tests;\n  }\n\n  function numberOfTests(module) {\n  \treturn collectTests(module).length;\n  }\n\n  function numberOfUnskippedTests(module) {\n  \treturn collectTests(module).filter(function (test) {\n  \t\treturn !test.skip;\n  \t}).length;\n  }\n\n  function notifyTestsRan(module, skipped) {\n  \tmodule.testsRun++;\n  \tif (!skipped) {\n  \t\tmodule.unskippedTestsRun++;\n  \t}\n  \twhile (module = module.parentModule) {\n  \t\tmodule.testsRun++;\n  \t\tif (!skipped) {\n  \t\t\tmodule.unskippedTestsRun++;\n  \t\t}\n  \t}\n  }\n\n  /**\n   * Returns a function that proxies to the given method name on the globals\n   * console object. The proxy will also detect if the console doesn't exist and\n   * will appropriately no-op. This allows support for IE9, which doesn't have a\n   * console if the developer tools are not open.\n   */\n  function consoleProxy(method) {\n  \treturn function () {\n  \t\tif (console) {\n  \t\t\tconsole[method].apply(console, arguments);\n  \t\t}\n  \t};\n  }\n\n  var Logger = {\n  \twarn: consoleProxy(\"warn\")\n  };\n\n  var Assert = function () {\n  \tfunction Assert(testContext) {\n  \t\tclassCallCheck(this, Assert);\n\n  \t\tthis.test = testContext;\n  \t}\n\n  \t// Assert helpers\n\n  \tcreateClass(Assert, [{\n  \t\tkey: \"timeout\",\n  \t\tvalue: function timeout(duration) {\n  \t\t\tif (typeof duration !== \"number\") {\n  \t\t\t\tthrow new Error(\"You must pass a number as the duration to assert.timeout\");\n  \t\t\t}\n\n  \t\t\tthis.test.timeout = duration;\n  \t\t}\n\n  \t\t// Documents a \"step\", which is a string value, in a test as a passing assertion\n\n  \t}, {\n  \t\tkey: \"step\",\n  \t\tvalue: function step(message) {\n  \t\t\tvar assertionMessage = message;\n  \t\t\tvar result = !!message;\n\n  \t\t\tthis.test.steps.push(message);\n\n  \t\t\tif (objectType(message) === \"undefined\" || message === \"\") {\n  \t\t\t\tassertionMessage = \"You must provide a message to assert.step\";\n  \t\t\t} else if (objectType(message) !== \"string\") {\n  \t\t\t\tassertionMessage = \"You must provide a string value to assert.step\";\n  \t\t\t\tresult = false;\n  \t\t\t}\n\n  \t\t\treturn this.pushResult({\n  \t\t\t\tresult: result,\n  \t\t\t\tmessage: assertionMessage\n  \t\t\t});\n  \t\t}\n\n  \t\t// Verifies the steps in a test match a given array of string values\n\n  \t}, {\n  \t\tkey: \"verifySteps\",\n  \t\tvalue: function verifySteps(steps, message) {\n\n  \t\t\t// Since the steps array is just string values, we can clone with slice\n  \t\t\tvar actualStepsClone = this.test.steps.slice();\n  \t\t\tthis.deepEqual(actualStepsClone, steps, message);\n  \t\t\tthis.test.steps.length = 0;\n  \t\t}\n\n  \t\t// Specify the number of expected assertions to guarantee that failed test\n  \t\t// (no assertions are run at all) don't slip through.\n\n  \t}, {\n  \t\tkey: \"expect\",\n  \t\tvalue: function expect(asserts) {\n  \t\t\tif (arguments.length === 1) {\n  \t\t\t\tthis.test.expected = asserts;\n  \t\t\t} else {\n  \t\t\t\treturn this.test.expected;\n  \t\t\t}\n  \t\t}\n\n  \t\t// Put a hold on processing and return a function that will release it a maximum of once.\n\n  \t}, {\n  \t\tkey: \"async\",\n  \t\tvalue: function async(count) {\n  \t\t\tvar test$$1 = this.test;\n\n  \t\t\tvar popped = false,\n  \t\t\t    acceptCallCount = count;\n\n  \t\t\tif (typeof acceptCallCount === \"undefined\") {\n  \t\t\t\tacceptCallCount = 1;\n  \t\t\t}\n\n  \t\t\tvar resume = internalStop(test$$1);\n\n  \t\t\treturn function done() {\n  \t\t\t\tif (config.current !== test$$1) {\n  \t\t\t\t\tthrow Error(\"assert.async callback called after test finished.\");\n  \t\t\t\t}\n\n  \t\t\t\tif (popped) {\n  \t\t\t\t\ttest$$1.pushFailure(\"Too many calls to the `assert.async` callback\", sourceFromStacktrace(2));\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n\n  \t\t\t\tacceptCallCount -= 1;\n  \t\t\t\tif (acceptCallCount > 0) {\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n\n  \t\t\t\tpopped = true;\n  \t\t\t\tresume();\n  \t\t\t};\n  \t\t}\n\n  \t\t// Exports test.push() to the user API\n  \t\t// Alias of pushResult.\n\n  \t}, {\n  \t\tkey: \"push\",\n  \t\tvalue: function push(result, actual, expected, message, negative) {\n  \t\t\tLogger.warn(\"assert.push is deprecated and will be removed in QUnit 3.0.\" + \" Please use assert.pushResult instead (https://api.qunitjs.com/assert/pushResult).\");\n\n  \t\t\tvar currentAssert = this instanceof Assert ? this : config.current.assert;\n  \t\t\treturn currentAssert.pushResult({\n  \t\t\t\tresult: result,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message,\n  \t\t\t\tnegative: negative\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"pushResult\",\n  \t\tvalue: function pushResult(resultInfo) {\n\n  \t\t\t// Destructure of resultInfo = { result, actual, expected, message, negative }\n  \t\t\tvar assert = this;\n  \t\t\tvar currentTest = assert instanceof Assert && assert.test || config.current;\n\n  \t\t\t// Backwards compatibility fix.\n  \t\t\t// Allows the direct use of global exported assertions and QUnit.assert.*\n  \t\t\t// Although, it's use is not recommended as it can leak assertions\n  \t\t\t// to other tests from async tests, because we only get a reference to the current test,\n  \t\t\t// not exactly the test where assertion were intended to be called.\n  \t\t\tif (!currentTest) {\n  \t\t\t\tthrow new Error(\"assertion outside test context, in \" + sourceFromStacktrace(2));\n  \t\t\t}\n\n  \t\t\tif (!(assert instanceof Assert)) {\n  \t\t\t\tassert = currentTest.assert;\n  \t\t\t}\n\n  \t\t\treturn assert.test.pushResult(resultInfo);\n  \t\t}\n  \t}, {\n  \t\tkey: \"ok\",\n  \t\tvalue: function ok(result, message) {\n  \t\t\tif (!message) {\n  \t\t\t\tmessage = result ? \"okay\" : \"failed, expected argument to be truthy, was: \" + dump.parse(result);\n  \t\t\t}\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: !!result,\n  \t\t\t\tactual: result,\n  \t\t\t\texpected: true,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"notOk\",\n  \t\tvalue: function notOk(result, message) {\n  \t\t\tif (!message) {\n  \t\t\t\tmessage = !result ? \"okay\" : \"failed, expected argument to be falsy, was: \" + dump.parse(result);\n  \t\t\t}\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: !result,\n  \t\t\t\tactual: result,\n  \t\t\t\texpected: false,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"equal\",\n  \t\tvalue: function equal(actual, expected, message) {\n\n  \t\t\t// eslint-disable-next-line eqeqeq\n  \t\t\tvar result = expected == actual;\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: result,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"notEqual\",\n  \t\tvalue: function notEqual(actual, expected, message) {\n\n  \t\t\t// eslint-disable-next-line eqeqeq\n  \t\t\tvar result = expected != actual;\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: result,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message,\n  \t\t\t\tnegative: true\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"propEqual\",\n  \t\tvalue: function propEqual(actual, expected, message) {\n  \t\t\tactual = objectValues(actual);\n  \t\t\texpected = objectValues(expected);\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: equiv(actual, expected),\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"notPropEqual\",\n  \t\tvalue: function notPropEqual(actual, expected, message) {\n  \t\t\tactual = objectValues(actual);\n  \t\t\texpected = objectValues(expected);\n\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: !equiv(actual, expected),\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message,\n  \t\t\t\tnegative: true\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"deepEqual\",\n  \t\tvalue: function deepEqual(actual, expected, message) {\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: equiv(actual, expected),\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"notDeepEqual\",\n  \t\tvalue: function notDeepEqual(actual, expected, message) {\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: !equiv(actual, expected),\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message,\n  \t\t\t\tnegative: true\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"strictEqual\",\n  \t\tvalue: function strictEqual(actual, expected, message) {\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: expected === actual,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"notStrictEqual\",\n  \t\tvalue: function notStrictEqual(actual, expected, message) {\n  \t\t\tthis.pushResult({\n  \t\t\t\tresult: expected !== actual,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message,\n  \t\t\t\tnegative: true\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"throws\",\n  \t\tvalue: function throws(block, expected, message) {\n  \t\t\tvar actual = void 0,\n  \t\t\t    result = false;\n\n  \t\t\tvar currentTest = this instanceof Assert && this.test || config.current;\n\n  \t\t\t// 'expected' is optional unless doing string comparison\n  \t\t\tif (objectType(expected) === \"string\") {\n  \t\t\t\tif (message == null) {\n  \t\t\t\t\tmessage = expected;\n  \t\t\t\t\texpected = null;\n  \t\t\t\t} else {\n  \t\t\t\t\tthrow new Error(\"throws/raises does not accept a string value for the expected argument.\\n\" + \"Use a non-string object value (e.g. regExp) instead if it's necessary.\");\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\tcurrentTest.ignoreGlobalErrors = true;\n  \t\t\ttry {\n  \t\t\t\tblock.call(currentTest.testEnvironment);\n  \t\t\t} catch (e) {\n  \t\t\t\tactual = e;\n  \t\t\t}\n  \t\t\tcurrentTest.ignoreGlobalErrors = false;\n\n  \t\t\tif (actual) {\n  \t\t\t\tvar expectedType = objectType(expected);\n\n  \t\t\t\t// We don't want to validate thrown error\n  \t\t\t\tif (!expected) {\n  \t\t\t\t\tresult = true;\n  \t\t\t\t\texpected = null;\n\n  \t\t\t\t\t// Expected is a regexp\n  \t\t\t\t} else if (expectedType === \"regexp\") {\n  \t\t\t\t\tresult = expected.test(errorString(actual));\n\n  \t\t\t\t\t// Expected is a constructor, maybe an Error constructor\n  \t\t\t\t} else if (expectedType === \"function\" && actual instanceof expected) {\n  \t\t\t\t\tresult = true;\n\n  \t\t\t\t\t// Expected is an Error object\n  \t\t\t\t} else if (expectedType === \"object\") {\n  \t\t\t\t\tresult = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;\n\n  \t\t\t\t\t// Expected is a validation function which returns true if validation passed\n  \t\t\t\t} else if (expectedType === \"function\" && expected.call({}, actual) === true) {\n  \t\t\t\t\texpected = null;\n  \t\t\t\t\tresult = true;\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\tcurrentTest.assert.pushResult({\n  \t\t\t\tresult: result,\n  \t\t\t\tactual: actual,\n  \t\t\t\texpected: expected,\n  \t\t\t\tmessage: message\n  \t\t\t});\n  \t\t}\n  \t}, {\n  \t\tkey: \"rejects\",\n  \t\tvalue: function rejects(promise, expected, message) {\n  \t\t\tvar result = false;\n\n  \t\t\tvar currentTest = this instanceof Assert && this.test || config.current;\n\n  \t\t\t// 'expected' is optional unless doing string comparison\n  \t\t\tif (objectType(expected) === \"string\") {\n  \t\t\t\tif (message === undefined) {\n  \t\t\t\t\tmessage = expected;\n  \t\t\t\t\texpected = undefined;\n  \t\t\t\t} else {\n  \t\t\t\t\tmessage = \"assert.rejects does not accept a string value for the expected \" + \"argument.\\nUse a non-string object value (e.g. validator function) instead \" + \"if necessary.\";\n\n  \t\t\t\t\tcurrentTest.assert.pushResult({\n  \t\t\t\t\t\tresult: false,\n  \t\t\t\t\t\tmessage: message\n  \t\t\t\t\t});\n\n  \t\t\t\t\treturn;\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\tvar then = promise && promise.then;\n  \t\t\tif (objectType(then) !== \"function\") {\n  \t\t\t\tvar _message = \"The value provided to `assert.rejects` in \" + \"\\\"\" + currentTest.testName + \"\\\" was not a promise.\";\n\n  \t\t\t\tcurrentTest.assert.pushResult({\n  \t\t\t\t\tresult: false,\n  \t\t\t\t\tmessage: _message,\n  \t\t\t\t\tactual: promise\n  \t\t\t\t});\n\n  \t\t\t\treturn;\n  \t\t\t}\n\n  \t\t\tvar done = this.async();\n\n  \t\t\treturn then.call(promise, function handleFulfillment() {\n  \t\t\t\tvar message = \"The promise returned by the `assert.rejects` callback in \" + \"\\\"\" + currentTest.testName + \"\\\" did not reject.\";\n\n  \t\t\t\tcurrentTest.assert.pushResult({\n  \t\t\t\t\tresult: false,\n  \t\t\t\t\tmessage: message,\n  \t\t\t\t\tactual: promise\n  \t\t\t\t});\n\n  \t\t\t\tdone();\n  \t\t\t}, function handleRejection(actual) {\n  \t\t\t\tvar expectedType = objectType(expected);\n\n  \t\t\t\t// We don't want to validate\n  \t\t\t\tif (expected === undefined) {\n  \t\t\t\t\tresult = true;\n  \t\t\t\t\texpected = actual;\n\n  \t\t\t\t\t// Expected is a regexp\n  \t\t\t\t} else if (expectedType === \"regexp\") {\n  \t\t\t\t\tresult = expected.test(errorString(actual));\n\n  \t\t\t\t\t// Expected is a constructor, maybe an Error constructor\n  \t\t\t\t} else if (expectedType === \"function\" && actual instanceof expected) {\n  \t\t\t\t\tresult = true;\n\n  \t\t\t\t\t// Expected is an Error object\n  \t\t\t\t} else if (expectedType === \"object\") {\n  \t\t\t\t\tresult = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;\n\n  \t\t\t\t\t// Expected is a validation function which returns true if validation passed\n  \t\t\t\t} else {\n  \t\t\t\t\tif (expectedType === \"function\") {\n  \t\t\t\t\t\tresult = expected.call({}, actual) === true;\n  \t\t\t\t\t\texpected = null;\n\n  \t\t\t\t\t\t// Expected is some other invalid type\n  \t\t\t\t\t} else {\n  \t\t\t\t\t\tresult = false;\n  \t\t\t\t\t\tmessage = \"invalid expected value provided to `assert.rejects` \" + \"callback in \\\"\" + currentTest.testName + \"\\\": \" + expectedType + \".\";\n  \t\t\t\t\t}\n  \t\t\t\t}\n\n  \t\t\t\tcurrentTest.assert.pushResult({\n  \t\t\t\t\tresult: result,\n  \t\t\t\t\tactual: actual,\n  \t\t\t\t\texpected: expected,\n  \t\t\t\t\tmessage: message\n  \t\t\t\t});\n\n  \t\t\t\tdone();\n  \t\t\t});\n  \t\t}\n  \t}]);\n  \treturn Assert;\n  }();\n\n  // Provide an alternative to assert.throws(), for environments that consider throws a reserved word\n  // Known to us are: Closure Compiler, Narwhal\n  // eslint-disable-next-line dot-notation\n\n\n  Assert.prototype.raises = Assert.prototype[\"throws\"];\n\n  /**\n   * Converts an error into a simple string for comparisons.\n   *\n   * @param {Error} error\n   * @return {String}\n   */\n  function errorString(error) {\n  \tvar resultErrorString = error.toString();\n\n  \tif (resultErrorString.substring(0, 7) === \"[object\") {\n  \t\tvar name = error.name ? error.name.toString() : \"Error\";\n  \t\tvar message = error.message ? error.message.toString() : \"\";\n\n  \t\tif (name && message) {\n  \t\t\treturn name + \": \" + message;\n  \t\t} else if (name) {\n  \t\t\treturn name;\n  \t\t} else if (message) {\n  \t\t\treturn message;\n  \t\t} else {\n  \t\t\treturn \"Error\";\n  \t\t}\n  \t} else {\n  \t\treturn resultErrorString;\n  \t}\n  }\n\n  /* global module, exports, define */\n  function exportQUnit(QUnit) {\n\n  \tif (defined.document) {\n\n  \t\t// QUnit may be defined when it is preconfigured but then only QUnit and QUnit.config may be defined.\n  \t\tif (window.QUnit && window.QUnit.version) {\n  \t\t\tthrow new Error(\"QUnit has already been defined.\");\n  \t\t}\n\n  \t\twindow.QUnit = QUnit;\n  \t}\n\n  \t// For nodejs\n  \tif (typeof module !== \"undefined\" && module && module.exports) {\n  \t\tmodule.exports = QUnit;\n\n  \t\t// For consistency with CommonJS environments' exports\n  \t\tmodule.exports.QUnit = QUnit;\n  \t}\n\n  \t// For CommonJS with exports, but without module.exports, like Rhino\n  \tif (typeof exports !== \"undefined\" && exports) {\n  \t\texports.QUnit = QUnit;\n  \t}\n\n  \tif (typeof define === \"function\" && define.amd) {\n  \t\tdefine(function () {\n  \t\t\treturn QUnit;\n  \t\t});\n  \t\tQUnit.config.autostart = false;\n  \t}\n\n  \t// For Web/Service Workers\n  \tif (self$1 && self$1.WorkerGlobalScope && self$1 instanceof self$1.WorkerGlobalScope) {\n  \t\tself$1.QUnit = QUnit;\n  \t}\n  }\n\n  var SuiteReport = function () {\n  \tfunction SuiteReport(name, parentSuite) {\n  \t\tclassCallCheck(this, SuiteReport);\n\n  \t\tthis.name = name;\n  \t\tthis.fullName = parentSuite ? parentSuite.fullName.concat(name) : [];\n\n  \t\tthis.tests = [];\n  \t\tthis.childSuites = [];\n\n  \t\tif (parentSuite) {\n  \t\t\tparentSuite.pushChildSuite(this);\n  \t\t}\n  \t}\n\n  \tcreateClass(SuiteReport, [{\n  \t\tkey: \"start\",\n  \t\tvalue: function start(recordTime) {\n  \t\t\tif (recordTime) {\n  \t\t\t\tthis._startTime = Date.now();\n  \t\t\t}\n\n  \t\t\treturn {\n  \t\t\t\tname: this.name,\n  \t\t\t\tfullName: this.fullName.slice(),\n  \t\t\t\ttests: this.tests.map(function (test) {\n  \t\t\t\t\treturn test.start();\n  \t\t\t\t}),\n  \t\t\t\tchildSuites: this.childSuites.map(function (suite) {\n  \t\t\t\t\treturn suite.start();\n  \t\t\t\t}),\n  \t\t\t\ttestCounts: {\n  \t\t\t\t\ttotal: this.getTestCounts().total\n  \t\t\t\t}\n  \t\t\t};\n  \t\t}\n  \t}, {\n  \t\tkey: \"end\",\n  \t\tvalue: function end(recordTime) {\n  \t\t\tif (recordTime) {\n  \t\t\t\tthis._endTime = Date.now();\n  \t\t\t}\n\n  \t\t\treturn {\n  \t\t\t\tname: this.name,\n  \t\t\t\tfullName: this.fullName.slice(),\n  \t\t\t\ttests: this.tests.map(function (test) {\n  \t\t\t\t\treturn test.end();\n  \t\t\t\t}),\n  \t\t\t\tchildSuites: this.childSuites.map(function (suite) {\n  \t\t\t\t\treturn suite.end();\n  \t\t\t\t}),\n  \t\t\t\ttestCounts: this.getTestCounts(),\n  \t\t\t\truntime: this.getRuntime(),\n  \t\t\t\tstatus: this.getStatus()\n  \t\t\t};\n  \t\t}\n  \t}, {\n  \t\tkey: \"pushChildSuite\",\n  \t\tvalue: function pushChildSuite(suite) {\n  \t\t\tthis.childSuites.push(suite);\n  \t\t}\n  \t}, {\n  \t\tkey: \"pushTest\",\n  \t\tvalue: function pushTest(test) {\n  \t\t\tthis.tests.push(test);\n  \t\t}\n  \t}, {\n  \t\tkey: \"getRuntime\",\n  \t\tvalue: function getRuntime() {\n  \t\t\treturn this._endTime - this._startTime;\n  \t\t}\n  \t}, {\n  \t\tkey: \"getTestCounts\",\n  \t\tvalue: function getTestCounts() {\n  \t\t\tvar counts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { passed: 0, failed: 0, skipped: 0, todo: 0, total: 0 };\n\n  \t\t\tcounts = this.tests.reduce(function (counts, test) {\n  \t\t\t\tif (test.valid) {\n  \t\t\t\t\tcounts[test.getStatus()]++;\n  \t\t\t\t\tcounts.total++;\n  \t\t\t\t}\n\n  \t\t\t\treturn counts;\n  \t\t\t}, counts);\n\n  \t\t\treturn this.childSuites.reduce(function (counts, suite) {\n  \t\t\t\treturn suite.getTestCounts(counts);\n  \t\t\t}, counts);\n  \t\t}\n  \t}, {\n  \t\tkey: \"getStatus\",\n  \t\tvalue: function getStatus() {\n  \t\t\tvar _getTestCounts = this.getTestCounts(),\n  \t\t\t    total = _getTestCounts.total,\n  \t\t\t    failed = _getTestCounts.failed,\n  \t\t\t    skipped = _getTestCounts.skipped,\n  \t\t\t    todo = _getTestCounts.todo;\n\n  \t\t\tif (failed) {\n  \t\t\t\treturn \"failed\";\n  \t\t\t} else {\n  \t\t\t\tif (skipped === total) {\n  \t\t\t\t\treturn \"skipped\";\n  \t\t\t\t} else if (todo === total) {\n  \t\t\t\t\treturn \"todo\";\n  \t\t\t\t} else {\n  \t\t\t\t\treturn \"passed\";\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n  \t}]);\n  \treturn SuiteReport;\n  }();\n\n  // Handle an unhandled exception. By convention, returns true if further\n  // error handling should be suppressed and false otherwise.\n  // In this case, we will only suppress further error handling if the\n  // \"ignoreGlobalErrors\" configuration option is enabled.\n  function onError(error) {\n  \tfor (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n  \t\targs[_key - 1] = arguments[_key];\n  \t}\n\n  \tif (config.current) {\n  \t\tif (config.current.ignoreGlobalErrors) {\n  \t\t\treturn true;\n  \t\t}\n  \t\tpushFailure.apply(undefined, [error.message, error.fileName + \":\" + error.lineNumber].concat(args));\n  \t} else {\n  \t\ttest(\"global failure\", extend(function () {\n  \t\t\tpushFailure.apply(undefined, [error.message, error.fileName + \":\" + error.lineNumber].concat(args));\n  \t\t}, { validTest: true }));\n  \t}\n\n  \treturn false;\n  }\n\n  // Handle an unhandled rejection\n  function onUnhandledRejection(reason) {\n  \tvar resultInfo = {\n  \t\tresult: false,\n  \t\tmessage: reason.message || \"error\",\n  \t\tactual: reason,\n  \t\tsource: reason.stack || sourceFromStacktrace(3)\n  \t};\n\n  \tvar currentTest = config.current;\n  \tif (currentTest) {\n  \t\tcurrentTest.assert.pushResult(resultInfo);\n  \t} else {\n  \t\ttest(\"global failure\", extend(function (assert) {\n  \t\t\tassert.pushResult(resultInfo);\n  \t\t}, { validTest: true }));\n  \t}\n  }\n\n  var focused = false;\n  var QUnit = {};\n  var globalSuite = new SuiteReport();\n\n  // The initial \"currentModule\" represents the global (or top-level) module that\n  // is not explicitly defined by the user, therefore we add the \"globalSuite\" to\n  // it since each module has a suiteReport associated with it.\n  config.currentModule.suiteReport = globalSuite;\n\n  var moduleStack = [];\n  var globalStartCalled = false;\n  var runStarted = false;\n\n  // Figure out if we're running the tests from a server or not\n  QUnit.isLocal = !(defined.document && window.location.protocol !== \"file:\");\n\n  // Expose the current QUnit version\n  QUnit.version = \"2.6.1-pre\";\n\n  function createModule(name, testEnvironment, modifiers) {\n  \tvar parentModule = moduleStack.length ? moduleStack.slice(-1)[0] : null;\n  \tvar moduleName = parentModule !== null ? [parentModule.name, name].join(\" > \") : name;\n  \tvar parentSuite = parentModule ? parentModule.suiteReport : globalSuite;\n\n  \tvar skip$$1 = parentModule !== null && parentModule.skip || modifiers.skip;\n  \tvar todo$$1 = parentModule !== null && parentModule.todo || modifiers.todo;\n\n  \tvar module = {\n  \t\tname: moduleName,\n  \t\tparentModule: parentModule,\n  \t\ttests: [],\n  \t\tmoduleId: generateHash(moduleName),\n  \t\ttestsRun: 0,\n  \t\tunskippedTestsRun: 0,\n  \t\tchildModules: [],\n  \t\tsuiteReport: new SuiteReport(name, parentSuite),\n\n  \t\t// Pass along `skip` and `todo` properties from parent module, in case\n  \t\t// there is one, to childs. And use own otherwise.\n  \t\t// This property will be used to mark own tests and tests of child suites\n  \t\t// as either `skipped` or `todo`.\n  \t\tskip: skip$$1,\n  \t\ttodo: skip$$1 ? false : todo$$1\n  \t};\n\n  \tvar env = {};\n  \tif (parentModule) {\n  \t\tparentModule.childModules.push(module);\n  \t\textend(env, parentModule.testEnvironment);\n  \t}\n  \textend(env, testEnvironment);\n  \tmodule.testEnvironment = env;\n\n  \tconfig.modules.push(module);\n  \treturn module;\n  }\n\n  function processModule(name, options, executeNow) {\n  \tvar modifiers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n  \tvar module = createModule(name, options, modifiers);\n\n  \t// Move any hooks to a 'hooks' object\n  \tvar testEnvironment = module.testEnvironment;\n  \tvar hooks = module.hooks = {};\n\n  \tsetHookFromEnvironment(hooks, testEnvironment, \"before\");\n  \tsetHookFromEnvironment(hooks, testEnvironment, \"beforeEach\");\n  \tsetHookFromEnvironment(hooks, testEnvironment, \"afterEach\");\n  \tsetHookFromEnvironment(hooks, testEnvironment, \"after\");\n\n  \tfunction setHookFromEnvironment(hooks, environment, name) {\n  \t\tvar potentialHook = environment[name];\n  \t\thooks[name] = typeof potentialHook === \"function\" ? [potentialHook] : [];\n  \t\tdelete environment[name];\n  \t}\n\n  \tvar moduleFns = {\n  \t\tbefore: setHookFunction(module, \"before\"),\n  \t\tbeforeEach: setHookFunction(module, \"beforeEach\"),\n  \t\tafterEach: setHookFunction(module, \"afterEach\"),\n  \t\tafter: setHookFunction(module, \"after\")\n  \t};\n\n  \tvar currentModule = config.currentModule;\n  \tif (objectType(executeNow) === \"function\") {\n  \t\tmoduleStack.push(module);\n  \t\tconfig.currentModule = module;\n  \t\texecuteNow.call(module.testEnvironment, moduleFns);\n  \t\tmoduleStack.pop();\n  \t\tmodule = module.parentModule || currentModule;\n  \t}\n\n  \tconfig.currentModule = module;\n  }\n\n  // TODO: extract this to a new file alongside its related functions\n  function module$1(name, options, executeNow) {\n  \tif (focused) {\n  \t\treturn;\n  \t}\n\n  \tif (arguments.length === 2) {\n  \t\tif (objectType(options) === \"function\") {\n  \t\t\texecuteNow = options;\n  \t\t\toptions = undefined;\n  \t\t}\n  \t}\n\n  \tprocessModule(name, options, executeNow);\n  }\n\n  module$1.only = function () {\n  \tif (focused) {\n  \t\treturn;\n  \t}\n\n  \tconfig.modules.length = 0;\n  \tconfig.queue.length = 0;\n\n  \tmodule$1.apply(undefined, arguments);\n\n  \tfocused = true;\n  };\n\n  module$1.skip = function (name, options, executeNow) {\n  \tif (focused) {\n  \t\treturn;\n  \t}\n\n  \tif (arguments.length === 2) {\n  \t\tif (objectType(options) === \"function\") {\n  \t\t\texecuteNow = options;\n  \t\t\toptions = undefined;\n  \t\t}\n  \t}\n\n  \tprocessModule(name, options, executeNow, { skip: true });\n  };\n\n  module$1.todo = function (name, options, executeNow) {\n  \tif (focused) {\n  \t\treturn;\n  \t}\n\n  \tif (arguments.length === 2) {\n  \t\tif (objectType(options) === \"function\") {\n  \t\t\texecuteNow = options;\n  \t\t\toptions = undefined;\n  \t\t}\n  \t}\n\n  \tprocessModule(name, options, executeNow, { todo: true });\n  };\n\n  extend(QUnit, {\n  \ton: on,\n\n  \tmodule: module$1,\n\n  \ttest: test,\n\n  \ttodo: todo,\n\n  \tskip: skip,\n\n  \tonly: only,\n\n  \tstart: function start(count) {\n  \t\tvar globalStartAlreadyCalled = globalStartCalled;\n\n  \t\tif (!config.current) {\n  \t\t\tglobalStartCalled = true;\n\n  \t\t\tif (runStarted) {\n  \t\t\t\tthrow new Error(\"Called start() while test already started running\");\n  \t\t\t} else if (globalStartAlreadyCalled || count > 1) {\n  \t\t\t\tthrow new Error(\"Called start() outside of a test context too many times\");\n  \t\t\t} else if (config.autostart) {\n  \t\t\t\tthrow new Error(\"Called start() outside of a test context when \" + \"QUnit.config.autostart was true\");\n  \t\t\t} else if (!config.pageLoaded) {\n\n  \t\t\t\t// The page isn't completely loaded yet, so we set autostart and then\n  \t\t\t\t// load if we're in Node or wait for the browser's load event.\n  \t\t\t\tconfig.autostart = true;\n\n  \t\t\t\t// Starts from Node even if .load was not previously called. We still return\n  \t\t\t\t// early otherwise we'll wind up \"beginning\" twice.\n  \t\t\t\tif (!defined.document) {\n  \t\t\t\t\tQUnit.load();\n  \t\t\t\t}\n\n  \t\t\t\treturn;\n  \t\t\t}\n  \t\t} else {\n  \t\t\tthrow new Error(\"QUnit.start cannot be called inside a test context.\");\n  \t\t}\n\n  \t\tscheduleBegin();\n  \t},\n\n  \tconfig: config,\n\n  \tis: is,\n\n  \tobjectType: objectType,\n\n  \textend: extend,\n\n  \tload: function load() {\n  \t\tconfig.pageLoaded = true;\n\n  \t\t// Initialize the configuration options\n  \t\textend(config, {\n  \t\t\tstats: { all: 0, bad: 0 },\n  \t\t\tstarted: 0,\n  \t\t\tupdateRate: 1000,\n  \t\t\tautostart: true,\n  \t\t\tfilter: \"\"\n  \t\t}, true);\n\n  \t\tif (!runStarted) {\n  \t\t\tconfig.blocking = false;\n\n  \t\t\tif (config.autostart) {\n  \t\t\t\tscheduleBegin();\n  \t\t\t}\n  \t\t}\n  \t},\n\n  \tstack: function stack(offset) {\n  \t\toffset = (offset || 0) + 2;\n  \t\treturn sourceFromStacktrace(offset);\n  \t},\n\n  \tonError: onError,\n\n  \tonUnhandledRejection: onUnhandledRejection\n  });\n\n  QUnit.pushFailure = pushFailure;\n  QUnit.assert = Assert.prototype;\n  QUnit.equiv = equiv;\n  QUnit.dump = dump;\n\n  registerLoggingCallbacks(QUnit);\n\n  function scheduleBegin() {\n\n  \trunStarted = true;\n\n  \t// Add a slight delay to allow definition of more modules and tests.\n  \tif (defined.setTimeout) {\n  \t\tsetTimeout(function () {\n  \t\t\tbegin();\n  \t\t});\n  \t} else {\n  \t\tbegin();\n  \t}\n  }\n\n  function begin() {\n  \tvar i,\n  \t    l,\n  \t    modulesLog = [];\n\n  \t// If the test run hasn't officially begun yet\n  \tif (!config.started) {\n\n  \t\t// Record the time of the test run's beginning\n  \t\tconfig.started = now();\n\n  \t\t// Delete the loose unnamed module if unused.\n  \t\tif (config.modules[0].name === \"\" && config.modules[0].tests.length === 0) {\n  \t\t\tconfig.modules.shift();\n  \t\t}\n\n  \t\t// Avoid unnecessary information by not logging modules' test environments\n  \t\tfor (i = 0, l = config.modules.length; i < l; i++) {\n  \t\t\tmodulesLog.push({\n  \t\t\t\tname: config.modules[i].name,\n  \t\t\t\ttests: config.modules[i].tests\n  \t\t\t});\n  \t\t}\n\n  \t\t// The test run is officially beginning now\n  \t\temit(\"runStart\", globalSuite.start(true));\n  \t\trunLoggingCallbacks(\"begin\", {\n  \t\t\ttotalTests: Test.count,\n  \t\t\tmodules: modulesLog\n  \t\t});\n  \t}\n\n  \tconfig.blocking = false;\n  \tProcessingQueue.advance();\n  }\n\n  function setHookFunction(module, hookName) {\n  \treturn function setHook(callback) {\n  \t\tmodule.hooks[hookName].push(callback);\n  \t};\n  }\n\n  exportQUnit(QUnit);\n\n  (function () {\n\n  \tif (typeof window === \"undefined\" || typeof document === \"undefined\") {\n  \t\treturn;\n  \t}\n\n  \tvar config = QUnit.config,\n  \t    hasOwn = Object.prototype.hasOwnProperty;\n\n  \t// Stores fixture HTML for resetting later\n  \tfunction storeFixture() {\n\n  \t\t// Avoid overwriting user-defined values\n  \t\tif (hasOwn.call(config, \"fixture\")) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\tvar fixture = document.getElementById(\"qunit-fixture\");\n  \t\tif (fixture) {\n  \t\t\tconfig.fixture = fixture.cloneNode(true);\n  \t\t}\n  \t}\n\n  \tQUnit.begin(storeFixture);\n\n  \t// Resets the fixture DOM element if available.\n  \tfunction resetFixture() {\n  \t\tif (config.fixture == null) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\tvar fixture = document.getElementById(\"qunit-fixture\");\n  \t\tvar resetFixtureType = _typeof(config.fixture);\n  \t\tif (resetFixtureType === \"string\") {\n\n  \t\t\t// support user defined values for `config.fixture`\n  \t\t\tvar newFixture = document.createElement(\"div\");\n  \t\t\tnewFixture.setAttribute(\"id\", \"qunit-fixture\");\n  \t\t\tnewFixture.innerHTML = config.fixture;\n  \t\t\tfixture.parentNode.replaceChild(newFixture, fixture);\n  \t\t} else {\n  \t\t\tvar clonedFixture = config.fixture.cloneNode(true);\n  \t\t\tfixture.parentNode.replaceChild(clonedFixture, fixture);\n  \t\t}\n  \t}\n\n  \tQUnit.testStart(resetFixture);\n  })();\n\n  (function () {\n\n  \t// Only interact with URLs via window.location\n  \tvar location = typeof window !== \"undefined\" && window.location;\n  \tif (!location) {\n  \t\treturn;\n  \t}\n\n  \tvar urlParams = getUrlParams();\n\n  \tQUnit.urlParams = urlParams;\n\n  \t// Match module/test by inclusion in an array\n  \tQUnit.config.moduleId = [].concat(urlParams.moduleId || []);\n  \tQUnit.config.testId = [].concat(urlParams.testId || []);\n\n  \t// Exact case-insensitive match of the module name\n  \tQUnit.config.module = urlParams.module;\n\n  \t// Regular expression or case-insenstive substring match against \"moduleName: testName\"\n  \tQUnit.config.filter = urlParams.filter;\n\n  \t// Test order randomization\n  \tif (urlParams.seed === true) {\n\n  \t\t// Generate a random seed if the option is specified without a value\n  \t\tQUnit.config.seed = Math.random().toString(36).slice(2);\n  \t} else if (urlParams.seed) {\n  \t\tQUnit.config.seed = urlParams.seed;\n  \t}\n\n  \t// Add URL-parameter-mapped config values with UI form rendering data\n  \tQUnit.config.urlConfig.push({\n  \t\tid: \"hidepassed\",\n  \t\tlabel: \"Hide passed tests\",\n  \t\ttooltip: \"Only show tests and assertions that fail. Stored as query-strings.\"\n  \t}, {\n  \t\tid: \"noglobals\",\n  \t\tlabel: \"Check for Globals\",\n  \t\ttooltip: \"Enabling this will test if any test introduces new properties on the \" + \"global object (`window` in Browsers). Stored as query-strings.\"\n  \t}, {\n  \t\tid: \"notrycatch\",\n  \t\tlabel: \"No try-catch\",\n  \t\ttooltip: \"Enabling this will run tests outside of a try-catch block. Makes debugging \" + \"exceptions in IE reasonable. Stored as query-strings.\"\n  \t});\n\n  \tQUnit.begin(function () {\n  \t\tvar i,\n  \t\t    option,\n  \t\t    urlConfig = QUnit.config.urlConfig;\n\n  \t\tfor (i = 0; i < urlConfig.length; i++) {\n\n  \t\t\t// Options can be either strings or objects with nonempty \"id\" properties\n  \t\t\toption = QUnit.config.urlConfig[i];\n  \t\t\tif (typeof option !== \"string\") {\n  \t\t\t\toption = option.id;\n  \t\t\t}\n\n  \t\t\tif (QUnit.config[option] === undefined) {\n  \t\t\t\tQUnit.config[option] = urlParams[option];\n  \t\t\t}\n  \t\t}\n  \t});\n\n  \tfunction getUrlParams() {\n  \t\tvar i, param, name, value;\n  \t\tvar urlParams = Object.create(null);\n  \t\tvar params = location.search.slice(1).split(\"&\");\n  \t\tvar length = params.length;\n\n  \t\tfor (i = 0; i < length; i++) {\n  \t\t\tif (params[i]) {\n  \t\t\t\tparam = params[i].split(\"=\");\n  \t\t\t\tname = decodeQueryParam(param[0]);\n\n  \t\t\t\t// Allow just a key to turn on a flag, e.g., test.html?noglobals\n  \t\t\t\tvalue = param.length === 1 || decodeQueryParam(param.slice(1).join(\"=\"));\n  \t\t\t\tif (name in urlParams) {\n  \t\t\t\t\turlParams[name] = [].concat(urlParams[name], value);\n  \t\t\t\t} else {\n  \t\t\t\t\turlParams[name] = value;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\treturn urlParams;\n  \t}\n\n  \tfunction decodeQueryParam(param) {\n  \t\treturn decodeURIComponent(param.replace(/\\+/g, \"%20\"));\n  \t}\n  })();\n\n  var stats = {\n  \tpassedTests: 0,\n  \tfailedTests: 0,\n  \tskippedTests: 0,\n  \ttodoTests: 0\n  };\n\n  // Escape text for attribute or text content.\n  function escapeText(s) {\n  \tif (!s) {\n  \t\treturn \"\";\n  \t}\n  \ts = s + \"\";\n\n  \t// Both single quotes and double quotes (for attributes)\n  \treturn s.replace(/['\"<>&]/g, function (s) {\n  \t\tswitch (s) {\n  \t\t\tcase \"'\":\n  \t\t\t\treturn \"&#039;\";\n  \t\t\tcase \"\\\"\":\n  \t\t\t\treturn \"&quot;\";\n  \t\t\tcase \"<\":\n  \t\t\t\treturn \"&lt;\";\n  \t\t\tcase \">\":\n  \t\t\t\treturn \"&gt;\";\n  \t\t\tcase \"&\":\n  \t\t\t\treturn \"&amp;\";\n  \t\t}\n  \t});\n  }\n\n  (function () {\n\n  \t// Don't load the HTML Reporter on non-browser environments\n  \tif (typeof window === \"undefined\" || !window.document) {\n  \t\treturn;\n  \t}\n\n  \tvar config = QUnit.config,\n  \t    document$$1 = window.document,\n  \t    collapseNext = false,\n  \t    hasOwn = Object.prototype.hasOwnProperty,\n  \t    unfilteredUrl = setUrl({ filter: undefined, module: undefined,\n  \t\tmoduleId: undefined, testId: undefined }),\n  \t    modulesList = [];\n\n  \tfunction addEvent(elem, type, fn) {\n  \t\telem.addEventListener(type, fn, false);\n  \t}\n\n  \tfunction removeEvent(elem, type, fn) {\n  \t\telem.removeEventListener(type, fn, false);\n  \t}\n\n  \tfunction addEvents(elems, type, fn) {\n  \t\tvar i = elems.length;\n  \t\twhile (i--) {\n  \t\t\taddEvent(elems[i], type, fn);\n  \t\t}\n  \t}\n\n  \tfunction hasClass(elem, name) {\n  \t\treturn (\" \" + elem.className + \" \").indexOf(\" \" + name + \" \") >= 0;\n  \t}\n\n  \tfunction addClass(elem, name) {\n  \t\tif (!hasClass(elem, name)) {\n  \t\t\telem.className += (elem.className ? \" \" : \"\") + name;\n  \t\t}\n  \t}\n\n  \tfunction toggleClass(elem, name, force) {\n  \t\tif (force || typeof force === \"undefined\" && !hasClass(elem, name)) {\n  \t\t\taddClass(elem, name);\n  \t\t} else {\n  \t\t\tremoveClass(elem, name);\n  \t\t}\n  \t}\n\n  \tfunction removeClass(elem, name) {\n  \t\tvar set = \" \" + elem.className + \" \";\n\n  \t\t// Class name may appear multiple times\n  \t\twhile (set.indexOf(\" \" + name + \" \") >= 0) {\n  \t\t\tset = set.replace(\" \" + name + \" \", \" \");\n  \t\t}\n\n  \t\t// Trim for prettiness\n  \t\telem.className = typeof set.trim === \"function\" ? set.trim() : set.replace(/^\\s+|\\s+$/g, \"\");\n  \t}\n\n  \tfunction id(name) {\n  \t\treturn document$$1.getElementById && document$$1.getElementById(name);\n  \t}\n\n  \tfunction abortTests() {\n  \t\tvar abortButton = id(\"qunit-abort-tests-button\");\n  \t\tif (abortButton) {\n  \t\t\tabortButton.disabled = true;\n  \t\t\tabortButton.innerHTML = \"Aborting...\";\n  \t\t}\n  \t\tQUnit.config.queue.length = 0;\n  \t\treturn false;\n  \t}\n\n  \tfunction interceptNavigation(ev) {\n  \t\tapplyUrlParams();\n\n  \t\tif (ev && ev.preventDefault) {\n  \t\t\tev.preventDefault();\n  \t\t}\n\n  \t\treturn false;\n  \t}\n\n  \tfunction getUrlConfigHtml() {\n  \t\tvar i,\n  \t\t    j,\n  \t\t    val,\n  \t\t    escaped,\n  \t\t    escapedTooltip,\n  \t\t    selection = false,\n  \t\t    urlConfig = config.urlConfig,\n  \t\t    urlConfigHtml = \"\";\n\n  \t\tfor (i = 0; i < urlConfig.length; i++) {\n\n  \t\t\t// Options can be either strings or objects with nonempty \"id\" properties\n  \t\t\tval = config.urlConfig[i];\n  \t\t\tif (typeof val === \"string\") {\n  \t\t\t\tval = {\n  \t\t\t\t\tid: val,\n  \t\t\t\t\tlabel: val\n  \t\t\t\t};\n  \t\t\t}\n\n  \t\t\tescaped = escapeText(val.id);\n  \t\t\tescapedTooltip = escapeText(val.tooltip);\n\n  \t\t\tif (!val.value || typeof val.value === \"string\") {\n  \t\t\t\turlConfigHtml += \"<label for='qunit-urlconfig-\" + escaped + \"' title='\" + escapedTooltip + \"'><input id='qunit-urlconfig-\" + escaped + \"' name='\" + escaped + \"' type='checkbox'\" + (val.value ? \" value='\" + escapeText(val.value) + \"'\" : \"\") + (config[val.id] ? \" checked='checked'\" : \"\") + \" title='\" + escapedTooltip + \"' />\" + escapeText(val.label) + \"</label>\";\n  \t\t\t} else {\n  \t\t\t\turlConfigHtml += \"<label for='qunit-urlconfig-\" + escaped + \"' title='\" + escapedTooltip + \"'>\" + val.label + \": </label><select id='qunit-urlconfig-\" + escaped + \"' name='\" + escaped + \"' title='\" + escapedTooltip + \"'><option></option>\";\n\n  \t\t\t\tif (QUnit.is(\"array\", val.value)) {\n  \t\t\t\t\tfor (j = 0; j < val.value.length; j++) {\n  \t\t\t\t\t\tescaped = escapeText(val.value[j]);\n  \t\t\t\t\t\turlConfigHtml += \"<option value='\" + escaped + \"'\" + (config[val.id] === val.value[j] ? (selection = true) && \" selected='selected'\" : \"\") + \">\" + escaped + \"</option>\";\n  \t\t\t\t\t}\n  \t\t\t\t} else {\n  \t\t\t\t\tfor (j in val.value) {\n  \t\t\t\t\t\tif (hasOwn.call(val.value, j)) {\n  \t\t\t\t\t\t\turlConfigHtml += \"<option value='\" + escapeText(j) + \"'\" + (config[val.id] === j ? (selection = true) && \" selected='selected'\" : \"\") + \">\" + escapeText(val.value[j]) + \"</option>\";\n  \t\t\t\t\t\t}\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t\tif (config[val.id] && !selection) {\n  \t\t\t\t\tescaped = escapeText(config[val.id]);\n  \t\t\t\t\turlConfigHtml += \"<option value='\" + escaped + \"' selected='selected' disabled='disabled'>\" + escaped + \"</option>\";\n  \t\t\t\t}\n  \t\t\t\turlConfigHtml += \"</select>\";\n  \t\t\t}\n  \t\t}\n\n  \t\treturn urlConfigHtml;\n  \t}\n\n  \t// Handle \"click\" events on toolbar checkboxes and \"change\" for select menus.\n  \t// Updates the URL with the new state of `config.urlConfig` values.\n  \tfunction toolbarChanged() {\n  \t\tvar updatedUrl,\n  \t\t    value,\n  \t\t    tests,\n  \t\t    field = this,\n  \t\t    params = {};\n\n  \t\t// Detect if field is a select menu or a checkbox\n  \t\tif (\"selectedIndex\" in field) {\n  \t\t\tvalue = field.options[field.selectedIndex].value || undefined;\n  \t\t} else {\n  \t\t\tvalue = field.checked ? field.defaultValue || true : undefined;\n  \t\t}\n\n  \t\tparams[field.name] = value;\n  \t\tupdatedUrl = setUrl(params);\n\n  \t\t// Check if we can apply the change without a page refresh\n  \t\tif (\"hidepassed\" === field.name && \"replaceState\" in window.history) {\n  \t\t\tQUnit.urlParams[field.name] = value;\n  \t\t\tconfig[field.name] = value || false;\n  \t\t\ttests = id(\"qunit-tests\");\n  \t\t\tif (tests) {\n  \t\t\t\ttoggleClass(tests, \"hidepass\", value || false);\n  \t\t\t}\n  \t\t\twindow.history.replaceState(null, \"\", updatedUrl);\n  \t\t} else {\n  \t\t\twindow.location = updatedUrl;\n  \t\t}\n  \t}\n\n  \tfunction setUrl(params) {\n  \t\tvar key,\n  \t\t    arrValue,\n  \t\t    i,\n  \t\t    querystring = \"?\",\n  \t\t    location = window.location;\n\n  \t\tparams = QUnit.extend(QUnit.extend({}, QUnit.urlParams), params);\n\n  \t\tfor (key in params) {\n\n  \t\t\t// Skip inherited or undefined properties\n  \t\t\tif (hasOwn.call(params, key) && params[key] !== undefined) {\n\n  \t\t\t\t// Output a parameter for each value of this key\n  \t\t\t\t// (but usually just one)\n  \t\t\t\tarrValue = [].concat(params[key]);\n  \t\t\t\tfor (i = 0; i < arrValue.length; i++) {\n  \t\t\t\t\tquerystring += encodeURIComponent(key);\n  \t\t\t\t\tif (arrValue[i] !== true) {\n  \t\t\t\t\t\tquerystring += \"=\" + encodeURIComponent(arrValue[i]);\n  \t\t\t\t\t}\n  \t\t\t\t\tquerystring += \"&\";\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n  \t\treturn location.protocol + \"//\" + location.host + location.pathname + querystring.slice(0, -1);\n  \t}\n\n  \tfunction applyUrlParams() {\n  \t\tvar i,\n  \t\t    selectedModules = [],\n  \t\t    modulesList = id(\"qunit-modulefilter-dropdown-list\").getElementsByTagName(\"input\"),\n  \t\t    filter = id(\"qunit-filter-input\").value;\n\n  \t\tfor (i = 0; i < modulesList.length; i++) {\n  \t\t\tif (modulesList[i].checked) {\n  \t\t\t\tselectedModules.push(modulesList[i].value);\n  \t\t\t}\n  \t\t}\n\n  \t\twindow.location = setUrl({\n  \t\t\tfilter: filter === \"\" ? undefined : filter,\n  \t\t\tmoduleId: selectedModules.length === 0 ? undefined : selectedModules,\n\n  \t\t\t// Remove module and testId filter\n  \t\t\tmodule: undefined,\n  \t\t\ttestId: undefined\n  \t\t});\n  \t}\n\n  \tfunction toolbarUrlConfigContainer() {\n  \t\tvar urlConfigContainer = document$$1.createElement(\"span\");\n\n  \t\turlConfigContainer.innerHTML = getUrlConfigHtml();\n  \t\taddClass(urlConfigContainer, \"qunit-url-config\");\n\n  \t\taddEvents(urlConfigContainer.getElementsByTagName(\"input\"), \"change\", toolbarChanged);\n  \t\taddEvents(urlConfigContainer.getElementsByTagName(\"select\"), \"change\", toolbarChanged);\n\n  \t\treturn urlConfigContainer;\n  \t}\n\n  \tfunction abortTestsButton() {\n  \t\tvar button = document$$1.createElement(\"button\");\n  \t\tbutton.id = \"qunit-abort-tests-button\";\n  \t\tbutton.innerHTML = \"Abort\";\n  \t\taddEvent(button, \"click\", abortTests);\n  \t\treturn button;\n  \t}\n\n  \tfunction toolbarLooseFilter() {\n  \t\tvar filter = document$$1.createElement(\"form\"),\n  \t\t    label = document$$1.createElement(\"label\"),\n  \t\t    input = document$$1.createElement(\"input\"),\n  \t\t    button = document$$1.createElement(\"button\");\n\n  \t\taddClass(filter, \"qunit-filter\");\n\n  \t\tlabel.innerHTML = \"Filter: \";\n\n  \t\tinput.type = \"text\";\n  \t\tinput.value = config.filter || \"\";\n  \t\tinput.name = \"filter\";\n  \t\tinput.id = \"qunit-filter-input\";\n\n  \t\tbutton.innerHTML = \"Go\";\n\n  \t\tlabel.appendChild(input);\n\n  \t\tfilter.appendChild(label);\n  \t\tfilter.appendChild(document$$1.createTextNode(\" \"));\n  \t\tfilter.appendChild(button);\n  \t\taddEvent(filter, \"submit\", interceptNavigation);\n\n  \t\treturn filter;\n  \t}\n\n  \tfunction moduleListHtml() {\n  \t\tvar i,\n  \t\t    checked,\n  \t\t    html = \"\";\n\n  \t\tfor (i = 0; i < config.modules.length; i++) {\n  \t\t\tif (config.modules[i].name !== \"\") {\n  \t\t\t\tchecked = config.moduleId.indexOf(config.modules[i].moduleId) > -1;\n  \t\t\t\thtml += \"<li><label class='clickable\" + (checked ? \" checked\" : \"\") + \"'><input type='checkbox' \" + \"value='\" + config.modules[i].moduleId + \"'\" + (checked ? \" checked='checked'\" : \"\") + \" />\" + escapeText(config.modules[i].name) + \"</label></li>\";\n  \t\t\t}\n  \t\t}\n\n  \t\treturn html;\n  \t}\n\n  \tfunction toolbarModuleFilter() {\n  \t\tvar allCheckbox,\n  \t\t    commit,\n  \t\t    reset,\n  \t\t    moduleFilter = document$$1.createElement(\"form\"),\n  \t\t    label = document$$1.createElement(\"label\"),\n  \t\t    moduleSearch = document$$1.createElement(\"input\"),\n  \t\t    dropDown = document$$1.createElement(\"div\"),\n  \t\t    actions = document$$1.createElement(\"span\"),\n  \t\t    dropDownList = document$$1.createElement(\"ul\"),\n  \t\t    dirty = false;\n\n  \t\tmoduleSearch.id = \"qunit-modulefilter-search\";\n  \t\taddEvent(moduleSearch, \"input\", searchInput);\n  \t\taddEvent(moduleSearch, \"input\", searchFocus);\n  \t\taddEvent(moduleSearch, \"focus\", searchFocus);\n  \t\taddEvent(moduleSearch, \"click\", searchFocus);\n\n  \t\tlabel.id = \"qunit-modulefilter-search-container\";\n  \t\tlabel.innerHTML = \"Module: \";\n  \t\tlabel.appendChild(moduleSearch);\n\n  \t\tactions.id = \"qunit-modulefilter-actions\";\n  \t\tactions.innerHTML = \"<button style='display:none'>Apply</button>\" + \"<button type='reset' style='display:none'>Reset</button>\" + \"<label class='clickable\" + (config.moduleId.length ? \"\" : \" checked\") + \"'><input type='checkbox'\" + (config.moduleId.length ? \"\" : \" checked='checked'\") + \">All modules</label>\";\n  \t\tallCheckbox = actions.lastChild.firstChild;\n  \t\tcommit = actions.firstChild;\n  \t\treset = commit.nextSibling;\n  \t\taddEvent(commit, \"click\", applyUrlParams);\n\n  \t\tdropDownList.id = \"qunit-modulefilter-dropdown-list\";\n  \t\tdropDownList.innerHTML = moduleListHtml();\n\n  \t\tdropDown.id = \"qunit-modulefilter-dropdown\";\n  \t\tdropDown.style.display = \"none\";\n  \t\tdropDown.appendChild(actions);\n  \t\tdropDown.appendChild(dropDownList);\n  \t\taddEvent(dropDown, \"change\", selectionChange);\n  \t\tselectionChange();\n\n  \t\tmoduleFilter.id = \"qunit-modulefilter\";\n  \t\tmoduleFilter.appendChild(label);\n  \t\tmoduleFilter.appendChild(dropDown);\n  \t\taddEvent(moduleFilter, \"submit\", interceptNavigation);\n  \t\taddEvent(moduleFilter, \"reset\", function () {\n\n  \t\t\t// Let the reset happen, then update styles\n  \t\t\twindow.setTimeout(selectionChange);\n  \t\t});\n\n  \t\t// Enables show/hide for the dropdown\n  \t\tfunction searchFocus() {\n  \t\t\tif (dropDown.style.display !== \"none\") {\n  \t\t\t\treturn;\n  \t\t\t}\n\n  \t\t\tdropDown.style.display = \"block\";\n  \t\t\taddEvent(document$$1, \"click\", hideHandler);\n  \t\t\taddEvent(document$$1, \"keydown\", hideHandler);\n\n  \t\t\t// Hide on Escape keydown or outside-container click\n  \t\t\tfunction hideHandler(e) {\n  \t\t\t\tvar inContainer = moduleFilter.contains(e.target);\n\n  \t\t\t\tif (e.keyCode === 27 || !inContainer) {\n  \t\t\t\t\tif (e.keyCode === 27 && inContainer) {\n  \t\t\t\t\t\tmoduleSearch.focus();\n  \t\t\t\t\t}\n  \t\t\t\t\tdropDown.style.display = \"none\";\n  \t\t\t\t\tremoveEvent(document$$1, \"click\", hideHandler);\n  \t\t\t\t\tremoveEvent(document$$1, \"keydown\", hideHandler);\n  \t\t\t\t\tmoduleSearch.value = \"\";\n  \t\t\t\t\tsearchInput();\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\t// Processes module search box input\n  \t\tfunction searchInput() {\n  \t\t\tvar i,\n  \t\t\t    item,\n  \t\t\t    searchText = moduleSearch.value.toLowerCase(),\n  \t\t\t    listItems = dropDownList.children;\n\n  \t\t\tfor (i = 0; i < listItems.length; i++) {\n  \t\t\t\titem = listItems[i];\n  \t\t\t\tif (!searchText || item.textContent.toLowerCase().indexOf(searchText) > -1) {\n  \t\t\t\t\titem.style.display = \"\";\n  \t\t\t\t} else {\n  \t\t\t\t\titem.style.display = \"none\";\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\t// Processes selection changes\n  \t\tfunction selectionChange(evt) {\n  \t\t\tvar i,\n  \t\t\t    item,\n  \t\t\t    checkbox = evt && evt.target || allCheckbox,\n  \t\t\t    modulesList = dropDownList.getElementsByTagName(\"input\"),\n  \t\t\t    selectedNames = [];\n\n  \t\t\ttoggleClass(checkbox.parentNode, \"checked\", checkbox.checked);\n\n  \t\t\tdirty = false;\n  \t\t\tif (checkbox.checked && checkbox !== allCheckbox) {\n  \t\t\t\tallCheckbox.checked = false;\n  \t\t\t\tremoveClass(allCheckbox.parentNode, \"checked\");\n  \t\t\t}\n  \t\t\tfor (i = 0; i < modulesList.length; i++) {\n  \t\t\t\titem = modulesList[i];\n  \t\t\t\tif (!evt) {\n  \t\t\t\t\ttoggleClass(item.parentNode, \"checked\", item.checked);\n  \t\t\t\t} else if (checkbox === allCheckbox && checkbox.checked) {\n  \t\t\t\t\titem.checked = false;\n  \t\t\t\t\tremoveClass(item.parentNode, \"checked\");\n  \t\t\t\t}\n  \t\t\t\tdirty = dirty || item.checked !== item.defaultChecked;\n  \t\t\t\tif (item.checked) {\n  \t\t\t\t\tselectedNames.push(item.parentNode.textContent);\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\tcommit.style.display = reset.style.display = dirty ? \"\" : \"none\";\n  \t\t\tmoduleSearch.placeholder = selectedNames.join(\", \") || allCheckbox.parentNode.textContent;\n  \t\t\tmoduleSearch.title = \"Type to filter list. Current selection:\\n\" + (selectedNames.join(\"\\n\") || allCheckbox.parentNode.textContent);\n  \t\t}\n\n  \t\treturn moduleFilter;\n  \t}\n\n  \tfunction appendToolbar() {\n  \t\tvar toolbar = id(\"qunit-testrunner-toolbar\");\n\n  \t\tif (toolbar) {\n  \t\t\ttoolbar.appendChild(toolbarUrlConfigContainer());\n  \t\t\ttoolbar.appendChild(toolbarModuleFilter());\n  \t\t\ttoolbar.appendChild(toolbarLooseFilter());\n  \t\t\ttoolbar.appendChild(document$$1.createElement(\"div\")).className = \"clearfix\";\n  \t\t}\n  \t}\n\n  \tfunction appendHeader() {\n  \t\tvar header = id(\"qunit-header\");\n\n  \t\tif (header) {\n  \t\t\theader.innerHTML = \"<a href='\" + escapeText(unfilteredUrl) + \"'>\" + header.innerHTML + \"</a> \";\n  \t\t}\n  \t}\n\n  \tfunction appendBanner() {\n  \t\tvar banner = id(\"qunit-banner\");\n\n  \t\tif (banner) {\n  \t\t\tbanner.className = \"\";\n  \t\t}\n  \t}\n\n  \tfunction appendTestResults() {\n  \t\tvar tests = id(\"qunit-tests\"),\n  \t\t    result = id(\"qunit-testresult\"),\n  \t\t    controls;\n\n  \t\tif (result) {\n  \t\t\tresult.parentNode.removeChild(result);\n  \t\t}\n\n  \t\tif (tests) {\n  \t\t\ttests.innerHTML = \"\";\n  \t\t\tresult = document$$1.createElement(\"p\");\n  \t\t\tresult.id = \"qunit-testresult\";\n  \t\t\tresult.className = \"result\";\n  \t\t\ttests.parentNode.insertBefore(result, tests);\n  \t\t\tresult.innerHTML = \"<div id=\\\"qunit-testresult-display\\\">Running...<br />&#160;</div>\" + \"<div id=\\\"qunit-testresult-controls\\\"></div>\" + \"<div class=\\\"clearfix\\\"></div>\";\n  \t\t\tcontrols = id(\"qunit-testresult-controls\");\n  \t\t}\n\n  \t\tif (controls) {\n  \t\t\tcontrols.appendChild(abortTestsButton());\n  \t\t}\n  \t}\n\n  \tfunction appendFilteredTest() {\n  \t\tvar testId = QUnit.config.testId;\n  \t\tif (!testId || testId.length <= 0) {\n  \t\t\treturn \"\";\n  \t\t}\n  \t\treturn \"<div id='qunit-filteredTest'>Rerunning selected tests: \" + escapeText(testId.join(\", \")) + \" <a id='qunit-clearFilter' href='\" + escapeText(unfilteredUrl) + \"'>Run all tests</a></div>\";\n  \t}\n\n  \tfunction appendUserAgent() {\n  \t\tvar userAgent = id(\"qunit-userAgent\");\n\n  \t\tif (userAgent) {\n  \t\t\tuserAgent.innerHTML = \"\";\n  \t\t\tuserAgent.appendChild(document$$1.createTextNode(\"QUnit \" + QUnit.version + \"; \" + navigator.userAgent));\n  \t\t}\n  \t}\n\n  \tfunction appendInterface() {\n  \t\tvar qunit = id(\"qunit\");\n\n  \t\tif (qunit) {\n  \t\t\tqunit.innerHTML = \"<h1 id='qunit-header'>\" + escapeText(document$$1.title) + \"</h1>\" + \"<h2 id='qunit-banner'></h2>\" + \"<div id='qunit-testrunner-toolbar'></div>\" + appendFilteredTest() + \"<h2 id='qunit-userAgent'></h2>\" + \"<ol id='qunit-tests'></ol>\";\n  \t\t}\n\n  \t\tappendHeader();\n  \t\tappendBanner();\n  \t\tappendTestResults();\n  \t\tappendUserAgent();\n  \t\tappendToolbar();\n  \t}\n\n  \tfunction appendTestsList(modules) {\n  \t\tvar i, l, x, z, test, moduleObj;\n\n  \t\tfor (i = 0, l = modules.length; i < l; i++) {\n  \t\t\tmoduleObj = modules[i];\n\n  \t\t\tfor (x = 0, z = moduleObj.tests.length; x < z; x++) {\n  \t\t\t\ttest = moduleObj.tests[x];\n\n  \t\t\t\tappendTest(test.name, test.testId, moduleObj.name);\n  \t\t\t}\n  \t\t}\n  \t}\n\n  \tfunction appendTest(name, testId, moduleName) {\n  \t\tvar title,\n  \t\t    rerunTrigger,\n  \t\t    testBlock,\n  \t\t    assertList,\n  \t\t    tests = id(\"qunit-tests\");\n\n  \t\tif (!tests) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\ttitle = document$$1.createElement(\"strong\");\n  \t\ttitle.innerHTML = getNameHtml(name, moduleName);\n\n  \t\trerunTrigger = document$$1.createElement(\"a\");\n  \t\trerunTrigger.innerHTML = \"Rerun\";\n  \t\trerunTrigger.href = setUrl({ testId: testId });\n\n  \t\ttestBlock = document$$1.createElement(\"li\");\n  \t\ttestBlock.appendChild(title);\n  \t\ttestBlock.appendChild(rerunTrigger);\n  \t\ttestBlock.id = \"qunit-test-output-\" + testId;\n\n  \t\tassertList = document$$1.createElement(\"ol\");\n  \t\tassertList.className = \"qunit-assert-list\";\n\n  \t\ttestBlock.appendChild(assertList);\n\n  \t\ttests.appendChild(testBlock);\n  \t}\n\n  \t// HTML Reporter initialization and load\n  \tQUnit.begin(function (details) {\n  \t\tvar i, moduleObj, tests;\n\n  \t\t// Sort modules by name for the picker\n  \t\tfor (i = 0; i < details.modules.length; i++) {\n  \t\t\tmoduleObj = details.modules[i];\n  \t\t\tif (moduleObj.name) {\n  \t\t\t\tmodulesList.push(moduleObj.name);\n  \t\t\t}\n  \t\t}\n  \t\tmodulesList.sort(function (a, b) {\n  \t\t\treturn a.localeCompare(b);\n  \t\t});\n\n  \t\t// Initialize QUnit elements\n  \t\tappendInterface();\n  \t\tappendTestsList(details.modules);\n  \t\ttests = id(\"qunit-tests\");\n  \t\tif (tests && config.hidepassed) {\n  \t\t\taddClass(tests, \"hidepass\");\n  \t\t}\n  \t});\n\n  \tQUnit.done(function (details) {\n  \t\tvar banner = id(\"qunit-banner\"),\n  \t\t    tests = id(\"qunit-tests\"),\n  \t\t    abortButton = id(\"qunit-abort-tests-button\"),\n  \t\t    totalTests = stats.passedTests + stats.skippedTests + stats.todoTests + stats.failedTests,\n  \t\t    html = [totalTests, \" tests completed in \", details.runtime, \" milliseconds, with \", stats.failedTests, \" failed, \", stats.skippedTests, \" skipped, and \", stats.todoTests, \" todo.<br />\", \"<span class='passed'>\", details.passed, \"</span> assertions of <span class='total'>\", details.total, \"</span> passed, <span class='failed'>\", details.failed, \"</span> failed.\"].join(\"\"),\n  \t\t    test,\n  \t\t    assertLi,\n  \t\t    assertList;\n\n  \t\t// Update remaing tests to aborted\n  \t\tif (abortButton && abortButton.disabled) {\n  \t\t\thtml = \"Tests aborted after \" + details.runtime + \" milliseconds.\";\n\n  \t\t\tfor (var i = 0; i < tests.children.length; i++) {\n  \t\t\t\ttest = tests.children[i];\n  \t\t\t\tif (test.className === \"\" || test.className === \"running\") {\n  \t\t\t\t\ttest.className = \"aborted\";\n  \t\t\t\t\tassertList = test.getElementsByTagName(\"ol\")[0];\n  \t\t\t\t\tassertLi = document$$1.createElement(\"li\");\n  \t\t\t\t\tassertLi.className = \"fail\";\n  \t\t\t\t\tassertLi.innerHTML = \"Test aborted.\";\n  \t\t\t\t\tassertList.appendChild(assertLi);\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\tif (banner && (!abortButton || abortButton.disabled === false)) {\n  \t\t\tbanner.className = stats.failedTests ? \"qunit-fail\" : \"qunit-pass\";\n  \t\t}\n\n  \t\tif (abortButton) {\n  \t\t\tabortButton.parentNode.removeChild(abortButton);\n  \t\t}\n\n  \t\tif (tests) {\n  \t\t\tid(\"qunit-testresult-display\").innerHTML = html;\n  \t\t}\n\n  \t\tif (config.altertitle && document$$1.title) {\n\n  \t\t\t// Show ✖ for good, ✔ for bad suite result in title\n  \t\t\t// use escape sequences in case file gets loaded with non-utf-8\n  \t\t\t// charset\n  \t\t\tdocument$$1.title = [stats.failedTests ? \"\\u2716\" : \"\\u2714\", document$$1.title.replace(/^[\\u2714\\u2716] /i, \"\")].join(\" \");\n  \t\t}\n\n  \t\t// Scroll back to top to show results\n  \t\tif (config.scrolltop && window.scrollTo) {\n  \t\t\twindow.scrollTo(0, 0);\n  \t\t}\n  \t});\n\n  \tfunction getNameHtml(name, module) {\n  \t\tvar nameHtml = \"\";\n\n  \t\tif (module) {\n  \t\t\tnameHtml = \"<span class='module-name'>\" + escapeText(module) + \"</span>: \";\n  \t\t}\n\n  \t\tnameHtml += \"<span class='test-name'>\" + escapeText(name) + \"</span>\";\n\n  \t\treturn nameHtml;\n  \t}\n\n  \tQUnit.testStart(function (details) {\n  \t\tvar running, testBlock, bad;\n\n  \t\ttestBlock = id(\"qunit-test-output-\" + details.testId);\n  \t\tif (testBlock) {\n  \t\t\ttestBlock.className = \"running\";\n  \t\t} else {\n\n  \t\t\t// Report later registered tests\n  \t\t\tappendTest(details.name, details.testId, details.module);\n  \t\t}\n\n  \t\trunning = id(\"qunit-testresult-display\");\n  \t\tif (running) {\n  \t\t\tbad = QUnit.config.reorder && details.previousFailure;\n\n  \t\t\trunning.innerHTML = [bad ? \"Rerunning previously failed test: <br />\" : \"Running: <br />\", getNameHtml(details.name, details.module)].join(\"\");\n  \t\t}\n  \t});\n\n  \tfunction stripHtml(string) {\n\n  \t\t// Strip tags, html entity and whitespaces\n  \t\treturn string.replace(/<\\/?[^>]+(>|$)/g, \"\").replace(/\\&quot;/g, \"\").replace(/\\s+/g, \"\");\n  \t}\n\n  \tQUnit.log(function (details) {\n  \t\tvar assertList,\n  \t\t    assertLi,\n  \t\t    message,\n  \t\t    expected,\n  \t\t    actual,\n  \t\t    diff,\n  \t\t    showDiff = false,\n  \t\t    testItem = id(\"qunit-test-output-\" + details.testId);\n\n  \t\tif (!testItem) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\tmessage = escapeText(details.message) || (details.result ? \"okay\" : \"failed\");\n  \t\tmessage = \"<span class='test-message'>\" + message + \"</span>\";\n  \t\tmessage += \"<span class='runtime'>@ \" + details.runtime + \" ms</span>\";\n\n  \t\t// The pushFailure doesn't provide details.expected\n  \t\t// when it calls, it's implicit to also not show expected and diff stuff\n  \t\t// Also, we need to check details.expected existence, as it can exist and be undefined\n  \t\tif (!details.result && hasOwn.call(details, \"expected\")) {\n  \t\t\tif (details.negative) {\n  \t\t\t\texpected = \"NOT \" + QUnit.dump.parse(details.expected);\n  \t\t\t} else {\n  \t\t\t\texpected = QUnit.dump.parse(details.expected);\n  \t\t\t}\n\n  \t\t\tactual = QUnit.dump.parse(details.actual);\n  \t\t\tmessage += \"<table><tr class='test-expected'><th>Expected: </th><td><pre>\" + escapeText(expected) + \"</pre></td></tr>\";\n\n  \t\t\tif (actual !== expected) {\n\n  \t\t\t\tmessage += \"<tr class='test-actual'><th>Result: </th><td><pre>\" + escapeText(actual) + \"</pre></td></tr>\";\n\n  \t\t\t\tif (typeof details.actual === \"number\" && typeof details.expected === \"number\") {\n  \t\t\t\t\tif (!isNaN(details.actual) && !isNaN(details.expected)) {\n  \t\t\t\t\t\tshowDiff = true;\n  \t\t\t\t\t\tdiff = details.actual - details.expected;\n  \t\t\t\t\t\tdiff = (diff > 0 ? \"+\" : \"\") + diff;\n  \t\t\t\t\t}\n  \t\t\t\t} else if (typeof details.actual !== \"boolean\" && typeof details.expected !== \"boolean\") {\n  \t\t\t\t\tdiff = QUnit.diff(expected, actual);\n\n  \t\t\t\t\t// don't show diff if there is zero overlap\n  \t\t\t\t\tshowDiff = stripHtml(diff).length !== stripHtml(expected).length + stripHtml(actual).length;\n  \t\t\t\t}\n\n  \t\t\t\tif (showDiff) {\n  \t\t\t\t\tmessage += \"<tr class='test-diff'><th>Diff: </th><td><pre>\" + diff + \"</pre></td></tr>\";\n  \t\t\t\t}\n  \t\t\t} else if (expected.indexOf(\"[object Array]\") !== -1 || expected.indexOf(\"[object Object]\") !== -1) {\n  \t\t\t\tmessage += \"<tr class='test-message'><th>Message: </th><td>\" + \"Diff suppressed as the depth of object is more than current max depth (\" + QUnit.config.maxDepth + \").<p>Hint: Use <code>QUnit.dump.maxDepth</code> to \" + \" run with a higher max depth or <a href='\" + escapeText(setUrl({ maxDepth: -1 })) + \"'>\" + \"Rerun</a> without max depth.</p></td></tr>\";\n  \t\t\t} else {\n  \t\t\t\tmessage += \"<tr class='test-message'><th>Message: </th><td>\" + \"Diff suppressed as the expected and actual results have an equivalent\" + \" serialization</td></tr>\";\n  \t\t\t}\n\n  \t\t\tif (details.source) {\n  \t\t\t\tmessage += \"<tr class='test-source'><th>Source: </th><td><pre>\" + escapeText(details.source) + \"</pre></td></tr>\";\n  \t\t\t}\n\n  \t\t\tmessage += \"</table>\";\n\n  \t\t\t// This occurs when pushFailure is set and we have an extracted stack trace\n  \t\t} else if (!details.result && details.source) {\n  \t\t\tmessage += \"<table>\" + \"<tr class='test-source'><th>Source: </th><td><pre>\" + escapeText(details.source) + \"</pre></td></tr>\" + \"</table>\";\n  \t\t}\n\n  \t\tassertList = testItem.getElementsByTagName(\"ol\")[0];\n\n  \t\tassertLi = document$$1.createElement(\"li\");\n  \t\tassertLi.className = details.result ? \"pass\" : \"fail\";\n  \t\tassertLi.innerHTML = message;\n  \t\tassertList.appendChild(assertLi);\n  \t});\n\n  \tQUnit.testDone(function (details) {\n  \t\tvar testTitle,\n  \t\t    time,\n  \t\t    testItem,\n  \t\t    assertList,\n  \t\t    good,\n  \t\t    bad,\n  \t\t    testCounts,\n  \t\t    skipped,\n  \t\t    sourceName,\n  \t\t    tests = id(\"qunit-tests\");\n\n  \t\tif (!tests) {\n  \t\t\treturn;\n  \t\t}\n\n  \t\ttestItem = id(\"qunit-test-output-\" + details.testId);\n\n  \t\tassertList = testItem.getElementsByTagName(\"ol\")[0];\n\n  \t\tgood = details.passed;\n  \t\tbad = details.failed;\n\n  \t\t// This test passed if it has no unexpected failed assertions\n  \t\tvar testPassed = details.failed > 0 ? details.todo : !details.todo;\n\n  \t\tif (testPassed) {\n\n  \t\t\t// Collapse the passing tests\n  \t\t\taddClass(assertList, \"qunit-collapsed\");\n  \t\t} else if (config.collapse) {\n  \t\t\tif (!collapseNext) {\n\n  \t\t\t\t// Skip collapsing the first failing test\n  \t\t\t\tcollapseNext = true;\n  \t\t\t} else {\n\n  \t\t\t\t// Collapse remaining tests\n  \t\t\t\taddClass(assertList, \"qunit-collapsed\");\n  \t\t\t}\n  \t\t}\n\n  \t\t// The testItem.firstChild is the test name\n  \t\ttestTitle = testItem.firstChild;\n\n  \t\ttestCounts = bad ? \"<b class='failed'>\" + bad + \"</b>, \" + \"<b class='passed'>\" + good + \"</b>, \" : \"\";\n\n  \t\ttestTitle.innerHTML += \" <b class='counts'>(\" + testCounts + details.assertions.length + \")</b>\";\n\n  \t\tif (details.skipped) {\n  \t\t\tstats.skippedTests++;\n\n  \t\t\ttestItem.className = \"skipped\";\n  \t\t\tskipped = document$$1.createElement(\"em\");\n  \t\t\tskipped.className = \"qunit-skipped-label\";\n  \t\t\tskipped.innerHTML = \"skipped\";\n  \t\t\ttestItem.insertBefore(skipped, testTitle);\n  \t\t} else {\n  \t\t\taddEvent(testTitle, \"click\", function () {\n  \t\t\t\ttoggleClass(assertList, \"qunit-collapsed\");\n  \t\t\t});\n\n  \t\t\ttestItem.className = testPassed ? \"pass\" : \"fail\";\n\n  \t\t\tif (details.todo) {\n  \t\t\t\tvar todoLabel = document$$1.createElement(\"em\");\n  \t\t\t\ttodoLabel.className = \"qunit-todo-label\";\n  \t\t\t\ttodoLabel.innerHTML = \"todo\";\n  \t\t\t\ttestItem.className += \" todo\";\n  \t\t\t\ttestItem.insertBefore(todoLabel, testTitle);\n  \t\t\t}\n\n  \t\t\ttime = document$$1.createElement(\"span\");\n  \t\t\ttime.className = \"runtime\";\n  \t\t\ttime.innerHTML = details.runtime + \" ms\";\n  \t\t\ttestItem.insertBefore(time, assertList);\n\n  \t\t\tif (!testPassed) {\n  \t\t\t\tstats.failedTests++;\n  \t\t\t} else if (details.todo) {\n  \t\t\t\tstats.todoTests++;\n  \t\t\t} else {\n  \t\t\t\tstats.passedTests++;\n  \t\t\t}\n  \t\t}\n\n  \t\t// Show the source of the test when showing assertions\n  \t\tif (details.source) {\n  \t\t\tsourceName = document$$1.createElement(\"p\");\n  \t\t\tsourceName.innerHTML = \"<strong>Source: </strong>\" + details.source;\n  \t\t\taddClass(sourceName, \"qunit-source\");\n  \t\t\tif (testPassed) {\n  \t\t\t\taddClass(sourceName, \"qunit-collapsed\");\n  \t\t\t}\n  \t\t\taddEvent(testTitle, \"click\", function () {\n  \t\t\t\ttoggleClass(sourceName, \"qunit-collapsed\");\n  \t\t\t});\n  \t\t\ttestItem.appendChild(sourceName);\n  \t\t}\n  \t});\n\n  \t// Avoid readyState issue with phantomjs\n  \t// Ref: #818\n  \tvar notPhantom = function (p) {\n  \t\treturn !(p && p.version && p.version.major > 0);\n  \t}(window.phantom);\n\n  \tif (notPhantom && document$$1.readyState === \"complete\") {\n  \t\tQUnit.load();\n  \t} else {\n  \t\taddEvent(window, \"load\", QUnit.load);\n  \t}\n\n  \t// Wrap window.onerror. We will call the original window.onerror to see if\n  \t// the existing handler fully handles the error; if not, we will call the\n  \t// QUnit.onError function.\n  \tvar originalWindowOnError = window.onerror;\n\n  \t// Cover uncaught exceptions\n  \t// Returning true will suppress the default browser handler,\n  \t// returning false will let it run.\n  \twindow.onerror = function (message, fileName, lineNumber) {\n  \t\tvar ret = false;\n  \t\tif (originalWindowOnError) {\n  \t\t\tfor (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {\n  \t\t\t\targs[_key - 3] = arguments[_key];\n  \t\t\t}\n\n  \t\t\tret = originalWindowOnError.call.apply(originalWindowOnError, [this, message, fileName, lineNumber].concat(args));\n  \t\t}\n\n  \t\t// Treat return value as window.onerror itself does,\n  \t\t// Only do our handling if not suppressed.\n  \t\tif (ret !== true) {\n  \t\t\tvar error = {\n  \t\t\t\tmessage: message,\n  \t\t\t\tfileName: fileName,\n  \t\t\t\tlineNumber: lineNumber\n  \t\t\t};\n\n  \t\t\tret = QUnit.onError(error);\n  \t\t}\n\n  \t\treturn ret;\n  \t};\n\n  \t// Listen for unhandled rejections, and call QUnit.onUnhandledRejection\n  \twindow.addEventListener(\"unhandledrejection\", function (event) {\n  \t\tQUnit.onUnhandledRejection(event.reason);\n  \t});\n  })();\n\n  /*\n   * This file is a modified version of google-diff-match-patch's JavaScript implementation\n   * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),\n   * modifications are licensed as more fully set forth in LICENSE.txt.\n   *\n   * The original source of google-diff-match-patch is attributable and licensed as follows:\n   *\n   * Copyright 2006 Google Inc.\n   * https://code.google.com/p/google-diff-match-patch/\n   *\n   * Licensed under the Apache License, Version 2.0 (the \"License\");\n   * you may not use this file except in compliance with the License.\n   * You may obtain a copy of the License at\n   *\n   * https://www.apache.org/licenses/LICENSE-2.0\n   *\n   * Unless required by applicable law or agreed to in writing, software\n   * distributed under the License is distributed on an \"AS IS\" BASIS,\n   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   * See the License for the specific language governing permissions and\n   * limitations under the License.\n   *\n   * More Info:\n   *  https://code.google.com/p/google-diff-match-patch/\n   *\n   * Usage: QUnit.diff(expected, actual)\n   *\n   */\n  QUnit.diff = function () {\n  \tfunction DiffMatchPatch() {}\n\n  \t//  DIFF FUNCTIONS\n\n  \t/**\n    * The data structure representing a diff is an array of tuples:\n    * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]\n    * which means: delete 'Hello', add 'Goodbye' and keep ' world.'\n    */\n  \tvar DIFF_DELETE = -1,\n  \t    DIFF_INSERT = 1,\n  \t    DIFF_EQUAL = 0;\n\n  \t/**\n    * Find the differences between two texts.  Simplifies the problem by stripping\n    * any common prefix or suffix off the texts before diffing.\n    * @param {string} text1 Old string to be diffed.\n    * @param {string} text2 New string to be diffed.\n    * @param {boolean=} optChecklines Optional speedup flag. If present and false,\n    *     then don't run a line-level diff first to identify the changed areas.\n    *     Defaults to true, which does a faster, slightly less optimal diff.\n    * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.\n    */\n  \tDiffMatchPatch.prototype.DiffMain = function (text1, text2, optChecklines) {\n  \t\tvar deadline, checklines, commonlength, commonprefix, commonsuffix, diffs;\n\n  \t\t// The diff must be complete in up to 1 second.\n  \t\tdeadline = new Date().getTime() + 1000;\n\n  \t\t// Check for null inputs.\n  \t\tif (text1 === null || text2 === null) {\n  \t\t\tthrow new Error(\"Null input. (DiffMain)\");\n  \t\t}\n\n  \t\t// Check for equality (speedup).\n  \t\tif (text1 === text2) {\n  \t\t\tif (text1) {\n  \t\t\t\treturn [[DIFF_EQUAL, text1]];\n  \t\t\t}\n  \t\t\treturn [];\n  \t\t}\n\n  \t\tif (typeof optChecklines === \"undefined\") {\n  \t\t\toptChecklines = true;\n  \t\t}\n\n  \t\tchecklines = optChecklines;\n\n  \t\t// Trim off common prefix (speedup).\n  \t\tcommonlength = this.diffCommonPrefix(text1, text2);\n  \t\tcommonprefix = text1.substring(0, commonlength);\n  \t\ttext1 = text1.substring(commonlength);\n  \t\ttext2 = text2.substring(commonlength);\n\n  \t\t// Trim off common suffix (speedup).\n  \t\tcommonlength = this.diffCommonSuffix(text1, text2);\n  \t\tcommonsuffix = text1.substring(text1.length - commonlength);\n  \t\ttext1 = text1.substring(0, text1.length - commonlength);\n  \t\ttext2 = text2.substring(0, text2.length - commonlength);\n\n  \t\t// Compute the diff on the middle block.\n  \t\tdiffs = this.diffCompute(text1, text2, checklines, deadline);\n\n  \t\t// Restore the prefix and suffix.\n  \t\tif (commonprefix) {\n  \t\t\tdiffs.unshift([DIFF_EQUAL, commonprefix]);\n  \t\t}\n  \t\tif (commonsuffix) {\n  \t\t\tdiffs.push([DIFF_EQUAL, commonsuffix]);\n  \t\t}\n  \t\tthis.diffCleanupMerge(diffs);\n  \t\treturn diffs;\n  \t};\n\n  \t/**\n    * Reduce the number of edits by eliminating operationally trivial equalities.\n    * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.\n    */\n  \tDiffMatchPatch.prototype.diffCleanupEfficiency = function (diffs) {\n  \t\tvar changes, equalities, equalitiesLength, lastequality, pointer, preIns, preDel, postIns, postDel;\n  \t\tchanges = false;\n  \t\tequalities = []; // Stack of indices where equalities are found.\n  \t\tequalitiesLength = 0; // Keeping our own length var is faster in JS.\n  \t\t/** @type {?string} */\n  \t\tlastequality = null;\n\n  \t\t// Always equal to diffs[equalities[equalitiesLength - 1]][1]\n  \t\tpointer = 0; // Index of current position.\n\n  \t\t// Is there an insertion operation before the last equality.\n  \t\tpreIns = false;\n\n  \t\t// Is there a deletion operation before the last equality.\n  \t\tpreDel = false;\n\n  \t\t// Is there an insertion operation after the last equality.\n  \t\tpostIns = false;\n\n  \t\t// Is there a deletion operation after the last equality.\n  \t\tpostDel = false;\n  \t\twhile (pointer < diffs.length) {\n\n  \t\t\t// Equality found.\n  \t\t\tif (diffs[pointer][0] === DIFF_EQUAL) {\n  \t\t\t\tif (diffs[pointer][1].length < 4 && (postIns || postDel)) {\n\n  \t\t\t\t\t// Candidate found.\n  \t\t\t\t\tequalities[equalitiesLength++] = pointer;\n  \t\t\t\t\tpreIns = postIns;\n  \t\t\t\t\tpreDel = postDel;\n  \t\t\t\t\tlastequality = diffs[pointer][1];\n  \t\t\t\t} else {\n\n  \t\t\t\t\t// Not a candidate, and can never become one.\n  \t\t\t\t\tequalitiesLength = 0;\n  \t\t\t\t\tlastequality = null;\n  \t\t\t\t}\n  \t\t\t\tpostIns = postDel = false;\n\n  \t\t\t\t// An insertion or deletion.\n  \t\t\t} else {\n\n  \t\t\t\tif (diffs[pointer][0] === DIFF_DELETE) {\n  \t\t\t\t\tpostDel = true;\n  \t\t\t\t} else {\n  \t\t\t\t\tpostIns = true;\n  \t\t\t\t}\n\n  \t\t\t\t/*\n       * Five types to be split:\n       * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>\n       * <ins>A</ins>X<ins>C</ins><del>D</del>\n       * <ins>A</ins><del>B</del>X<ins>C</ins>\n       * <ins>A</del>X<ins>C</ins><del>D</del>\n       * <ins>A</ins><del>B</del>X<del>C</del>\n       */\n  \t\t\t\tif (lastequality && (preIns && preDel && postIns && postDel || lastequality.length < 2 && preIns + preDel + postIns + postDel === 3)) {\n\n  \t\t\t\t\t// Duplicate record.\n  \t\t\t\t\tdiffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]);\n\n  \t\t\t\t\t// Change second copy to insert.\n  \t\t\t\t\tdiffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;\n  \t\t\t\t\tequalitiesLength--; // Throw away the equality we just deleted;\n  \t\t\t\t\tlastequality = null;\n  \t\t\t\t\tif (preIns && preDel) {\n\n  \t\t\t\t\t\t// No changes made which could affect previous entry, keep going.\n  \t\t\t\t\t\tpostIns = postDel = true;\n  \t\t\t\t\t\tequalitiesLength = 0;\n  \t\t\t\t\t} else {\n  \t\t\t\t\t\tequalitiesLength--; // Throw away the previous equality.\n  \t\t\t\t\t\tpointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;\n  \t\t\t\t\t\tpostIns = postDel = false;\n  \t\t\t\t\t}\n  \t\t\t\t\tchanges = true;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\tpointer++;\n  \t\t}\n\n  \t\tif (changes) {\n  \t\t\tthis.diffCleanupMerge(diffs);\n  \t\t}\n  \t};\n\n  \t/**\n    * Convert a diff array into a pretty HTML report.\n    * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.\n    * @param {integer} string to be beautified.\n    * @return {string} HTML representation.\n    */\n  \tDiffMatchPatch.prototype.diffPrettyHtml = function (diffs) {\n  \t\tvar op,\n  \t\t    data,\n  \t\t    x,\n  \t\t    html = [];\n  \t\tfor (x = 0; x < diffs.length; x++) {\n  \t\t\top = diffs[x][0]; // Operation (insert, delete, equal)\n  \t\t\tdata = diffs[x][1]; // Text of change.\n  \t\t\tswitch (op) {\n  \t\t\t\tcase DIFF_INSERT:\n  \t\t\t\t\thtml[x] = \"<ins>\" + escapeText(data) + \"</ins>\";\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_DELETE:\n  \t\t\t\t\thtml[x] = \"<del>\" + escapeText(data) + \"</del>\";\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_EQUAL:\n  \t\t\t\t\thtml[x] = \"<span>\" + escapeText(data) + \"</span>\";\n  \t\t\t\t\tbreak;\n  \t\t\t}\n  \t\t}\n  \t\treturn html.join(\"\");\n  \t};\n\n  \t/**\n    * Determine the common prefix of two strings.\n    * @param {string} text1 First string.\n    * @param {string} text2 Second string.\n    * @return {number} The number of characters common to the start of each\n    *     string.\n    */\n  \tDiffMatchPatch.prototype.diffCommonPrefix = function (text1, text2) {\n  \t\tvar pointermid, pointermax, pointermin, pointerstart;\n\n  \t\t// Quick check for common null cases.\n  \t\tif (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {\n  \t\t\treturn 0;\n  \t\t}\n\n  \t\t// Binary search.\n  \t\t// Performance analysis: https://neil.fraser.name/news/2007/10/09/\n  \t\tpointermin = 0;\n  \t\tpointermax = Math.min(text1.length, text2.length);\n  \t\tpointermid = pointermax;\n  \t\tpointerstart = 0;\n  \t\twhile (pointermin < pointermid) {\n  \t\t\tif (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {\n  \t\t\t\tpointermin = pointermid;\n  \t\t\t\tpointerstart = pointermin;\n  \t\t\t} else {\n  \t\t\t\tpointermax = pointermid;\n  \t\t\t}\n  \t\t\tpointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);\n  \t\t}\n  \t\treturn pointermid;\n  \t};\n\n  \t/**\n    * Determine the common suffix of two strings.\n    * @param {string} text1 First string.\n    * @param {string} text2 Second string.\n    * @return {number} The number of characters common to the end of each string.\n    */\n  \tDiffMatchPatch.prototype.diffCommonSuffix = function (text1, text2) {\n  \t\tvar pointermid, pointermax, pointermin, pointerend;\n\n  \t\t// Quick check for common null cases.\n  \t\tif (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) {\n  \t\t\treturn 0;\n  \t\t}\n\n  \t\t// Binary search.\n  \t\t// Performance analysis: https://neil.fraser.name/news/2007/10/09/\n  \t\tpointermin = 0;\n  \t\tpointermax = Math.min(text1.length, text2.length);\n  \t\tpointermid = pointermax;\n  \t\tpointerend = 0;\n  \t\twhile (pointermin < pointermid) {\n  \t\t\tif (text1.substring(text1.length - pointermid, text1.length - pointerend) === text2.substring(text2.length - pointermid, text2.length - pointerend)) {\n  \t\t\t\tpointermin = pointermid;\n  \t\t\t\tpointerend = pointermin;\n  \t\t\t} else {\n  \t\t\t\tpointermax = pointermid;\n  \t\t\t}\n  \t\t\tpointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);\n  \t\t}\n  \t\treturn pointermid;\n  \t};\n\n  \t/**\n    * Find the differences between two texts.  Assumes that the texts do not\n    * have any common prefix or suffix.\n    * @param {string} text1 Old string to be diffed.\n    * @param {string} text2 New string to be diffed.\n    * @param {boolean} checklines Speedup flag.  If false, then don't run a\n    *     line-level diff first to identify the changed areas.\n    *     If true, then run a faster, slightly less optimal diff.\n    * @param {number} deadline Time when the diff should be complete by.\n    * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffCompute = function (text1, text2, checklines, deadline) {\n  \t\tvar diffs, longtext, shorttext, i, hm, text1A, text2A, text1B, text2B, midCommon, diffsA, diffsB;\n\n  \t\tif (!text1) {\n\n  \t\t\t// Just add some text (speedup).\n  \t\t\treturn [[DIFF_INSERT, text2]];\n  \t\t}\n\n  \t\tif (!text2) {\n\n  \t\t\t// Just delete some text (speedup).\n  \t\t\treturn [[DIFF_DELETE, text1]];\n  \t\t}\n\n  \t\tlongtext = text1.length > text2.length ? text1 : text2;\n  \t\tshorttext = text1.length > text2.length ? text2 : text1;\n  \t\ti = longtext.indexOf(shorttext);\n  \t\tif (i !== -1) {\n\n  \t\t\t// Shorter text is inside the longer text (speedup).\n  \t\t\tdiffs = [[DIFF_INSERT, longtext.substring(0, i)], [DIFF_EQUAL, shorttext], [DIFF_INSERT, longtext.substring(i + shorttext.length)]];\n\n  \t\t\t// Swap insertions for deletions if diff is reversed.\n  \t\t\tif (text1.length > text2.length) {\n  \t\t\t\tdiffs[0][0] = diffs[2][0] = DIFF_DELETE;\n  \t\t\t}\n  \t\t\treturn diffs;\n  \t\t}\n\n  \t\tif (shorttext.length === 1) {\n\n  \t\t\t// Single character string.\n  \t\t\t// After the previous speedup, the character can't be an equality.\n  \t\t\treturn [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];\n  \t\t}\n\n  \t\t// Check to see if the problem can be split in two.\n  \t\thm = this.diffHalfMatch(text1, text2);\n  \t\tif (hm) {\n\n  \t\t\t// A half-match was found, sort out the return data.\n  \t\t\ttext1A = hm[0];\n  \t\t\ttext1B = hm[1];\n  \t\t\ttext2A = hm[2];\n  \t\t\ttext2B = hm[3];\n  \t\t\tmidCommon = hm[4];\n\n  \t\t\t// Send both pairs off for separate processing.\n  \t\t\tdiffsA = this.DiffMain(text1A, text2A, checklines, deadline);\n  \t\t\tdiffsB = this.DiffMain(text1B, text2B, checklines, deadline);\n\n  \t\t\t// Merge the results.\n  \t\t\treturn diffsA.concat([[DIFF_EQUAL, midCommon]], diffsB);\n  \t\t}\n\n  \t\tif (checklines && text1.length > 100 && text2.length > 100) {\n  \t\t\treturn this.diffLineMode(text1, text2, deadline);\n  \t\t}\n\n  \t\treturn this.diffBisect(text1, text2, deadline);\n  \t};\n\n  \t/**\n    * Do the two texts share a substring which is at least half the length of the\n    * longer text?\n    * This speedup can produce non-minimal diffs.\n    * @param {string} text1 First string.\n    * @param {string} text2 Second string.\n    * @return {Array.<string>} Five element Array, containing the prefix of\n    *     text1, the suffix of text1, the prefix of text2, the suffix of\n    *     text2 and the common middle.  Or null if there was no match.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffHalfMatch = function (text1, text2) {\n  \t\tvar longtext, shorttext, dmp, text1A, text2B, text2A, text1B, midCommon, hm1, hm2, hm;\n\n  \t\tlongtext = text1.length > text2.length ? text1 : text2;\n  \t\tshorttext = text1.length > text2.length ? text2 : text1;\n  \t\tif (longtext.length < 4 || shorttext.length * 2 < longtext.length) {\n  \t\t\treturn null; // Pointless.\n  \t\t}\n  \t\tdmp = this; // 'this' becomes 'window' in a closure.\n\n  \t\t/**\n     * Does a substring of shorttext exist within longtext such that the substring\n     * is at least half the length of longtext?\n     * Closure, but does not reference any external variables.\n     * @param {string} longtext Longer string.\n     * @param {string} shorttext Shorter string.\n     * @param {number} i Start index of quarter length substring within longtext.\n     * @return {Array.<string>} Five element Array, containing the prefix of\n     *     longtext, the suffix of longtext, the prefix of shorttext, the suffix\n     *     of shorttext and the common middle.  Or null if there was no match.\n     * @private\n     */\n  \t\tfunction diffHalfMatchI(longtext, shorttext, i) {\n  \t\t\tvar seed, j, bestCommon, prefixLength, suffixLength, bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;\n\n  \t\t\t// Start with a 1/4 length substring at position i as a seed.\n  \t\t\tseed = longtext.substring(i, i + Math.floor(longtext.length / 4));\n  \t\t\tj = -1;\n  \t\t\tbestCommon = \"\";\n  \t\t\twhile ((j = shorttext.indexOf(seed, j + 1)) !== -1) {\n  \t\t\t\tprefixLength = dmp.diffCommonPrefix(longtext.substring(i), shorttext.substring(j));\n  \t\t\t\tsuffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), shorttext.substring(0, j));\n  \t\t\t\tif (bestCommon.length < suffixLength + prefixLength) {\n  \t\t\t\t\tbestCommon = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength);\n  \t\t\t\t\tbestLongtextA = longtext.substring(0, i - suffixLength);\n  \t\t\t\t\tbestLongtextB = longtext.substring(i + prefixLength);\n  \t\t\t\t\tbestShorttextA = shorttext.substring(0, j - suffixLength);\n  \t\t\t\t\tbestShorttextB = shorttext.substring(j + prefixLength);\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\tif (bestCommon.length * 2 >= longtext.length) {\n  \t\t\t\treturn [bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB, bestCommon];\n  \t\t\t} else {\n  \t\t\t\treturn null;\n  \t\t\t}\n  \t\t}\n\n  \t\t// First check if the second quarter is the seed for a half-match.\n  \t\thm1 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 4));\n\n  \t\t// Check again based on the third quarter.\n  \t\thm2 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 2));\n  \t\tif (!hm1 && !hm2) {\n  \t\t\treturn null;\n  \t\t} else if (!hm2) {\n  \t\t\thm = hm1;\n  \t\t} else if (!hm1) {\n  \t\t\thm = hm2;\n  \t\t} else {\n\n  \t\t\t// Both matched.  Select the longest.\n  \t\t\thm = hm1[4].length > hm2[4].length ? hm1 : hm2;\n  \t\t}\n\n  \t\t// A half-match was found, sort out the return data.\n  \t\tif (text1.length > text2.length) {\n  \t\t\ttext1A = hm[0];\n  \t\t\ttext1B = hm[1];\n  \t\t\ttext2A = hm[2];\n  \t\t\ttext2B = hm[3];\n  \t\t} else {\n  \t\t\ttext2A = hm[0];\n  \t\t\ttext2B = hm[1];\n  \t\t\ttext1A = hm[2];\n  \t\t\ttext1B = hm[3];\n  \t\t}\n  \t\tmidCommon = hm[4];\n  \t\treturn [text1A, text1B, text2A, text2B, midCommon];\n  \t};\n\n  \t/**\n    * Do a quick line-level diff on both strings, then rediff the parts for\n    * greater accuracy.\n    * This speedup can produce non-minimal diffs.\n    * @param {string} text1 Old string to be diffed.\n    * @param {string} text2 New string to be diffed.\n    * @param {number} deadline Time when the diff should be complete by.\n    * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffLineMode = function (text1, text2, deadline) {\n  \t\tvar a, diffs, linearray, pointer, countInsert, countDelete, textInsert, textDelete, j;\n\n  \t\t// Scan the text on a line-by-line basis first.\n  \t\ta = this.diffLinesToChars(text1, text2);\n  \t\ttext1 = a.chars1;\n  \t\ttext2 = a.chars2;\n  \t\tlinearray = a.lineArray;\n\n  \t\tdiffs = this.DiffMain(text1, text2, false, deadline);\n\n  \t\t// Convert the diff back to original text.\n  \t\tthis.diffCharsToLines(diffs, linearray);\n\n  \t\t// Eliminate freak matches (e.g. blank lines)\n  \t\tthis.diffCleanupSemantic(diffs);\n\n  \t\t// Rediff any replacement blocks, this time character-by-character.\n  \t\t// Add a dummy entry at the end.\n  \t\tdiffs.push([DIFF_EQUAL, \"\"]);\n  \t\tpointer = 0;\n  \t\tcountDelete = 0;\n  \t\tcountInsert = 0;\n  \t\ttextDelete = \"\";\n  \t\ttextInsert = \"\";\n  \t\twhile (pointer < diffs.length) {\n  \t\t\tswitch (diffs[pointer][0]) {\n  \t\t\t\tcase DIFF_INSERT:\n  \t\t\t\t\tcountInsert++;\n  \t\t\t\t\ttextInsert += diffs[pointer][1];\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_DELETE:\n  \t\t\t\t\tcountDelete++;\n  \t\t\t\t\ttextDelete += diffs[pointer][1];\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_EQUAL:\n\n  \t\t\t\t\t// Upon reaching an equality, check for prior redundancies.\n  \t\t\t\t\tif (countDelete >= 1 && countInsert >= 1) {\n\n  \t\t\t\t\t\t// Delete the offending records and add the merged ones.\n  \t\t\t\t\t\tdiffs.splice(pointer - countDelete - countInsert, countDelete + countInsert);\n  \t\t\t\t\t\tpointer = pointer - countDelete - countInsert;\n  \t\t\t\t\t\ta = this.DiffMain(textDelete, textInsert, false, deadline);\n  \t\t\t\t\t\tfor (j = a.length - 1; j >= 0; j--) {\n  \t\t\t\t\t\t\tdiffs.splice(pointer, 0, a[j]);\n  \t\t\t\t\t\t}\n  \t\t\t\t\t\tpointer = pointer + a.length;\n  \t\t\t\t\t}\n  \t\t\t\t\tcountInsert = 0;\n  \t\t\t\t\tcountDelete = 0;\n  \t\t\t\t\ttextDelete = \"\";\n  \t\t\t\t\ttextInsert = \"\";\n  \t\t\t\t\tbreak;\n  \t\t\t}\n  \t\t\tpointer++;\n  \t\t}\n  \t\tdiffs.pop(); // Remove the dummy entry at the end.\n\n  \t\treturn diffs;\n  \t};\n\n  \t/**\n    * Find the 'middle snake' of a diff, split the problem in two\n    * and return the recursively constructed diff.\n    * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.\n    * @param {string} text1 Old string to be diffed.\n    * @param {string} text2 New string to be diffed.\n    * @param {number} deadline Time at which to bail if not yet complete.\n    * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffBisect = function (text1, text2, deadline) {\n  \t\tvar text1Length, text2Length, maxD, vOffset, vLength, v1, v2, x, delta, front, k1start, k1end, k2start, k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;\n\n  \t\t// Cache the text lengths to prevent multiple calls.\n  \t\ttext1Length = text1.length;\n  \t\ttext2Length = text2.length;\n  \t\tmaxD = Math.ceil((text1Length + text2Length) / 2);\n  \t\tvOffset = maxD;\n  \t\tvLength = 2 * maxD;\n  \t\tv1 = new Array(vLength);\n  \t\tv2 = new Array(vLength);\n\n  \t\t// Setting all elements to -1 is faster in Chrome & Firefox than mixing\n  \t\t// integers and undefined.\n  \t\tfor (x = 0; x < vLength; x++) {\n  \t\t\tv1[x] = -1;\n  \t\t\tv2[x] = -1;\n  \t\t}\n  \t\tv1[vOffset + 1] = 0;\n  \t\tv2[vOffset + 1] = 0;\n  \t\tdelta = text1Length - text2Length;\n\n  \t\t// If the total number of characters is odd, then the front path will collide\n  \t\t// with the reverse path.\n  \t\tfront = delta % 2 !== 0;\n\n  \t\t// Offsets for start and end of k loop.\n  \t\t// Prevents mapping of space beyond the grid.\n  \t\tk1start = 0;\n  \t\tk1end = 0;\n  \t\tk2start = 0;\n  \t\tk2end = 0;\n  \t\tfor (d = 0; d < maxD; d++) {\n\n  \t\t\t// Bail out if deadline is reached.\n  \t\t\tif (new Date().getTime() > deadline) {\n  \t\t\t\tbreak;\n  \t\t\t}\n\n  \t\t\t// Walk the front path one step.\n  \t\t\tfor (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {\n  \t\t\t\tk1Offset = vOffset + k1;\n  \t\t\t\tif (k1 === -d || k1 !== d && v1[k1Offset - 1] < v1[k1Offset + 1]) {\n  \t\t\t\t\tx1 = v1[k1Offset + 1];\n  \t\t\t\t} else {\n  \t\t\t\t\tx1 = v1[k1Offset - 1] + 1;\n  \t\t\t\t}\n  \t\t\t\ty1 = x1 - k1;\n  \t\t\t\twhile (x1 < text1Length && y1 < text2Length && text1.charAt(x1) === text2.charAt(y1)) {\n  \t\t\t\t\tx1++;\n  \t\t\t\t\ty1++;\n  \t\t\t\t}\n  \t\t\t\tv1[k1Offset] = x1;\n  \t\t\t\tif (x1 > text1Length) {\n\n  \t\t\t\t\t// Ran off the right of the graph.\n  \t\t\t\t\tk1end += 2;\n  \t\t\t\t} else if (y1 > text2Length) {\n\n  \t\t\t\t\t// Ran off the bottom of the graph.\n  \t\t\t\t\tk1start += 2;\n  \t\t\t\t} else if (front) {\n  \t\t\t\t\tk2Offset = vOffset + delta - k1;\n  \t\t\t\t\tif (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) {\n\n  \t\t\t\t\t\t// Mirror x2 onto top-left coordinate system.\n  \t\t\t\t\t\tx2 = text1Length - v2[k2Offset];\n  \t\t\t\t\t\tif (x1 >= x2) {\n\n  \t\t\t\t\t\t\t// Overlap detected.\n  \t\t\t\t\t\t\treturn this.diffBisectSplit(text1, text2, x1, y1, deadline);\n  \t\t\t\t\t\t}\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t}\n\n  \t\t\t// Walk the reverse path one step.\n  \t\t\tfor (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {\n  \t\t\t\tk2Offset = vOffset + k2;\n  \t\t\t\tif (k2 === -d || k2 !== d && v2[k2Offset - 1] < v2[k2Offset + 1]) {\n  \t\t\t\t\tx2 = v2[k2Offset + 1];\n  \t\t\t\t} else {\n  \t\t\t\t\tx2 = v2[k2Offset - 1] + 1;\n  \t\t\t\t}\n  \t\t\t\ty2 = x2 - k2;\n  \t\t\t\twhile (x2 < text1Length && y2 < text2Length && text1.charAt(text1Length - x2 - 1) === text2.charAt(text2Length - y2 - 1)) {\n  \t\t\t\t\tx2++;\n  \t\t\t\t\ty2++;\n  \t\t\t\t}\n  \t\t\t\tv2[k2Offset] = x2;\n  \t\t\t\tif (x2 > text1Length) {\n\n  \t\t\t\t\t// Ran off the left of the graph.\n  \t\t\t\t\tk2end += 2;\n  \t\t\t\t} else if (y2 > text2Length) {\n\n  \t\t\t\t\t// Ran off the top of the graph.\n  \t\t\t\t\tk2start += 2;\n  \t\t\t\t} else if (!front) {\n  \t\t\t\t\tk1Offset = vOffset + delta - k2;\n  \t\t\t\t\tif (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) {\n  \t\t\t\t\t\tx1 = v1[k1Offset];\n  \t\t\t\t\t\ty1 = vOffset + x1 - k1Offset;\n\n  \t\t\t\t\t\t// Mirror x2 onto top-left coordinate system.\n  \t\t\t\t\t\tx2 = text1Length - x2;\n  \t\t\t\t\t\tif (x1 >= x2) {\n\n  \t\t\t\t\t\t\t// Overlap detected.\n  \t\t\t\t\t\t\treturn this.diffBisectSplit(text1, text2, x1, y1, deadline);\n  \t\t\t\t\t\t}\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t}\n  \t\t}\n\n  \t\t// Diff took too long and hit the deadline or\n  \t\t// number of diffs equals number of characters, no commonality at all.\n  \t\treturn [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];\n  \t};\n\n  \t/**\n    * Given the location of the 'middle snake', split the diff in two parts\n    * and recurse.\n    * @param {string} text1 Old string to be diffed.\n    * @param {string} text2 New string to be diffed.\n    * @param {number} x Index of split point in text1.\n    * @param {number} y Index of split point in text2.\n    * @param {number} deadline Time at which to bail if not yet complete.\n    * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffBisectSplit = function (text1, text2, x, y, deadline) {\n  \t\tvar text1a, text1b, text2a, text2b, diffs, diffsb;\n  \t\ttext1a = text1.substring(0, x);\n  \t\ttext2a = text2.substring(0, y);\n  \t\ttext1b = text1.substring(x);\n  \t\ttext2b = text2.substring(y);\n\n  \t\t// Compute both diffs serially.\n  \t\tdiffs = this.DiffMain(text1a, text2a, false, deadline);\n  \t\tdiffsb = this.DiffMain(text1b, text2b, false, deadline);\n\n  \t\treturn diffs.concat(diffsb);\n  \t};\n\n  \t/**\n    * Reduce the number of edits by eliminating semantically trivial equalities.\n    * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.\n    */\n  \tDiffMatchPatch.prototype.diffCleanupSemantic = function (diffs) {\n  \t\tvar changes, equalities, equalitiesLength, lastequality, pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1, lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;\n  \t\tchanges = false;\n  \t\tequalities = []; // Stack of indices where equalities are found.\n  \t\tequalitiesLength = 0; // Keeping our own length var is faster in JS.\n  \t\t/** @type {?string} */\n  \t\tlastequality = null;\n\n  \t\t// Always equal to diffs[equalities[equalitiesLength - 1]][1]\n  \t\tpointer = 0; // Index of current position.\n\n  \t\t// Number of characters that changed prior to the equality.\n  \t\tlengthInsertions1 = 0;\n  \t\tlengthDeletions1 = 0;\n\n  \t\t// Number of characters that changed after the equality.\n  \t\tlengthInsertions2 = 0;\n  \t\tlengthDeletions2 = 0;\n  \t\twhile (pointer < diffs.length) {\n  \t\t\tif (diffs[pointer][0] === DIFF_EQUAL) {\n  \t\t\t\t// Equality found.\n  \t\t\t\tequalities[equalitiesLength++] = pointer;\n  \t\t\t\tlengthInsertions1 = lengthInsertions2;\n  \t\t\t\tlengthDeletions1 = lengthDeletions2;\n  \t\t\t\tlengthInsertions2 = 0;\n  \t\t\t\tlengthDeletions2 = 0;\n  \t\t\t\tlastequality = diffs[pointer][1];\n  \t\t\t} else {\n  \t\t\t\t// An insertion or deletion.\n  \t\t\t\tif (diffs[pointer][0] === DIFF_INSERT) {\n  \t\t\t\t\tlengthInsertions2 += diffs[pointer][1].length;\n  \t\t\t\t} else {\n  \t\t\t\t\tlengthDeletions2 += diffs[pointer][1].length;\n  \t\t\t\t}\n\n  \t\t\t\t// Eliminate an equality that is smaller or equal to the edits on both\n  \t\t\t\t// sides of it.\n  \t\t\t\tif (lastequality && lastequality.length <= Math.max(lengthInsertions1, lengthDeletions1) && lastequality.length <= Math.max(lengthInsertions2, lengthDeletions2)) {\n\n  \t\t\t\t\t// Duplicate record.\n  \t\t\t\t\tdiffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]);\n\n  \t\t\t\t\t// Change second copy to insert.\n  \t\t\t\t\tdiffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;\n\n  \t\t\t\t\t// Throw away the equality we just deleted.\n  \t\t\t\t\tequalitiesLength--;\n\n  \t\t\t\t\t// Throw away the previous equality (it needs to be reevaluated).\n  \t\t\t\t\tequalitiesLength--;\n  \t\t\t\t\tpointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;\n\n  \t\t\t\t\t// Reset the counters.\n  \t\t\t\t\tlengthInsertions1 = 0;\n  \t\t\t\t\tlengthDeletions1 = 0;\n  \t\t\t\t\tlengthInsertions2 = 0;\n  \t\t\t\t\tlengthDeletions2 = 0;\n  \t\t\t\t\tlastequality = null;\n  \t\t\t\t\tchanges = true;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\tpointer++;\n  \t\t}\n\n  \t\t// Normalize the diff.\n  \t\tif (changes) {\n  \t\t\tthis.diffCleanupMerge(diffs);\n  \t\t}\n\n  \t\t// Find any overlaps between deletions and insertions.\n  \t\t// e.g: <del>abcxxx</del><ins>xxxdef</ins>\n  \t\t//   -> <del>abc</del>xxx<ins>def</ins>\n  \t\t// e.g: <del>xxxabc</del><ins>defxxx</ins>\n  \t\t//   -> <ins>def</ins>xxx<del>abc</del>\n  \t\t// Only extract an overlap if it is as big as the edit ahead or behind it.\n  \t\tpointer = 1;\n  \t\twhile (pointer < diffs.length) {\n  \t\t\tif (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) {\n  \t\t\t\tdeletion = diffs[pointer - 1][1];\n  \t\t\t\tinsertion = diffs[pointer][1];\n  \t\t\t\toverlapLength1 = this.diffCommonOverlap(deletion, insertion);\n  \t\t\t\toverlapLength2 = this.diffCommonOverlap(insertion, deletion);\n  \t\t\t\tif (overlapLength1 >= overlapLength2) {\n  \t\t\t\t\tif (overlapLength1 >= deletion.length / 2 || overlapLength1 >= insertion.length / 2) {\n\n  \t\t\t\t\t\t// Overlap found.  Insert an equality and trim the surrounding edits.\n  \t\t\t\t\t\tdiffs.splice(pointer, 0, [DIFF_EQUAL, insertion.substring(0, overlapLength1)]);\n  \t\t\t\t\t\tdiffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlapLength1);\n  \t\t\t\t\t\tdiffs[pointer + 1][1] = insertion.substring(overlapLength1);\n  \t\t\t\t\t\tpointer++;\n  \t\t\t\t\t}\n  \t\t\t\t} else {\n  \t\t\t\t\tif (overlapLength2 >= deletion.length / 2 || overlapLength2 >= insertion.length / 2) {\n\n  \t\t\t\t\t\t// Reverse overlap found.\n  \t\t\t\t\t\t// Insert an equality and swap and trim the surrounding edits.\n  \t\t\t\t\t\tdiffs.splice(pointer, 0, [DIFF_EQUAL, deletion.substring(0, overlapLength2)]);\n\n  \t\t\t\t\t\tdiffs[pointer - 1][0] = DIFF_INSERT;\n  \t\t\t\t\t\tdiffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlapLength2);\n  \t\t\t\t\t\tdiffs[pointer + 1][0] = DIFF_DELETE;\n  \t\t\t\t\t\tdiffs[pointer + 1][1] = deletion.substring(overlapLength2);\n  \t\t\t\t\t\tpointer++;\n  \t\t\t\t\t}\n  \t\t\t\t}\n  \t\t\t\tpointer++;\n  \t\t\t}\n  \t\t\tpointer++;\n  \t\t}\n  \t};\n\n  \t/**\n    * Determine if the suffix of one string is the prefix of another.\n    * @param {string} text1 First string.\n    * @param {string} text2 Second string.\n    * @return {number} The number of characters common to the end of the first\n    *     string and the start of the second string.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffCommonOverlap = function (text1, text2) {\n  \t\tvar text1Length, text2Length, textLength, best, length, pattern, found;\n\n  \t\t// Cache the text lengths to prevent multiple calls.\n  \t\ttext1Length = text1.length;\n  \t\ttext2Length = text2.length;\n\n  \t\t// Eliminate the null case.\n  \t\tif (text1Length === 0 || text2Length === 0) {\n  \t\t\treturn 0;\n  \t\t}\n\n  \t\t// Truncate the longer string.\n  \t\tif (text1Length > text2Length) {\n  \t\t\ttext1 = text1.substring(text1Length - text2Length);\n  \t\t} else if (text1Length < text2Length) {\n  \t\t\ttext2 = text2.substring(0, text1Length);\n  \t\t}\n  \t\ttextLength = Math.min(text1Length, text2Length);\n\n  \t\t// Quick check for the worst case.\n  \t\tif (text1 === text2) {\n  \t\t\treturn textLength;\n  \t\t}\n\n  \t\t// Start by looking for a single character match\n  \t\t// and increase length until no match is found.\n  \t\t// Performance analysis: https://neil.fraser.name/news/2010/11/04/\n  \t\tbest = 0;\n  \t\tlength = 1;\n  \t\twhile (true) {\n  \t\t\tpattern = text1.substring(textLength - length);\n  \t\t\tfound = text2.indexOf(pattern);\n  \t\t\tif (found === -1) {\n  \t\t\t\treturn best;\n  \t\t\t}\n  \t\t\tlength += found;\n  \t\t\tif (found === 0 || text1.substring(textLength - length) === text2.substring(0, length)) {\n  \t\t\t\tbest = length;\n  \t\t\t\tlength++;\n  \t\t\t}\n  \t\t}\n  \t};\n\n  \t/**\n    * Split two texts into an array of strings.  Reduce the texts to a string of\n    * hashes where each Unicode character represents one line.\n    * @param {string} text1 First string.\n    * @param {string} text2 Second string.\n    * @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}\n    *     An object containing the encoded text1, the encoded text2 and\n    *     the array of unique strings.\n    *     The zeroth element of the array of unique strings is intentionally blank.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffLinesToChars = function (text1, text2) {\n  \t\tvar lineArray, lineHash, chars1, chars2;\n  \t\tlineArray = []; // E.g. lineArray[4] === 'Hello\\n'\n  \t\tlineHash = {}; // E.g. lineHash['Hello\\n'] === 4\n\n  \t\t// '\\x00' is a valid character, but various debuggers don't like it.\n  \t\t// So we'll insert a junk entry to avoid generating a null character.\n  \t\tlineArray[0] = \"\";\n\n  \t\t/**\n     * Split a text into an array of strings.  Reduce the texts to a string of\n     * hashes where each Unicode character represents one line.\n     * Modifies linearray and linehash through being a closure.\n     * @param {string} text String to encode.\n     * @return {string} Encoded string.\n     * @private\n     */\n  \t\tfunction diffLinesToCharsMunge(text) {\n  \t\t\tvar chars, lineStart, lineEnd, lineArrayLength, line;\n  \t\t\tchars = \"\";\n\n  \t\t\t// Walk the text, pulling out a substring for each line.\n  \t\t\t// text.split('\\n') would would temporarily double our memory footprint.\n  \t\t\t// Modifying text would create many large strings to garbage collect.\n  \t\t\tlineStart = 0;\n  \t\t\tlineEnd = -1;\n\n  \t\t\t// Keeping our own length variable is faster than looking it up.\n  \t\t\tlineArrayLength = lineArray.length;\n  \t\t\twhile (lineEnd < text.length - 1) {\n  \t\t\t\tlineEnd = text.indexOf(\"\\n\", lineStart);\n  \t\t\t\tif (lineEnd === -1) {\n  \t\t\t\t\tlineEnd = text.length - 1;\n  \t\t\t\t}\n  \t\t\t\tline = text.substring(lineStart, lineEnd + 1);\n  \t\t\t\tlineStart = lineEnd + 1;\n\n  \t\t\t\tvar lineHashExists = lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : lineHash[line] !== undefined;\n\n  \t\t\t\tif (lineHashExists) {\n  \t\t\t\t\tchars += String.fromCharCode(lineHash[line]);\n  \t\t\t\t} else {\n  \t\t\t\t\tchars += String.fromCharCode(lineArrayLength);\n  \t\t\t\t\tlineHash[line] = lineArrayLength;\n  \t\t\t\t\tlineArray[lineArrayLength++] = line;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\treturn chars;\n  \t\t}\n\n  \t\tchars1 = diffLinesToCharsMunge(text1);\n  \t\tchars2 = diffLinesToCharsMunge(text2);\n  \t\treturn {\n  \t\t\tchars1: chars1,\n  \t\t\tchars2: chars2,\n  \t\t\tlineArray: lineArray\n  \t\t};\n  \t};\n\n  \t/**\n    * Rehydrate the text in a diff from a string of line hashes to real lines of\n    * text.\n    * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.\n    * @param {!Array.<string>} lineArray Array of unique strings.\n    * @private\n    */\n  \tDiffMatchPatch.prototype.diffCharsToLines = function (diffs, lineArray) {\n  \t\tvar x, chars, text, y;\n  \t\tfor (x = 0; x < diffs.length; x++) {\n  \t\t\tchars = diffs[x][1];\n  \t\t\ttext = [];\n  \t\t\tfor (y = 0; y < chars.length; y++) {\n  \t\t\t\ttext[y] = lineArray[chars.charCodeAt(y)];\n  \t\t\t}\n  \t\t\tdiffs[x][1] = text.join(\"\");\n  \t\t}\n  \t};\n\n  \t/**\n    * Reorder and merge like edit sections.  Merge equalities.\n    * Any edit section can move as long as it doesn't cross an equality.\n    * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.\n    */\n  \tDiffMatchPatch.prototype.diffCleanupMerge = function (diffs) {\n  \t\tvar pointer, countDelete, countInsert, textInsert, textDelete, commonlength, changes, diffPointer, position;\n  \t\tdiffs.push([DIFF_EQUAL, \"\"]); // Add a dummy entry at the end.\n  \t\tpointer = 0;\n  \t\tcountDelete = 0;\n  \t\tcountInsert = 0;\n  \t\ttextDelete = \"\";\n  \t\ttextInsert = \"\";\n\n  \t\twhile (pointer < diffs.length) {\n  \t\t\tswitch (diffs[pointer][0]) {\n  \t\t\t\tcase DIFF_INSERT:\n  \t\t\t\t\tcountInsert++;\n  \t\t\t\t\ttextInsert += diffs[pointer][1];\n  \t\t\t\t\tpointer++;\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_DELETE:\n  \t\t\t\t\tcountDelete++;\n  \t\t\t\t\ttextDelete += diffs[pointer][1];\n  \t\t\t\t\tpointer++;\n  \t\t\t\t\tbreak;\n  \t\t\t\tcase DIFF_EQUAL:\n\n  \t\t\t\t\t// Upon reaching an equality, check for prior redundancies.\n  \t\t\t\t\tif (countDelete + countInsert > 1) {\n  \t\t\t\t\t\tif (countDelete !== 0 && countInsert !== 0) {\n\n  \t\t\t\t\t\t\t// Factor out any common prefixes.\n  \t\t\t\t\t\t\tcommonlength = this.diffCommonPrefix(textInsert, textDelete);\n  \t\t\t\t\t\t\tif (commonlength !== 0) {\n  \t\t\t\t\t\t\t\tif (pointer - countDelete - countInsert > 0 && diffs[pointer - countDelete - countInsert - 1][0] === DIFF_EQUAL) {\n  \t\t\t\t\t\t\t\t\tdiffs[pointer - countDelete - countInsert - 1][1] += textInsert.substring(0, commonlength);\n  \t\t\t\t\t\t\t\t} else {\n  \t\t\t\t\t\t\t\t\tdiffs.splice(0, 0, [DIFF_EQUAL, textInsert.substring(0, commonlength)]);\n  \t\t\t\t\t\t\t\t\tpointer++;\n  \t\t\t\t\t\t\t\t}\n  \t\t\t\t\t\t\t\ttextInsert = textInsert.substring(commonlength);\n  \t\t\t\t\t\t\t\ttextDelete = textDelete.substring(commonlength);\n  \t\t\t\t\t\t\t}\n\n  \t\t\t\t\t\t\t// Factor out any common suffixies.\n  \t\t\t\t\t\t\tcommonlength = this.diffCommonSuffix(textInsert, textDelete);\n  \t\t\t\t\t\t\tif (commonlength !== 0) {\n  \t\t\t\t\t\t\t\tdiffs[pointer][1] = textInsert.substring(textInsert.length - commonlength) + diffs[pointer][1];\n  \t\t\t\t\t\t\t\ttextInsert = textInsert.substring(0, textInsert.length - commonlength);\n  \t\t\t\t\t\t\t\ttextDelete = textDelete.substring(0, textDelete.length - commonlength);\n  \t\t\t\t\t\t\t}\n  \t\t\t\t\t\t}\n\n  \t\t\t\t\t\t// Delete the offending records and add the merged ones.\n  \t\t\t\t\t\tif (countDelete === 0) {\n  \t\t\t\t\t\t\tdiffs.splice(pointer - countInsert, countDelete + countInsert, [DIFF_INSERT, textInsert]);\n  \t\t\t\t\t\t} else if (countInsert === 0) {\n  \t\t\t\t\t\t\tdiffs.splice(pointer - countDelete, countDelete + countInsert, [DIFF_DELETE, textDelete]);\n  \t\t\t\t\t\t} else {\n  \t\t\t\t\t\t\tdiffs.splice(pointer - countDelete - countInsert, countDelete + countInsert, [DIFF_DELETE, textDelete], [DIFF_INSERT, textInsert]);\n  \t\t\t\t\t\t}\n  \t\t\t\t\t\tpointer = pointer - countDelete - countInsert + (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1;\n  \t\t\t\t\t} else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {\n\n  \t\t\t\t\t\t// Merge this equality with the previous one.\n  \t\t\t\t\t\tdiffs[pointer - 1][1] += diffs[pointer][1];\n  \t\t\t\t\t\tdiffs.splice(pointer, 1);\n  \t\t\t\t\t} else {\n  \t\t\t\t\t\tpointer++;\n  \t\t\t\t\t}\n  \t\t\t\t\tcountInsert = 0;\n  \t\t\t\t\tcountDelete = 0;\n  \t\t\t\t\ttextDelete = \"\";\n  \t\t\t\t\ttextInsert = \"\";\n  \t\t\t\t\tbreak;\n  \t\t\t}\n  \t\t}\n  \t\tif (diffs[diffs.length - 1][1] === \"\") {\n  \t\t\tdiffs.pop(); // Remove the dummy entry at the end.\n  \t\t}\n\n  \t\t// Second pass: look for single edits surrounded on both sides by equalities\n  \t\t// which can be shifted sideways to eliminate an equality.\n  \t\t// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC\n  \t\tchanges = false;\n  \t\tpointer = 1;\n\n  \t\t// Intentionally ignore the first and last element (don't need checking).\n  \t\twhile (pointer < diffs.length - 1) {\n  \t\t\tif (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {\n\n  \t\t\t\tdiffPointer = diffs[pointer][1];\n  \t\t\t\tposition = diffPointer.substring(diffPointer.length - diffs[pointer - 1][1].length);\n\n  \t\t\t\t// This is a single edit surrounded by equalities.\n  \t\t\t\tif (position === diffs[pointer - 1][1]) {\n\n  \t\t\t\t\t// Shift the edit over the previous equality.\n  \t\t\t\t\tdiffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);\n  \t\t\t\t\tdiffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];\n  \t\t\t\t\tdiffs.splice(pointer - 1, 1);\n  \t\t\t\t\tchanges = true;\n  \t\t\t\t} else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) {\n\n  \t\t\t\t\t// Shift the edit over the next equality.\n  \t\t\t\t\tdiffs[pointer - 1][1] += diffs[pointer + 1][1];\n  \t\t\t\t\tdiffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];\n  \t\t\t\t\tdiffs.splice(pointer + 1, 1);\n  \t\t\t\t\tchanges = true;\n  \t\t\t\t}\n  \t\t\t}\n  \t\t\tpointer++;\n  \t\t}\n\n  \t\t// If shifts were made, the diff needs reordering and another shift sweep.\n  \t\tif (changes) {\n  \t\t\tthis.diffCleanupMerge(diffs);\n  \t\t}\n  \t};\n\n  \treturn function (o, n) {\n  \t\tvar diff, output, text;\n  \t\tdiff = new DiffMatchPatch();\n  \t\toutput = diff.DiffMain(o, n);\n  \t\tdiff.diffCleanupEfficiency(output);\n  \t\ttext = diff.diffPrettyHtml(output);\n\n  \t\treturn text;\n  \t};\n  }();\n\n}((function() { return this; }())));\n"
  },
  {
    "path": "test/test.ie.js",
    "content": "\"use strict\";\n\nQUnit.test(\"Basic test\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    var result = qone({ arr: arr }).query(\"\\n        from n in arr   \\n        where n > 3\\n        select n\\n    \");\n\n    assert.deepEqual(result, [4, 5]);\n});\n\nQUnit.test(\"Query json array\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 18\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Multi conditional query\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 10 && n.name = 'linq'\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"linq\", \"age\": 18 }]);\n});\n\nQUnit.test(\"Select test\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age < 20\\n                select n.age, n.name\\n            \");\n\n    assert.deepEqual(result, [[1, \"qone\"], [18, \"linq\"]]);\n});\n\nQUnit.test(\"Select JSON test\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age < 20\\n                select {n.age, n.name}\\n            \");\n\n    assert.deepEqual(result, [{ \"age\": 1, \"name\": \"qone\" }, { \"age\": 18, \"name\": \"linq\" }]);\n});\n\nQUnit.test(\"Select full JSON test\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age < 20\\n                select {a : n.age, b : n.name}\\n            \");\n\n    assert.deepEqual(result, [{ \"a\": 1, \"b\": \"qone\" }, { \"a\": 18, \"b\": \"linq\" }]);\n});\n\nQUnit.test(\"|| conditional test\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 19 ||  n.age < 2\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"|| and && conditional test\", function (assert) {\n    var list = [{ name: 'qone', age: 0 }, { name: 'linq', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 17 || n.age < 2 && n.name != 'dntzhang'\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 0 }, { \"name\": \"linq\", \"age\": 1 }, { \"name\": \"linq\", \"age\": 18 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"(), || and && conditional test\", function (assert) {\n    var list = [{ name: 'qone', age: 0 }, { name: 'linq', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where (n.age > 17 || n.age < 2) && n.name != 'dntzhang'\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 0 }, { \"name\": \"linq\", \"age\": 1 }, { \"name\": \"linq\", \"age\": 18 }]);\n});\n\nQUnit.test(\"Query from prop\", function (assert) {\n    var data = {\n        users: [{ name: 'qone', age: 1 }, { name: 'dntzhang', age: 17 }, { name: 'dntzhang2', age: 27 }]\n    };\n\n    var result = qone({ data: data }).query(\"\\n            from n in data.users        \\n            where n.age < 10\\n            select n\\n        \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 1 }]);\n});\n\nQUnit.test(\"Multi datasource \", function (assert) {\n\n    var listA = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var listB = [{ name: 'x', age: 11 }, { name: 'xx', age: 12 }, { name: 'xxx', age: 13 }];\n\n    var result = qone({ listA: listA, listB: listB }).query(\"\\n            from a in listA     \\n            from b in listB      \\n            where a.age < 20 && b.age > 11\\n            select a, b\\n        \");\n\n    assert.deepEqual(result, [[{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"xx\", \"age\": 12 }], [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"xxx\", \"age\": 13 }], [{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 12 }], [{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xxx\", \"age\": 13 }]]);\n});\n\nQUnit.test(\"Multi datasource with props condition\", function (assert) {\n\n    var listA = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var listB = [{ name: 'x', age: 11 }, { name: 'xx', age: 18 }, { name: 'xxx', age: 13 }];\n\n    var result = qone({ listA: listA, listB: listB }).query(\"\\n            from a in listA     \\n            from b in listB      \\n            where a.age = b.age\\n            select a, b\\n        \");\n\n    assert.deepEqual(result, [[{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 18 }]]);\n});\n\nQUnit.test(\"Bool condition \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }]);\n});\n\nQUnit.test(\"Bool condition \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: [true] }, { name: 'linq', age: 18, isBaby: [false] }, { name: 'dntzhang', age: 28, isBaby: [false] }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby[0]\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: [true] }]);\n});\n\nQUnit.test(\"Multi from test \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true, colors: ['red', 'green', 'blue'] }, { name: 'linq', age: 18, colors: ['red', 'blue'] }, { name: 'dntzhang', age: 28, colors: ['red', 'blue'] }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list   \\n            from c in a.colors   \\n            where c = 'green'\\n            select a, c\\n        \");\n\n    assert.deepEqual(result, [[{ \"name\": \"qone\", \"age\": 1, \"isBaby\": true, \"colors\": [\"red\", \"green\", \"blue\"] }, \"green\"]]);\n});\n\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }, { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] }, { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list   \\n            from c in a.colors   \\n            from d in c.xx  \\n            select a, c,d\\n        \");\n\n    assert.equal(result.length, 18);\n});\n\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }, { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] }, { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list   \\n            from c in a.colors   \\n            from d in c.xx  \\n            where d === 100\\n            select a.name, c,d\\n        \");\n\n    assert.deepEqual(result, [[\"linq\", { \"xx\": [100, 2, 3] }, 100]]);\n});\n\nQUnit.test(\"Deep prop path test \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, fullName: { first: 'q', last: 'one' } }, { name: 'linq', age: 18, fullName: { first: 'l', last: 'inq' } }, { name: 'dntzhang', age: 28, fullName: { first: 'dnt', last: 'zhang' } }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list   \\n            where a.fullName.first === 'dnt'\\n            select a.name\\n        \");\n\n    assert.deepEqual(result, [\"dntzhang\"]);\n});\n\nQUnit.test(\"Method test 1\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  square(n) > 10\\n      select n\\n  \");\n\n    assert.deepEqual(result, [4, 5]);\n});\n\nQUnit.test(\"Method test 2\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  10 >  square(n)\\n      select n\\n  \");\n\n    assert.deepEqual(result, [1, 2, 3]);\n});\n\nQUnit.test(\"Method test 3\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  n > 3\\n      select square(n)\\n  \");\n\n    assert.deepEqual(result, [16, 25]);\n});\n\nQUnit.test(\"Method test 4\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  n > 3\\n      select n, square(n)\\n  \");\n\n    assert.deepEqual(result, [[4, 16], [5, 25]]);\n});\n\nQUnit.test(\"Method test 5\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  n > 3\\n      select { value : n, squareValue : square(n) }\\n  \");\n\n    assert.deepEqual(result, [{ \"value\": 4, \"squareValue\": 16 }, { \"value\": 5, \"squareValue\": 25 }]);\n});\n\nQUnit.test(\"Method test 6\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  n > 3\\n      select { squareValue : square(n) }\\n  \");\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }]);\n});\n\nQUnit.test(\"Method test 7\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  n > 3\\n      select { squareValue : square(n) }\\n  \");\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }]);\n});\n\nQUnit.test(\"Method test 8\", function (assert) {\n    var arr = [1, 2, 3, 4, 5];\n\n    qone('square', function (num) {\n        return num * num;\n    });\n\n    qone('sqrt', function (num) {\n        return Math.sqrt(num);\n    });\n\n    var result = qone({ arr: arr }).query(\"\\n      from n in arr   \\n      where  sqrt(n) >= 2 \\n      select { squareValue : square(n) }\\n  \");\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }]);\n});\n\nQUnit.test(\"Method test 9\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 19 }, { name: 'dntzhang', age: 28 }];\n\n    qone('greaterThan18', function (num) {\n        return num > 18;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where greaterThan18(n.age) && n.name = 'dntzhang'\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Method test 10\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 19 }, { name: 'dntzhang', age: 28 }];\n\n    qone('greaterThan18', function (num) {\n        return num > 18;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where greaterThan18(n.age) && n.name = 'dntzhang'\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Order by test 1\", function (assert) {\n    var list = [{ name: 'linq2', age: 7 }, { name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 0\\n                orderby n.age desc\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }, { \"name\": \"linq\", \"age\": 18 }, { \"name\": \"linq2\", \"age\": 7 }, { \"name\": \"qone\", \"age\": 1 }]);\n});\n\nQUnit.test(\"Order by test 2\", function (assert) {\n    var list = [{ name: 'linq2', age: 7 }, { name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'ainq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 0\\n                orderby n.age asc, n.name desc\\n                select n\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"linq2\", \"age\": 7 }, { \"name\": \"linq\", \"age\": 18 }, { \"name\": \"ainq\", \"age\": 18 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Order by test 3\", function (assert) {\n    var list = [{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 2 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang3', age: 29, age2: 1 }];\n\n    qone('sum', function (a, b) {\n        return a + b;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                  from n in list   \\n                  where n.age > 0\\n                  orderby sum(n.age,n.age2) \\n                  select n\\n              \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 2 }, { name: 'dntzhang3', age: 29, age2: 1 }]);\n});\n\nQUnit.test(\"Order by test 4\", function (assert) {\n    var list = [{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 2 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang3', age: 29, age2: 1 }];\n\n    qone('sum', function (a, b) {\n        return a + b;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                  from n in list   \\n                  where n.age > 0\\n                  orderby sum(n.age,n.age2) ,n.name\\n                  select n\\n              \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18, age2: 1 }, { name: 'qone', age: 17, age2: 2 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 2 }, { name: 'dntzhang3', age: 29, age2: 1 }]);\n});\n\nQUnit.test(\"Simple groupby test 1\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'linq', age: 18 }, { name: 'dntzhang1', age: 28 }, { name: 'dntzhang2', age: 28 }, { name: 'dntzhang3', age: 29 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 18\\n                groupby n.age\\n            \");\n\n    assert.deepEqual(result, [[{ \"name\": \"dntzhang1\", \"age\": 28 }, { \"name\": \"dntzhang2\", \"age\": 28 }], [{ \"name\": \"dntzhang3\", \"age\": 29 }]]);\n});\n\nQUnit.test(\"Simple groupby test 2\", function (assert) {\n    var list = [{ name: 'qone', age: 1 }, { name: 'qone', age: 1 }, { name: 'dntzhang', age: 28 }, { name: 'dntzhang2', age: 28 }, { name: 'dntzhang', age: 29 }];\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                where n.age > 0\\n                groupby n.age,n.name\\n            \");\n\n    assert.deepEqual(result, [[{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"qone\", \"age\": 1 }], [{ \"name\": \"dntzhang\", \"age\": 28 }], [{ \"name\": \"dntzhang2\", \"age\": 28 }], [{ \"name\": \"dntzhang\", \"age\": 29 }]]);\n});\n\nQUnit.test(\"Simple groupby with method\", function (assert) {\n    var list = [{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 1 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang3', age: 29, age2: 1 }];\n    qone('sum', function (a, b) {\n        return a + b;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                groupby sum(n.age,n.age2)\\n            \");\n\n    assert.deepEqual(result, [[{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }], [{ name: 'dntzhang1', age: 28, age2: 1 }, { name: 'dntzhang2', age: 28, age2: 1 }], [{ name: 'dntzhang3', age: 29, age2: 1 }]]);\n});\n\nQUnit.test(\"Simple groupby with method\", function (assert) {\n    var list = [{ name: 'qone', age: 17, age2: 2 }, { name: 'qone', age: 18, age2: 1 }, { name: 'dntzhang1', age: 28, age2: 1 }, { name: 'dntzhang2', age: 28, age2: 1 }, { name: 'dntzhang3', age: 29, age2: 1 }];\n    qone('sum', function (a, b) {\n        return a + b;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                from n in list   \\n                groupby sum(n.age,n.age2), n.name\\n            \");\n\n    assert.deepEqual(result, [[{ name: 'qone', age: 17, age2: 2 }, { name: 'qone', age: 18, age2: 1 }], [{ name: 'dntzhang1', age: 28, age2: 1 }], [{ name: 'dntzhang2', age: 28, age2: 1 }], [{ name: 'dntzhang3', age: 29, age2: 1 }]]);\n});\n\nQUnit.test(\"Bool condition 1 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where !a.isBaby\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Bool condition 2 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from a in list       \\n                where !a.isBaby && a.name='qone'\\n                select a\\n            \");\n\n    assert.deepEqual(result, []);\n});\n\nQUnit.test(\"Bool condition 3 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where !(a.isBaby && a.name='qone') \\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Bool condition 4 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from a in list       \\n                where !(a.isBaby && a.name='qone') && a.age = 28\\n                select a\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Bool condition 5 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = true\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }]);\n});\n\nQUnit.test(\"Bool condition 6 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = true\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }]);\n});\n\nQUnit.test(\"Bool condition 7 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = true\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }]);\n});\n\nQUnit.test(\"Bool condition 8 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = undefined\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }]);\n});\n\nQUnit.test(\"Bool condition 9 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: false }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = false\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: false }]);\n});\n\nQUnit.test(\"Bool condition 10 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: null }];\n\n    var result = qone({ list: list }).query(\"\\n            from a in list       \\n            where a.isBaby = false || a.isBaby = null\\n            select a\\n        \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: null }]);\n});\n\nQUnit.test(\"Bool condition 11 \", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from a in list       \\n                where !((a.isBaby && a.name='qone') && a.age = 28)\\n                select a\\n            \");\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 1, \"isBaby\": true }, { \"name\": \"linq\", \"age\": 18 }, { \"name\": \"dntzhang\", \"age\": 28 }]);\n});\n\nQUnit.test(\"Bool condition 12\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from a in list       \\n                where !((a.isBaby && a.name='qone') && ((a.age = 28)||!a.isBaby))\\n                select a\\n            \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }]);\n});\n\nQUnit.test(\"Bool condition 13\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, isBaby: true }, { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }];\n\n    var result = qone({ list: list }).query(\"\\n                from a in list       \\n                where ((a.isBaby && a.name='qone') && !((a.age = 28)||!a.isBaby))\\n                select a\\n            \");\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }]);\n});\n\nQUnit.test(\"Method test\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, scores: [1, 2, 3] }, { name: 'linq', age: 18, scores: [11, 2, 3] }, { name: 'dntzhang', age: 28, scores: [100, 2, 3] }];\n\n    qone('fullCredit', function (item) {\n        return item[0] === 100;\n    });\n\n    var result = qone({ list: list }).query(\"\\n                    from a in list       \\n                    where fullCredit(a.scores)\\n                    select a\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang', age: 28, scores: [100, 2, 3] }]);\n});\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, scores: [1, 2, 3] }, { name: 'linq', age: 18, scores: [11, 2, 3] }, { name: 'dntzhang', age: 28, scores: [100, 2, 3] }];\n\n    var result = qone({ list: list }).query(\"\\n                    from a in list       \\n                    where a.scores[0] === 100\\n                    select a\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang', age: 28, scores: [100, 2, 3] }]);\n});\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, scores: [{ a: 1 }, 2, 3] }, { name: 'linq', age: 18, scores: [{ a: 2 }, 2, 3] }, { name: 'dntzhang', age: 28, scores: [{ a: 3 }, 2, 3] }];\n\n    var result = qone({ list: list }).query(\"\\n                    from a in list       \\n                    where a.scores[0].a === 3\\n                    select a\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang', age: 28, scores: [{ a: 3 }, 2, 3] }]);\n});\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, scores: [[1, 2], 2, 3] }, { name: 'linq', age: 18, scores: [[3, 4], 2, 3] }, { name: 'dntzhang', age: 28, scores: [[5, 6], 2, 3] }];\n\n    var result = qone({ list: list }).query(\"\\n                    from a in list       \\n                    where a.scores[0][1] === 6\\n                    select a\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang', age: 28, scores: [[5, 6], 2, 3] }]);\n});\n\nQUnit.test(\"Method test\", function (assert) {\n\n    var list = [{ name: 'qone', age: 1, scores: [1, 2, 3] }, { name: 'linq', age: 18, scores: [11, 2, 3] }, { name: 'dntzhang', age: 28, scores: [100, 2, 3] }];\n\n    qone('fullCredit', function (item, x, y) {\n        return item[0] * x + y === '22abc';\n    });\n\n    var result = qone({ list: list }).query(\"\\n                    from a in list       \\n                    where fullCredit(a.scores, 2, \\\"abc\\\")\\n                    select a\\n                \");\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18, scores: [11, 2, 3] }]);\n});\n\nQUnit.test(\"Single line test\", function (assert) {\n    var list = [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }, { name: 'dntzhang9', age: 9 }, { name: 'dntzhang10', age: 10 }];\n\n    var result = qone({ list: list }).query('from n in list where n.age > 1 select n limit 1, 3');\n\n    assert.deepEqual(result, [{ name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }]);\n});\n\nQUnit.test(\"Limit one page test\", function (assert) {\n    var list = [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }, { name: 'dntzhang9', age: 9 }, { name: 'dntzhang10', age: 10 }];\n\n    var pageIndex = 1,\n        pageSize = 4;\n    var result = qone({ list: list }).query(\"\\n                    from n in list   \\n                    where n.age > 0\\n                    select n\\n                    limit \" + pageIndex * pageSize + \", \" + pageSize + \"\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }]);\n});\n\nQUnit.test(\"Limit top 3\", function (assert) {\n    var list = [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }, { name: 'dntzhang9', age: 9 }, { name: 'dntzhang10', age: 10 }];\n\n    var pageIndex = 1,\n        pageSize = 4;\n    var result = qone({ list: list }).query(\"\\n                    from n in list   \\n                    select n\\n                    limit 0, 3\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }]);\n});\n\nQUnit.test(\"Limit top 13\", function (assert) {\n    var list = [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }, { name: 'dntzhang9', age: 9 }, { name: 'dntzhang10', age: 10 }];\n\n    var pageIndex = 1,\n        pageSize = 4;\n    var result = qone({ list: list }).query(\"\\n                    from n in list   \\n                    select n\\n                    limit 0, 13\\n                \");\n\n    assert.deepEqual(result, [{ name: 'dntzhang1', age: 1 }, { name: 'dntzhang2', age: 2 }, { name: 'dntzhang3', age: 3 }, { name: 'dntzhang4', age: 4 }, { name: 'dntzhang5', age: 5 }, { name: 'dntzhang6', age: 6 }, { name: 'dntzhang7', age: 7 }, { name: 'dntzhang8', age: 8 }, { name: 'dntzhang9', age: 9 }, { name: 'dntzhang10', age: 10 }]);\n});"
  },
  {
    "path": "test/test.js",
    "content": "\nQUnit.test(\"Basic test\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    var result = qone({ arr }).query(`\n        from n in arr   \n        where n > 3\n        select n\n    `)\n\n    assert.deepEqual(result, [4, 5])\n})\n\nQUnit.test(\"Query json array\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 18\n                select n\n            `)\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n\n})\n\nQUnit.test(\"Multi conditional query\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 10 && n.name = 'linq'\n                select n\n            `)\n\n    assert.deepEqual(result, [{ \"name\": \"linq\", \"age\": 18 }])\n\n})\n\nQUnit.test(\"Select test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age < 20\n                select n.age, n.name\n            `)\n\n    assert.deepEqual(result, [[1, \"qone\"], [18, \"linq\"]])\n\n})\n\nQUnit.test(\"Select JSON test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age < 20\n                select {n.age, n.name}\n            `)\n\n    assert.deepEqual(result, [\n        { \"age\": 1, \"name\": \"qone\" },\n        { \"age\": 18, \"name\": \"linq\" }\n    ])\n\n})\n\nQUnit.test(\"Select full JSON test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age < 20\n                select {a : n.age, b : n.name}\n            `)\n\n    assert.deepEqual(result, [\n        { \"a\": 1, \"b\": \"qone\" },\n        { \"a\": 18, \"b\": \"linq\" }\n    ])\n\n})\n\nQUnit.test(\"|| conditional test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 19 ||  n.age < 2\n                select n\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"qone\", \"age\": 1 },\n        { \"name\": \"dntzhang\", \"age\": 28 }\n    ])\n\n})\n\nQUnit.test(\"|| and && conditional test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 0 },\n        { name: 'linq', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 17 || n.age < 2 && n.name != 'dntzhang'\n                select n\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"qone\", \"age\": 0 },\n        { \"name\": \"linq\", \"age\": 1 },\n        { \"name\": \"linq\", \"age\": 18 },\n        { \"name\": \"dntzhang\", \"age\": 28 }])\n\n})\n\nQUnit.test(\"(), || and && conditional test\", function (assert) {\n    var list = [\n        { name: 'qone', age: 0 },\n        { name: 'linq', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where (n.age > 17 || n.age < 2) && n.name != 'dntzhang'\n                select n\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"qone\", \"age\": 0 },\n        { \"name\": \"linq\", \"age\": 1 },\n        { \"name\": \"linq\", \"age\": 18 }])\n\n})\n\n\nQUnit.test(\"Query from prop\", function (assert) {\n    var data = {\n        users: [\n            { name: 'qone', age: 1 },\n            { name: 'dntzhang', age: 17 },\n            { name: 'dntzhang2', age: 27 }]\n    }\n\n    var result = qone({ data }).query(`\n            from n in data.users        \n            where n.age < 10\n            select n\n        `)\n\n    assert.deepEqual(result, [{ \"name\": \"qone\", \"age\": 1 }])\n\n})\n\n\nQUnit.test(\"Multi datasource \", function (assert) {\n\n    var listA = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n\n    var listB = [\n        { name: 'x', age: 11 },\n        { name: 'xx', age: 12 },\n        { name: 'xxx', age: 13 }\n    ]\n\n\n    var result = qone({ listA, listB }).query(`\n            from a in listA     \n            from b in listB      \n            where a.age < 20 && b.age > 11\n            select a, b\n        `)\n\n    assert.deepEqual(result, [\n        [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"xx\", \"age\": 12 }],\n        [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"xxx\", \"age\": 13 }],\n        [{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 12 }],\n        [{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xxx\", \"age\": 13 }]])\n})\n\nQUnit.test(\"Multi datasource with props condition\", function (assert) {\n\n    var listA = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n\n    var listB = [\n        { name: 'x', age: 11 },\n        { name: 'xx', age: 18 },\n        { name: 'xxx', age: 13 }\n    ]\n\n    var result = qone({ listA, listB }).query(`\n            from a in listA     \n            from b in listB      \n            where a.age = b.age\n            select a, b\n        `)\n\n    assert.deepEqual(result, [[{ \"name\": \"linq\", \"age\": 18 }, { \"name\": \"xx\", \"age\": 18 }]])\n})\n\nQUnit.test(\"Bool condition \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby\n            select a\n        `)\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }])\n})\n\nQUnit.test(\"Bool condition \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: [true] },\n        { name: 'linq', age: 18, isBaby: [false] },\n        { name: 'dntzhang', age: 28, isBaby: [false] }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby[0]\n            select a\n        `)\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: [true] }])\n})\n\n\n\nQUnit.test(\"Multi from test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true, colors: ['red', 'green', 'blue'] },\n        { name: 'linq', age: 18, colors: ['red', 'blue'] },\n        { name: 'dntzhang', age: 28, colors: ['red', 'blue'] }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            from c in a.colors   \n            where c = 'green'\n            select a, c\n        `)\n\n    assert.deepEqual(result, [[{ \"name\": \"qone\", \"age\": 1, \"isBaby\": true, \"colors\": [\"red\", \"green\", \"blue\"] }, \"green\"]])\n})\n\n\n\n\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            from c in a.colors   \n            from d in c.xx  \n            select a, c,d\n        `)\n\n    assert.equal(result.length, 18)\n})\n\n\nQUnit.test(\"Multi deep from test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'linq', age: 18, colors: [{ xx: [100, 2, 3] }, { xx: [11, 2, 3] }] },\n        { name: 'dntzhang', age: 28, colors: [{ xx: [1, 2, 3] }, { xx: [11, 2, 3] }] }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            from c in a.colors   \n            from d in c.xx  \n            where d === 100\n            select a.name, c,d\n        `)\n\n    assert.deepEqual(result, [[\"linq\", { \"xx\": [100, 2, 3] }, 100]])\n})\n\nQUnit.test(\"Deep prop path test \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, fullName: { first: 'q', last: 'one' } },\n        { name: 'linq', age: 18, fullName: { first: 'l', last: 'inq' } },\n        { name: 'dntzhang', age: 28, fullName: { first: 'dnt', last: 'zhang' } }]\n\n    var result = qone({ list }).query(`\n            from a in list   \n            where a.fullName.first === 'dnt'\n            select a.name\n        `)\n\n    assert.deepEqual(result, [\"dntzhang\"])\n})\n\n\nQUnit.test(\"Method test 1\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  square(n) > 10\n      select n\n  `)\n\n    assert.deepEqual(result, [4, 5])\n})\n\n\nQUnit.test(\"Method test 2\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  10 >  square(n)\n      select n\n  `)\n\n    assert.deepEqual(result, [1, 2, 3])\n})\n\n\nQUnit.test(\"Method test 3\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  n > 3\n      select square(n)\n  `)\n\n    assert.deepEqual(result, [16, 25])\n})\n\nQUnit.test(\"Method test 4\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  n > 3\n      select n, square(n)\n  `)\n\n    assert.deepEqual(result, [[4, 16], [5, 25]])\n})\n\n\nQUnit.test(\"Method test 5\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  n > 3\n      select { value : n, squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [\n        { \"value\": 4, \"squareValue\": 16 },\n        { \"value\": 5, \"squareValue\": 25 }])\n})\n\nQUnit.test(\"Method test 6\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  n > 3\n      select { squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }])\n})\n\nQUnit.test(\"Method test 7\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  n > 3\n      select { squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }])\n})\n\nQUnit.test(\"Method test 8\", function (assert) {\n    var arr = [1, 2, 3, 4, 5]\n\n    qone('square', function (num) {\n        return num * num\n    })\n\n    qone('sqrt', function (num) {\n        return Math.sqrt(num)\n    })\n\n    var result = qone({ arr }).query(`\n      from n in arr   \n      where  sqrt(n) >= 2 \n      select { squareValue : square(n) }\n  `)\n\n    assert.deepEqual(result, [{ \"squareValue\": 16 }, { \"squareValue\": 25 }])\n})\n\nQUnit.test(\"Method test 9\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 19 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    qone('greaterThan18', function (num) {\n        return num > 18\n    })\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where greaterThan18(n.age) && n.name = 'dntzhang'\n                select n\n            `)\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n\n})\n\nQUnit.test(\"Method test 10\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 19 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    qone('greaterThan18', function (num) {\n        return num > 18\n    })\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where greaterThan18(n.age) && n.name = 'dntzhang'\n                select n\n            `)\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n\n})\n\nQUnit.test(\"Order by test 1\", function (assert) {\n    var list = [\n        { name: 'linq2', age: 7 },\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 0\n                orderby n.age desc\n                select n\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"dntzhang\", \"age\": 28 },\n        { \"name\": \"linq\", \"age\": 18 },\n        { \"name\": \"linq2\", \"age\": 7 },\n        { \"name\": \"qone\", \"age\": 1 }])\n\n})\n\nQUnit.test(\"Order by test 2\", function (assert) {\n    var list = [\n        { name: 'linq2', age: 7 },\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'ainq', age: 18 },\n        { name: 'dntzhang', age: 28 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 0\n                orderby n.age asc, n.name desc\n                select n\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"qone\", \"age\": 1 },\n        { \"name\": \"linq2\", \"age\": 7 },\n        { \"name\": \"linq\", \"age\": 18 },\n        { \"name\": \"ainq\", \"age\": 18 },\n        { \"name\": \"dntzhang\", \"age\": 28 }])\n\n})\n\n\n\nQUnit.test(\"Order by test 3\", function (assert) {\n    var list = [\n        { name: 'qone', age: 17, age2: 2 },\n        { name: 'linq', age: 18, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 2 },\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang3', age: 29, age2: 1 }\n    ]\n\n    qone('sum', function (a, b) {\n        return a + b\n    })\n\n\n    var result = qone({ list }).query(`\n                  from n in list   \n                  where n.age > 0\n                  orderby sum(n.age,n.age2) \n                  select n\n              `)\n\n    assert.deepEqual(result, [\n        { name: 'qone', age: 17, age2: 2 },\n        { name: 'linq', age: 18, age2: 1 },\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 2 },\n        { name: 'dntzhang3', age: 29, age2: 1 }])\n\n})\n\n\nQUnit.test(\"Order by test 4\", function (assert) {\n    var list = [\n        { name: 'qone', age: 17, age2: 2 },\n        { name: 'linq', age: 18, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 2 },\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang3', age: 29, age2: 1 }\n    ]\n\n    qone('sum', function (a, b) {\n        return a + b\n    })\n\n\n    var result = qone({ list }).query(`\n                  from n in list   \n                  where n.age > 0\n                  orderby sum(n.age,n.age2) ,n.name\n                  select n\n              `)\n\n    assert.deepEqual(result, [\n        { name: 'linq', age: 18, age2: 1 },\n        { name: 'qone', age: 17, age2: 2 },\n\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 2 },\n        { name: 'dntzhang3', age: 29, age2: 1 }])\n\n})\n\nQUnit.test(\"Simple groupby test 1\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang1', age: 28 },\n        { name: 'dntzhang2', age: 28 },\n        { name: 'dntzhang3', age: 29 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 18\n                groupby n.age\n            `)\n\n    assert.deepEqual(result, [\n        [{ \"name\": \"dntzhang1\", \"age\": 28 }, { \"name\": \"dntzhang2\", \"age\": 28 }],\n        [{ \"name\": \"dntzhang3\", \"age\": 29 }]])\n\n})\n\nQUnit.test(\"Simple groupby test 2\", function (assert) {\n    var list = [\n        { name: 'qone', age: 1 },\n        { name: 'qone', age: 1 },\n        { name: 'dntzhang', age: 28 },\n        { name: 'dntzhang2', age: 28 },\n        { name: 'dntzhang', age: 29 }\n    ]\n\n    var result = qone({ list }).query(`\n                from n in list   \n                where n.age > 0\n                groupby n.age,n.name\n            `)\n\n    assert.deepEqual(result, [\n        [{ \"name\": \"qone\", \"age\": 1 }, { \"name\": \"qone\", \"age\": 1 }],\n        [{ \"name\": \"dntzhang\", \"age\": 28 }],\n        [{ \"name\": \"dntzhang2\", \"age\": 28 }],\n        [{ \"name\": \"dntzhang\", \"age\": 29 }]])\n\n})\n\nQUnit.test(\"Simple groupby with method\", function (assert) {\n    var list = [\n        { name: 'qone', age: 17, age2: 2 },\n        { name: 'linq', age: 18, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 1 },\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang3', age: 29, age2: 1 }\n    ]\n    qone('sum', function (a, b) {\n        return a + b\n    })\n\n\n    var result = qone({ list }).query(`\n                from n in list   \n                groupby sum(n.age,n.age2)\n            `)\n\n    assert.deepEqual(result, [\n        [{ name: 'qone', age: 17, age2: 2 }, { name: 'linq', age: 18, age2: 1 }],\n        [{ name: 'dntzhang1', age: 28, age2: 1 }, { name: 'dntzhang2', age: 28, age2: 1 }],\n        [{ name: 'dntzhang3', age: 29, age2: 1 }]])\n\n})\n\n\nQUnit.test(\"Simple groupby with method\", function (assert) {\n    var list = [\n        { name: 'qone', age: 17, age2: 2 },\n        { name: 'qone', age: 18, age2: 1 },\n        { name: 'dntzhang1', age: 28, age2: 1 },\n        { name: 'dntzhang2', age: 28, age2: 1 },\n        { name: 'dntzhang3', age: 29, age2: 1 }\n    ]\n    qone('sum', function (a, b) {\n        return a + b\n    })\n\n\n    var result = qone({ list }).query(`\n                from n in list   \n                groupby sum(n.age,n.age2), n.name\n            `)\n\n    assert.deepEqual(result, [\n        [{ name: 'qone', age: 17, age2: 2 }, { name: 'qone', age: 18, age2: 1 }],\n        [{ name: 'dntzhang1', age: 28, age2: 1 }],\n        [{ name: 'dntzhang2', age: 28, age2: 1 }],\n        [{ name: 'dntzhang3', age: 29, age2: 1 }]])\n\n})\n\nQUnit.test(\"Bool condition 1 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where !a.isBaby\n            select a\n        `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"linq\", \"age\": 18 },\n        { \"name\": \"dntzhang\", \"age\": 28 }])\n})\n\n\n\nQUnit.test(\"Bool condition 2 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n                from a in list       \n                where !a.isBaby && a.name='qone'\n                select a\n            `)\n\n    assert.deepEqual(result, [])\n})\n\n\nQUnit.test(\"Bool condition 3 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where !(a.isBaby && a.name='qone') \n            select a\n        `)\n\n\n    assert.deepEqual(result, [{ name: 'linq', age: 18 }, { \"name\": \"dntzhang\", \"age\": 28 }])\n})\n\n\nQUnit.test(\"Bool condition 4 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n                from a in list       \n                where !(a.isBaby && a.name='qone') && a.age = 28\n                select a\n            `)\n\n\n    assert.deepEqual(result, [{ \"name\": \"dntzhang\", \"age\": 28 }])\n})\n\n\nQUnit.test(\"Bool condition 5 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = true\n            select a\n        `)\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }])\n})\n\n\n\nQUnit.test(\"Bool condition 6 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = true\n            select a\n        `)\n\n    assert.deepEqual(result, [{ name: 'qone', age: 1, isBaby: true }])\n})\n\nQUnit.test(\"Bool condition 7 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = true\n            select a\n        `)\n\n    assert.deepEqual(result, [\n        { name: 'qone', age: 1, isBaby: true }])\n})\n\nQUnit.test(\"Bool condition 8 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = undefined\n            select a\n        `)\n\n    assert.deepEqual(result, [\n        { name: 'linq', age: 18 }, { name: 'dntzhang', age: 28 }])\n})\n\nQUnit.test(\"Bool condition 9 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18, isBaby: false },\n        { name: 'dntzhang', age: 28, isBaby: false }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = false\n            select a\n        `)\n\n    assert.deepEqual(result, [\n        { name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: false }])\n})\n\nQUnit.test(\"Bool condition 10 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18, isBaby: false },\n        { name: 'dntzhang', age: 28, isBaby: null }]\n\n    var result = qone({ list }).query(`\n            from a in list       \n            where a.isBaby = false || a.isBaby = null\n            select a\n        `)\n\n    assert.deepEqual(result, [\n        { name: 'linq', age: 18, isBaby: false }, { name: 'dntzhang', age: 28, isBaby: null }])\n})\n\nQUnit.test(\"Bool condition 11 \", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n                from a in list       \n                where !((a.isBaby && a.name='qone') && a.age = 28)\n                select a\n            `)\n\n    assert.deepEqual(result, [\n        { \"name\": \"qone\", \"age\": 1, \"isBaby\": true },\n        { \"name\": \"linq\", \"age\": 18 },\n        { \"name\": \"dntzhang\", \"age\": 28 }])\n})\n\n\nQUnit.test(\"Bool condition 12\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n                from a in list       \n                where !((a.isBaby && a.name='qone') && ((a.age = 28)||!a.isBaby))\n                select a\n            `)\n\n    assert.deepEqual(result, [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }])\n})\n\n\nQUnit.test(\"Bool condition 13\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, isBaby: true },\n        { name: 'linq', age: 18 },\n        { name: 'dntzhang', age: 28 }]\n\n    var result = qone({ list }).query(`\n                from a in list       \n                where ((a.isBaby && a.name='qone') && !((a.age = 28)||!a.isBaby))\n                select a\n            `)\n\n    assert.deepEqual(result, [\n        { name: 'qone', age: 1, isBaby: true }])\n})\n\n\nQUnit.test(\"Method test\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, scores: [1, 2, 3] },\n        { name: 'linq', age: 18, scores: [11, 2, 3] },\n        { name: 'dntzhang', age: 28, scores: [100, 2, 3] }]\n\n    qone('fullCredit', function (item) {\n        return item[0] === 100\n    })\n\n    var result = qone({ list }).query(`\n                    from a in list       \n                    where fullCredit(a.scores)\n                    select a\n                `)\n\n    assert.deepEqual(result, [\n        { name: 'dntzhang', age: 28, scores: [100, 2, 3] }])\n})\n\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, scores: [1, 2, 3] },\n        { name: 'linq', age: 18, scores: [11, 2, 3] },\n        { name: 'dntzhang', age: 28, scores: [100, 2, 3] }]\n\n\n    var result = qone({ list }).query(`\n                    from a in list       \n                    where a.scores[0] === 100\n                    select a\n                `)\n\n    assert.deepEqual(result, [\n        { name: 'dntzhang', age: 28, scores: [100, 2, 3] }])\n})\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, scores: [{ a: 1 }, 2, 3] },\n        { name: 'linq', age: 18, scores: [{ a: 2 }, 2, 3] },\n        { name: 'dntzhang', age: 28, scores: [{ a: 3 }, 2, 3] }]\n\n\n    var result = qone({ list }).query(`\n                    from a in list       \n                    where a.scores[0].a === 3\n                    select a\n                `)\n\n    assert.deepEqual(result, [\n        { name: 'dntzhang', age: 28, scores: [{ a: 3 }, 2, 3] }])\n})\n\n\nQUnit.test(\"Access array\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, scores: [[1, 2], 2, 3] },\n        { name: 'linq', age: 18, scores: [[3, 4], 2, 3] },\n        { name: 'dntzhang', age: 28, scores: [[5, 6], 2, 3] }]\n\n\n    var result = qone({ list }).query(`\n                    from a in list       \n                    where a.scores[0][1] === 6\n                    select a\n                `)\n\n    assert.deepEqual(result, [\n        { name: 'dntzhang', age: 28, scores: [[5, 6], 2, 3] }])\n})\n\n\nQUnit.test(\"Method test\", function (assert) {\n\n    var list = [\n        { name: 'qone', age: 1, scores: [1, 2, 3] },\n        { name: 'linq', age: 18, scores: [11, 2, 3] },\n        { name: 'dntzhang', age: 28, scores: [100, 2, 3] }]\n\n    qone('fullCredit', function (item, x, y) {\n        return item[0] * x + y === '22abc'\n    })\n\n    var result = qone({ list }).query(`\n                    from a in list       \n                    where fullCredit(a.scores, 2, \"abc\")\n                    select a\n                `)\n\n    assert.deepEqual(result, [\n        { name: 'linq', age: 18, scores: [11, 2, 3] }])\n})\n\n\nQUnit.test(\"Single line test\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n\n    ]\n\n    var result = qone({ list }).query('from n in list where n.age > 1 select n limit 1, 3')\n\n\n    assert.deepEqual(result, [\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 }])\n\n})\n\n\nQUnit.test(\"Limit one page test\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    where n.age > 0\n                    select n\n                    limit ${pageIndex * pageSize}, ${pageSize}\n                `)\n\n\n    assert.deepEqual(result, [{ name: 'dntzhang5', age: 5 },\n    { name: 'dntzhang6', age: 6 },\n    { name: 'dntzhang7', age: 7 },\n    { name: 'dntzhang8', age: 8 }])\n\n})\n\n\nQUnit.test(\"Limit top 3\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    select n\n                    limit 0, 3\n                `)\n\n\n    assert.deepEqual(result, [\n\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 }\n    ])\n\n})\n\n\n\n\nQUnit.test(\"Limit top 13\", function (assert) {\n    var list = [\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ]\n\n    var pageIndex = 1,\n        pageSize = 4\n    var result = qone({ list }).query(`\n                    from n in list   \n                    select n\n                    limit 0, 13\n                `)\n\n\n    assert.deepEqual(result, [\n\n        { name: 'dntzhang1', age: 1 },\n        { name: 'dntzhang2', age: 2 },\n        { name: 'dntzhang3', age: 3 },\n        { name: 'dntzhang4', age: 4 },\n        { name: 'dntzhang5', age: 5 },\n        { name: 'dntzhang6', age: 6 },\n        { name: 'dntzhang7', age: 7 },\n        { name: 'dntzhang8', age: 8 },\n        { name: 'dntzhang9', age: 9 },\n        { name: 'dntzhang10', age: 10 }\n    ])\n\n})"
  }
]