{
"tiddlers": {
"$:/config/EditorTypeMappings/image/gif": {
"title": "$:/config/EditorTypeMappings/image/gif",
"text": "bitmap"
},
"$:/config/EditorTypeMappings/image/jpeg": {
"title": "$:/config/EditorTypeMappings/image/jpeg",
"text": "bitmap"
},
"$:/config/EditorTypeMappings/image/jpg": {
"title": "$:/config/EditorTypeMappings/image/jpg",
"text": "bitmap"
},
"$:/config/EditorTypeMappings/image/png": {
"title": "$:/config/EditorTypeMappings/image/png",
"text": "bitmap"
},
"$:/config/EditorTypeMappings/image/x-icon": {
"title": "$:/config/EditorTypeMappings/image/x-icon",
"text": "bitmap"
},
"$:/config/EditorTypeMappings/text/vnd.tiddlywiki": {
"title": "$:/config/EditorTypeMappings/text/vnd.tiddlywiki",
"text": "text"
},
"$:/core/copyright.txt": {
"title": "$:/core/copyright.txt",
"type": "text/plain",
"text": "TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)\n\nCopyright © Jeremy Ruston 2004-2007\nCopyright © UnaMesa Association 2007-2014\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this\nlist of conditions and the following disclaimer in the documentation and/or other\nmaterials provided with the distribution.\n\nNeither the name of the UnaMesa Association nor the names of its contributors may be\nused to endorse or promote products derived from this software without specific\nprior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT\nSHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGE.\n"
},
"$:/core/images/cancel-button": {
"title": "$:/core/images/cancel-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-cancel-button tw-image-button\" viewBox=\"366 150 58 58\" width=\"22pt\" height=\"22pt\"><path d=\"M 414.76236 158.98764 C 403.77887 148.0041 385.97113 148.0041 374.98764 158.98764 C 364.0041 169.97113 364.0041 187.77887 374.98764 198.76236 C 385.97113 209.7459 403.77887 209.7459 414.76236 198.76236 C 425.7459 187.77887 425.7459 169.97113 414.76236 158.98764 M 385.3967 165.32954 L 385.3967 165.32954 L 394.77674 174.7096 L 404.3533 165.13303 C 405.53068 163.95566 407.4396 163.95566 408.61697 165.13303 C 409.79434 166.31041 409.79434 168.21932 408.61697 169.39669 L 399.0404 178.97325 L 408.42046 188.35331 C 409.59783 189.53068 409.59783 191.43959 408.42046 192.61697 L 408.42046 192.61697 C 407.24308 193.79434 405.33417 193.79434 404.1568 192.61697 L 394.77675 183.23692 L 385.5932 192.42046 C 384.41583 193.59783 382.50692 193.59783 381.32954 192.42046 L 381.32954 192.42046 C 380.15217 191.24308 380.15217 189.33417 381.32954 188.1568 C 381.32954 188.1568 381.32954 188.1568 381.32954 188.1568 L 381.32954 188.1568 L 381.32954 188.1568 L 390.51309 178.97326 L 381.13303 169.5932 C 379.95566 168.41583 379.95566 166.50692 381.13303 165.32954 L 381.13303 165.32954 C 382.3104 164.15217 384.21932 164.15217 385.3967 165.32954 C 385.3967 165.32954 385.3967 165.32954 385.3967 165.32954 Z\"/></svg>"
},
"$:/core/images/chevron-left": {
"title": "$:/core/images/chevron-left",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-chevron-left tw-image-button\" width=\"22pt\" height=\"22pt\" viewBox=\"0 0 128 128\" version=\"1.1\">\n <g>\n <path d=\"M97.7982405,98.1688105 L152.184015,43.4979042 C155.938662,39.7236635 155.938662,33.6043964 152.184015,29.8301557 C148.429583,26.0559364 142.342116,26.0559364 138.587684,29.8301557 L91.0000107,77.667222 L43.4123803,29.8301557 C39.6578195,26.0559364 33.5704813,26.0559364 29.8159206,29.8301557 C26.0613598,33.6043964 26.0613598,39.7236635 29.8159206,43.4979042 L84.2017595,98.1688105 C87.9563202,101.943051 94.0436798,101.943051 97.7982405,98.1688126 L97.7982405,98.1688105 Z\" transform=\"translate(91.000000, 63.999491) rotate(-270.000000) translate(-91.000000, -63.999491) \"></path>\n <path d=\"M43.7982405,98.1688105 L98.1840153,43.4979042 C101.938662,39.7236635 101.938662,33.6043964 98.1840153,29.8301557 C94.4295828,26.0559364 88.3421164,26.0559364 84.5876838,29.8301557 L37.0000107,77.667222 L-10.5876197,29.8301557 C-14.3421805,26.0559364 -20.4295187,26.0559364 -24.1840794,29.8301557 C-27.9386402,33.6043964 -27.9386402,39.7236635 -24.1840794,43.4979042 L30.2017595,98.1688105 C33.9563202,101.943051 40.0436798,101.943051 43.7982405,98.1688126 L43.7982405,98.1688105 Z\" transform=\"translate(37.000000, 63.999491) rotate(-270.000000) translate(-37.000000, -63.999491) \"></path>\n </g>\n</svg>"
},
"$:/core/images/chevron-right": {
"title": "$:/core/images/chevron-right",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-chevron-right tw-image-button\" width=\"22pt\" height=\"22pt\" viewBox=\"0 0 128 128\">\n <g>\n <path d=\"M97.7982405,98.1688105 L152.184015,43.4979042 C155.938662,39.7236635 155.938662,33.6043964 152.184015,29.8301557 C148.429583,26.0559364 142.342116,26.0559364 138.587684,29.8301557 L91.0000107,77.667222 L43.4123803,29.8301557 C39.6578195,26.0559364 33.5704813,26.0559364 29.8159206,29.8301557 C26.0613598,33.6043964 26.0613598,39.7236635 29.8159206,43.4979042 L84.2017595,98.1688105 C87.9563202,101.943051 94.0436798,101.943051 97.7982405,98.1688126 L97.7982405,98.1688105 Z\" transform=\"translate(91.000000, 63.999491) rotate(-90.000000) translate(-91.000000, -63.999491) \"></path>\n <path d=\"M43.7982405,98.1688105 L98.1840153,43.4979042 C101.938662,39.7236635 101.938662,33.6043964 98.1840153,29.8301557 C94.4295828,26.0559364 88.3421164,26.0559364 84.5876838,29.8301557 L37.0000107,77.667222 L-10.5876197,29.8301557 C-14.3421805,26.0559364 -20.4295187,26.0559364 -24.1840794,29.8301557 C-27.9386402,33.6043964 -27.9386402,39.7236635 -24.1840794,43.4979042 L30.2017595,98.1688105 C33.9563202,101.943051 40.0436798,101.943051 43.7982405,98.1688126 L43.7982405,98.1688105 Z\" transform=\"translate(37.000000, 63.999491) rotate(-90.000000) translate(-37.000000, -63.999491) \"></path>\n </g>\n</svg>"
},
"$:/core/images/close-button": {
"title": "$:/core/images/close-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-close-button tw-image-button\" viewBox=\"222 150 56 56\" width=\"22pt\" height=\"22pt\"><path d=\"M 249.56668 185.88827 L 267.06757 203.38916 C 269.26427 205.58586 272.82582 205.58586 275.02252 203.38916 L 275.02252 203.38916 C 277.21922 201.19246 277.21922 197.63091 275.02252 195.43421 L 257.52163 177.93332 L 275.38916 160.06579 C 277.58586 157.86909 277.58586 154.30754 275.38916 152.11084 C 273.19246 149.91414 269.63091 149.91414 267.43421 152.11084 L 249.56668 169.97837 L 232.06579 152.47748 L 232.06579 152.47748 C 232.06579 152.47748 232.06579 152.47748 232.06579 152.47748 C 229.86909 150.28078 226.30754 150.28078 224.11084 152.47748 L 224.11084 152.47748 C 221.91414 154.674175 221.91414 158.23573 224.11084 160.43243 L 241.61173 177.93332 L 224.47748 195.06757 L 224.47748 195.06757 L 224.47748 195.06757 C 224.47748 195.06757 224.47748 195.06757 224.47748 195.06757 C 222.28078 197.26427 222.28078 200.82583 224.47748 203.02252 L 224.47748 203.02252 C 226.67418 205.21922 230.23573 205.21922 232.43243 203.02252 Z\"/></svg>\n"
},
"$:/core/images/delete-button": {
"title": "$:/core/images/delete-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-delete-button tw-image-button\" viewBox=\"303 155 39 50\" width=\"17pt\" height=\"22pt\"><path d=\"M 333 164.25 L 333 157.25 C 333 156.14543 332.10457 155.25 331 155.25 L 314.75 155.25 C 314.75 155.25 314.75 155.25 314.75 155.25 C 313.64543 155.25 312.75 156.14543 312.75 157.25 L 312.75 164.25 L 303.75 164.25 L 303.75 168.75 L 306 168.75 L 306 201.75 L 306 201.75 L 306 201.75 C 306 203.40685 307.34315 204.75 309 204.75 L 336.75 204.75 C 338.40685 204.75 339.75 203.40685 339.75 201.75 L 339.75 168.75 L 342 168.75 L 342 164.25 Z M 317.25 160.75 L 317.25 160.75 C 317.25 160.19772 317.69772 159.75 318.25 159.75 C 318.25 159.75 318.25 159.75 318.25 159.75 L 327.5 159.75 C 328.05228 159.75 328.5 160.19772 328.5 160.75 L 328.5 164.25 L 317.25 164.25 L 317.25 160.75 Z M 310.5 168.75 L 312.75 168.75 L 312.75 200.25 L 310.5 200.25 Z M 317.25 168.75 L 319.5 168.75 L 319.5 200.25 L 317.25 200.25 Z M 324 168.75 L 326.25 168.75 L 326.25 200.25 L 324 200.25 Z M 330.75 168.75 L 333 168.75 L 333 200.25 L 330.75 200.25 Z\"/></svg>\n"
},
"$:/core/images/done-button": {
"title": "$:/core/images/done-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-done-button tw-image-button\" viewBox=\"434 150 68 55\" width=\"22pt\" height=\"18pt\"><path d=\"M 438.49266 178.00797 L 439.00744 177.49319 C 441.35054 175.15008 445.14946 175.15004 447.49262 177.49309 L 452.50734 182.50757 C 454.8505 184.85063 458.6494 184.85058 460.99252 182.50748 L 488.50747 154.99255 C 490.85058 152.64944 494.6495 152.6494 496.99266 154.99246 L 497.50722 155.506995 C 499.8504 157.85009 499.8505 161.64908 497.5074 163.99228 C 497.50738 163.99229 497.50736 163.99231 497.50734 163.99233 L 460.9926 200.5077 C 458.64947 202.85087 454.85048 202.8509 452.50732 200.50778 C 452.5073 200.50777 452.5073 200.50777 452.5073 200.50776 L 438.49268 186.49327 C 436.14952 184.15013 436.1495 180.35114 438.49264 178.00799 C 438.49265 178.00798 438.49265 178.00797 438.49266 178.00797 Z\"/></svg>\n"
},
"$:/core/images/down-arrow": {
"title": "$:/core/images/down-arrow",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-down-arrow tw-image-button\" viewBox=\"63 152 64 64\" width=\"22pt\" height=\"22pt\"><path d=\"M 98.001786 212.81802 L 123.45763 187.36218 C 125.21499 185.60482 125.21499 182.75557 123.45763 180.99821 C 121.70027 179.24086 118.85103 179.24086 117.09367 180.99821 L 94.819805 203.27208 L 72.54594 180.99821 C 70.788582 179.24086 67.93934 179.24086 66.18198 180.99821 C 64.42462 182.75557 64.42462 185.60482 66.18198 187.36218 L 91.637825 212.81802 C 93.395184 214.57538 96.244426 214.57538 98.001786 212.81802 Z\"/></svg>\n"
},
"$:/core/images/edit-button": {
"title": "$:/core/images/edit-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-edit-button tw-image-button\" viewBox=\"244 193 20 22\" width=\"20pt\" height=\"22pt\"><path d=\"M 257.33334 196.80951 L 245.90476 207.2857 L 244 212.0476 L 248.7619 210.14284 L 260.19048 199.66665 Z M 259.2381 194.90475 L 258.28566 195.85716 L 261.14284 198.71428 L 262.09522 197.76187 Z M 261.14286 193 L 260.19042 193.95241 L 263.04762 196.80953 L 264 195.85714 Z M 244 213.72882 C 244 213.72882 247.4281 215.43353 250.8572 213.7288 C 254.28599 212.02405 261.14284 214.86531 261.14284 214.86531 L 261.14284 213.72884 C 261.14284 213.72884 254.28577 210.88755 250.8572 212.5923 C 247.42858 214.29712 244 212.59228 244 212.59228 Z\"/></svg>\n"
},
"$:/core/images/home-button": {
"title": "$:/core/images/home-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-home-button tw-image-button\" viewBox=\"81 513 64 54\" width=\"22pt\" height=\"22pt\"><g><path d=\"M 97.04536 522.62083 L 81.364685 531.49067 L 87.85863 531.49067 L 87.85863 566.9699 L 107.49902 566.9699 L 107.49902 552.99265 L 117.95268 552.99265 L 117.95268 566.9699 L 137.59307 566.9699 L 137.59307 531.49067 L 144.086885 531.49067 L 112.72591 513.751 L 107.49902 516.70758 L 107.49902 513.751 L 97.04536 513.751 Z M 94.669443 534.17844 L 103.222493 534.17844 L 103.222493 545.19854 L 94.669443 545.19854 Z M 108.449266 534.17844 L 117.002435 534.17844 L 117.002435 545.19854 L 108.449266 545.19854 Z M 122.387575 534.17844 L 130.9405 534.17844 L 130.9405 545.19854 L 122.387575 545.19854 Z\"/></g></svg>\n"
},
"$:/core/images/info-button": {
"title": "$:/core/images/info-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-info-button tw-image-button\" viewBox=\"294 150 58 58\" width=\"22pt\" height=\"22pt\"><path d=\"M 342.76236 158.98764 C 331.77887 148.0041 313.97113 148.0041 302.98764 158.98764 C 292.0041 169.97113 292.0041 187.77887 302.98764 198.76236 C 313.97113 209.7459 331.77887 209.7459 342.76236 198.76236 C 353.7459 187.77887 353.7459 169.97113 342.76236 158.98764 M 326.5425 157.5 L 326.5425 157.5 C 327.72545 157.5 328.72201 157.91022 329.5337 158.73088 C 330.34465 159.55157 330.75 160.54402 330.75 161.7075 C 330.75 162.87172 330.33979 163.86316 329.51911 164.68385 C 328.69842 165.5045 327.70674 165.91501 326.5425 165.91501 C 325.39801 165.91501 324.4153 165.5045 323.5946 164.68385 C 322.77393 163.86316 322.36372 162.87172 322.36372 161.7075 C 322.36372 160.54402 322.76906 159.55157 323.58 158.73088 C 324.39171 157.91022 325.3793 157.5 326.5425 157.5 Z M 327.80211 190.47259 C 324.91945 195.49132 321.85778 198 318.61462 198 C 317.37452 198 316.38691 197.65158 315.65186 196.9555 C 314.9176 196.25866 314.54943 195.37617 314.54943 194.30782 C 314.54943 193.60202 314.71223 192.70572 315.03629 191.61813 L 319.0151 177.93651 C 319.39685 176.61922 319.58735 175.62754 319.58735 174.95991 C 319.58735 174.53996 319.40582 174.16692 319.04356 173.84286 C 318.68052 173.51905 318.18469 173.35701 317.55527 173.35701 C 317.26861 173.35701 316.92506 173.36677 316.5246 173.38548 L 316.89661 172.2407 L 326.59967 170.66627 L 328.31744 170.66627 L 322.44986 191.01638 C 322.12503 192.18064 321.963 192.94337 321.963 193.30666 C 321.963 193.51588 322.04862 193.71121 322.2204 193.89273 C 322.39218 194.07425 322.5737 194.16554 322.7642 194.16477 C 323.08903 194.16554 323.4131 194.02221 323.73792 193.73559 C 324.59605 193.02976 325.6267 191.75142 326.82838 189.90008 Z\"/></svg>\n"
},
"$:/core/images/menu-button": {
"title": "$:/core/images/menu-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-menu-button tw-image-button\" viewBox=\"216 585 63 45\" width=\"22pt\" height=\"22pt\"><g><path d=\"M 274.5 585 L 229.5 585 C 227.01472 585 225 587.01472 225 589.5 L 225 589.5 C 225 591.98528 227.01472 594 229.5 594 L 274.5 594 C 276.98528 594 279 591.98528 279 589.5 L 279 589.5 C 279 587.01472 276.98528 585 274.5 585 Z\"/><path d=\"M 274.5 603 L 229.5 603 C 227.01472 603 225 605.01472 225 607.5 L 225 607.5 C 225 609.98528 227.01472 612 229.5 612 L 274.5 612 C 276.98528 612 279 609.98528 279 607.5 L 279 607.5 C 279 605.01472 276.98528 603 274.5 603 Z\"/><path d=\"M 274.5 621 L 229.5 621 C 227.01472 621 225 623.01472 225 625.5 L 225 625.5 C 225 627.9853 227.01472 630 229.5 630 L 274.5 630 C 276.98528 630 279 627.9853 279 625.5 L 279 625.5 C 279 623.01472 276.98528 621 274.5 621 Z\"/></g></svg>\n"
},
"$:/core/images/new-button": {
"title": "$:/core/images/new-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-new-button tw-image-button\" viewBox=\"83 81 50 50\" width=\"22pt\" height=\"22pt\"><path d=\"M 101.25 112.5 L 101.25 127.5 C 101.25 127.5 101.25 127.5 101.25 127.5 L 101.25 127.5 C 101.25 129.156855 102.593146 130.5 104.25 130.5 L 111.75 130.5 C 113.406854 130.5 114.75 129.156854 114.75 127.5 L 114.75 112.5 L 129.75 112.5 C 131.406854 112.5 132.75 111.156854 132.75 109.5 L 132.75 102 C 132.75 100.343146 131.406854 99 129.75 99 L 114.75 99 L 114.75 84 C 114.75 82.343146 113.406854 81 111.75 81 L 104.25 81 C 104.25 81 104.25 81 104.25 81 C 102.593146 81 101.25 82.343146 101.25 84 L 101.25 99 L 86.25 99 C 86.25 99 86.25 99 86.25 99 C 84.593146 99 83.25 100.343146 83.25 102 L 83.25 109.5 C 83.25 109.5 83.25 109.5 83.25 109.5 L 83.25 109.5 C 83.25 111.156855 84.593146 112.5 86.25 112.5 Z\"/></svg>\n"
},
"$:/core/images/options-button": {
"title": "$:/core/images/options-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-options-button tw-image-button\" viewBox=\"434 218 68 68\" width=\"22pt\" height=\"22pt\"><path d=\"M 478.39696 232.53705 L 478.39696 232.53705 C 477.11453 231.85132 475.77877 231.30146 474.4106 230.88735 L 474.4106 218.24993 L 461.58944 218.24993 L 461.58944 230.88735 C 460.22126 231.30146 458.8855 231.85132 457.60308 232.53705 L 448.66825 223.60214 L 439.6022 232.66814 L 448.53716 241.60304 C 447.8515 242.88541 447.30158 244.22116 446.88747 245.58935 L 434.25 245.58935 L 434.25 258.41052 L 446.88747 258.41052 C 447.30158 259.7787 447.8515 261.11446 448.53716 262.39689 L 439.6022 271.33173 L 448.66825 280.39779 L 457.60308 271.46281 C 458.8855 272.14862 460.22126 272.69847 461.58944 273.11251 L 461.58944 285.74986 L 474.4106 285.74986 L 474.4106 273.11251 C 475.77877 272.69847 477.11453 272.14862 478.39696 271.46281 L 487.3318 280.39779 L 496.3977 271.33173 L 487.46287 262.39689 C 488.14854 261.11446 488.6984 259.7787 489.11257 258.41052 L 501.7499 258.41052 L 501.7499 245.58935 L 489.11257 245.58935 C 488.6984 244.22116 488.14854 242.88541 487.46287 241.60304 L 496.3977 232.66814 L 487.3318 223.60214 Z M 475.3328 244.66714 C 479.38253 248.71698 479.38253 255.2829 475.3328 259.33273 C 471.28297 263.3826 464.71706 263.3826 460.66723 259.33273 C 456.61737 255.2829 456.61737 248.71698 460.66723 244.66714 C 464.71706 240.61734 471.28297 240.61734 475.3328 244.66714\"/></svg>\n"
},
"$:/core/images/save-button": {
"title": "$:/core/images/save-button",
"tags": "$:/tags/Image",
"text": "<svg class=\"tw-image-save-button tw-image-button\" viewBox=\"4 512 64 60\" width=\"22pt\" height=\"21pt\"><path d=\"M 13.5 537.75 L 11.5 537.75 C 11.5 537.75 11.5 537.75 11.5 537.75 C 7.6340064 537.75 4.4999994 540.884 4.5 544.75 L 4.5 564.5 L 4.5 564.5 C 4.5 564.5 4.5 564.5 4.5 564.5 L 4.5 564.5 C 4.5000006 568.366 7.634007 571.5 11.5 571.5 L 60.5 571.5 C 64.365993 571.5 67.5 568.366 67.5 564.5 L 67.5 544.75 C 67.5 540.884 64.365993 537.75 60.5 537.75 L 58.5 537.75 L 49.5 546.75 L 50 546.75 C 52.20914 546.75 54 548.54086 54 550.75 L 54 556.25 C 54 558.45914 52.20914 560.25 50 560.25 L 36 560.25 L 22 560.25 C 19.790861 560.25 18 558.45914 18 556.25 L 18 556.25 C 18 556.25 18 556.25 18 556.25 L 18 550.75 C 18 548.54086 19.790861 546.75 22 546.75 C 22 546.75 22 546.75 22 546.75 L 22.5 546.75 Z\"/><path d=\"M 16.37132 533.87132 L 33.87868 551.37868 C 35.050253 552.55025 36.949747 552.55025 38.12132 551.37868 L 55.62868 533.87132 C 56.800252 532.69975 56.800252 530.80025 55.62868 529.62868 C 55.06607 529.06607 54.30301 528.75 53.50736 528.75 L 48 528.75 C 46.343146 528.75 45 527.40685 45 525.75 L 45 516 C 45 514.34315 43.656854 513 42 513 L 30 513 C 28.343146 513 27 514.34315 27 516 L 27 525.75 C 27 527.40685 25.656854 528.75 24 528.75 L 18.492641 528.75 C 16.835786 528.75 15.492641 530.09315 15.492641 531.75 C 15.492641 532.54565 15.808711 533.3087 16.37132 533.87132 Z\"/></svg>\n"
},
"$:/language/ControlPanel/Advanced/Caption": {
"title": "$:/language/ControlPanel/Advanced/Caption",
"text": "Advanced"
},
"$:/language/ControlPanel/Advanced/Hint": {
"title": "$:/language/ControlPanel/Advanced/Hint",
"text": "Internal information about this TiddlyWiki"
},
"$:/language/ControlPanel/Advanced/LoadedModules/Caption": {
"title": "$:/language/ControlPanel/Advanced/LoadedModules/Caption",
"text": "Loaded Modules"
},
"$:/language/ControlPanel/Advanced/LoadedModules/Hint": {
"title": "$:/language/ControlPanel/Advanced/LoadedModules/Hint",
"text": "These are the currently loaded tiddler modules linked to their source tiddlers. Any italicised modules lack a source tiddler, typically because they were setup during the boot process."
},
"$:/language/ControlPanel/Advanced/Settings/Caption": {
"title": "$:/language/ControlPanel/Advanced/Settings/Caption",
"text": "Settings"
},
"$:/language/ControlPanel/Advanced/Settings/Hint": {
"title": "$:/language/ControlPanel/Advanced/Settings/Hint",
"text": "These advanced settings let you customise the behaviour of TiddlyWiki."
},
"$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Caption": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Caption",
"text": "Navigation Address Bar"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Hint": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Hint",
"text": "Behaviour of the browser address bar when navigating to a tiddler:"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/No/Description": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/No/Description",
"text": "Do not update the address bar"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Permalink/Description": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Permalink/Description",
"text": "Include the target tiddler"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Permaview/Description": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Permaview/Description",
"text": "Include the target tiddler and the current story sequence"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Caption": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Caption",
"text": "Navigation History"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Hint": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Hint",
"text": "Update browser history when navigating to a tiddler:"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationHistory/No/Description": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationHistory/No/Description",
"text": "Do not update history"
},
"$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Yes/Description": {
"title": "$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Yes/Description",
"text": "Update history"
},
"$:/language/ControlPanel/Advanced/TiddlerFields/Caption": {
"title": "$:/language/ControlPanel/Advanced/TiddlerFields/Caption",
"text": "Tiddler Fields"
},
"$:/language/ControlPanel/Advanced/TiddlerFields/Hint": {
"title": "$:/language/ControlPanel/Advanced/TiddlerFields/Hint",
"text": "This is the full set of TiddlerFields in use in this wiki (including system tiddlers but excluding shadow tiddlers)."
},
"$:/language/ControlPanel/Appearance/Caption": {
"title": "$:/language/ControlPanel/Appearance/Caption",
"text": "Appearance"
},
"$:/language/ControlPanel/Appearance/Hint": {
"title": "$:/language/ControlPanel/Appearance/Hint",
"text": "Ways to customise the appearance of your TiddlyWiki."
},
"$:/language/ControlPanel/Appearance/Palette/Caption": {
"title": "$:/language/ControlPanel/Appearance/Palette/Caption",
"text": "Palette"
},
"$:/language/ControlPanel/Appearance/Palette/Editor/Clone/Caption": {
"title": "$:/language/ControlPanel/Appearance/Palette/Editor/Clone/Caption",
"text": "clone"
},
"$:/language/ControlPanel/Appearance/Palette/Editor/Clone/Prompt": {
"title": "$:/language/ControlPanel/Appearance/Palette/Editor/Clone/Prompt",
"text": "It is recommended that you clone this shadow palette before editing it"
},
"$:/language/ControlPanel/Appearance/Palette/Editor/Prompt/Modified": {
"title": "$:/language/ControlPanel/Appearance/Palette/Editor/Prompt/Modified",
"text": "This shadow palette has been modified"
},
"$:/language/ControlPanel/Appearance/Palette/Editor/Prompt": {
"title": "$:/language/ControlPanel/Appearance/Palette/Editor/Prompt",
"text": "Editing"
},
"$:/language/ControlPanel/Appearance/Palette/Editor/Reset/Caption": {
"title": "$:/language/ControlPanel/Appearance/Palette/Editor/Reset/Caption",
"text": "reset"
},
"$:/language/ControlPanel/Appearance/Palette/HideEditor/Caption": {
"title": "$:/language/ControlPanel/Appearance/Palette/HideEditor/Caption",
"text": "hide editor"
},
"$:/language/ControlPanel/Appearance/Palette/Prompt": {
"title": "$:/language/ControlPanel/Appearance/Palette/Prompt",
"text": "Current palette:"
},
"$:/language/ControlPanel/Appearance/Palette/ShowEditor/Caption": {
"title": "$:/language/ControlPanel/Appearance/Palette/ShowEditor/Caption",
"text": "show editor"
},
"$:/language/ControlPanel/Appearance/StoryView/Caption": {
"title": "$:/language/ControlPanel/Appearance/StoryView/Caption",
"text": "Story View"
},
"$:/language/ControlPanel/Appearance/StoryView/Prompt": {
"title": "$:/language/ControlPanel/Appearance/StoryView/Prompt",
"text": "Current view:"
},
"$:/language/ControlPanel/Appearance/Theme/Caption": {
"title": "$:/language/ControlPanel/Appearance/Theme/Caption",
"text": "Theme"
},
"$:/language/ControlPanel/Appearance/Theme/Prompt": {
"title": "$:/language/ControlPanel/Appearance/Theme/Prompt",
"text": "Current theme:"
},
"$:/language/ControlPanel/Basics/AnimDuration/Prompt": {
"title": "$:/language/ControlPanel/Basics/AnimDuration/Prompt",
"text": "Animation duration:"
},
"$:/language/ControlPanel/Basics/Caption": {
"title": "$:/language/ControlPanel/Basics/Caption",
"text": "Basics"
},
"$:/language/ControlPanel/Basics/DefaultTiddlers/BottomHint": {
"title": "$:/language/ControlPanel/Basics/DefaultTiddlers/BottomHint",
"text": "Use [[double square brackets]] for titles with spaces. Or you can choose to <$button set=\"$:/DefaultTiddlers\" setTo=\"[list[$:/StoryList]]\">retain story ordering</$button>"
},
"$:/language/ControlPanel/Basics/DefaultTiddlers/Prompt": {
"title": "$:/language/ControlPanel/Basics/DefaultTiddlers/Prompt",
"text": "Default tiddlers:"
},
"$:/language/ControlPanel/Basics/DefaultTiddlers/TopHint": {
"title": "$:/language/ControlPanel/Basics/DefaultTiddlers/TopHint",
"text": "Choose which tiddlers are displayed at startup:"
},
"$:/language/ControlPanel/Basics/Language/Prompt": {
"title": "$:/language/ControlPanel/Basics/Language/Prompt",
"text": "Hello! Current language:"
},
"$:/language/ControlPanel/Basics/OverriddenShadowTiddlers/Prompt": {
"title": "$:/language/ControlPanel/Basics/OverriddenShadowTiddlers/Prompt",
"text": "Number of overridden shadow tiddlers:"
},
"$:/language/ControlPanel/Basics/ShadowTiddlers/Prompt": {
"title": "$:/language/ControlPanel/Basics/ShadowTiddlers/Prompt",
"text": "Number of shadow tiddlers:"
},
"$:/language/ControlPanel/Basics/Subtitle/Prompt": {
"title": "$:/language/ControlPanel/Basics/Subtitle/Prompt",
"text": "Subtitle:"
},
"$:/language/ControlPanel/Basics/SystemTiddlers/Prompt": {
"title": "$:/language/ControlPanel/Basics/SystemTiddlers/Prompt",
"text": "Number of system tiddlers:"
},
"$:/language/ControlPanel/Basics/Tags/Prompt": {
"title": "$:/language/ControlPanel/Basics/Tags/Prompt",
"text": "Number of tags:"
},
"$:/language/ControlPanel/Basics/Tiddlers/Prompt": {
"title": "$:/language/ControlPanel/Basics/Tiddlers/Prompt",
"text": "Number of tiddlers:"
},
"$:/language/ControlPanel/Basics/Title/Prompt": {
"title": "$:/language/ControlPanel/Basics/Title/Prompt",
"text": "Title of this ~TiddlyWiki:"
},
"$:/language/ControlPanel/Basics/Username/Prompt": {
"title": "$:/language/ControlPanel/Basics/Username/Prompt",
"text": "Username for signing edits:"
},
"$:/language/ControlPanel/Basics/Version/Prompt": {
"title": "$:/language/ControlPanel/Basics/Version/Prompt",
"text": "~TiddlyWiki version:"
},
"$:/language/ControlPanel/Plugins/Caption": {
"title": "$:/language/ControlPanel/Plugins/Caption",
"text": "Plugins"
},
"$:/language/ControlPanel/Plugins/Fields/Description": {
"title": "$:/language/ControlPanel/Plugins/Fields/Description",
"text": "Description"
},
"$:/language/ControlPanel/Plugins/Fields/Title": {
"title": "$:/language/ControlPanel/Plugins/Fields/Title",
"text": "Title"
},
"$:/language/ControlPanel/Plugins/Fields/Version": {
"title": "$:/language/ControlPanel/Plugins/Fields/Version",
"text": "Version"
},
"$:/language/ControlPanel/Plugins/Language/Prompt": {
"title": "$:/language/ControlPanel/Plugins/Language/Prompt",
"text": "Languages"
},
"$:/language/ControlPanel/Plugins/Plugin/Prompt": {
"title": "$:/language/ControlPanel/Plugins/Plugin/Prompt",
"text": "Plugins"
},
"$:/language/ControlPanel/Plugins/Theme/Prompt": {
"title": "$:/language/ControlPanel/Plugins/Theme/Prompt",
"text": "Themes"
},
"$:/language/ControlPanel/Saving/AutoSave/Disabled/Button": {
"title": "$:/language/ControlPanel/Saving/AutoSave/Disabled/Button",
"text": "enable"
},
"$:/language/ControlPanel/Saving/AutoSave/Disabled/Prompt": {
"title": "$:/language/ControlPanel/Saving/AutoSave/Disabled/Prompt",
"text": "Autosave is currently disabled"
},
"$:/language/ControlPanel/Saving/AutoSave/Enabled/Button": {
"title": "$:/language/ControlPanel/Saving/AutoSave/Enabled/Button",
"text": "disable"
},
"$:/language/ControlPanel/Saving/AutoSave/Enabled/Prompt": {
"title": "$:/language/ControlPanel/Saving/AutoSave/Enabled/Prompt",
"text": "Autosave is currently enabled"
},
"$:/language/ControlPanel/Saving/AutoSave": {
"title": "$:/language/ControlPanel/Saving/AutoSave",
"text": "Autosave"
},
"$:/language/ControlPanel/Saving/Caption": {
"title": "$:/language/ControlPanel/Saving/Caption",
"text": "Saving"
},
"$:/language/ControlPanel/Saving/Heading": {
"title": "$:/language/ControlPanel/Saving/Heading",
"text": "Saving"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Advanced/Heading": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Advanced/Heading",
"text": "Advanced Settings"
},
"$:/language/ControlPanel/Saving/TiddlySpot/BackupDir": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/BackupDir",
"text": "Backup Directory"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Backups": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Backups",
"text": "Backups"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Filename": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Filename",
"text": "Upload Filename"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Heading": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Heading",
"text": "~TiddlySpot"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Hint": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Hint",
"text": "//The server URL defaults to `http://<wikiname>.tiddlyspot.com/store.cgi` and can be changed to use a custom server address//"
},
"$:/language/ControlPanel/Saving/TiddlySpot/Password": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/Password",
"text": "Password"
},
"$:/language/ControlPanel/Saving/TiddlySpot/ServerURL": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/ServerURL",
"text": "Server URL"
},
"$:/language/ControlPanel/Saving/TiddlySpot/UploadDir": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/UploadDir",
"text": "Upload Directory"
},
"$:/language/ControlPanel/Saving/TiddlySpot/UserName": {
"title": "$:/language/ControlPanel/Saving/TiddlySpot/UserName",
"text": "Wiki Name"
},
"$:/language/ControlPanel/Tools/Caption": {
"title": "$:/language/ControlPanel/Tools/Caption",
"text": "Tools"
},
"$:/language/ControlPanel/Tools/Download/Full/Caption": {
"title": "$:/language/ControlPanel/Tools/Download/Full/Caption",
"text": "Download full wiki"
},
"$:/language/ControlPanel/Tools/Encryption/ChangePassword/Button": {
"title": "$:/language/ControlPanel/Tools/Encryption/ChangePassword/Button",
"text": "change password"
},
"$:/language/ControlPanel/Tools/Encryption/ClearPassword/Button": {
"title": "$:/language/ControlPanel/Tools/Encryption/ClearPassword/Button",
"text": "clear password"
},
"$:/language/ControlPanel/Tools/Encryption/Disabled/Prompt": {
"title": "$:/language/ControlPanel/Tools/Encryption/Disabled/Prompt",
"text": "This wiki is not encrypted"
},
"$:/language/ControlPanel/Tools/Encryption/Enabled/Prompt": {
"title": "$:/language/ControlPanel/Tools/Encryption/Enabled/Prompt",
"text": "This wiki is encrypted"
},
"$:/language/ControlPanel/Tools/Encryption/Heading": {
"title": "$:/language/ControlPanel/Tools/Encryption/Heading",
"text": "Encryption"
},
"$:/language/ControlPanel/Tools/Encryption/SetPassword/Button": {
"title": "$:/language/ControlPanel/Tools/Encryption/SetPassword/Button",
"text": "set password"
},
"$:/language/ControlPanel/Tools/Export/AllAsStaticHTML/Caption": {
"title": "$:/language/ControlPanel/Tools/Export/AllAsStaticHTML/Caption",
"text": "Download all tiddlers as static HTML"
},
"$:/language/ControlPanel/Tools/Export/Heading": {
"title": "$:/language/ControlPanel/Tools/Export/Heading",
"text": "Export"
},
"$:/language/ControlPanel/Tools/Import/Heading": {
"title": "$:/language/ControlPanel/Tools/Import/Heading",
"text": "Import"
},
"$:/language/ControlPanel/Tools/Import/Hint": {
"title": "$:/language/ControlPanel/Tools/Import/Hint",
"text": "Browse for files on your computer to import their contents (the individual tiddlers within TiddlyWiki HTML files are imported separately). You can also drag and drop files directly to the browser window."
},
"$:/language/ControlPanel/Tools/Import/Prompt": {
"title": "$:/language/ControlPanel/Tools/Import/Prompt",
"text": "Import:"
},
"$:/language/Docs/ModuleTypes/animation": {
"title": "$:/language/Docs/ModuleTypes/animation",
"text": "Animations that may be used with the RevealWidget."
},
"$:/language/Docs/ModuleTypes/command": {
"title": "$:/language/Docs/ModuleTypes/command",
"text": "Commands that can be executed under Node.js."
},
"$:/language/Docs/ModuleTypes/config": {
"title": "$:/language/Docs/ModuleTypes/config",
"text": "Data to be inserted into `$tw.config`."
},
"$:/language/Docs/ModuleTypes/filteroperator": {
"title": "$:/language/Docs/ModuleTypes/filteroperator",
"text": "Individual filter operator methods."
},
"$:/language/Docs/ModuleTypes/global": {
"title": "$:/language/Docs/ModuleTypes/global",
"text": "Global data to be inserted into `$tw`."
},
"$:/language/Docs/ModuleTypes/isfilteroperator": {
"title": "$:/language/Docs/ModuleTypes/isfilteroperator",
"text": "Operands for the ''is'' filter operator."
},
"$:/language/Docs/ModuleTypes/macro": {
"title": "$:/language/Docs/ModuleTypes/macro",
"text": "JavaScript macro definitions."
},
"$:/language/Docs/ModuleTypes/parser": {
"title": "$:/language/Docs/ModuleTypes/parser",
"text": "Parsers for different content types."
},
"$:/language/Docs/ModuleTypes/saver": {
"title": "$:/language/Docs/ModuleTypes/saver",
"text": "Savers handle different methods for saving files from the browser."
},
"$:/language/Docs/ModuleTypes/startup": {
"title": "$:/language/Docs/ModuleTypes/startup",
"text": "Startup functions."
},
"$:/language/Docs/ModuleTypes/storyview": {
"title": "$:/language/Docs/ModuleTypes/storyview",
"text": "Story views customise the animation and behaviour of list widgets."
},
"$:/language/Docs/ModuleTypes/tiddlerdeserializer": {
"title": "$:/language/Docs/ModuleTypes/tiddlerdeserializer",
"text": "Converts different content types into tiddlers."
},
"$:/language/Docs/ModuleTypes/tiddlerfield": {
"title": "$:/language/Docs/ModuleTypes/tiddlerfield",
"text": "Defines the behaviour of an individual tiddler field."
},
"$:/language/Docs/ModuleTypes/tiddlermethod": {
"title": "$:/language/Docs/ModuleTypes/tiddlermethod",
"text": "Adds methods to the `$tw.Tiddler` prototype."
},
"$:/language/Docs/ModuleTypes/utils": {
"title": "$:/language/Docs/ModuleTypes/utils",
"text": "Adds methods to `$tw.utils`."
},
"$:/language/Docs/ModuleTypes/utils-node": {
"title": "$:/language/Docs/ModuleTypes/utils-node",
"text": "Adds Node.js-specific methods to `$tw.utils`."
},
"$:/language/Docs/ModuleTypes/widget": {
"title": "$:/language/Docs/ModuleTypes/widget",
"text": "Widgets encapsulate DOM rendering and refreshing."
},
"$:/language/Docs/ModuleTypes/wikimethod": {
"title": "$:/language/Docs/ModuleTypes/wikimethod",
"text": "Adds methods to `$tw.Wiki`."
},
"$:/language/Docs/ModuleTypes/wikirule": {
"title": "$:/language/Docs/ModuleTypes/wikirule",
"text": "Individual parser rules for the main WikiText parser."
},
"$:/language/Docs/PaletteColours/alert-background": {
"title": "$:/language/Docs/PaletteColours/alert-background",
"text": "Alert background"
},
"$:/language/Docs/PaletteColours/alert-border": {
"title": "$:/language/Docs/PaletteColours/alert-border",
"text": "Alert border"
},
"$:/language/Docs/PaletteColours/alert-highlight": {
"title": "$:/language/Docs/PaletteColours/alert-highlight",
"text": "Alert highlight"
},
"$:/language/Docs/PaletteColours/alert-muted-foreground": {
"title": "$:/language/Docs/PaletteColours/alert-muted-foreground",
"text": "Alert muted foreground"
},
"$:/language/Docs/PaletteColours/background": {
"title": "$:/language/Docs/PaletteColours/background",
"text": "General background"
},
"$:/language/Docs/PaletteColours/blockquote-bar": {
"title": "$:/language/Docs/PaletteColours/blockquote-bar",
"text": "Blockquote bar"
},
"$:/language/Docs/PaletteColours/code-background": {
"title": "$:/language/Docs/PaletteColours/code-background",
"text": "Code background"
},
"$:/language/Docs/PaletteColours/code-border": {
"title": "$:/language/Docs/PaletteColours/code-border",
"text": "Code border"
},
"$:/language/Docs/PaletteColours/code-foreground": {
"title": "$:/language/Docs/PaletteColours/code-foreground",
"text": "Code foreground"
},
"$:/language/Docs/PaletteColours/download-background": {
"title": "$:/language/Docs/PaletteColours/download-background",
"text": "Download button background"
},
"$:/language/Docs/PaletteColours/download-foreground": {
"title": "$:/language/Docs/PaletteColours/download-foreground",
"text": "Download button foreground"
},
"$:/language/Docs/PaletteColours/dragger-background": {
"title": "$:/language/Docs/PaletteColours/dragger-background",
"text": "Dragger background"
},
"$:/language/Docs/PaletteColours/dragger-foreground": {
"title": "$:/language/Docs/PaletteColours/dragger-foreground",
"text": "Dragger foreground"
},
"$:/language/Docs/PaletteColours/dropdown-background": {
"title": "$:/language/Docs/PaletteColours/dropdown-background",
"text": "Dropdown background"
},
"$:/language/Docs/PaletteColours/dropdown-border": {
"title": "$:/language/Docs/PaletteColours/dropdown-border",
"text": "Dropdown border"
},
"$:/language/Docs/PaletteColours/dropdown-tab-background-selected": {
"title": "$:/language/Docs/PaletteColours/dropdown-tab-background-selected",
"text": "Dropdown tab background for selected tabs"
},
"$:/language/Docs/PaletteColours/dropdown-tab-background": {
"title": "$:/language/Docs/PaletteColours/dropdown-tab-background",
"text": "Dropdown tab background"
},
"$:/language/Docs/PaletteColours/dropzone-background": {
"title": "$:/language/Docs/PaletteColours/dropzone-background",
"text": "Dropzone background"
},
"$:/language/Docs/PaletteColours/external-link-background-hover": {
"title": "$:/language/Docs/PaletteColours/external-link-background-hover",
"text": "External link background hover"
},
"$:/language/Docs/PaletteColours/external-link-background-visited": {
"title": "$:/language/Docs/PaletteColours/external-link-background-visited",
"text": "External link background visited"
},
"$:/language/Docs/PaletteColours/external-link-background": {
"title": "$:/language/Docs/PaletteColours/external-link-background",
"text": "External link background"
},
"$:/language/Docs/PaletteColours/external-link-foreground-hover": {
"title": "$:/language/Docs/PaletteColours/external-link-foreground-hover",
"text": "External link foreground hover"
},
"$:/language/Docs/PaletteColours/external-link-foreground-visited": {
"title": "$:/language/Docs/PaletteColours/external-link-foreground-visited",
"text": "External link foreground visited"
},
"$:/language/Docs/PaletteColours/external-link-foreground": {
"title": "$:/language/Docs/PaletteColours/external-link-foreground",
"text": "External link foreground"
},
"$:/language/Docs/PaletteColours/foreground": {
"title": "$:/language/Docs/PaletteColours/foreground",
"text": "General foreground"
},
"$:/language/Docs/PaletteColours/message-background": {
"title": "$:/language/Docs/PaletteColours/message-background",
"text": "Message box background"
},
"$:/language/Docs/PaletteColours/message-border": {
"title": "$:/language/Docs/PaletteColours/message-border",
"text": "Message box border"
},
"$:/language/Docs/PaletteColours/message-foreground": {
"title": "$:/language/Docs/PaletteColours/message-foreground",
"text": "Message box foreground"
},
"$:/language/Docs/PaletteColours/modal-backdrop": {
"title": "$:/language/Docs/PaletteColours/modal-backdrop",
"text": "Modal backdrop"
},
"$:/language/Docs/PaletteColours/modal-background": {
"title": "$:/language/Docs/PaletteColours/modal-background",
"text": "Modal background"
},
"$:/language/Docs/PaletteColours/modal-border": {
"title": "$:/language/Docs/PaletteColours/modal-border",
"text": "Modal border"
},
"$:/language/Docs/PaletteColours/modal-footer-background": {
"title": "$:/language/Docs/PaletteColours/modal-footer-background",
"text": "Modal footer background"
},
"$:/language/Docs/PaletteColours/modal-footer-border": {
"title": "$:/language/Docs/PaletteColours/modal-footer-border",
"text": "Modal footer border"
},
"$:/language/Docs/PaletteColours/modal-header-border": {
"title": "$:/language/Docs/PaletteColours/modal-header-border",
"text": "Modal header border"
},
"$:/language/Docs/PaletteColours/muted-foreground": {
"title": "$:/language/Docs/PaletteColours/muted-foreground",
"text": "General muted foreground"
},
"$:/language/Docs/PaletteColours/notification-background": {
"title": "$:/language/Docs/PaletteColours/notification-background",
"text": "Notification background"
},
"$:/language/Docs/PaletteColours/notification-border": {
"title": "$:/language/Docs/PaletteColours/notification-border",
"text": "Notification border"
},
"$:/language/Docs/PaletteColours/page-background": {
"title": "$:/language/Docs/PaletteColours/page-background",
"text": "Page background"
},
"$:/language/Docs/PaletteColours/pre-background": {
"title": "$:/language/Docs/PaletteColours/pre-background",
"text": "Preformatted code background"
},
"$:/language/Docs/PaletteColours/pre-border": {
"title": "$:/language/Docs/PaletteColours/pre-border",
"text": "Preformatted code border"
},
"$:/language/Docs/PaletteColours/primary": {
"title": "$:/language/Docs/PaletteColours/primary",
"text": "General primary"
},
"$:/language/Docs/PaletteColours/sidebar-button-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-button-foreground",
"text": "Sidebar button foreground"
},
"$:/language/Docs/PaletteColours/sidebar-controls-foreground-hover": {
"title": "$:/language/Docs/PaletteColours/sidebar-controls-foreground-hover",
"text": "Sidebar controls foreground hover"
},
"$:/language/Docs/PaletteColours/sidebar-controls-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-controls-foreground",
"text": "Sidebar controls foreground"
},
"$:/language/Docs/PaletteColours/sidebar-foreground-shadow": {
"title": "$:/language/Docs/PaletteColours/sidebar-foreground-shadow",
"text": "Sidebar foreground shadow"
},
"$:/language/Docs/PaletteColours/sidebar-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-foreground",
"text": "Sidebar foreground"
},
"$:/language/Docs/PaletteColours/sidebar-muted-foreground-hover": {
"title": "$:/language/Docs/PaletteColours/sidebar-muted-foreground-hover",
"text": "Sidebar muted foreground hover"
},
"$:/language/Docs/PaletteColours/sidebar-muted-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-muted-foreground",
"text": "Sidebar muted foreground"
},
"$:/language/Docs/PaletteColours/sidebar-tab-background-selected": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-background-selected",
"text": "Sidebar tab background for selected tabs"
},
"$:/language/Docs/PaletteColours/sidebar-tab-background": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-background",
"text": "Sidebar tab background"
},
"$:/language/Docs/PaletteColours/sidebar-tab-border-selected": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-border-selected",
"text": "Sidebar tab border for selected tabs"
},
"$:/language/Docs/PaletteColours/sidebar-tab-border": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-border",
"text": "Sidebar tab border"
},
"$:/language/Docs/PaletteColours/sidebar-tab-divider": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-divider",
"text": "Sidebar tab divider"
},
"$:/language/Docs/PaletteColours/sidebar-tab-foreground-selected": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-foreground-selected",
"text": "Sidebar tab foreground for selected tabs"
},
"$:/language/Docs/PaletteColours/sidebar-tab-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-tab-foreground",
"text": "Sidebar tab foreground"
},
"$:/language/Docs/PaletteColours/sidebar-tiddler-link-foreground-hover": {
"title": "$:/language/Docs/PaletteColours/sidebar-tiddler-link-foreground-hover",
"text": "Sidebar tiddler link foreground hover"
},
"$:/language/Docs/PaletteColours/sidebar-tiddler-link-foreground": {
"title": "$:/language/Docs/PaletteColours/sidebar-tiddler-link-foreground",
"text": "Sidebar tiddler link foreground"
},
"$:/language/Docs/PaletteColours/static-alert-foreground": {
"title": "$:/language/Docs/PaletteColours/static-alert-foreground",
"text": "Static alert foreground"
},
"$:/language/Docs/PaletteColours/tab-background-selected": {
"title": "$:/language/Docs/PaletteColours/tab-background-selected",
"text": "Tab background for selected tabs"
},
"$:/language/Docs/PaletteColours/tab-background": {
"title": "$:/language/Docs/PaletteColours/tab-background",
"text": "Tab background"
},
"$:/language/Docs/PaletteColours/tab-border-selected": {
"title": "$:/language/Docs/PaletteColours/tab-border-selected",
"text": "Tab border for selected tabs"
},
"$:/language/Docs/PaletteColours/tab-border": {
"title": "$:/language/Docs/PaletteColours/tab-border",
"text": "Tab border"
},
"$:/language/Docs/PaletteColours/tab-divider": {
"title": "$:/language/Docs/PaletteColours/tab-divider",
"text": "Tab divider"
},
"$:/language/Docs/PaletteColours/tab-foreground-selected": {
"title": "$:/language/Docs/PaletteColours/tab-foreground-selected",
"text": "Tab foreground for selected tabs"
},
"$:/language/Docs/PaletteColours/tab-foreground": {
"title": "$:/language/Docs/PaletteColours/tab-foreground",
"text": "Tab foreground"
},
"$:/language/Docs/PaletteColours/table-border": {
"title": "$:/language/Docs/PaletteColours/table-border",
"text": "Table border"
},
"$:/language/Docs/PaletteColours/table-footer-background": {
"title": "$:/language/Docs/PaletteColours/table-footer-background",
"text": "Table footer background"
},
"$:/language/Docs/PaletteColours/table-header-background": {
"title": "$:/language/Docs/PaletteColours/table-header-background",
"text": "Table header background"
},
"$:/language/Docs/PaletteColours/tag-background": {
"title": "$:/language/Docs/PaletteColours/tag-background",
"text": "Tag background"
},
"$:/language/Docs/PaletteColours/tag-foreground": {
"title": "$:/language/Docs/PaletteColours/tag-foreground",
"text": "Tag foreground"
},
"$:/language/Docs/PaletteColours/tiddler-background": {
"title": "$:/language/Docs/PaletteColours/tiddler-background",
"text": "Tiddler background"
},
"$:/language/Docs/PaletteColours/tiddler-border": {
"title": "$:/language/Docs/PaletteColours/tiddler-border",
"text": "Tiddler border"
},
"$:/language/Docs/PaletteColours/tiddler-controls-foreground-hover": {
"title": "$:/language/Docs/PaletteColours/tiddler-controls-foreground-hover",
"text": "Tiddler controls foreground hover"
},
"$:/language/Docs/PaletteColours/tiddler-controls-foreground-selected": {
"title": "$:/language/Docs/PaletteColours/tiddler-controls-foreground-selected",
"text": "Tiddler controls foreground for selected controls"
},
"$:/language/Docs/PaletteColours/tiddler-controls-foreground": {
"title": "$:/language/Docs/PaletteColours/tiddler-controls-foreground",
"text": "Tiddler controls foreground"
},
"$:/language/Docs/PaletteColours/tiddler-editor-background": {
"title": "$:/language/Docs/PaletteColours/tiddler-editor-background",
"text": "Tiddler editor background"
},
"$:/language/Docs/PaletteColours/tiddler-editor-border-image": {
"title": "$:/language/Docs/PaletteColours/tiddler-editor-border-image",
"text": "Tiddler editor border image"
},
"$:/language/Docs/PaletteColours/tiddler-editor-border": {
"title": "$:/language/Docs/PaletteColours/tiddler-editor-border",
"text": "Tiddler editor border"
},
"$:/language/Docs/PaletteColours/tiddler-editor-fields-even": {
"title": "$:/language/Docs/PaletteColours/tiddler-editor-fields-even",
"text": "Tiddler editor background for even fields"
},
"$:/language/Docs/PaletteColours/tiddler-editor-fields-odd": {
"title": "$:/language/Docs/PaletteColours/tiddler-editor-fields-odd",
"text": "Tiddler editor background for odd fields"
},
"$:/language/Docs/PaletteColours/tiddler-info-background": {
"title": "$:/language/Docs/PaletteColours/tiddler-info-background",
"text": "Tiddler info panel background"
},
"$:/language/Docs/PaletteColours/tiddler-info-border": {
"title": "$:/language/Docs/PaletteColours/tiddler-info-border",
"text": "Tiddler info panel border"
},
"$:/language/Docs/PaletteColours/tiddler-info-tab-background": {
"title": "$:/language/Docs/PaletteColours/tiddler-info-tab-background",
"text": "Tiddler info panel tab background"
},
"$:/language/Docs/PaletteColours/tiddler-link-background": {
"title": "$:/language/Docs/PaletteColours/tiddler-link-background",
"text": "Tiddler link background"
},
"$:/language/Docs/PaletteColours/tiddler-link-foreground": {
"title": "$:/language/Docs/PaletteColours/tiddler-link-foreground",
"text": "Tiddler link foreground"
},
"$:/language/Docs/PaletteColours/tiddler-subtitle-foreground": {
"title": "$:/language/Docs/PaletteColours/tiddler-subtitle-foreground",
"text": "Tiddler subtitle foreground"
},
"$:/language/Docs/PaletteColours/tiddler-title-foreground": {
"title": "$:/language/Docs/PaletteColours/tiddler-title-foreground",
"text": "Tiddler title foreground"
},
"$:/language/Docs/PaletteColours/toolbar-new-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-new-button",
"text": "Toolbar 'new tiddler' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-options-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-options-button",
"text": "Toolbar 'options' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-save-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-save-button",
"text": "Toolbar 'save' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-info-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-info-button",
"text": "Toolbar 'info' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-edit-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-edit-button",
"text": "Toolbar 'edit' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-close-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-close-button",
"text": "Toolbar 'close' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-delete-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-delete-button",
"text": "Toolbar 'delete' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-cancel-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-cancel-button",
"text": "Toolbar 'cancel' button foreground"
},
"$:/language/Docs/PaletteColours/toolbar-done-button": {
"title": "$:/language/Docs/PaletteColours/toolbar-done-button",
"text": "Toolbar 'done' button foreground"
},
"$:/language/Docs/PaletteColours/untagged-background": {
"title": "$:/language/Docs/PaletteColours/untagged-background",
"text": "Untagged pill background"
},
"$:/language/Docs/PaletteColours/very-muted-foreground": {
"title": "$:/language/Docs/PaletteColours/very-muted-foreground",
"text": "Very muted foreground"
},
"$:/language/EditTemplate/Body/Hint": {
"title": "$:/language/EditTemplate/Body/Hint",
"text": "Use [[wiki text|http://tiddlywiki.com/static/WikiText.html]] to add formatting, images, and dynamic features"
},
"$:/language/EditTemplate/Body/Placeholder": {
"title": "$:/language/EditTemplate/Body/Placeholder",
"text": "Type the text for this tiddler"
},
"$:/language/EditTemplate/Body/Preview/Button/Hide": {
"title": "$:/language/EditTemplate/Body/Preview/Button/Hide",
"text": "hide preview"
},
"$:/language/EditTemplate/Body/Preview/Button/Show": {
"title": "$:/language/EditTemplate/Body/Preview/Button/Show",
"text": "show preview"
},
"$:/language/EditTemplate/Fields/Add/Button": {
"title": "$:/language/EditTemplate/Fields/Add/Button",
"text": "add"
},
"$:/language/EditTemplate/Fields/Add/Name/Placeholder": {
"title": "$:/language/EditTemplate/Fields/Add/Name/Placeholder",
"text": "field name"
},
"$:/language/EditTemplate/Fields/Add/Prompt": {
"title": "$:/language/EditTemplate/Fields/Add/Prompt",
"text": "Add a new field:"
},
"$:/language/EditTemplate/Fields/Add/Value/Placeholder": {
"title": "$:/language/EditTemplate/Fields/Add/Value/Placeholder",
"text": "field value"
},
"$:/language/EditTemplate/Shadow/Warning": {
"title": "$:/language/EditTemplate/Shadow/Warning",
"text": "This is a shadow tiddler. Any changes will override the default version"
},
"$:/language/EditTemplate/Shadow/OverriddenWarning": {
"title": "$:/language/EditTemplate/Shadow/OverriddenWarning",
"text": "This is a modified shadow tiddler. You can revert to the default version by deleting this tiddler"
},
"$:/language/EditTemplate/Tags/Add/Button": {
"title": "$:/language/EditTemplate/Tags/Add/Button",
"text": "add"
},
"$:/language/EditTemplate/Tags/Add/Placeholder": {
"title": "$:/language/EditTemplate/Tags/Add/Placeholder",
"text": "tag name"
},
"$:/language/EditTemplate/Type/Placeholder": {
"title": "$:/language/EditTemplate/Type/Placeholder",
"text": "content type"
},
"$:/language/EditTemplate/Type/Prompt": {
"title": "$:/language/EditTemplate/Type/Prompt",
"text": "Type:"
},
"$:/language/Docs/Fields/bag": {
"title": "$:/language/Docs/Fields/bag",
"text": "The name of the bag from which a tiddler came"
},
"$:/language/Docs/Fields/caption": {
"title": "$:/language/Docs/Fields/caption",
"text": "The text to be displayed on a tab or button"
},
"$:/language/Docs/Fields/color": {
"title": "$:/language/Docs/Fields/color",
"text": "The CSS color value associated with a tiddler"
},
"$:/language/Docs/Fields/component": {
"title": "$:/language/Docs/Fields/component",
"text": "The name of the component responsible for an [[alert tiddler|AlertMechanism]]"
},
"$:/language/Docs/Fields/current-tiddler": {
"title": "$:/language/Docs/Fields/current-tiddler",
"text": "Used to cache the top tiddler in a [[history list|HistoryMechanism]]"
},
"$:/language/Docs/Fields/created": {
"title": "$:/language/Docs/Fields/created",
"text": "The date a tiddler was created"
},
"$:/language/Docs/Fields/creator": {
"title": "$:/language/Docs/Fields/creator",
"text": "The name of the person who created a tiddler"
},
"$:/language/Docs/Fields/dependents": {
"title": "$:/language/Docs/Fields/dependents",
"text": "For a plugin, lists the dependent plugin titles"
},
"$:/language/Docs/Fields/description": {
"title": "$:/language/Docs/Fields/description",
"text": "The descriptive text for a plugin, or a modal dialogue"
},
"$:/language/Docs/Fields/draft.of": {
"title": "$:/language/Docs/Fields/draft.of",
"text": "For draft tiddlers, contains the title of the tiddler of which this is a draft"
},
"$:/language/Docs/Fields/draft.title": {
"title": "$:/language/Docs/Fields/draft.title",
"text": "For draft tiddlers, contains the proposed new title of the tiddler"
},
"$:/language/Docs/Fields/footer": {
"title": "$:/language/Docs/Fields/footer",
"text": "The footer text for a wizard"
},
"$:/language/Docs/Fields/hack-to-give-us-something-to-compare-against": {
"title": "$:/language/Docs/Fields/hack-to-give-us-something-to-compare-against",
"text": "A temporary storage field used in [[$:/core/templates/static.content]]"
},
"$:/language/Docs/Fields/icon": {
"title": "$:/language/Docs/Fields/icon",
"text": "The title of the tiddler containing the icon associated with a tiddler"
},
"$:/language/Docs/Fields/library": {
"title": "$:/language/Docs/Fields/library",
"text": "If set to \"yes\" indicates that a tiddler should be saved as a JavaScript library"
},
"$:/language/Docs/Fields/list": {
"title": "$:/language/Docs/Fields/list",
"text": "An ordered list of tiddler titles associated with a tiddler"
},
"$:/language/Docs/Fields/list-before": {
"title": "$:/language/Docs/Fields/list-before",
"text": "If set, the title of a tiddler before which this tiddler should be added to the ordered list of tiddler titles, or at the start of the list if this field is present but empty"
},
"$:/language/Docs/Fields/list-after": {
"title": "$:/language/Docs/Fields/list-after",
"text": "If set, the title of the tiddler after which this tiddler should be added to the ordered list of tiddler titles"
},
"$:/language/Docs/Fields/modified": {
"title": "$:/language/Docs/Fields/modified",
"text": "The date and time at which a tiddler was last modified"
},
"$:/language/Docs/Fields/modifier": {
"title": "$:/language/Docs/Fields/modifier",
"text": "The tiddler title associated with the person who last modified a tiddler"
},
"$:/language/Docs/Fields/name": {
"title": "$:/language/Docs/Fields/name",
"text": "The human readable name associated with a plugin tiddler"
},
"$:/language/Docs/Fields/plugin-priority": {
"title": "$:/language/Docs/Fields/plugin-priority",
"text": "A numerical value indicating the priority of a plugin tiddler"
},
"$:/language/Docs/Fields/plugin-type": {
"title": "$:/language/Docs/Fields/plugin-type",
"text": "The type of plugin in a plugin tiddler"
},
"$:/language/Docs/Fields/revision": {
"title": "$:/language/Docs/Fields/revision",
"text": "The revision of the tiddler held at the server"
},
"$:/language/Docs/Fields/released": {
"title": "$:/language/Docs/Fields/released",
"text": "Date of a TiddlyWiki release"
},
"$:/language/Docs/Fields/source": {
"title": "$:/language/Docs/Fields/source",
"text": "The source URL associated with a tiddler"
},
"$:/language/Docs/Fields/subtitle": {
"title": "$:/language/Docs/Fields/subtitle",
"text": "The subtitle text for a wizard"
},
"$:/language/Docs/Fields/tags": {
"title": "$:/language/Docs/Fields/tags",
"text": "A list of tags associated with a tiddler"
},
"$:/language/Docs/Fields/text": {
"title": "$:/language/Docs/Fields/text",
"text": "The body text of a tiddler"
},
"$:/language/Docs/Fields/title": {
"title": "$:/language/Docs/Fields/title",
"text": "The unique name of a tiddler"
},
"$:/language/Docs/Fields/type": {
"title": "$:/language/Docs/Fields/type",
"text": "The content type of a tiddler"
},
"$:/language/Docs/Fields/version": {
"title": "$:/language/Docs/Fields/version",
"text": "Version information for a plugin"
},
"$:/language/Filters/AllTiddlers": {
"title": "$:/language/Filters/AllTiddlers",
"text": "All tiddlers except system tiddlers"
},
"$:/language/Filters/RecentTiddlers": {
"title": "$:/language/Filters/RecentTiddlers",
"text": "Recently modified tiddlers"
},
"$:/language/Filters/AllTags": {
"title": "$:/language/Filters/AllTags",
"text": "All tags except system tags"
},
"$:/language/Filters/Missing": {
"title": "$:/language/Filters/Missing",
"text": "Missing tiddlers"
},
"$:/language/Filters/Drafts": {
"title": "$:/language/Filters/Drafts",
"text": "Draft tiddlers"
},
"$:/language/Filters/Orphans": {
"title": "$:/language/Filters/Orphans",
"text": "Orphan tiddlers"
},
"$:/language/Filters/SystemTiddlers": {
"title": "$:/language/Filters/SystemTiddlers",
"text": "System tiddlers"
},
"$:/language/Filters/ShadowTiddlers": {
"title": "$:/language/Filters/ShadowTiddlers",
"text": "Shadow tiddlers"
},
"$:/language/Filters/OverriddenShadowTiddlers": {
"title": "$:/language/Filters/OverriddenShadowTiddlers",
"text": "Overridden shadow tiddlers"
},
"$:/language/Filters/SystemTags": {
"title": "$:/language/Filters/SystemTags",
"text": "System tags"
},
"GettingStarted": {
"title": "GettingStarted",
"text": "Welcome to TiddlyWiki, the non-linear personal web notebook.\n\nTo get started, first verify that you can save changes successfully - see http://tiddlywiki.com/ for detailed instructions.\n\nThen you can:\n\n* Create new tiddlers using the 'plus' button in the sidebar\n* Visit the [[control panel|$:/ControlPanel]] using the 'cog' button in the sidebar to customise your wiki\n** Stop this message appearing by changing the default tiddlers under the ''Basics'' tab\n* Save changes using the 'download' button in the sidebar\n* Learn more about [[WikiText|http://tiddlywiki.com/static/WikiText.html]]\n"
},
"$:/language/Help/build": {
"title": "$:/language/Help/build",
"description": "Automatically run configured commands",
"text": "Build the specified build targets for the current wiki. If no build targets are specified then all available targets will be built.\n\n```\n--build <target> [<target> ...]\n```\n\nBuild targets are defined in the `tiddlywiki.info` file of a wiki folder.\n\n"
},
"$:/language/Help/clearpassword": {
"title": "$:/language/Help/clearpassword",
"description": "Clear a password for subsequent crypto operations",
"text": "Clear the password for subsequent crypto operations\n\n```\n--clearpassword\n```\n"
},
"$:/language/Help/default": {
"title": "$:/language/Help/default",
"text": "\\define commandTitle()\n$:/language/Help/$(command)$\n\\end\n```\nusage: tiddlywiki [<wikifolder>] [--<command> [<args>...]...]\n```\n\nAvailable commands:\n\n<ul>\n<$list filter=\"[commands[]sort[title]]\" variable=\"command\">\n<li><$link to=<<commandTitle>>><$macrocall $name=\"command\" $type=\"text/plain\" $output=\"text/plain\"/></$link>: <$transclude tiddler=<<commandTitle>> field=\"description\"/></li>\n</$list>\n</ul>\n\nTo get detailed help on a command:\n\n```\ntiddlywiki --help <command>\n```\n"
},
"$:/language/Help/help": {
"title": "$:/language/Help/help",
"description": "Display help for TiddlyWiki commands",
"text": "Displays help text for a command:\n\n```\n--help [<command>]\n```\n\nIf the command name is omitted then a list of available commands is displayed.\n"
},
"$:/language/Help/init": {
"title": "$:/language/Help/init",
"description": "Initialise a new wiki folder",
"text": "Initialise an empty [[WikiFolder|WikiFolders]] with a copy of the specified edition.\n\n```\n--init <edition> [<edition> ...]\n```\n\nFor example:\n\n```\ntiddlywiki ./MyWikiFolder --init empty\n```\n\nNote:\n\n* The wiki folder directory will be created if necessary\n* The \"edition\" defaults to ''empty''\n* The init command will fail if the wiki folder is not empty\n* The init command removes any `includeWikis` definitions in the edition's `tiddlywiki.info` file\n* When multiple editions are specified, editions initialised later will overwrite any files shared with earlier editions (so, the final `tiddlywiki.info` file will be copied from the last edition)\n* `--help editions` returns a list of available editions\n"
},
"$:/language/Help/load": {
"title": "$:/language/Help/load",
"description": "Load tiddlers from a file",
"text": "Load tiddlers from 2.x.x TiddlyWiki files (`.html`), `.tiddler`, `.tid`, `.json` or other files \n\n```\n--load <filepath>\n```\n\nTo load tiddlers from an encrypted TiddlyWiki file you should first specify the password with the PasswordCommand. For example:\n\n```\ntiddlywiki ./MyWiki --password pa55w0rd --load my_encrypted_wiki.html\n```\n\nNote that TiddlyWiki will not load an older version of an already loaded plugin.\n"
},
"$:/language/Help/notfound": {
"title": "$:/language/Help/notfound",
"text": "No such help item"
},
"$:/language/Help/output": {
"title": "$:/language/Help/output",
"description": "Set the base output directory for subsequent commands",
"text": "Sets the base output directory for subsequent commands. The default output directory is the `output` subdirectory of the edition directory.\n\n```\n--output <pathname>\n```\n\nIf the specified pathname is relative then it is resolved relative to the current working directory.\n"
},
"$:/language/Help/password": {
"title": "$:/language/Help/password",
"description": "Set a password for subsequent crypto operations",
"text": "Set a password for subsequent crypto operations\n\n```\n--password <password>\n```\n\n"
},
"$:/language/Help/rendertiddler": {
"title": "$:/language/Help/rendertiddler",
"description": "Render an individual tiddler as a specified ContentType",
"text": "Render an individual tiddler as a specified ContentType, defaults to `text/html` and save it to the specified filename:\n\n```\n--rendertiddler <title> <filename> [<type>]\n```\n\nBy default, the filename is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.\n\nAny missing directories in the path to the filename are automatically created.\n"
},
"$:/language/Help/rendertiddlers": {
"title": "$:/language/Help/rendertiddlers",
"description": "Render tiddlers matching a filter to a specified ContentType",
"text": "Render a set of tiddlers matching a filter to separate files of a specified ContentType (defaults to `text/html`) and extension (defaults to `.html`).\n\n```\n--rendertiddlers <filter> <template> <pathname> [<type>] [<extension>]\n```\n\nFor example:\n\n```\n--rendertiddlers [!is[system]] $:/core/templates/static.tiddler.html ./static text/plain\n```\n\nBy default, the pathname is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.\n\nAny files in the target directory are deleted. The target directory is recursively created if it is missing.\n"
},
"$:/language/Help/savetiddler": {
"title": "$:/language/Help/savetiddler",
"description": "Saves a raw tiddler to a file",
"text": "Saves an individual tiddler in its raw text or binary format to the specified filename. \n\n```\n--savetiddler <title> <filename>\n```\n\nBy default, the filename is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.\n\nAny missing directories in the path to the filename are automatically created.\n"
},
"$:/language/Help/server": {
"title": "$:/language/Help/server",
"description": "Provides an HTTP server interface to TiddlyWiki",
"text": "The server built in to TiddlyWiki5 is very simple. Although compatible with TiddlyWeb it doesn't support many of the features needed for robust Internet-facing usage.\n\nAt the root, it serves a rendering of a specified tiddler. Away from the root, it serves individual tiddlers encoded in JSON, and supports the basic HTTP operations for `GET`, `PUT` and `DELETE`.\n\n```\n--server <port> <roottiddler> <rendertype> <servetype> <username> <password> <host>\n```\n\nThe parameters are:\n\n* ''port'' - port number to serve from (defaults to \"8080\")\n* ''roottiddler'' - the tiddler to serve at the root (defaults to \"$:/core/save/all\") \n* ''rendertype'' - the content type to which the root tiddler should be rendered (defaults to \"text/plain\")\n* ''servetype'' - the content type with which the root tiddler should be served (defaults to \"text/html\")\n* ''username'' - the default username for signing edits\n* ''password'' - optional password for basic authentication\n* ''host'' - optional hostname to serve from (defaults to \"127.0.0.1\" aka \"localhost\")\n\nIf the password parameter is specified then the browser will prompt the user for the username and password. Note that the password is transmitted in plain text so this implementation isn't suitable for general use.\n\nFor example:\n\n```\n--server 8080 $:/core/save/all text/plain text/html MyUserName passw0rd\n```\n\nTo run multiple TiddlyWiki servers at the same time you'll need to put each one on a different port.\n"
},
"$:/language/Help/verbose": {
"title": "$:/language/Help/verbose",
"description": "Triggers verbose output mode",
"text": "Triggers verbose output, useful for debugging \n\n```\n--verbose\n```\n"
},
"$:/language/Help/version": {
"title": "$:/language/Help/version",
"description": "Displays the version number of TiddlyWiki",
"text": "Displays the version number of TiddlyWiki.\n\n```\n--version\n```\n"
},
"$:/language/BinaryWarning/Prompt": {
"title": "$:/language/BinaryWarning/Prompt",
"text": "This tiddler contains binary data"
},
"$:/language/ClassicWarning/Hint": {
"title": "$:/language/ClassicWarning/Hint",
"text": "This tiddler is written in TiddlyWiki Classic wiki text format, which is not fully compatible with TiddlyWiki version 5. See http://tiddlywiki.com/static/Upgrading.html for more details. "
},
"$:/language/ClassicWarning/Upgrade/Caption": {
"title": "$:/language/ClassicWarning/Upgrade/Caption",
"text": "upgrade"
},
"$:/language/CloseAll/Button": {
"title": "$:/language/CloseAll/Button",
"text": "close all"
},
"$:/language/ConfirmCancelTiddler": {
"title": "$:/language/ConfirmCancelTiddler",
"text": "Do you wish to discard changes to the tiddler \"<$text text=<<title>>/>\"?"
},
"$:/language/ConfirmDeleteTiddler": {
"title": "$:/language/ConfirmDeleteTiddler",
"text": "Do you wish to delete the tiddler \"<$text text=<<title>>/>\"?"
},
"$:/language/ConfirmOverwriteTiddler": {
"title": "$:/language/ConfirmOverwriteTiddler",
"text": "Do you wish to overwrite the tiddler \"<$text text=<<title>>/>\"?"
},
"$:/language/ConfirmEditShadowTiddler": {
"title": "$:/language/ConfirmEditShadowTiddler",
"text": "You are about to edit a ShadowTiddler. Any changes will override the default system making future upgrades non-trivial. Are you sure you want to edit \"<$text text=<<title>>/>\"?"
},
"$:/language/InvalidFieldName": {
"title": "$:/language/InvalidFieldName",
"text": "Illegal characters in field name \"<$text text=<<fieldName>>/>\". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`)"
},
"$:/language/MissingTiddler/Hint": {
"title": "$:/language/MissingTiddler/Hint",
"text": "Missing tiddler \"<$text text=<<currentTiddler>>/>\" - click {{$:/core/images/edit-button}} to create"
},
"$:/language/RecentChanges/DateFormat": {
"title": "$:/language/RecentChanges/DateFormat",
"text": "DDth MMM YYYY"
},
"$:/language/RelativeDate/Future/Days": {
"title": "$:/language/RelativeDate/Future/Days",
"text": "<<period>> days from now"
},
"$:/language/RelativeDate/Future/Hours": {
"title": "$:/language/RelativeDate/Future/Hours",
"text": "<<period>> hours from now"
},
"$:/language/RelativeDate/Future/Minutes": {
"title": "$:/language/RelativeDate/Future/Minutes",
"text": "<<period>> minutes from now"
},
"$:/language/RelativeDate/Future/Months": {
"title": "$:/language/RelativeDate/Future/Months",
"text": "<<period>> months from now"
},
"$:/language/RelativeDate/Future/Second": {
"title": "$:/language/RelativeDate/Future/Second",
"text": "1 second from now"
},
"$:/language/RelativeDate/Future/Seconds": {
"title": "$:/language/RelativeDate/Future/Seconds",
"text": "<<period>> seconds from now"
},
"$:/language/RelativeDate/Future/Years": {
"title": "$:/language/RelativeDate/Future/Years",
"text": "<<period>> years from now"
},
"$:/language/RelativeDate/Past/Days": {
"title": "$:/language/RelativeDate/Past/Days",
"text": "<<period>> days ago"
},
"$:/language/RelativeDate/Past/Hours": {
"title": "$:/language/RelativeDate/Past/Hours",
"text": "<<period>> hours ago"
},
"$:/language/RelativeDate/Past/Minutes": {
"title": "$:/language/RelativeDate/Past/Minutes",
"text": "<<period>> minutes ago"
},
"$:/language/RelativeDate/Past/Months": {
"title": "$:/language/RelativeDate/Past/Months",
"text": "<<period>> months ago"
},
"$:/language/RelativeDate/Past/Second": {
"title": "$:/language/RelativeDate/Past/Second",
"text": "1 second ago"
},
"$:/language/RelativeDate/Past/Seconds": {
"title": "$:/language/RelativeDate/Past/Seconds",
"text": "<<period>> seconds ago"
},
"$:/language/RelativeDate/Past/Years": {
"title": "$:/language/RelativeDate/Past/Years",
"text": "<<period>> years ago"
},
"$:/language/SystemTiddler/Tooltip": {
"title": "$:/language/SystemTiddler/Tooltip",
"text": "This is a system tiddler"
},
"$:/language/TagManager/Colour/Heading": {
"title": "$:/language/TagManager/Colour/Heading",
"text": "Colour"
},
"$:/language/TagManager/Count/Heading": {
"title": "$:/language/TagManager/Count/Heading",
"text": "Count"
},
"$:/language/TagManager/Icon/Heading": {
"title": "$:/language/TagManager/Icon/Heading",
"text": "Icon"
},
"$:/language/TagManager/Tag/Heading": {
"title": "$:/language/TagManager/Tag/Heading",
"text": "Tag"
},
"$:/language/Modals/Download": {
"title": "$:/language/Modals/Download",
"type": "text/vnd.tiddlywiki",
"subtitle": "Download changes",
"footer": "<$button message=\"tw-close-tiddler\" class=\"btn btn-primary\">Close</$button>",
"help": "http://tiddlywiki.com/static/DownloadingChanges.html",
"text": "Your browser only supports manual saving.\n\nTo save your modified wiki, right click on the download link below and select \"Download file\" or \"Save file\", and then choose the folder and filename.\n\n//You can marginally speed things up by clicking the link with the control key (Windows) or the options/alt key (Mac OS X). You will not be prompted for the folder or filename, but your browser is likely to give it an unrecognisable name -- you may need to rename the file to include an `.html` extension before you can do anything useful with it.//\n\nOn smartphones that do not allow files to be downloaded you can instead bookmark the link, and then sync your bookmarks to a desktop computer from where the wiki can be saved normally.\n"
},
"$:/language/Modals/SaveInstructions": {
"title": "$:/language/Modals/SaveInstructions",
"type": "text/vnd.tiddlywiki",
"subtitle": "Save your work",
"footer": "<$button message=\"tw-close-tiddler\" class=\"btn btn-primary\">Close</$button>",
"help": "http://tiddlywiki.com/static/SavingChanges.html",
"text": "Your changes to this wiki need to be saved as a ~TiddlyWiki HTML file.\n\n!!! Desktop browsers\n\n# Select ''Save As'' from the ''File'' menu\n# Choose a filename and location\n#* Some browsers also require you to explicitly specify the file saving format as ''Webpage, HTML only'' or similar\n# Close this tab\n\n!!! Smartphone browsers\n\n# Create a bookmark to this page\n#* If you've got iCloud or Google Sync set up then the bookmark will automatically sync to your desktop where you can open it and save it as above\n# Close this tab\n\n//If you open the bookmark again in Mobile Safari you will see this message again. If you want to go ahead and use the file, just click the ''close'' button below//\n"
},
"$:/language/Notifications/Save/Done": {
"title": "$:/language/Notifications/Save/Done",
"text": "Saved wiki"
},
"$:/language/Notifications/Save/Starting": {
"title": "$:/language/Notifications/Save/Starting",
"text": "Starting to save wiki"
},
"$:/language/Search/Filter/Caption": {
"title": "$:/language/Search/Filter/Caption",
"text": "Filter"
},
"$:/language/Search/Filter/Hint": {
"title": "$:/language/Search/Filter/Hint",
"text": "Search via a [[filter expression|http://tiddlywiki.com/static/TiddlerFilters.html]]"
},
"$:/language/Search/Filter/Matches": {
"title": "$:/language/Search/Filter/Matches",
"text": "//<small><$count filter={{$:/temp/advancedsearch}}/> matches</small>//"
},
"$:/language/Search/Matches": {
"title": "$:/language/Search/Matches",
"text": "//<small><$count filter=\"[!is[system]search{$:/temp/search}]\"/> matches</small>//"
},
"$:/language/Search/Shadows/Caption": {
"title": "$:/language/Search/Shadows/Caption",
"text": "Shadows"
},
"$:/language/Search/Shadows/Hint": {
"title": "$:/language/Search/Shadows/Hint",
"text": "Search for shadow tiddlers"
},
"$:/language/Search/Shadows/Matches": {
"title": "$:/language/Search/Shadows/Matches",
"text": "//<small><$count filter=\"[all[shadows]search{$:/temp/advancedsearch}]\"/> matches</small>//"
},
"$:/language/Search/Standard/Caption": {
"title": "$:/language/Search/Standard/Caption",
"text": "Standard"
},
"$:/language/Search/Standard/Hint": {
"title": "$:/language/Search/Standard/Hint",
"text": "Search for standard tiddlers"
},
"$:/language/Search/Standard/Matches": {
"title": "$:/language/Search/Standard/Matches",
"text": "//<small><$count filter=\"[!is[system]search{$:/temp/advancedsearch}]\"/> matches</small>//"
},
"$:/language/Search/System/Caption": {
"title": "$:/language/Search/System/Caption",
"text": "System"
},
"$:/language/Search/System/Hint": {
"title": "$:/language/Search/System/Hint",
"text": "Search for system tiddlers"
},
"$:/language/Search/System/Matches": {
"title": "$:/language/Search/System/Matches",
"text": "//<small><$count filter=\"[is[system]search{$:/temp/advancedsearch}]\"/> matches</small>//"
},
"$:/language/SideBar/All/Caption": {
"title": "$:/language/SideBar/All/Caption",
"text": "All"
},
"$:/language/SideBar/Drafts/Caption": {
"title": "$:/language/SideBar/Drafts/Caption",
"text": "Drafts"
},
"$:/language/SideBar/Missing/Caption": {
"title": "$:/language/SideBar/Missing/Caption",
"text": "Missing"
},
"$:/language/SideBar/More/Caption": {
"title": "$:/language/SideBar/More/Caption",
"text": "More"
},
"$:/language/SideBar/Open/Caption": {
"title": "$:/language/SideBar/Open/Caption",
"text": "Open"
},
"$:/language/SideBar/Orphans/Caption": {
"title": "$:/language/SideBar/Orphans/Caption",
"text": "Orphans"
},
"$:/language/SideBar/Recent/Caption": {
"title": "$:/language/SideBar/Recent/Caption",
"text": "Recent"
},
"$:/language/SideBar/Shadows/Caption": {
"title": "$:/language/SideBar/Shadows/Caption",
"text": "Shadows"
},
"$:/language/SideBar/System/Caption": {
"title": "$:/language/SideBar/System/Caption",
"text": "System"
},
"$:/language/SideBar/Tags/Caption": {
"title": "$:/language/SideBar/Tags/Caption",
"text": "Tags"
},
"$:/language/SideBar/Tags/TagManager/Caption": {
"title": "$:/language/SideBar/Tags/TagManager/Caption",
"text": "Tag Manager"
},
"$:/language/SideBar/Tags/Untagged/Caption": {
"title": "$:/language/SideBar/Tags/Untagged/Caption",
"text": "untagged"
},
"$:/language/SideBar/Tools/Caption": {
"title": "$:/language/SideBar/Tools/Caption",
"text": "Tools"
},
"$:/language/SideBar/Types/Caption": {
"title": "$:/language/SideBar/Types/Caption",
"text": "Types"
},
"$:/SiteSubtitle": {
"title": "$:/SiteSubtitle",
"text": "a non-linear personal web notebook"
},
"$:/SiteTitle": {
"title": "$:/SiteTitle",
"text": "My ~TiddlyWiki"
},
"$:/language/TiddlerInfo/Advanced/Caption": {
"title": "$:/language/TiddlerInfo/Advanced/Caption",
"text": "Advanced"
},
"$:/language/TiddlerInfo/Advanced/PluginInfo/Empty/Hint": {
"title": "$:/language/TiddlerInfo/Advanced/PluginInfo/Empty/Hint",
"text": "none"
},
"$:/language/TiddlerInfo/Advanced/PluginInfo/Heading": {
"title": "$:/language/TiddlerInfo/Advanced/PluginInfo/Heading",
"text": "Plugin Details"
},
"$:/language/TiddlerInfo/Advanced/PluginInfo/Hint": {
"title": "$:/language/TiddlerInfo/Advanced/PluginInfo/Hint",
"text": "This plugin contains the following shadow tiddlers:"
},
"$:/language/TiddlerInfo/Advanced/ShadowInfo/Heading": {
"title": "$:/language/TiddlerInfo/Advanced/ShadowInfo/Heading",
"text": "Shadow Status"
},
"$:/language/TiddlerInfo/Advanced/ShadowInfo/NotShadow/Hint": {
"title": "$:/language/TiddlerInfo/Advanced/ShadowInfo/NotShadow/Hint",
"text": "The tiddler <$link to=<<infoTiddler>>><$text text=<<infoTiddler>>/></$link> is not a shadow tiddler"
},
"$:/language/TiddlerInfo/Advanced/ShadowInfo/Shadow/Hint": {
"title": "$:/language/TiddlerInfo/Advanced/ShadowInfo/Shadow/Hint",
"text": "The tiddler <$link to=<<infoTiddler>>><$text text=<<infoTiddler>>/></$link> is a shadow tiddler"
},
"$:/language/TiddlerInfo/Advanced/ShadowInfo/Shadow/Source": {
"title": "$:/language/TiddlerInfo/Advanced/ShadowInfo/Shadow/Source",
"text": "It is defined in the plugin <$link to=<<pluginTiddler>>><$text text=<<pluginTiddler>>/></$link>"
},
"$:/language/TiddlerInfo/Advanced/ShadowInfo/OverriddenShadow/Hint": {
"title": "$:/language/TiddlerInfo/Advanced/ShadowInfo/OverriddenShadow/Hint",
"text": "It is overridden by an ordinary tiddler"
},
"$:/language/TiddlerInfo/Fields/Caption": {
"title": "$:/language/TiddlerInfo/Fields/Caption",
"text": "Fields"
},
"$:/language/TiddlerInfo/List/Caption": {
"title": "$:/language/TiddlerInfo/List/Caption",
"text": "List"
},
"$:/language/TiddlerInfo/List/Empty": {
"title": "$:/language/TiddlerInfo/List/Empty",
"text": "This tiddler does not have a list"
},
"$:/language/TiddlerInfo/Listed/Caption": {
"title": "$:/language/TiddlerInfo/Listed/Caption",
"text": "Listed"
},
"$:/language/TiddlerInfo/Listed/Empty": {
"title": "$:/language/TiddlerInfo/Listed/Empty",
"text": "This tiddler is not listed by any others"
},
"$:/language/TiddlerInfo/References/Caption": {
"title": "$:/language/TiddlerInfo/References/Caption",
"text": "References"
},
"$:/language/TiddlerInfo/References/Empty": {
"title": "$:/language/TiddlerInfo/References/Empty",
"text": "No tiddlers link to this one"
},
"$:/language/TiddlerInfo/Tagging/Caption": {
"title": "$:/language/TiddlerInfo/Tagging/Caption",
"text": "Tagging"
},
"$:/language/TiddlerInfo/Tagging/Empty": {
"title": "$:/language/TiddlerInfo/Tagging/Empty",
"text": "No tiddlers are tagged with this one"
},
"$:/language/Docs/Types/application/json": {
"title": "$:/language/Docs/Types/application/json",
"description": "JSON data",
"name": "application/json"
},
"$:/language/Docs/Types/application/x-tiddler-dictionary": {
"title": "$:/language/Docs/Types/application/x-tiddler-dictionary",
"description": "Data dictionary",
"name": "application/x-tiddler-dictionary"
},
"$:/language/Docs/Types/image/gif": {
"title": "$:/language/Docs/Types/image/gif",
"description": "GIF image",
"name": "image/gif"
},
"$:/language/Docs/Types/image/jpeg": {
"title": "$:/language/Docs/Types/image/jpeg",
"description": "JPEG image",
"name": "image/jpeg"
},
"$:/language/Docs/Types/image/png": {
"title": "$:/language/Docs/Types/image/png",
"description": "PNG image",
"name": "image/png"
},
"$:/language/Docs/Types/image/svg+xml": {
"title": "$:/language/Docs/Types/image/svg+xml",
"description": "Structured Vector Graphics image",
"name": "image/svg+xml"
},
"$:/language/Docs/Types/image/x-icon": {
"title": "$:/language/Docs/Types/image/x-icon",
"description": "ICO format icon file",
"name": "image/x-icon"
},
"$:/language/Docs/Types/text/css": {
"title": "$:/language/Docs/Types/text/css",
"description": "Static stylesheet",
"name": "text/css"
},
"$:/language/Docs/Types/text/html": {
"title": "$:/language/Docs/Types/text/html",
"description": "HTML markup",
"name": "text/html"
},
"$:/language/Docs/Types/text/plain": {
"title": "$:/language/Docs/Types/text/plain",
"description": "Plain text",
"name": "text/plain"
},
"$:/language/Docs/Types/text/vnd.tiddlywiki": {
"title": "$:/language/Docs/Types/text/vnd.tiddlywiki",
"description": "TiddlyWiki version 5 wikitext",
"name": "text/vnd.tiddlywiki"
},
"$:/language/Docs/Types/text/x-tiddlywiki": {
"title": "$:/language/Docs/Types/text/x-tiddlywiki",
"description": "TiddlyWiki Classic wikitext",
"name": "text/x-tiddlywiki"
},
"$:/languages/en-GB": {
"title": "$:/languages/en-GB",
"name": "en-GB",
"description": "English (British)",
"author": "JeremyRuston",
"core-version": ">=5.0.0\"",
"text": "Stub pseudo-plugin for the default language"
},
"$:/core/modules/commander.js": {
"text": "/*\\\ntitle: $:/core/modules/commander.js\ntype: application/javascript\nmodule-type: global\n\nThe $tw.Commander class is a command interpreter\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nParse a sequence of commands\n\tcommandTokens: an array of command string tokens\n\twiki: reference to the wiki store object\n\tstreams: {output:, error:}, each of which has a write(string) method\n\tcallback: a callback invoked as callback(err) where err is null if there was no error\n*/\nvar Commander = function(commandTokens,callback,wiki,streams) {\n\tvar path = require(\"path\");\n\tthis.commandTokens = commandTokens;\n\tthis.nextToken = 0;\n\tthis.callback = callback;\n\tthis.wiki = wiki;\n\tthis.streams = streams;\n\tthis.outputPath = path.resolve($tw.boot.wikiPath,$tw.config.wikiOutputSubDir);\n};\n\n/*\nAdd a string of tokens to the command queue\n*/\nCommander.prototype.addCommandTokens = function(commandTokens) {\n\tArray.prototype.push.apply(this.commandTokens,commandTokens);\n};\n\n/*\nExecute the sequence of commands and invoke a callback on completion\n*/\nCommander.prototype.execute = function() {\n\tthis.executeNextCommand();\n};\n\n/*\nExecute the next command in the sequence\n*/\nCommander.prototype.executeNextCommand = function() {\n\tvar self = this;\n\t// Invoke the callback if there are no more commands\n\tif(this.nextToken >= this.commandTokens.length) {\n\t\tthis.callback(null);\n\t} else {\n\t\t// Get and check the command token\n\t\tvar commandName = this.commandTokens[this.nextToken++];\n\t\tif(commandName.substr(0,2) !== \"--\") {\n\t\t\tthis.callback(\"Missing command\");\n\t\t} else {\n\t\t\tcommandName = commandName.substr(2); // Trim off the --\n\t\t\t// Accumulate the parameters to the command\n\t\t\tvar params = [];\n\t\t\twhile(this.nextToken < this.commandTokens.length && \n\t\t\t\tthis.commandTokens[this.nextToken].substr(0,2) !== \"--\") {\n\t\t\t\tparams.push(this.commandTokens[this.nextToken++]);\n\t\t\t}\n\t\t\t// Get the command info\n\t\t\tvar command = $tw.commands[commandName],\n\t\t\t\tc,err;\n\t\t\tif(!command) {\n\t\t\t\tthis.callback(\"Unknown command: \" + commandName);\n\t\t\t} else {\n\t\t\t\tif(this.verbose) {\n\t\t\t\t\tthis.streams.output.write(\"Executing command: \" + commandName + \" \" + params.join(\" \") + \"\\n\");\n\t\t\t\t}\n\t\t\t\tif(command.info.synchronous) {\n\t\t\t\t\t// Synchronous command\n\t\t\t\t\tc = new command.Command(params,this);\n\t\t\t\t\terr = c.execute();\n\t\t\t\t\tif(err) {\n\t\t\t\t\t\tthis.callback(err);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.executeNextCommand();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Asynchronous command\n\t\t\t\t\tc = new command.Command(params,this,function(err) {\n\t\t\t\t\t\tif(err) {\n\t\t\t\t\t\t\tself.callback(err);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tself.executeNextCommand();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\terr = c.execute();\n\t\t\t\t\tif(err) {\n\t\t\t\t\t\tthis.callback(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nCommander.initCommands = function(moduleType) {\n\tmoduleType = moduleType || \"command\";\n\t$tw.commands = {};\n\t$tw.modules.forEachModuleOfType(moduleType,function(title,module) {\n\t\tvar c = $tw.commands[module.info.name] = {};\n\t\t// Add the methods defined by the module\n\t\tfor(var f in module) {\n\t\t\tif($tw.utils.hop(module,f)) {\n\t\t\t\tc[f] = module[f];\n\t\t\t}\n\t\t}\n\t});\n};\n\nexports.Commander = Commander;\n\n})();\n",
"title": "$:/core/modules/commander.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/commands/build.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/build.js\ntype: application/javascript\nmodule-type: command\n\nCommand to build a build target\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"build\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander) {\n\tthis.params = params;\n\tthis.commander = commander;\n};\n\nCommand.prototype.execute = function() {\n\t// Get the build targets defined in the wiki\n\tvar buildTargets = $tw.boot.wikiInfo.build;\n\tif(!buildTargets) {\n\t\treturn \"No build targets defined\"\n\t}\n\t// Loop through each of the specified targets\n\tvar targets;\n\tif(this.params.length > 0) {\n\t\ttargets = this.params;\n\t} else {\n\t\ttargets = Object.keys(buildTargets);\n\t}\n\tfor(var targetIndex=0; targetIndex<targets.length; targetIndex++) {\n\t\tvar target = targets[targetIndex],\n\t\t\tcommands = buildTargets[target];\n\t\tif(!commands) {\n\t\t\treturn \"Build target '\" + target + \"' not found\";\n\t\t}\n\t\t// Add the commands to the queue\n\t\tthis.commander.addCommandTokens(commands);\n\t}\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/build.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/clearpassword.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/clearpassword.js\ntype: application/javascript\nmodule-type: command\n\nClear password for crypto operations\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"clearpassword\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\t$tw.crypto.setPassword(null);\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/clearpassword.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/help.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/help.js\ntype: application/javascript\nmodule-type: command\n\nHelp command\n\n\\*/\n(function(){\n\n/*jshint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"help\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander) {\n\tthis.params = params;\n\tthis.commander = commander;\n};\n\nCommand.prototype.execute = function() {\n\tvar subhelp = this.params[0] || \"default\",\n\t\thelpBase = \"$:/language/Help/\",\n\t\ttext;\n\tif(!this.commander.wiki.getTiddler(helpBase + subhelp)) {\n\t\tsubhelp = \"notfound\";\n\t}\n\t// Wikify the help as formatted text (ie block elements generate newlines)\n\ttext = this.commander.wiki.renderTiddler(\"text/plain-formatted\",helpBase + subhelp);\n\t// Remove any leading linebreaks\n\ttext = text.replace(/^(\\r?\\n)*/g,\"\");\n\tthis.commander.streams.output.write(text);\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/help.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/init.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/init.js\ntype: application/javascript\nmodule-type: command\n\nCommand to initialise an empty wiki folder\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"init\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander) {\n\tthis.params = params;\n\tthis.commander = commander;\n};\n\nCommand.prototype.execute = function() {\n\tvar fs = require(\"fs\"),\n\t\tpath = require(\"path\");\n\t// Check that we don't already have a valid wiki folder\n\tif($tw.boot.wikiTiddlersPath) {\n\t\treturn \"Wiki folder is not empty\";\n\t}\n\t// Loop through each of the specified editions\n\tvar editions = this.params.length > 0 ? this.params : [\"empty\"];\n\tfor(var editionIndex=0; editionIndex<editions.length; editionIndex++) {\n\t\tvar editionName = editions[editionIndex];\n\t\t// Check the edition exists\n\t\tvar editionPath = path.resolve($tw.boot.corePath,$tw.config.editionsPath) + path.sep + editionName;\n\t\tif(!$tw.utils.isDirectory(editionPath)) {\n\t\t\treturn \"Edition '\" + editionName + \"' not found\";\n\t\t}\n\t\t// Copy the edition content\n\t\tvar err = $tw.utils.copyDirectory(editionPath,$tw.boot.wikiPath);\n\t\tif(!err) {\n\t\t\tthis.commander.streams.output.write(\"Copied edition '\" + editionName + \"' to \" + $tw.boot.wikiPath + \"\\n\");\n\t\t} else {\n\t\t\treturn err;\n\t\t}\n\t}\n\t// Tweak the tiddlywiki.info to remove any included wikis\n\tvar packagePath = $tw.boot.wikiPath + \"/tiddlywiki.info\",\n\t\tpackageJson = JSON.parse(fs.readFileSync(packagePath));\n\tdelete packageJson.includeWikis;\n\tfs.writeFileSync(packagePath,JSON.stringify(packageJson,null,$tw.config.preferences.jsonSpaces));\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/init.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/load.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/load.js\ntype: application/javascript\nmodule-type: command\n\nCommand to load tiddlers from a file\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"load\",\n\tsynchronous: false\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tvar self = this,\n\t\tfs = require(\"fs\"),\n\t\tpath = require(\"path\");\n\tif(this.params.length < 1) {\n\t\treturn \"Missing filename\";\n\t}\n\tvar ext = path.extname(self.params[0]);\n\tfs.readFile(this.params[0],$tw.utils.getTypeEncoding(ext),function(err,data) {\n\t\tif (err) {\n\t\t\tself.callback(err);\n\t\t} else {\n\t\t\tvar fields = {title: self.params[0]},\n\t\t\t\ttype = path.extname(self.params[0]);\n\t\t\tvar tiddlers = self.commander.wiki.deserializeTiddlers(type,data,fields);\n\t\t\tif(!tiddlers) {\n\t\t\t\tself.callback(\"No tiddlers found in file \\\"\" + self.params[0] + \"\\\"\");\n\t\t\t} else {\n\t\t\t\tfor(var t=0; t<tiddlers.length; t++) {\n\t\t\t\t\tself.commander.wiki.importTiddler(new $tw.Tiddler(tiddlers[t]));\n\t\t\t\t}\n\t\t\t\tself.callback(null);\t\n\t\t\t}\n\t\t}\n\t});\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/load.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/output.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/output.js\ntype: application/javascript\nmodule-type: command\n\nCommand to set the default output location (defaults to current working directory)\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"output\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tvar fs = require(\"fs\"),\n\t\tpath = require(\"path\");\n\tif(this.params.length < 1) {\n\t\treturn \"Missing output path\";\n\t}\n\tthis.commander.outputPath = path.resolve(process.cwd(),this.params[0]);\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/output.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/password.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/password.js\ntype: application/javascript\nmodule-type: command\n\nSave password for crypto operations\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"password\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tif(this.params.length < 1) {\n\t\treturn \"Missing password\";\n\t}\n\t$tw.crypto.setPassword(this.params[0]);\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/password.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/rendertiddler.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/rendertiddler.js\ntype: application/javascript\nmodule-type: command\n\nCommand to render a tiddler and save it to a file\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"rendertiddler\",\n\tsynchronous: false\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tif(this.params.length < 2) {\n\t\treturn \"Missing filename\";\n\t}\n\tvar self = this,\n\t\tfs = require(\"fs\"),\n\t\tpath = require(\"path\"),\n\t\ttitle = this.params[0],\n\t\tfilename = path.resolve(this.commander.outputPath,this.params[1]),\n\t\ttype = this.params[2] || \"text/html\";\n\t$tw.utils.createFileDirectories(filename);\n\tfs.writeFile(filename,this.commander.wiki.renderTiddler(type,title),\"utf8\",function(err) {\n\t\tself.callback(err);\n\t});\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/rendertiddler.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/rendertiddlers.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/rendertiddlers.js\ntype: application/javascript\nmodule-type: command\n\nCommand to render several tiddlers to a folder of files\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nexports.info = {\n\tname: \"rendertiddlers\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tif(this.params.length < 2) {\n\t\treturn \"Missing filename\";\n\t}\n\tvar self = this,\n\t\tfs = require(\"fs\"),\n\t\tpath = require(\"path\"),\n\t\twiki = this.commander.wiki,\n\t\tfilter = this.params[0],\n\t\ttemplate = this.params[1],\n\t\tpathname = path.resolve(this.commander.outputPath,this.params[2]),\n\t\ttype = this.params[3] || \"text/html\",\n\t\textension = this.params[4] || \".html\",\n\t\ttiddlers = wiki.filterTiddlers(filter);\n\t$tw.utils.deleteDirectory(pathname);\n\t$tw.utils.createDirectory(pathname);\n\t$tw.utils.each(tiddlers,function(title) {\n\t\tvar parser = wiki.parseTiddler(template),\n\t\t\twidgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}});\n\t\tvar container = $tw.fakeDocument.createElement(\"div\");\n\t\twidgetNode.render(container,null);\n\t\tvar text = type === \"text/html\" ? container.innerHTML : container.textContent;\n\t\tfs.writeFileSync(path.resolve(pathname,encodeURIComponent(title) + extension),text,\"utf8\");\n\t});\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/rendertiddlers.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/savetiddler.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/savetiddler.js\ntype: application/javascript\nmodule-type: command\n\nCommand to save the content of a tiddler to a file\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"savetiddler\",\n\tsynchronous: false\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n};\n\nCommand.prototype.execute = function() {\n\tif(this.params.length < 2) {\n\t\treturn \"Missing filename\";\n\t}\n\tvar self = this,\n\t\tfs = require(\"fs\"),\n\t\tpath = require(\"path\"),\n\t\ttitle = this.params[0],\n\t\tfilename = path.resolve(this.commander.outputPath,this.params[1]),\n\t\ttiddler = this.commander.wiki.getTiddler(title),\n\t\ttype = tiddler.fields.type || \"text/vnd.tiddlywiki\",\n\t\tcontentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: \"utf8\"};\n\t$tw.utils.createFileDirectories(filename);\n\tfs.writeFile(filename,tiddler.fields.text,contentTypeInfo.encoding,function(err) {\n\t\tself.callback(err);\n\t});\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/savetiddler.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/server.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/server.js\ntype: application/javascript\nmodule-type: command\n\nServe tiddlers over http\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nif(!$tw.browser) {\n\tvar util = require(\"util\"),\n\t\tfs = require(\"fs\"),\n\t\turl = require(\"url\"),\n\t\tpath = require(\"path\"),\n\t\thttp = require(\"http\");\t\n}\n\nexports.info = {\n\tname: \"server\",\n\tsynchronous: true\n};\n\n/*\nA simple HTTP server with regexp-based routes\n*/\nfunction SimpleServer(options) {\n\tthis.routes = options.routes || [];\n\tthis.wiki = options.wiki;\n\tthis.variables = options.variables || {};\n}\n\nSimpleServer.prototype.set = function(obj) {\n\tvar self = this;\n\t$tw.utils.each(obj,function(value,name) {\n\t\tself.variables[name] = value;\n\t});\n};\n\nSimpleServer.prototype.get = function(name) {\n\treturn this.variables[name];\n};\n\nSimpleServer.prototype.addRoute = function(route) {\n\tthis.routes.push(route);\n};\n\nSimpleServer.prototype.findMatchingRoute = function(request,state) {\n\tfor(var t=0; t<this.routes.length; t++) {\n\t\tvar potentialRoute = this.routes[t],\n\t\t\tpathRegExp = potentialRoute.path,\n\t\t\tmatch = potentialRoute.path.exec(state.urlInfo.pathname);\n\t\tif(match && request.method === potentialRoute.method) {\n\t\t\tstate.params = [];\n\t\t\tfor(var p=1; p<match.length; p++) {\n\t\t\t\tstate.params.push(match[p]);\n\t\t\t}\n\t\t\treturn potentialRoute;\n\t\t}\n\t}\n\treturn null;\n};\n\nSimpleServer.prototype.checkCredentials = function(request,incomingUsername,incomingPassword) {\n\tvar header = request.headers[\"authorization\"] || \"\",\n\t\ttoken = header.split(/\\s+/).pop() || \"\",\n\t\tauth = $tw.utils.base64Decode(token),\n\t\tparts = auth.split(/:/),\n\t\tusername = parts[0],\n\t\tpassword = parts[1];\n\tif(incomingUsername === username && incomingPassword === password) {\n\t\treturn \"ALLOWED\";\n\t} else {\n\t\treturn \"DENIED\";\n\t}\n}\n\nSimpleServer.prototype.listen = function(port,host) {\n\tvar self = this;\n\thttp.createServer(function(request,response) {\n\t\t// Compose the state object\n\t\tvar state = {};\n\t\tstate.wiki = self.wiki;\n\t\tstate.server = self;\n\t\tstate.urlInfo = url.parse(request.url);\n\t\t// Find the route that matches this path\n\t\tvar route = self.findMatchingRoute(request,state);\n\t\t// Check for the username and password if we've got one\n\t\tvar username = self.get(\"username\"),\n\t\t\tpassword = self.get(\"password\");\n\t\tif(username && password) {\n\t\t\t// Check they match\n\t\t\tif(self.checkCredentials(request,username,password) !== \"ALLOWED\") {\n\t\t\t\tvar servername = state.wiki.getTiddlerText(\"$:/SiteTitle\") || \"TiddlyWiki5\";\n\t\t\t\tresponse.writeHead(401,\"Authentication required\",{\n\t\t\t\t\t\"WWW-Authenticate\": 'Basic realm=\"Please provide your username and password to login to ' + servername + '\"'\n\t\t\t\t});\n\t\t\t\tresponse.end();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// Return a 404 if we didn't find a route\n\t\tif(!route) {\n\t\t\tresponse.writeHead(404);\n\t\t\tresponse.end();\n\t\t\treturn;\n\t\t}\n\t\t// Set the encoding for the incoming request\n\t\t// TODO: Presumably this would need tweaking if we supported PUTting binary tiddlers\n\t\trequest.setEncoding(\"utf8\");\n\t\t// Dispatch the appropriate method\n\t\tswitch(request.method) {\n\t\t\tcase \"GET\": // Intentional fall-through\n\t\t\tcase \"DELETE\":\n\t\t\t\troute.handler(request,response,state);\n\t\t\t\tbreak;\n\t\t\tcase \"PUT\":\n\t\t\t\tvar data = \"\";\n\t\t\t\trequest.on(\"data\",function(chunk) {\n\t\t\t\t\tdata += chunk.toString();\n\t\t\t\t});\n\t\t\t\trequest.on(\"end\",function() {\n\t\t\t\t\tstate.data = data;\n\t\t\t\t\troute.handler(request,response,state);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t}\n\t}).listen(port,host);\n};\n\nvar Command = function(params,commander,callback) {\n\tthis.params = params;\n\tthis.commander = commander;\n\tthis.callback = callback;\n\t// Set up server\n\tthis.server = new SimpleServer({\n\t\twiki: this.commander.wiki\n\t});\n\t// Add route handlers\n\tthis.server.addRoute({\n\t\tmethod: \"PUT\",\n\t\tpath: /^\\/recipes\\/default\\/tiddlers\\/(.+)$/,\n\t\thandler: function(request,response,state) {\n\t\t\tvar title = decodeURIComponent(state.params[0]),\n\t\t\t\tfields = JSON.parse(state.data);\n\t\t\t// Pull up any subfields in the `fields` object\n\t\t\tif(fields.fields) {\n\t\t\t\t$tw.utils.each(fields.fields,function(field,name) {\n\t\t\t\t\tfields[name] = field;\n\t\t\t\t});\n\t\t\t\tdelete fields.fields;\n\t\t\t}\n\t\t\t// Remove any revision field\n\t\t\tif(fields[\"revision\"]) {\n\t\t\t\tdelete fields[\"revision\"];\n\t\t\t}\n\t\t\tstate.wiki.addTiddler(new $tw.Tiddler(state.wiki.getCreationFields(),fields,{title: title}));\n\t\t\tvar changeCount = state.wiki.getChangeCount(title).toString();\n\t\t\tresponse.writeHead(204, \"OK\",{\n\t\t\t\tEtag: \"\\\"default/\" + encodeURIComponent(title) + \"/\" + changeCount + \":\\\"\"\n\t\t\t});\n\t\t\tresponse.end();\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"DELETE\",\n\t\tpath: /^\\/bags\\/default\\/tiddlers\\/(.+)$/,\n\t\thandler: function(request,response,state) {\n\t\t\tvar title = decodeURIComponent(state.params[0]);\n\t\t\tstate.wiki.deleteTiddler(title);\n\t\t\tresponse.writeHead(204, \"OK\");\n\t\t\tresponse.end();\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"GET\",\n\t\tpath: /^\\/$/,\n\t\thandler: function(request,response,state) {\n\t\t\tresponse.writeHead(200, {\"Content-Type\": state.server.get(\"serveType\")});\n\t\t\tvar text = state.wiki.renderTiddler(state.server.get(\"renderType\"),state.server.get(\"rootTiddler\"));\n\t\t\tresponse.end(text,\"utf8\");\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"GET\",\n\t\tpath: /^\\/status$/,\n\t\thandler: function(request,response,state) {\n\t\t\tresponse.writeHead(200, {\"Content-Type\": \"application/json\"});\n\t\t\tvar text = JSON.stringify({\n\t\t\t\tusername: state.server.get(\"username\"),\n\t\t\t\tspace: {\n\t\t\t\t\trecipe: \"default\"\n\t\t\t\t},\n\t\t\t\ttiddlywiki_version: $tw.version\n\t\t\t});\n\t\t\tresponse.end(text,\"utf8\");\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"GET\",\n\t\tpath: /^\\/favicon.ico$/,\n\t\thandler: function(request,response,state) {\n\t\t\tresponse.writeHead(200, {\"Content-Type\": \"image/x-icon\"});\n\t\t\tvar buffer = state.wiki.getTiddlerText(\"$:/favicon.ico\",\"\");\n\t\t\tresponse.end(buffer,\"base64\");\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"GET\",\n\t\tpath: /^\\/recipes\\/default\\/tiddlers.json$/,\n\t\thandler: function(request,response,state) {\n\t\t\tresponse.writeHead(200, {\"Content-Type\": \"application/json\"});\n\t\t\tvar tiddlers = [];\n\t\t\tstate.wiki.forEachTiddler({sortField: \"title\"},function(title,tiddler) {\n\t\t\t\tvar tiddlerFields = {};\n\t\t\t\t$tw.utils.each(tiddler.fields,function(field,name) {\n\t\t\t\t\tif(name !== \"text\") {\n\t\t\t\t\t\ttiddlerFields[name] = tiddler.getFieldString(name);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\ttiddlerFields[\"revision\"] = state.wiki.getChangeCount(title);\n\t\t\t\ttiddlerFields.type = tiddlerFields.type || \"text/vnd.tiddlywiki\";\n\t\t\t\ttiddlers.push(tiddlerFields);\n\t\t\t});\n\t\t\tvar text = JSON.stringify(tiddlers);\n\t\t\tresponse.end(text,\"utf8\");\n\t\t}\n\t});\n\tthis.server.addRoute({\n\t\tmethod: \"GET\",\n\t\tpath: /^\\/recipes\\/default\\/tiddlers\\/(.+)$/,\n\t\thandler: function(request,response,state) {\n\t\t\tvar title = decodeURIComponent(state.params[0]),\n\t\t\t\ttiddler = state.wiki.getTiddler(title),\n\t\t\t\ttiddlerFields = {},\n\t\t\t\tknownFields = [\n\t\t\t\t\t\"bag\", \"created\", \"creator\", \"modified\", \"modifier\", \"permissions\", \"recipe\", \"revision\", \"tags\", \"text\", \"title\", \"type\", \"uri\"\n\t\t\t\t];\n\t\t\tif(tiddler) {\n\t\t\t\t$tw.utils.each(tiddler.fields,function(field,name) {\n\t\t\t\t\tvar value = tiddler.getFieldString(name);\n\t\t\t\t\tif(knownFields.indexOf(name) !== -1) {\n\t\t\t\t\t\ttiddlerFields[name] = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttiddlerFields.fields = tiddlerFields.fields || {};\n\t\t\t\t\t\ttiddlerFields.fields[name] = value;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\ttiddlerFields[\"revision\"] = state.wiki.getChangeCount(title);\n\t\t\t\ttiddlerFields.type = tiddlerFields.type || \"text/vnd.tiddlywiki\";\n\t\t\t\tresponse.writeHead(200, {\"Content-Type\": \"application/json\"});\n\t\t\t\tresponse.end(JSON.stringify(tiddlerFields),\"utf8\");\n\t\t\t} else {\n\t\t\t\tresponse.writeHead(404);\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t}\n\t});\n};\n\nCommand.prototype.execute = function() {\n\tvar port = this.params[0] || \"8080\",\n\t\trootTiddler = this.params[1] || \"$:/core/save/all\",\n\t\trenderType = this.params[2] || \"text/plain\",\n\t\tserveType = this.params[3] || \"text/html\",\n\t\tusername = this.params[4],\n\t\tpassword = this.params[5],\n\t\thost = this.params[6] || \"127.0.0.1\";\n\tthis.server.set({\n\t\trootTiddler: rootTiddler,\n\t\trenderType: renderType,\n\t\tserveType: serveType,\n\t\tusername: username,\n\t\tpassword: password\n\t});\n\tthis.server.listen(port,host);\n\tconsole.log(\"Serving on \" + host + \":\" + port);\n\tconsole.log(\"(press ctrl-C to exit)\");\n\treturn null;\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/server.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/verbose.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/verbose.js\ntype: application/javascript\nmodule-type: command\n\nVerbose command\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"verbose\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander) {\n\tthis.params = params;\n\tthis.commander = commander;\n};\n\nCommand.prototype.execute = function() {\n\tthis.commander.verbose = true;\n\t// Output the boot message log\n\tthis.commander.streams.output.write(\"Boot log:\\n \" + $tw.boot.logMessages.join(\"\\n \") + \"\\n\");\n\treturn null; // No error\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/verbose.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/commands/version.js": {
"text": "/*\\\ntitle: $:/core/modules/commands/version.js\ntype: application/javascript\nmodule-type: command\n\nVersion command\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.info = {\n\tname: \"version\",\n\tsynchronous: true\n};\n\nvar Command = function(params,commander) {\n\tthis.params = params;\n\tthis.commander = commander;\n};\n\nCommand.prototype.execute = function() {\n\tthis.commander.streams.output.write($tw.version + \"\\n\");\n\treturn null; // No error\n};\n\nexports.Command = Command;\n\n})();\n",
"title": "$:/core/modules/commands/version.js",
"type": "application/javascript",
"module-type": "command"
},
"$:/core/modules/config.js": {
"text": "/*\\\ntitle: $:/core/modules/config.js\ntype: application/javascript\nmodule-type: config\n\nCore configuration constants\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.preferences = {};\n\nexports.preferences.notificationDuration = 3 * 1000;\nexports.preferences.jsonSpaces = 4;\n\nexports.dateFormats = {\n\tmonths: [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\",\"December\"],\n\tdays: [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n\tshortMonths: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],\n\tshortDays: [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"],\n// suffixes for dates, eg \"1st\",\"2nd\",\"3rd\"...\"30th\",\"31st\"\n\tdaySuffixes: [\"st\",\"nd\",\"rd\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\n\t\t\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\n\t\t\"st\",\"nd\",\"rd\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\"th\",\n\t\t\"st\"],\n\tam: \"am\",\n\tpm: \"pm\"\n};\n\nexports.htmlEntities = {quot:34, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:161, cent:162, pound:163, curren:164, yen:165, brvbar:166, sect:167, uml:168, copy:169, ordf:170, laquo:171, not:172, shy:173, reg:174, macr:175, deg:176, plusmn:177, sup2:178, sup3:179, acute:180, micro:181, para:182, middot:183, cedil:184, sup1:185, ordm:186, raquo:187, frac14:188, frac12:189, frac34:190, iquest:191, Agrave:192, Aacute:193, Acirc:194, Atilde:195, Auml:196, Aring:197, AElig:198, Ccedil:199, Egrave:200, Eacute:201, Ecirc:202, Euml:203, Igrave:204, Iacute:205, Icirc:206, Iuml:207, ETH:208, Ntilde:209, Ograve:210, Oacute:211, Ocirc:212, Otilde:213, Ouml:214, times:215, Oslash:216, Ugrave:217, Uacute:218, Ucirc:219, Uuml:220, Yacute:221, THORN:222, szlig:223, agrave:224, aacute:225, acirc:226, atilde:227, auml:228, aring:229, aelig:230, ccedil:231, egrave:232, eacute:233, ecirc:234, euml:235, igrave:236, iacute:237, icirc:238, iuml:239, eth:240, ntilde:241, ograve:242, oacute:243, ocirc:244, otilde:245, ouml:246, divide:247, oslash:248, ugrave:249, uacute:250, ucirc:251, uuml:252, yacute:253, thorn:254, yuml:255, OElig:338, oelig:339, Scaron:352, scaron:353, Yuml:376, fnof:402, circ:710, tilde:732, Alpha:913, Beta:914, Gamma:915, Delta:916, Epsilon:917, Zeta:918, Eta:919, Theta:920, Iota:921, Kappa:922, Lambda:923, Mu:924, Nu:925, Xi:926, Omicron:927, Pi:928, Rho:929, Sigma:931, Tau:932, Upsilon:933, Phi:934, Chi:935, Psi:936, Omega:937, alpha:945, beta:946, gamma:947, delta:948, epsilon:949, zeta:950, eta:951, theta:952, iota:953, kappa:954, lambda:955, mu:956, nu:957, xi:958, omicron:959, pi:960, rho:961, sigmaf:962, sigma:963, tau:964, upsilon:965, phi:966, chi:967, psi:968, omega:969, thetasym:977, upsih:978, piv:982, ensp:8194, emsp:8195, thinsp:8201, zwnj:8204, zwj:8205, lrm:8206, rlm:8207, ndash:8211, mdash:8212, lsquo:8216, rsquo:8217, sbquo:8218, ldquo:8220, rdquo:8221, bdquo:8222, dagger:8224, Dagger:8225, bull:8226, hellip:8230, permil:8240, prime:8242, Prime:8243, lsaquo:8249, rsaquo:8250, oline:8254, frasl:8260, euro:8364, image:8465, weierp:8472, real:8476, trade:8482, alefsym:8501, larr:8592, uarr:8593, rarr:8594, darr:8595, harr:8596, crarr:8629, lArr:8656, uArr:8657, rArr:8658, dArr:8659, hArr:8660, forall:8704, part:8706, exist:8707, empty:8709, nabla:8711, isin:8712, notin:8713, ni:8715, prod:8719, sum:8721, minus:8722, lowast:8727, radic:8730, prop:8733, infin:8734, ang:8736, and:8743, or:8744, cap:8745, cup:8746, int:8747, there4:8756, sim:8764, cong:8773, asymp:8776, ne:8800, equiv:8801, le:8804, ge:8805, sub:8834, sup:8835, nsub:8836, sube:8838, supe:8839, oplus:8853, otimes:8855, perp:8869, sdot:8901, lceil:8968, rceil:8969, lfloor:8970, rfloor:8971, lang:9001, rang:9002, loz:9674, spades:9824, clubs:9827, hearts:9829, diams:9830 };\n\nexports.htmlVoidElements = \"area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr\".split(\",\");\n\nexports.htmlBlockElements = \"address,article,aside,audio,blockquote,canvas,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,noscript,ol,output,p,pre,section,table,tfoot,ul,video\".split(\",\");\n\nexports.htmlUnsafeElements = \"script\".split(\",\");\n\n})();\n",
"title": "$:/core/modules/config.js",
"type": "application/javascript",
"module-type": "config"
},
"$:/core/modules/deserializers.js": {
"text": "/*\\\ntitle: $:/core/modules/deserializers.js\ntype: application/javascript\nmodule-type: tiddlerdeserializer\n\nFunctions to deserialise tiddlers from a block of text\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nUtility function to parse an old-style tiddler DIV in a *.tid file. It looks like this:\n\n<div title=\"Title\" creator=\"JoeBloggs\" modifier=\"JoeBloggs\" created=\"201102111106\" modified=\"201102111310\" tags=\"myTag [[my long tag]]\">\n<pre>The text of the tiddler (without the expected HTML encoding).\n</pre>\n</div>\n\nNote that the field attributes are HTML encoded, but that the body of the <PRE> tag is not encoded.\n\nWhen these tiddler DIVs are encountered within a TiddlyWiki HTML file then the body is encoded in the usual way.\n*/\nvar parseTiddlerDiv = function(text /* [,fields] */) {\n\t// Slot together the default results\n\tvar result = {};\n\tif(arguments.length > 1) {\n\t\tfor(var f=1; f<arguments.length; f++) {\n\t\t\tvar fields = arguments[f];\n\t\t\tfor(var t in fields) {\n\t\t\t\tresult[t] = fields[t];\t\t\n\t\t\t}\n\t\t}\n\t}\n\t// Parse the DIV body\n\tvar startRegExp = /^\\s*<div\\s+([^>]*)>(\\s*<pre>)?/gi,\n\t\tendRegExp,\n\t\tmatch = startRegExp.exec(text);\n\tif(match) {\n\t\t// Old-style DIVs don't have the <pre> tag\n\t\tif(match[2]) {\n\t\t\tendRegExp = /<\\/pre>\\s*<\\/div>\\s*$/gi;\n\t\t} else {\n\t\t\tendRegExp = /<\\/div>\\s*$/gi;\n\t\t}\n\t\tvar endMatch = endRegExp.exec(text);\n\t\tif(endMatch) {\n\t\t\t// Extract the text\n\t\t\tresult.text = text.substring(match.index + match[0].length,endMatch.index);\n\t\t\t// Process the attributes\n\t\t\tvar attrRegExp = /\\s*([^=\\s]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/gi,\n\t\t\t\tattrMatch;\n\t\t\tdo {\n\t\t\t\tattrMatch = attrRegExp.exec(match[1]);\n\t\t\t\tif(attrMatch) {\n\t\t\t\t\tvar name = attrMatch[1];\n\t\t\t\t\tvar value = attrMatch[2] || attrMatch[3];\n\t\t\t\t\tresult[name] = value;\n\t\t\t\t}\n\t\t\t} while(attrMatch);\n\t\t\treturn result;\n\t\t}\n\t}\n\treturn undefined;\n};\n\nexports[\"application/x-tiddler-html-div\"] = function(text,fields) {\n\treturn [parseTiddlerDiv(text,fields)];\n};\n\nexports[\"application/json\"] = function(text,fields) {\n\tvar tiddlers = JSON.parse(text),\n\t\tresult = [],\n\t\tgetKnownFields = function(tid) {\n\t\t\tvar fields = {};\n\t\t\t\"title text created creator modified modifier type tags\".split(\" \").forEach(function(value) {\n\t\t\t\tif(tid[value] !== null) {\n\t\t\t\t\tfields[value] = tid[value];\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn fields;\n\t\t};\n\tfor(var t=0; t<tiddlers.length; t++) {\n\t\tresult.push(getKnownFields(tiddlers[t]));\n\t}\n\treturn result;\n};\n\n/*\nParse an HTML file into tiddlers. There are three possibilities:\n# A TiddlyWiki classic HTML file containing `text/x-tiddlywiki` tiddlers\n# A TiddlyWiki5 HTML file containing `text/vnd.tiddlywiki` tiddlers\n# An ordinary HTML file\n*/\nexports[\"text/html\"] = function(text,fields) {\n\t// Check if we've got a store area\n\tvar storeAreaMarkerRegExp = /<div id=[\"']?storeArea['\"]?( style=[\"']?display:none;[\"']?)?>/gi,\n\t\tmatch = storeAreaMarkerRegExp.exec(text);\n\tif(match) {\n\t\t// If so, it's either a classic TiddlyWiki file or an unencrypted TW5 file\n\t\t// First read the normal tiddlers\n\t\tvar results = deserializeTiddlyWikiFile(text,storeAreaMarkerRegExp.lastIndex,!!match[1],fields);\n\t\t// Then any system tiddlers\n\t\tvar systemAreaMarkerRegExp = /<div id=[\"']?systemArea['\"]?( style=[\"']?display:none;[\"']?)?>/gi,\n\t\t\tsysMatch = systemAreaMarkerRegExp.exec(text);\n\t\tif(sysMatch) {\n\t\t\tresults.push.apply(results,deserializeTiddlyWikiFile(text,systemAreaMarkerRegExp.lastIndex,!!sysMatch[1],fields));\n\t\t}\n\t\treturn results\n\t} else {\n\t\t// Check whether we've got an encrypted file\n\t\tvar encryptedStoreArea = $tw.utils.extractEncryptedStoreArea(text);\n\t\tif(encryptedStoreArea) {\n\t\t\t// If so, attempt to decrypt it using the current password\n\t\t\treturn $tw.utils.decryptStoreArea(encryptedStoreArea);\n\t\t} else {\n\t\t\t// It's not a TiddlyWiki so we'll return the entire HTML file as a tiddler\n\t\t\treturn deserializeHtmlFile(text,fields);\n\t\t}\n\t}\n};\n\nfunction deserializeHtmlFile(text,fields) {\n\tvar result = {};\n\t$tw.utils.each(fields,function(value,name) {\n\t\tresult[name] = value;\n\t});\n\tresult.text = text;\n\tresult.type = \"text/html\";\n\treturn [result];\n}\n\nfunction deserializeTiddlyWikiFile(text,storeAreaEnd,isTiddlyWiki5,fields) {\n\tvar results = [],\n\t\tendOfDivRegExp = /(<\\/div>\\s*)/gi,\n\t\tstartPos = storeAreaEnd,\n\t\tdefaultType = isTiddlyWiki5 ? undefined : \"text/x-tiddlywiki\";\n\tendOfDivRegExp.lastIndex = startPos;\n\tvar match = endOfDivRegExp.exec(text);\n\twhile(match) {\n\t\tvar endPos = endOfDivRegExp.lastIndex,\n\t\t\ttiddlerFields = parseTiddlerDiv(text.substring(startPos,endPos),fields,{type: defaultType});\n\t\tif(!tiddlerFields) {\n\t\t\tbreak;\n\t\t}\n\t\t$tw.utils.each(tiddlerFields,function(value,name) {\n\t\t\tif(typeof value === \"string\") {\n\t\t\t\ttiddlerFields[name] = $tw.utils.htmlDecode(value);\n\t\t\t}\n\t\t});\n\t\tif(tiddlerFields.text !== null) {\n\t\t\tresults.push(tiddlerFields);\n\t\t}\n\t\tstartPos = endPos;\n\t\tmatch = endOfDivRegExp.exec(text);\n\t}\n\treturn results;\n}\n\n})();\n",
"title": "$:/core/modules/deserializers.js",
"type": "application/javascript",
"module-type": "tiddlerdeserializer"
},
"$:/core/modules/filters/after.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/after.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning the tiddler from the current list that is after the tiddler named in the operand.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.after = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\tvar index = results.indexOf(operator.operand);\n\tif(index === -1 || index > (results.length - 2)) {\n\t\treturn [];\n\t} else {\n\t\treturn [results[index + 1]];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/filters/after.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/all/current.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all/current.js\ntype: application/javascript\nmodule-type: allfilteroperator\n\nFilter function for [all[current]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.current = function(source,prefix,options) {\n\tvar currTiddlerTitle = options.widget && options.widget.getVariable(\"currentTiddler\");\n\tif(currTiddlerTitle) {\n\t\treturn [currTiddlerTitle];\n\t} else {\n\t\treturn [];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/filters/all/current.js",
"type": "application/javascript",
"module-type": "allfilteroperator"
},
"$:/core/modules/filters/all/missing.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all/missing.js\ntype: application/javascript\nmodule-type: allfilteroperator\n\nFilter function for [all[missing]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.missing = function(source,prefix,options) {\n\treturn options.wiki.getMissingTitles();\n};\n\n})();\n",
"title": "$:/core/modules/filters/all/missing.js",
"type": "application/javascript",
"module-type": "allfilteroperator"
},
"$:/core/modules/filters/all/orphans.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all/orphans.js\ntype: application/javascript\nmodule-type: allfilteroperator\n\nFilter function for [all[orphans]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.orphans = function(source,prefix,options) {\n\treturn options.wiki.getOrphanTitles();\n};\n\n})();\n",
"title": "$:/core/modules/filters/all/orphans.js",
"type": "application/javascript",
"module-type": "allfilteroperator"
},
"$:/core/modules/filters/all/shadows.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all/shadows.js\ntype: application/javascript\nmodule-type: allfilteroperator\n\nFilter function for [all[shadows]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.shadows = function(source,prefix,options) {\n\treturn options.wiki.allShadowTitles();\n};\n\n})();\n",
"title": "$:/core/modules/filters/all/shadows.js",
"type": "application/javascript",
"module-type": "allfilteroperator"
},
"$:/core/modules/filters/all/tiddlers.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all/tiddlers.js\ntype: application/javascript\nmodule-type: allfilteroperator\n\nFilter function for [all[tiddlers]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tiddlers = function(source,prefix,options) {\n\treturn options.wiki.allTitles();\n};\n\n})();\n",
"title": "$:/core/modules/filters/all/tiddlers.js",
"type": "application/javascript",
"module-type": "allfilteroperator"
},
"$:/core/modules/filters/all.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/all.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for selecting tiddlers\n\n[all[shadows+tiddlers]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar allFilterOperators;\n\nfunction getAllFilterOperators() {\n\tif(!allFilterOperators) {\n\t\tallFilterOperators = {};\n\t\t$tw.modules.applyMethods(\"allfilteroperator\",allFilterOperators);\n\t}\n\treturn allFilterOperators;\n}\n\n/*\nExport our filter function\n*/\nexports.all = function(source,operator,options) {\n\t// Get our suboperators\n\tvar allFilterOperators = getAllFilterOperators();\n\t// Cycle through the suboperators accumulating their results\n\tvar results = [],\n\t\tsubops = operator.operand.split(\"+\");\n\t// Check for common optimisations\n\tif(subops.length === 1 && subops[0] === \"tiddlers\") {\n\t\treturn options.wiki.each;\n\t} else if(subops.length === 1 && subops[0] === \"shadows\") {\n\t\treturn options.wiki.eachShadow;\n\t} else if(subops.length === 2 && subops[0] === \"tiddlers\" && subops[1] === \"shadows\") {\n\t\treturn options.wiki.eachTiddlerPlusShadows;\n\t} else if(subops.length === 2 && subops[0] === \"shadows\" && subops[1] === \"tiddlers\") {\n\t\treturn options.wiki.eachShadowPlusTiddlers;\n\t}\n\t// Do it the hard way\n\tfor(var t=0; t<subops.length; t++) {\n\t\tvar subop = allFilterOperators[subops[t]];\n\t\tif(subop) {\n\t\t\t$tw.utils.pushTop(results,subop(source,operator.prefix,options));\n\t\t}\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/all.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/backlinks.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/backlinks.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning all the backlinks from a tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.backlinks = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\t$tw.utils.pushTop(results,options.wiki.getTiddlerBacklinks(title));\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/backlinks.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/before.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/before.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning the tiddler from the current list that is before the tiddler named in the operand.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.before = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\tvar index = results.indexOf(operator.operand);\n\tif(index <= 0) {\n\t\treturn [];\n\t} else {\n\t\treturn [results[index - 1]];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/filters/before.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/commands.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/commands.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the names of the commands available in this wiki\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.commands = function(source,operator,options) {\n\tvar results = [];\n\t$tw.utils.each($tw.commands,function(commandInfo,name) {\n\t\tresults.push(name);\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/commands.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/each.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/each.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator that selects one tiddler for each unique value of the specified field\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.each = function(source,operator,options) {\n\tvar results = [],\n\t\tvalues = {};\n\tsource(function(tiddler,title) {\n\t\tif(tiddler) {\n\t\t\tvar value = tiddler.getFieldString(operator.operand);\n\t\t\tif(!$tw.utils.hop(values,value)) {\n\t\t\t\tvalues[value] = true;\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/each.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/eachday.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/eachday.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator that selects one tiddler for each unique day covered by the specified date field\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.eachday = function(source,operator,options) {\n\tvar results = [],\n\t\tvalues = [];\n\t// Function to convert a date/time to a date integer\n\tvar toDate = function(value) {\n\t\tvalue = (new Date(value)).setHours(0,0,0,0);\n\t\treturn value+0;\n\t};\n\tsource(function(tiddler,title) {\n\t\tif(tiddler && tiddler.fields[operator.operand]) {\n\t\t\tvar value = toDate(tiddler.fields[operator.operand]);\n\t\t\tif(values.indexOf(value) === -1) {\n\t\t\t\tvalues.push(value);\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/eachday.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/field.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/field.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for comparing fields for equality\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.field = function(source,operator,options) {\n\tvar results = [],\n\t\tfieldname = (operator.suffix || operator.operator || \"title\").toLowerCase();\n\tif(operator.prefix === \"!\") {\n\t\tif(operator.regexp) {\n\t\t\tsource(function(tiddler,title) {\n\t\t\t\tif(tiddler) {\n\t\t\t\t\tvar text = tiddler.getFieldString(fieldname);\n\t\t\t\t\tif(text !== null && !operator.regexp.exec(text)) {\n\t\t\t\t\t\tresults.push(title);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tsource(function(tiddler,title) {\n\t\t\t\tif(tiddler) {\n\t\t\t\t\tvar text = tiddler.getFieldString(fieldname);\n\t\t\t\t\tif(text !== null && text !== operator.operand) {\n\t\t\t\t\t\tresults.push(title);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else {\n\t\tif(operator.regexp) {\n\t\t\tsource(function(tiddler,title) {\n\t\t\t\tif(tiddler) {\n\t\t\t\t\tvar text = tiddler.getFieldString(fieldname);\n\t\t\t\t\tif(text !== null && !!operator.regexp.exec(text)) {\n\t\t\t\t\t\tresults.push(title);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tsource(function(tiddler,title) {\n\t\t\t\tif(tiddler) {\n\t\t\t\t\tvar text = tiddler.getFieldString(fieldname);\n\t\t\t\t\tif(text !== null && text === operator.operand) {\n\t\t\t\t\t\tresults.push(title);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/field.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/fields.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/fields.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the names of the fields on the selected tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.fields = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tif(tiddler) {\n\t\t\tfor(var fieldName in tiddler.fields) {\n\t\t\t\t$tw.utils.pushTop(results,fieldName);\n\t\t\t}\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/fields.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/get.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/get.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for replacing tiddler titles by the value of the field specified in the operand.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.get = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tif(tiddler) {\n\t\t\tvar value = tiddler.getFieldString(operator.operand);\n\t\t\tif(value) {\n\t\t\t\tresults.push(value);\n\t\t\t}\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/get.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/has.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/has.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for checking if a tiddler has the specified field\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.has = function(source,operator,options) {\n\tvar results = [];\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && (!$tw.utils.hop(tiddler.fields,operator.operand) || tiddler.fields[operator.operand] === \"\")) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && tiddler.fields[operator.operand] !== \"\") {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/has.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/indexes.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/indexes.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the indexes of a data tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.indexes = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tvar data = options.wiki.getTiddlerData(title);\n\t\tif(data) {\n\t\t\t$tw.utils.pushTop(results,Object.keys(data));\n\t\t}\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/indexes.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/is/current.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/current.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[current]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.current = function(source,prefix,options) {\n\tvar results = [],\n\t\tcurrTiddlerTitle = options.widget && options.widget.getVariable(\"currentTiddler\");\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(title !== currTiddlerTitle) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(title === currTiddlerTitle) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/current.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/image.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/image.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[image]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.image = function(source,prefix,options) {\n\tvar results = [];\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!options.wiki.isImageTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(options.wiki.isImageTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/image.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/missing.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/missing.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[missing]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.missing = function(source,prefix,options) {\n\tvar results = [];\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(options.wiki.tiddlerExists(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!options.wiki.tiddlerExists(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/missing.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/orphan.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/orphan.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[orphan]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.orphan = function(source,prefix,options) {\n\tvar results = [],\n\t\torphanTitles = options.wiki.getOrphanTitles();\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(orphanTitles.indexOf(title) === -1) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(orphanTitles.indexOf(title) !== -1) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/orphan.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/shadow.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/shadow.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[shadow]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.shadow = function(source,prefix,options) {\n\tvar results = [];\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!options.wiki.isShadowTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(options.wiki.isShadowTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/shadow.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/system.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/system.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[system]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.system = function(source,prefix,options) {\n\tvar results = [];\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!options.wiki.isSystemTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(options.wiki.isSystemTiddler(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/system.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/tag.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/tag.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[tag]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tag = function(source,prefix,options) {\n\tvar results = [],\n\t\ttagMap = options.wiki.getTagMap();\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!$tw.utils.hop(tagMap,title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif($tw.utils.hop(tagMap,title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/tag.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is/tiddler.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is/tiddler.js\ntype: application/javascript\nmodule-type: isfilteroperator\n\nFilter function for [is[tiddler]]\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tiddler = function(source,prefix,options) {\n\tvar results = [];\n\tif(prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!options.wiki.tiddlerExists(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(options.wiki.tiddlerExists(title)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/is/tiddler.js",
"type": "application/javascript",
"module-type": "isfilteroperator"
},
"$:/core/modules/filters/is.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/is.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for checking tiddler properties\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar isFilterOperators;\n\nfunction getIsFilterOperators() {\n\tif(!isFilterOperators) {\n\t\tisFilterOperators = {};\n\t\t$tw.modules.applyMethods(\"isfilteroperator\",isFilterOperators);\n\t}\n\treturn isFilterOperators;\n};\n\n/*\nExport our filter function\n*/\nexports.is = function(source,operator,options) {\n\t// Dispatch to the correct isfilteroperator\n\tvar isFilterOperators = getIsFilterOperators();\n\tvar isFilterOperator = isFilterOperators[operator.operand];\n\tif(isFilterOperator) {\n\t\treturn isFilterOperator(source,operator.prefix,options);\n\t} else {\n\t\treturn [\"Filter Error: Unknown operand for the 'is' filter operator\"];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/filters/is.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/limit.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/limit.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for chopping the results to a specified maximum number of entries\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.limit = function(source,operator,options) {\n\tvar results = [];\n\t// Convert to an array\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\t// Slice the array if necessary\n\tvar limit = Math.min(results.length,parseInt(operator.operand,10));\n\tif(operator.prefix === \"!\") {\n\t\tresults = results.slice(-limit);\n\t} else {\n\t\tresults = results.slice(0,limit);\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/limit.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/links.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/links.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning all the links from a tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.links = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\t$tw.utils.pushTop(results,options.wiki.getTiddlerLinks(title));\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/links.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/list.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/list.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning the tiddlers whose title is listed in the operand tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.list = function(source,operator,options) {\n\tvar results = [],\n\t\ttr = $tw.utils.parseTextReference(operator.operand),\n\t\tcurrTiddlerTitle = options.widget && options.widget.getVariable(\"currentTiddler\"),\n\t\tlist = options.wiki.getTiddlerList(tr.title || currTiddlerTitle,tr.field,tr.index);\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(list.indexOf(title) === -1) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tresults = list;\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/list.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/listed.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/listed.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning all tiddlers that have the selected tiddlers in a list\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.listed = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\t$tw.utils.pushTop(results,options.wiki.findListingsOfTiddler(title));\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/listed.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/listops.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/listops.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operators for manipulating the current selection list\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nReverse list\n*/\nexports.reverse = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tresults.unshift(title);\n\t});\n\treturn results;\n};\n\n/*\nFirst entry/entries in list\n*/\nexports.first = function(source,operator,options) {\n\tvar count = parseInt(operator.operand) || 1,\n\t\tresults = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results.slice(0,count);\n};\n\n/*\nLast entry/entries in list\n*/\nexports.last = function(source,operator,options) {\n\tvar count = parseInt(operator.operand) || 1,\n\t\tresults = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results.slice(-count);\n};\n\n/*\nAll but the first entry/entries of the list\n*/\nexports.rest = function(source,operator,options) {\n\tvar count = parseInt(operator.operand) || 1,\n\t\tresults = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results.slice(count);\n};\nexports.butfirst = exports.rest;\nexports.bf = exports.rest;\n\n/*\nAll but the last entry/entries of the list\n*/\nexports.butlast = function(source,operator,options) {\n\tvar count = parseInt(operator.operand) || 1,\n\t\tresults = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results.slice(0,-count);\n};\nexports.bl = exports.butlast;\n\n/*\nThe nth member of the list\n*/\nexports.nth = function(source,operator,options) {\n\tvar count = parseInt(operator.operand) || 1,\n\t\tresults = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results.slice(count - 1,count);\n};\n\n})();\n",
"title": "$:/core/modules/filters/listops.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/modules.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/modules.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the titles of the modules of a given type in this wiki\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.modules = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\t$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {\n\t\t\tresults.push(moduleName);\n\t\t});\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/modules.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/moduletypes.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/moduletypes.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the names of the module types in this wiki\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.moduletypes = function(source,operator,options) {\n\tvar results = [];\n\t$tw.utils.each($tw.modules.types,function(moduleInfo,type) {\n\t\tresults.push(type);\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/moduletypes.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/next.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/next.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning the tiddler whose title occurs next in the list supplied in the operand tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.next = function(source,operator,options) {\n\tvar results = [],\n\t\tlist = options.wiki.getTiddlerList(operator.operand);\n\tsource(function(tiddler,title) {\n\t\tvar match = list.indexOf(title);\n\t\t// increment match and then test if result is in range\n\t\tmatch++;\n\t\tif(match > 0 && match < list.length) {\n\t\t\tresults.push(list[match]);\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/next.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/plugintiddlers.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/plugintiddlers.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the titles of the shadow tiddlers within a plugin\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.plugintiddlers = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n \t\tvar pluginInfo = options.wiki.getPluginInfo(title);\n \t\tif(pluginInfo) {\n \t\t\t$tw.utils.each(pluginInfo.tiddlers,function(fields,title) {\n \t\t\t\tresults.push(title);\n \t\t\t});\n \t\t}\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/plugintiddlers.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/prefix.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/prefix.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for checking if a title starts with a prefix\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.prefix = function(source,operator,options) {\n\tvar results = [];\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(title.substr(0,operator.operand.length).toLowerCase() !== operator.operand.toLowerCase()) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(title.substr(0,operator.operand.length).toLowerCase() === operator.operand.toLowerCase()) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/prefix.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/previous.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/previous.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning the tiddler whose title occurs immediately prior in the list supplied in the operand tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.previous = function(source,operator,options) {\n\tvar results = [],\n\t\tlist = options.wiki.getTiddlerList(operator.operand);\n\tsource(function(tiddler,title) {\n\t\tvar match = list.indexOf(title);\n\t\t// increment match and then test if result is in range\n\t\tmatch--;\n\t\tif(match >= 0) {\n\t\t\tresults.push(list[match]);\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/previous.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/removeprefix.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/removeprefix.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for removing a prefix from each title in the list. Titles that do not start with the prefix are removed.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.removeprefix = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tif(title.substr(0,operator.operand.length).toLowerCase() === operator.operand.toLowerCase()) {\n\t\t\tresults.push(title.substr(operator.operand.length));\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/removeprefix.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/sameday.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/sameday.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator that selects tiddlers with a modified date field on the same day as the provided value.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.sameday = function(source,operator,options) {\n\tvar results = [],\n\t\tfieldName = operator.suffix || \"modified\",\n\t\ttargetDate = (new Date($tw.utils.parseDate(operator.operand))).setHours(0,0,0,0);\n\t// Function to convert a date/time to a date integer\n\tvar isSameDay = function(dateField) {\n\t\t\treturn (new Date(dateField)).setHours(0,0,0,0) === targetDate;\n\t\t};\n\tsource(function(tiddler,title) {\n\t\tif(tiddler && tiddler.fields[fieldName]) {\n\t\t\tif(isSameDay(tiddler.fields[fieldName])) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/sameday.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/search.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/search.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for searching for the text in the operand tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.search = function(source,operator,options) {\n\tvar invert = operator.prefix === \"!\";\n\treturn options.wiki.search(operator.operand,{\n\t\tsource: source,\n\t\tinvert: invert\n\t});\n};\n\n})();\n",
"title": "$:/core/modules/filters/search.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/shadowsource.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/shadowsource.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the source plugins for shadow tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.shadowsource = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tvar source = options.wiki.getShadowSource(title);\n \t\tif(source) {\n\t\t\t$tw.utils.pushTop(results,source);\n \t\t}\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/shadowsource.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/sort.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/sort.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for sorting\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.sort = function(source,operator,options) {\n\tvar results = prepare_results(source);\n\toptions.wiki.sortTiddlers(results,operator.operand || \"title\",operator.prefix === \"!\",false,false);\n\treturn results;\n};\n\nexports.nsort = function(source,operator,options) {\n\tvar results = prepare_results(source);\n\toptions.wiki.sortTiddlers(results,operator.operand || \"title\",operator.prefix === \"!\",false,true);\n\treturn results;\n};\n\nexports.sortcs = function(source,operator,options) {\n\tvar results = prepare_results(source);\n\toptions.wiki.sortTiddlers(results,operator.operand || \"title\",operator.prefix === \"!\",true,false);\n\treturn results;\n};\n\nexports.nsortcs = function(source,operator,options) {\n\tvar results = prepare_results(source);\n\toptions.wiki.sortTiddlers(results,operator.operand || \"title\",operator.prefix === \"!\",true,true);\n\treturn results;\n};\n\nvar prepare_results = function (source) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tresults.push(title);\n\t});\n\treturn results;\n}\n\n})();\n",
"title": "$:/core/modules/filters/sort.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/tag.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/tag.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for checking for the presence of a tag\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tag = function(source,operator,options) {\n\tvar results = [];\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && !tiddler.hasTag(operator.operand)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && tiddler.hasTag(operator.operand)) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t\tresults = options.wiki.sortByList(results,operator.operand);\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/tag.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/tagging.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/tagging.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning all tiddlers that are tagged with the selected tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tagging = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\t$tw.utils.pushTop(results,options.wiki.getTiddlersWithTag(title));\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/tagging.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/tags.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/tags.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning all the tags of the selected tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.tags = function(source,operator,options) {\n\tvar results = [];\n\tsource(function(tiddler,title) {\n\t\tif(tiddler && tiddler.fields.tags) {\n\t\t\t$tw.utils.pushTop(results,tiddler.fields.tags);\n\t\t}\n\t});\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/tags.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/title.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/title.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for comparing title fields for equality\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.title = function(source,operator,options) {\n\tvar results = [];\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && tiddler.fields.title !== operator.operand) {\n\t\t\t\tresults.push(title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tresults.push(operator.operand);\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/title.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters/untagged.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/untagged.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator returning all the selected tiddlers that are untagged\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.untagged = function(source,operator,options) {\n\tvar results = [];\n\tif(operator.prefix === \"!\") {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(tiddler && $tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length > 0) {\n\t\t\t\t$tw.utils.pushTop(results,title);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tsource(function(tiddler,title) {\n\t\t\tif(!tiddler || !tiddler.hasField(\"tags\") || ($tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length === 0)) {\n\t\t\t\t$tw.utils.pushTop(results,title);\n\t\t\t}\n\t\t});\n\t}\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/untagged.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/filters.js": {
"text": "/*\\\ntitle: $:/core/modules/filters.js\ntype: application/javascript\nmodule-type: wikimethod\n\nAdds tiddler filtering methods to the $tw.Wiki object.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nParses an operation within a filter string\n\tresults: Array of array of operator nodes into which results should be inserted\n\tfilterString: filter string\n\tp: start position within the string\nReturns the new start position, after the parsed operation\n*/\nfunction parseFilterOperation(operators,filterString,p) {\n\tvar operator, operand, bracketPos, curlyBracketPos;\n\t// Skip the starting square bracket\n\tif(filterString.charAt(p++) !== \"[\") {\n\t\tthrow \"Missing [ in filter expression\";\n\t}\n\t// Process each operator in turn\n\tdo {\n\t\toperator = {};\n\t\t// Check for an operator prefix\n\t\tif(filterString.charAt(p) === \"!\") {\n\t\t\toperator.prefix = filterString.charAt(p++);\n\t\t}\n\t\t// Get the operator name\n\t\tvar nextBracketPos = filterString.substring(p).search(/[\\[\\{\\/]/);\n\t\tif(nextBracketPos === -1) {\n\t\t\tthrow \"Missing [ in filter expression\";\n\t\t}\n\t\tnextBracketPos += p;\n\t\tvar bracket = filterString.charAt(nextBracketPos);\n\t\toperator.operator = filterString.substring(p,nextBracketPos);\n\t\t\n\t\t// Any suffix?\n\t\tvar colon = operator.operator.indexOf(':');\n\t\tif(colon > -1) {\n\t\t\toperator.suffix = operator.operator.substring(colon + 1);\n\t\t\toperator.operator = operator.operator.substring(0,colon) || \"field\";\n\t\t}\n\t\t// Empty operator means: title\n\t\telse if(operator.operator === \"\") {\n\t\t\toperator.operator = \"title\";\n\t\t}\n\n\t\tp = nextBracketPos + 1;\n\t\tswitch (bracket) {\n\t\tcase '{': // Curly brackets\n\t\t\toperator.indirect = true;\n\t\t\tnextBracketPos = filterString.indexOf('}',p);\n\t\t\tbreak;\n\t\tcase '[': // Square brackets\n\t\t\tnextBracketPos = filterString.indexOf(']',p);\n\t\t\tbreak;\n\t\tcase '/': // regexp brackets\n\t\t\tvar rex = /^((?:[^\\\\\\/]*|\\\\.)*)\\/(?:\\(([mygi]+)\\))?/g,\n\t\t\t\trexMatch = rex.exec(filterString.substring(p));\n\t\t\tif(rexMatch) {\n\t\t\t\toperator.regexp = new RegExp(rexMatch[1], rexMatch[2]);\n\t\t\t\tnextBracketPos = p + rex.lastIndex - 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow \"Unterminated regular expression in filter expression\";\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tif(nextBracketPos === -1) {\n\t\t\tthrow \"Missing closing bracket in filter expression\";\n\t\t}\n\t\tif(!operator.regexp) {\n\t\t\toperator.operand = filterString.substring(p,nextBracketPos);\n\t\t}\n\t\tp = nextBracketPos + 1;\n\t\t\t\n\t\t// Push this operator\n\t\toperators.push(operator);\n\t} while(filterString.charAt(p) !== \"]\");\n\t// Skip the ending square bracket\n\tif(filterString.charAt(p++) !== \"]\") {\n\t\tthrow \"Missing ] in filter expression\";\n\t}\n\t// Return the parsing position\n\treturn p;\n}\n\n/*\nParse a filter string\n*/\nexports.parseFilter = function(filterString) {\n\tfilterString = filterString || \"\";\n\tvar results = [], // Array of arrays of operator nodes {operator:,operand:}\n\t\tp = 0, // Current position in the filter string\n\t\tmatch;\n\tvar whitespaceRegExp = /(\\s+)/mg,\n\t\toperandRegExp = /((?:\\+|\\-)?)(?:(\\[)|(\"(?:[^\"])*\")|('(?:[^'])*')|([^\\s\\[\\]]+))/mg;\n\twhile(p < filterString.length) {\n\t\t// Skip any whitespace\n\t\twhitespaceRegExp.lastIndex = p;\n\t\tmatch = whitespaceRegExp.exec(filterString);\n\t\tif(match && match.index === p) {\n\t\t\tp = p + match[0].length;\n\t\t}\n\t\t// Match the start of the operation\n\t\tif(p < filterString.length) {\n\t\t\toperandRegExp.lastIndex = p;\n\t\t\tmatch = operandRegExp.exec(filterString);\n\t\t\tif(!match || match.index !== p) {\n\t\t\t\tthrow \"Syntax error in filter expression\";\n\t\t\t}\n\t\t\tvar operation = {\n\t\t\t\tprefix: \"\",\n\t\t\t\toperators: []\n\t\t\t};\n\t\t\tif(match[1]) {\n\t\t\t\toperation.prefix = match[1];\n\t\t\t\tp++;\n\t\t\t}\n\t\t\tif(match[2]) { // Opening square bracket\n\t\t\t\tp = parseFilterOperation(operation.operators,filterString,p);\n\t\t\t} else {\n\t\t\t\tp = match.index + match[0].length;\n\t\t\t}\n\t\t\tif(match[3] || match[4] || match[5]) { // Double quoted string, single quoted string or unquoted title\n\t\t\t\toperation.operators.push(\n\t\t\t\t\t{operator: \"title\", operand: match[3] || match[4] || match[5]}\n\t\t\t\t);\n\t\t\t}\n\t\t\tresults.push(operation);\n\t\t}\n\t}\n\treturn results;\n};\n\nexports.getFilterOperators = function() {\n\tif(!this.filterOperators) {\n\t\t$tw.Wiki.prototype.filterOperators = {};\n\t\t$tw.modules.applyMethods(\"filteroperator\",this.filterOperators);\n\t}\n\treturn this.filterOperators;\n};\n\nexports.filterTiddlers = function(filterString,widget,source) {\n\tvar fn = this.compileFilter(filterString);\n\treturn fn.call(this,source,widget);\n};\n\n/*\nCompile a filter into a function with the signature fn(source,widget) where:\nsource: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)\nwidget: an optional widget node for retrieving the current tiddler etc.\n*/\nexports.compileFilter = function(filterString) {\n\tvar filterParseTree;\n\ttry {\n\t\tfilterParseTree = this.parseFilter(filterString);\n\t} catch(e) {\n\t\treturn function(source,widget) {\n\t\t\treturn [\"Filter error: \" + e];\n\t\t};\n\t}\n\t// Get the hashmap of filter operator functions\n\tvar filterOperators = this.getFilterOperators();\n\t// Assemble array of functions, one for each operation\n\tvar operationFunctions = [];\n\t// Step through the operations\n\tvar self = this;\n\t$tw.utils.each(filterParseTree,function(operation) {\n\t\t// Create a function for the chain of operators in the operation\n\t\tvar operationSubFunction = function(source,widget) {\n\t\t\tvar accumulator = source,\n\t\t\t\tresults = [],\n\t\t\t\tcurrTiddlerTitle = widget && widget.getVariable(\"currentTiddler\");\n\t\t\t$tw.utils.each(operation.operators,function(operator) {\n\t\t\t\tvar operand = operator.operand,\n\t\t\t\t\toperatorFunction;\n\t\t\t\tif(!operator.operator) {\n\t\t\t\t\toperatorFunction = filterOperators.title;\n\t\t\t\t} else if(!filterOperators[operator.operator]) {\n\t\t\t\t\toperatorFunction = filterOperators.field;\n\t\t\t\t} else {\n\t\t\t\t\toperatorFunction = filterOperators[operator.operator];\n\t\t\t\t}\n\t\t\t\tif(operator.indirect) {\n\t\t\t\t\toperand = self.getTextReference(operator.operand,\"\",currTiddlerTitle);\n\t\t\t\t}\n\t\t\t\tresults = operatorFunction(accumulator,{\n\t\t\t\t\t\t\toperator: operator.operator,\n\t\t\t\t\t\t\toperand: operand,\n\t\t\t\t\t\t\tprefix: operator.prefix,\n\t\t\t\t\t\t\tsuffix: operator.suffix,\n\t\t\t\t\t\t\tregexp: operator.regexp\n\t\t\t\t\t\t},{\n\t\t\t\t\t\t\twiki: self,\n\t\t\t\t\t\t\twidget: widget\n\t\t\t\t\t\t});\n\t\t\t\tif($tw.utils.isArray(results)) {\n\t\t\t\t\taccumulator = self.makeTiddlerIterator(results);\n\t\t\t\t} else {\n\t\t\t\t\taccumulator = results;\n\t\t\t\t}\n\t\t\t});\n\t\t\tif($tw.utils.isArray(results)) {\n\t\t\t\treturn results;\n\t\t\t} else {\n\t\t\t\tvar resultArray = [];\n\t\t\t\tresults(function(tiddler,title) {\n\t\t\t\t\tresultArray.push(title);\n\t\t\t\t});\n\t\t\t\treturn resultArray;\n\t\t\t}\n\t\t};\n\t\t// Wrap the operator functions in a wrapper function that depends on the prefix\n\t\toperationFunctions.push((function() {\n\t\t\tswitch(operation.prefix || \"\") {\n\t\t\t\tcase \"\": // No prefix means that the operation is unioned into the result\n\t\t\t\t\treturn function(results,source,widget) {\n\t\t\t\t\t\t$tw.utils.pushTop(results,operationSubFunction(source,widget));\n\t\t\t\t\t};\n\t\t\t\tcase \"-\": // The results of this operation are removed from the main result\n\t\t\t\t\treturn function(results,source,widget) {\n\t\t\t\t\t\t$tw.utils.removeArrayEntries(results,operationSubFunction(source,widget));\n\t\t\t\t\t};\n\t\t\t\tcase \"+\": // This operation is applied to the main results so far\n\t\t\t\t\treturn function(results,source,widget) {\n\t\t\t\t\t\t// This replaces all the elements of the array, but keeps the actual array so that references to it are preserved\n\t\t\t\t\t\tsource = self.makeTiddlerIterator(results);\n\t\t\t\t\t\tresults.splice(0,results.length);\n\t\t\t\t\t\t$tw.utils.pushTop(results,operationSubFunction(source,widget));\n\t\t\t\t\t};\n\t\t\t}\n\t\t})());\n\t});\n\t// Return a function that applies the operations to a source iterator of tiddler titles\n\treturn $tw.perf.measure(\"filter\",function filterFunction(source,widget) {\n\t\tif(!source) {\n\t\t\tsource = self.each;\n\t\t} else if(typeof source === \"object\") { // Array or hashmap\n\t\t\tsource = self.makeTiddlerIterator(source);\n\t\t}\n\t\tvar results = [];\n\t\t$tw.utils.each(operationFunctions,function(operationFunction) {\n\t\t\toperationFunction(results,source,widget);\n\t\t});\n\t\treturn results;\n\t});\n};\n\n})();\n",
"title": "$:/core/modules/filters.js",
"type": "application/javascript",
"module-type": "wikimethod"
},
"$:/core/modules/language.js": {
"text": "/*\\\ntitle: $:/core/modules/language.js\ntype: application/javascript\nmodule-type: global\n\nThe $tw.Language() manages translateable strings\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nCreate an instance of the language manager. Options include:\nwiki: wiki from which to retrieve translation tiddlers\n*/\nfunction Language(options) {\n\toptions = options || \"\";\n\tthis.wiki = options.wiki || $tw.wiki;\n}\n\n/*\nReturn a single translateable string. The title is automatically prefixed with \"$:/language/\"\nOptions include:\nvariables: optional hashmap of variables to supply to the language wikification\n*/\nLanguage.prototype.getString = function(title,options) {\n\toptions = options || {};\n\ttitle = \"$:/language/\" + title;\n\treturn this.wiki.renderTiddler(\"text/plain\",title,{variables: options.variables});\n};\n\nexports.Language = Language;\n\n})();\n",
"title": "$:/core/modules/language.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/macros/changecount.js": {
"text": "/*\\\ntitle: $:/core/modules/macros/changecount.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to return the changecount for the current tiddler\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nexports.name = \"changecount\";\n\nexports.params = [];\n\n/*\nRun the macro\n*/\nexports.run = function() {\n\treturn this.wiki.getChangeCount(this.getVariable(\"currentTiddler\")) + \"\";\n};\n\n})();\n",
"title": "$:/core/modules/macros/changecount.js",
"type": "application/javascript",
"module-type": "macro"
},
"$:/core/modules/macros/makedatauri.js": {
"text": "/*\\\ntitle: $:/core/modules/macros/makedatauri.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to convert the content of a tiddler to a data URI\n\n<<makedatauri text:\"Text to be converted\" type:\"text/vnd.tiddlywiki\">>\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nexports.name = \"makedatauri\";\n\nexports.params = [\n\t{name: \"text\"},\n\t{name: \"type\"}\n];\n\n/*\nRun the macro\n*/\nexports.run = function(text,type) {\n\ttype = type || \"text/vnd.tiddlywiki\";\n\tvar typeInfo = $tw.config.contentTypeInfo[type] || $tw.config.contentTypeInfo[\"text/plain\"],\n\t\tisBase64 = typeInfo.encoding === \"base64\",\n\t\tparts = [];\n\tparts.push(\"data:\");\n\tparts.push(type);\n\tparts.push(isBase64 ? \";base64\" : \"\");\n\tparts.push(\",\");\n\tparts.push(isBase64 ? text : encodeURIComponent(text));\n\treturn parts.join(\"\");\n};\n\n})();\n",
"title": "$:/core/modules/macros/makedatauri.js",
"type": "application/javascript",
"module-type": "macro"
},
"$:/core/modules/macros/qualify.js": {
"text": "/*\\\ntitle: $:/core/modules/macros/qualify.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to qualify a state tiddler title according\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nexports.name = \"qualify\";\n\nexports.params = [\n\t{name: \"title\"}\n];\n\n/*\nRun the macro\n*/\nexports.run = function(title) {\n\treturn title + \"-\" + this.getStateQualifier();\n};\n\n})();\n",
"title": "$:/core/modules/macros/qualify.js",
"type": "application/javascript",
"module-type": "macro"
},
"$:/core/modules/macros/version.js": {
"text": "/*\\\ntitle: $:/core/modules/macros/version.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to return the TiddlyWiki core version number\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nexports.name = \"version\";\n\nexports.params = [];\n\n/*\nRun the macro\n*/\nexports.run = function() {\n\treturn $tw.version;\n};\n\n})();\n",
"title": "$:/core/modules/macros/version.js",
"type": "application/javascript",
"module-type": "macro"
},
"$:/core/modules/parsers/csvparser.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/csvparser.js\ntype: application/javascript\nmodule-type: parser\n\nThe CSV text parser processes CSV files into a table wrapped in a scrollable widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar CsvParser = function(type,text,options) {\n\t// Table framework\n\tthis.tree = [{\n\t\t\"type\": \"scrollable\", \"children\": [{\n\t\t\t\"type\": \"element\", \"tag\": \"table\", \"children\": [{\n\t\t\t\t\"type\": \"element\", \"tag\": \"tbody\", \"children\": []\n\t\t\t}], \"attributes\": {\n\t\t\t\t\"class\": {\"type\": \"string\", \"value\": \"tw-csv-table\"}\n\t\t\t}\n\t\t}]\n\t}];\n\t// Split the text into lines\n\tvar lines = text.split(/\\r?\\n/mg),\n\t\ttag = \"th\";\n\tfor(var line=0; line<lines.length; line++) {\n\t\tvar lineText = lines[line];\n\t\tif(lineText) {\n\t\t\tvar row = {\n\t\t\t\t\t\"type\": \"element\", \"tag\": \"tr\", \"children\": []\n\t\t\t\t};\n\t\t\tvar columns = lineText.split(\",\");\n\t\t\tfor(var column=0; column<columns.length; column++) {\n\t\t\t\trow.children.push({\n\t\t\t\t\t\t\"type\": \"element\", \"tag\": tag, \"children\": [{\n\t\t\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\t\t\"text\": columns[column]\n\t\t\t\t\t\t}]\n\t\t\t\t\t});\n\t\t\t}\n\t\t\ttag = \"td\";\n\t\t\tthis.tree[0].children[0].children[0].children.push(row);\n\t\t}\n\t}\n};\n\nexports[\"text/csv\"] = CsvParser;\n\n})();\n\n",
"title": "$:/core/modules/parsers/csvparser.js",
"type": "application/javascript",
"module-type": "parser"
},
"$:/core/modules/parsers/htmlparser.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/htmlparser.js\ntype: application/javascript\nmodule-type: parser\n\nThe HTML parser displays text as raw HTML\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar HtmlParser = function(type,text,options) {\n\tthis.tree = [{\n\t\ttype: \"raw\",\n\t\thtml: text\n\t}];\n};\n\nexports[\"text/html\"] = HtmlParser;\n\n})();\n\n",
"title": "$:/core/modules/parsers/htmlparser.js",
"type": "application/javascript",
"module-type": "parser"
},
"$:/core/modules/parsers/imageparser.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/imageparser.js\ntype: application/javascript\nmodule-type: parser\n\nThe image parser parses an image into an embeddable HTML element\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar ImageParser = function(type,text,options) {\n\tvar element = {\n\t\t\ttype: \"element\",\n\t\t\ttag: \"img\",\n\t\t\tattributes: {}\n\t\t},\n\t\tsrc;\n\tif(text) {\n\t\tif(type === \"application/pdf\" || type === \".pdf\") {\n\t\t\telement.attributes.src = {type: \"string\", value: \"data:application/pdf;base64,\" + text};\n\t\t\telement.tag = \"embed\";\n\t\t} else if(type === \"image/svg+xml\" || type === \".svg\") {\n\t\t\telement.attributes.src = {type: \"string\", value: \"data:image/svg+xml,\" + encodeURIComponent(text)};\n\t\t} else {\n\t\t\telement.attributes.src = {type: \"string\", value: \"data:\" + type + \";base64,\" + text};\n\t\t}\n\t}\n\tthis.tree = [element];\n};\n\nexports[\"image/svg+xml\"] = ImageParser;\nexports[\"image/jpg\"] = ImageParser;\nexports[\"image/jpeg\"] = ImageParser;\nexports[\"image/png\"] = ImageParser;\nexports[\"image/gif\"] = ImageParser;\nexports[\"application/pdf\"] = ImageParser;\nexports[\"image/x-icon\"] = ImageParser;\n\n})();\n\n",
"title": "$:/core/modules/parsers/imageparser.js",
"type": "application/javascript",
"module-type": "parser"
},
"$:/core/modules/utils/parseutils.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/parseutils.js\ntype: application/javascript\nmodule-type: utils\n\nUtility functions concerned with parsing text into tokens.\n\nMost functions have the following pattern:\n\n* The parameters are:\n** `source`: the source string being parsed\n** `pos`: the current parse position within the string\n** Any further parameters are used to identify the token that is being parsed\n* The return value is:\n** null if the token was not found at the specified position\n** an object representing the token with the following standard fields:\n*** `type`: string indicating the type of the token\n*** `start`: start position of the token in the source string\n*** `end`: end position of the token in the source string\n*** Any further fields required to describe the token\n\nThe exception is `skipWhiteSpace`, which just returns the position after the whitespace.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nLook for a whitespace token. Returns null if not found, otherwise returns {type: \"whitespace\", start:, end:,}\n*/\nexports.parseWhiteSpace = function(source,pos) {\n\tvar node = {\n\t\ttype: \"whitespace\",\n\t\tstart: pos\n\t};\n\tvar re = /(\\s)+/g;\n\tre.lastIndex = pos;\n\tvar match = re.exec(source);\n\tif(match && match.index === pos) {\n\t\tnode.end = pos + match[0].length;\n\t\treturn node;\n\t}\n\treturn null;\n};\n\n/*\nConvenience wrapper for parseWhiteSpace. Returns the position after the whitespace\n*/\nexports.skipWhiteSpace = function(source,pos) {\n\tvar whitespace = $tw.utils.parseWhiteSpace(source,pos);\n\tif(whitespace) {\n\t\treturn whitespace.end;\n\t}\n\treturn pos;\n};\n\n/*\nLook for a given string token. Returns null if not found, otherwise returns {type: \"token\", value:, start:, end:,}\n*/\nexports.parseTokenString = function(source,pos,token) {\n\tvar match = source.indexOf(token,pos) === pos;\n\tif(match) {\n\t\treturn {\n\t\t\ttype: \"token\",\n\t\t\tvalue: token,\n\t\t\tstart: pos,\n\t\t\tend: pos + token.length\n\t\t};\n\t}\n\treturn null;\n};\n\n/*\nLook for a token matching a regex. Returns null if not found, otherwise returns {type: \"regexp\", match:, start:, end:,}\n*/\nexports.parseTokenRegExp = function(source,pos,reToken) {\n\tvar node = {\n\t\ttype: \"regexp\",\n\t\tstart: pos\n\t};\n\treToken.lastIndex = pos;\n\tnode.match = reToken.exec(source);\n\tif(node.match && node.match.index === pos) {\n\t\tnode.end = pos + node.match[0].length;\n\t\treturn node;\n\t} else {\n\t\treturn null;\n\t}\n};\n\n/*\nLook for a string literal. Returns null if not found, otherwise returns {type: \"string\", value:, start:, end:,}\n*/\nexports.parseStringLiteral = function(source,pos) {\n\tvar node = {\n\t\ttype: \"string\",\n\t\tstart: pos\n\t};\n\tvar reString = /(?:\"([^\"]*)\")|(?:'([^']*)')/g;\n\treString.lastIndex = pos;\n\tvar match = reString.exec(source);\n\tif(match && match.index === pos) {\n\t\tnode.value = match[1] === undefined ? match[2] : match[1];\n\t\tnode.end = pos + match[0].length;\n\t\treturn node;\n\t} else {\n\t\treturn null;\n\t}\n};\n\n/*\nLook for a macro invocation parameter. Returns null if not found, or {type: \"macro-parameter\", name:, value:, start:, end:}\n*/\nexports.parseMacroParameter = function(source,pos) {\n\tvar node = {\n\t\ttype: \"macro-parameter\",\n\t\tstart: pos\n\t};\n\t// Define our regexp\n\tvar reMacroParameter = /(?:([A-Za-z0-9\\-_]+)\\s*:)?(?:\\s*(?:\"([^\"]*)\"|'([^']*)'|\\[\\[([^\\]]*)\\]\\]|([^\\s>\"'=]+)))/g;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for the parameter\n\tvar token = $tw.utils.parseTokenRegExp(source,pos,reMacroParameter);\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Get the parameter details\n\tnode.value = token.match[2] !== undefined ? token.match[2] : (\n\t\t\t\t\ttoken.match[3] !== undefined ? token.match[3] : (\n\t\t\t\t\t\ttoken.match[4] !== undefined ? token.match[4] : (\n\t\t\t\t\t\t\ttoken.match[5] !== undefined ? token.match[5] : (\n\t\t\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\tif(token.match[1]) {\n\t\tnode.name = token.match[1];\n\t}\n\t// Update the end position\n\tnode.end = pos;\n\treturn node;\n};\n\n/*\nLook for a macro invocation. Returns null if not found, or {type: \"macrocall\", name:, parameters:, start:, end:}\n*/\nexports.parseMacroInvocation = function(source,pos) {\n\tvar node = {\n\t\ttype: \"macrocall\",\n\t\tstart: pos,\n\t\tparams: []\n\t};\n\t// Define our regexps\n\tvar reMacroName = /([^\\s>\"'=]+)/g;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for a double less than sign\n\tvar token = $tw.utils.parseTokenString(source,pos,\"<<\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Get the macro name\n\tvar name = $tw.utils.parseTokenRegExp(source,pos,reMacroName);\n\tif(!name) {\n\t\treturn null;\n\t}\n\tnode.name = name.match[1];\n\tpos = name.end;\n\t// Process parameters\n\tvar parameter = $tw.utils.parseMacroParameter(source,pos);\n\twhile(parameter) {\n\t\tnode.params.push(parameter);\n\t\tpos = parameter.end;\n\t\t// Get the next parameter\n\t\tparameter = $tw.utils.parseMacroParameter(source,pos);\n\t}\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for a double greater than sign\n\ttoken = $tw.utils.parseTokenString(source,pos,\">>\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Update the end position\n\tnode.end = pos;\n\treturn node;\n};\n\n/*\nLook for an HTML attribute definition. Returns null if not found, otherwise returns {type: \"attribute\", name:, valueType: \"string|indirect|macro\", value:, start:, end:,}\n*/\nexports.parseAttribute = function(source,pos) {\n\tvar node = {\n\t\tstart: pos\n\t};\n\t// Define our regexps\n\tvar reAttributeName = /([^\\/\\s>\"'=]+)/g,\n\t\treUnquotedAttribute = /([^\\/\\s<>\"'=]+)/g,\n\t\treIndirectValue = /\\{\\{([^\\}]+)\\}\\}/g;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Get the attribute name\n\tvar name = $tw.utils.parseTokenRegExp(source,pos,reAttributeName);\n\tif(!name) {\n\t\treturn null;\n\t}\n\tnode.name = name.match[1];\n\tpos = name.end;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for an equals sign\n\tvar token = $tw.utils.parseTokenString(source,pos,\"=\");\n\tif(token) {\n\t\tpos = token.end;\n\t\t// Skip whitespace\n\t\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t\t// Look for a string literal\n\t\tvar stringLiteral = $tw.utils.parseStringLiteral(source,pos);\n\t\tif(stringLiteral) {\n\t\t\tpos = stringLiteral.end;\n\t\t\tnode.type = \"string\";\n\t\t\tnode.value = stringLiteral.value;\n\t\t} else {\n\t\t\t// Look for an indirect value\n\t\t\tvar indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);\n\t\t\tif(indirectValue) {\n\t\t\t\tpos = indirectValue.end;\n\t\t\t\tnode.type = \"indirect\";\n\t\t\t\tnode.textReference = indirectValue.match[1];\n\t\t\t} else {\n\t\t\t\t// Look for a unquoted value\n\t\t\t\tvar unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);\n\t\t\t\tif(unquotedValue) {\n\t\t\t\t\tpos = unquotedValue.end;\n\t\t\t\t\tnode.type = \"string\";\n\t\t\t\t\tnode.value = unquotedValue.match[1];\n\t\t\t\t} else {\n\t\t\t\t\t// Look for a macro invocation value\n\t\t\t\t\tvar macroInvocation = $tw.utils.parseMacroInvocation(source,pos);\n\t\t\t\t\tif(macroInvocation) {\n\t\t\t\t\t\tpos = macroInvocation.end;\n\t\t\t\t\t\tnode.type = \"macro\";\n\t\t\t\t\t\tnode.value = macroInvocation;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.type = \"string\";\n\t\t\t\t\t\tnode.value = \"true\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tnode.type = \"string\";\n\t\tnode.value = \"true\";\n\t}\n\t// Update the end position\n\tnode.end = pos;\n\treturn node;\n};\n\n})();\n",
"title": "$:/core/modules/utils/parseutils.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/parsers/textparser.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/textparser.js\ntype: application/javascript\nmodule-type: parser\n\nThe plain text parser processes blocks of source text into a degenerate parse tree consisting of a single text node\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar TextParser = function(type,text,options) {\n\tthis.tree = [{\n\t\ttype: \"codeblock\",\n\t\tattributes: {\n\t\t\tcode: {type: \"string\", value: text},\n\t\t\tlanguage: {type: \"string\", value: type}\n\t\t}\n\t}];\n};\n\nexports[\"text/plain\"] = TextParser;\nexports[\"text/x-tiddlywiki\"] = TextParser;\nexports[\"application/javascript\"] = TextParser;\nexports[\"application/json\"] = TextParser;\nexports[\"text/css\"] = TextParser;\nexports[\"application/x-tiddler-dictionary\"] = TextParser;\n\n})();\n\n",
"title": "$:/core/modules/parsers/textparser.js",
"type": "application/javascript",
"module-type": "parser"
},
"$:/core/modules/parsers/wikiparser/rules/codeblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/codeblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for code blocks. For example:\n\n```\n\t```\n\tThis text will not be //wikified//\n\t```\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"codeblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match and get language if defined\n\tthis.matchRegExp = /```([\\w-]*)\\r?\\n/mg;\n};\n\nexports.parse = function() {\n\tvar reEnd = /(\\r?\\n```$)/mg;\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\n\t// Look for the end of the block\n\treEnd.lastIndex = this.parser.pos;\n\tvar match = reEnd.exec(this.parser.source),\n\t\ttext;\n\t// Process the block\n\tif(match) {\n\t\ttext = this.parser.source.substring(this.parser.pos,match.index);\n\t\tthis.parser.pos = match.index + match[0].length;\n\t} else {\n\t\ttext = this.parser.source.substr(this.parser.pos);\n\t\tthis.parser.pos = this.parser.sourceLength;\n\t}\n\t// Return the $codeblock widget\n\treturn [{\n\t\t\ttype: \"codeblock\",\n\t\t\tattributes: {\n\t\t\t\t\tcode: {type: \"string\", value: text},\n\t\t\t\t\tlanguage: {type: \"string\", value: this.match[1]}\n\t\t\t}\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/codeblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/codeinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/codeinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for code runs. For example:\n\n```\n\tThis is a `code run`.\n\tThis is another ``code run``\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"codeinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /(``?)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\tvar reEnd = new RegExp(this.match[1], \"mg\");\n\t// Look for the end marker\n\treEnd.lastIndex = this.parser.pos;\n\tvar match = reEnd.exec(this.parser.source),\n\t\ttext;\n\t// Process the text\n\tif(match) {\n\t\ttext = this.parser.source.substring(this.parser.pos,match.index);\n\t\tthis.parser.pos = match.index + match[0].length;\n\t} else {\n\t\ttext = this.parser.source.substr(this.parser.pos);\n\t\tthis.parser.pos = this.parser.sourceLength;\n\t}\n\treturn [{\n\t\ttype: \"element\",\n\t\ttag: \"code\",\n\t\tchildren: [{\n\t\t\ttype: \"text\",\n\t\t\ttext: text\n\t\t}]\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/codeinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/commentblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/commentblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for HTML comments. For example:\n\n```\n<!-- This is a comment -->\n```\n\nNote that the syntax for comments is simplified to an opening \"<!--\" sequence and a closing \"-->\" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html)\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"commentblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\tthis.matchRegExp = /\\<!--/mg;\n\tthis.endMatchRegExp = /--\\>/mg;\n};\n\nexports.findNextMatch = function(startPos) {\n\tthis.matchRegExp.lastIndex = startPos;\n\tthis.match = this.matchRegExp.exec(this.parser.source);\n\tif(this.match) {\n\t\tthis.endMatchRegExp.lastIndex = startPos + this.match[0].length;\n\t\tthis.endMatch = this.endMatchRegExp.exec(this.parser.source);\n\t\tif(this.endMatch) {\n\t\t\treturn this.match.index;\n\t\t}\n\t}\n\treturn undefined;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.endMatchRegExp.lastIndex;\n\t// Don't return any elements\n\treturn [];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/commentblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/commentinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/commentinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for HTML comments. For example:\n\n```\n<!-- This is a comment -->\n```\n\nNote that the syntax for comments is simplified to an opening \"<!--\" sequence and a closing \"-->\" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html)\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"commentinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\tthis.matchRegExp = /\\<!--/mg;\n\tthis.endMatchRegExp = /--\\>/mg;\n};\n\nexports.findNextMatch = function(startPos) {\n\tthis.matchRegExp.lastIndex = startPos;\n\tthis.match = this.matchRegExp.exec(this.parser.source);\n\tif(this.match) {\n\t\tthis.endMatchRegExp.lastIndex = startPos + this.match[0].length;\n\t\tthis.endMatch = this.endMatchRegExp.exec(this.parser.source);\n\t\tif(this.endMatch) {\n\t\t\treturn this.match.index;\n\t\t}\n\t}\n\treturn undefined;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.endMatchRegExp.lastIndex;\n\t// Don't return any elements\n\treturn [];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/commentinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/dash.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/dash.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for dashes. For example:\n\n```\nThis is an en-dash: --\n\nThis is an em-dash: ---\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"dash\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /-{2,3}(?!-)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\tvar dash = this.match[0].length === 2 ? \"–\" : \"—\";\n\treturn [{\n\t\ttype: \"entity\",\n\t\tentity: dash\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/dash.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/emphasis.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/emphasis.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for emphasis. For example:\n\n```\n\tThis is ''bold'' text\n\n\tThis is //italic// text\n\n\tThis is __underlined__ text\n\n\tThis is ^^superscript^^ text\n\n\tThis is ,,subscript,, text\n\n\tThis is ~~strikethrough~~ text\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"emphasis\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /''|\\/\\/|__|\\^\\^|,,|~~/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Figure out which element and closing regexp to use\n\tvar tag,reEnd;\n\tswitch(this.match[0]) {\n\t\tcase \"''\": // Bold\n\t\t\ttag = \"strong\";\n\t\t\treEnd = /''/mg;\n\t\t\tbreak;\n\t\tcase \"//\": // Italics\n\t\t\ttag = \"em\";\n\t\t\treEnd = /\\/\\//mg;\n\t\t\tbreak;\n\t\tcase \"__\": // Underline\n\t\t\ttag = \"u\";\n\t\t\treEnd = /__/mg;\n\t\t\tbreak;\n\t\tcase \"^^\": // Superscript\n\t\t\ttag = \"sup\";\n\t\t\treEnd = /\\^\\^/mg;\n\t\t\tbreak;\n\t\tcase \",,\": // Subscript\n\t\t\ttag = \"sub\";\n\t\t\treEnd = /,,/mg;\n\t\t\tbreak;\n\t\tcase \"~~\": // Strikethrough\n\t\t\ttag = \"strike\";\n\t\t\treEnd = /~~/mg;\n\t\t\tbreak;\n\t}\n\t// Parse the run including the terminator\n\tvar tree = this.parser.parseInlineRun(reEnd,{eatTerminator: true});\n\t// Return the classed span\n\treturn [{\n\t\ttype: \"element\",\n\t\ttag: tag,\n\t\tchildren: tree\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/emphasis.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/entity.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/entity.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for HTML entities. For example:\n\n```\n\tThis is a copyright symbol: ©\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"entity\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /(&#?[a-zA-Z0-9]{2,8};)/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Get all the details of the match\n\tvar entityString = this.match[1];\n\t// Move past the macro call\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Return the entity\n\treturn [{type: \"entity\", entity: this.match[0]}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/entity.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/extlink.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/extlink.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for external links. For example:\n\n```\nAn external link: http://www.tiddlywiki.com/\n\nA suppressed external link: ~http://www.tiddlyspace.com/\n```\n\nExternal links can be suppressed by preceding them with `~`.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"extlink\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /~?(?:file|http|https|mailto|ftp|irc|news|data|skype):[^\\s<>{}\\[\\]`|'\"\\\\^~]+(?:\\/|\\b)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Create the link unless it is suppressed\n\tif(this.match[0].substr(0,1) === \"~\") {\n\t\treturn [{type: \"text\", text: this.match[0].substr(1)}];\n\t} else {\n\t\treturn [{\n\t\t\ttype: \"element\",\n\t\t\ttag: \"a\",\n\t\t\tattributes: {\n\t\t\t\thref: {type: \"string\", value: this.match[0]},\n\t\t\t\t\"class\": {type: \"string\", value: \"tw-tiddlylink-external\"},\n\t\t\t\ttarget: {type: \"string\", value: \"_blank\"}\n\t\t\t},\n\t\t\tchildren: [{\n\t\t\t\ttype: \"text\", text: this.match[0]\n\t\t\t}]\n\t\t}];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/extlink.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for block-level filtered transclusion. For example:\n\n```\n{{{ [tag[docs]] }}}\n{{{ [tag[docs]] |tooltip}}}\n{{{ [tag[docs]] ||TemplateTitle}}}\n{{{ [tag[docs]] |tooltip||TemplateTitle}}}\n{{{ [tag[docs]] }}width:40;height:50;}.class.class\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"filteredtranscludeblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\{\\{\\{([^\\|]+?)(?:\\|([^\\|\\{\\}]+))?(?:\\|\\|([^\\|\\{\\}]+))?\\}\\}([^\\}]*)\\}(?:\\.(\\S+))?(?:\\r?\\n|$)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Get the match details\n\tvar filter = this.match[1],\n\t\ttooltip = this.match[2],\n\t\ttemplate = $tw.utils.trim(this.match[3]),\n\t\tstyle = this.match[4],\n\t\tclasses = this.match[5];\n\t// Return the list widget\n\tvar node = {\n\t\ttype: \"list\",\n\t\tattributes: {\n\t\t\tfilter: {type: \"string\", value: filter}\n\t\t},\n\t\tisBlock: true\n\t};\n\tif(tooltip) {\n\t\tnode.attributes.tooltip = {type: \"string\", value: tooltip};\n\t}\n\tif(template) {\n\t\tnode.attributes.template = {type: \"string\", value: template};\n\t}\n\tif(style) {\n\t\tnode.attributes.style = {type: \"string\", value: style};\n\t}\n\tif(classes) {\n\t\tnode.attributes[\"itemClass\"] = {type: \"string\", value: classes.split(\".\").join(\" \")};\n\t}\n\treturn [node];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for inline filtered transclusion. For example:\n\n```\n{{{ [tag[docs]] }}}\n{{{ [tag[docs]] |tooltip}}}\n{{{ [tag[docs]] ||TemplateTitle}}}\n{{{ [tag[docs]] |tooltip||TemplateTitle}}}\n{{{ [tag[docs]] }}width:40;height:50;}.class.class\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"filteredtranscludeinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\{\\{\\{([^\\|]+?)(?:\\|([^\\|\\{\\}]+))?(?:\\|\\|([^\\|\\{\\}]+))?\\}\\}([^\\}]*)\\}(?:\\.(\\S+))?/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Get the match details\n\tvar filter = this.match[1],\n\t\ttooltip = this.match[2],\n\t\ttemplate = $tw.utils.trim(this.match[3]),\n\t\tstyle = this.match[4],\n\t\tclasses = this.match[5];\n\t// Return the list widget\n\tvar node = {\n\t\ttype: \"list\",\n\t\tattributes: {\n\t\t\tfilter: {type: \"string\", value: filter}\n\t\t}\n\t};\n\tif(tooltip) {\n\t\tnode.attributes.tooltip = {type: \"string\", value: tooltip};\n\t}\n\tif(template) {\n\t\tnode.attributes.template = {type: \"string\", value: template};\n\t}\n\tif(style) {\n\t\tnode.attributes.style = {type: \"string\", value: style};\n\t}\n\tif(classes) {\n\t\tnode.attributes[\"itemClass\"] = {type: \"string\", value: classes.split(\".\").join(\" \")};\n\t}\n\treturn [node];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/hardlinebreaks.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/hardlinebreaks.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for marking areas with hard line breaks. For example:\n\n```\n\"\"\"\nThis is some text\nThat is set like\nIt is a Poem\nWhen it is\nClearly\nNot\n\"\"\"\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"hardlinebreaks\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\"\"\"(?:\\r?\\n)?/mg;\n};\n\nexports.parse = function() {\n\tvar reEnd = /(\"\"\")|(\\r?\\n)/mg,\n\t\ttree = [];\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\tdo {\n\t\t// Parse the run up to the terminator\n\t\ttree.push.apply(tree,this.parser.parseInlineRun(reEnd,{eatTerminator: false}));\n\t\t// Redo the terminator match\n\t\treEnd.lastIndex = this.parser.pos;\n\t\tvar match = reEnd.exec(this.parser.source);\n\t\tif(match) {\n\t\t\tthis.parser.pos = reEnd.lastIndex;\n\t\t\t// Add a line break if the terminator was a line break\n\t\t\tif(match[2]) {\n\t\t\t\ttree.push({type: \"element\", tag: \"br\"});\n\t\t\t}\n\t\t}\n\t} while(match && !match[1]);\n\t// Return the nodes\n\treturn tree;\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/hardlinebreaks.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/heading.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/heading.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for headings\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"heading\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /(!{1,6})/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Get all the details of the match\n\tvar headingLevel = this.match[1].length;\n\t// Move past the !s\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Parse any classes, whitespace and then the heading itself\n\tvar classes = this.parser.parseClasses();\n\tthis.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});\n\tvar tree = this.parser.parseInlineRun(/(\\r?\\n)/mg);\n\t// Return the heading\n\treturn [{\n\t\ttype: \"element\",\n\t\ttag: \"h\" + headingLevel, \n\t\tattributes: {\n\t\t\t\"class\": {type: \"string\", value: classes.join(\" \")}\n\t\t},\n\t\tchildren: tree\n\t}];\n};\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/heading.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/horizrule.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/horizrule.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for rules. For example:\n\n```\n---\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"horizrule\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /-{3,}\\r?(?:\\n|$)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\treturn [{type: \"element\", tag: \"hr\"}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/horizrule.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/html.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/html.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki rule for HTML elements and widgets. For example:\n\n{{{\n<aside>\nThis is an HTML5 aside element\n</aside>\n\n<$slider target=\"MyTiddler\">\nThis is a widget invocation\n</$slider>\n\n}}}\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"html\";\nexports.types = {inline: true, block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n};\n\nexports.findNextMatch = function(startPos) {\n\t// Find the next tag\n\tthis.nextTag = this.findNextTag(this.parser.source,startPos,{\n\t\trequireLineBreak: this.is.block\n\t});\n\treturn this.nextTag ? this.nextTag.start : undefined;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Retrieve the most recent match so that recursive calls don't overwrite it\n\tvar tag = this.nextTag;\n\tthis.nextTag = null;\n\t// Advance the parser position to past the tag\n\tthis.parser.pos = tag.end;\n\t// Check for an immediately following double linebreak\n\tvar hasLineBreak = !tag.isSelfClosing && !!$tw.utils.parseTokenRegExp(this.parser.source,this.parser.pos,/([^\\S\\n]*\\r?\\n(?:[^\\S\\n]*\\r?\\n|$))/g);\n\t// Set whether we're in block mode\n\ttag.isBlock = this.is.block || hasLineBreak;\n\t// Parse the body if we need to\n\tif(!tag.isSelfClosing && $tw.config.htmlVoidElements.indexOf(tag.tag) === -1) {\n\t\t\tvar reEndString = \"</\" + $tw.utils.escapeRegExp(tag.tag) + \">\",\n\t\t\t\treEnd = new RegExp(\"(\" + reEndString + \")\",\"mg\");\n\t\tif(hasLineBreak) {\n\t\t\ttag.children = this.parser.parseBlocks(reEndString);\n\t\t} else {\n\t\t\ttag.children = this.parser.parseInlineRun(reEnd);\n\t\t}\n\t\treEnd.lastIndex = this.parser.pos;\n\t\tvar endMatch = reEnd.exec(this.parser.source);\n\t\tif(endMatch && endMatch.index === this.parser.pos) {\n\t\t\tthis.parser.pos = endMatch.index + endMatch[0].length;\n\t\t}\n\t}\n\t// Return the tag\n\treturn [tag];\n};\n\n/*\nLook for an HTML tag. Returns null if not found, otherwise returns {type: \"element\", name:, attributes: [], isSelfClosing:, start:, end:,}\n*/\nexports.parseTag = function(source,pos,options) {\n\toptions = options || {};\n\tvar token,\n\t\tnode = {\n\t\t\ttype: \"element\",\n\t\t\tstart: pos,\n\t\t\tattributes: {}\n\t\t};\n\t// Define our regexps\n\tvar reTagName = /([a-zA-Z0-9\\-\\$]+)/g;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for a less than sign\n\ttoken = $tw.utils.parseTokenString(source,pos,\"<\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Get the tag name\n\ttoken = $tw.utils.parseTokenRegExp(source,pos,reTagName);\n\tif(!token) {\n\t\treturn null;\n\t}\n\tnode.tag = token.match[1];\n\tif(node.tag.charAt(0) === \"$\") {\n\t\tnode.type = node.tag.substr(1);\n\t}\n\tpos = token.end;\n\t// Process attributes\n\tvar attribute = $tw.utils.parseAttribute(source,pos);\n\twhile(attribute) {\n\t\tnode.attributes[attribute.name] = attribute;\n\t\tpos = attribute.end;\n\t\t// Get the next attribute\n\t\tattribute = $tw.utils.parseAttribute(source,pos);\n\t}\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for a closing slash\n\ttoken = $tw.utils.parseTokenString(source,pos,\"/\");\n\tif(token) {\n\t\tpos = token.end;\n\t\tnode.isSelfClosing = true;\n\t}\n\t// Look for a greater than sign\n\ttoken = $tw.utils.parseTokenString(source,pos,\">\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Check for a required line break\n\tif(options.requireLineBreak) {\n\t\ttoken = $tw.utils.parseTokenRegExp(source,pos,/([^\\S\\n]*\\r?\\n(?:[^\\S\\n]*\\r?\\n|$))/g);\n\t\tif(!token) {\n\t\t\treturn null;\n\t\t}\n\t}\n\t// Update the end position\n\tnode.end = pos;\n\treturn node;\n};\n\nexports.findNextTag = function(source,pos,options) {\n\t// A regexp for finding candidate HTML tags\n\tvar reLookahead = /<([a-zA-Z\\-\\$]+)/g;\n\t// Find the next candidate\n\treLookahead.lastIndex = pos;\n\tvar match = reLookahead.exec(source);\n\twhile(match) {\n\t\t// Try to parse the candidate as a tag\n\t\tvar tag = this.parseTag(source,match.index,options);\n\t\t// Return success\n\t\tif(tag && this.isLegalTag(tag)) {\n\t\t\treturn tag;\n\t\t}\n\t\t// Look for the next match\n\t\treLookahead.lastIndex = match.index + 1;\n\t\tmatch = reLookahead.exec(source);\n\t}\n\t// Failed\n\treturn null;\n};\n\nexports.isLegalTag = function(tag) {\n\t// Widgets are always OK\n\tif(tag.type !== \"element\") {\n\t\treturn true;\n\t// If it's an HTML tag that starts with a dash then it's not legal\n\t} else if(tag.tag.charAt(0) === \"-\") {\n\t\treturn false;\n\t} else {\n\t\t// Otherwise it's OK\n\t\treturn true;\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/html.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/image.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/image.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for embedding images. For example:\n\n```\n[img[http://tiddlywiki.com/fractalveg.jpg]]\n[img width=23 height=24 [http://tiddlywiki.com/fractalveg.jpg]]\n[img width={{!!width}} height={{!!height}} [http://tiddlywiki.com/fractalveg.jpg]]\n[img[Description of image|http://tiddlywiki.com/fractalveg.jpg]]\n[img[TiddlerTitle]]\n[img[Description of image|TiddlerTitle]]\n```\n\nGenerates the `<$image>` widget.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"image\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n};\n\nexports.findNextMatch = function(startPos) {\n\t// Find the next tag\n\tthis.nextImage = this.findNextImage(this.parser.source,startPos);\n\treturn this.nextImage ? this.nextImage.start : undefined;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.nextImage.end;\n\tvar node = {\n\t\ttype: \"image\",\n\t\tattributes: this.nextImage.attributes\n\t};\n\treturn [node];\n};\n\n/*\nFind the next image from the current position\n*/\nexports.findNextImage = function(source,pos) {\n\t// A regexp for finding candidate HTML tags\n\tvar reLookahead = /(\\[img)/g;\n\t// Find the next candidate\n\treLookahead.lastIndex = pos;\n\tvar match = reLookahead.exec(source);\n\twhile(match) {\n\t\t// Try to parse the candidate as a tag\n\t\tvar tag = this.parseImage(source,match.index);\n\t\t// Return success\n\t\tif(tag) {\n\t\t\treturn tag;\n\t\t}\n\t\t// Look for the next match\n\t\treLookahead.lastIndex = match.index + 1;\n\t\tmatch = reLookahead.exec(source);\n\t}\n\t// Failed\n\treturn null;\n};\n\n/*\nLook for an image at the specified position. Returns null if not found, otherwise returns {type: \"image\", attributes: [], isSelfClosing:, start:, end:,}\n*/\nexports.parseImage = function(source,pos) {\n\tvar token,\n\t\tnode = {\n\t\t\ttype: \"image\",\n\t\t\tstart: pos,\n\t\t\tattributes: {}\n\t\t};\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for the `[img`\n\ttoken = $tw.utils.parseTokenString(source,pos,\"[img\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Process attributes\n\tif(source.charAt(pos) !== \"[\") {\n\t\tvar attribute = $tw.utils.parseAttribute(source,pos);\n\t\twhile(attribute) {\n\t\t\tnode.attributes[attribute.name] = attribute;\n\t\t\tpos = attribute.end;\n\t\t\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t\t\tif(source.charAt(pos) !== \"[\") {\n\t\t\t\t// Get the next attribute\n\t\t\t\tattribute = $tw.utils.parseAttribute(source,pos);\n\t\t\t} else {\n\t\t\t\tattribute = null;\n\t\t\t}\n\t\t}\n\t}\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for the `[` after the attributes\n\ttoken = $tw.utils.parseTokenString(source,pos,\"[\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Get the source up to the terminating `]]`\n\ttoken = $tw.utils.parseTokenRegExp(source,pos,/(?:([^|\\]]*?)\\|)?([^\\]]+?)\\]\\]/g);\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\tif(token.match[1]) {\n\t\tnode.attributes.tooltip = {type: \"string\", value: token.match[1].trim()};\n\t}\n\tnode.attributes.source = {type: \"string\", value: (token.match[2] || \"\").trim()};\n\t// Update the end position\n\tnode.end = pos;\n\treturn node;\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/image.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/list.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/list.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for lists. For example:\n\n```\n* This is an unordered list\n* It has two items\n\n# This is a numbered list\n## With a subitem\n# And a third item\n\n; This is a term that is being defined\n: This is the definition of that term\n```\n\nNote that lists can be nested arbitrarily:\n\n```\n#** One\n#* Two\n#** Three\n#**** Four\n#**# Five\n#**## Six\n## Seven\n### Eight\n## Nine\n```\n\nA CSS class can be applied to a list item as follows:\n\n```\n* List item one\n*.active List item two has the class `active`\n* List item three\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"list\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /([\\*#;:>]+)/mg;\n};\n\nvar listTypes = {\n\t\"*\": {listTag: \"ul\", itemTag: \"li\"},\n\t\"#\": {listTag: \"ol\", itemTag: \"li\"},\n\t\";\": {listTag: \"dl\", itemTag: \"dt\"},\n\t\":\": {listTag: \"dl\", itemTag: \"dd\"},\n\t\">\": {listTag: \"blockquote\", itemTag: \"p\"}\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Array of parse tree nodes for the previous row of the list\n\tvar listStack = [];\n\t// Cycle through the items in the list\n\twhile(true) {\n\t\t// Match the list marker\n\t\tvar reMatch = /([\\*#;:>]+)/mg;\n\t\treMatch.lastIndex = this.parser.pos;\n\t\tvar match = reMatch.exec(this.parser.source);\n\t\tif(!match || match.index !== this.parser.pos) {\n\t\t\tbreak;\n\t\t}\n\t\t// Check whether the list type of the top level matches\n\t\tvar listInfo = listTypes[match[0].charAt(0)];\n\t\tif(listStack.length > 0 && listStack[0].tag !== listInfo.listTag) {\n\t\t\tbreak;\n\t\t}\n\t\t// Move past the list marker\n\t\tthis.parser.pos = match.index + match[0].length;\n\t\t// Walk through the list markers for the current row\n\t\tfor(var t=0; t<match[0].length; t++) {\n\t\t\tlistInfo = listTypes[match[0].charAt(t)];\n\t\t\t// Remove any stacked up element if we can't re-use it because the list type doesn't match\n\t\t\tif(listStack.length > t && listStack[t].tag !== listInfo.listTag) {\n\t\t\t\tlistStack.splice(t,listStack.length - t);\n\t\t\t}\n\t\t\t// Construct the list element or reuse the previous one at this level\n\t\t\tif(listStack.length <= t) {\n\t\t\t\tvar listElement = {type: \"element\", tag: listInfo.listTag, children: [\n\t\t\t\t\t{type: \"element\", tag: listInfo.itemTag, children: []}\n\t\t\t\t]};\n\t\t\t\t// Link this list element into the last child item of the parent list item\n\t\t\t\tif(t) {\n\t\t\t\t\tvar prevListItem = listStack[t-1].children[listStack[t-1].children.length-1];\n\t\t\t\t\tprevListItem.children.push(listElement);\n\t\t\t\t}\n\t\t\t\t// Save this element in the stack\n\t\t\t\tlistStack[t] = listElement;\n\t\t\t} else if(t === (match[0].length - 1)) {\n\t\t\t\tlistStack[t].children.push({type: \"element\", tag: listInfo.itemTag, children: []});\n\t\t\t}\n\t\t}\n\t\tif(listStack.length > match[0].length) {\n\t\t\tlistStack.splice(match[0].length,listStack.length - match[0].length);\n\t\t}\n\t\t// Process the body of the list item into the last list item\n\t\tvar lastListChildren = listStack[listStack.length-1].children,\n\t\t\tlastListItem = lastListChildren[lastListChildren.length-1],\n\t\t\tclasses = this.parser.parseClasses();\n\t\tthis.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});\n\t\tvar tree = this.parser.parseInlineRun(/(\\r?\\n)/mg);\n\t\tlastListItem.children.push.apply(lastListItem.children,tree);\n\t\tif(classes.length > 0) {\n\t\t\t$tw.utils.addClassToParseTreeNode(lastListItem,classes.join(\" \"));\n\t\t}\n\t\t// Consume any whitespace following the list item\n\t\tthis.parser.skipWhitespace();\n\t}\n\t// Return the root element of the list\n\treturn [listStack[0]];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/list.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/macrocallblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/macrocallblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki rule for block macro calls\n\n```\n<<name value value2>>\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"macrocallblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /<<([^>\\s]+)(?:\\s*)((?:[^>]|(?:>(?!>)))*?)>>(?:\\r?\\n|$)/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Get all the details of the match\n\tvar macroName = this.match[1],\n\t\tparamString = this.match[2];\n\t// Move past the macro call\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\tvar params = [],\n\t\treParam = /\\s*(?:([A-Za-z0-9\\-_]+)\\s*:)?(?:\\s*(?:\"([^\"]*)\"|'([^']*)'|\\[\\[([^\\]]*)\\]\\]|([^\"'\\s]+)))/mg,\n\t\tparamMatch = reParam.exec(paramString);\n\twhile(paramMatch) {\n\t\t// Process this parameter\n\t\tvar paramInfo = {\n\t\t\tvalue: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]\n\t\t};\n\t\tif(paramMatch[1]) {\n\t\t\tparamInfo.name = paramMatch[1];\n\t\t}\n\t\tparams.push(paramInfo);\n\t\t// Find the next match\n\t\tparamMatch = reParam.exec(paramString);\n\t}\n\treturn [{\n\t\ttype: \"macrocall\",\n\t\tname: macroName,\n\t\tparams: params,\n\t\tisBlock: true\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/macrocallblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/macrocallinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/macrocallinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki rule for macro calls\n\n```\n<<name value value2>>\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"macrocallinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /<<([^\\s>]+)\\s*([\\s\\S]*?)>>/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Get all the details of the match\n\tvar macroName = this.match[1],\n\t\tparamString = this.match[2];\n\t// Move past the macro call\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\tvar params = [],\n\t\treParam = /\\s*(?:([A-Za-z0-9\\-_]+)\\s*:)?(?:\\s*(?:\"([^\"]*)\"|'([^']*)'|\\[\\[([^\\]]*)\\]\\]|([^\"'\\s]+)))/mg,\n\t\tparamMatch = reParam.exec(paramString);\n\twhile(paramMatch) {\n\t\t// Process this parameter\n\t\tvar paramInfo = {\n\t\t\tvalue: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]\n\t\t};\n\t\tif(paramMatch[1]) {\n\t\t\tparamInfo.name = paramMatch[1];\n\t\t}\n\t\tparams.push(paramInfo);\n\t\t// Find the next match\n\t\tparamMatch = reParam.exec(paramString);\n\t}\n\treturn [{\n\t\ttype: \"macrocall\",\n\t\tname: macroName,\n\t\tparams: params\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/macrocallinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/macrodef.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/macrodef.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki pragma rule for macro definitions\n\n```\n\\define name(param:defaultvalue,param2:defaultvalue)\ndefinition text, including $param$ markers\n\\end\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"macrodef\";\nexports.types = {pragma: true};\n\n/*\nInstantiate parse rule\n*/\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /^\\\\define\\s+([^(\\s]+)\\(\\s*([^)]*)\\)(\\r?\\n)?/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Move past the macro name and parameters\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Parse the parameters\n\tvar paramString = this.match[2],\n\t\tparams = [];\n\tif(paramString !== \"\") {\n\t\tvar reParam = /\\s*([A-Za-z0-9\\-_]+)(?:\\s*:\\s*(?:\"([^\"]*)\"|'([^']*)'|\\[\\[([^\\]]*)\\]\\]|([^\"'\\s]+)))?/mg,\n\t\t\tparamMatch = reParam.exec(paramString);\n\t\twhile(paramMatch) {\n\t\t\t// Save the parameter details\n\t\t\tvar paramInfo = {name: paramMatch[1]},\n\t\t\t\tdefaultValue = paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5];\n\t\t\tif(defaultValue) {\n\t\t\t\tparamInfo[\"default\"] = defaultValue;\n\t\t\t}\n\t\t\tparams.push(paramInfo);\n\t\t\t// Look for the next parameter\n\t\t\tparamMatch = reParam.exec(paramString);\n\t\t}\n\t}\n\t// Is this a multiline definition?\n\tvar reEnd;\n\tif(this.match[3]) {\n\t\t// If so, the end of the body is marked with \\end\n\t\treEnd = /(\\r?\\n\\\\end\\r?\\n)/mg;\n\t} else {\n\t\t// Otherwise, the end of the definition is marked by the end of the line\n\t\treEnd = /(\\r?\\n)/mg;\n\t}\n\t// Find the end of the definition\n\treEnd.lastIndex = this.parser.pos;\n\tvar text,\n\t\tendMatch = reEnd.exec(this.parser.source);\n\tif(endMatch) {\n\t\ttext = this.parser.source.substring(this.parser.pos,endMatch.index);\n\t\tthis.parser.pos = endMatch.index + endMatch[0].length;\n\t} else {\n\t\t// We didn't find the end of the definition, so we'll make it blank\n\t\ttext = \"\";\n\t}\n\t// Save the macro definition\n\treturn [{\n\t\ttype: \"macrodef\",\n\t\tname: this.match[1],\n\t\tparams: params,\n\t\ttext: text\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/macrodef.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/prettyextlink.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/prettyextlink.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for external links. For example:\n\n```\n[ext[http://tiddlywiki.com/fractalveg.jpg]]\n[ext[Tooltip|http://tiddlywiki.com/fractalveg.jpg]]\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"prettyextlink\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n};\n\nexports.findNextMatch = function(startPos) {\n\t// Find the next tag\n\tthis.nextLink = this.findNextLink(this.parser.source,startPos);\n\treturn this.nextLink ? this.nextLink.start : undefined;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.nextLink.end;\n\treturn [this.nextLink];\n};\n\n/*\nFind the next link from the current position\n*/\nexports.findNextLink = function(source,pos) {\n\t// A regexp for finding candidate links\n\tvar reLookahead = /(\\[ext\\[)/g;\n\t// Find the next candidate\n\treLookahead.lastIndex = pos;\n\tvar match = reLookahead.exec(source);\n\twhile(match) {\n\t\t// Try to parse the candidate as a link\n\t\tvar link = this.parseLink(source,match.index);\n\t\t// Return success\n\t\tif(link) {\n\t\t\treturn link;\n\t\t}\n\t\t// Look for the next match\n\t\treLookahead.lastIndex = match.index + 1;\n\t\tmatch = reLookahead.exec(source);\n\t}\n\t// Failed\n\treturn null;\n};\n\n/*\nLook for an link at the specified position. Returns null if not found, otherwise returns {type: \"element\", tag: \"a\", attributes: [], isSelfClosing:, start:, end:,}\n*/\nexports.parseLink = function(source,pos) {\n\tvar token,\n\t\ttextNode = {\n\t\t\ttype: \"text\"\n\t\t},\n\t\tnode = {\n\t\t\ttype: \"element\",\n\t\t\ttag: \"a\",\n\t\t\tstart: pos,\n\t\t\tattributes: {},\n\t\t\tchildren: [textNode]\n\t\t};\n\t// Skip whitespace\n\tpos = $tw.utils.skipWhiteSpace(source,pos);\n\t// Look for the `[ext[`\n\ttoken = $tw.utils.parseTokenString(source,pos,\"[ext[\");\n\tif(!token) {\n\t\treturn null;\n\t}\n\tpos = token.end;\n\t// Look ahead for the terminating `]]`\n\tvar closePos = source.indexOf(\"]]\",pos);\n\tif(closePos === -1) {\n\t\treturn null;\n\t}\n\t// Look for a `|` separating the tooltip\n\tvar splitPos = source.indexOf(\"|\",pos);\n\tif(splitPos === -1 || splitPos > closePos) {\n\t\tsplitPos = null;\n\t}\n\t// Pull out the tooltip and URL\n\tvar tooltip, URL;\n\tif(splitPos) {\n\t\tURL = source.substring(splitPos + 1,closePos).trim();\n\t\ttextNode.text = source.substring(pos,splitPos).trim();\n\t} else {\n\t\tURL = source.substring(pos,closePos).trim();\n\t\ttextNode.text = URL;\n\t}\n\tnode.attributes.href = {type: \"string\", value: URL};\n\tnode.attributes.target = {type: \"string\", value: \"_blank\"};\n\t// Update the end position\n\tnode.end = closePos + 2;\n\treturn node;\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/prettyextlink.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/prettylink.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/prettylink.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for pretty links. For example:\n\n```\n[[Introduction]]\n\n[[Link description|TiddlerTitle]]\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"prettylink\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\[\\[(.*?)(?:\\|(.*?))?\\]\\]/mg;\n};\n\nvar isLinkExternal = function(to) {\n\tvar externalRegExp = /(?:file|http|https|mailto|ftp|irc|news|data|skype):[^\\s<>{}\\[\\]`|'\"\\\\^~]+(?:\\/|\\b)/i;\n\treturn externalRegExp.test(to);\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Process the link\n\tvar text = this.match[1],\n\t\tlink = this.match[2] || text;\n\tif(isLinkExternal(link)) {\n\t\treturn [{\n\t\t\ttype: \"element\",\n\t\t\ttag: \"a\",\n\t\t\tattributes: {\n\t\t\t\thref: {type: \"string\", value: link},\n\t\t\t\t\"class\": {type: \"string\", value: \"tw-tiddlylink-external\"},\n\t\t\t\ttarget: {type: \"string\", value: \"_blank\"}\n\t\t\t},\n\t\t\tchildren: [{\n\t\t\t\ttype: \"text\", text: text\n\t\t\t}]\n\t\t}];\n\t} else {\n\t\treturn [{\n\t\t\ttype: \"link\",\n\t\t\tattributes: {\n\t\t\t\tto: {type: \"string\", value: link}\n\t\t\t},\n\t\t\tchildren: [{\n\t\t\t\ttype: \"text\", text: text\n\t\t\t}]\n\t\t}];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/prettylink.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/quoteblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/quoteblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for quote blocks. For example:\n\n```\n\t<<<.optionalClass(es) optional cited from\n\ta quote\n\t<<<\n\t\n\t<<<.optionalClass(es)\n\ta quote\n\t<<< optional cited from\n```\n\nQuotes can be quoted by putting more <s\n\n```\n\t<<<\n\tQuote Level 1\n\t\n\t<<<<\n\tQuoteLevel 2\n\t<<<<\n\t\n\t<<<\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"quoteblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /(<<<+)/mg;\n};\n\nexports.parse = function() {\n\tvar classes = [\"tw-quote\"];\n\t// Get all the details of the match\n\tvar reEndString = \"^\" + this.match[1] + \"(?!<)\";\n\t// Move past the <s\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t\n\t// Parse any classes, whitespace and then the optional cite itself\n\tclasses.push.apply(classes, this.parser.parseClasses());\n\tthis.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});\n\tvar cite = this.parser.parseInlineRun(/(\\r?\\n)/mg);\n\n\t// before handling the cite, parse the body of the quote\n\tvar tree= this.parser.parseBlocks(reEndString);\n\t// If we got a cite, put it before the text\n\tif(cite.length > 0) {\n\t\ttree.unshift({\n\t\t\ttype: \"element\",\n\t\t\ttag: \"cite\",\n\t\t\tchildren: cite\n\t\t});\n\t}\n\n\t// Parse any optional cite\n\tthis.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});\n\tvar cite = this.parser.parseInlineRun(/(\\r?\\n)/mg);\n\t// If we got a cite, push it\n\tif(cite.length > 0) {\n\t\ttree.push({\n\t\t\ttype: \"element\",\n\t\t\ttag: \"cite\",\n\t\t\tchildren: cite\n\t\t});\n\t}\n\n\t// Return the blockquote element\n\treturn [{\n\t\ttype: \"element\",\n\t\ttag: \"blockquote\",\n\t\tattributes: {\n\t\t\tclass: { type: \"string\", value: classes.join(\" \") },\n\t\t},\n\t\tchildren: tree\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/quoteblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/rules.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/rules.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki pragma rule for rules specifications\n\n```\n\\rules except ruleone ruletwo rulethree\n\\rules only ruleone ruletwo rulethree\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"rules\";\nexports.types = {pragma: true};\n\n/*\nInstantiate parse rule\n*/\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /^\\\\rules[^\\S\\n]/mg;\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Move past the pragma invocation\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Parse whitespace delimited tokens terminated by a line break\n\tvar reMatch = /[^\\S\\n]*(\\S+)|(\\r?\\n)/mg,\n\t\ttokens = [];\n\treMatch.lastIndex = this.parser.pos;\n\tvar match = reMatch.exec(this.parser.source);\n\twhile(match && match.index === this.parser.pos) {\n\t\tthis.parser.pos = reMatch.lastIndex;\n\t\t// Exit if we've got the line break\n\t\tif(match[2]) {\n\t\t\tbreak;\n\t\t}\n\t\t// Process the token\n\t\tif(match[1]) {\n\t\t\ttokens.push(match[1]);\n\t\t}\n\t\t// Match the next token\n\t\tmatch = reMatch.exec(this.parser.source);\n\t}\n\t// Process the tokens\n\tif(tokens.length > 0) {\n\t\tthis.parser.amendRules(tokens[0],tokens.slice(1));\n\t}\n\t// No parse tree nodes to return\n\treturn [];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/rules.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/styleblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/styleblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for assigning styles and classes to paragraphs and other blocks. For example:\n\n```\n@@.myClass\n@@background-color:red;\nThis paragraph will have the CSS class `myClass`.\n\n* The `<ul>` around this list will also have the class `myClass`\n* List item 2\n\n@@\n```\n\nNote that classes and styles can be mixed subject to the rule that styles must precede classes. For example\n\n```\n@@.myFirstClass.mySecondClass\n@@width:100px;.myThirdClass\nThis is a paragraph\n@@\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"styleblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /@@((?:[^\\.\\r\\n\\s:]+:[^\\r\\n;]+;)+)?(?:\\.([^\\r\\n\\s]+))?\\r?\\n/mg;\n};\n\nexports.parse = function() {\n\tvar reEndString = \"^@@(?:\\\\r?\\\\n)?\";\n\tvar classes = [], styles = [];\n\tdo {\n\t\t// Get the class and style\n\t\tif(this.match[1]) {\n\t\t\tstyles.push(this.match[1]);\n\t\t}\n\t\tif(this.match[2]) {\n\t\t\tclasses.push(this.match[2].split(\".\").join(\" \"));\n\t\t}\n\t\t// Move past the match\n\t\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t\t// Look for another line of classes and styles\n\t\tthis.match = this.matchRegExp.exec(this.parser.source);\n\t} while(this.match && this.match.index === this.parser.pos);\n\t// Parse the body\n\tvar tree = this.parser.parseBlocks(reEndString);\n\tfor(var t=0; t<tree.length; t++) {\n\t\tif(classes.length > 0) {\n\t\t\t$tw.utils.addClassToParseTreeNode(tree[t],classes.join(\" \"));\n\t\t}\n\t\tif(styles.length > 0) {\n\t\t\t$tw.utils.addAttributeToParseTreeNode(tree[t],\"style\",styles.join(\"\"));\n\t\t}\n\t}\n\treturn tree;\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/styleblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/styleinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/styleinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for assigning styles and classes to inline runs. For example:\n\n```\n@@.myClass This is some text with a class@@\n@@background-color:red;This is some text with a background colour@@\n@@width:100px;.myClass This is some text with a class and a width@@\n```\n\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"styleinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /@@((?:[^\\.\\r\\n\\s:]+:[^\\r\\n;]+;)+)?(\\.(?:[^\\r\\n\\s]+)\\s+)?/mg;\n};\n\nexports.parse = function() {\n\tvar reEnd = /@@/g;\n\t// Get the styles and class\n\tvar stylesString = this.match[1],\n\t\tclassString = this.match[2] ? this.match[2].split(\".\").join(\" \") : undefined;\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Parse the run up to the terminator\n\tvar tree = this.parser.parseInlineRun(reEnd,{eatTerminator: true});\n\t// Return the classed span\n\tvar node = {\n\t\ttype: \"element\",\n\t\ttag: \"span\",\n\t\tattributes: {\n\t\t\t\"class\": {type: \"string\", value: \"tw-inline-style\"}\n\t\t},\n\t\tchildren: tree\n\t};\n\tif(classString) {\n\t\t$tw.utils.addClassToParseTreeNode(node,classString);\n\t}\n\tif(stylesString) {\n\t\t$tw.utils.addAttributeToParseTreeNode(node,\"style\",stylesString);\n\t}\n\treturn [node];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/styleinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/table.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/table.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text block rule for tables.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"table\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /^\\|(?:[^\\n]*)\\|(?:[fhck]?)\\r?(?:\\n|$)/mg;\n};\n\nvar processRow = function(prevColumns) {\n\tvar cellRegExp = /(?:\\|([^\\n\\|]*)\\|)|(\\|[fhck]?\\r?(?:\\n|$))/mg,\n\t\tcellTermRegExp = /((?:\\x20*)\\|)/mg,\n\t\ttree = [],\n\t\tcol = 0,\n\t\tcolSpanCount = 1,\n\t\tprevCell;\n\t// Match a single cell\n\tcellRegExp.lastIndex = this.parser.pos;\n\tvar cellMatch = cellRegExp.exec(this.parser.source);\n\twhile(cellMatch && cellMatch.index === this.parser.pos) {\n\t\tif(cellMatch[1] === \"~\") {\n\t\t\t// Rowspan\n\t\t\tvar last = prevColumns[col];\n\t\t\tif(last) {\n\t\t\t\tlast.rowSpanCount++;\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(last.element,\"rowspan\",last.rowSpanCount);\n\t\t\t\tvar vAlign = $tw.utils.getAttributeValueFromParseTreeNode(last.element,\"valign\",\"center\");\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(last.element,\"valign\",vAlign);\n\t\t\t\tif(colSpanCount > 1) {\n\t\t\t\t\t$tw.utils.addAttributeToParseTreeNode(last.element,\"colspan\",colSpanCount);\n\t\t\t\t\tcolSpanCount = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Move to just before the `|` terminating the cell\n\t\t\tthis.parser.pos = cellRegExp.lastIndex - 1;\n\t\t} else if(cellMatch[1] === \">\") {\n\t\t\t// Colspan\n\t\t\tcolSpanCount++;\n\t\t\t// Move to just before the `|` terminating the cell\n\t\t\tthis.parser.pos = cellRegExp.lastIndex - 1;\n\t\t} else if(cellMatch[1] === \"<\" && prevCell) {\n\t\t\tcolSpanCount = 1 + $tw.utils.getAttributeValueFromParseTreeNode(prevCell,\"colspan\",1);\n\t\t\t$tw.utils.addAttributeToParseTreeNode(prevCell,\"colspan\",colSpanCount);\n\t\t\tcolSpanCount = 1;\n\t\t\t// Move to just before the `|` terminating the cell\n\t\t\tthis.parser.pos = cellRegExp.lastIndex - 1;\n\t\t} else if(cellMatch[2]) {\n\t\t\t// End of row\n\t\t\tif(prevCell && colSpanCount > 1) {\n\t\t\t\tif(prevCell.attributes && prevCell.attributes && prevCell.attributes.colspan) {\n\t\t\t\t\t\tcolSpanCount += prevCell.attributes.colspan.value;\n\t\t\t\t} else {\n\t\t\t\t\tcolSpanCount -= 1;\n\t\t\t\t}\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(prevCell,\"colspan\",colSpanCount);\n\t\t\t}\n\t\t\tthis.parser.pos = cellRegExp.lastIndex - 1;\n\t\t\tbreak;\n\t\t} else {\n\t\t\t// For ordinary cells, step beyond the opening `|`\n\t\t\tthis.parser.pos++;\n\t\t\t// Look for a space at the start of the cell\n\t\t\tvar spaceLeft = false,\n\t\t\t\tvAlign = null;\n\t\t\tif(this.parser.source.substr(this.parser.pos).search(/^\\^([^\\^]|\\^\\^)/) === 0) {\n\t\t\t\tvAlign = \"top\";\n\t\t\t} else if(this.parser.source.substr(this.parser.pos).search(/^,([^,]|,,)/) === 0) {\n\t\t\t\tvAlign = \"bottom\";\n\t\t\t}\n\t\t\tif(vAlign) {\n\t\t\t\tthis.parser.pos++;\n\t\t\t}\n\t\t\tvar chr = this.parser.source.substr(this.parser.pos,1);\n\t\t\twhile(chr === \" \") {\n\t\t\t\tspaceLeft = true;\n\t\t\t\tthis.parser.pos++;\n\t\t\t\tchr = this.parser.source.substr(this.parser.pos,1);\n\t\t\t}\n\t\t\t// Check whether this is a heading cell\n\t\t\tvar cell;\n\t\t\tif(chr === \"!\") {\n\t\t\t\tthis.parser.pos++;\n\t\t\t\tcell = {type: \"element\", tag: \"th\", children: []};\n\t\t\t} else {\n\t\t\t\tcell = {type: \"element\", tag: \"td\", children: []};\n\t\t\t}\n\t\t\ttree.push(cell);\n\t\t\t// Record information about this cell\n\t\t\tprevCell = cell;\n\t\t\tprevColumns[col] = {rowSpanCount:1,element:cell};\n\t\t\t// Check for a colspan\n\t\t\tif(colSpanCount > 1) {\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(cell,\"colspan\",colSpanCount);\n\t\t\t\tcolSpanCount = 1;\n\t\t\t}\n\t\t\t// Parse the cell\n\t\t\tcell.children = this.parser.parseInlineRun(cellTermRegExp,{eatTerminator: true});\n\t\t\t// Set the alignment for the cell\n\t\t\tif(vAlign) {\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(cell,\"valign\",vAlign);\n\t\t\t}\n\t\t\tif(this.parser.source.substr(this.parser.pos - 2,1) === \" \") { // spaceRight\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(cell,\"align\",spaceLeft ? \"center\" : \"left\");\n\t\t\t} else if(spaceLeft) {\n\t\t\t\t$tw.utils.addAttributeToParseTreeNode(cell,\"align\",\"right\");\n\t\t\t}\n\t\t\t// Move back to the closing `|`\n\t\t\tthis.parser.pos--;\n\t\t}\n\t\tcol++;\n\t\tcellRegExp.lastIndex = this.parser.pos;\n\t\tcellMatch = cellRegExp.exec(this.parser.source);\n\t}\n\treturn tree;\n};\n\nexports.parse = function() {\n\tvar rowContainerTypes = {\"c\":\"caption\", \"h\":\"thead\", \"\":\"tbody\", \"f\":\"tfoot\"},\n\t\ttable = {type: \"element\", tag: \"table\", children: []},\n\t\trowRegExp = /^\\|([^\\n]*)\\|([fhck]?)\\r?(?:\\n|$)/mg,\n\t\trowTermRegExp = /(\\|(?:[fhck]?)\\r?(?:\\n|$))/mg,\n\t\tprevColumns = [],\n\t\tcurrRowType,\n\t\trowContainer,\n\t\trowCount = 0;\n\t// Match the row\n\trowRegExp.lastIndex = this.parser.pos;\n\tvar rowMatch = rowRegExp.exec(this.parser.source);\n\twhile(rowMatch && rowMatch.index === this.parser.pos) {\n\t\tvar rowType = rowMatch[2];\n\t\t// Check if it is a class assignment\n\t\tif(rowType === \"k\") {\n\t\t\t$tw.utils.addClassToParseTreeNode(table,rowMatch[1]);\n\t\t\tthis.parser.pos = rowMatch.index + rowMatch[0].length;\n\t\t} else {\n\t\t\t// Otherwise, create a new row if this one is of a different type\n\t\t\tif(rowType !== currRowType) {\n\t\t\t\trowContainer = {type: \"element\", tag: rowContainerTypes[rowType], children: []};\n\t\t\t\ttable.children.push(rowContainer);\n\t\t\t\tcurrRowType = rowType;\n\t\t\t}\n\t\t\t// Is this a caption row?\n\t\t\tif(currRowType === \"c\") {\n\t\t\t\t// If so, move past the opening `|` of the row\n\t\t\t\tthis.parser.pos++;\n\t\t\t\t// Move the caption to the first row if it isn't already\n\t\t\t\tif(table.children.length !== 1) {\n\t\t\t\t\ttable.children.pop(); // Take rowContainer out of the children array\n\t\t\t\t\ttable.children.splice(0,0,rowContainer); // Insert it at the bottom\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t// Set the alignment - TODO: figure out why TW did this\n//\t\t\t\trowContainer.attributes.align = rowCount === 0 ? \"top\" : \"bottom\";\n\t\t\t\t// Parse the caption\n\t\t\t\trowContainer.children = this.parser.parseInlineRun(rowTermRegExp,{eatTerminator: true});\n\t\t\t} else {\n\t\t\t\t// Create the row\n\t\t\t\tvar theRow = {type: \"element\", tag: \"tr\", children: []};\n\t\t\t\t$tw.utils.addClassToParseTreeNode(theRow,rowCount%2 ? \"oddRow\" : \"evenRow\");\n\t\t\t\trowContainer.children.push(theRow);\n\t\t\t\t// Process the row\n\t\t\t\ttheRow.children = processRow.call(this,prevColumns);\n\t\t\t\tthis.parser.pos = rowMatch.index + rowMatch[0].length;\n\t\t\t\t// Increment the row count\n\t\t\t\trowCount++;\n\t\t\t}\n\t\t}\n\t\trowMatch = rowRegExp.exec(this.parser.source);\n\t}\n\treturn [table];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/table.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/transcludeblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/transcludeblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for block-level transclusion. For example:\n\n```\n{{MyTiddler}}\n{{MyTiddler||TemplateTitle}}\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"transcludeblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\{\\{([^\\{\\}\\|]*)(?:\\|\\|([^\\|\\{\\}]+))?\\}\\}(?:\\r?\\n|$)/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Get the match details\n\tvar template = $tw.utils.trim(this.match[2]),\n\t\ttextRef = $tw.utils.trim(this.match[1]);\n\t// Prepare the transclude widget\n\tvar transcludeNode = {\n\t\t\ttype: \"transclude\",\n\t\t\tattributes: {},\n\t\t\tisBlock: true\n\t\t};\n\t// Prepare the tiddler widget\n\tif(textRef) {\n\t\tvar tr = $tw.utils.parseTextReference(textRef),\n\t\t\ttargetTitle = tr.title,\n\t\t\ttargetField = tr.field,\n\t\t\ttargetIndex = tr.index,\n\t\t\ttiddlerNode = {\n\t\t\t\ttype: \"tiddler\",\n\t\t\t\tattributes: {\n\t\t\t\t\ttiddler: {type: \"string\", value: targetTitle}\n\t\t\t\t},\n\t\t\t\tisBlock: true,\n\t\t\t\tchildren: [transcludeNode]\n\t\t\t};\n\t}\n\tif(template) {\n\t\ttranscludeNode.attributes.tiddler = {type: \"string\", value: template};\n\t\tif(textRef) {\n\t\t\treturn [tiddlerNode];\n\t\t} else {\n\t\t\treturn [transcludeNode];\n\t\t}\n\t} else {\n\t\tif(textRef) {\n\t\t\ttranscludeNode.attributes.tiddler = {type: \"string\", value: targetTitle};\n\t\t\tif(targetField) {\n\t\t\t\ttranscludeNode.attributes.field = {type: \"string\", value: targetField};\n\t\t\t}\n\t\t\tif(targetIndex) {\n\t\t\t\ttranscludeNode.attributes.index = {type: \"string\", value: targetIndex};\n\t\t\t}\n\t\t\treturn [tiddlerNode];\n\t\t} else {\n\t\t\treturn [transcludeNode];\n\t\t}\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/transcludeblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/transcludeinline.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/transcludeinline.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for inline-level transclusion. For example:\n\n```\n{{MyTiddler}}\n{{MyTiddler||TemplateTitle}}\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"transcludeinline\";\nexports.types = {inline: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\{\\{([^\\{\\}\\|]*)(?:\\|\\|([^\\|\\{\\}]+))?\\}\\}/mg;\n};\n\nexports.parse = function() {\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Get the match details\n\tvar template = $tw.utils.trim(this.match[2]),\n\t\ttextRef = $tw.utils.trim(this.match[1]);\n\t// Prepare the transclude widget\n\tvar transcludeNode = {\n\t\t\ttype: \"transclude\",\n\t\t\tattributes: {}\n\t\t};\n\t// Prepare the tiddler widget\n\tif(textRef) {\n\t\tvar tr = $tw.utils.parseTextReference(textRef),\n\t\t\ttargetTitle = tr.title,\n\t\t\ttargetField = tr.field,\n\t\t\ttargetIndex = tr.index,\n\t\t\ttiddlerNode = {\n\t\t\t\ttype: \"tiddler\",\n\t\t\t\tattributes: {\n\t\t\t\t\ttiddler: {type: \"string\", value: targetTitle}\n\t\t\t\t},\n\t\t\t\tchildren: [transcludeNode]\n\t\t\t};\n\t}\n\tif(template) {\n\t\ttranscludeNode.attributes.tiddler = {type: \"string\", value: template};\n\t\tif(textRef) {\n\t\t\treturn [tiddlerNode];\n\t\t} else {\n\t\t\treturn [transcludeNode];\n\t\t}\n\t} else {\n\t\tif(textRef) {\n\t\t\ttranscludeNode.attributes.tiddler = {type: \"string\", value: targetTitle};\n\t\t\tif(targetField) {\n\t\t\t\ttranscludeNode.attributes.field = {type: \"string\", value: targetField};\n\t\t\t}\n\t\t\tif(targetIndex) {\n\t\t\t\ttranscludeNode.attributes.index = {type: \"string\", value: targetIndex};\n\t\t\t}\n\t\t\treturn [tiddlerNode];\n\t\t} else {\n\t\t\treturn [transcludeNode];\n\t\t}\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/transcludeinline.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/typedblock.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/typedblock.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text rule for typed blocks. For example:\n\n```\n$$$.js\nThis will be rendered as JavaScript\n$$$\n\n$$$.svg\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"150\" height=\"100\">\n <circle cx=\"100\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"2\" fill=\"red\" />\n</svg>\n$$$\n\n$$$text/vnd.tiddlywiki>text/html\nThis will be rendered as an //HTML representation// of WikiText\n$$$\n```\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nexports.name = \"typedblock\";\nexports.types = {block: true};\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = /\\$\\$\\$([^ >\\r\\n]*)(?: *> *([^ \\r\\n]+))?\\r?\\n/mg;\n};\n\nexports.parse = function() {\n\tvar reEnd = /\\r?\\n\\$\\$\\$\\r?(?:\\n|$)/mg;\n\t// Save the type\n\tvar parseType = this.match[1],\n\t\trenderType = this.match[2];\n\t// Move past the match\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// Look for the end of the block\n\treEnd.lastIndex = this.parser.pos;\n\tvar match = reEnd.exec(this.parser.source),\n\t\ttext;\n\t// Process the block\n\tif(match) {\n\t\ttext = this.parser.source.substring(this.parser.pos,match.index);\n\t\tthis.parser.pos = match.index + match[0].length;\n\t} else {\n\t\ttext = this.parser.source.substr(this.parser.pos);\n\t\tthis.parser.pos = this.parser.sourceLength;\n\t}\n\t// Parse the block according to the specified type\n\tvar parser = this.parser.wiki.parseText(parseType,text,{defaultType: \"text/plain\"});\n\t// If there's no render type, just return the parse tree\n\tif(!renderType) {\n\t\treturn parser.tree;\n\t} else {\n\t\t// Otherwise, render to the rendertype and return in a <PRE> tag\n\t\tvar widgetNode = this.parser.wiki.makeWidget(parser),\n\t\t\tcontainer = $tw.fakeDocument.createElement(\"div\");\n\t\twidgetNode.render(container,null);\n\t\tvar text = renderType === \"text/html\" ? container.innerHTML : container.textContent;\n\t\treturn [{\n\t\t\ttype: \"element\",\n\t\t\ttag: \"pre\",\n\t\t\tchildren: [{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: text\n\t\t\t}]\n\t\t}];\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/typedblock.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/rules/wikilink.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/wikilink.js\ntype: application/javascript\nmodule-type: wikirule\n\nWiki text inline rule for wiki links. For example:\n\n```\nAWikiLink\nAnotherLink\n~SuppressedLink\n```\n\nPrecede a camel case word with `~` to prevent it from being recognised as a link.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = \"wikilink\";\nexports.types = {inline: true};\n\nvar textPrimitives = {\n\tupperLetter: \"[A-Z\\u00c0-\\u00de\\u0150\\u0170]\",\n\tlowerLetter: \"[a-z0-9_\\\\-\\u00df-\\u00ff\\u0151\\u0171]\",\n\tanyLetter: \"[A-Za-z0-9_\\\\-\\u00c0-\\u00de\\u00df-\\u00ff\\u0150\\u0170\\u0151\\u0171]\",\n\tanyLetterStrict: \"[A-Za-z0-9\\u00c0-\\u00de\\u00df-\\u00ff\\u0150\\u0170\\u0151\\u0171]\"\n};\n\ntextPrimitives.unWikiLink = \"~\";\ntextPrimitives.wikiLink = textPrimitives.upperLetter + \"+\" +\n\ttextPrimitives.lowerLetter + \"+\" +\n\ttextPrimitives.upperLetter +\n\ttextPrimitives.anyLetter + \"*\";\n\nexports.init = function(parser) {\n\tthis.parser = parser;\n\t// Regexp to match\n\tthis.matchRegExp = new RegExp(textPrimitives.unWikiLink + \"?\" + textPrimitives.wikiLink,\"mg\");\n};\n\n/*\nParse the most recent match\n*/\nexports.parse = function() {\n\t// Get the details of the match\n\tvar linkText = this.match[0];\n\t// Move past the macro call\n\tthis.parser.pos = this.matchRegExp.lastIndex;\n\t// If the link starts with the unwikilink character then just output it as plain text\n\tif(linkText.substr(0,1) === textPrimitives.unWikiLink) {\n\t\treturn [{type: \"text\", text: linkText.substr(1)}];\n\t}\n\t// If the link has been preceded with a letter then don't treat it as a link\n\tif(this.match.index > 0) {\n\t\tvar preRegExp = new RegExp(textPrimitives.anyLetterStrict,\"mg\");\n\t\tpreRegExp.lastIndex = this.match.index-1;\n\t\tvar preMatch = preRegExp.exec(this.parser.source);\n\t\tif(preMatch && preMatch.index === this.match.index-1) {\n\t\t\treturn [{type: \"text\", text: linkText}];\n\t\t}\n\t}\n\treturn [{\n\t\ttype: \"link\",\n\t\tattributes: {\n\t\t\tto: {type: \"string\", value: linkText}\n\t\t},\n\t\tchildren: [{\n\t\t\ttype: \"text\",\n\t\t\ttext: linkText\n\t\t}]\n\t}];\n};\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/wikilink.js",
"type": "application/javascript",
"module-type": "wikirule"
},
"$:/core/modules/parsers/wikiparser/wikiparser.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/wikiparser.js\ntype: application/javascript\nmodule-type: parser\n\nThe wiki text parser processes blocks of source text into a parse tree.\n\nThe parse tree is made up of nested arrays of these JavaScript objects:\n\n\t{type: \"element\", tag: <string>, attributes: {}, children: []} - an HTML element\n\t{type: \"text\", text: <string>} - a text node\n\t{type: \"entity\", value: <string>} - an entity\n\t{type: \"raw\", html: <string>} - raw HTML\n\nAttributes are stored as hashmaps of the following objects:\n\n\t{type: \"string\", value: <string>} - literal string\n\t{type: \"indirect\", textReference: <textReference>} - indirect through a text reference\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar WikiParser = function(type,text,options) {\n\tthis.wiki = options.wiki;\n\t// Initialise the classes if we don't have them already\n\tif(!this.pragmaRuleClasses) {\n\t\tWikiParser.prototype.pragmaRuleClasses = $tw.modules.createClassesFromModules(\"wikirule\",\"pragma\",$tw.WikiRuleBase);\n\t}\n\tif(!this.blockRuleClasses) {\n\t\tWikiParser.prototype.blockRuleClasses = $tw.modules.createClassesFromModules(\"wikirule\",\"block\",$tw.WikiRuleBase);\n\t}\n\tif(!this.inlineRuleClasses) {\n\t\tWikiParser.prototype.inlineRuleClasses = $tw.modules.createClassesFromModules(\"wikirule\",\"inline\",$tw.WikiRuleBase);\n\t}\n\t// Save the parse text\n\tthis.type = type || \"text/vnd.tiddlywiki\";\n\tthis.source = text || \"\";\n\tthis.sourceLength = this.source.length;\n\t// Set current parse position\n\tthis.pos = 0;\n\t// Instantiate the pragma parse rules\n\tthis.pragmaRules = this.instantiateRules(this.pragmaRuleClasses,\"pragma\",0);\n\t// Instantiate the parser block and inline rules\n\tthis.blockRules = this.instantiateRules(this.blockRuleClasses,\"block\",0);\n\tthis.inlineRules = this.instantiateRules(this.inlineRuleClasses,\"inline\",0);\n\t// Parse any pragmas\n\tthis.tree = this.parsePragmas();\n\t// Parse the text into inline runs or blocks\n\tif(options.parseAsInline) {\n\t\tthis.tree.push.apply(this.tree,this.parseInlineRun());\n\t} else {\n\t\tthis.tree.push.apply(this.tree,this.parseBlocks());\n\t}\n\t// Return the parse tree\n};\n\n/*\nInstantiate an array of parse rules\n*/\nWikiParser.prototype.instantiateRules = function(classes,type,startPos) {\n\tvar rulesInfo = [],\n\t\tself = this;\n\t$tw.utils.each(classes,function(RuleClass) {\n\t\t// Instantiate the rule\n\t\tvar rule = new RuleClass(self);\n\t\trule.is = {};\n\t\trule.is[type] = true;\n\t\trule.init(self);\n\t\tvar matchIndex = rule.findNextMatch(startPos);\n\t\tif(matchIndex !== undefined) {\n\t\t\trulesInfo.push({\n\t\t\t\trule: rule,\n\t\t\t\tmatchIndex: matchIndex\n\t\t\t});\n\t\t}\n\t});\n\treturn rulesInfo;\n};\n\n/*\nSkip any whitespace at the current position. Options are:\n\ttreatNewlinesAsNonWhitespace: true if newlines are NOT to be treated as whitespace\n*/\nWikiParser.prototype.skipWhitespace = function(options) {\n\toptions = options || {};\n\tvar whitespaceRegExp = options.treatNewlinesAsNonWhitespace ? /([^\\S\\n]+)/mg : /(\\s+)/mg;\n\twhitespaceRegExp.lastIndex = this.pos;\n\tvar whitespaceMatch = whitespaceRegExp.exec(this.source);\n\tif(whitespaceMatch && whitespaceMatch.index === this.pos) {\n\t\tthis.pos = whitespaceRegExp.lastIndex;\n\t}\n};\n\n/*\nGet the next match out of an array of parse rule instances\n*/\nWikiParser.prototype.findNextMatch = function(rules,startPos) {\n\t// Find the best matching rule by finding the closest match position\n\tvar matchingRule = undefined,\n\t\tmatchingRulePos = this.sourceLength;\n\t// Step through each rule\n\tfor(var t=0; t<rules.length; t++) {\n\t\tvar ruleInfo = rules[t];\n\t\t// Ask the rule to get the next match if we've moved past the current one\n\t\tif(ruleInfo.matchIndex !== undefined && ruleInfo.matchIndex < startPos) {\n\t\t\truleInfo.matchIndex = ruleInfo.rule.findNextMatch(startPos);\n\t\t}\n\t\t// Adopt this match if it's closer than the current best match\n\t\tif(ruleInfo.matchIndex !== undefined && ruleInfo.matchIndex <= matchingRulePos) {\n\t\t\tmatchingRule = ruleInfo;\n\t\t\tmatchingRulePos = ruleInfo.matchIndex;\n\t\t}\n\t}\n\treturn matchingRule;\n};\n\n/*\nParse any pragmas at the beginning of a block of parse text\n*/\nWikiParser.prototype.parsePragmas = function() {\n\tvar tree = [];\n\twhile(true) {\n\t\t// Skip whitespace\n\t\tthis.skipWhitespace();\n\t\t// Check for the end of the text\n\t\tif(this.pos >= this.sourceLength) {\n\t\t\tbreak;\n\t\t}\n\t\t// Check if we've arrived at a pragma rule match\n\t\tvar nextMatch = this.findNextMatch(this.pragmaRules,this.pos);\n\t\t// If not, just exit\n\t\tif(!nextMatch || nextMatch.matchIndex !== this.pos) {\n\t\t\tbreak;\n\t\t}\n\t\t// Process the pragma rule\n\t\ttree.push.apply(tree,nextMatch.rule.parse());\n\t}\n\treturn tree;\n};\n\n/*\nParse a block from the current position\n\tterminatorRegExpString: optional regular expression string that identifies the end of plain paragraphs. Must not include capturing parenthesis\n*/\nWikiParser.prototype.parseBlock = function(terminatorRegExpString) {\n\tvar terminatorRegExp = terminatorRegExpString ? new RegExp(\"(\" + terminatorRegExpString + \"|\\\\r?\\\\n\\\\r?\\\\n)\",\"mg\") : /(\\r?\\n\\r?\\n)/mg;\n\tthis.skipWhitespace();\n\tif(this.pos >= this.sourceLength) {\n\t\treturn [];\n\t}\n\t// Look for a block rule that applies at the current position\n\tvar nextMatch = this.findNextMatch(this.blockRules,this.pos);\n\tif(nextMatch && nextMatch.matchIndex === this.pos) {\n\t\treturn nextMatch.rule.parse();\n\t}\n\t// Treat it as a paragraph if we didn't find a block rule\n\treturn [{type: \"element\", tag: \"p\", children: this.parseInlineRun(terminatorRegExp)}];\n};\n\n/*\nParse a series of blocks of text until a terminating regexp is encountered or the end of the text\n\tterminatorRegExpString: terminating regular expression\n*/\nWikiParser.prototype.parseBlocks = function(terminatorRegExpString) {\n\tif(terminatorRegExpString) {\n\t\treturn this.parseBlocksTerminated(terminatorRegExpString);\n\t} else {\n\t\treturn this.parseBlocksUnterminated();\n\t}\n};\n\n/*\nParse a block from the current position to the end of the text\n*/\nWikiParser.prototype.parseBlocksUnterminated = function() {\n\tvar tree = [];\n\twhile(this.pos < this.sourceLength) {\n\t\ttree.push.apply(tree,this.parseBlock());\n\t}\n\treturn tree;\n};\n\n/*\nParse blocks of text until a terminating regexp is encountered\n*/\nWikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {\n\tvar terminatorRegExp = new RegExp(\"(\" + terminatorRegExpString + \")\",\"mg\"),\n\t\ttree = [];\n\t// Skip any whitespace\n\tthis.skipWhitespace();\n\t// Check if we've got the end marker\n\tterminatorRegExp.lastIndex = this.pos;\n\tvar match = terminatorRegExp.exec(this.source);\n\t// Parse the text into blocks\n\twhile(this.pos < this.sourceLength && !(match && match.index === this.pos)) {\n\t\tvar blocks = this.parseBlock(terminatorRegExpString);\n\t\ttree.push.apply(tree,blocks);\n\t\t// Skip any whitespace\n\t\tthis.skipWhitespace();\n\t\t// Check if we've got the end marker\n\t\tterminatorRegExp.lastIndex = this.pos;\n\t\tmatch = terminatorRegExp.exec(this.source);\n\t}\n\tif(match && match.index === this.pos) {\n\t\tthis.pos = match.index + match[0].length;\n\t}\n\treturn tree;\n};\n\n/*\nParse a run of text at the current position\n\tterminatorRegExp: a regexp at which to stop the run\n\toptions: see below\nOptions available:\n\teatTerminator: move the parse position past any encountered terminator (default false)\n*/\nWikiParser.prototype.parseInlineRun = function(terminatorRegExp,options) {\n\tif(terminatorRegExp) {\n\t\treturn this.parseInlineRunTerminated(terminatorRegExp,options);\n\t} else {\n\t\treturn this.parseInlineRunUnterminated(options);\n\t}\n};\n\nWikiParser.prototype.parseInlineRunUnterminated = function(options) {\n\tvar tree = [];\n\t// Find the next occurrence of an inline rule\n\tvar nextMatch = this.findNextMatch(this.inlineRules,this.pos);\n\t// Loop around the matches until we've reached the end of the text\n\twhile(this.pos < this.sourceLength && nextMatch) {\n\t\t// Process the text preceding the run rule\n\t\tif(nextMatch.matchIndex > this.pos) {\n\t\t\ttree.push({type: \"text\", text: this.source.substring(this.pos,nextMatch.matchIndex)});\n\t\t\tthis.pos = nextMatch.matchIndex;\n\t\t}\n\t\t// Process the run rule\n\t\ttree.push.apply(tree,nextMatch.rule.parse());\n\t\t// Look for the next run rule\n\t\tnextMatch = this.findNextMatch(this.inlineRules,this.pos);\n\t}\n\t// Process the remaining text\n\tif(this.pos < this.sourceLength) {\n\t\ttree.push({type: \"text\", text: this.source.substr(this.pos)});\n\t}\n\tthis.pos = this.sourceLength;\n\treturn tree;\n};\n\nWikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {\n\toptions = options || {};\n\tvar tree = [];\n\t// Find the next occurrence of the terminator\n\tterminatorRegExp.lastIndex = this.pos;\n\tvar terminatorMatch = terminatorRegExp.exec(this.source);\n\t// Find the next occurrence of a inlinerule\n\tvar inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);\n\t// Loop around until we've reached the end of the text\n\twhile(this.pos < this.sourceLength && (terminatorMatch || inlineRuleMatch)) {\n\t\t// Return if we've found the terminator, and it precedes any inline rule match\n\t\tif(terminatorMatch) {\n\t\t\tif(!inlineRuleMatch || inlineRuleMatch.matchIndex >= terminatorMatch.index) {\n\t\t\t\tif(terminatorMatch.index > this.pos) {\n\t\t\t\t\ttree.push({type: \"text\", text: this.source.substring(this.pos,terminatorMatch.index)});\n\t\t\t\t}\n\t\t\t\tthis.pos = terminatorMatch.index;\n\t\t\t\tif(options.eatTerminator) {\n\t\t\t\t\tthis.pos += terminatorMatch[0].length;\n\t\t\t\t}\n\t\t\t\treturn tree;\n\t\t\t}\n\t\t}\n\t\t// Process any inline rule, along with the text preceding it\n\t\tif(inlineRuleMatch) {\n\t\t\t// Preceding text\n\t\t\tif(inlineRuleMatch.matchIndex > this.pos) {\n\t\t\t\ttree.push({type: \"text\", text: this.source.substring(this.pos,inlineRuleMatch.matchIndex)});\n\t\t\t\tthis.pos = inlineRuleMatch.matchIndex;\n\t\t\t}\n\t\t\t// Process the inline rule\n\t\t\ttree.push.apply(tree,inlineRuleMatch.rule.parse());\n\t\t\t// Look for the next inline rule\n\t\t\tinlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);\n\t\t\t// Look for the next terminator match\n\t\t\tterminatorRegExp.lastIndex = this.pos;\n\t\t\tterminatorMatch = terminatorRegExp.exec(this.source);\n\t\t}\n\t}\n\t// Process the remaining text\n\tif(this.pos < this.sourceLength) {\n\t\ttree.push({type: \"text\", text: this.source.substr(this.pos)});\n\t}\n\tthis.pos = this.sourceLength;\n\treturn tree;\n};\n\n/*\nParse zero or more class specifiers `.classname`\n*/\nWikiParser.prototype.parseClasses = function() {\n\tvar classRegExp = /\\.([^\\s\\.]+)/mg,\n\t\tclassNames = [];\n\tclassRegExp.lastIndex = this.pos;\n\tvar match = classRegExp.exec(this.source);\n\twhile(match && match.index === this.pos) {\n\t\tthis.pos = match.index + match[0].length;\n\t\tclassNames.push(match[1]);\n\t\tvar match = classRegExp.exec(this.source);\n\t}\n\treturn classNames;\n};\n\n/*\nAmend the rules used by this instance of the parser\n\ttype: `only` keeps just the named rules, `except` keeps all but the named rules\n\tnames: array of rule names\n*/\nWikiParser.prototype.amendRules = function(type,names) {\n\tnames = names || [];\n\t// Define the filter function\n\tvar keepFilter;\n\tif(type === \"only\") {\n\t\tkeepFilter = function(name) {\n\t\t\treturn names.indexOf(name) !== -1;\n\t\t};\n\t} else if(type === \"except\") {\n\t\tkeepFilter = function(name) {\n\t\t\treturn names.indexOf(name) === -1;\n\t\t};\n\t} else {\n\t\treturn;\n\t}\n\t// Define a function to process each of our rule arrays\n\tvar processRuleArray = function(ruleArray) {\n\t\tfor(var t=ruleArray.length-1; t>=0; t--) {\n\t\t\tif(!keepFilter(ruleArray[t].rule.name)) {\n\t\t\t\truleArray.splice(t,1);\n\t\t\t}\n\t\t}\n\t};\n\t// Process each rule array\n\tprocessRuleArray(this.pragmaRules);\n\tprocessRuleArray(this.blockRules);\n\tprocessRuleArray(this.inlineRules);\n}\n\nexports[\"text/vnd.tiddlywiki\"] = WikiParser;\n\n})();\n\n",
"title": "$:/core/modules/parsers/wikiparser/wikiparser.js",
"type": "application/javascript",
"module-type": "parser"
},
"$:/core/modules/parsers/wikiparser/rules/wikirulebase.js": {
"text": "/*\\\ntitle: $:/core/modules/parsers/wikiparser/rules/wikirulebase.js\ntype: application/javascript\nmodule-type: global\n\nBase class for wiki parser rules\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nThis constructor is always overridden with a blank constructor, and so shouldn't be used\n*/\nvar WikiRuleBase = function() {\n};\n\n/*\nTo be overridden by individual rules\n*/\nWikiRuleBase.prototype.init = function(parser) {\n\tthis.parser = parser;\n};\n\n/*\nDefault implementation of findNextMatch uses RegExp matching\n*/\nWikiRuleBase.prototype.findNextMatch = function(startPos) {\n\tthis.matchRegExp.lastIndex = startPos;\n\tthis.match = this.matchRegExp.exec(this.parser.source);\n\treturn this.match ? this.match.index : undefined;\n};\n\nexports.WikiRuleBase = WikiRuleBase;\n\n})();\n",
"title": "$:/core/modules/parsers/wikiparser/rules/wikirulebase.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/pluginswitcher.js": {
"text": "/*\\\ntitle: $:/core/modules/pluginswitcher.js\ntype: application/javascript\nmodule-type: global\n\nManages switching plugins for themes and languages.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\noptions:\nwiki: wiki store to be used\npluginType: type of plugin to be switched\ncontrollerTitle: title of tiddler used to control switching of this resource\ndefaultPlugins: array of default plugins to be used if nominated plugin isn't found\n*/\nfunction PluginSwitcher(options) {\n\tthis.wiki = options.wiki;\n\tthis.pluginType = options.pluginType;\n\tthis.controllerTitle = options.controllerTitle;\n\tthis.defaultPlugins = options.defaultPlugins || [];\n\t// Switch to the current plugin\n\tthis.switchPlugins();\n\t// Listen for changes to the selected plugin\n\tvar self = this;\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\tif($tw.utils.hop(changes,self.controllerTitle)) {\n\t\t\tself.switchPlugins();\n\t\t}\n\t});\n}\n\nPluginSwitcher.prototype.switchPlugins = function() {\n\t// Get the name of the current theme\n\tvar selectedPluginTitle = this.wiki.getTiddlerText(this.controllerTitle);\n\t// If it doesn't exist, then fallback to one of the default themes\n\tvar index = 0;\n\twhile(!this.wiki.getTiddler(selectedPluginTitle) && index < this.defaultPlugins.length) {\n\t\tselectedPluginTitle = this.defaultPlugins[index++];\n\t}\n\t// Accumulate the titles of the plugins that we need to load\n\tvar plugins = [],\n\t\tself = this,\n\t\taccumulatePlugin = function(title) {\n\t\t\tvar tiddler = self.wiki.getTiddler(title);\n\t\t\tif(tiddler && tiddler.isPlugin() && plugins.indexOf(title) === -1) {\n\t\t\t\tplugins.push(title);\n\t\t\t\tvar pluginInfo = JSON.parse(self.wiki.getTiddlerText(title)),\n\t\t\t\t\tdependents = $tw.utils.parseStringArray(tiddler.fields.dependents || \"\");\n\t\t\t\t$tw.utils.each(dependents,function(title) {\n\t\t\t\t\taccumulatePlugin(title);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\taccumulatePlugin(selectedPluginTitle);\n\t// Unregister any existing theme tiddlers\n\tvar unregisteredTiddlers = $tw.wiki.unregisterPluginTiddlers(this.pluginType);\n\t// Accumulate the titles of shadow tiddlers that have changed as a result of this switch\n\tvar changedTiddlers = {};\n\tthis.wiki.eachShadow(function(tiddler,title) {\n\t\tvar source = self.wiki.getShadowSource(title);\n\t\tif(unregisteredTiddlers.indexOf(source) !== -1) {\n\t\t\tchangedTiddlers[title] = true; // isDeleted?\n\t\t}\n\t});\n\t// Register any new theme tiddlers\n\tvar registeredTiddlers = $tw.wiki.registerPluginTiddlers(this.pluginType,plugins);\n\t// Unpack the current theme tiddlers\n\t$tw.wiki.unpackPluginTiddlers();\n\t// Accumulate the affected shadow tiddlers\n\tthis.wiki.eachShadow(function(tiddler,title) {\n\t\tvar source = self.wiki.getShadowSource(title);\n\t\tif(registeredTiddlers.indexOf(source) !== -1) {\n\t\t\tchangedTiddlers[title] = false; // isDeleted?\n\t\t}\n\t});\n\t// Issue change events for the modified tiddlers\n\t$tw.utils.each(changedTiddlers,function(status,title) {\n\t\tself.wiki.enqueueTiddlerEvent(title,status);\n\t});\n};\n\nexports.PluginSwitcher = PluginSwitcher;\n\n})();\n",
"title": "$:/core/modules/pluginswitcher.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/savers/andtidwiki.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/andtidwiki.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via the AndTidWiki Android app\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false, netscape: false, Components: false */\n\"use strict\";\n\nvar AndTidWiki = function(wiki) {\n};\n\nAndTidWiki.prototype.save = function(text,method,callback) {\n\t// Get the pathname of this document\n\tvar pathname = decodeURIComponent(document.location.toString().split(\"#\")[0]);\n\t// Strip the file://\n\tif(pathname.indexOf(\"file://\") === 0) {\n\t\tpathname = pathname.substr(7);\n\t}\n\t// Strip any query or location part\n\tvar p = pathname.indexOf(\"?\");\n\tif(p !== -1) {\n\t\tpathname = pathname.substr(0,p);\n\t}\n\tp = pathname.indexOf(\"#\");\n\tif(p !== -1) {\n\t\tpathname = pathname.substr(0,p);\n\t}\n\t// Save the file\n\twindow.twi.saveFile(pathname,text)\n\t// Call the callback\n\tcallback(null);\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nAndTidWiki.prototype.info = {\n\tname: \"andtidwiki\",\n\tpriority: 1600,\n\tcapabilities: [\"save\", \"autosave\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn !!window.twi && !!window.twi.saveFile;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new AndTidWiki(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/andtidwiki.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/download.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/download.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via HTML5's download APIs\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar DownloadSaver = function(wiki) {\n};\n\nDownloadSaver.prototype.save = function(text,method,callback) {\n\t// Get the current filename\n\tvar filename = \"tiddlywiki.html\",\n\t\tp = document.location.pathname.lastIndexOf(\"/\");\n\tif(p !== -1) {\n\t\tfilename = document.location.pathname.substr(p+1);\n\t}\n\t// Set up the link\n\tvar link = document.createElement(\"a\");\n\tlink.setAttribute(\"target\",\"_blank\");\n\tif(Blob !== undefined) {\n\t\tvar blob = new Blob([text], {type: \"text/html\"});\n\t\tlink.setAttribute(\"href\", URL.createObjectURL(blob));\n\t} else {\n\t\tlink.setAttribute(\"href\",\"data:text/html,\" + encodeURIComponent(text));\n\t}\n\tlink.setAttribute(\"download\",filename);\n\tdocument.body.appendChild(link);\n\tlink.click();\n\tdocument.body.removeChild(link);\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nDownloadSaver.prototype.info = {\n\tname: \"download\",\n\tpriority: 100,\n\tcapabilities: [\"save\", \"download\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn document.createElement(\"a\").download !== undefined;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new DownloadSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/download.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/fsosaver.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/fsosaver.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via MS FileSystemObject ActiveXObject\n\nNote: Since TiddlyWiki's markup contains the MOTW, the FileSystemObject normally won't be available. \nHowever, if the wiki is loaded as an .HTA file (Windows HTML Applications) then the FSO can be used.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar FSOSaver = function(wiki) {\n};\n\nFSOSaver.prototype.save = function(text,method,callback) {\n\t// Get the pathname of this document\n\tvar pathname = unescape(document.location.pathname);\n\t// Test for a Windows path of the form /x:\\blah...\n\tif(/^\\/[A-Z]\\:\\\\[^\\\\]+/i.test(pathname)) {\t// ie: ^/[a-z]:/[^/]+\n\t\t// Remove the leading slash\n\t\tpathname = pathname.substr(1);\n\t} else if(document.location.hostname !== \"\" && /^\\/\\\\[^\\\\]+\\\\[^\\\\]+/i.test(pathname)) {\t// test for \\\\server\\share\\blah... - ^/[^/]+/[^/]+\n\t\t// Remove the leading slash\n\t\tpathname = pathname.substr(1);\n\t\t// reconstruct UNC path\n\t\tpathname = \"\\\\\\\\\" + document.location.hostname + pathname;\n\t} else return false;\n\t\n\t// Save the file (as UTF-16)\n\tvar fso = new ActiveXObject(\"Scripting.FileSystemObject\");\n\tvar file = fso.OpenTextFile(pathname,2,-1,-1);\n\t\n\tfile.Write(text);\n\tfile.Close();\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nFSOSaver.prototype.info = {\n\tname: \"FSOSaver\",\n\tpriority: 120,\n\tcapabilities: [\"save\", \"autosave\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\ttry {\n\t\treturn (window.location.protocol === \"file:\") && !!(new ActiveXObject(\"Scripting.FileSystemObject\"));\n\t} catch(e) { return false; }\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new FSOSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/fsosaver.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/manualdownload.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/manualdownload.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via HTML5's download APIs\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Title of the tiddler containing the download message\nvar downloadInstructionsTitle = \"$:/language/Modals/Download\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar ManualDownloadSaver = function(wiki) {\n};\n\nManualDownloadSaver.prototype.save = function(text,method,callback) {\n\t$tw.modal.display(downloadInstructionsTitle,{\n\t\tdownloadLink: \"data:text/html,\" + encodeURIComponent(text)\n\t});\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nManualDownloadSaver.prototype.info = {\n\tname: \"manualdownload\",\n\tpriority: 0,\n\tcapabilities: [\"save\", \"download\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn true;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new ManualDownloadSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/manualdownload.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/msdownload.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/msdownload.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via window.navigator.msSaveBlob()\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar MsDownloadSaver = function(wiki) {\n};\n\nMsDownloadSaver.prototype.save = function(text,method,callback) {\n\t// Get the current filename\n\tvar filename = \"tiddlywiki.html\",\n\t\tp = document.location.pathname.lastIndexOf(\"/\");\n\tif(p !== -1) {\n\t\tfilename = document.location.pathname.substr(p+1);\n\t}\n\t// Set up the link\n\tvar blob = new Blob([text], {type: \"text/html\"});\n\twindow.navigator.msSaveBlob(blob,filename);\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nMsDownloadSaver.prototype.info = {\n\tname: \"msdownload\",\n\tpriority: 110,\n\tcapabilities: [\"save\", \"download\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn !!window.navigator.msSaveBlob;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new MsDownloadSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/msdownload.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/tiddlyfox.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/tiddlyfox.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via the TiddlyFox file extension\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false, netscape: false, Components: false */\n\"use strict\";\n\nvar TiddlyFoxSaver = function(wiki) {\n};\n\nTiddlyFoxSaver.prototype.save = function(text,method,callback) {\n\tvar messageBox = document.getElementById(\"tiddlyfox-message-box\");\n\tif(messageBox) {\n\t\t// Get the pathname of this document\n\t\tvar pathname = document.location.toString().split(\"#\")[0];\n\t\t// Replace file://localhost/ with file:///\n\t\tif(pathname.indexOf(\"file://localhost/\") == 0) {\n\t\t\tpathname = \"file://\" + pathname.substr(16);\n\t\t}\n\t\t// Windows path file:///x:/blah/blah --> x:\\blah\\blah\n\t\tif(/^file\\:\\/\\/\\/[A-Z]\\:\\//i.test(pathname)) {\n\t\t\t// Remove the leading slash and convert slashes to backslashes\n\t\t\tpathname = pathname.substr(8).replace(/\\//g,\"\\\\\");\n\t\t// Firefox Windows network path file://///server/share/blah/blah --> //server/share/blah/blah\n\t\t} else if(pathname.indexOf(\"file://///\") === 0) {\n\t\t\tpathname = \"\\\\\\\\\" + unescape(pathname.substr(10)).replace(/\\//g,\"\\\\\");\n\t\t// Mac/Unix local path file:///path/path --> /path/path\n\t\t} else if(pathname.indexOf(\"file:///\") == 0) {\n\t\t\tpathname = unescape(pathname.substr(7));\n\t\t// Mac/Unix local path file:/path/path --> /path/path\n\t\t} else if(pathname.indexOf(\"file:/\") == 0) {\n\t\t\tpathname = unescape(pathname.substr(5));\n\t\t// Otherwise Windows networth path file://server/share/path/path --> \\\\server\\share\\path\\path\n\t\t} else {\n\t\t\tpathname = \"\\\\\\\\\" + unescape(pathname.substr(7)).replace(new RegExp(\"/\",\"g\"),\"\\\\\");\n\t\t}\n\t\t// Create the message element and put it in the message box\n\t\tvar message = document.createElement(\"div\");\nconsole.log(\"Pathname\",pathname);\n\t\tmessage.setAttribute(\"data-tiddlyfox-path\",decodeURIComponent(pathname));\n\t\tmessage.setAttribute(\"data-tiddlyfox-content\",text);\n\t\tmessageBox.appendChild(message);\n\t\t// Add an event handler for when the file has been saved\n\t\tmessage.addEventListener(\"tiddlyfox-have-saved-file\",function(event) {\n\t\t\tcallback(null);\n\t\t}, false);\n\t\t// Create and dispatch the custom event to the extension\n\t\tvar event = document.createEvent(\"Events\");\n\t\tevent.initEvent(\"tiddlyfox-save-file\",true,false);\n\t\tmessage.dispatchEvent(event);\n\t\treturn true;\n\t} else {\n\t\treturn false;\n\t}\n};\n\n/*\nInformation about this saver\n*/\nTiddlyFoxSaver.prototype.info = {\n\tname: \"tiddlyfox\",\n\tpriority: 1500,\n\tcapabilities: [\"save\", \"autosave\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn (window.location.protocol === \"file:\");\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new TiddlyFoxSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/tiddlyfox.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/tiddlyie.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/tiddlyie.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via Internet Explorer BHO extenion (TiddlyIE)\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar TiddlyIESaver = function(wiki) {\n};\n\nTiddlyIESaver.prototype.save = function(text,method,callback) {\n\t// Check existence of TiddlyIE BHO extension (note: only works after document is complete)\n\tif(typeof(window.TiddlyIE) != \"undefined\") {\n\t\t// Get the pathname of this document\n\t\tvar pathname = unescape(document.location.pathname);\n\t\t// Test for a Windows path of the form /x:/blah...\n\t\tif(/^\\/[A-Z]\\:\\/[^\\/]+/i.test(pathname)) {\t// ie: ^/[a-z]:/[^/]+ (is this better?: ^/[a-z]:/[^/]+(/[^/]+)*\\.[^/]+ )\n\t\t\t// Remove the leading slash\n\t\t\tpathname = pathname.substr(1);\n\t\t\t// Convert slashes to backslashes\n\t\t\tpathname = pathname.replace(/\\//g,\"\\\\\");\n\t\t} else if(document.hostname !== \"\" && /^\\/[^\\/]+\\/[^\\/]+/i.test(pathname)) {\t// test for \\\\server\\share\\blah... - ^/[^/]+/[^/]+\n\t\t\t// Convert slashes to backslashes\n\t\t\tpathname = pathname.replace(/\\//g,\"\\\\\");\n\t\t\t// reconstruct UNC path\n\t\t\tpathname = \"\\\\\\\\\" + document.location.hostname + pathname;\n\t\t} else return false;\n\t\t\n\t\t// Prompt the user to save the file\n\t\twindow.TiddlyIE.save(pathname, text);\n\t\treturn true;\n\t} else {\n\t\treturn false;\n\t}\n};\n\n/*\nInformation about this saver\n*/\nTiddlyIESaver.prototype.info = {\n\tname: \"tiddlyiesaver\",\n\tpriority: 1500,\n\tcapabilities: [\"save\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn (window.location.protocol === \"file:\");\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new TiddlyIESaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/tiddlyie.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/twedit.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/twedit.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via the TWEdit iOS app\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false, netscape: false, Components: false */\n\"use strict\";\n\nvar TWEditSaver = function(wiki) {\n};\n\nTWEditSaver.prototype.save = function(text,method,callback) {\n\t// Bail if we're not running under TWEdit\n\tif(typeof DeviceInfo !== \"object\") {\n\t\treturn false;\n\t}\n\t// Get the pathname of this document\n\tvar pathname = decodeURIComponent(document.location.pathname);\n\t// Strip any query or location part\n\tvar p = pathname.indexOf(\"?\");\n\tif(p !== -1) {\n\t\tpathname = pathname.substr(0,p);\n\t}\n\tp = pathname.indexOf(\"#\");\n\tif(p !== -1) {\n\t\tpathname = pathname.substr(0,p);\n\t}\n\t// Remove the leading \"/Documents\" from path\n\tvar prefix = \"/Documents\";\n\tif(pathname.indexOf(prefix) === 0) {\n\t\tpathname = pathname.substr(prefix.length);\n\t}\n\t// Error handler\n\tvar errorHandler = function(event) {\n \t// Error\n \tcallback(\"Error saving to TWEdit: \" + event.target.error.code);\n };\n\t// Get the file system\n window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(fileSystem) {\n \t// Now we've got the filesystem, get the fileEntry\n fileSystem.root.getFile(pathname, {create: true}, function(fileEntry) {\n \t// Now we've got the fileEntry, create the writer\n \tfileEntry.createWriter(function(writer) {\n\t\t writer.onerror = errorHandler;\n\t\t writer.onwrite = function() {\n\t\t \tcallback(null);\n\t\t };\n\t\t writer.position = 0;\n\t\t writer.write(text);\n \t},errorHandler);\n }, errorHandler);\n }, errorHandler);\n return true;\n};\n\n/*\nInformation about this saver\n*/\nTWEditSaver.prototype.info = {\n\tname: \"twedit\",\n\tpriority: 1600,\n\tcapabilities: [\"save\", \"autosave\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn true;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new TWEditSaver(wiki);\n};\n\n/////////////////////////// Hack\n// HACK: This ensures that TWEdit recognises us as a TiddlyWiki document\nif($tw.browser) {\n\twindow.version = {title: \"TiddlyWiki\"};\n}\n\n})();\n",
"title": "$:/core/modules/savers/twedit.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/savers/upload.js": {
"text": "/*\\\ntitle: $:/core/modules/savers/upload.js\ntype: application/javascript\nmodule-type: saver\n\nHandles saving changes via upload to a server.\n\nDesigned to be compatible with BidiX's UploadPlugin at http://tiddlywiki.bidix.info/#UploadPlugin\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSelect the appropriate saver module and set it up\n*/\nvar UploadSaver = function(wiki) {\n\tthis.wiki = wiki;\n};\n\nUploadSaver.prototype.save = function(text,method,callback) {\n\t// Get the various parameters we need\n\tvar backupDir = this.wiki.getTextReference(\"$:/UploadBackupDir\") || \".\",\n\t\tusername = this.wiki.getTextReference(\"$:/UploadName\"),\n\t\tpassword = $tw.utils.getPassword(\"upload\"),\n\t\tuploadDir = this.wiki.getTextReference(\"$:/UploadDir\") || \".\",\n\t\tuploadFilename = this.wiki.getTextReference(\"$:/UploadFilename\") || \"index.html\",\n\t\turl = this.wiki.getTextReference(\"$:/UploadURL\");\n\t// Bail out if we don't have the bits we need\n\tif(!username || username.toString().trim() === \"\" || !password || password.toString().trim() === \"\") {\n\t\treturn false;\n\t}\n\t// Construct the url if not provided\n\tif(!url) {\n\t\turl = \"http://\" + username + \".tiddlyspot.com/store.cgi\";\n\t}\n\t// Assemble the header\n\tvar boundary = \"---------------------------\" + \"AaB03x\";\t\n\tvar uploadFormName = \"UploadPlugin\";\n\tvar head = [];\n\thead.push(\"--\" + boundary + \"\\r\\nContent-disposition: form-data; name=\\\"UploadPlugin\\\"\\r\\n\");\n\thead.push(\"backupDir=\" + backupDir + \";user=\" + username + \";password=\" + password + \";uploaddir=\" + uploadDir + \";;\"); \n\thead.push(\"\\r\\n\" + \"--\" + boundary);\n\thead.push(\"Content-disposition: form-data; name=\\\"userfile\\\"; filename=\\\"\" + uploadFilename + \"\\\"\");\n\thead.push(\"Content-Type: text/html;charset=UTF-8\");\n\thead.push(\"Content-Length: \" + text.length + \"\\r\\n\");\n\thead.push(\"\");\n\t// Assemble the tail and the data itself\n\tvar tail = \"\\r\\n--\" + boundary + \"--\\r\\n\",\n\t\tdata = head.join(\"\\r\\n\") + text + tail;\n\t// Do the HTTP post\n\tvar http = new XMLHttpRequest();\n\thttp.open(\"POST\",url,true,username,password);\n\thttp.setRequestHeader(\"Content-Type\",\"multipart/form-data; ;charset=UTF-8; boundary=\" + boundary);\n\thttp.onreadystatechange = function() {\n\t\tif(http.readyState == 4 && http.status == 200) {\n\t\t\tif(http.responseText.substr(0,4) === \"0 - \") {\n\t\t\t\tcallback(null);\n\t\t\t} else {\n\t\t\t\tcallback(http.responseText);\n\t\t\t}\n\t\t}\n\t};\n\thttp.send(data);\n\t$tw.notifier.display(\"$:/language/Notifications/Save/Starting\");\n\treturn true;\n};\n\n/*\nInformation about this saver\n*/\nUploadSaver.prototype.info = {\n\tname: \"upload\",\n\tpriority: 2000,\n\tcapabilities: [\"save\", \"autosave\"]\n};\n\n/*\nStatic method that returns true if this saver is capable of working\n*/\nexports.canSave = function(wiki) {\n\treturn true;\n};\n\n/*\nCreate an instance of this saver\n*/\nexports.create = function(wiki) {\n\treturn new UploadSaver(wiki);\n};\n\n})();\n",
"title": "$:/core/modules/savers/upload.js",
"type": "application/javascript",
"module-type": "saver"
},
"$:/core/modules/startup/commands.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/commands.js\ntype: application/javascript\nmodule-type: startup\n\nCommand processing\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"commands\";\nexports.platforms = [\"node\"];\nexports.after = [\"story\"];\nexports.synchronous = false;\n\nexports.startup = function(callback) {\n\t// On the server, start a commander with the command line arguments\n\tvar commander = new $tw.Commander(\n\t\t$tw.boot.argv,\n\t\tfunction(err) {\n\t\t\tif(err) {\n\t\t\t\tconsole.log(\"Error: \" + err);\n\t\t\t}\n\t\t\tcallback();\n\t\t},\n\t\t$tw.wiki,\n\t\t{output: process.stdout, error: process.stderr}\n\t);\n\tcommander.execute();\n};\n\n})();\n",
"title": "$:/core/modules/startup/commands.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/favicon.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/favicon.js\ntype: application/javascript\nmodule-type: startup\n\nFavicon handling\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"favicon\";\nexports.platforms = [\"browser\"];\nexports.after = [\"startup\"];\nexports.synchronous = true;\n\t\t\n// Favicon tiddler\nvar FAVICON_TITLE = \"$:/favicon.ico\";\n\nexports.startup = function() {\n\t// Set up the favicon\n\tsetFavicon();\n\t// Reset the favicon when the tiddler changes\n\t$tw.wiki.addEventListener(\"change\",function(changes) {\n\t\tif($tw.utils.hop(changes,FAVICON_TITLE)) {\n\t\t\tsetFavicon();\n\t\t}\n\t});\n};\n\nfunction setFavicon() {\n\tvar tiddler = $tw.wiki.getTiddler(FAVICON_TITLE);\n\tif(tiddler) {\n\t\tvar faviconLink = document.getElementById(\"faviconLink\");\n\t\tfaviconLink.setAttribute(\"href\",\"data:\" + tiddler.fields.type + \";base64,\" + tiddler.fields.text);\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/startup/favicon.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/load-modules.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/load-modules.js\ntype: application/javascript\nmodule-type: startup\n\nLoad core modules\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"load-modules\";\nexports.synchronous = true;\n\nexports.startup = function() {\n\t// Load modules\n\t$tw.modules.applyMethods(\"utils\",$tw.utils);\n\tif($tw.node && !$tw.browser) {\n\t\t$tw.modules.applyMethods(\"utils-node\",$tw.utils);\n\t}\n\t$tw.modules.applyMethods(\"global\",$tw);\n\t$tw.modules.applyMethods(\"config\",$tw.config);\n\t$tw.Tiddler.fieldModules = $tw.modules.getModulesByTypeAsHashmap(\"tiddlerfield\");\n\t$tw.modules.applyMethods(\"tiddlermethod\",$tw.Tiddler.prototype);\n\t$tw.modules.applyMethods(\"wikimethod\",$tw.Wiki.prototype);\n\t$tw.modules.applyMethods(\"tiddlerdeserializer\",$tw.Wiki.tiddlerDeserializerModules);\n\t$tw.macros = $tw.modules.getModulesByTypeAsHashmap(\"macro\");\n\t$tw.wiki.initParsers();\n\t$tw.Commander.initCommands();\n};\n\n})();\n",
"title": "$:/core/modules/startup/load-modules.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/password.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/password.js\ntype: application/javascript\nmodule-type: startup\n\nPassword handling\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"password\";\nexports.platforms = [\"browser\"];\nexports.after = [\"rootwidget\"];\nexports.synchronous = true;\n\nexports.startup = function() {\n\t$tw.rootWidget.addEventListener(\"tw-set-password\",function(event) {\n\t\t$tw.passwordPrompt.createPrompt({\n\t\t\tserviceName: \"Set a new password for this TiddlyWiki\",\n\t\t\tnoUserName: true,\n\t\t\tsubmitText: \"Set password\",\n\t\t\tcanCancel: true,\n\t\t\tcallback: function(data) {\n\t\t\t\tif(data) {\n\t\t\t\t\t$tw.crypto.setPassword(data.password);\n\t\t\t\t}\n\t\t\t\treturn true; // Get rid of the password prompt\n\t\t\t}\n\t\t});\n\t});\n\t$tw.rootWidget.addEventListener(\"tw-clear-password\",function(event) {\n\t\t$tw.crypto.setPassword(null);\n\t});\n\t// Ensure that $:/isEncrypted is maintained properly\n\t$tw.wiki.addEventListener(\"change\",function(changes) {\n\t\tif($tw.utils.hop(changes,\"$:/isEncrypted\")) {\n\t\t\t$tw.crypto.updateCryptoStateTiddler();\n\t\t}\n\t});\n};\n\n})();\n",
"title": "$:/core/modules/startup/password.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/render.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/render.js\ntype: application/javascript\nmodule-type: startup\n\nTitle, stylesheet and page rendering\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"render\";\nexports.platforms = [\"browser\"];\nexports.after = [\"story\"];\nexports.synchronous = true;\n\n// Default story and history lists\nvar PAGE_TITLE_TITLE = \"$:/core/wiki/title\"\nvar PAGE_STYLESHEET_TITLE = \"$:/core/ui/PageStylesheet\";\nvar PAGE_TEMPLATE_TITLE = \"$:/core/ui/PageMacros\";\n\n// Time (in ms) that we defer refreshing changes to draft tiddlers\nvar DRAFT_TIDDLER_TIMEOUT = 400;\n\nexports.startup = function() {\n\t// Set up the title\n\t$tw.titleWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TITLE_TITLE,{document: $tw.fakeDocument, parseAsInline: true});\n\t$tw.titleContainer = $tw.fakeDocument.createElement(\"div\");\n\t$tw.titleWidgetNode.render($tw.titleContainer,null);\n\tdocument.title = $tw.titleContainer.textContent;\n\t$tw.wiki.addEventListener(\"change\",function(changes) {\n\t\tif($tw.titleWidgetNode.refresh(changes,$tw.titleContainer,null)) {\n\t\t\tdocument.title = $tw.titleContainer.textContent;\n\t\t}\n\t});\n\t// Set up the styles\n\t$tw.styleWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_STYLESHEET_TITLE,{document: $tw.fakeDocument});\n\t$tw.styleContainer = $tw.fakeDocument.createElement(\"style\");\n\t$tw.styleWidgetNode.render($tw.styleContainer,null);\n\t$tw.styleElement = document.createElement(\"style\");\n\t$tw.styleElement.innerHTML = $tw.styleContainer.textContent;\n\tdocument.head.insertBefore($tw.styleElement,document.head.firstChild);\n\t$tw.wiki.addEventListener(\"change\",$tw.perf.report(\"styleRefresh\",function(changes) {\n\t\tif($tw.styleWidgetNode.refresh(changes,$tw.styleContainer,null)) {\n\t\t\t$tw.styleElement.innerHTML = $tw.styleContainer.textContent;\n\t\t}\n\t}));\n\t// Display the $:/core/ui/PageMacros tiddler to kick off the display\n\t$tw.perf.report(\"mainRender\",function() {\n\t\t$tw.pageWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TEMPLATE_TITLE,{document: document, parentWidget: $tw.rootWidget});\n\t\t$tw.pageContainer = document.createElement(\"div\");\n\t\t$tw.utils.addClass($tw.pageContainer,\"tw-page-container-wrapper\");\n\t\tdocument.body.insertBefore($tw.pageContainer,document.body.firstChild);\n\t\t$tw.pageWidgetNode.render($tw.pageContainer,null);\n\t})();\n\t// Prepare refresh mechanism\n\tvar deferredChanges = Object.create(null),\n\t\ttimerId;\n\tfunction refresh() {\n\t\t// Process the refresh\n\t\t$tw.pageWidgetNode.refresh(deferredChanges,$tw.pageContainer,null);\n\t\tdeferredChanges = Object.create(null);\n\t}\n\t// Add the change event handler\n\t$tw.wiki.addEventListener(\"change\",$tw.perf.report(\"mainRefresh\",function(changes) {\n\t\t// Check if only drafts have changed\n\t\tvar onlyDraftsHaveChanged = true;\n\t\tfor(var title in changes) {\n\t\t\tvar tiddler = $tw.wiki.getTiddler(title);\n\t\t\tif(!tiddler || !tiddler.hasField(\"draft.of\")) {\n\t\t\t\tonlyDraftsHaveChanged = false;\n\t\t\t}\n\t\t}\n\t\t// Defer the change if only drafts have changed\n\t\tif(timerId) {\n\t\t\tclearTimeout(timerId);\n\t\t}\n\t\ttimerId = null;\n\t\tif(onlyDraftsHaveChanged) {\n\t\t\ttimerId = setTimeout(refresh,DRAFT_TIDDLER_TIMEOUT);\n\t\t\t$tw.utils.extend(deferredChanges,changes);\n\t\t} else {\n\t\t\t$tw.utils.extend(deferredChanges,changes);\n\t\t\trefresh();\n\t\t}\n\t}));\n\t// Fix up the link between the root widget and the page container\n\t$tw.rootWidget.domNodes = [$tw.pageContainer];\n\t$tw.rootWidget.children = [$tw.pageWidgetNode];\n};\n\n})();\n",
"title": "$:/core/modules/startup/render.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/rootwidget.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/rootwidget.js\ntype: application/javascript\nmodule-type: startup\n\nSetup the root widget and the core root widget handlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"rootwidget\";\nexports.platforms = [\"browser\"];\nexports.after = [\"load-modules\"];\nexports.before = [\"story\"];\nexports.synchronous = true;\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nexports.startup = function() {\n\t// Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers\n\t$tw.rootWidget = new widget.widget({\n\t\ttype: \"widget\",\n\t\tchildren: []\n\t},{\n\t\twiki: $tw.wiki,\n\t\tdocument: document\n\t});\n\t// Install the modal message mechanism\n\t$tw.modal = new $tw.utils.Modal($tw.wiki);\n\t$tw.rootWidget.addEventListener(\"tw-modal\",function(event) {\n\t\t$tw.modal.display(event.param);\n\t});\n\t// Install the notification mechanism\n\t$tw.notifier = new $tw.utils.Notifier($tw.wiki);\n\t$tw.rootWidget.addEventListener(\"tw-notify\",function(event) {\n\t\t$tw.notifier.display(event.param);\n\t});\n\t// Install the scroller\n\t$tw.pageScroller = new $tw.utils.PageScroller();\n\t$tw.rootWidget.addEventListener(\"tw-scroll\",function(event) {\n\t\t$tw.pageScroller.handleEvent(event);\n\t});\n\t// Install the save action handlers\n\t$tw.rootWidget.addEventListener(\"tw-save-wiki\",function(event) {\n\t\t$tw.syncer.saveWiki({\n\t\t\ttemplate: event.param,\n\t\t\tdownloadType: \"text/plain\"\n\t\t});\n\t});\n\t$tw.rootWidget.addEventListener(\"tw-auto-save-wiki\",function(event) {\n\t\t$tw.syncer.saveWiki({\n\t\t\tmethod: \"autosave\",\n\t\t\ttemplate: event.param,\n\t\t\tdownloadType: \"text/plain\"\n\t\t});\n\t});\n\t$tw.rootWidget.addEventListener(\"tw-download-file\",function(event) {\n\t\t$tw.syncer.saveWiki({\n\t\t\tmethod: \"download\",\n\t\t\ttemplate: event.param,\n\t\t\tdownloadType: \"text/plain\"\n\t\t});\n\t});\n\t// If we're being viewed on a data: URI then give instructions for how to save\n\tif(document.location.protocol === \"data:\") {\n\t\t$tw.rootWidget.dispatchEvent({\n\t\t\ttype: \"tw-modal\",\n\t\t\tparam: \"$:/language/Modals/SaveInstructions\"\n\t\t});\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/startup/rootwidget.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/story.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/story.js\ntype: application/javascript\nmodule-type: startup\n\nLoad core modules\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"story\";\nexports.after = [\"startup\"];\nexports.synchronous = true;\n\n// Default story and history lists\nvar DEFAULT_STORY_TITLE = \"$:/StoryList\";\nvar DEFAULT_HISTORY_TITLE = \"$:/HistoryList\";\n\n// Default tiddlers\nvar DEFAULT_TIDDLERS_TITLE = \"$:/DefaultTiddlers\";\n\n// Config\nvar CONFIG_UPDATE_ADDRESS_BAR = \"$:/config/Navigation/UpdateAddressBar\"; // Can be \"no\", \"permalink\", \"permaview\"\nvar CONFIG_UPDATE_HISTORY = \"$:/config/Navigation/UpdateHistory\"; // Can be \"yes\" or \"no\"\n\nexports.startup = function() {\n\t// Open startup tiddlers\n\topenStartupTiddlers();\n\tif($tw.browser) {\n\t\t// Set up location hash update\n\t\t$tw.wiki.addEventListener(\"change\",function(changes) {\n\t\t\tif($tw.utils.hop(changes,DEFAULT_STORY_TITLE) || $tw.utils.hop(changes,DEFAULT_HISTORY_TITLE)) {\n\t\t\t\tupdateLocationHash();\n\t\t\t}\n\t\t});\n\t\t// Listen for changes to the browser location hash\n\t\twindow.addEventListener(\"hashchange\",function() {\n\t\t\tvar hash = $tw.utils.getLocationHash();\n\t\t\tif(hash !== $tw.locationHash) {\n\t\t\t\t$tw.locationHash = hash;\n\t\t\t\topenStartupTiddlers({defaultToCurrentStory: true});\n\t\t\t}\n\t\t},false)\n\t\t// Listen for the tw-home message\n\t\t$tw.rootWidget.addEventListener(\"tw-home\",function(event) {\n\t\t\tvar storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE),\n\t\t\t\tstoryList = $tw.wiki.filterTiddlers(storyFilter);\n\t\t\t$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: \"\", list: storyList},$tw.wiki.getModificationFields());\n\t\t});\n\t}\n};\n\n/*\nProcess the location hash to open the specified tiddlers. Options:\ndefaultToCurrentStory: If true, the current story is retained as the default, instead of opening the default tiddlers\n*/\nfunction openStartupTiddlers(options) {\n\toptions = options || {};\n\t// Decode the hash portion of our URL\n\tvar target,\n\t\tstoryFilter;\n\tif($tw.locationHash.length > 1) {\n\t\tvar hash = $tw.locationHash.substr(1),\n\t\t\tsplit = hash.indexOf(\":\");\n\t\tif(split === -1) {\n\t\t\ttarget = decodeURIComponent(hash.trim());\n\t\t} else {\n\t\t\ttarget = decodeURIComponent(hash.substr(0,split).trim());\n\t\t\tstoryFilter = decodeURIComponent(hash.substr(split + 1).trim());\n\t\t}\n\t}\n\t// If a target tiddler was specified add it to the history stack\n\tif(target && target !== \"\") {\n\t\t// The target tiddler doesn't need double square brackets, but we'll silently remove them if they're present\n\t\tif(target.indexOf(\"[[\") === 0 && target.substr(-2) === \"]]\") {\n\t\t\ttarget = target.substr(2,target.length - 4);\n\t\t}\n\t\t$tw.wiki.addToHistory(target);\n\t}\n\t// Use the story filter specified in the hash, or the default tiddlers\n\tif(!storyFilter || storyFilter === \"\") {\n\t\tif(options.defaultToCurrentStory) {\n\t\t\tvar currStoryList = $tw.wiki.getTiddlerList(DEFAULT_STORY_TITLE);\n\t\t\tstoryFilter = $tw.utils.stringifyList(currStoryList);\n\t\t} else {\n\t\t\tstoryFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE);\n\t\t}\n\t}\n\tvar storyList = $tw.wiki.filterTiddlers(storyFilter);\n\t// If the target tiddler isn't included then splice it in at the top\n\tif(target && storyList.indexOf(target) === -1) {\n\t\tstoryList.unshift(target);\n\t}\n\t// Save the story list\n\t$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: \"\", list: storyList},$tw.wiki.getModificationFields());\n}\n\nfunction updateLocationHash() {\n\tvar updateAddressBar = $tw.wiki.getTiddlerText(CONFIG_UPDATE_ADDRESS_BAR,\"permaview\").trim();\n\tif(updateAddressBar !== \"no\") {\n\t\t// Get the story and the history stack\n\t\tvar storyList = $tw.wiki.getTiddlerList(DEFAULT_STORY_TITLE),\n\t\t\thistoryList = $tw.wiki.getTiddlerData(DEFAULT_HISTORY_TITLE,[]);\n\t\t\tvar targetTiddler = \"\";\n\t\t// The target tiddler is the one at the top of the stack\n\t\tif(historyList.length > 0) {\n\t\t\ttargetTiddler = historyList[historyList.length-1].title;\n\t\t}\n\t\t// Blank the target tiddler if it isn't present in the story\n\t\tif(storyList.indexOf(targetTiddler) === -1) {\n\t\t\ttargetTiddler = \"\";\n\t\t}\n\t\t// Assemble the location hash\n\t\tif(updateAddressBar === \"permalink\") {\n\t\t\t$tw.locationHash = \"#\" + encodeURIComponent(targetTiddler)\n\t\t} else {\n\t\t\t$tw.locationHash = \"#\" + encodeURIComponent(targetTiddler) + \":\" + encodeURIComponent($tw.utils.stringifyList(storyList));\n\t\t}\n\t\t// Only change the location hash if we must, thus avoiding unnecessary onhashchange events\n\t\tif($tw.utils.getLocationHash() !== $tw.locationHash) {\n\t\t\tif($tw.wiki.getTiddlerText(CONFIG_UPDATE_HISTORY,\"no\").trim() === \"yes\") {\n\t\t\t\t// Assign the location hash so that history is updated\n\t\t\t\twindow.location.hash = $tw.locationHash;\n\t\t\t} else {\n\t\t\t\t// We use replace so that browser history isn't affected\n\t\t\t\twindow.location.replace(window.location.toString().split(\"#\")[0] + $tw.locationHash);\n\t\t\t}\n\t\t}\n\t}\n}\n\n})();\n",
"title": "$:/core/modules/startup/story.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup/syncer-browser.js": {
"text": "/*\\\ntitle: $:/core/modules/startup/syncer-browser.js\ntype: application/javascript\nmodule-type: startup\n\nStartup handling\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"syncer-browser\";\nexports.platforms = [\"browser\"];\nexports.after = [\"rootwidget\"];\nexports.synchronous = true;\n\nexports.startup = function() {\n\t// Listen out for login/logout/refresh events in the browser\n\t$tw.rootWidget.addEventListener(\"tw-login\",function() {\n\t\t$tw.syncer.handleLoginEvent();\n\t});\n\t$tw.rootWidget.addEventListener(\"tw-logout\",function() {\n\t\t$tw.syncer.handleLogoutEvent();\n\t});\n\t$tw.rootWidget.addEventListener(\"tw-server-refresh\",function() {\n\t\t$tw.syncer.handleRefreshEvent();\n\t});\n};\n\n})();\n",
"title": "$:/core/modules/startup/syncer-browser.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/startup.js": {
"text": "/*\\\ntitle: $:/core/modules/startup.js\ntype: application/javascript\nmodule-type: startup\n\nThis is the main application logic for both the client and server\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Export name and synchronous status\nexports.name = \"startup\";\nexports.after = [\"load-modules\"];\nexports.synchronous = true;\n\n// Set to `true` to enable performance instrumentation\nvar PERFORMANCE_INSTRUMENTATION = false;\n\nexports.startup = function() {\n\tvar modules,n,m,f;\n\tif($tw.browser) {\n\t\t$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));\n\t}\n\t$tw.version = $tw.utils.extractVersionInfo();\n\t// Set up the performance framework\n\t$tw.perf = new $tw.Performance(PERFORMANCE_INSTRUMENTATION);\n\t// Kick off the language manager and switcher\n\t$tw.language = new $tw.Language();\n\t$tw.languageSwitcher = new $tw.PluginSwitcher({\n\t\twiki: $tw.wiki,\n\t\tpluginType: \"language\",\n\t\tcontrollerTitle: \"$:/language\",\n\t\tdefaultPlugins: [\n\t\t\t\"$:/languages/en-US\"\n\t\t]\n\t});\n\t// Kick off the theme manager\n\t$tw.themeManager = new $tw.PluginSwitcher({\n\t\twiki: $tw.wiki,\n\t\tpluginType: \"theme\",\n\t\tcontrollerTitle: \"$:/theme\",\n\t\tdefaultPlugins: [\n\t\t\t\"$:/themes/tiddlywiki/snowwhite\",\n\t\t\t\"$:/themes/tiddlywiki/vanilla\"\n\t\t]\n\t});\n\t// Clear outstanding tiddler store change events to avoid an unnecessary refresh cycle at startup\n\t$tw.wiki.clearTiddlerEventQueue();\n\t// Set up the syncer object\n\t$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});\n\t// Host-specific startup\n\tif($tw.browser) {\n\t\t// Set up our beforeunload handler\n\t\twindow.addEventListener(\"beforeunload\",function(event) {\n\t\t\tvar confirmationMessage = undefined;\n\t\t\tif($tw.syncer.isDirty()) {\n\t\t\t\tconfirmationMessage = \"You have unsaved changes in TiddlyWiki\";\n\t\t\t\tevent.returnValue = confirmationMessage; // Gecko\n\t\t\t}\n\t\t\treturn confirmationMessage;\n\t\t});\n\t\t// Install the popup manager\n\t\t$tw.popup = new $tw.utils.Popup({\n\t\t\trootElement: document.body\n\t\t});\n\t\t// Install the animator\n\t\t$tw.anim = new $tw.utils.Animator();\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/startup.js",
"type": "application/javascript",
"module-type": "startup"
},
"$:/core/modules/storyviews/classic.js": {
"text": "/*\\\ntitle: $:/core/modules/storyviews/classic.js\ntype: application/javascript\nmodule-type: storyview\n\nViews the story as a linear sequence\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar ClassicStoryView = function(listWidget) {\n\tthis.listWidget = listWidget;\n}\n\nClassicStoryView.prototype.navigateTo = function(historyInfo) {\n\tvar listElementIndex = this.listWidget.findListItem(0,historyInfo.title);\n\tif(listElementIndex === undefined) {\n\t\treturn;\n\t}\n\tvar listItemWidget = this.listWidget.children[listElementIndex],\n\t\ttargetElement = listItemWidget.findFirstDomNode();\n\t// Scroll the node into view\n\tthis.listWidget.dispatchEvent({type: \"tw-scroll\", target: targetElement});\n};\n\nClassicStoryView.prototype.insert = function(widget) {\n\tvar targetElement = widget.findFirstDomNode(),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Get the current height of the tiddler\n\tvar computedStyle = window.getComputedStyle(targetElement),\n\t\tcurrMarginBottom = parseInt(computedStyle.marginBottom,10),\n\t\tcurrMarginTop = parseInt(computedStyle.marginTop,10),\n\t\tcurrHeight = targetElement.offsetHeight + currMarginTop;\n\t// Reset the margin once the transition is over\n\tsetTimeout(function() {\n\t\t$tw.utils.setStyle(targetElement,[\n\t\t\t{transition: \"none\"},\n\t\t\t{marginBottom: \"\"}\n\t\t]);\n\t},duration);\n\t// Set up the initial position of the element\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: \"none\"},\n\t\t{marginBottom: (-currHeight) + \"px\"},\n\t\t{opacity: \"0.0\"}\n\t]);\n\t$tw.utils.forceLayout(targetElement);\n\t// Transition to the final position\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: \"opacity \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"margin-bottom \" + duration + \"ms ease-in-out\"},\n\t\t{marginBottom: currMarginBottom + \"px\"},\n\t\t{opacity: \"1.0\"}\n\t]);\n};\n\nClassicStoryView.prototype.remove = function(widget) {\n\tvar targetElement = widget.findFirstDomNode(),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Get the current height of the tiddler\n\tvar currWidth = targetElement.offsetWidth,\n\t\tcomputedStyle = window.getComputedStyle(targetElement),\n\t\tcurrMarginBottom = parseInt(computedStyle.marginBottom,10),\n\t\tcurrMarginTop = parseInt(computedStyle.marginTop,10),\n\t\tcurrHeight = targetElement.offsetHeight + currMarginTop;\n\t// Remove the dom nodes of the widget at the end of the transition\n\tsetTimeout(function() {\n\t\twidget.removeChildDomNodes();\n\t},duration);\n\t// Animate the closure\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: \"none\"},\n\t\t{transform: \"translateX(0px)\"},\n\t\t{marginBottom: currMarginBottom + \"px\"},\n\t\t{opacity: \"1.0\"}\n\t]);\n\t$tw.utils.forceLayout(targetElement);\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"opacity \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"margin-bottom \" + duration + \"ms ease-in-out\"},\n\t\t{transform: \"translateX(-\" + currWidth + \"px)\"},\n\t\t{marginBottom: (-currHeight) + \"px\"},\n\t\t{opacity: \"0.0\"}\n\t]);\n};\n\nexports.classic = ClassicStoryView;\n\n})();",
"title": "$:/core/modules/storyviews/classic.js",
"type": "application/javascript",
"module-type": "storyview"
},
"$:/core/modules/storyviews/pop.js": {
"text": "/*\\\ntitle: $:/core/modules/storyviews/pop.js\ntype: application/javascript\nmodule-type: storyview\n\nAnimates list insertions and removals\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar PopStoryView = function(listWidget) {\n\tthis.listWidget = listWidget;\n}\n\nPopStoryView.prototype.navigateTo = function(historyInfo) {\n\tvar listElementIndex = this.listWidget.findListItem(0,historyInfo.title);\n\tif(listElementIndex === undefined) {\n\t\treturn;\n\t}\n\tvar listItemWidget = this.listWidget.children[listElementIndex],\n\t\ttargetElement = listItemWidget.findFirstDomNode();\n\t// Scroll the node into view\n\tthis.listWidget.dispatchEvent({type: \"tw-scroll\", target: targetElement});\n};\n\nPopStoryView.prototype.insert = function(widget) {\n\tvar targetElement = widget.findFirstDomNode(),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Reset once the transition is over\n\tsetTimeout(function() {\n\t\t$tw.utils.setStyle(targetElement,[\n\t\t\t{transition: \"none\"},\n\t\t\t{transform: \"none\"}\n\t\t]);\n\t},duration);\n\t// Set up the initial position of the element\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: \"none\"},\n\t\t{transform: \"scale(2)\"},\n\t\t{opacity: \"0.0\"}\n\t]);\n\t$tw.utils.forceLayout(targetElement);\n\t// Transition to the final position\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"opacity \" + duration + \"ms ease-in-out\"},\n\t\t{transform: \"scale(1)\"},\n\t\t{opacity: \"1.0\"}\n\t]);\n};\n\nPopStoryView.prototype.remove = function(widget) {\n\tvar targetElement = widget.findFirstDomNode(),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Remove the element at the end of the transition\n\tsetTimeout(function() {\n\t\tif(targetElement.parentNode) {\n\t\t\twidget.removeChildDomNodes();\n\t\t}\n\t},duration);\n\t// Animate the closure\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: \"none\"},\n\t\t{transform: \"scale(1)\"},\n\t\t{opacity: \"1.0\"}\n\t]);\n\t$tw.utils.forceLayout(targetElement);\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"opacity \" + duration + \"ms ease-in-out\"},\n\t\t{transform: \"scale(0.1)\"},\n\t\t{opacity: \"0.0\"}\n\t]);\n};\n\nexports.pop = PopStoryView;\n\n})();\n",
"title": "$:/core/modules/storyviews/pop.js",
"type": "application/javascript",
"module-type": "storyview"
},
"$:/core/modules/storyviews/zoomin.js": {
"text": "/*\\\ntitle: $:/core/modules/storyviews/zoomin.js\ntype: application/javascript\nmodule-type: storyview\n\nZooms between individual tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar ZoominListView = function(listWidget) {\n\tvar self = this;\n\tthis.listWidget = listWidget;\n\t// Get the index of the tiddler that is at the top of the history\n\tvar history = this.listWidget.wiki.getTiddlerData(this.listWidget.historyTitle,[]),\n\t\ttargetTiddler;\n\tif(history.length > 0) {\n\t\ttargetTiddler = history[history.length-1].title;\n\t}\n\t// Make all the tiddlers position absolute, and hide all but the top (or first) one\n\t$tw.utils.each(this.listWidget.children,function(itemWidget,index) {\n\t\tvar domNode = itemWidget.findFirstDomNode();\n\t\tif(targetTiddler !== itemWidget.parseTreeNode.itemTitle || (!targetTiddler && index)) {\n\t\t\tdomNode.style.display = \"none\";\n\t\t} else {\n\t\t\tself.currentTiddlerDomNode = domNode;\n\t\t}\n\t\tdomNode.style.position = \"absolute\";\n\t});\n};\n\nZoominListView.prototype.navigateTo = function(historyInfo) {\n\tvar duration = $tw.utils.getAnimationDuration(),\n\t\tlistElementIndex = this.listWidget.findListItem(0,historyInfo.title);\n\tif(listElementIndex === undefined) {\n\t\treturn;\n\t}\n\tvar listItemWidget = this.listWidget.children[listElementIndex],\n\t\ttargetElement = listItemWidget.findFirstDomNode();\n\t// Make the new tiddler be position absolute and visible so that we can measure it\n\t$tw.utils.setStyle(targetElement,[\n\t\t{position: \"absolute\"},\n\t\t{display: \"block\"},\n\t\t{transformOrigin: \"0 0\"},\n\t\t{transform: \"translateX(0px) translateY(0px) scale(1)\"},\n\t\t{transition: \"none\"},\n\t\t{opacity: \"0.0\"}\n\t]);\n\t// Get the position of the source node, or use the centre of the window as the source position\n\tvar sourceBounds = historyInfo.fromPageRect || {\n\t\t\tleft: window.innerWidth/2 - 2,\n\t\t\ttop: window.innerHeight/2 - 2,\n\t\t\twidth: window.innerWidth/8,\n\t\t\theight: window.innerHeight/8\n\t\t};\n\t// Try to find the title node in the target tiddler\n\tvar titleDomNode = findTitleDomNode(listItemWidget) || listItemWidget.findFirstDomNode(),\n\t\tzoomBounds = titleDomNode.getBoundingClientRect();\n\t// Compute the transform for the target tiddler to make the title lie over the source rectange\n\tvar targetBounds = targetElement.getBoundingClientRect(),\n\t\tscale = sourceBounds.width / zoomBounds.width,\n\t\tx = sourceBounds.left - targetBounds.left - (zoomBounds.left - targetBounds.left) * scale,\n\t\ty = sourceBounds.top - targetBounds.top - (zoomBounds.top - targetBounds.top) * scale;\n\t// Transform the target tiddler to its starting position\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transform: \"translateX(\" + x + \"px) translateY(\" + y + \"px) scale(\" + scale + \")\"}\n\t]);\n\t// Force layout\n\t$tw.utils.forceLayout(targetElement);\n\t// Apply the ending transitions with a timeout to ensure that the previously applied transformations are applied first\n\tvar self = this,\n\t\tprevCurrentTiddler = this.currentTiddlerDomNode;\n\tthis.currentTiddlerDomNode = targetElement;\n\t// Transform the target tiddler to its natural size\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in, opacity \" + duration + \"ms ease-in\"},\n\t\t{opacity: \"1.0\"},\n\t\t{transform: \"translateX(0px) translateY(0px) scale(1)\"},\n\t\t{zIndex: \"500\"},\n\t]);\n\t// Transform the previous tiddler out of the way and then hide it\n\tif(prevCurrentTiddler && prevCurrentTiddler !== targetElement) {\n\t\tvar scale = zoomBounds.width / sourceBounds.width;\n\t\tx = zoomBounds.left - targetBounds.left - (sourceBounds.left - targetBounds.left) * scale;\n\t\ty = zoomBounds.top - targetBounds.top - (sourceBounds.top - targetBounds.top) * scale;\n\t\t$tw.utils.setStyle(prevCurrentTiddler,[\n\t\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in, opacity \" + duration + \"ms ease-in\"},\n\t\t\t{opacity: \"0.0\"},\n\t\t\t{transformOrigin: \"0 0\"},\n\t\t\t{transform: \"translateX(\" + x + \"px) translateY(\" + y + \"px) scale(\" + scale + \")\"},\n\t\t\t{zIndex: \"0\"}\n\t\t]);\n\t\t// Hide the tiddler when the transition has finished\n\t\tsetTimeout(function() {\n\t\t\tif(self.currentTiddlerDomNode !== prevCurrentTiddler) {\n\t\t\t\tprevCurrentTiddler.style.display = \"none\";\n\t\t\t}\n\t\t},duration);\n\t}\n\t// Scroll the target into view\n//\t$tw.pageScroller.scrollIntoView(targetElement);\n};\n\n/*\nFind the first child DOM node of a widget that has the class \"title\"\n*/\nfunction findTitleDomNode(widget,targetClass) {\n\ttargetClass = targetClass || \"title\";\n\tvar domNode = widget.findFirstDomNode();\n\tif(domNode && domNode.querySelector) {\n\t\treturn domNode.querySelector(\".\" + targetClass);\n\t}\n\treturn null;\n}\n\nZoominListView.prototype.insert = function(widget) {\n\tvar targetElement = widget.findFirstDomNode();\n\t// Make the newly inserted node position absolute and hidden\n\t$tw.utils.setStyle(targetElement,[\n\t\t{display: \"none\"},\n\t\t{position: \"absolute\"}\n\t]);\n};\n\nZoominListView.prototype.remove = function(widget) {\n\tvar targetElement = widget.findFirstDomNode(),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Set up the tiddler that is being closed\n\t$tw.utils.setStyle(targetElement,[\n\t\t{position: \"absolute\"},\n\t\t{display: \"block\"},\n\t\t{transformOrigin: \"50% 50%\"},\n\t\t{transform: \"translateX(0px) translateY(0px) scale(1)\"},\n\t\t{transition: \"none\"},\n\t\t{zIndex: \"0\"}\n\t]);\n\t// We'll move back to the previous or next element in the story\n\tvar toWidget = widget.previousSibling();\n\tif(!toWidget) {\n\t\ttoWidget = widget.nextSibling();\n\t}\n\tvar toWidgetDomNode = toWidget && toWidget.findFirstDomNode();\n\t// Set up the tiddler we're moving back in\n\tif(toWidgetDomNode) {\n\t\t$tw.utils.setStyle(toWidgetDomNode,[\n\t\t\t{position: \"absolute\"},\n\t\t\t{display: \"block\"},\n\t\t\t{transformOrigin: \"50% 50%\"},\n\t\t\t{transform: \"translateX(0px) translateY(0px) scale(10)\"},\n\t\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in, opacity \" + duration + \"ms ease-in\"},\n\t\t\t{opacity: \"0\"},\n\t\t\t{zIndex: \"500\"}\n\t\t]);\n\t\tthis.currentTiddlerDomNode = toWidgetDomNode;\n\t}\n\t// Animate them both\n\t// Force layout\n\t$tw.utils.forceLayout(this.listWidget.parentDomNode);\n\t// First, the tiddler we're closing\n\t$tw.utils.setStyle(targetElement,[\n\t\t{transformOrigin: \"50% 50%\"},\n\t\t{transform: \"translateX(0px) translateY(0px) scale(0.1)\"},\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in, opacity \" + duration + \"ms ease-in\"},\n\t\t{opacity: \"0\"},\n\t\t{zIndex: \"0\"}\n\t]);\n\tsetTimeout(function() {\n\t\t// Delete the DOM node when the transition is over\n\t\twidget.removeChildDomNodes();\n\t},duration);\n\t// Now the tiddler we're going back to\n\tif(toWidgetDomNode) {\n\t\t$tw.utils.setStyle(toWidgetDomNode,[\n\t\t\t{transform: \"translateX(0px) translateY(0px) scale(1)\"},\n\t\t\t{opacity: \"1\"}\n\t\t]);\n\t}\n\treturn true; // Indicate that we'll delete the DOM node\n};\n\nexports.zoomin = ZoominListView;\n\n})();",
"title": "$:/core/modules/storyviews/zoomin.js",
"type": "application/javascript",
"module-type": "storyview"
},
"$:/core/modules/syncer.js": {
"text": "/*\\\ntitle: $:/core/modules/syncer.js\ntype: application/javascript\nmodule-type: global\n\nThe syncer tracks changes to the store. If a syncadaptor is used then individual tiddlers are synchronised through it. If there is no syncadaptor then the entire wiki is saved via saver modules.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInstantiate the syncer with the following options:\nwiki: wiki to be synced\n*/\nfunction Syncer(options) {\n\tvar self = this;\n\tthis.wiki = options.wiki;\n\t// Make a logger\n\tthis.logger = new $tw.utils.Logger(\"syncer\" + ($tw.browser ? \"-browser\" : \"\") + ($tw.node ? \"-server\" : \"\"));\n\t// Find a working syncadaptor\n\tthis.syncadaptor = undefined;\n\t$tw.modules.forEachModuleOfType(\"syncadaptor\",function(title,module) {\n\t\tif(!self.syncadaptor && module.adaptorClass) {\n\t\t\tself.syncadaptor = new module.adaptorClass(self);\n\t\t}\n\t});\n\t// Initialise our savers\n\tif($tw.browser) {\n\t\tthis.initSavers();\n\t}\n\t// Compile the dirty tiddler filter\n\tthis.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter));\n\t// Record information for known tiddlers\n\tthis.readTiddlerInfo();\n\t// Tasks are {type: \"load\"/\"save\"/\"delete\", title:, queueTime:, lastModificationTime:}\n\tthis.taskQueue = {}; // Hashmap of tasks yet to be performed\n\tthis.taskInProgress = {}; // Hash of tasks in progress\n\tthis.taskTimerId = null; // Timer for task dispatch\n\tthis.pollTimerId = null; // Timer for polling server\n\t// Listen out for changes to tiddlers\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\tself.syncToServer(changes);\n\t});\n\t// Listen out for lazyLoad events\n\tif(this.syncadaptor) {\n\t\tthis.wiki.addEventListener(\"lazyLoad\",function(title) {\n\t\t\tself.handleLazyLoadEvent(title);\n\t\t});\n\t}\n\t// Get the login status\n\tthis.getStatus(function (err,isLoggedIn) {\n\t\t// Do a sync from the server\n\t\tself.syncFromServer();\n\t});\n}\n\n/*\nConstants\n*/\nSyncer.prototype.titleIsLoggedIn = \"$:/status/IsLoggedIn\";\nSyncer.prototype.titleUserName = \"$:/status/UserName\";\nSyncer.prototype.titleSyncFilter = \"$:/config/SyncFilter\";\nSyncer.prototype.titleAutoSave = \"$:/config/AutoSave\";\nSyncer.prototype.titleSavedNotification = \"$:/language/Notifications/Save/Done\";\nSyncer.prototype.taskTimerInterval = 1 * 1000; // Interval for sync timer\nSyncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they've changed in the last 1s...\nSyncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s\nSyncer.prototype.pollTimerInterval = 60 * 1000; // Interval for polling for changes from the adaptor\n\n/*\nRead (or re-read) the latest tiddler info from the store\n*/\nSyncer.prototype.readTiddlerInfo = function() {\n\t// Hashmap by title of {revision:,changeCount:,adaptorInfo:}\n\tthis.tiddlerInfo = {};\n\t// Record information for known tiddlers\n\tvar self = this,\n\t\ttiddlers = this.filterFn.call(this.wiki);\n\t$tw.utils.each(tiddlers,function(title) {\n\t\tvar tiddler = self.wiki.getTiddler(title);\n\t\tself.tiddlerInfo[title] = {\n\t\t\trevision: tiddler.fields[\"revision\"],\n\t\t\tadaptorInfo: self.syncadaptor && self.syncadaptor.getTiddlerInfo(tiddler),\n\t\t\tchangeCount: self.wiki.getChangeCount(title)\n\t\t}\n\t});\n};\n\n/*\nSelect the appropriate saver modules and set them up\n*/\nSyncer.prototype.initSavers = function(moduleType) {\n\tmoduleType = moduleType || \"saver\";\n\t// Instantiate the available savers\n\tthis.savers = [];\n\tvar self = this;\n\t$tw.modules.forEachModuleOfType(moduleType,function(title,module) {\n\t\tif(module.canSave(self)) {\n\t\t\tself.savers.push(module.create(self.wiki));\n\t\t}\n\t});\n\t// Sort the savers into priority order\n\tthis.savers.sort(function(a,b) {\n\t\tif(a.info.priority < b.info.priority) {\n\t\t\treturn -1;\n\t\t} else {\n\t\t\tif(a.info.priority > b.info.priority) {\n\t\t\t\treturn +1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n};\n\n/*\nSave the wiki contents. Options are:\n\tmethod: \"save\" or \"download\"\n\ttemplate: the tiddler containing the template to save\n\tdownloadType: the content type for the saved file\n*/\nSyncer.prototype.saveWiki = function(options) {\n\toptions = options || {};\n\tvar self = this,\n\t\tmethod = options.method || \"save\",\n\t\ttemplate = options.template || \"$:/core/save/all\",\n\t\tdownloadType = options.downloadType || \"text/plain\",\n\t\ttext = this.wiki.renderTiddler(downloadType,template),\n\t\tcallback = function(err) {\n\t\t\tif(err) {\n\t\t\t\talert(\"Error while saving:\\n\\n\" + err);\n\t\t\t} else {\n\t\t\t\t$tw.notifier.display(self.titleSavedNotification);\n\t\t\t\tif(options.callback) {\n\t\t\t\t\toptions.callback();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t// Ignore autosave if we've got a syncadaptor or autosave is disabled\n\tif(method === \"autosave\") {\n\t\tif(this.syncadaptor || this.wiki.getTiddlerText(this.titleAutoSave,\"yes\") !== \"yes\") {\n\t\t\treturn false;\n\t\t}\n\t}\n\t// Call the highest priority saver that supports this method\n\tfor(var t=this.savers.length-1; t>=0; t--) {\n\t\tvar saver = this.savers[t];\n\t\tif(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback)) {\n\t\t\tthis.logger.log(\"Saving wiki with method\",method,\"through saver\",saver.info.name);\n\t\t\t// Clear the task queue if we're saving (rather than downloading)\n\t\t\tif(method !== \"download\") {\n\t\t\t\tthis.readTiddlerInfo();\n\t\t\t\tthis.taskQueue = {};\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n};\n\n/*\nChecks whether the wiki is dirty (ie the window shouldn't be closed)\n*/\nSyncer.prototype.isDirty = function() {\n\treturn (this.numTasksInQueue() > 0) || (this.numTasksInProgress() > 0);\n};\n\n/*\nSave an incoming tiddler in the store, and updates the associated tiddlerInfo\n*/\nSyncer.prototype.storeTiddler = function(tiddlerFields) {\n\t// Save the tiddler\n\tvar tiddler = new $tw.Tiddler(this.wiki.getTiddler(tiddlerFields.title),tiddlerFields);\n\tthis.wiki.addTiddler(tiddler);\n\t// Save the tiddler revision and changeCount details\n\tthis.tiddlerInfo[tiddlerFields.title] = {\n\t\trevision: tiddlerFields.revision,\n\t\tadaptorInfo: this.syncadaptor.getTiddlerInfo(tiddler),\n\t\tchangeCount: this.wiki.getChangeCount(tiddlerFields.title)\n\t};\n};\n\nSyncer.prototype.getStatus = function(callback) {\n\tvar self = this;\n\t// Check if the adaptor supports getStatus()\n\tif(this.syncadaptor && this.syncadaptor.getStatus) {\n\t\t// Mark us as not logged in\n\t\tthis.wiki.addTiddler({title: this.titleIsLoggedIn,text: \"no\"});\n\t\t// Get login status\n\t\tthis.syncadaptor.getStatus(function(err,isLoggedIn,username) {\n\t\t\tif(err) {\n\t\t\t\tself.logger.alert(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Set the various status tiddlers\n\t\t\tself.wiki.addTiddler({title: self.titleIsLoggedIn,text: isLoggedIn ? \"yes\" : \"no\"});\n\t\t\tif(isLoggedIn) {\n\t\t\t\tself.wiki.addTiddler({title: self.titleUserName,text: username || \"\"});\n\t\t\t} else {\n\t\t\t\tself.wiki.deleteTiddler(self.titleUserName);\n\t\t\t}\n\t\t\t// Invoke the callback\n\t\t\tif(callback) {\n\t\t\t\tcallback(err,isLoggedIn,username);\n\t\t\t}\n\t\t});\n\t} else {\n\t\tcallback(null,true,\"UNAUTHENTICATED\");\n\t}\n};\n\n/*\nSynchronise from the server by reading the skinny tiddler list and queuing up loads for any tiddlers that we don't already have up to date\n*/\nSyncer.prototype.syncFromServer = function() {\n\tif(this.syncadaptor && this.syncadaptor.getSkinnyTiddlers) {\n\t\tthis.logger.log(\"Retrieving skinny tiddler list\");\n\t\tvar self = this;\n\t\tif(this.pollTimerId) {\n\t\t\tclearTimeout(this.pollTimerId);\n\t\t\tthis.pollTimerId = null;\n\t\t}\n\t\tthis.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {\n\t\t\t// Trigger another sync\n\t\t\tself.pollTimerId = setTimeout(function() {\n\t\t\t\tself.pollTimerId = null;\n\t\t\t\tself.syncFromServer.call(self);\n\t\t\t},self.pollTimerInterval);\n\t\t\t// Check for errors\n\t\t\tif(err) {\n\t\t\t\tself.logger.alert(\"Error retrieving skinny tiddler list:\",err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Process each incoming tiddler\n\t\t\tfor(var t=0; t<tiddlers.length; t++) {\n\t\t\t\t// Get the incoming tiddler fields, and the existing tiddler\n\t\t\t\tvar tiddlerFields = tiddlers[t],\n\t\t\t\t\tincomingRevision = tiddlerFields.revision + \"\",\n\t\t\t\t\ttiddler = self.wiki.getTiddler(tiddlerFields.title),\n\t\t\t\t\ttiddlerInfo = self.tiddlerInfo[tiddlerFields.title],\n\t\t\t\t\tcurrRevision = tiddlerInfo ? tiddlerInfo.revision : null;\n\t\t\t\t// Ignore the incoming tiddler if it's the same as the revision we've already got\n\t\t\t\tif(currRevision !== incomingRevision) {\n\t\t\t\t\t// Do a full load if we've already got a fat version of the tiddler\n\t\t\t\t\tif(tiddler && tiddler.fields.text !== undefined) {\n\t\t\t\t\t\t// Do a full load of this tiddler\n\t\t\t\t\t\tself.enqueueSyncTask({\n\t\t\t\t\t\t\ttype: \"load\",\n\t\t\t\t\t\t\ttitle: tiddlerFields.title\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Load the skinny version of the tiddler\n\t\t\t\t\t\tself.storeTiddler(tiddlerFields);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n};\n\n/*\nSynchronise a set of changes to the server\n*/\nSyncer.prototype.syncToServer = function(changes) {\n\tvar self = this,\n\t\tnow = Date.now(),\n\t\tfilteredChanges = this.filterFn.call(this.wiki,function(callback) {\n\t\t\t$tw.utils.each(changes,function(change,title) {\n\t\t\t\tvar tiddler = self.wiki.getTiddler(title);\n\t\t\t\tcallback(tiddler,title);\n\t\t\t});\n\t\t});\n\t$tw.utils.each(changes,function(change,title,object) {\n\t\t// Process the change if it is a deletion of a tiddler we're already syncing, or is on the filtered change list\n\t\tif((change.deleted && $tw.utils.hop(self.tiddlerInfo,title)) || filteredChanges.indexOf(title) !== -1) {\n\t\t\t// Queue a task to sync this tiddler\n\t\t\tself.enqueueSyncTask({\n\t\t\t\ttype: change.deleted ? \"delete\" : \"save\",\n\t\t\t\ttitle: title\n\t\t\t});\n\t\t}\n\t});\n};\n\n/*\nLazily load a skinny tiddler if we can\n*/\nSyncer.prototype.handleLazyLoadEvent = function(title) {\n\t// Queue up a sync task to load this tiddler\n\tthis.enqueueSyncTask({\n\t\ttype: \"load\",\n\t\ttitle: title\n\t});\n};\n\n/*\nDispay a password prompt and allow the user to login\n*/\nSyncer.prototype.handleLoginEvent = function() {\n\tvar self = this;\n\tthis.getStatus(function(err,isLoggedIn,username) {\n\t\tif(!isLoggedIn) {\n\t\t\t$tw.passwordPrompt.createPrompt({\n\t\t\t\tserviceName: \"Login to TiddlySpace\",\n\t\t\t\tcallback: function(data) {\n\t\t\t\t\tself.login(data.username,data.password,function(err,isLoggedIn) {\n\t\t\t\t\t\tself.syncFromServer();\n\t\t\t\t\t});\n\t\t\t\t\treturn true; // Get rid of the password prompt\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n};\n\n/*\nAttempt to login to TiddlyWeb.\n\tusername: username\n\tpassword: password\n\tcallback: invoked with arguments (err,isLoggedIn)\n*/\nSyncer.prototype.login = function(username,password,callback) {\n\tthis.logger.log(\"Attempting to login as\",username);\n\tvar self = this;\n\tif(this.syncadaptor.login) {\n\t\tthis.syncadaptor.login(username,password,function(err) {\n\t\t\tif(err) {\n\t\t\t\treturn callback(err);\n\t\t\t}\n\t\t\tself.getStatus(function(err,isLoggedIn,username) {\n\t\t\t\tif(callback) {\n\t\t\t\t\tcallback(null,isLoggedIn);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t} else {\n\t\tcallback(null,true);\n\t}\n};\n\n/*\nAttempt to log out of TiddlyWeb\n*/\nSyncer.prototype.handleLogoutEvent = function() {\n\tthis.logger.log(\"Attempting to logout\");\n\tvar self = this;\n\tif(this.syncadaptor.logout) {\n\t\tthis.syncadaptor.logout(function(err) {\n\t\t\tif(err) {\n\t\t\t\tself.logger.alert(err);\n\t\t\t} else {\n\t\t\t\tself.getStatus();\n\t\t\t}\n\t\t});\n\t}\n};\n\n/*\nImmediately refresh from the server\n*/\nSyncer.prototype.handleRefreshEvent = function() {\n\tthis.syncFromServer();\n};\n\n/*\nQueue up a sync task. If there is already a pending task for the tiddler, just update the last modification time\n*/\nSyncer.prototype.enqueueSyncTask = function(task) {\n\tvar self = this,\n\t\tnow = Date.now();\n\t// Set the timestamps on this task\n\ttask.queueTime = now;\n\ttask.lastModificationTime = now;\n\t// Fill in some tiddlerInfo if the tiddler is one we haven't seen before\n\tif(!$tw.utils.hop(this.tiddlerInfo,task.title)) {\n\t\tthis.tiddlerInfo[task.title] = {\n\t\t\trevision: null,\n\t\t\tadaptorInfo: {},\n\t\t\tchangeCount: -1\n\t\t}\n\t}\n\t// Bail if this is a save and the tiddler is already at the changeCount that the server has\n\tif(task.type === \"save\" && this.wiki.getChangeCount(task.title) <= this.tiddlerInfo[task.title].changeCount) {\n\t\treturn;\n\t}\n\t// Check if this tiddler is already in the queue\n\tif($tw.utils.hop(this.taskQueue,task.title)) {\n\t\t// this.logger.log(\"Re-queueing up sync task with type:\",task.type,\"title:\",task.title);\n\t\tvar existingTask = this.taskQueue[task.title];\n\t\t// If so, just update the last modification time\n\t\texistingTask.lastModificationTime = task.lastModificationTime;\n\t\t// If the new task is a save then we upgrade the existing task to a save. Thus a pending load is turned into a save if the tiddler changes locally in the meantime. But a pending save is not modified to become a load\n\t\tif(task.type === \"save\" || task.type === \"delete\") {\n\t\t\texistingTask.type = task.type;\n\t\t}\n\t} else {\n\t\t// this.logger.log(\"Queuing up sync task with type:\",task.type,\"title:\",task.title);\n\t\t// If it is not in the queue, insert it\n\t\tthis.taskQueue[task.title] = task;\n\t}\n\t// Process the queue\n\tif(this.syncadaptor) {\n\t\t$tw.utils.nextTick(function() {self.processTaskQueue.call(self);});\n\t}\n};\n\n/*\nReturn the number of tasks in progress\n*/\nSyncer.prototype.numTasksInProgress = function() {\n\treturn $tw.utils.count(this.taskInProgress);\n};\n\n/*\nReturn the number of tasks in the queue\n*/\nSyncer.prototype.numTasksInQueue = function() {\n\treturn $tw.utils.count(this.taskQueue);\n};\n\n/*\nTrigger a timeout if one isn't already outstanding\n*/\nSyncer.prototype.triggerTimeout = function() {\n\tvar self = this;\n\tif(!this.taskTimerId) {\n\t\tthis.taskTimerId = setTimeout(function() {\n\t\t\tself.taskTimerId = null;\n\t\t\tself.processTaskQueue.call(self);\n\t\t},self.taskTimerInterval);\n\t}\n};\n\n/*\nProcess the task queue, performing the next task if appropriate\n*/\nSyncer.prototype.processTaskQueue = function() {\n\tvar self = this;\n\t// Only process a task if we're not already performing a task. If we are already performing a task then we'll dispatch the next one when it completes\n\tif(this.numTasksInProgress() === 0) {\n\t\t// Choose the next task to perform\n\t\tvar task = this.chooseNextTask();\n\t\t// Perform the task if we had one\n\t\tif(task) {\n\t\t\t// Remove the task from the queue and add it to the in progress list\n\t\t\tdelete this.taskQueue[task.title];\n\t\t\tthis.taskInProgress[task.title] = task;\n\t\t\t// Dispatch the task\n\t\t\tthis.dispatchTask(task,function(err) {\n\t\t\t\tif(err) {\n\t\t\t\t\tself.logger.alert(\"Sync error while processing '\" + task.title + \"':\\n\" + err);\n\t\t\t\t}\n\t\t\t\t// Mark that this task is no longer in progress\n\t\t\t\tdelete self.taskInProgress[task.title];\n\t\t\t\t// Process the next task\n\t\t\t\tself.processTaskQueue.call(self);\n\t\t\t});\n\t\t} else {\n\t\t\t// Make sure we've set a time if there wasn't a task to perform, but we've still got tasks in the queue\n\t\t\tif(this.numTasksInQueue() > 0) {\n\t\t\t\tthis.triggerTimeout();\n\t\t\t}\n\t\t}\n\t}\n};\n\n/*\nChoose the next applicable task\n*/\nSyncer.prototype.chooseNextTask = function() {\n\tvar self = this,\n\t\tcandidateTask = null,\n\t\tnow = Date.now();\n\t// Select the best candidate task\n\t$tw.utils.each(this.taskQueue,function(task,title) {\n\t\t// Exclude the task if there's one of the same name in progress\n\t\tif($tw.utils.hop(self.taskInProgress,title)) {\n\t\t\treturn;\n\t\t}\n\t\t// Exclude the task if it is a save and the tiddler has been modified recently, but not hit the fallback time\n\t\tif(task.type === \"save\" && (now - task.lastModificationTime) < self.throttleInterval &&\n\t\t\t(now - task.queueTime) < self.fallbackInterval) {\n\t\t\treturn;\t\n\t\t}\n\t\t// Exclude the task if it is newer than the current best candidate\n\t\tif(candidateTask && candidateTask.queueTime < task.queueTime) {\n\t\t\treturn;\n\t\t}\n\t\t// Now this is our best candidate\n\t\tcandidateTask = task;\n\t});\n\treturn candidateTask;\n};\n\n/*\nDispatch a task and invoke the callback\n*/\nSyncer.prototype.dispatchTask = function(task,callback) {\n\tvar self = this;\n\tif(task.type === \"save\") {\n\t\tvar changeCount = this.wiki.getChangeCount(task.title),\n\t\t\ttiddler = this.wiki.getTiddler(task.title);\n\t\tthis.logger.log(\"Dispatching 'save' task:\",task.title);\n\t\tif(tiddler) {\n\t\t\tthis.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {\n\t\t\t\tif(err) {\n\t\t\t\t\treturn callback(err);\n\t\t\t\t}\n\t\t\t\t// Adjust the info stored about this tiddler\n\t\t\t\tself.tiddlerInfo[task.title] = {\n\t\t\t\t\tchangeCount: changeCount,\n\t\t\t\t\tadaptorInfo: adaptorInfo,\n\t\t\t\t\trevision: revision\n\t\t\t\t};\n\t\t\t\t// Invoke the callback\n\t\t\t\tcallback(null);\n\t\t\t});\n\t\t} else {\n\t\t\tthis.logger.log(\" Not Dispatching 'save' task:\",task.title,\"tiddler does not exist\");\n\t\t\treturn callback(null);\n\t\t}\n\t} else if(task.type === \"load\") {\n\t\t// Load the tiddler\n\t\tthis.logger.log(\"Dispatching 'load' task:\",task.title);\n\t\tthis.syncadaptor.loadTiddler(task.title,function(err,tiddlerFields) {\n\t\t\tif(err) {\n\t\t\t\treturn callback(err);\n\t\t\t}\n\t\t\t// Store the tiddler\n\t\t\tif(tiddlerFields) {\n\t\t\t\tself.storeTiddler(tiddlerFields);\n\t\t\t}\n\t\t\t// Invoke the callback\n\t\t\tcallback(null);\n\t\t});\n\t} else if(task.type === \"delete\") {\n\t\t// Delete the tiddler\n\t\tthis.logger.log(\"Dispatching 'delete' task:\",task.title);\n\t\tthis.syncadaptor.deleteTiddler(task.title,function(err) {\n\t\t\tif(err) {\n\t\t\t\treturn callback(err);\n\t\t\t}\n\t\t\t// Invoke the callback\n\t\t\tcallback(null);\n\t\t});\n\t}\n};\n\nexports.Syncer = Syncer;\n\n})();\n",
"title": "$:/core/modules/syncer.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/tiddler.js": {
"text": "/*\\\ntitle: $:/core/modules/tiddler.js\ntype: application/javascript\nmodule-type: tiddlermethod\n\nExtension methods for the $tw.Tiddler object (constructor and methods required at boot time are in boot/boot.js)\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.hasTag = function(tag) {\n\treturn this.fields.tags && this.fields.tags.indexOf(tag) !== -1;\n};\n\nexports.isPlugin = function() {\n\treturn this.fields.type === \"application/json\" && this.hasField(\"plugin-type\");\n}\n\nexports.isDraft = function() {\n\treturn this.hasField(\"draft.of\");\n};\n\nexports.getFieldString = function(field) {\n\tvar value = this.fields[field];\n\t// Check for a missing field\n\tif(value === undefined || value === null) {\n\t\treturn \"\";\n\t}\n\t// Parse the field with the associated module (if any)\n\tvar fieldModule = $tw.Tiddler.fieldModules[field];\n\tif(fieldModule && fieldModule.stringify) {\n\t\treturn fieldModule.stringify.call(this,value);\n\t} else {\n\t\treturn value.toString();\n\t}\n};\n\n/*\nGet all the fields as a name:value block. Options:\n\texclude: an array of field names to exclude\n*/\nexports.getFieldStringBlock = function(options) {\n\toptions = options || {};\n\tvar exclude = options.exclude || [];\n\tvar fields = [];\n\tfor(var field in this.fields) {\n\t\tif($tw.utils.hop(this.fields,field)) {\n\t\t\tif(exclude.indexOf(field) === -1) {\n\t\t\t\tfields.push(field + \": \" + this.getFieldString(field));\n\t\t\t}\n\t\t}\n\t}\n\treturn fields.join(\"\\n\");\n};\n\n})();\n",
"title": "$:/core/modules/tiddler.js",
"type": "application/javascript",
"module-type": "tiddlermethod"
},
"$:/core/modules/utils/crypto.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/crypto.js\ntype: application/javascript\nmodule-type: utils\n\nUtility functions related to crypto.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nLook for an encrypted store area in the text of a TiddlyWiki file\n*/\nexports.extractEncryptedStoreArea = function(text) {\n\tvar encryptedStoreAreaStartMarker = \"<pre id=\\\"encryptedStoreArea\\\" type=\\\"text/plain\\\" style=\\\"display:none;\\\">\",\n\t\tencryptedStoreAreaStart = text.indexOf(encryptedStoreAreaStartMarker);\n\tif(encryptedStoreAreaStart !== -1) {\n\t\tvar encryptedStoreAreaEnd = text.indexOf(\"</pre>\",encryptedStoreAreaStart);\n\t\tif(encryptedStoreAreaEnd !== -1) {\n\t\t\treturn $tw.utils.htmlDecode(text.substring(encryptedStoreAreaStart + encryptedStoreAreaStartMarker.length,encryptedStoreAreaEnd-1));\n\t\t}\n\t}\n\treturn null;\n};\n\n/*\nAttempt to extract the tiddlers from an encrypted store area using the current password. If the password is not provided then the password in the password store will be used\n*/\nexports.decryptStoreArea = function(encryptedStoreArea,password) {\n\tvar decryptedText = $tw.crypto.decrypt(encryptedStoreArea,password);\n\tif(decryptedText) {\n\t\tvar json = JSON.parse(decryptedText),\n\t\t\ttiddlers = [];\n\t\tfor(var title in json) {\n\t\t\tif(title !== \"$:/isEncrypted\") {\n\t\t\t\ttiddlers.push(json[title]);\n\t\t\t}\n\t\t}\n\t\treturn tiddlers;\n\t} else {\n\t\treturn null;\n\t}\n};\n\nexports.decryptStoreAreaInteractive = function(encryptedStoreArea,callback) {\n\t// Try to decrypt with the current password\n\tvar tiddlers = $tw.utils.decryptStoreArea(encryptedStoreArea);\n\tif(tiddlers) {\n\t\tcallback(tiddlers);\n\t} else {\n\t\t// Prompt for a new password and keep trying\n\t\t$tw.passwordPrompt.createPrompt({\n\t\t\tserviceName: \"Enter a password to decrypt the imported TiddlyWiki\",\n\t\t\tnoUserName: true,\n\t\t\tcanCancel: true,\n\t\t\tsubmitText: \"Decrypt\",\n\t\t\tcallback: function(data) {\n\t\t\t\t// Exit if the user cancelled\n\t\t\t\tif(!data) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// Attempt to decrypt the tiddlers\n\t\t\t\tvar tiddlers = $tw.utils.decryptStoreArea(encryptedStoreArea,data.password);\n\t\t\t\tif(tiddlers) {\n\t\t\t\t\tcallback(tiddlers);\n\t\t\t\t\t// Exit and remove the password prompt\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\t// We didn't decrypt everything, so continue to prompt for password\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/utils/crypto.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/animations/slide.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/animations/slide.js\ntype: application/javascript\nmodule-type: animation\n\nA simple slide animation that varies the height of the element\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nfunction slideOpen(domNode,options) {\n\toptions = options || {};\n\tvar duration = options.duration || $tw.utils.getAnimationDuration();\n\t// Get the current height of the domNode\n\tvar computedStyle = window.getComputedStyle(domNode),\n\t\tcurrMarginBottom = parseInt(computedStyle.marginBottom,10),\n\t\tcurrMarginTop = parseInt(computedStyle.marginTop,10),\n\t\tcurrPaddingBottom = parseInt(computedStyle.paddingBottom,10),\n\t\tcurrPaddingTop = parseInt(computedStyle.paddingTop,10),\n\t\tcurrHeight = domNode.offsetHeight;\n\t// Reset the margin once the transition is over\n\tsetTimeout(function() {\n\t\t$tw.utils.setStyle(domNode,[\n\t\t\t{transition: \"none\"},\n\t\t\t{marginBottom: \"\"},\n\t\t\t{marginTop: \"\"},\n\t\t\t{paddingBottom: \"\"},\n\t\t\t{paddingTop: \"\"},\n\t\t\t{height: \"auto\"},\n\t\t\t{opacity: \"\"}\n\t\t]);\n\t\tif(options.callback) {\n\t\t\toptions.callback();\n\t\t}\n\t},duration);\n\t// Set up the initial position of the element\n\t$tw.utils.setStyle(domNode,[\n\t\t{transition: \"none\"},\n\t\t{marginTop: \"0px\"},\n\t\t{marginBottom: \"0px\"},\n\t\t{paddingTop: \"0px\"},\n\t\t{paddingBottom: \"0px\"},\n\t\t{height: \"0px\"},\n\t\t{opacity: \"0\"}\n\t]);\n\t$tw.utils.forceLayout(domNode);\n\t// Transition to the final position\n\t$tw.utils.setStyle(domNode,[\n\t\t{transition: \"margin-top \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"margin-bottom \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"padding-top \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"padding-bottom \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"height \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"opacity \" + duration + \"ms ease-in-out\"},\n\t\t{marginBottom: currMarginBottom + \"px\"},\n\t\t{marginTop: currMarginTop + \"px\"},\n\t\t{paddingBottom: currPaddingBottom + \"px\"},\n\t\t{paddingTop: currPaddingTop + \"px\"},\n\t\t{height: currHeight + \"px\"},\n\t\t{opacity: \"1\"}\n\t]);\n}\n\nfunction slideClosed(domNode,options) {\n\toptions = options || {};\n\tvar duration = options.duration || $tw.utils.getAnimationDuration(),\n\t\tcurrHeight = domNode.offsetHeight;\n\t// Clear the properties we've set when the animation is over\n\tsetTimeout(function() {\n\t\t$tw.utils.setStyle(domNode,[\n\t\t\t{transition: \"none\"},\n\t\t\t{marginBottom: \"\"},\n\t\t\t{marginTop: \"\"},\n\t\t\t{paddingBottom: \"\"},\n\t\t\t{paddingTop: \"\"},\n\t\t\t{height: \"auto\"},\n\t\t\t{opacity: \"\"}\n\t\t]);\n\t\tif(options.callback) {\n\t\t\toptions.callback();\n\t\t}\n\t},duration);\n\t// Set up the initial position of the element\n\t$tw.utils.setStyle(domNode,[\n\t\t{height: currHeight + \"px\"},\n\t\t{opacity: \"1\"}\n\t]);\n\t$tw.utils.forceLayout(domNode);\n\t// Transition to the final position\n\t$tw.utils.setStyle(domNode,[\n\t\t{transition: \"margin-top \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"margin-bottom \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"padding-top \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"padding-bottom \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"height \" + duration + \"ms ease-in-out, \" +\n\t\t\t\t\t\"opacity \" + duration + \"ms ease-in-out\"},\n\t\t{marginTop: \"0px\"},\n\t\t{marginBottom: \"0px\"},\n\t\t{paddingTop: \"0px\"},\n\t\t{paddingBottom: \"0px\"},\n\t\t{height: \"0px\"},\n\t\t{opacity: \"0\"}\n\t]);\n}\n\nexports.slide = {\n\topen: slideOpen,\n\tclose: slideClosed\n};\n\n})();\n",
"title": "$:/core/modules/utils/dom/animations/slide.js",
"type": "application/javascript",
"module-type": "animation"
},
"$:/core/modules/utils/dom/animator.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/animator.js\ntype: application/javascript\nmodule-type: utils\n\nOrchestrates animations and transitions\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nfunction Animator() {\n\t// Get the registered animation modules\n\tthis.animations = {};\n\t$tw.modules.applyMethods(\"animation\",this.animations);\n}\n\nAnimator.prototype.perform = function(type,domNode,options) {\n\toptions = options || {};\n\t// Find an animation that can handle this type\n\tvar chosenAnimation;\n\t$tw.utils.each(this.animations,function(animation,name) {\n\t\tif($tw.utils.hop(animation,type)) {\n\t\t\tchosenAnimation = animation[type];\n\t\t}\n\t});\n\tif(!chosenAnimation) {\n\t\tchosenAnimation = function(domNode,options) {\n\t\t\tif(options.callback) {\n\t\t\t\toptions.callback();\n\t\t\t}\n\t\t};\n\t}\n\t// Call the animation\n\tchosenAnimation(domNode,options);\n};\n\nexports.Animator = Animator;\n\n})();\n",
"title": "$:/core/modules/utils/dom/animator.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/browser.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/browser.js\ntype: application/javascript\nmodule-type: utils\n\nBrowser feature detection\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nSet style properties of an element\n\telement: dom node\n\tstyles: ordered array of {name: value} pairs\n*/\nexports.setStyle = function(element,styles) {\n\tif(element.nodeType === 1) { // Element.ELEMENT_NODE\n\t\tfor(var t=0; t<styles.length; t++) {\n\t\t\tfor(var styleName in styles[t]) {\n\t\t\t\telement.style[$tw.utils.convertStyleNameToPropertyName(styleName)] = styles[t][styleName];\n\t\t\t}\n\t\t}\n\t}\n};\n\n/*\nConverts a standard CSS property name into the local browser-specific equivalent. For example:\n\t\"background-color\" --> \"backgroundColor\"\n\t\"transition\" --> \"webkitTransition\"\n*/\n\nvar styleNameCache = {}; // We'll cache the style name conversions\n\nexports.convertStyleNameToPropertyName = function(styleName) {\n\t// Return from the cache if we can\n\tif(styleNameCache[styleName]) {\n\t\treturn styleNameCache[styleName];\n\t}\n\t// Convert it by first removing any hyphens\n\tvar propertyName = $tw.utils.unHyphenateCss(styleName);\n\t// Then check if it needs a prefix\n\tif(document.body.style[propertyName] === undefined) {\n\t\tvar prefixes = [\"O\",\"MS\",\"Moz\",\"webkit\"];\n\t\tfor(var t=0; t<prefixes.length; t++) {\n\t\t\tvar prefixedName = prefixes[t] + propertyName.substr(0,1).toUpperCase() + propertyName.substr(1);\n\t\t\tif(document.body.style[prefixedName] !== undefined) {\n\t\t\t\tpropertyName = prefixedName;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// Put it in the cache too\n\tstyleNameCache[styleName] = propertyName;\n\treturn propertyName;\n};\n\n/*\nConverts a JS format CSS property name back into the dashed form used in CSS declarations. For example:\n\t\"backgroundColor\" --> \"background-color\"\n\t\"webkitTransform\" --> \"-webkit-transform\"\n*/\nexports.convertPropertyNameToStyleName = function(propertyName) {\n\t// Rehyphenate the name\n\tvar styleName = $tw.utils.hyphenateCss(propertyName);\n\t// If there's a webkit prefix, add a dash (other browsers have uppercase prefixes, and so get the dash automatically)\n\tif(styleName.indexOf(\"webkit\") === 0) {\n\t\tstyleName = \"-\" + styleName;\n\t} else if(styleName.indexOf(\"-m-s\") === 0) {\n\t\tstyleName = \"-ms\" + styleName.substr(4);\n\t}\n\treturn styleName;\n};\n\n/*\nRound trip a stylename to a property name and back again. For example:\n\t\"transform\" --> \"webkitTransform\" --> \"-webkit-transform\"\n*/\nexports.roundTripPropertyName = function(propertyName) {\n\treturn $tw.utils.convertPropertyNameToStyleName($tw.utils.convertStyleNameToPropertyName(propertyName));\n};\n\n/*\nConverts a standard event name into the local browser specific equivalent. For example:\n\t\"animationEnd\" --> \"webkitAnimationEnd\"\n*/\n\nvar eventNameCache = {}; // We'll cache the conversions\n\nvar eventNameMappings = {\n\t\"transitionEnd\": {\n\t\tcorrespondingCssProperty: \"transition\",\n\t\tmappings: {\n\t\t\ttransition: \"transitionend\",\n\t\t\tOTransition: \"oTransitionEnd\",\n\t\t\tMSTransition: \"msTransitionEnd\",\n\t\t\tMozTransition: \"transitionend\",\n\t\t\twebkitTransition: \"webkitTransitionEnd\"\n\t\t}\n\t},\n\t\"animationEnd\": {\n\t\tcorrespondingCssProperty: \"animation\",\n\t\tmappings: {\n\t\t\tanimation: \"animationend\",\n\t\t\tOAnimation: \"oAnimationEnd\",\n\t\t\tMSAnimation: \"msAnimationEnd\",\n\t\t\tMozAnimation: \"animationend\",\n\t\t\twebkitAnimation: \"webkitAnimationEnd\"\n\t\t}\n\t}\n};\n\nexports.convertEventName = function(eventName) {\n\tif(eventNameCache[eventName]) {\n\t\treturn eventNameCache[eventName];\n\t}\n\tvar newEventName = eventName,\n\t\tmappings = eventNameMappings[eventName];\n\tif(mappings) {\n\t\tvar convertedProperty = $tw.utils.convertStyleNameToPropertyName(mappings.correspondingCssProperty);\n\t\tif(mappings.mappings[convertedProperty]) {\n\t\t\tnewEventName = mappings.mappings[convertedProperty];\n\t\t}\n\t}\n\t// Put it in the cache too\n\teventNameCache[eventName] = newEventName;\n\treturn newEventName;\n};\n\n})();\n",
"title": "$:/core/modules/utils/dom/browser.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom.js\ntype: application/javascript\nmodule-type: utils\n\nVarious static DOM-related utility functions.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nDetermines whether element 'a' contains element 'b'\nCode thanks to John Resig, http://ejohn.org/blog/comparing-document-position/\n*/\nexports.domContains = function(a,b) {\n\treturn a.contains ?\n\t\ta !== b && a.contains(b) :\n\t\t!!(a.compareDocumentPosition(b) & 16);\n};\n\nexports.removeChildren = function(node) {\n\twhile(node.hasChildNodes()) {\n\t\tnode.removeChild(node.firstChild);\n\t}\n};\n\nexports.hasClass = function(el,className) {\n\treturn el && el.className && el.className.split(\" \").indexOf(className) !== -1;\n};\n\nexports.addClass = function(el,className) {\n\tvar c = el.className.split(\" \");\n\tif(c.indexOf(className) === -1) {\n\t\tc.push(className);\n\t}\n\tel.className = c.join(\" \");\n};\n\nexports.removeClass = function(el,className) {\n\tvar c = el.className.split(\" \"),\n\t\tp = c.indexOf(className);\n\tif(p !== -1) {\n\t\tc.splice(p,1);\n\t\tel.className = c.join(\" \");\n\t}\n};\n\nexports.toggleClass = function(el,className,status) {\n\tif(status === undefined) {\n\t\tstatus = !exports.hasClass(el,className);\n\t}\n\tif(status) {\n\t\texports.addClass(el,className);\n\t} else {\n\t\texports.removeClass(el,className);\n\t}\n};\n\n/*\nGet the scroll position of the viewport\nReturns:\n\t{\n\t\tx: horizontal scroll position in pixels,\n\t\ty: vertical scroll position in pixels\n\t}\n*/\nexports.getScrollPosition = function() {\n\tif(\"scrollX\" in window) {\n\t\treturn {x: window.scrollX, y: window.scrollY};\n\t} else {\n\t\treturn {x: document.documentElement.scrollLeft, y: document.documentElement.scrollTop};\n\t}\n};\n\n/*\nGets the bounding rectangle of an element in absolute page coordinates\n*/\nexports.getBoundingPageRect = function(element) {\n\tvar scrollPos = $tw.utils.getScrollPosition(),\n\t\tclientRect = element.getBoundingClientRect();\n\treturn {\n\t\tleft: clientRect.left + scrollPos.x,\n\t\twidth: clientRect.width,\n\t\tright: clientRect.right + scrollPos.x,\n\t\ttop: clientRect.top + scrollPos.y,\n\t\theight: clientRect.height,\n\t\tbottom: clientRect.bottom + scrollPos.y\n\t};\n};\n\n/*\nSaves a named password in the browser\n*/\nexports.savePassword = function(name,password) {\n\tif(window.localStorage) {\n\t\tlocalStorage.setItem(\"tw5-password-\" + name,password);\n\t}\n};\n\n/*\nRetrieve a named password from the browser\n*/\nexports.getPassword = function(name) {\n\treturn window.localStorage ? localStorage.getItem(\"tw5-password-\" + name) : \"\";\n};\n\n/*\nForce layout of a dom node and its descendents\n*/\nexports.forceLayout = function(element) {\n\tvar dummy = element.offsetWidth;\n};\n\n/*\nPulse an element for debugging purposes\n*/\nexports.pulseElement = function(element) {\n\t// Event handler to remove the class at the end\n\telement.addEventListener($tw.browser.animationEnd,function handler(event) {\n\t\telement.removeEventListener($tw.browser.animationEnd,handler,false);\n\t\t$tw.utils.removeClass(element,\"pulse\");\n\t},false);\n\t// Apply the pulse class\n\t$tw.utils.removeClass(element,\"pulse\");\n\t$tw.utils.forceLayout(element);\n\t$tw.utils.addClass(element,\"pulse\");\n};\n\n/*\nAttach specified event handlers to a DOM node\ndomNode: where to attach the event handlers\nevents: array of event handlers to be added (see below)\nEach entry in the events array is an object with these properties:\nhandlerFunction: optional event handler function\nhandlerObject: optional event handler object\nhandlerMethod: optionally specifies object handler method name (defaults to `handleEvent`)\n*/\nexports.addEventListeners = function(domNode,events) {\n\t$tw.utils.each(events,function(eventInfo) {\n\t\tvar handler;\n\t\tif(eventInfo.handlerFunction) {\n\t\t\thandler = eventInfo.handlerFunction;\n\t\t} else if(eventInfo.handlerObject) {\n\t\t\tif(eventInfo.handlerMethod) {\n\t\t\t\thandler = function(event) {\n\t\t\t\t\teventInfo.handlerObject[eventInfo.handlerMethod].call(eventInfo.handlerObject,event);\n\t\t\t\t};\t\n\t\t\t} else {\n\t\t\t\thandler = eventInfo.handlerObject;\n\t\t\t}\n\t\t}\n\t\tdomNode.addEventListener(eventInfo.name,handler,false);\n\t});\n};\n\n\n})();\n",
"title": "$:/core/modules/utils/dom.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/http.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/http.js\ntype: application/javascript\nmodule-type: utils\n\nBrowser HTTP support\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nA quick and dirty HTTP function; to be refactored later. Options are:\n\turl: URL to retrieve\n\ttype: GET, PUT, POST etc\n\tcallback: function invoked with (err,data)\n*/\nexports.httpRequest = function(options) {\n\tvar type = options.type || \"GET\",\n\t\theaders = options.headers || {accept: \"application/json\"},\n\t\trequest = new XMLHttpRequest(),\n\t\tdata = \"\",\n\t\tf,results;\n\t// Massage the data hashmap into a string\n\tif(options.data) {\n\t\tif(typeof options.data === \"string\") { // Already a string\n\t\t\tdata = options.data;\n\t\t} else { // A hashmap of strings\n\t\t\tresults = [];\n\t\t\t$tw.utils.each(options.data,function(dataItem,dataItemTitle) {\n\t\t\t\tresults.push(dataItemTitle + \"=\" + encodeURIComponent(dataItem));\n\t\t\t});\n\t\t\tdata = results.join(\"&\");\n\t\t}\n\t}\n\t// Set up the state change handler\n\trequest.onreadystatechange = function() {\n\t\tif(this.readyState === 4) {\n\t\t\tif(this.status === 200 || this.status === 204) {\n\t\t\t\t// Success!\n\t\t\t\toptions.callback(null,this.responseText,this);\n\t\t\t\treturn;\n\t\t\t}\n\t\t// Something went wrong\n\t\toptions.callback(\"XMLHttpRequest error code: \" + this.status);\n\t\t}\n\t};\n\t// Make the request\n\trequest.open(type,options.url,true);\n\tif(headers) {\n\t\t$tw.utils.each(headers,function(header,headerTitle,object) {\n\t\t\trequest.setRequestHeader(headerTitle,header);\n\t\t});\n\t}\n\tif(data && !$tw.utils.hop(headers,\"Content-type\")) {\n\t\trequest.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded; charset=UTF-8\");\n\t}\n\trequest.send(data);\n\treturn request;\n};\n\n})();\n",
"title": "$:/core/modules/utils/dom/http.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/keyboard.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/keyboard.js\ntype: application/javascript\nmodule-type: utils\n\nKeyboard utilities\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar namedKeys = {\n\t\"backspace\": 8,\n\t\"tab\": 9,\n\t\"enter\": 13,\n\t\"escape\": 27\n};\n\n/*\nParses a key descriptor into the structure:\n{\n\tkeyCode: numeric keycode\n\tshiftKey: boolean\n\taltKey: boolean\n\tctrlKey: boolean\n}\nKey descriptors have the following format:\n\tctrl+enter\n\tctrl+shift+alt+A\n*/\nexports.parseKeyDescriptor = function(keyDescriptor) {\n\tvar components = keyDescriptor.split(\"+\"),\n\t\tinfo = {\n\t\t\tkeyCode: 0,\n\t\t\tshiftKey: false,\n\t\t\taltKey: false,\n\t\t\tctrlKey: false\n\t\t};\n\tfor(var t=0; t<components.length; t++) {\n\t\tvar s = components[t].toLowerCase();\n\t\t// Look for modifier keys\n\t\tif(s === \"ctrl\") {\n\t\t\tinfo.ctrlKey = true;\n\t\t} else if(s === \"shift\") {\n\t\t\tinfo.shiftKey = true;\n\t\t} else if(s === \"alt\") {\n\t\t\tinfo.altKey = true;\n\t\t}\n\t\t// Replace named keys with their code\n\t\tif(namedKeys[s]) {\n\t\t\tinfo.keyCode = namedKeys[s];\n\t\t}\n\t}\n\treturn info;\n};\n\n})();\n",
"title": "$:/core/modules/utils/dom/keyboard.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/modal.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/modal.js\ntype: application/javascript\nmodule-type: utils\n\nModal message mechanism\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nvar Modal = function(wiki) {\n\tthis.wiki = wiki;\n\tthis.modalCount = 0;\n};\n\n/*\nDisplay a modal dialogue\n\ttitle: Title of tiddler to display\n\toptions: see below\nOptions include:\n\tdownloadLink: Text of a big download link to include\n*/\nModal.prototype.display = function(title,options) {\n\toptions = options || {};\n\tvar self = this,\n\t\tduration = $tw.utils.getAnimationDuration(),\n\t\ttiddler = this.wiki.getTiddler(title);\n\t// Don't do anything if the tiddler doesn't exist\n\tif(!tiddler) {\n\t\treturn;\n\t}\n\t// Create the wrapper divs\n\tvar wrapper = document.createElement(\"div\"),\n\t\tmodalBackdrop = document.createElement(\"div\"),\n\t\tmodalWrapper = document.createElement(\"div\"),\n\t\tmodalHeader = document.createElement(\"div\"),\n\t\theaderTitle = document.createElement(\"h3\"),\n\t\tmodalBody = document.createElement(\"div\"),\n\t\tmodalLink = document.createElement(\"a\"),\n\t\tmodalFooter = document.createElement(\"div\"),\n\t\tmodalFooterHelp = document.createElement(\"span\"),\n\t\tmodalFooterButtons = document.createElement(\"span\");\n\t// Up the modal count and adjust the body class\n\tthis.modalCount++;\n\tthis.adjustPageClass();\n\t// Add classes\n\t$tw.utils.addClass(wrapper,\"modal-wrapper\");\n\t$tw.utils.addClass(modalBackdrop,\"modal-backdrop\");\n\t$tw.utils.addClass(modalWrapper,\"modal\");\n\t$tw.utils.addClass(modalHeader,\"modal-header\");\n\t$tw.utils.addClass(modalBody,\"modal-body\");\n\t$tw.utils.addClass(modalLink,\"btn btn-large btn-block btn-success\");\n\t$tw.utils.addClass(modalFooter,\"modal-footer\");\n\t// Join them together\n\twrapper.appendChild(modalBackdrop);\n\twrapper.appendChild(modalWrapper);\n\tmodalHeader.appendChild(headerTitle);\n\tmodalWrapper.appendChild(modalHeader);\n\tmodalWrapper.appendChild(modalBody);\n\tmodalFooter.appendChild(modalFooterHelp);\n\tmodalFooter.appendChild(modalFooterButtons);\n\tmodalWrapper.appendChild(modalFooter);\n\t// Render the title of the message\n\tvar titleText;\n\tif(tiddler && tiddler.fields && tiddler.fields.subtitle) {\n\t\ttitleText = tiddler.fields.subtitle;\n\t} else {\n\t\ttitleText = title;\n\t}\n\tvar headerParser = this.wiki.parseText(\"text/vnd.tiddlywiki\",titleText,{parseAsInline: true}),\n\t\theaderWidgetNode = this.wiki.makeWidget(headerParser,{parentWidget: $tw.rootWidget, document: document});\n\theaderWidgetNode.render(headerTitle,null);\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\theaderWidgetNode.refresh(changes,modalHeader,null);\n\t});\n\t// Render the body of the message\n\tvar bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{parentWidget: $tw.rootWidget, document: document});\n\tbodyWidgetNode.render(modalBody,null);\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\tbodyWidgetNode.refresh(changes,modalBody,null);\n\t});\n\t// Setup the link if present\n\tif(options.downloadLink) {\n\t\tmodalLink.href = options.downloadLink\n\t\tmodalLink.appendChild(document.createTextNode(\"Right-click to save changes\"));\n\t\tmodalBody.appendChild(modalLink);\n\t}\n\t// Render the footer of the message\n\tif(tiddler && tiddler.fields && tiddler.fields.help) {\n\t\tvar link = document.createElement(\"a\");\n\t\tlink.setAttribute(\"href\",tiddler.fields.help);\n\t\tlink.setAttribute(\"target\",\"_blank\");\n\t\tlink.appendChild(document.createTextNode(\"Help\"));\n\t\tmodalFooterHelp.appendChild(link);\n\t\tmodalFooterHelp.style.float = \"left\";\n\t}\n\tvar footerText;\n\tif(tiddler && tiddler.fields && tiddler.fields.footer) {\n\t\tfooterText = tiddler.fields.footer;\n\t} else {\n\t\tfooterText = '<$button message=\"tw-close-tiddler\" class=\"btn btn-primary\">Close</$button>';\n\t}\n\tvar footerParser = this.wiki.parseText(\"text/vnd.tiddlywiki\",footerText,{parseAsInline: true}),\n\t\tfooterWidgetNode = this.wiki.makeWidget(footerParser,{parentWidget: $tw.rootWidget, document: document});\n\tfooterWidgetNode.render(modalFooterButtons,null);\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\tfooterWidgetNode.refresh(changes,modalFooterButtons,null);\n\t});\n\t// Add the close event handler\n\tvar closeHandler = function(event) {\n\t\t// Decrease the modal count and adjust the body class\n\t\tself.modalCount--;\n\t\tself.adjustPageClass();\n\t\t// Force layout and animate the modal message away\n\t\t$tw.utils.forceLayout(modalBackdrop);\n\t\t$tw.utils.forceLayout(modalWrapper);\n\t\t$tw.utils.setStyle(modalBackdrop,[\n\t\t\t{opacity: \"0\"}\n\t\t]);\n\t\t$tw.utils.setStyle(modalWrapper,[\n\t\t\t{transform: \"translateY(\" + window.innerHeight + \"px)\"}\n\t\t]);\n\t\t// Set up an event for the transition end\n\t\twindow.setTimeout(function() {\n\t\t\tif(wrapper.parentNode) {\n\t\t\t\t// Remove the modal message from the DOM\n\t\t\t\tdocument.body.removeChild(wrapper);\n\t\t\t}\n\t\t},duration);\n\t\t// Don't let anyone else handle the tw-close-tiddler message\n\t\treturn false;\n\t};\n\theaderWidgetNode.addEventListener(\"tw-close-tiddler\",closeHandler,false);\n\tbodyWidgetNode.addEventListener(\"tw-close-tiddler\",closeHandler,false);\n\tfooterWidgetNode.addEventListener(\"tw-close-tiddler\",closeHandler,false);\n\t// Set the initial styles for the message\n\t$tw.utils.setStyle(modalBackdrop,[\n\t\t{opacity: \"0\"}\n\t]);\n\t$tw.utils.setStyle(modalWrapper,[\n\t\t{transformOrigin: \"0% 0%\"},\n\t\t{transform: \"translateY(\" + (-window.innerHeight) + \"px)\"}\n\t]);\n\t// Put the message into the document\n\tdocument.body.appendChild(wrapper);\n\t// Set up animation for the styles\n\t$tw.utils.setStyle(modalBackdrop,[\n\t\t{transition: \"opacity \" + duration + \"ms ease-out\"}\n\t]);\n\t$tw.utils.setStyle(modalWrapper,[\n\t\t{transition: $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in-out\"}\n\t]);\n\t// Force layout\n\t$tw.utils.forceLayout(modalBackdrop);\n\t$tw.utils.forceLayout(modalWrapper);\n\t// Set final animated styles\n\t$tw.utils.setStyle(modalBackdrop,[\n\t\t{opacity: \"0.7\"}\n\t]);\n\t$tw.utils.setStyle(modalWrapper,[\n\t\t{transform: \"translateY(0px)\"}\n\t]);\n};\n\nModal.prototype.adjustPageClass = function() {\n\tif($tw.pageContainer) {\n\t\t$tw.utils.toggleClass($tw.pageContainer,\"tw-modal-displayed\",this.modalCount > 0);\n\t}\n};\n\nexports.Modal = Modal;\n\n})();\n",
"title": "$:/core/modules/utils/dom/modal.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/notifier.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/notifier.js\ntype: application/javascript\nmodule-type: utils\n\nNotifier mechanism\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nvar Notifier = function(wiki) {\n\tthis.wiki = wiki;\n};\n\n/*\nDisplay a notification\n\ttitle: Title of tiddler containing the notification text\n\toptions: see below\nOptions include:\n*/\nNotifier.prototype.display = function(title,options) {\n\toptions = options || {};\n\t// Create the wrapper divs\n\tvar notification = document.createElement(\"div\"),\n\t\ttiddler = this.wiki.getTiddler(title),\n\t\tduration = $tw.utils.getAnimationDuration();\n\t// Don't do anything if the tiddler doesn't exist\n\tif(!tiddler) {\n\t\treturn;\n\t}\n\t// Add classes\n\t$tw.utils.addClass(notification,\"tw-notification\");\n\t// Render the body of the notification\n\tvar widgetNode = this.wiki.makeTranscludeWidget(title,{parentWidget: $tw.rootWidget, document: document});\n\twidgetNode.render(notification,null);\n\tthis.wiki.addEventListener(\"change\",function(changes) {\n\t\twidgetNode.refresh(changes,notification,null);\n\t});\n\t// Set the initial styles for the notification\n\t$tw.utils.setStyle(notification,[\n\t\t{opacity: \"0\"},\n\t\t{transformOrigin: \"0% 0%\"},\n\t\t{transform: \"translateY(\" + (-window.innerHeight) + \"px)\"},\n\t\t{transition: \"opacity \" + duration + \"ms ease-out, \" + $tw.utils.roundTripPropertyName(\"transform\") + \" \" + duration + \"ms ease-in-out\"}\n\t]);\n\t// Add the notification to the DOM\n\tdocument.body.appendChild(notification);\n\t// Force layout\n\t$tw.utils.forceLayout(notification);\n\t// Set final animated styles\n\t$tw.utils.setStyle(notification,[\n\t\t{opacity: \"1.0\"},\n\t\t{transform: \"translateY(0px)\"}\n\t]);\n\t// Set a timer to remove the notification\n\twindow.setTimeout(function() {\n\t\t// Force layout and animate the notification away\n\t\t$tw.utils.forceLayout(notification);\n\t\t$tw.utils.setStyle(notification,[\n\t\t\t{opacity: \"0.0\"},\n\t\t\t{transform: \"translateX(\" + (notification.offsetWidth) + \"px)\"}\n\t\t]);\n\t\t// Remove the modal message from the DOM once the transition ends\n\t\tsetTimeout(function() {\n\t\t\tif(notification.parentNode) {\n\t\t\t\tdocument.body.removeChild(notification);\n\t\t\t}\n\t\t},duration);\n\t},$tw.config.preferences.notificationDuration);\n};\n\nexports.Notifier = Notifier;\n\n})();\n",
"title": "$:/core/modules/utils/dom/notifier.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/popup.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/popup.js\ntype: application/javascript\nmodule-type: utils\n\nModule that creates a $tw.utils.Popup object prototype that manages popups in the browser\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nCreates a Popup object with these options:\n\trootElement: the DOM element to which the popup zapper should be attached\n*/\nvar Popup = function(options) {\n\toptions = options || {};\n\tthis.rootElement = options.rootElement || document.body;\n};\n\nPopup.prototype.show = function(options) {\n\tthis.cancel();\n\tthis.title = options.title;\n\tthis.wiki = options.wiki;\n\tthis.anchorDomNode = options.domNode;\n\t$tw.utils.addClass(this.anchorDomNode,\"tw-popup\");\n\tthis.rootElement.addEventListener(\"click\",this,false);\n};\n\nPopup.prototype.handleEvent = function(event) {\n\t// Dismiss the popup if we get a click on an element that doesn't have .tw-popup class\n\tif(event.type === \"click\") {\n\t\tvar node = event.target;\n\t\twhile(node && !$tw.utils.hasClass(node,\"tw-popup\")) {\n\t\t\tnode = node.parentNode;\n\t\t}\n\t\tif(!node) {\n\t\t\tthis.cancel();\n\t\t}\n\t}\n};\n\nPopup.prototype.cancel = function() {\n\tif(this.anchorDomNode) {\n\t\t$tw.utils.removeClass(this.anchorDomNode,\"tw-popup\");\n\t\tthis.anchorDomNode = null;\t\t\n\t}\n\tthis.rootElement.removeEventListener(\"click\",this,false);\n\tif(this.title) {\n\t\tthis.wiki.deleteTiddler(this.title);\n\t\tthis.title = null;\n\t}\n};\n\n/*\nTrigger a popup open or closed. Parameters are in a hashmap:\n\ttitle: title of the tiddler where the popup details are stored\n\tdomNode: dom node to which the popup will be positioned\n\twiki: wiki\n\tforce: if specified, forces the popup state to true or false\n*/\nPopup.prototype.triggerPopup = function(options) {\n\t// Get the current popup state tiddler\n\tvar value = options.wiki.getTextReference(options.title,\"\");\n\t// Check if the popup is open by checking whether it matches \"(<x>,<y>)\"\n\tvar state = !this.readPopupState(options.title,value);\n\tif(\"force\" in options) {\n\t\tstate = options.force;\n\t}\n\tif(state) {\n\t\t// Set the position if we're opening it\n\t\tthis.cancel();\n\t\toptions.wiki.setTextReference(options.title,\n\t\t\t\"(\" + options.domNode.offsetLeft + \",\" + options.domNode.offsetTop + \",\" + \n\t\t\t\toptions.domNode.offsetWidth + \",\" + options.domNode.offsetHeight + \")\");\n\t\tthis.show(options);\n\t} else {\n\t\tthis.cancel();\n\t}\n};\n\n/*\nReturns true if the specified title and text identifies an active popup\n*/\nPopup.prototype.readPopupState = function(title,text) {\n\tvar popupLocationRegExp = /^\\((-?[0-9\\.E]+),(-?[0-9\\.E]+),(-?[0-9\\.E]+),(-?[0-9\\.E]+)\\)$/,\n\t\tresult = false;\n\tif(this.title === title) {\n\t\tresult = popupLocationRegExp.test(text);\n\t}\n\treturn result;\n};\n\nexports.Popup = Popup;\n\n})();\n",
"title": "$:/core/modules/utils/dom/popup.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/dom/scroller.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/dom/scroller.js\ntype: application/javascript\nmodule-type: utils\n\nModule that creates a $tw.utils.Scroller object prototype that manages scrolling in the browser\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nEvent handler for when the `tw-scroll` event hits the document body\n*/\nvar PageScroller = function() {\n\tthis.idRequestFrame = null;\n\tthis.requestAnimationFrame = window.requestAnimationFrame ||\n\t\twindow.webkitRequestAnimationFrame ||\n\t\twindow.mozRequestAnimationFrame ||\n\t\tfunction(callback) {\n\t\t\treturn window.setTimeout(callback, 1000/60);\n\t\t};\n\tthis.cancelAnimationFrame = window.cancelAnimationFrame ||\n\t\twindow.webkitCancelAnimationFrame ||\n\t\twindow.webkitCancelRequestAnimationFrame ||\n\t\twindow.mozCancelAnimationFrame ||\n\t\twindow.mozCancelRequestAnimationFrame ||\n\t\tfunction(id) {\n\t\t\twindow.clearTimeout(id);\n\t\t};\n};\n\nPageScroller.prototype.cancelScroll = function() {\n\tif(this.idRequestFrame) {\n\t\tthis.cancelAnimationFrame.call(window,this.idRequestFrame);\n\t\tthis.idRequestFrame = null;\n\t}\n};\n\n/*\nHandle an event\n*/\nPageScroller.prototype.handleEvent = function(event) {\n\tif(event.type === \"tw-scroll\") {\n\t\treturn this.scrollIntoView(event.target);\n\t}\n\treturn true;\n};\n\n/*\nHandle a scroll event hitting the page document\n*/\nPageScroller.prototype.scrollIntoView = function(element) {\n\tvar duration = $tw.utils.getAnimationDuration();\n\t// Now get ready to scroll the body\n\tthis.cancelScroll();\n\tthis.startTime = Date.now();\n\tvar scrollPosition = $tw.utils.getScrollPosition();\n\t// Get the client bounds of the element and adjust by the scroll position\n\tvar clientBounds = element.getBoundingClientRect(),\n\t\tbounds = {\n\t\t\tleft: clientBounds.left + scrollPosition.x,\n\t\t\ttop: clientBounds.top + scrollPosition.y,\n\t\t\twidth: clientBounds.width,\n\t\t\theight: clientBounds.height\n\t\t};\n\t// We'll consider the horizontal and vertical scroll directions separately via this function\n\tvar getEndPos = function(targetPos,targetSize,currentPos,currentSize) {\n\t\t\t// If the target is above/left of the current view, then scroll to it's top/left\n\t\t\tif(targetPos <= currentPos) {\n\t\t\t\treturn targetPos;\n\t\t\t// If the target is smaller than the window and the scroll position is too far up, then scroll till the target is at the bottom of the window\n\t\t\t} else if(targetSize < currentSize && currentPos < (targetPos + targetSize - currentSize)) {\n\t\t\t\treturn targetPos + targetSize - currentSize;\n\t\t\t// If the target is big, then just scroll to the top\n\t\t\t} else if(currentPos < targetPos) {\n\t\t\t\treturn targetPos;\n\t\t\t// Otherwise, stay where we are\n\t\t\t} else {\n\t\t\t\treturn currentPos;\n\t\t\t}\n\t\t},\n\t\tendX = getEndPos(bounds.left,bounds.width,scrollPosition.x,window.innerWidth),\n\t\tendY = getEndPos(bounds.top,bounds.height,scrollPosition.y,window.innerHeight);\n\t// Only scroll if necessary\n\tif(endX !== scrollPosition.x || endY !== scrollPosition.y) {\n\t\tvar self = this,\n\t\t\tdrawFrame;\n\t\tdrawFrame = function () {\n\t\t\tvar t;\n\t\t\tif(duration <= 0) {\n\t\t\t\tt = 1;\n\t\t\t} else {\n\t\t\t\tt = ((Date.now()) - self.startTime) / duration;\t\n\t\t\t}\n\t\t\tif(t >= 1) {\n\t\t\t\tself.cancelScroll();\n\t\t\t\tt = 1;\n\t\t\t}\n\t\t\tt = $tw.utils.slowInSlowOut(t);\n\t\t\twindow.scrollTo(scrollPosition.x + (endX - scrollPosition.x) * t,scrollPosition.y + (endY - scrollPosition.y) * t);\n\t\t\tif(t < 1) {\n\t\t\t\tself.idRequestFrame = self.requestAnimationFrame.call(window,drawFrame);\n\t\t\t}\n\t\t};\n\t\tdrawFrame();\n\t}\n};\n\nexports.PageScroller = PageScroller;\n\n})();\n",
"title": "$:/core/modules/utils/dom/scroller.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/fakedom.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/fakedom.js\ntype: application/javascript\nmodule-type: global\n\nA barebones implementation of DOM interfaces needed by the rendering mechanism.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Sequence number used to enable us to track objects for testing\nvar sequenceNumber = null;\n\nvar bumpSequenceNumber = function(object) {\n\tif(sequenceNumber !== null) {\n\t\tobject.sequenceNumber = sequenceNumber++;\n\t}\n}\n\nvar TW_TextNode = function(text) {\n\tbumpSequenceNumber(this);\n\tthis.textContent = text;\n};\n\nObject.defineProperty(TW_TextNode.prototype, \"formattedTextContent\", {\n\tget: function() {\n\t\treturn this.textContent.replace(/(\\r?\\n)/g,\"\");\n\t}\n});\n\nvar TW_Element = function(tag,namespace) {\n\tbumpSequenceNumber(this);\n\tthis.isTiddlyWikiFakeDom = true;\n\tthis.tag = tag;\n\tthis.attributes = {};\n\tthis.isRaw = false;\n\tthis.children = [];\n\tthis.namespaceURI = namespace || \"http://www.w3.org/1999/xhtml\";\n};\n\nTW_Element.prototype.setAttribute = function(name,value) {\n\tif(this.isRaw) {\n\t\tthrow \"Cannot setAttribute on a raw TW_Element\";\n\t}\n\tthis.attributes[name] = value;\n};\n\nTW_Element.prototype.setAttributeNS = function(namespace,name,value) {\n\tthis.setAttribute(name,value);\n};\n\nTW_Element.prototype.removeAttribute = function(name) {\n\tif(this.isRaw) {\n\t\tthrow \"Cannot removeAttribute on a raw TW_Element\";\n\t}\n\tif($tw.utils.hop(this.attributes,name)) {\n\t\tdelete this.attributes[name];\n\t}\n};\n\nTW_Element.prototype.appendChild = function(node) {\n\tthis.children.push(node);\n\tnode.parentNode = this;\n};\n\nTW_Element.prototype.insertBefore = function(node,nextSibling) {\n\tif(nextSibling) {\n\t\tvar p = this.children.indexOf(nextSibling);\n\t\tif(p !== -1) {\n\t\t\tthis.children.splice(p,0,node);\n\t\t\tnode.parentNode = this;\n\t\t} else {\n\t\t\tthis.appendChild(node);\n\t\t}\n\t} else {\n\t\tthis.appendChild(node);\n\t}\n}\n\nTW_Element.prototype.removeChild = function(node) {\n\tvar p = this.children.indexOf(node);\n\tif(p !== -1) {\n\t\tthis.children.splice(p,1);\n\t}\n};\n\nTW_Element.prototype.hasChildNodes = function() {\n\treturn !!this.children.length;\n};\n\nObject.defineProperty(TW_Element.prototype, \"firstChild\", {\n get: function() {\n \treturn this.children[0];\n }\n});\n\nTW_Element.prototype.addEventListener = function(type,listener,useCapture) {\n\t// Do nothing\n};\n\nObject.defineProperty(TW_Element.prototype, \"className\", {\n\tget: function() {\n\t\treturn this.attributes[\"class\"] || \"\";\n\t},\n set: function(value) {\n \tthis.attributes[\"class\"] = value;\n }\n});\n\nObject.defineProperty(TW_Element.prototype, \"value\", {\n\tget: function() {\n\t\treturn this.attributes[\"value\"] || \"\";\n\t},\n set: function(value) {\n \tthis.attributes[\"value\"] = value;\n }\n});\n\nObject.defineProperty(TW_Element.prototype, \"outerHTML\", {\n get: function() {\n\t\tvar output = [],attr,a,v;\n\t\toutput.push(\"<\",this.tag);\n\t\tif(this.attributes) {\n\t\t\tattr = [];\n\t\t\tfor(a in this.attributes) {\n\t\t\t\tattr.push(a);\n\t\t\t}\n\t\t\tattr.sort();\n\t\t\tfor(a=0; a<attr.length; a++) {\n\t\t\t\tv = this.attributes[attr[a]];\n\t\t\t\tif(v !== undefined) {\n\t\t\t\t\toutput.push(\" \",attr[a],\"='\",$tw.utils.htmlEncode(v),\"'\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toutput.push(\">\");\n\t\tif($tw.config.htmlVoidElements.indexOf(this.tag) === -1) {\n\t\t\toutput.push(this.innerHTML);\n\t\t\toutput.push(\"</\",this.tag,\">\");\n\t\t}\n\t\treturn output.join(\"\");\n }\n});\n\nObject.defineProperty(TW_Element.prototype, \"innerHTML\", {\n\tget: function() {\n\t\tif(this.isRaw) {\n\t\t\treturn this.rawHTML;\n\t\t} else {\n\t\t\tvar b = [];\n\t\t\t$tw.utils.each(this.children,function(node) {\n\t\t\t\tif(node instanceof TW_Element) {\n\t\t\t\t\tb.push(node.outerHTML);\n\t\t\t\t} else if(node instanceof TW_TextNode) {\n\t\t\t\t\tb.push($tw.utils.htmlEncode(node.textContent));\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn b.join(\"\");\n\t\t}\n\t},\n set: function(value) {\n \tthis.isRaw = true;\n \tthis.rawHTML = value;\n }\n});\n\nObject.defineProperty(TW_Element.prototype, \"textContent\", {\n\tget: function() {\n\t\tif(this.isRaw) {\n\t\t\tthrow \"Cannot get textContent on a raw TW_Element\";\n\t\t} else {\n\t\t\tvar b = [];\n\t\t\t$tw.utils.each(this.children,function(node) {\n\t\t\t\tb.push(node.textContent);\n\t\t\t});\n\t\t\treturn b.join(\"\");\n\t\t}\n\t}\n});\n\nObject.defineProperty(TW_Element.prototype, \"formattedTextContent\", {\n\tget: function() {\n\t\tif(this.isRaw) {\n\t\t\tthrow \"Cannot get formattedTextContent on a raw TW_Element\";\n\t\t} else {\n\t\t\tvar b = [],\n\t\t\t\tisBlock = $tw.config.htmlBlockElements.indexOf(this.tag) !== -1;\n\t\t\tif(isBlock) {\n\t\t\t\tb.push(\"\\n\");\n\t\t\t}\n\t\t\tif(this.tag === \"li\") {\n\t\t\t\tb.push(\"* \")\n\t\t\t}\n\t\t\t$tw.utils.each(this.children,function(node) {\n\t\t\t\tb.push(node.formattedTextContent);\n\t\t\t});\n\t\t\tif(isBlock) {\n\t\t\t\tb.push(\"\\n\");\n\t\t\t}\n\t\t\treturn b.join(\"\");\n\t\t}\n\t}\n});\n\nvar document = {\n\tsetSequenceNumber: function(value) {\n\t\tsequenceNumber = value;\n\t},\n\tcreateElementNS: function(namespace,tag) {\n\t\treturn new TW_Element(tag,namespace);\n\t},\n\tcreateElement: function(tag) {\n\t\treturn new TW_Element(tag);\n\t},\n\tcreateTextNode: function(text) {\n\t\treturn new TW_TextNode(text);\n\t},\n\tisTiddlyWikiFakeDom: true\n};\n\nexports.fakeDocument = document;\n\n})();\n",
"title": "$:/core/modules/utils/fakedom.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/utils/filesystem.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/filesystem.js\ntype: application/javascript\nmodule-type: utils-node\n\nFile system utilities\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar fs = require(\"fs\"),\n\tpath = require(\"path\");\n\n/*\nRecursively (and synchronously) copy a directory and all its content\n*/\nexports.copyDirectory = function(srcPath,dstPath) {\n\t// Remove any trailing path separators\n\tsrcPath = $tw.utils.removeTrailingSeparator(srcPath);\n\tdstPath = $tw.utils.removeTrailingSeparator(dstPath);\n\t// Create the destination directory\n\tvar err = $tw.utils.createDirectory(dstPath);\n\tif(err) {\n\t\treturn err;\n\t}\n\t// Function to copy a folder full of files\n\tvar copy = function(srcPath,dstPath) {\n\t\tvar srcStats = fs.lstatSync(srcPath),\n\t\t\tdstExists = fs.existsSync(dstPath);\n\t\tif(srcStats.isFile()) {\n\t\t\t$tw.utils.copyFile(srcPath,dstPath);\n\t\t} else if(srcStats.isDirectory()) {\n\t\t\tvar items = fs.readdirSync(srcPath);\n\t\t\tfor(var t=0; t<items.length; t++) {\n\t\t\t\tvar item = items[t],\n\t\t\t\t\terr = copy(srcPath + path.sep + item,dstPath + path.sep + item);\n\t\t\t\tif(err) {\n\t\t\t\t\treturn err;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t};\n\tcopy(srcPath,dstPath);\n\treturn null;\n};\n\n/*\nCopy a file\n*/\nvar FILE_BUFFER_LENGTH = 64 * 1024,\n\tfileBuffer = $tw.node && new Buffer(FILE_BUFFER_LENGTH);\n\nexports.copyFile = function(srcPath,dstPath) {\n\t// Create any directories in the destination\n\t$tw.utils.createDirectory(path.dirname(dstPath));\n\t// Copy the file\n\tvar srcFile = fs.openSync(srcPath,\"r\"),\n\t\tdstFile = fs.openSync(dstPath,\"w\"),\n\t\tbytesRead = 1,\n\t\tpos = 0;\n\twhile (bytesRead > 0) {\n\t\tbytesRead = fs.readSync(srcFile,fileBuffer,0,FILE_BUFFER_LENGTH,pos);\n\t\tfs.writeSync(dstFile,fileBuffer,0,bytesRead);\n\t\tpos += bytesRead;\n\t}\n\tfs.closeSync(srcFile);\n\tfs.closeSync(dstFile);\n\treturn null;\n}\n\n/*\nRemove trailing path separator\n*/\nexports.removeTrailingSeparator = function(dirPath) {\n\tvar len = dirPath.length;\n\tif(dirPath.charAt(len-1) === path.sep) {\n\t\tdirPath = dirPath.substr(0,len-1);\n\t}\n\treturn dirPath;\n};\n\n/*\nRecursively create a directory\n*/\nexports.createDirectory = function(dirPath) {\n\tif(dirPath.substr(dirPath.length-1,1) !== path.sep) {\n\t\tdirPath = dirPath + path.sep;\n\t}\n\tvar pos = 1;\n\tpos = dirPath.indexOf(path.sep,pos);\n\twhile(pos !== -1) {\n\t\tvar subDirPath = dirPath.substr(0,pos);\n\t\tif(!$tw.utils.isDirectory(subDirPath)) {\n\t\t\ttry {\n\t\t\t\tfs.mkdirSync(subDirPath);\n\t\t\t} catch(e) {\n\t\t\t\treturn \"Error creating directory '\" + subDirPath + \"'\";\n\t\t\t}\n\t\t}\n\t\tpos = dirPath.indexOf(path.sep,pos + 1);\n\t}\n\treturn null;\n};\n\n/*\nRecursively create directories needed to contain a specified file\n*/\nexports.createFileDirectories = function(filePath) {\n\treturn $tw.utils.createDirectory(path.dirname(filePath));\n};\n\n/*\nRecursively delete a directory\n*/\nexports.deleteDirectory = function(dirPath) {\n\tif(fs.existsSync(dirPath)) {\n\t\tvar entries = fs.readdirSync(dirPath);\n\t\tfor(var entryIndex=0; entryIndex<entries.length; entryIndex++) {\n\t\t\tvar currPath = dirPath + path.sep + entries[entryIndex];\n\t\t\tif(fs.lstatSync(currPath).isDirectory()) {\n\t\t\t\t$tw.utils.deleteDirectory(currPath);\n\t\t\t} else {\n\t\t\t\tfs.unlinkSync(currPath);\n\t\t\t}\n\t\t}\n\tfs.rmdirSync(dirPath);\n\t}\n\treturn null;\n};\n\n/*\nCheck if a path identifies a directory\n*/\nexports.isDirectory = function(dirPath) {\n\treturn fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory();\n};\n\n})();\n",
"title": "$:/core/modules/utils/filesystem.js",
"type": "application/javascript",
"module-type": "utils-node"
},
"$:/core/modules/utils/logger.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/logger.js\ntype: application/javascript\nmodule-type: utils\n\nA basic logging implementation\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar ALERT_TAG = \"$:/tags/Alert\";\n\n/*\nMake a new logger\n*/\nfunction Logger(componentName) {\n\tthis.componentName = componentName || \"\";\n}\n\n/*\nLog a message\n*/\nLogger.prototype.log = function(/* args */) {\n\tif(console !== undefined && console.log !== undefined) {\n\t\treturn Function.apply.call(console.log, console, [this.componentName + \":\"].concat(Array.prototype.slice.call(arguments,0)));\n\t}\n};\n\n/*\nAlert a message\n*/\nLogger.prototype.alert = function(/* args */) {\n\t// Prepare the text of the alert\n\tvar text = Array.prototype.join.call(arguments,\" \");\n\t// Check if there is an existing alert with the same text and the same component\n\tvar existingAlerts = $tw.wiki.getTiddlersWithTag(ALERT_TAG),\n\t\talertFields,\n\t\texistingCount,\n\t\tself = this;\n\t$tw.utils.each(existingAlerts,function(title) {\n\t\tvar tiddler = $tw.wiki.getTiddler(title);\n\t\tif(tiddler.fields.text === text && tiddler.fields.component === self.componentName && tiddler.fields.modified && (!alertFields || tiddler.fields.modified < alertFields.modified)) {\n\t\t\t\talertFields = $tw.utils.extend({},tiddler.fields);\n\t\t}\n\t});\n\tif(alertFields) {\n\t\texistingCount = alertFields.count || 1;\n\t} else {\n\t\talertFields = {\n\t\t\ttitle: $tw.wiki.generateNewTitle(\"$:/temp/alerts/alert\",{prefix: \"\"}),\n\t\t\ttext: text,\n\t\t\ttags: [ALERT_TAG],\n\t\t\tcomponent: this.componentName\n\t\t};\n\t\texistingCount = 0;\n\t}\n\talertFields.modified = new Date();\n\tif(++existingCount > 1) {\n\t\talertFields.count = existingCount;\n\t} else {\n\t\talertFields.count = undefined;\n\t}\n\t$tw.wiki.addTiddler(new $tw.Tiddler(alertFields));\n\t// Log it too\n\tthis.log.apply(this,Array.prototype.slice.call(arguments,0));\n};\n\nexports.Logger = Logger;\n\n})();\n",
"title": "$:/core/modules/utils/logger.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/parsetree.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/parsetree.js\ntype: application/javascript\nmodule-type: utils\n\nParse tree utility functions.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.addAttributeToParseTreeNode = function(node,name,value) {\n\tnode.attributes = node.attributes || {};\n\tnode.attributes[name] = {type: \"string\", value: value};\n};\n\nexports.getAttributeValueFromParseTreeNode = function(node,name,defaultValue) {\n\tif(node.attributes && node.attributes[name] && node.attributes[name].value !== undefined) {\n\t\treturn node.attributes[name].value;\n\t}\n\treturn defaultValue;\n};\n\nexports.addClassToParseTreeNode = function(node,classString) {\n\tvar classes = [];\n\tnode.attributes = node.attributes || {};\n\tnode.attributes[\"class\"] = node.attributes[\"class\"] || {type: \"string\", value: \"\"};\n\tif(node.attributes[\"class\"].type === \"string\") {\n\t\tif(node.attributes[\"class\"].value !== \"\") {\n\t\t\tclasses = node.attributes[\"class\"].value.split(\" \");\n\t\t}\n\t\tif(classString !== \"\") {\n\t\t\t$tw.utils.pushTop(classes,classString.split(\" \"));\n\t\t}\n\t\tnode.attributes[\"class\"].value = classes.join(\" \");\n\t}\n};\n\nexports.addStyleToParseTreeNode = function(node,name,value) {\n\t\tnode.attributes = node.attributes || {};\n\t\tnode.attributes[\"style\"] = node.attributes[\"style\"] || {type: \"string\", value: \"\"};\n\t\tif(node.attributes[\"style\"].type === \"string\") {\n\t\t\tnode.attributes[\"style\"].value += name + \":\" + value + \";\";\n\t\t}\n};\n\nexports.findParseTreeNode = function(nodeArray,search) {\n\tfor(var t=0; t<nodeArray.length; t++) {\n\t\tif(nodeArray[t].type === search.type && nodeArray[t].tag === search.tag) {\n\t\t\treturn nodeArray[t];\n\t\t}\n\t}\n\treturn undefined;\n};\n\n})();\n",
"title": "$:/core/modules/utils/parsetree.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/performance.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/performance.js\ntype: application/javascript\nmodule-type: global\n\nPerformance measurement.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nfunction Performance(enabled) {\n\tthis.enabled = !!enabled;\n\tthis.measures = {}; // Hashmap of current values of measurements\n\tthis.logger = new $tw.utils.Logger(\"performance\");\n}\n\n/*\nWrap performance reporting around a top level function\n*/\nPerformance.prototype.report = function(name,fn) {\n\tvar self = this;\n\tif(this.enabled) {\n\t\treturn function() {\n\t\t\tself.measures = {};\n\t\t\tvar startTime = $tw.utils.timer(),\n\t\t\t\tresult = fn.apply(this,arguments);\n\t\t\tself.logger.log(name + \": \" + $tw.utils.timer(startTime) + \"ms\");\n\t\t\tfor(var m in self.measures) {\n\t\t\t\tself.logger.log(\"+\" + m + \": \" + self.measures[m] + \"ms\");\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t} else {\n\t\treturn fn;\n\t}\n};\n\n/*\nWrap performance measurements around a subfunction\n*/\nPerformance.prototype.measure = function(name,fn) {\n\tvar self = this;\n\tif(this.enabled) {\n\t\treturn function() {\n\t\t\tvar startTime = $tw.utils.timer(),\n\t\t\t\tresult = fn.apply(this,arguments),\n\t\t\t\tvalue = self.measures[name] || 0;\n\t\t\tself.measures[name] = value + $tw.utils.timer(startTime);\n\t\t\treturn result;\n\t\t};\n\t} else {\n\t\treturn fn;\n\t}\n};\n\nexports.Performance = Performance;\n\n})();\n",
"title": "$:/core/modules/utils/performance.js",
"type": "application/javascript",
"module-type": "global"
},
"$:/core/modules/utils/pluginmaker.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/pluginmaker.js\ntype: application/javascript\nmodule-type: utils\n\nA quick and dirty way to pack up plugins within the browser.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nRepack a plugin, and then delete any non-shadow payload tiddlers\n*/\nexports.repackPlugin = function(title,additionalTiddlers,excludeTiddlers) {\n\tadditionalTiddlers = additionalTiddlers || [];\n\texcludeTiddlers = excludeTiddlers || [];\n\t// Get the plugin tiddler\n\tvar pluginTiddler = $tw.wiki.getTiddler(title);\n\tif(!pluginTiddler) {\n\t\tthrow \"No such tiddler as \" + title;\n\t}\n\t// Extract the JSON\n\ttry {\n\t\tvar jsonPluginTiddler = JSON.parse(pluginTiddler.fields.text);\n\t} catch(e) {\n\t\tthrow \"Cannot parse plugin tiddler \" + title + \"\\nError: \" + e;\n\t}\n\t// Get the list of tiddlers\n\tvar tiddlers = Object.keys(jsonPluginTiddler.tiddlers);\n\t// Add the additional tiddlers\n\t$tw.utils.pushTop(tiddlers,additionalTiddlers)\n\t// Remove any excluded tiddlers\n\tfor(var t=tiddlers.length-1; t>=0; t--) {\n\t\tif(excludeTiddlers.indexOf(tiddlers[t]) !== -1) {\n\t\t\ttiddlers.splice(t,1);\n\t\t}\n\t}\n\t// Pack up the tiddlers into a block of JSON\n\tvar plugins = {};\n\t$tw.utils.each(tiddlers,function(title) {\n\t\tvar tiddler = $tw.wiki.getTiddler(title),\n\t\t\tfields = {};\n\t\t$tw.utils.each(tiddler.fields,function (value,name) {\n\t\t\tfields[name] = tiddler.getFieldString(name);\n\t\t});\n\t\tplugins[title] = fields;\n\t});\n\t// Retrieve and bump the version number\n\tvar pluginVersion = $tw.utils.parseVersion(pluginTiddler.getFieldString(\"version\") || \"0.0.0\") || {\n\t\t\tmajor: \"0\",\n\t\t\tminor: \"0\",\n\t\t\tpatch: \"0\"\n\t\t};\n\tpluginVersion.patch++;\n\tvar version = pluginVersion.major + \".\" + pluginVersion.minor + \".\" + pluginVersion.patch;\n\tif(pluginVersion.prerelease) {\n\t\tversion += \"-\" + pluginVersion.prerelease;\n\t}\n\tif(pluginVersion.build) {\n\t\tversion += \"+\" + pluginVersion.build;\n\t}\n\t// Save the tiddler\n\t$tw.wiki.addTiddler(new $tw.Tiddler(pluginTiddler,{text: JSON.stringify({tiddlers: plugins},null,4), version: version}));\n\t// Delete any non-shadow constituent tiddlers\n\t$tw.utils.each(tiddlers,function(title) {\n\t\tif($tw.wiki.tiddlerExists(title)) {\n\t\t\t$tw.wiki.deleteTiddler(title);\n\t\t}\n\t});\n\t// Trigger an autosave\n\t$tw.rootWidget.dispatchEvent({type: \"tw-auto-save-wiki\"});\n\t// Return a heartwarming confirmation\n\treturn \"Plugin \" + title + \" successfully saved\";\n}\n\n})();\n",
"title": "$:/core/modules/utils/pluginmaker.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/utils/utils.js": {
"text": "/*\\\ntitle: $:/core/modules/utils/utils.js\ntype: application/javascript\nmodule-type: utils\n\nVarious static utility functions.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nTrim whitespace from the start and end of a string\nThanks to Steven Levithan, http://blog.stevenlevithan.com/archives/faster-trim-javascript\n*/\nexports.trim = function(str) {\n\tif(typeof str === \"string\") {\n\t\treturn str.replace(/^\\s\\s*/, '').replace(/\\s\\s*$/, '');\n\t} else {\n\t\treturn str;\n\t}\n};\n\n/*\nReturn the number of keys in an object\n*/\nexports.count = function(object) {\n\tvar s = 0;\n\t$tw.utils.each(object,function() {s++;});\n\treturn s;\n};\n\n/*\nCheck if an array is equal by value and by reference.\n*/\nexports.isArrayEqual = function(array1,array2) {\n\tif(array1 === array2) {\n\t\treturn true;\n\t}\n\tarray1 = array1 || [];\n\tarray2 = array2 || [];\n\tif(array1.length !== array2.length) {\n\t\treturn false;\n\t}\n\treturn array1.every(function(value,index) {\n\t\treturn value === array2[index];\n\t});\n};\n\n/*\nPush entries onto an array, removing them first if they already exist in the array\n\tarray: array to modify (assumed to be free of duplicates)\n\tvalue: a single value to push or an array of values to push\n*/\nexports.pushTop = function(array,value) {\n\tvar t,p;\n\tif($tw.utils.isArray(value)) {\n\t\t// Remove any array entries that are duplicated in the new values\n\t\tif(value.length !== 0) {\n\t\t\tif(array.length !== 0) {\n\t\t\t\tif(value.length < array.length) {\n\t\t\t\t\tfor(t=0; t<value.length; t++) {\n\t\t\t\t\t\tp = array.indexOf(value[t]);\n\t\t\t\t\t\tif(p !== -1) {\n\t\t\t\t\t\t\tarray.splice(p,1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor(t=array.length-1; t>=0; t--) {\n\t\t\t\t\t\tp = value.indexOf(array[t]);\n\t\t\t\t\t\tif(p !== -1) {\n\t\t\t\t\t\t\tarray.splice(t,1);\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\t// Push the values on top of the main array\n\t\t\tarray.push.apply(array,value);\n\t\t}\n\t} else {\n\t\tp = array.indexOf(value);\n\t\tif(p !== -1) {\n\t\t\tarray.splice(p,1);\n\t\t}\n\t\tarray.push(value);\n\t}\n};\n\n/*\nRemove entries from an array\n\tarray: array to modify\n\tvalue: a single value to remove, or an array of values to remove\n*/\nexports.removeArrayEntries = function(array,value) {\n\tvar t,p;\n\tif($tw.utils.isArray(value)) {\n\t\tfor(t=0; t<value.length; t++) {\n\t\t\tp = array.indexOf(value[t]);\n\t\t\tif(p !== -1) {\n\t\t\t\tarray.splice(p,1);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tp = array.indexOf(value);\n\t\tif(p !== -1) {\n\t\t\tarray.splice(p,1);\n\t\t}\n\t}\n};\n\n/*\nCheck whether any members of a hashmap are present in another hashmap\n*/\nexports.checkDependencies = function(dependencies,changes) {\n\tvar hit = false;\n\t$tw.utils.each(changes,function(change,title) {\n\t\tif($tw.utils.hop(dependencies,title)) {\n\t\t\thit = true;\n\t\t}\n\t});\n\treturn hit;\n};\n\nexports.extend = function(object /* [, src] */) {\n\t$tw.utils.each(Array.prototype.slice.call(arguments, 1), function(source) {\n\t\tif(source) {\n\t\t\tfor(var property in source) {\n\t\t\t\tobject[property] = source[property];\n\t\t\t}\n\t\t}\n\t});\n\treturn object;\n};\n\nexports.deepCopy = function(object) {\n\tvar result,t;\n\tif($tw.utils.isArray(object)) {\n\t\t// Copy arrays\n\t\tresult = object.slice(0);\n\t} else if(typeof object === \"object\") {\n\t\tresult = {};\n\t\tfor(t in object) {\n\t\t\tif(object[t] !== undefined) {\n\t\t\t\tresult[t] = $tw.utils.deepCopy(object[t]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tresult = object;\n\t}\n\treturn result;\n};\n\nexports.extendDeepCopy = function(object,extendedProperties) {\n\tvar result = $tw.utils.deepCopy(object),t;\n\tfor(t in extendedProperties) {\n\t\tif(extendedProperties[t] !== undefined) {\n\t\t\tresult[t] = $tw.utils.deepCopy(extendedProperties[t]);\n\t\t}\n\t}\n\treturn result;\n};\n\nexports.slowInSlowOut = function(t) {\n\treturn (1 - ((Math.cos(t * Math.PI) + 1) / 2));\n};\n\nexports.formatDateString = function (date,template) {\n\tvar t = template.replace(/0hh12/g,$tw.utils.pad($tw.utils.getHours12(date)));\n\tt = t.replace(/hh12/g,$tw.utils.getHours12(date));\n\tt = t.replace(/0hh/g,$tw.utils.pad(date.getHours()));\n\tt = t.replace(/hh/g,date.getHours());\n\tt = t.replace(/mmm/g,$tw.config.dateFormats.shortMonths[date.getMonth()]);\n\tt = t.replace(/0mm/g,$tw.utils.pad(date.getMinutes()));\n\tt = t.replace(/mm/g,date.getMinutes());\n\tt = t.replace(/0ss/g,$tw.utils.pad(date.getSeconds()));\n\tt = t.replace(/ss/g,date.getSeconds());\n\tt = t.replace(/[ap]m/g,$tw.utils.getAmPm(date).toLowerCase());\n\tt = t.replace(/[AP]M/g,$tw.utils.getAmPm(date).toUpperCase());\n\tt = t.replace(/wYYYY/g,$tw.utils.getYearForWeekNo(date));\n\tt = t.replace(/wYY/g,$tw.utils.pad($tw.utils.getYearForWeekNo(date)-2000));\n\tt = t.replace(/YYYY/g,date.getFullYear());\n\tt = t.replace(/YY/g,$tw.utils.pad(date.getFullYear()-2000));\n\tt = t.replace(/MMM/g,$tw.config.dateFormats.months[date.getMonth()]);\n\tt = t.replace(/0MM/g,$tw.utils.pad(date.getMonth()+1));\n\tt = t.replace(/MM/g,date.getMonth()+1);\n\tt = t.replace(/0WW/g,$tw.utils.pad($tw.utils.getWeek(date)));\n\tt = t.replace(/WW/g,$tw.utils.getWeek(date));\n\tt = t.replace(/DDD/g,$tw.config.dateFormats.days[date.getDay()]);\n\tt = t.replace(/ddd/g,$tw.config.dateFormats.shortDays[date.getDay()]);\n\tt = t.replace(/0DD/g,$tw.utils.pad(date.getDate()));\n\tt = t.replace(/DDth/g,date.getDate()+$tw.utils.getDaySuffix(date));\n\tt = t.replace(/DD/g,date.getDate());\n\tvar tz = date.getTimezoneOffset();\n\tvar atz = Math.abs(tz);\n\tt = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + $tw.utils.pad(Math.floor(atz / 60)) + ':' + $tw.utils.pad(atz % 60));\n\tt = t.replace(/\\\\(.)/g,\"$1\");\n\treturn t;\n};\n\nexports.getAmPm = function(date) {\n\treturn date.getHours() >= 12 ? $tw.config.dateFormats.pm : $tw.config.dateFormats.am;\n};\n\nexports.getDaySuffix = function(date) {\n\treturn $tw.config.dateFormats.daySuffixes[date.getDate()-1];\n};\n\nexports.getWeek = function(date) {\n\tvar dt = new Date(date.getTime());\n\tvar d = dt.getDay();\n\tif(d === 0) d=7;// JavaScript Sun=0, ISO Sun=7\n\tdt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo\n\tvar n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);\n\treturn Math.floor(n/7)+1;\n};\n\nexports.getYearForWeekNo = function(date) {\n\tvar dt = new Date(date.getTime());\n\tvar d = dt.getDay();\n\tif(d === 0) d=7;// JavaScript Sun=0, ISO Sun=7\n\tdt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week\n\treturn dt.getFullYear();\n};\n\nexports.getHours12 = function(date) {\n\tvar h = date.getHours();\n\treturn h > 12 ? h-12 : ( h > 0 ? h : 12 );\n};\n\n/*\nConvert a date delta in milliseconds into a string representation of \"23 seconds ago\", \"27 minutes ago\" etc.\n\tdelta: delta in milliseconds\nReturns an object with these members:\n\tdescription: string describing the delta period\n\tupdatePeriod: time in millisecond until the string will be inaccurate\n*/\nexports.getRelativeDate = function(delta) {\n\tvar futurep = false;\n\tif(delta < 0) {\n\t\tdelta = -1 * delta;\n\t\tfuturep = true;\n\t}\n\tvar units = [\n\t\t{name: \"Years\", duration: 365 * 24 * 60 * 60 * 1000},\n\t\t{name: \"Months\", duration: (365/12) * 24 * 60 * 60 * 1000},\n\t\t{name: \"Days\", duration: 24 * 60 * 60 * 1000},\n\t\t{name: \"Hours\", duration: 60 * 60 * 1000},\n\t\t{name: \"Minutes\", duration: 60 * 1000},\n\t\t{name: \"Seconds\", duration: 1000}\n\t];\n\tfor(var t=0; t<units.length; t++) {\n\t\tvar result = Math.floor(delta / units[t].duration);\n\t\tif(result >= 2) {\n\t\t\treturn {\n\t\t\t\tdelta: delta,\n\t\t\t\tdescription: $tw.language.getString(\n\t\t\t\t\t\"RelativeDate/\" + (futurep ? \"Future\" : \"Past\") + \"/\" + units[t].name,\n\t\t\t\t\t{variables:\n\t\t\t\t\t\t{period: result.toString()}\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t\tupdatePeriod: units[t].duration\n\t\t\t};\n\t\t}\n\t}\n\treturn {\n\t\tdelta: delta,\n\t\tdescription: $tw.language.getString(\n\t\t\t\"RelativeDate/\" + (futurep ? \"Future\" : \"Past\") + \"/Second\",\n\t\t\t{variables:\n\t\t\t\t{period: \"1\"}\n\t\t\t}\n\t\t),\n\t\tupdatePeriod: 1000\n\t};\n};\n\n// Convert & to \"&\", < to \"<\", > to \">\" and \" to \""\"\nexports.htmlEncode = function(s) {\n\tif(s) {\n\t\treturn s.toString().replace(/&/mg,\"&\").replace(/</mg,\"<\").replace(/>/mg,\">\").replace(/\\\"/mg,\""\");\n\t} else {\n\t\treturn \"\";\n\t}\n};\n\n// Converts all HTML entities to their character equivalents\nexports.entityDecode = function(s) {\n\tvar e = s.substr(1,s.length-2); // Strip the & and the ;\n\tif(e.charAt(0) === \"#\") {\n\t\tif(e.charAt(1) === \"x\" || e.charAt(1) === \"X\") {\n\t\t\treturn String.fromCharCode(parseInt(e.substr(2),16));\t\n\t\t} else {\n\t\t\treturn String.fromCharCode(parseInt(e.substr(1),10));\n\t\t}\n\t} else {\n\t\tvar c = $tw.config.htmlEntities[e];\n\t\tif(c) {\n\t\t\treturn String.fromCharCode(c);\n\t\t} else {\n\t\t\treturn s; // Couldn't convert it as an entity, just return it raw\n\t\t}\n\t}\n};\n\nexports.unescapeLineBreaks = function(s) {\n\treturn s.replace(/\\\\n/mg,\"\\n\").replace(/\\\\b/mg,\" \").replace(/\\\\s/mg,\"\\\\\").replace(/\\r/mg,\"\");\n};\n\n/*\n * Returns an escape sequence for given character. Uses \\x for characters <=\n * 0xFF to save space, \\u for the rest.\n *\n * The code needs to be in sync with th code template in the compilation\n * function for \"action\" nodes.\n */\n// Copied from peg.js, thanks to David Majda\nexports.escape = function(ch) {\n\tvar charCode = ch.charCodeAt(0);\n\tif(charCode <= 0xFF) {\n\t\treturn '\\\\x' + $tw.utils.pad(charCode.toString(16).toUpperCase());\n\t} else {\n\t\treturn '\\\\u' + $tw.utils.pad(charCode.toString(16).toUpperCase(),4);\n\t}\n};\n\n// Turns a string into a legal JavaScript string\n// Copied from peg.js, thanks to David Majda\nexports.stringify = function(s) {\n\t/*\n\t* ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string\n\t* literal except for the closing quote character, backslash, carriage return,\n\t* line separator, paragraph separator, and line feed. Any character may\n\t* appear in the form of an escape sequence.\n\t*\n\t* For portability, we also escape escape all non-ASCII characters.\n\t*/\n\treturn s\n\t\t.replace(/\\\\/g, '\\\\\\\\') // backslash\n\t\t.replace(/\"/g, '\\\\\"') // double quote character\n\t\t.replace(/'/g, \"\\\\'\") // single quote character\n\t\t.replace(/\\r/g, '\\\\r') // carriage return\n\t\t.replace(/\\n/g, '\\\\n') // line feed\n\t\t.replace(/[\\x80-\\uFFFF]/g, exports.escape); // non-ASCII characters\n};\n\n/*\nEscape the RegExp special characters with a preceding backslash\n*/\nexports.escapeRegExp = function(s) {\n return s.replace(/[\\-\\/\\\\\\^\\$\\*\\+\\?\\.\\(\\)\\|\\[\\]\\{\\}]/g, '\\\\$&');\n};\n\nexports.nextTick = function(fn) {\n/*global window: false */\n\tif(typeof window !== \"undefined\") {\n\t\t// Apparently it would be faster to use postMessage - http://dbaron.org/log/20100309-faster-timeouts\n\t\twindow.setTimeout(fn,4);\n\t} else {\n\t\tprocess.nextTick(fn);\n\t}\n};\n\n/*\nConvert a hyphenated CSS property name into a camel case one\n*/\nexports.unHyphenateCss = function(propName) {\n\treturn propName.replace(/-([a-z])/gi, function(match0,match1) {\n\t\treturn match1.toUpperCase();\n\t});\n};\n\n/*\nConvert a camelcase CSS property name into a dashed one (\"backgroundColor\" --> \"background-color\")\n*/\nexports.hyphenateCss = function(propName) {\n\treturn propName.replace(/([A-Z])/g, function(match0,match1) {\n\t\treturn \"-\" + match1.toLowerCase();\n\t});\n};\n\n/*\nParse a text reference of one of these forms:\n* title\n* !!field\n* title!!field\n* title##index\n* etc\nReturns an object with the following fields, all optional:\n* title: tiddler title\n* field: tiddler field name\n* index: JSON property index\n*/\nexports.parseTextReference = function(textRef) {\n\t// Separate out the title, field name and/or JSON indices\n\tvar reTextRef = /^\\s*([^!#]+)?(?:(?:!!([^\\s]+))|(?:##(.+)))?\\s*/mg,\n\t\tmatch = reTextRef.exec(textRef);\n\tif(match && reTextRef.lastIndex === textRef.length) {\n\t\t// Return the parts\n\t\treturn {\n\t\t\ttitle: match[1],\n\t\t\tfield: match[2],\n\t\t\tindex: match[3]\n\t\t};\n\t} else {\n\t\t// If we couldn't parse it (eg it started with a)\n\t\treturn {\n\t\t\ttitle: textRef\n\t\t};\n\t}\n};\n\n/*\nChecks whether a string is a valid fieldname\n*/\nexports.isValidFieldName = function(name) {\n\tif(!name || typeof name !== \"string\") {\n\t\treturn false;\n\t}\n\tname = name.toLowerCase().trim();\n\tvar fieldValidatorRegEx = /^[a-z0-9\\-\\._]+$/mg;\n\treturn fieldValidatorRegEx.test(name);\n};\n\n/*\nExtract the version number from the meta tag or from the boot file\n*/\n\nif($tw.browser) {\n\n// Browser version\nexports.extractVersionInfo = function() {\n\tvar metatags = document.getElementsByTagName(\"meta\");\n\tfor(var t=0; t<metatags.length; t++) {\n\t\tvar m = metatags[t];\n\t\tif(m.name === \"tiddlywiki-version\") {\n\t\t\treturn m.content;\n\t\t}\n\t}\n\treturn null;\n};\n\n} else {\n\n// Server version\nexports.extractVersionInfo = function() {\n\treturn $tw.packageInfo.version;\n};\n\n}\n\n/*\nGet the animation duration in ms\n*/\nexports.getAnimationDuration = function() {\n\treturn parseInt($tw.wiki.getTiddlerText(\"$:/config/AnimationDuration\",\"400\"),10);\n};\n\n/*\nHash a string to a number\nDerived from http://stackoverflow.com/a/15710692\n*/\nexports.hashString = function(str) {\n\treturn str.split(\"\").reduce(function(a,b) {\n\t\ta = ((a << 5) - a) + b.charCodeAt(0);\n\t\treturn a & a;\n\t},0);\n};\n\n/*\nDecode a base64 string\n*/\nexports.base64Decode = function(string64) {\n\tif($tw.browser) {\n\t\t// TODO\n\t\tthrow \"$tw.utils.base64Decode() doesn't work in the browser\";\n\t} else {\n\t\treturn (new Buffer(string64,\"base64\")).toString();\n\t}\n};\n\n/*\nConvert a hashmap into a tiddler dictionary format sequence of name:value pairs\n*/\nexports.makeTiddlerDictionary = function(data) {\n\tvar output = [];\n\tfor(var name in data) {\n\t\toutput.push(name + \": \" + data[name]);\n\t}\n\treturn output.join(\"\\n\");\n};\n\n/*\nHigh resolution microsecond timer for profiling\n*/\nexports.timer = function(base) {\n\tvar m;\n\tif($tw.node) {\n\t\tvar r = process.hrtime();\t\t\n\t\tm = r[0] * 1e3 + (r[1] / 1e6);\n\t} else if(window.performance) {\n\t\tm = performance.now();\n\t} else {\n\t\tm = Date.now();\n\t}\n\tif(typeof base !== \"undefined\") {\n\t\tm = m - base;\n\t}\n\treturn m;\n};\n\n})();\n",
"title": "$:/core/modules/utils/utils.js",
"type": "application/javascript",
"module-type": "utils"
},
"$:/core/modules/widgets/browse.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/browse.js\ntype: application/javascript\nmodule-type: widget\n\nBrowse widget for browsing for files to import\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar BrowseWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nBrowseWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nBrowseWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Remember parent\n\tthis.parentDomNode = parent;\n\t// Compute attributes and execute state\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create element\n\tvar domNode = this.document.createElement(\"input\");\n\tdomNode.setAttribute(\"type\",\"file\");\n\tdomNode.setAttribute(\"multiple\",\"multiple\");\n\t// Add a click event handler\n\tdomNode.addEventListener(\"change\",function (event) {\n\t\tself.wiki.readFiles(event.target.files,function(tiddlerFieldsArray) {\n\t\t\tself.dispatchEvent({type: \"tw-import-tiddlers\", param: JSON.stringify(tiddlerFieldsArray)});\n\t\t});\n\t\treturn false;\n\t},false);\n\t// Insert element\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nBrowseWidget.prototype.execute = function() {\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nBrowseWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nexports.browse = BrowseWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/browse.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/button.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/button.js\ntype: application/javascript\nmodule-type: widget\n\nButton widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar ButtonWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nButtonWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nButtonWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Remember parent\n\tthis.parentDomNode = parent;\n\t// Compute attributes and execute state\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create element\n\tvar domNode = this.document.createElement(\"button\");\n\t// Assign classes\n\tvar classes = this[\"class\"].split(\" \") || [];\n\tif(this.selectedClass) {\n\t\tif(this.set && this.setTo && this.isSelected()) {\n\t\t\t$tw.utils.pushTop(classes,this.selectedClass.split(\" \"));\n\t\t}\n\t\tif(this.popup && this.isPoppedUp()) {\n\t\t\t$tw.utils.pushTop(classes,this.selectedClass.split(\" \"));\n\t\t}\n\t}\n\tdomNode.className = classes.join(\" \");\n\t// Assign classes\n\tif(this.style) {\n\t\tdomNode.setAttribute(\"style\",this.style);\n\t}\n\t// Add a click event handler\n\tdomNode.addEventListener(\"click\",function (event) {\n\t\tvar handled = false;\n\t\tif(self.to) {\n\t\t\tself.navigateTo(event);\n\t\t\thandled = true;\n\t\t}\n\t\tif(self.message) {\n\t\t\tself.dispatchMessage(event);\n\t\t\thandled = true;\n\t\t}\n\t\tif(self.popup) {\n\t\t\tself.triggerPopup(event);\n\t\t\thandled = true;\n\t\t}\n\t\tif(self.set) {\n\t\t\tself.setTiddler();\n\t\t\thandled = true;\n\t\t}\n\t\tif(handled) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t}\n\t\treturn handled;\n\t},false);\n\t// Insert element\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\nButtonWidget.prototype.isSelected = function() {\n\tvar tiddler = this.wiki.getTiddler(this.set);\n\treturn tiddler ? tiddler.fields.text === this.setTo : this.defaultSetValue === this.setTo;\n};\n\nButtonWidget.prototype.isPoppedUp = function() {\n\tvar tiddler = this.wiki.getTiddler(this.popup);\n\tvar result = tiddler && tiddler.fields.text ? $tw.popup.readPopupState(this.popup,tiddler.fields.text) : false;\n\treturn result;\n};\n\nButtonWidget.prototype.navigateTo = function(event) {\n\tvar bounds = this.domNodes[0].getBoundingClientRect();\n\tthis.dispatchEvent({\n\t\ttype: \"tw-navigate\",\n\t\tnavigateTo: this.to,\n\t\tnavigateFromTitle: this.getVariable(\"storyTiddler\"),\n\t\tnavigateFromNode: this,\n\t\tnavigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height\n\t\t},\n\t\tnavigateSuppressNavigation: event.metaKey || event.ctrlKey || (event.button === 1)\n\t});\n};\n\nButtonWidget.prototype.dispatchMessage = function(event) {\n\tthis.dispatchEvent({type: this.message, param: this.param, tiddlerTitle: this.getVariable(\"currentTiddler\")});\n};\n\nButtonWidget.prototype.triggerPopup = function(event) {\n\t$tw.popup.triggerPopup({\n\t\tdomNode: this.domNodes[0],\n\t\ttitle: this.popup,\n\t\twiki: this.wiki\n\t});\n};\n\nButtonWidget.prototype.setTiddler = function() {\n\tthis.wiki.setTextReference(this.set,this.setTo,this.getVariable(\"currentTiddler\"));\n};\n\n/*\nCompute the internal state of the widget\n*/\nButtonWidget.prototype.execute = function() {\n\t// Get attributes\n\tthis.to = this.getAttribute(\"to\");\n\tthis.message = this.getAttribute(\"message\");\n\tthis.param = this.getAttribute(\"param\");\n\tthis.set = this.getAttribute(\"set\");\n\tthis.setTo = this.getAttribute(\"setTo\");\n\tthis.popup = this.getAttribute(\"popup\");\n\tthis.hover = this.getAttribute(\"hover\");\n\tthis[\"class\"] = this.getAttribute(\"class\",\"\");\n\tthis.style = this.getAttribute(\"style\");\n\tthis.selectedClass = this.getAttribute(\"selectedClass\");\n\tthis.defaultSetValue = this.getAttribute(\"default\");\n\t// Make child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nButtonWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes[\"class\"] || changedAttributes.selectedClass || changedAttributes.style || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup])) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t}\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.button = ButtonWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/button.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/checkbox.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/checkbox.js\ntype: application/javascript\nmodule-type: widget\n\nCheckbox widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar CheckboxWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nCheckboxWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nCheckboxWidget.prototype.render = function(parent,nextSibling) {\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Create our elements\n\tthis.labelDomNode = this.document.createElement(\"label\");\n\tthis.inputDomNode = this.document.createElement(\"input\");\n\tthis.inputDomNode.setAttribute(\"type\",\"checkbox\");\n\tif(this.getValue()) {\n\t\tthis.inputDomNode.setAttribute(\"checked\",\"true\");\n\t}\n\tthis.labelDomNode.appendChild(this.inputDomNode);\n\tthis.spanDomNode = this.document.createElement(\"span\");\n\tthis.labelDomNode.appendChild(this.spanDomNode);\n\t// Add a click event handler\n\t$tw.utils.addEventListeners(this.inputDomNode,[\n\t\t{name: \"change\", handlerObject: this, handlerMethod: \"handleChangeEvent\"}\n\t]);\n\t// Insert the label into the DOM and render any children\n\tparent.insertBefore(this.labelDomNode,nextSibling);\n\tthis.renderChildren(this.spanDomNode,null);\n\tthis.domNodes.push(this.labelDomNode);\n};\n\nCheckboxWidget.prototype.getValue = function() {\n\tvar tiddler = this.wiki.getTiddler(this.checkboxTitle);\n\treturn tiddler ? tiddler.hasTag(this.checkboxTag) : false;\n};\n\nCheckboxWidget.prototype.handleChangeEvent = function(event) {\n\tvar checked = this.inputDomNode.checked,\n\t\ttiddler = this.wiki.getTiddler(this.checkboxTitle);\n\tif(tiddler && tiddler.hasTag(this.checkboxTag) !== checked) {\n\t\tvar newTags = (tiddler.fields.tags || []).slice(0),\n\t\t\tpos = newTags.indexOf(this.checkboxTag);\n\t\tif(pos !== -1) {\n\t\t\tnewTags.splice(pos,1);\n\t\t}\n\t\tif(checked) {\n\t\t\tnewTags.push(this.checkboxTag);\n\t\t}\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,{tags: newTags},this.wiki.getModificationFields()));\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nCheckboxWidget.prototype.execute = function() {\n\t// Get the parameters from the attributes\n\tthis.checkboxTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.checkboxTag = this.getAttribute(\"tag\");\n\t// Make the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nCheckboxWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.tag || changedAttributes[\"class\"]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\tvar refreshed = false;\n\t\tif(changedTiddlers[this.checkboxTitle]) {\n\t\t\tthis.inputDomNode.checked = this.getValue();\n\t\t\trefreshed = true;\n\t\t}\n\t\treturn this.refreshChildren(changedTiddlers) || refreshed;\n\t}\n};\n\nexports.checkbox = CheckboxWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/checkbox.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/codeblock.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/codeblock.js\ntype: application/javascript\nmodule-type: widget\n\nCode block node widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar CodeBlockWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nCodeBlockWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nCodeBlockWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar codeNode = this.document.createElement(\"code\"),\n\t\tdomNode = this.document.createElement(\"pre\");\n\tcodeNode.appendChild(this.document.createTextNode(this.getAttribute(\"code\")));\n\tdomNode.appendChild(codeNode);\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.domNodes.push(domNode);\n\tif(this.postRender) {\n\t\tthis.postRender();\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nCodeBlockWidget.prototype.execute = function() {\n\tthis.language = this.getAttribute(\"language\");\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nCodeBlockWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nexports.codeblock = CodeBlockWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/codeblock.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/count.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/count.js\ntype: application/javascript\nmodule-type: widget\n\nCount widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar CountWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nCountWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nCountWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar textNode = this.document.createTextNode(this.currentCount);\n\tparent.insertBefore(textNode,nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nCountWidget.prototype.execute = function() {\n\t// Get parameters from our attributes\n\tthis.filter = this.getAttribute(\"filter\");\n\t// Execute the filter\n\tif(this.filter) {\n\t\tthis.currentCount = this.wiki.filterTiddlers(this.filter,this).length;\n\t} else {\n\t\tthis.currentCount = undefined;\n\t}\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nCountWidget.prototype.refresh = function(changedTiddlers) {\n\t// Re-execute the filter to get the count\n\tthis.computeAttributes();\n\tvar oldCount = this.currentCount;\n\tthis.execute();\n\tif(this.currentCount !== oldCount) {\n\t\t// Regenerate and rerender the widget and replace the existing DOM node\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn false;\n\t}\n\n};\n\nexports.count = CountWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/count.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/dropzone.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/dropzone.js\ntype: application/javascript\nmodule-type: widget\n\nDropzone widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar DropZoneWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nDropZoneWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nDropZoneWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Remember parent\n\tthis.parentDomNode = parent;\n\t// Compute attributes and execute state\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create element\n\tvar domNode = this.document.createElement(\"div\");\n\tdomNode.className = \"tw-dropzone\";\n\t// Add event handlers\n\t$tw.utils.addEventListeners(domNode,[\n\t\t{name: \"dragenter\", handlerObject: this, handlerMethod: \"handleDragEnterEvent\"},\n\t\t{name: \"dragover\", handlerObject: this, handlerMethod: \"handleDragOverEvent\"},\n\t\t{name: \"dragleave\", handlerObject: this, handlerMethod: \"handleDragLeaveEvent\"},\n\t\t{name: \"drop\", handlerObject: this, handlerMethod: \"handleDropEvent\"},\n\t\t{name: \"paste\", handlerObject: this, handlerMethod: \"handlePasteEvent\"}\n\t]);\n\tdomNode.addEventListener(\"click\",function (event) {\n\t},false);\n\t// Insert element\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\nDropZoneWidget.prototype.handleDragEnterEvent = function(event) {\n\t// We count enter/leave events\n\tthis.dragEnterCount = (this.dragEnterCount || 0) + 1;\n\t// If we're entering for the first time we need to apply highlighting\n\tif(this.dragEnterCount === 1) {\n\t\t$tw.utils.addClass(this.domNodes[0],\"tw-dragover\");\n\t}\n\t// Tell the browser that we're ready to handle the drop\n\tevent.preventDefault();\n\t// Tell the browser not to ripple the drag up to any parent drop handlers\n\tevent.stopPropagation();\n};\n\nDropZoneWidget.prototype.handleDragOverEvent = function(event) {\n\t// Check for being over a TEXTAREA or INPUT\n\tif([\"TEXTAREA\",\"INPUT\"].indexOf(event.target.tagName) !== -1) {\n\t\treturn false;\n\t}\n\t// Tell the browser that we're still interested in the drop\n\tevent.preventDefault();\n\tevent.dataTransfer.dropEffect = \"copy\"; // Explicitly show this is a copy\n};\n\nDropZoneWidget.prototype.handleDragLeaveEvent = function(event) {\n\t// Reduce the enter count\n\tthis.dragEnterCount = (this.dragEnterCount || 0) - 1;\n\t// Remove highlighting if we're leaving externally\n\tif(this.dragEnterCount <= 0) {\n\t\t$tw.utils.removeClass(this.domNodes[0],\"tw-dragover\");\n\t}\n};\n\nDropZoneWidget.prototype.handleDropEvent = function(event) {\n\t// Check for being over a TEXTAREA or INPUT\n\tif([\"TEXTAREA\",\"INPUT\"].indexOf(event.target.tagName) !== -1) {\n\t\treturn false;\n\t}\n\tvar self = this,\n\t\tdataTransfer = event.dataTransfer;\n\t// Reset the enter count\n\tthis.dragEnterCount = 0;\n\t// Remove highlighting\n\t$tw.utils.removeClass(this.domNodes[0],\"tw-dragover\");\n\t// Import any files in the drop\n\tvar numFiles = this.wiki.readFiles(dataTransfer.files,function(tiddlerFieldsArray) {\n\t\tself.dispatchEvent({type: \"tw-import-tiddlers\", param: JSON.stringify(tiddlerFieldsArray)});\n\t});\n\t// Try to import the various data types we understand\n\tif(numFiles === 0) {\n\t\tthis.importData(dataTransfer);\n\t}\n\t// Tell the browser that we handled the drop\n\tevent.preventDefault();\n\t// Stop the drop ripple up to any parent handlers\n\tevent.stopPropagation();\n};\n\nDropZoneWidget.prototype.importData = function(dataTransfer) {\n\t// Try each provided data type in turn\n\tfor(var t=0; t<this.importDataTypes.length; t++) {\n\t\tif(!$tw.browser.isIE || this.importDataTypes[t].IECompatible) {\n\t\t\t// Get the data\n\t\t\tvar dataType = this.importDataTypes[t];\n\t\t\t\tvar data = dataTransfer.getData(dataType.type);\n\t\t\t// Import the tiddlers in the data\n\t\t\tif(data !== \"\" && data !== null) {\n\t\t\t\tvar tiddlerFields = dataType.convertToFields(data);\n\t\t\t\tif(!tiddlerFields.title) {\n\t\t\t\t\ttiddlerFields.title = this.wiki.generateNewTitle(\"Untitled\");\n\t\t\t\t}\n\t\t\t\tthis.dispatchEvent({type: \"tw-import-tiddlers\", param: JSON.stringify([tiddlerFields])});\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n};\n\nDropZoneWidget.prototype.importDataTypes = [\n\t{type: \"text/vnd.tiddler\", IECompatible: false, convertToFields: function(data) {\n\t\treturn JSON.parse(data);\n\t}},\n\t{type: \"URL\", IECompatible: true, convertToFields: function(data) {\n\t\t// Check for tiddler data URI\n\t\tvar match = decodeURI(data).match(/^data\\:text\\/vnd\\.tiddler,(.*)/i);\n\t\tif(match) {\n\t\t\treturn JSON.parse(match[1]);\n\t\t} else {\n\t\t\treturn { // As URL string\n\t\t\t\ttext: data\n\t\t\t};\n\t\t}\n\t}},\n\t{type: \"text/x-moz-url\", IECompatible: false, convertToFields: function(data) {\n\t\t// Check for tiddler data URI\n\t\tvar match = decodeURI(data).match(/^data\\:text\\/vnd\\.tiddler,(.*)/i);\n\t\tif(match) {\n\t\t\treturn JSON.parse(match[1]);\n\t\t} else {\n\t\t\treturn { // As URL string\n\t\t\t\ttext: data\n\t\t\t};\n\t\t}\n\t}},\n\t{type: \"text/html\", IECompatible: false, convertToFields: function(data) {\n\t\treturn {\n\t\t\ttext: data\n\t\t};\n\t}},\n\t{type: \"text/plain\", IECompatible: false, convertToFields: function(data) {\n\t\treturn {\n\t\t\ttext: data\n\t\t};\n\t}},\n\t{type: \"Text\", IECompatible: true, convertToFields: function(data) {\n\t\treturn {\n\t\t\ttext: data\n\t\t};\n\t}},\n\t{type: \"text/uri-list\", IECompatible: false, convertToFields: function(data) {\n\t\treturn {\n\t\t\ttext: data\n\t\t};\n\t}}\n];\n\nDropZoneWidget.prototype.handlePasteEvent = function(event) {\n\t// Let the browser handle it if we're in a textarea or input box\n\tif([\"TEXTAREA\",\"INPUT\"].indexOf(event.target.tagName) == -1) {\n\t\tvar self = this,\n\t\t\titems = event.clipboardData.items;\n\t\t// Enumerate the clipboard items\n\t\tfor(var t = 0; t<items.length; t++) {\n\t\t\tvar item = items[t];\n\t\t\tif(item.kind === \"file\") {\n\t\t\t\t// Import any files\n\t\t\t\tthis.wiki.readFile(item.getAsFile(),function(tiddlerFieldsArray) {\n\t\t\t\t\tself.dispatchEvent({type: \"tw-import-tiddlers\", param: JSON.stringify(tiddlerFieldsArray)});\n\t\t\t\t});\n\t\t\t} else if(item.kind === \"string\") {\n\t\t\t\t// Create tiddlers from string items\n\t\t\t\titem.getAsString(function(str) {\n\t\t\t\t\tvar tiddlerFields = {\n\t\t\t\t\t\ttitle: self.wiki.generateNewTitle(\"Untitled\"),\n\t\t\t\t\t\ttext: str\n\t\t\t\t\t};\n\t\t\t\t\tself.dispatchEvent({type: \"tw-import-tiddlers\", param: JSON.stringify([tiddlerFields])});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t// Tell the browser that we've handled the paste\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nDropZoneWidget.prototype.execute = function() {\n\t// Make child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nDropZoneWidget.prototype.refresh = function(changedTiddlers) {\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.dropzone = DropZoneWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/dropzone.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/edit-binary.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/edit-binary.js\ntype: application/javascript\nmodule-type: widget\n\nEdit-binary widget; placeholder for editing binary tiddlers\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar BINARY_WARNING_MESSAGE = \"$:/core/ui/BinaryWarning\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EditBinaryWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEditBinaryWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEditBinaryWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nEditBinaryWidget.prototype.execute = function() {\n\t// Construct the child widgets\n\tthis.makeChildWidgets([{\n\t\ttype: \"transclude\",\n\t\tattributes: {\n\t\t\ttiddler: {type: \"string\", value: BINARY_WARNING_MESSAGE}\n\t\t}\n\t}]);\n};\n\n/*\nRefresh by refreshing our child widget\n*/\nEditBinaryWidget.prototype.refresh = function(changedTiddlers) {\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports[\"edit-binary\"] = EditBinaryWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/edit-binary.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/edit-bitmap.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/edit-bitmap.js\ntype: application/javascript\nmodule-type: widget\n\nEdit-bitmap widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n// Default image sizes\nvar DEFAULT_IMAGE_WIDTH = 300,\n\tDEFAULT_IMAGE_HEIGHT = 185;\n\n// Configuration tiddlers\nvar LINE_WIDTH_TITLE = \"$:/config/BitmapEditor/LineWidth\",\n\tLINE_COLOUR_TITLE = \"$:/config/BitmapEditor/Colour\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EditBitmapWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEditBitmapWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEditBitmapWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Create our element\n\tthis.canvasDomNode = $tw.utils.domMaker(\"canvas\",{\n\t\tdocument: this.document,\n\t\t\"class\":\"tw-edit-bitmapeditor\",\n\t\teventListeners: [{\n\t\t\tname: \"touchstart\", handlerObject: this, handlerMethod: \"handleTouchStartEvent\"\n\t\t},{\n\t\t\tname: \"touchmove\", handlerObject: this, handlerMethod: \"handleTouchMoveEvent\"\n\t\t},{\n\t\t\tname: \"touchend\", handlerObject: this, handlerMethod: \"handleTouchEndEvent\"\n\t\t},{\n\t\t\tname: \"mousedown\", handlerObject: this, handlerMethod: \"handleMouseDownEvent\"\n\t\t},{\n\t\t\tname: \"mousemove\", handlerObject: this, handlerMethod: \"handleMouseMoveEvent\"\n\t\t},{\n\t\t\tname: \"mouseup\", handlerObject: this, handlerMethod: \"handleMouseUpEvent\"\n\t\t}]\n\t});\n\tthis.widthDomNode = $tw.utils.domMaker(\"input\",{\n\t\tdocument: this.document,\n\t\t\"class\":\"tw-edit-bitmapeditor-width\",\n\t\teventListeners: [{\n\t\t\tname: \"change\", handlerObject: this, handlerMethod: \"handleWidthChangeEvent\"\n\t\t}]\n\t});\n\tthis.heightDomNode = $tw.utils.domMaker(\"input\",{\n\t\tdocument: this.document,\n\t\t\"class\":\"tw-edit-bitmapeditor-height\",\n\t\teventListeners: [{\n\t\t\tname: \"change\", handlerObject: this, handlerMethod: \"handleHeightChangeEvent\"\n\t\t}]\n\t});\n\t// Insert the elements into the DOM\n\tparent.insertBefore(this.canvasDomNode,nextSibling);\n\tparent.insertBefore(this.widthDomNode,nextSibling);\n\tparent.insertBefore(this.heightDomNode,nextSibling);\n\tthis.domNodes.push(this.canvasDomNode,this.widthDomNode,this.heightDomNode);\n\t// Load the image into the canvas\n\tthis.loadCanvas();\n};\n\n/*\nCompute the internal state of the widget\n*/\nEditBitmapWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.editTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n};\n\n/*\nNote that the bitmap editor intentionally doesn't try to refresh itself because it would be confusing to have the image changing spontaneously while editting it\n*/\nEditBitmapWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nEditBitmapWidget.prototype.loadCanvas = function() {\n\tvar tiddler = this.wiki.getTiddler(this.editTitle),\n\t\tcurrImage = new Image();\n\t// Set up event handlers for loading the image\n\tvar self = this;\n\tcurrImage.onload = function() {\n\t\t// Copy the image to the on-screen canvas\n\t\tself.initCanvas(self.canvasDomNode,currImage.width,currImage.height,currImage);\n\t\t// And also copy the current bitmap to the off-screen canvas\n\t\tself.currCanvas = self.document.createElement(\"canvas\");\n\t\tself.initCanvas(self.currCanvas,currImage.width,currImage.height,currImage);\n\t\t// Set the width and height input boxes\n\t\tself.updateSize();\n\t};\n\tcurrImage.onerror = function() {\n\t\t// Set the on-screen canvas size and clear it\n\t\tself.initCanvas(self.canvasDomNode,DEFAULT_IMAGE_WIDTH,DEFAULT_IMAGE_HEIGHT);\n\t\t// Set the off-screen canvas size and clear it\n\t\tself.currCanvas = self.document.createElement(\"canvas\");\n\t\tself.initCanvas(self.currCanvas,DEFAULT_IMAGE_WIDTH,DEFAULT_IMAGE_HEIGHT);\n\t\t// Set the width and height input boxes\n\t\tself.updateSize();\n\t}\n\t// Get the current bitmap into an image object\n\tcurrImage.src = \"data:\" + tiddler.fields.type + \";base64,\" + tiddler.fields.text;\n};\n\nEditBitmapWidget.prototype.initCanvas = function(canvas,width,height,image) {\n\tcanvas.width = width;\n\tcanvas.height = height;\n\tvar ctx = canvas.getContext(\"2d\");\n\tif(image) {\n\t\tctx.drawImage(image,0,0);\n\t} else {\n\t\tctx.fillStyle = \"#fff\";\n\t\tctx.fillRect(0,0,canvas.width,canvas.height);\n\t}\n}\n\n/*\n** Update the input boxes with the actual size of the canvas\n*/\nEditBitmapWidget.prototype.updateSize = function() {\n\tthis.widthDomNode.value = this.currCanvas.width;\n\tthis.heightDomNode.value = this.currCanvas.height;\n};\n\n/*\n** Change the size of the canvas, preserving the current image\n*/\nEditBitmapWidget.prototype.changeCanvasSize = function(newWidth,newHeight) {\n\t// Create and size a new canvas\n\tvar newCanvas = this.document.createElement(\"canvas\");\n\tthis.initCanvas(newCanvas,newWidth,newHeight);\n\t// Copy the old image\n\tvar ctx = newCanvas.getContext(\"2d\");\n\tctx.drawImage(this.currCanvas,0,0);\n\t// Set the new canvas as the current one\n\tthis.currCanvas = newCanvas;\n\t// Set the size of the onscreen canvas\n\tthis.canvasDomNode.width = newWidth;\n\tthis.canvasDomNode.height = newHeight;\n\t// Paint the onscreen canvas with the offscreen canvas\n\tctx = this.canvasDomNode.getContext(\"2d\");\n\tctx.drawImage(this.currCanvas,0,0);\n};\n\nEditBitmapWidget.prototype.handleWidthChangeEvent = function(event) {\n\t// Get the new width\n\tvar newWidth = parseInt(this.widthDomNode.value,10);\n\t// Update if necessary\n\tif(newWidth > 0 && newWidth !== this.currCanvas.width) {\n\t\tthis.changeCanvasSize(newWidth,this.currCanvas.height);\n\t}\n\t// Update the input controls\n\tthis.updateSize();\n};\n\nEditBitmapWidget.prototype.handleHeightChangeEvent = function(event) {\n\t// Get the new width\n\tvar newHeight = parseInt(this.heightDomNode.value,10);\n\t// Update if necessary\n\tif(newHeight > 0 && newHeight !== this.currCanvas.height) {\n\t\tthis.changeCanvasSize(this.currCanvas.width,newHeight);\n\t}\n\t// Update the input controls\n\tthis.updateSize();\n};\n\nEditBitmapWidget.prototype.handleTouchStartEvent = function(event) {\n\tthis.brushDown = true;\n\tthis.strokeStart(event.touches[0].clientX,event.touches[0].clientY);\n\tevent.preventDefault();\n\tevent.stopPropagation();\n\treturn false;\n};\n\nEditBitmapWidget.prototype.handleTouchMoveEvent = function(event) {\n\tif(this.brushDown) {\n\t\tthis.strokeMove(event.touches[0].clientX,event.touches[0].clientY);\n\t}\n\tevent.preventDefault();\n\tevent.stopPropagation();\n\treturn false;\n};\n\nEditBitmapWidget.prototype.handleTouchEndEvent = function(event) {\n\tif(this.brushDown) {\n\t\tthis.brushDown = false;\n\t\tthis.strokeEnd();\n\t}\n\tevent.preventDefault();\n\tevent.stopPropagation();\n\treturn false;\n};\n\nEditBitmapWidget.prototype.handleMouseDownEvent = function(event) {\n\tthis.strokeStart(event.clientX,event.clientY);\n\tthis.brushDown = true;\n\tevent.preventDefault();\n\tevent.stopPropagation();\n\treturn false;\n};\n\nEditBitmapWidget.prototype.handleMouseMoveEvent = function(event) {\n\tif(this.brushDown) {\n\t\tthis.strokeMove(event.clientX,event.clientY);\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\treturn false;\n\t}\n\treturn true;\n};\n\nEditBitmapWidget.prototype.handleMouseUpEvent = function(event) {\n\tif(this.brushDown) {\n\t\tthis.brushDown = false;\n\t\tthis.strokeEnd();\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\treturn false;\n\t}\n\treturn true;\n};\n\nEditBitmapWidget.prototype.adjustCoordinates = function(x,y) {\n\tvar canvasRect = this.canvasDomNode.getBoundingClientRect(),\n\t\tscale = this.canvasDomNode.width/canvasRect.width;\n\treturn {x: (x - canvasRect.left) * scale, y: (y - canvasRect.top) * scale};\n};\n\nEditBitmapWidget.prototype.strokeStart = function(x,y) {\n\t// Start off a new stroke\n\tthis.stroke = [this.adjustCoordinates(x,y)];\n};\n\nEditBitmapWidget.prototype.strokeMove = function(x,y) {\n\tvar ctx = this.canvasDomNode.getContext(\"2d\"),\n\t\tt;\n\t// Add the new position to the end of the stroke\n\tthis.stroke.push(this.adjustCoordinates(x,y));\n\t// Redraw the previous image\n\tctx.drawImage(this.currCanvas,0,0);\n\t// Render the stroke\n\tctx.strokeStyle = this.wiki.getTiddlerText(LINE_COLOUR_TITLE,\"#ff0\");\n\tctx.lineWidth = parseInt(this.wiki.getTiddlerText(LINE_WIDTH_TITLE,\"3\"),10);\n\tctx.lineCap = \"round\";\n\tctx.lineJoin = \"round\";\n\tctx.beginPath();\n\tctx.moveTo(this.stroke[0].x,this.stroke[0].y);\n\tfor(t=1; t<this.stroke.length-1; t++) {\n\t\tvar s1 = this.stroke[t],\n\t\t\ts2 = this.stroke[t-1],\n\t\t\ttx = (s1.x + s2.x)/2,\n\t\t\tty = (s1.y + s2.y)/2;\n\t\tctx.quadraticCurveTo(s2.x,s2.y,tx,ty);\n\t}\n\tctx.stroke();\n};\n\nEditBitmapWidget.prototype.strokeEnd = function() {\n\t// Copy the bitmap to the off-screen canvas\n\tvar ctx = this.currCanvas.getContext(\"2d\");\n\tctx.drawImage(this.canvasDomNode,0,0);\n\t// Save the image into the tiddler\n\tthis.saveChanges();\n};\n\nEditBitmapWidget.prototype.saveChanges = function() {\n\tvar tiddler = this.wiki.getTiddler(this.editTitle);\n\tif(tiddler) {\n\t\t// data URIs look like \"data:<type>;base64,<text>\"\n\t\tvar dataURL = this.canvasDomNode.toDataURL(tiddler.fields.type,1.0),\n\t\t\tposColon = dataURL.indexOf(\":\"),\n\t\t\tposSemiColon = dataURL.indexOf(\";\"),\n\t\t\tposComma = dataURL.indexOf(\",\"),\n\t\t\ttype = dataURL.substring(posColon+1,posSemiColon),\n\t\t\ttext = dataURL.substring(posComma+1);\n\t\tvar update = {type: type, text: text};\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,update));\n\t}\n};\n\nexports[\"edit-bitmap\"] = EditBitmapWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/edit-bitmap.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/edit-text.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/edit-text.js\ntype: application/javascript\nmodule-type: widget\n\nEdit-text widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar MIN_TEXT_AREA_HEIGHT = 100; // Minimum height of textareas in pixels\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EditTextWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEditTextWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEditTextWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Create our element\n\tvar editInfo = this.getEditInfo();\n\tvar domNode = this.document.createElement(this.editTag);\n\tif(this.editType) {\n\t\tdomNode.setAttribute(\"type\",this.editType);\n\t}\n\tif(editInfo.value === \"\" && this.editPlaceholder) {\n\t\tdomNode.setAttribute(\"placeholder\",this.editPlaceholder);\n\t}\n\tif(this.editSize) {\n\t\tdomNode.setAttribute(\"size\",this.editSize);\n\t}\n\t// Assign classes\n\tif(this.editClass) {\n\t\tdomNode.className = this.editClass;\n\t}\n\t// Set the text\n\tif(this.editTag === \"textarea\") {\n\t\tdomNode.appendChild(this.document.createTextNode(editInfo.value));\n\t} else {\n\t\tdomNode.value = editInfo.value;\n\t}\n\t// Add an input event handler\n\t$tw.utils.addEventListeners(domNode,[\n\t\t{name: \"focus\", handlerObject: this, handlerMethod: \"handleFocusEvent\"},\n\t\t{name: \"input\", handlerObject: this, handlerMethod: \"handleInputEvent\"}\n\t]);\n\t// Insert the element into the DOM\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.domNodes.push(domNode);\n\tif(this.postRender) {\n\t\tthis.postRender();\n\t}\n\t// Fix height\n\tthis.fixHeight();\n};\n\n/*\nGet the tiddler being edited and current value\n*/\nEditTextWidget.prototype.getEditInfo = function() {\n\t// Get the edit value\n\tvar self = this,\n\t\tvalue,\n\t\tupdate;\n\tif(this.editIndex) {\n\t\tvalue = this.wiki.extractTiddlerDataItem(this.editTitle,this.editIndex,this.editDefault);\n\t\tupdate = function(value) {\n\t\t\tvar data = self.wiki.getTiddlerData(self.editTitle,{});\n\t\t\tif(data[self.editIndex] !== value) {\n\t\t\t\tdata[self.editIndex] = value;\n\t\t\t\tself.wiki.setTiddlerData(self.editTitle,data);\n\t\t\t}\n\t\t};\n\t} else {\n\t\t// Get the current tiddler and the field name\n\t\tvar tiddler = this.wiki.getTiddler(this.editTitle);\n\t\tif(tiddler) {\n\t\t\t// If we've got a tiddler, the value to display is the field string value\n\t\t\tvalue = tiddler.getFieldString(this.editField);\n\t\t} else {\n\t\t\t// Otherwise, we need to construct a default value for the editor\n\t\t\tswitch(this.editField) {\n\t\t\t\tcase \"text\":\n\t\t\t\t\tvalue = \"Type the text for the tiddler '\" + this.editTitle + \"'\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"title\":\n\t\t\t\t\tvalue = this.editTitle;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = \"\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(this.editDefault !== undefined) {\n\t\t\t\tvalue = this.editDefault;\n\t\t\t}\n\t\t}\n\t\tupdate = function(value) {\n\t\t\tvar tiddler = self.wiki.getTiddler(self.editTitle),\n\t\t\t\tupdateFields = {\n\t\t\t\t\ttitle: self.editTitle\n\t\t\t\t};\n\t\t\tupdateFields[self.editField] = value;\n\t\t\tself.wiki.addTiddler(new $tw.Tiddler(self.wiki.getCreationFields(),tiddler,updateFields,self.wiki.getModificationFields()));\n\t\t};\n\t}\n\treturn {value: value, update: update};\n};\n\n/*\nCompute the internal state of the widget\n*/\nEditTextWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.editTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.editField = this.getAttribute(\"field\",\"text\");\n\tthis.editIndex = this.getAttribute(\"index\");\n\tthis.editDefault = this.getAttribute(\"default\");\n\tthis.editClass = this.getAttribute(\"class\");\n\tthis.editPlaceholder = this.getAttribute(\"placeholder\");\n\tthis.editSize = this.getAttribute(\"size\");\n\tthis.editFocusPopup = this.getAttribute(\"focusPopup\");\n\t// Get the editor element tag and type\n\tvar tag,type;\n\tif(this.editField === \"text\") {\n\t\ttag = \"textarea\";\n\t} else {\n\t\ttag = \"input\";\n\t\tvar fieldModule = $tw.Tiddler.fieldModules[this.editField];\n\t\tif(fieldModule && fieldModule.editTag) {\n\t\t\ttag = fieldModule.editTag;\n\t\t}\n\t\tif(fieldModule && fieldModule.editType) {\n\t\t\ttype = fieldModule.editType;\n\t\t}\n\t\ttype = type || \"text\";\n\t}\n\t// Get the rest of our parameters\n\tthis.editTag = this.getAttribute(\"tag\",tag);\n\tthis.editType = this.getAttribute(\"type\",type);\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nEditTextWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\t// Completely rerender if any of our attributes have changed\n\tif(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else if(changedTiddlers[this.editTitle]) {\n\t\tthis.updateEditor(this.getEditInfo().value);\n\t\treturn true;\n\t}\n\treturn false;\n};\n\n/*\nUpdate the editor with new text. This method is separate from updateEditorDomNode()\nso that subclasses can override updateEditor() and still use updateEditorDomNode()\n*/\nEditTextWidget.prototype.updateEditor = function(text) {\n\tthis.updateEditorDomNode(text);\n};\n\n/*\nUpdate the editor dom node with new text\n*/\nEditTextWidget.prototype.updateEditorDomNode = function(text) {\n\t// Replace the edit value if the tiddler we're editing has changed\n\tvar domNode = this.domNodes[0];\n\tif(!domNode.isTiddlyWikiFakeDom) {\n\t\tif(this.document.activeElement !== domNode) {\n\t\t\tdomNode.value = text;\n\t\t}\n\t\t// Fix the height if needed\n\t\tthis.fixHeight();\n\t}\n};\n\n/*\nFix the height of textareas to fit their content\n*/\nEditTextWidget.prototype.fixHeight = function() {\n\tvar self = this,\n\t\tdomNode = this.domNodes[0];\n\tif(domNode && !domNode.isTiddlyWikiFakeDom && this.editTag === \"textarea\") {\n\t\t$tw.utils.nextTick(function() {\n\t\t\t// Resize the textarea to fit its content, preserving scroll position\n\t\t\tvar scrollPosition = $tw.utils.getScrollPosition(),\n\t\t\t\tscrollTop = scrollPosition.y;\n\t\t\t// Set its height to auto so that it snaps to the correct height\n\t\t\tdomNode.style.height = \"auto\";\n\t\t\t// Calculate the revised height\n\t\t\tvar newHeight = Math.max(domNode.scrollHeight + domNode.offsetHeight - domNode.clientHeight,MIN_TEXT_AREA_HEIGHT);\n\t\t\t// Only try to change the height if it has changed\n\t\t\tif(newHeight !== domNode.offsetHeight) {\n\t\t\t\tdomNode.style.height = newHeight + \"px\";\n\t\t\t\t// Make sure that the dimensions of the textarea are recalculated\n\t\t\t\t$tw.utils.forceLayout(domNode);\n\t\t\t\t// Check that the scroll position is still visible before trying to scroll back to it\n\t\t\t\tscrollTop = Math.min(scrollTop,self.document.body.scrollHeight - window.innerHeight);\n\t\t\t\twindow.scrollTo(scrollPosition.x,scrollTop);\n\t\t\t}\n\t\t});\n\t}\n};\n\n/*\nHandle a dom \"input\" event\n*/\nEditTextWidget.prototype.handleInputEvent = function(event) {\n\tthis.saveChanges(this.domNodes[0].value);\n\tthis.fixHeight();\n\treturn true;\n};\n\nEditTextWidget.prototype.handleFocusEvent = function(event) {\n\tif(this.editFocusPopup) {\n\t\t$tw.popup.triggerPopup({\n\t\t\tdomNode: this.domNodes[0],\n\t\t\ttitle: this.editFocusPopup,\n\t\t\twiki: this.wiki,\n\t\t\tforce: true\n\t\t});\n\t}\n\treturn true;\n};\n\nEditTextWidget.prototype.saveChanges = function(text) {\n\tvar editInfo = this.getEditInfo();\n\tif(text !== editInfo.value) {\n\t\teditInfo.update(text);\n\t}\n};\n\nexports[\"edit-text\"] = EditTextWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/edit-text.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/edit.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/edit.js\ntype: application/javascript\nmodule-type: widget\n\nEdit widget is a meta-widget chooses the appropriate actual editting widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EditWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEditWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEditWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n// Mappings from content type to editor type are stored in tiddlers with this prefix\nvar EDITOR_MAPPING_PREFIX = \"$:/config/EditorTypeMappings/\";\n\n/*\nCompute the internal state of the widget\n*/\nEditWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.editTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.editField = this.getAttribute(\"field\",\"text\");\n\tthis.editIndex = this.getAttribute(\"index\");\n\tthis.editClass = this.getAttribute(\"class\");\n\tthis.editPlaceholder = this.getAttribute(\"placeholder\");\n\t// Get the content type of the thing we're editing\n\tvar type;\n\tif(this.editField === \"text\") {\n\t\tvar tiddler = this.wiki.getTiddler(this.editTitle);\n\t\tif(tiddler) {\n\t\t\ttype = tiddler.fields.type;\n\t\t}\n\t}\n\ttype = type || \"text/vnd.tiddlywiki\";\n\t// Choose the appropriate edit widget\n\tvar editorType = this.wiki.getTiddlerText(EDITOR_MAPPING_PREFIX + type);\n\tif(!editorType) {\n\t\tvar typeInfo = $tw.config.contentTypeInfo[type];\n\t\tif(typeInfo && typeInfo.encoding === \"base64\") {\n\t\t\teditorType = \"binary\";\n\t\t} else {\n\t\t\teditorType = \"text\";\n\t\t}\n\t}\n\t// Make the child widgets\n\tthis.makeChildWidgets([{\n\t\ttype: \"edit-\" + editorType,\n\t\tattributes: {\n\t\t\ttiddler: {type: \"string\", value: this.editTitle},\n\t\t\tfield: {type: \"string\", value: this.editField},\n\t\t\tindex: {type: \"string\", value: this.editIndex},\n\t\t\t\"class\": {type: \"string\", value: this.editClass},\n\t\t\t\"placeholder\": {type: \"string\", value: this.editPlaceholder}\n\t\t}\n\t}]);\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nEditWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nexports.edit = EditWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/edit.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/element.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/element.js\ntype: application/javascript\nmodule-type: widget\n\nElement widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar ElementWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nElementWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nElementWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Neuter blacklisted elements\n\tvar tag = this.parseTreeNode.tag;\n\tif($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {\n\t\ttag = \"safe-\" + tag;\n\t}\n\tvar domNode = this.document.createElementNS(this.namespace,tag);\n\tthis.assignAttributes(domNode,{excludeEventAttributes: true});\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nElementWidget.prototype.execute = function() {\n\t// Select the namespace for the tag\n\tvar tagNamespaces = {\n\t\t\tsvg: \"http://www.w3.org/2000/svg\",\n\t\t\tmath: \"http://www.w3.org/1998/Math/MathML\",\n\t\t\tbody: \"http://www.w3.org/1999/xhtml\"\n\t\t};\n\tthis.namespace = tagNamespaces[this.parseTreeNode.tag];\n\tif(this.namespace) {\n\t\tthis.setVariable(\"namespace\",this.namespace);\n\t} else {\n\t\tthis.namespace = this.getVariable(\"namespace\",{defaultValue: \"http://www.w3.org/1999/xhtml\"});\n\t}\n\t// Make the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nElementWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes(),\n\t\thasChangedAttributes = $tw.utils.count(changedAttributes) > 0;\n\tif(hasChangedAttributes) {\n\t\t// Update our attributes\n\t\tthis.assignAttributes(this.domNodes[0],{excludeEventAttributes: true});\n\t}\n\treturn this.refreshChildren(changedTiddlers) || hasChangedAttributes;\n};\n\nexports.element = ElementWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/element.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/encrypt.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/encrypt.js\ntype: application/javascript\nmodule-type: widget\n\nEncrypt widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EncryptWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEncryptWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEncryptWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar textNode = this.document.createTextNode(this.encryptedText);\n\tparent.insertBefore(textNode,nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nEncryptWidget.prototype.execute = function() {\n\t// Get parameters from our attributes\n\tthis.filter = this.getAttribute(\"filter\",\"[!is[system]]\");\n\t// Encrypt the filtered tiddlers\n\tvar tiddlers = this.wiki.filterTiddlers(this.filter),\n\t\tjson = {},\n\t\tself = this;\n\t$tw.utils.each(tiddlers,function(title) {\n\t\tvar tiddler = self.wiki.getTiddler(title),\n\t\t\tjsonTiddler = {};\n\t\tfor(var f in tiddler.fields) {\n\t\t\tjsonTiddler[f] = tiddler.getFieldString(f);\n\t\t}\n\t\tjson[title] = jsonTiddler;\n\t});\n\tthis.encryptedText = $tw.utils.htmlEncode($tw.crypto.encrypt(JSON.stringify(json)));\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nEncryptWidget.prototype.refresh = function(changedTiddlers) {\n\t// We don't need to worry about refreshing because the encrypt widget isn't for interactive use\n\treturn false;\n};\n\nexports.encrypt = EncryptWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/encrypt.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/entity.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/entity.js\ntype: application/javascript\nmodule-type: widget\n\nHTML entity widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar EntityWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nEntityWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nEntityWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.execute();\n\tvar textNode = this.document.createTextNode($tw.utils.entityDecode(this.parseTreeNode.entity));\n\tparent.insertBefore(textNode,nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nEntityWidget.prototype.execute = function() {\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nEntityWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nexports.entity = EntityWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/entity.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/fieldmangler.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/fieldmangler.js\ntype: application/javascript\nmodule-type: widget\n\nField mangler widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar FieldManglerWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n\tthis.addEventListeners([\n\t\t{type: \"tw-remove-field\", handler: \"handleRemoveFieldEvent\"},\n\t\t{type: \"tw-add-field\", handler: \"handleAddFieldEvent\"},\n\t\t{type: \"tw-remove-tag\", handler: \"handleRemoveTagEvent\"},\n\t\t{type: \"tw-add-tag\", handler: \"handleAddTagEvent\"}\n\t]);\n};\n\n/*\nInherit from the base widget class\n*/\nFieldManglerWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nFieldManglerWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nFieldManglerWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.mangleTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nFieldManglerWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nFieldManglerWidget.prototype.handleRemoveFieldEvent = function(event) {\n\tvar tiddler = this.wiki.getTiddler(this.mangleTitle),\n\t\tdeletion = {};\n\tdeletion[event.param] = undefined;\n\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,deletion));\n\treturn true;\n};\n\nFieldManglerWidget.prototype.handleAddFieldEvent = function(event) {\n\tvar tiddler = this.wiki.getTiddler(this.mangleTitle);\n\tif(tiddler && typeof event.param === \"string\") {\n\t\tvar name = event.param.toLowerCase().trim();\n\t\tif(name !== \"\" && !$tw.utils.hop(tiddler.fields,name)) {\n\t\t\tif(!$tw.utils.isValidFieldName(name)) {\n\t\t\t\talert($tw.language.getString(\n\t\t\t\t\t\"InvalidFieldName\",\n\t\t\t\t\t{variables:\n\t\t\t\t\t\t{fieldName: name}\n\t\t\t\t\t}\n\t\t\t\t));\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tvar addition = this.wiki.getModificationFields();\n\t\t\taddition[name] = \"\";\n\t\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,addition));\n\t\t}\n\t}\n\treturn true;\n};\n\nFieldManglerWidget.prototype.handleRemoveTagEvent = function(event) {\n\tvar tiddler = this.wiki.getTiddler(this.mangleTitle);\n\tif(tiddler && tiddler.fields.tags) {\n\t\tvar p = tiddler.fields.tags.indexOf(event.param);\n\t\tif(p !== -1) {\n\t\t\tvar modification = this.wiki.getModificationFields();\n\t\t\tmodification.tags = (tiddler.fields.tags || []).slice(0);\n\t\t\tmodification.tags.splice(p,1);\n\t\t\tif(modification.tags.length === 0) {\n\t\t\t\tmodification.tags = undefined;\n\t\t\t}\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,modification));\n\t\t}\n\t}\n\treturn true;\n};\n\nFieldManglerWidget.prototype.handleAddTagEvent = function(event) {\n\tvar tiddler = this.wiki.getTiddler(this.mangleTitle);\n\tif(tiddler && typeof event.param === \"string\") {\n\t\tvar tag = event.param.trim();\n\t\tif(tag !== \"\") {\n\t\t\tvar modification = this.wiki.getModificationFields();\n\t\t\tmodification.tags = (tiddler.fields.tags || []).slice(0);\n\t\t\t$tw.utils.pushTop(modification.tags,tag);\n\t\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,modification));\t\t\t\n\t\t}\n\t}\n\treturn true;\n};\n\nexports.fieldmangler = FieldManglerWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/fieldmangler.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/fields.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/fields.js\ntype: application/javascript\nmodule-type: widget\n\nFields widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar FieldsWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nFieldsWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nFieldsWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar textNode = this.document.createTextNode(this.text);\n\tparent.insertBefore(textNode,nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nFieldsWidget.prototype.execute = function() {\n\t// Get parameters from our attributes\n\tthis.tiddlerTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.template = this.getAttribute(\"template\");\n\tthis.exclude = this.getAttribute(\"exclude\");\n\tthis.stripTitlePrefix = this.getAttribute(\"stripTitlePrefix\",\"no\") === \"yes\";\n\t// Get the value to display\n\tvar tiddler = this.wiki.getTiddler(this.tiddlerTitle);\n\t// Get the exclusion list\n\tvar exclude;\n\tif(this.exclude) {\n\t\texclude = this.exclude.split(\" \");\n\t} else {\n\t\texclude = [\"text\"]; \n\t}\n\t// Compose the template\n\tvar text = [];\n\tif(this.template && tiddler) {\n\t\tvar fields = [];\n\t\tfor(var fieldName in tiddler.fields) {\n\t\t\tif(exclude.indexOf(fieldName) === -1) {\n\t\t\t\tfields.push(fieldName);\n\t\t\t}\n\t\t}\n\t\tfields.sort();\n\t\tfor(var f=0; f<fields.length; f++) {\n\t\t\tfieldName = fields[f];\n\t\t\tif(exclude.indexOf(fieldName) === -1) {\n\t\t\t\tvar row = this.template,\n\t\t\t\t\tvalue = tiddler.getFieldString(fieldName);\n\t\t\t\tif(this.stripTitlePrefix && fieldName === \"title\") {\n\t\t\t\t\tvar reStrip = /^\\{[^\\}]+\\}(.+)/mg,\n\t\t\t\t\t\treMatch = reStrip.exec(value);\n\t\t\t\t\tif(reMatch) {\n\t\t\t\t\t\tvalue = reMatch[1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trow = row.replace(\"$name$\",fieldName);\n\t\t\t\trow = row.replace(\"$value$\",value);\n\t\t\t\trow = row.replace(\"$encoded_value$\",$tw.utils.htmlEncode(value));\n\t\t\t\ttext.push(row)\n\t\t\t}\n\t\t}\n\t}\n\tthis.text = text.join(\"\");\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nFieldsWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.template || changedAttributes.exclude || changedAttributes.stripTitlePrefix || changedTiddlers[this.tiddlerTitle]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn false;\t\n\t}\n};\n\nexports.fields = FieldsWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/fields.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/image.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/image.js\ntype: application/javascript\nmodule-type: widget\n\nThe image widget displays an image referenced with an external URI or with a local tiddler title.\n\n```\n<$image src=\"TiddlerTitle\" width=\"320\" height=\"400\" class=\"classnames\">\n```\n\nThe image source can be the title of an existing tiddler or the URL of an external image.\n\nExternal images always generate an HTML `<img>` tag.\n\nTiddlers that have a _canonical_uri field generate an HTML `<img>` tag with the src attribute containing the URI.\n\nTiddlers that contain image data generate an HTML `<img>` tag with the src attribute containing a base64 representation of the image.\n\nTiddlers that contain wikitext could be rendered to a DIV of the usual size of a tiddler, and then transformed to the size requested.\n\nThe width and height attributes are interpreted as a number of pixels, and do not need to include the \"px\" suffix.\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar ImageWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nImageWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nImageWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create element\n\t// Determine what type of image it is\n\tvar tag = \"img\", src = \"\",\n\t\ttiddler = this.wiki.getTiddler(this.imageSource);\n\tif(!tiddler) {\n\t\t// The source isn't the title of a tiddler, so we'll assume it's a URL\n\t\tsrc = this.imageSource;\n\t} else {\n\t\t// Check if it is an image tiddler\n\t\tif(this.wiki.isImageTiddler(this.imageSource)) {\n\t\t\t// Render the appropriate element for the image type\n\t\t\tvar type = tiddler.fields.type,\n\t\t\t\ttext = tiddler.fields.text;\n\t\t\tswitch(type) {\n\t\t\t\tcase \"application/pdf\":\n\t\t\t\t\ttag = \"embed\";\n\t\t\t\t\tsrc = \"data:application/pdf;base64,\" + text;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"image/svg+xml\":\n\t\t\t\t\tsrc = \"data:image/svg+xml,\" + encodeURIComponent(text);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsrc = \"data:\" + type + \";base64,\" + text;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// Create the element and assign the attributes\n\tvar domNode = this.document.createElement(tag);\n\tdomNode.setAttribute(\"src\",src);\n\tif(this.imageClass) {\n\t\tdomNode.setAttribute(\"class\",this.imageClass);\t\t\n\t}\n\tif(this.imageWidth) {\n\t\tdomNode.setAttribute(\"width\",parseInt(this.imageWidth,10) + \"px\");\n\t}\n\tif(this.imageHeight) {\n\t\tdomNode.setAttribute(\"height\",parseInt(this.imageHeight,10) + \"px\");\n\t}\n\tif(this.imageTooltip) {\n\t\tdomNode.setAttribute(\"title\",this.imageTooltip);\t\t\n\t}\n\t// Insert element\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.domNodes.push(domNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nImageWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.imageSource = this.getAttribute(\"source\");\n\tthis.imageWidth = this.getAttribute(\"width\");\n\tthis.imageHeight = this.getAttribute(\"height\");\n\tthis.imageClass = this.getAttribute(\"class\");\n\tthis.imageTooltip = this.getAttribute(\"tooltip\");\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nImageWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.source || changedAttributes.width || changedAttributes.height || changedAttributes[\"class\"] || changedAttributes.tooltip || changedTiddlers[this.imageSource]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn false;\t\t\n\t}\n};\n\nexports.image = ImageWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/image.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/keyboard.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/keyboard.js\ntype: application/javascript\nmodule-type: widget\n\nKeyboard shortcut widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar KeyboardWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nKeyboardWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nKeyboardWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Remember parent\n\tthis.parentDomNode = parent;\n\t// Compute attributes and execute state\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create element\n\tvar domNode = this.document.createElement(\"div\");\n\t// Assign classes\n\tvar classes = (this[\"class\"] || \"\").split(\" \");\n\tclasses.push(\"tw-keyboard\");\n\tdomNode.className = classes.join(\" \");\n\t// Add a keyboard event handler\n\tdomNode.addEventListener(\"keydown\",function (event) {\n\t\tif(event.keyCode === self.keyInfo.keyCode && \n\t\t\tevent.shiftKey === self.keyInfo.shiftKey && \n\t\t\tevent.altKey === self.keyInfo.altKey && \n\t\t\tevent.ctrlKey === self.keyInfo.ctrlKey) {\n\t\t\tself.dispatchMessage(event);\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t},false);\n\t// Insert element\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\nKeyboardWidget.prototype.dispatchMessage = function(event) {\n\tthis.dispatchEvent({type: this.message, param: this.param, tiddlerTitle: this.getVariable(\"currentTiddler\")});\n};\n\n/*\nCompute the internal state of the widget\n*/\nKeyboardWidget.prototype.execute = function() {\n\t// Get attributes\n\tthis.message = this.getAttribute(\"message\");\n\tthis.param = this.getAttribute(\"param\");\n\tthis.key = this.getAttribute(\"key\");\n\tthis.keyInfo = $tw.utils.parseKeyDescriptor(this.key);\n\tthis[\"class\"] = this.getAttribute(\"class\");\n\t// Make child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nKeyboardWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.message || changedAttributes.param || changedAttributes.key || changedAttributes[\"class\"]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t}\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.keyboard = KeyboardWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/keyboard.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/link.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/link.js\ntype: application/javascript\nmodule-type: widget\n\nLink widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar LinkWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nLinkWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nLinkWidget.prototype.render = function(parent,nextSibling) {\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Get the value of the tw-wikilinks configuration macro\n\tvar wikiLinksMacro = this.getVariable(\"tw-wikilinks\"),\n\t\tuseWikiLinks = wikiLinksMacro ? !(wikiLinksMacro.trim() === \"no\") : true;\n\t// Render the link if required\n\tif(useWikiLinks) {\n\t\tthis.renderLink(parent,nextSibling);\n\t} else {\n\t\t// Just insert the link text\n\t\tvar domNode = this.document.createElement(\"span\");\n\t\tparent.insertBefore(domNode,nextSibling);\n\t\tthis.renderChildren(domNode,null);\n\t\tthis.domNodes.push(domNode);\n\t}\n};\n\n/*\nRender this widget into the DOM\n*/\nLinkWidget.prototype.renderLink = function(parent,nextSibling) {\n\tvar self = this;\n\t// Create our element\n\tvar domNode = this.document.createElement(\"a\");\n\t// Assign classes\n\tvar classes = [\"tw-tiddlylink\"];\n\tif(this.isShadow) {\n\t\tclasses.push(\"tw-tiddlylink-shadow\");\n\t}\n\tif(this.isMissing && !this.isShadow) {\n\t\tclasses.push(\"tw-tiddlylink-missing\");\n\t} else {\n\t\tif(!this.isMissing) {\n\t\t\tclasses.push(\"tw-tiddlylink-resolves\");\n\t\t}\n\t}\n\tdomNode.setAttribute(\"class\",classes.join(\" \"));\n\t// Set an href\n\tvar wikiLinkTemplateMacro = this.getVariable(\"tw-wikilink-template\"),\n\t\twikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.trim() : \"#$uri_encoded$\",\n\t\twikiLinkText = wikiLinkTemplate.replace(\"$uri_encoded$\",encodeURIComponent(this.to));\n\twikiLinkText = wikiLinkText.replace(\"$uri_doubleencoded$\",encodeURIComponent(encodeURIComponent(this.to)));\n\tdomNode.setAttribute(\"href\",wikiLinkText);\n\t// Set the tooltip\n\t// HACK: Performance issues with re-parsing the tooltip prevent us defaulting the tooltip to \"<$transclude field='tooltip'><$transclude field='title'/></$transclude>\"\n\tvar tooltipWikiText = this.tooltip || this.getVariable(\"tw-wikilink-tooltip\");\n\tif(tooltipWikiText) {\n\t\tvar tooltipText = this.wiki.renderText(\"text/plain\",\"text/vnd.tiddlywiki\",tooltipWikiText,{\n\t\t\t\tparseAsInline: true,\n\t\t\t\tvariables: {\n\t\t\t\t\tcurrentTiddler: this.to\n\t\t\t\t},\n\t\t\t\tparentWidget: this\n\t\t\t});\n\t\tdomNode.setAttribute(\"title\",tooltipText);\n\t}\n\t// Add a click event handler\n\t$tw.utils.addEventListeners(domNode,[\n\t\t{name: \"click\", handlerObject: this, handlerMethod: \"handleClickEvent\"},\n\t\t{name: \"dragstart\", handlerObject: this, handlerMethod: \"handleDragStartEvent\"},\n\t\t{name: \"dragend\", handlerObject: this, handlerMethod: \"handleDragEndEvent\"}\n\t]);\n\t// Insert the link into the DOM and render any children\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\nLinkWidget.prototype.handleClickEvent = function (event) {\n\t// Send the click on it's way as a navigate event\n\tvar bounds = this.domNodes[0].getBoundingClientRect();\n\tthis.dispatchEvent({\n\t\ttype: \"tw-navigate\",\n\t\tnavigateTo: this.to,\n\t\tnavigateFromTitle: this.getVariable(\"storyTiddler\"),\n\t\tnavigateFromNode: this,\n\t\tnavigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height\n\t\t},\n\t\tnavigateSuppressNavigation: event.metaKey || event.ctrlKey || (event.button === 1)\n\t});\n\tevent.preventDefault();\n\tevent.stopPropagation();\n\treturn false;\n};\n\nLinkWidget.prototype.handleDragStartEvent = function(event) {\n\tif(this.to) {\n\t\t// Set the dragging class on the element being dragged\n\t\t$tw.utils.addClass(event.target,\"tw-tiddlylink-dragging\");\n\t\t// Create the drag image elements\n\t\tthis.dragImage = this.document.createElement(\"div\");\n\t\tthis.dragImage.className = \"tw-tiddler-dragger\";\n\t\tvar inner = this.document.createElement(\"div\");\n\t\tinner.className = \"tw-tiddler-dragger-inner\";\n\t\tinner.appendChild(this.document.createTextNode(this.to));\n\t\tthis.dragImage.appendChild(inner);\n\t\tthis.document.body.appendChild(this.dragImage);\n\t\t// Astoundingly, we need to cover the dragger up: http://www.kryogenix.org/code/browser/custom-drag-image.html\n\t\tvar cover = this.document.createElement(\"div\");\n\t\tcover.className = \"tw-tiddler-dragger-cover\";\n\t\tcover.style.left = (inner.offsetLeft - 16) + \"px\";\n\t\tcover.style.top = (inner.offsetTop - 16) + \"px\";\n\t\tcover.style.width = (inner.offsetWidth + 32) + \"px\";\n\t\tcover.style.height = (inner.offsetHeight + 32) + \"px\";\n\t\tthis.dragImage.appendChild(cover);\n\t\t// Set the data transfer properties\n\t\tvar dataTransfer = event.dataTransfer;\n\t\t// First the image\n\t\tdataTransfer.effectAllowed = \"copy\";\n\t\tif(dataTransfer.setDragImage) {\n\t\t\tdataTransfer.setDragImage(this.dragImage.firstChild,-16,-16);\n\t\t}\n\t\t// Then the data\n\t\tdataTransfer.clearData();\n\t\tvar jsonData = this.wiki.getTiddlerAsJson(this.to),\n\t\t\ttextData = this.wiki.getTiddlerText(this.to,\"\");\n\t\t// IE doesn't like these content types\n\t\tif(!$tw.browser.isIE) {\n\t\t\tdataTransfer.setData(\"text/vnd.tiddler\",jsonData);\n\t\t\tdataTransfer.setData(\"text/plain\",textData);\n\t\t\tdataTransfer.setData(\"text/x-moz-url\",\"data:text/vnd.tiddler,\" + encodeURI(jsonData));\n\t\t}\n\t\tdataTransfer.setData(\"URL\",\"data:text/vnd.tiddler,\" + encodeURI(jsonData));\n\t\tdataTransfer.setData(\"Text\",textData);\n\t\tevent.stopPropagation();\n\t} else {\n\t\tevent.preventDefault();\n\t}\n};\n\nLinkWidget.prototype.handleDragEndEvent = function(event) {\n\t// Remove the dragging class on the element being dragged\n\t$tw.utils.removeClass(event.target,\"tw-tiddlylink-dragging\");\n\t// Delete the drag image element\n\tif(this.dragImage) {\n\t\tthis.dragImage.parentNode.removeChild(this.dragImage);\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nLinkWidget.prototype.execute = function() {\n\t// Get the target tiddler title\n\tthis.to = this.getAttribute(\"to\",this.getVariable(\"currentTiddler\"));\n\t// Get the link title\n\tthis.tooltip = this.getAttribute(\"tooltip\");\n\t// Determine the link characteristics\n\tthis.isMissing = !this.wiki.tiddlerExists(this.to);\n\tthis.isShadow = this.wiki.isShadowTiddler(this.to);\n\t// Make the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nLinkWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.to || changedTiddlers[this.to] || changedAttributes.tooltip) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t}\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.link = LinkWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/link.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/linkcatcher.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/linkcatcher.js\ntype: application/javascript\nmodule-type: widget\n\nLinkcatcher widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar LinkCatcherWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n\tthis.addEventListeners([\n\t\t{type: \"tw-navigate\", handler: \"handleNavigateEvent\"}\n\t]);\n};\n\n/*\nInherit from the base widget class\n*/\nLinkCatcherWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nLinkCatcherWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nLinkCatcherWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.catchTo = this.getAttribute(\"to\");\n\tthis.catchMessage = this.getAttribute(\"message\");\n\tthis.catchSet = this.getAttribute(\"set\");\n\tthis.catchSetTo = this.getAttribute(\"setTo\");\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nLinkCatcherWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.to || changedAttributes.message || changedAttributes.set || changedAttributes.setTo) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\n/*\nHandle a tw-navigate event\n*/\nLinkCatcherWidget.prototype.handleNavigateEvent = function(event) {\n\tif(this.catchTo) {\n\t\tthis.wiki.setTextReference(this.catchTo,event.navigateTo,this.getVariable(\"currentTiddler\"));\n\t}\n\tif(this.catchMessage && this.parentWidget) {\n\t\tthis.parentWidget.dispatchEvent({\n\t\t\ttype: this.catchMessage,\n\t\t\tparam: event.navigateTo,\n\t\t\tnavigateTo: event.navigateTo\n\t\t});\n\t}\n\tif(this.catchSet) {\n\t\tvar tiddler = this.wiki.getTiddler(this.catchSet);\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: this.catchSet, text: this.catchSetTo}));\n\t}\n\treturn false;\n};\n\nexports.linkcatcher = LinkCatcherWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/linkcatcher.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/list.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/list.js\ntype: application/javascript\nmodule-type: widget\n\nList and list item widgets\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\n/*\nThe list widget creates list element sub-widgets that reach back into the list widget for their configuration\n*/\n\nvar ListWidget = function(parseTreeNode,options) {\n\t// Initialise the storyviews if they've not been done already\n\tif(!this.storyViews) {\n\t\tListWidget.prototype.storyViews = {};\n\t\t$tw.modules.applyMethods(\"storyview\",this.storyViews);\n\t}\n\t// Main initialisation inherited from widget.js\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nListWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nListWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n\t// Construct the storyview\n\tvar StoryView = this.storyViews[this.storyViewName];\n\tif(StoryView && !this.document.isTiddlyWikiFakeDom) {\n\t\tthis.storyview = new StoryView(this)\n\t} else {\n\t\tthis.storyview = null;\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nListWidget.prototype.execute = function() {\n\t// Get our attributes\n\tthis.template = this.getAttribute(\"template\");\n\tthis.editTemplate = this.getAttribute(\"editTemplate\");\n\tthis.variableName = this.getAttribute(\"variable\",\"currentTiddler\");\n\tthis.storyViewName = this.getAttribute(\"storyview\");\n\tthis.historyTitle = this.getAttribute(\"history\");\n\t// Compose the list elements\n\tthis.list = this.getTiddlerList();\n\tvar members = [],\n\t\tself = this;\n\t// Check for an empty list\n\tif(this.list.length === 0) {\n\t\tmembers = this.getEmptyMessage();\n\t} else {\n\t\t$tw.utils.each(this.list,function(title,index) {\n\t\t\tmembers.push(self.makeItemTemplate(title));\n\t\t});\n\t}\n\t// Construct the child widgets\n\tthis.makeChildWidgets(members);\n\t// Clear the last history\n\tthis.history = [];\n};\n\nListWidget.prototype.getTiddlerList = function() {\n\tvar defaultFilter = \"[!is[system]sort[title]]\";\n\treturn this.wiki.filterTiddlers(this.getAttribute(\"filter\",defaultFilter),this);\n};\n\nListWidget.prototype.getEmptyMessage = function() {\n\tvar emptyMessage = this.getAttribute(\"emptyMessage\",\"\"),\n\t\tparser = this.wiki.parseText(\"text/vnd.tiddlywiki\",emptyMessage,{parseAsInline: true});\n\tif(parser) {\n\t\treturn parser.tree;\n\t} else {\n\t\treturn [];\n\t}\n};\n\n/*\nCompose the template for a list item\n*/\nListWidget.prototype.makeItemTemplate = function(title) {\n\t// Check if the tiddler is a draft\n\tvar tiddler = this.wiki.getTiddler(title),\n\t\tisDraft = tiddler && tiddler.hasField(\"draft.of\"),\n\t\ttemplate = this.template,\n\t\ttemplateTree;\n\tif(isDraft && this.editTemplate) {\n\t\ttemplate = this.editTemplate;\n\t}\n\t// Compose the transclusion of the template\n\tif(template) {\n\t\ttemplateTree = [{type: \"transclude\", attributes: {tiddler: {type: \"string\", value: template}}}];\n\t} else {\n\t\tif(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) {\n\t\t\ttemplateTree = this.parseTreeNode.children;\n\t\t} else {\n\t\t\t// Default template is a link to the title\n\t\t\ttemplateTree = [{type: \"element\", tag: this.parseTreeNode.isBlock ? \"div\" : \"span\", children: [{type: \"link\", attributes: {to: {type: \"string\", value: title}}, children: [\n\t\t\t\t\t{type: \"text\", text: title}\n\t\t\t]}]}];\n\t\t}\n\t}\n\t// Return the list item\n\treturn {type: \"listitem\", itemTitle: title, variableName: this.variableName, children: templateTree};\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nListWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\t// Completely refresh if any of our attributes have changed\n\tif(changedAttributes.filter || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.emptyMessage || changedAttributes.storyview || changedAttributes.history) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\t// Handle any changes to the list\n\t\tvar hasChanged = this.handleListChanges(changedTiddlers);\n\t\t// Handle any changes to the history stack\n\t\tif(this.historyTitle && changedTiddlers[this.historyTitle]) {\n\t\t\tthis.handleHistoryChanges();\n\t\t}\n\t\treturn hasChanged;\n\t}\n};\n\n/*\nHandle any changes to the history list\n*/\nListWidget.prototype.handleHistoryChanges = function() {\n\t// Get the history data\n\tvar newHistory = this.wiki.getTiddlerData(this.historyTitle,[]);\n\t// Ignore any entries of the history that match the previous history\n\tvar entry = 0;\n\twhile(entry < newHistory.length && entry < this.history.length && newHistory[entry].title === this.history[entry].title) {\n\t\tentry++;\n\t}\n\t// Navigate forwards to each of the new tiddlers\n\twhile(entry < newHistory.length) {\n\t\tif(this.storyview && this.storyview.navigateTo) {\n\t\t\tthis.storyview.navigateTo(newHistory[entry]);\n\t\t}\n\t\tentry++;\n\t}\n\t// Update the history\n\tthis.history = newHistory;\n};\n\n/*\nProcess any changes to the list\n*/\nListWidget.prototype.handleListChanges = function(changedTiddlers) {\n\t// Get the new list\n\tvar prevList = this.list;\n\tthis.list = this.getTiddlerList();\n\t// Check for an empty list\n\tif(this.list.length === 0) {\n\t\t// Check if it was empty before\n\t\tif(prevList.length === 0) {\n\t\t\t// If so, just refresh the empty message\n\t\t\treturn this.refreshChildren(changedTiddlers);\n\t\t} else {\n\t\t\t// Replace the previous content with the empty message\n\t\t\tfor(t=this.children.length-1; t>=0; t--) {\n\t\t\t\tthis.removeListItem(t);\n\t\t\t}\n\t\t\tvar nextSibling = this.findNextSiblingDomNode();\n\t\t\tthis.makeChildWidgets(this.getEmptyMessage());\n\t\t\tthis.renderChildren(this.parentDomNode,nextSibling);\n\t\t\treturn true;\n\t\t}\n\t} else {\n\t\t// If the list was empty then we need to remove the empty message\n\t\tif(prevList.length === 0) {\n\t\t\tthis.removeChildDomNodes();\n\t\t\tthis.children = [];\n\t\t}\n\t\t// Cycle through the list, inserting and removing list items as needed\n\t\tvar hasRefreshed = false;\n\t\tfor(var t=0; t<this.list.length; t++) {\n\t\t\tvar index = this.findListItem(t,this.list[t]);\n\t\t\tif(index === undefined) {\n\t\t\t\t// The list item must be inserted\n\t\t\t\tthis.insertListItem(t,this.list[t]);\n\t\t\t\thasRefreshed = true;\n\t\t\t} else {\n\t\t\t\t// There are intervening list items that must be removed\n\t\t\t\tfor(var n=index-1; n>=t; n--) {\n\t\t\t\t\tthis.removeListItem(n);\n\t\t\t\t\thasRefreshed = true;\n\t\t\t\t}\n\t\t\t\t// Refresh the item we're reusing\n\t\t\t\tvar refreshed = this.children[t].refresh(changedTiddlers);\n\t\t\t\thasRefreshed = hasRefreshed || refreshed;\n\t\t\t}\n\t\t}\n\t\t// Remove any left over items\n\t\tfor(t=this.children.length-1; t>=this.list.length; t--) {\n\t\t\tthis.removeListItem(t);\n\t\t\thasRefreshed = true;\n\t\t}\n\t\treturn hasRefreshed;\n\t}\n};\n\n/*\nFind the list item with a given title, starting from a specified position\n*/\nListWidget.prototype.findListItem = function(startIndex,title) {\n\twhile(startIndex < this.children.length) {\n\t\tif(this.children[startIndex].parseTreeNode.itemTitle === title) {\n\t\t\treturn startIndex;\n\t\t}\n\t\tstartIndex++;\n\t}\n\treturn undefined;\n};\n\n/*\nInsert a new list item at the specified index\n*/\nListWidget.prototype.insertListItem = function(index,title) {\n\t// Create, insert and render the new child widgets\n\tvar widget = this.makeChildWidget(this.makeItemTemplate(title));\n\twidget.parentDomNode = this.parentDomNode; // Hack to enable findNextSiblingDomNode() to work\n\tthis.children.splice(index,0,widget);\n\tvar nextSibling = widget.findNextSiblingDomNode();\n\twidget.render(this.parentDomNode,nextSibling);\n\t// Animate the insertion if required\n\tif(this.storyview && this.storyview.insert) {\n\t\tthis.storyview.insert(widget);\n\t}\n\treturn true;\n};\n\n/*\nRemove the specified list item\n*/\nListWidget.prototype.removeListItem = function(index) {\n\tvar widget = this.children[index];\n\t// Animate the removal if required\n\tif(this.storyview && this.storyview.remove) {\n\t\tthis.storyview.remove(widget);\n\t} else {\n\t\twidget.removeChildDomNodes();\n\t}\n\t// Remove the child widget\n\tthis.children.splice(index,1);\n};\n\nexports.list = ListWidget;\n\nvar ListItemWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nListItemWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nListItemWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nListItemWidget.prototype.execute = function() {\n\t// Set the current list item title\n\tthis.setVariable(this.parseTreeNode.variableName,this.parseTreeNode.itemTitle);\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nListItemWidget.prototype.refresh = function(changedTiddlers) {\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.listitem = ListItemWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/list.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/macrocall.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/macrocall.js\ntype: application/javascript\nmodule-type: widget\n\nMacrocall widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar MacroCallWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nMacroCallWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nMacroCallWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nMacroCallWidget.prototype.execute = function() {\n\t// Get the parse type if specified\n\tthis.parseType = this.getAttribute(\"$type\",\"text/vnd.tiddlywiki\");\n\tthis.renderOutput = this.getAttribute(\"$output\",\"text/html\");\n\t// Merge together the parameters specified in the parse tree with the specified attributes\n\tvar params = this.parseTreeNode.params ? this.parseTreeNode.params.slice(0) : [];\n\t$tw.utils.each(this.attributes,function(attribute,name) {\n\t\tif(name.charAt(0) !== \"$\") {\n\t\t\tparams.push({name: name, value: attribute});\t\t\t\n\t\t}\n\t});\n\t// Get the macro value\n\tvar text = this.getVariable(this.parseTreeNode.name || this.getAttribute(\"$name\"),{params: params}),\n\t\tparseTreeNodes;\n\t// Are we rendering to HTML?\n\tif(this.renderOutput === \"text/html\") {\n\t\t// If so we'll return the parsed macro\n\t\tvar parser = this.wiki.parseText(this.parseType,text,\n\t\t\t\t\t\t\t{parseAsInline: !this.parseTreeNode.isBlock});\n\t\tparseTreeNodes = parser ? parser.tree : [];\n\t} else {\n\t\t// Otherwise, we'll render the text\n\t\tvar plainText = this.wiki.renderText(\"text/plain\",this.parseType,text,{parentWidget: this});\n\t\tparseTreeNodes = [{type: \"text\", text: plainText}];\n\t}\n\t// Construct the child widgets\n\tthis.makeChildWidgets(parseTreeNodes);\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nMacroCallWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif($tw.utils.count(changedAttributes) > 0) {\n\t\t// Rerender ourselves\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\n\t}\n};\n\nexports.macrocall = MacroCallWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/macrocall.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/navigator.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/navigator.js\ntype: application/javascript\nmodule-type: widget\n\nNavigator widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar NavigatorWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n\tthis.addEventListeners([\n\t\t{type: \"tw-navigate\", handler: \"handleNavigateEvent\"},\n\t\t{type: \"tw-edit-tiddler\", handler: \"handleEditTiddlerEvent\"},\n\t\t{type: \"tw-delete-tiddler\", handler: \"handleDeleteTiddlerEvent\"},\n\t\t{type: \"tw-save-tiddler\", handler: \"handleSaveTiddlerEvent\"},\n\t\t{type: \"tw-cancel-tiddler\", handler: \"handleCancelTiddlerEvent\"},\n\t\t{type: \"tw-close-tiddler\", handler: \"handleCloseTiddlerEvent\"},\n\t\t{type: \"tw-close-all-tiddlers\", handler: \"handleCloseAllTiddlersEvent\"},\n\t\t{type: \"tw-close-other-tiddlers\", handler: \"handleCloseOtherTiddlersEvent\"},\n\t\t{type: \"tw-new-tiddler\", handler: \"handleNewTiddlerEvent\"},\n\t\t{type: \"tw-import-tiddlers\", handler: \"handleImportTiddlersEvent\"}\n\t]);\n};\n\n/*\nInherit from the base widget class\n*/\nNavigatorWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nNavigatorWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nNavigatorWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.storyTitle = this.getAttribute(\"story\");\n\tthis.historyTitle = this.getAttribute(\"history\");\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nNavigatorWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.story || changedAttributes.history) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nNavigatorWidget.prototype.getStoryList = function() {\n\treturn this.storyTitle ? this.wiki.getTiddlerList(this.storyTitle) : null;\n};\n\nNavigatorWidget.prototype.saveStoryList = function(storyList) {\n\tvar storyTiddler = this.wiki.getTiddler(this.storyTitle);\n\tthis.wiki.addTiddler(new $tw.Tiddler(\n\t\t{title: this.storyTitle},\n\t\tstoryTiddler,\n\t\t{list: storyList}\n\t));\n};\n\nNavigatorWidget.prototype.findTitleInStory = function(storyList,title,defaultIndex) {\n\tvar p = storyList.indexOf(title);\n\treturn p === -1 ? defaultIndex : p;\n};\n\nNavigatorWidget.prototype.removeTitleFromStory = function(storyList,title) {\n\tvar p = storyList.indexOf(title);\n\twhile(p !== -1) {\n\t\tstoryList.splice(p,1);\n\t\tp = storyList.indexOf(title);\n\t}\n};\n\nNavigatorWidget.prototype.replaceFirstTitleInStory = function(storyList,oldTitle,newTitle) {\n\tvar pos = storyList.indexOf(oldTitle);\n\tif(pos !== -1) {\n\t\tstoryList[pos] = newTitle;\n\t\tdo {\n\t\t\tpos = storyList.indexOf(oldTitle,pos + 1);\n\t\t\tif(pos !== -1) {\n\t\t\t\tstoryList.splice(pos,1);\n\t\t\t}\n\t\t} while(pos !== -1);\n\t} else {\n\t\tstoryList.splice(0,0,newTitle);\n\t}\n};\n\nNavigatorWidget.prototype.addToStory = function(title,fromTitle) {\n\tvar storyList = this.getStoryList();\n\tif(storyList) {\n\t\t// See if the tiddler is already there\n\t\tvar slot = this.findTitleInStory(storyList,title,-1);\n\t\t// If not we need to add it\n\t\tif(slot === -1) {\n\t\t\t// First we try to find the position of the story element we navigated from\n\t\t\tslot = this.findTitleInStory(storyList,fromTitle,-1) + 1;\n\t\t\t// Add the tiddler\n\t\t\tstoryList.splice(slot,0,title);\n\t\t\t// Save the story\n\t\t\tthis.saveStoryList(storyList);\n\t\t}\n\t}\n};\n\n/*\nAdd a new record to the top of the history stack\ntitle: a title string or an array of title strings\nfromPageRect: page coordinates of the origin of the navigation\n*/\nNavigatorWidget.prototype.addToHistory = function(title,fromPageRect) {\n\tthis.wiki.addToHistory(title,fromPageRect,this.historyTitle);\n};\n\n/*\nHandle a tw-navigate event\n*/\nNavigatorWidget.prototype.handleNavigateEvent = function(event) {\n\tthis.addToStory(event.navigateTo,event.navigateFromTitle);\n\tif(!event.navigateSuppressNavigation) {\n\t\tthis.addToHistory(event.navigateTo,event.navigateFromClientRect);\n\t}\n\treturn false;\n};\n\n// Close a specified tiddler\nNavigatorWidget.prototype.handleCloseTiddlerEvent = function(event) {\n\tvar title = event.param || event.tiddlerTitle,\n\t\tstoryList = this.getStoryList();\n\t// Look for tiddlers with this title to close\n\tthis.removeTitleFromStory(storyList,title);\n\tthis.saveStoryList(storyList);\n\treturn false;\n};\n\n// Close all tiddlers\nNavigatorWidget.prototype.handleCloseAllTiddlersEvent = function(event) {\n\tthis.saveStoryList([]);\n\treturn false;\n};\n\n// Close other tiddlers\nNavigatorWidget.prototype.handleCloseOtherTiddlersEvent = function(event) {\n\tvar title = event.param || event.tiddlerTitle;\n\tthis.saveStoryList([title]);\n\treturn false;\n};\n\n// Place a tiddler in edit mode\nNavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {\n\tvar self = this;\n\tfunction isUnmodifiedShadow(title) {\n\t\t// jshint eqnull:true\n\t\tvar tiddler = self.wiki.getTiddler(title);\n\t\treturn (\n\t\t\tself.wiki.isShadowTiddler(title) &&\n\t\t\ttiddler.fields.modified == null\n\t\t);\n\t}\n\tfunction confirmEditShadow(title) {\n\t\treturn confirm($tw.language.getString(\n\t\t\t\"ConfirmEditShadowTiddler\",\n\t\t\t{variables:\n\t\t\t\t{title: title}\n\t\t\t}\n\t\t));\n\t}\n\tvar title = event.param || event.tiddlerTitle;\n\tif(isUnmodifiedShadow(title) && !confirmEditShadow(title)) {\n\t\treturn false;\n\t}\n\t// Replace the specified tiddler with a draft in edit mode\n\tvar draftTiddler = this.makeDraftTiddler(title),\n\t\tdraftTitle = draftTiddler.fields.title,\n\t\tstoryList = this.getStoryList();\n\tthis.removeTitleFromStory(storyList,draftTitle);\n\tthis.replaceFirstTitleInStory(storyList,title,draftTitle);\n\tthis.addToHistory(draftTitle,event.navigateFromClientRect);\n\tthis.saveStoryList(storyList);\n\treturn false;\n};\n\n// Delete a tiddler\nNavigatorWidget.prototype.handleDeleteTiddlerEvent = function(event) {\n\t// Get the tiddler we're deleting\n\tvar title = event.param || event.tiddlerTitle,\n\t\ttiddler = this.wiki.getTiddler(title),\n\t\tstoryList = this.getStoryList(),\n\t\toriginalTitle, confirmationTitle;\n\t// Check if the tiddler we're deleting is in draft mode\n\tif(tiddler.hasField(\"draft.title\")) {\n\t\t// If so, we'll prompt for confirmation referencing the original tiddler\n\t\toriginalTitle = tiddler.fields[\"draft.of\"];\n\t\tconfirmationTitle = originalTitle;\n\t} else {\n\t\t// If not a draft, then prompt for confirmation referencing the specified tiddler\n\t\toriginalTitle = null;\n\t\tconfirmationTitle = title;\n\t}\n\t// Seek confirmation\n\tif(!confirm($tw.language.getString(\n\t\t\t\t\"ConfirmDeleteTiddler\",\n\t\t\t\t{variables:\n\t\t\t\t\t{title: confirmationTitle}\n\t\t\t\t}\n\t\t\t))) {\n\t\treturn false;\n\t}\n\t// Delete the original tiddler\n\tif(originalTitle) {\n\t\tthis.wiki.deleteTiddler(originalTitle);\n\t\tthis.removeTitleFromStory(storyList,originalTitle);\n\t}\n\t// Delete this tiddler\n\tthis.wiki.deleteTiddler(title);\n\t// Remove the closed tiddler from the story\n\tthis.removeTitleFromStory(storyList,title);\n\tthis.saveStoryList(storyList);\n\t// Send a notification event\n\tthis.dispatchEvent({type: \"tw-auto-save-wiki\"});\n\treturn false;\n};\n\n/*\nCreate/reuse the draft tiddler for a given title\n*/\nNavigatorWidget.prototype.makeDraftTiddler = function(targetTitle) {\n\t// See if there is already a draft tiddler for this tiddler\n\tvar drafts = [];\n\tthis.wiki.forEachTiddler({includeSystem: true},function(title,tiddler) {\n\t\tif(tiddler.fields[\"draft.title\"] && tiddler.fields[\"draft.of\"] === targetTitle) {\n\t\t\tdrafts.push(tiddler);\n\t\t}\n\t});\n\tif(drafts.length > 0) {\n\t\treturn drafts[0];\n\t}\n\t// Get the current value of the tiddler we're editing\n\tvar tiddler = this.wiki.getTiddler(targetTitle),\n\t\tdraftTitle = this.generateDraftTitle(targetTitle);\n\t// Save the initial value of the draft tiddler\n\tvar draftTiddler = new $tw.Tiddler(\n\t\t\ttiddler,\n\t\t\t{\n\t\t\t\ttitle: draftTitle,\n\t\t\t\t\"draft.title\": targetTitle,\n\t\t\t\t\"draft.of\": targetTitle\n\t\t\t},\n\t\t\tthis.wiki.getModificationFields()\n\t\t);\n\tthis.wiki.addTiddler(draftTiddler);\n\treturn draftTiddler;\n};\n\n/*\nGenerate a title for the draft of a given tiddler\n*/\nNavigatorWidget.prototype.generateDraftTitle = function(title) {\n\tvar c = 0;\n\tdo {\n\t\tvar draftTitle = \"Draft \" + (c ? (c + 1) + \" \" : \"\") + \"of '\" + title + \"'\";\n\t\tc++;\n\t} while(this.wiki.tiddlerExists(draftTitle));\n\treturn draftTitle;\n};\n\n// Take a tiddler out of edit mode, saving the changes\nNavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {\n\tvar title = event.param || event.tiddlerTitle,\n\t\ttiddler = this.wiki.getTiddler(title),\n\t\tstoryList = this.getStoryList();\n\t// Replace the original tiddler with the draft\n\tif(tiddler) {\n\t\tvar draftTitle = (tiddler.fields[\"draft.title\"] || \"\").trim(),\n\t\t\tdraftOf = (tiddler.fields[\"draft.of\"] || \"\").trim();\n\t\tif(draftTitle) {\n\t\t\tvar isRename = draftOf !== draftTitle,\n\t\t\t\tisConfirmed = true;\n\t\t\tif(isRename && this.wiki.tiddlerExists(draftTitle)) {\n\t\t\t\tisConfirmed = confirm($tw.language.getString(\n\t\t\t\t\t\"ConfirmOverwriteTiddler\",\n\t\t\t\t\t{variables:\n\t\t\t\t\t\t{title: draftTitle}\n\t\t\t\t\t}\n\t\t\t\t));\n\t\t\t} else if(!this.wiki.isDraftModified(title)) {\n\t\t\t\tevent.type = \"tw-cancel-tiddler\";\n\t\t\t\tthis.dispatchEvent(event);\n\t\t\t} else if(isConfirmed) {\n\t\t\t\t// Save the draft tiddler as the real tiddler\n\t\t\t\tthis.wiki.addTiddler(new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,{\n\t\t\t\t\ttitle: draftTitle,\n\t\t\t\t\t\"draft.title\": undefined,\n\t\t\t\t\t\"draft.of\": undefined\n\t\t\t\t},this.wiki.getModificationFields()));\n\t\t\t\t// Remove the draft tiddler\n\t\t\t\tthis.wiki.deleteTiddler(title);\n\t\t\t\t// Remove the original tiddler if we're renaming it\n\t\t\t\tif(isRename) {\n\t\t\t\t\tthis.wiki.deleteTiddler(draftOf);\n\t\t\t\t}\n\t\t\t\t// Replace the draft in the story with the original\n\t\t\t\tthis.replaceFirstTitleInStory(storyList,title,draftTitle);\n\t\t\t\tthis.addToHistory(draftTitle,event.navigateFromClientRect);\n\t\t\t\tif(draftTitle !== this.storyTitle) {\n\t\t\t\t\tthis.saveStoryList(storyList);\n\t\t\t\t}\n\t\t\t\t// Send a notification event\n\t\t\t\tthis.dispatchEvent({type: \"tw-auto-save-wiki\"});\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n};\n\n// Take a tiddler out of edit mode without saving the changes\nNavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {\n\t// Flip the specified tiddler from draft back to the original\n\tvar draftTitle = event.param || event.tiddlerTitle,\n\t\tdraftTiddler = this.wiki.getTiddler(draftTitle),\n\t\toriginalTitle = draftTiddler.fields[\"draft.of\"],\n\t\tstoryList = this.getStoryList();\n\tif(draftTiddler && originalTitle) {\n\t\t// Ask for confirmation if the tiddler text has changed\n\t\tvar isConfirmed = true;\n\t\tif(this.wiki.getTiddlerText(draftTitle) !== this.wiki.getTiddlerText(originalTitle)) {\n\t\t\tisConfirmed = confirm($tw.language.getString(\n\t\t\t\t\"ConfirmCancelTiddler\",\n\t\t\t\t{variables:\n\t\t\t\t\t{title: draftTitle}\n\t\t\t\t}\n\t\t\t));\n\t\t}\n\t\t// Remove the draft tiddler\n\t\tif(isConfirmed) {\n\t\t\tthis.wiki.deleteTiddler(draftTitle);\n\t\t\tthis.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);\n\t\t\tthis.addToHistory(originalTitle,event.navigateFromClientRect);\n\t\t\tthis.saveStoryList(storyList);\n\t\t}\n\t}\n\treturn false;\n};\n\n// Create a new draft tiddler\nNavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {\n\t// Get the story details\n\tvar storyList = this.getStoryList();\n\t// Get the template tiddler if there is one\n\tvar templateTiddler = this.wiki.getTiddler(event.param);\n\t// Create the new tiddler\n\tvar title = this.wiki.generateNewTitle((templateTiddler && templateTiddler.fields.title) || \"New Tiddler\");\n\tvar tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{\n\t\ttext: \"Newly created tiddler\",\n\t\ttitle: title\n\t},this.wiki.getModificationFields());\n\tthis.wiki.addTiddler(tiddler);\n\t// Create the draft tiddler\n\tvar draftTitle = this.generateDraftTitle(title),\n\t\tdraftTiddler = new $tw.Tiddler({\n\t\t\ttext: \"\"\n\t\t},templateTiddler,\n\t\tthis.wiki.getCreationFields(),\n\t\t{\n\t\t\ttitle: draftTitle,\n\t\t\t\"draft.title\": title,\n\t\t\t\"draft.of\": title\n\t\t},this.wiki.getModificationFields());\n\tthis.wiki.addTiddler(draftTiddler);\n\t// Update the story to insert the new draft at the top\n\tvar slot = storyList.indexOf(event.navigateFromTitle);\n\tstoryList.splice(slot + 1,0,draftTitle);\n\t// Save the updated story\n\tthis.saveStoryList(storyList);\n\t// Add a new record to the top of the history stack\n\tthis.addToHistory(draftTitle);\n\treturn false;\n};\n\n// Import JSON tiddlers\nNavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {\n\tvar self = this;\n\t// Get the tiddlers\n\tvar tiddlers = [];\n\ttry {\n\t\ttiddlers = JSON.parse(event.param);\t\n\t} catch(e) {\n\t}\n\t// Process each tiddler\n\tvar importedTiddlers = [];\n\t$tw.utils.each(tiddlers,function(tiddlerFields) {\n\t\tvar title = tiddlerFields.title;\n\t\t// Add it to the store\n\t\tvar imported = self.wiki.importTiddler(new $tw.Tiddler(\n\t\t\tself.wiki.getCreationFields(),\n\t\t\tself.wiki.getModificationFields(),\n\t\t\ttiddlerFields\n\t\t));\n\t\tif(imported) {\n\t\t\timportedTiddlers.push(title);\n\t\t}\n\t});\n\t// Get the story and history details\n\tvar storyList = this.getStoryList(),\n\t\thistory = [];\n\t// Create the import report tiddler\n\tif(importedTiddlers.length === 0) {\n\t\treturn false;\n\t}\n\tvar title;\n\tif(importedTiddlers.length > 1) {\n\t\ttitle = this.wiki.generateNewTitle(\"$:/temp/ImportReport\");\n\t\tvar tiddlerFields = {\n\t\t\ttitle: title,\n\t\t\ttext: \"# [[\" + importedTiddlers.join(\"]]\\n# [[\") + \"]]\\n\"\n\t\t};\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(\n\t\t\tself.wiki.getCreationFields(),\n\t\t\ttiddlerFields,\n\t\t\tself.wiki.getModificationFields()\n\t\t));\n\t} else {\n\t\ttitle = importedTiddlers[0];\n\t}\n\t// Add it to the story\n\tif(storyList.indexOf(title) === -1) {\n\t\tstoryList.unshift(title);\n\t}\n\t// And to history\n\thistory.push(title);\n\t// Save the updated story and history\n\tthis.saveStoryList(storyList);\n\tthis.addToHistory(history);\n\treturn false;\n};\n\nexports.navigator = NavigatorWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/navigator.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/password.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/password.js\ntype: application/javascript\nmodule-type: widget\n\nPassword widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar PasswordWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nPasswordWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nPasswordWidget.prototype.render = function(parent,nextSibling) {\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Get the current password\n\tvar password = $tw.browser ? $tw.utils.getPassword(this.passwordName) || \"\" : \"\";\n\t// Create our element\n\tvar domNode = this.document.createElement(\"input\");\n\tdomNode.setAttribute(\"type\",\"password\");\n\tdomNode.setAttribute(\"value\",password);\n\t// Add a click event handler\n\t$tw.utils.addEventListeners(domNode,[\n\t\t{name: \"change\", handlerObject: this, handlerMethod: \"handleChangeEvent\"}\n\t]);\n\t// Insert the label into the DOM and render any children\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tthis.domNodes.push(domNode);\n};\n\nPasswordWidget.prototype.handleChangeEvent = function(event) {\n\tvar password = this.domNodes[0].value;\n\treturn $tw.utils.savePassword(this.passwordName,password);\n};\n\n/*\nCompute the internal state of the widget\n*/\nPasswordWidget.prototype.execute = function() {\n\t// Get the parameters from the attributes\n\tthis.passwordName = this.getAttribute(\"name\",\"\");\n\t// Make the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nPasswordWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.name) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\n\t}\n};\n\nexports.password = PasswordWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/password.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/radio.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/radio.js\ntype: application/javascript\nmodule-type: widget\n\nRadio widget\n\nWill set a field to the selected value:\n\n```\n\t<$radio field=\"myfield\" value=\"check 1\">one</$radio>\n\t<$radio field=\"myfield\" value=\"check 2\">two</$radio>\n\t<$radio field=\"myfield\" value=\"check 3\">three</$radio>\n```\n\n|Parameter |Description |h\n|tiddler |Name of the tiddler in which the field should be set. Defaults to current tiddler |\n|field |The name of the field to be set |\n|value |The value to set |\n|class |Optional class name(s) |\n\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar RadioWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nRadioWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nRadioWidget.prototype.render = function(parent,nextSibling) {\n\t// Save the parent dom node\n\tthis.parentDomNode = parent;\n\t// Compute our attributes\n\tthis.computeAttributes();\n\t// Execute our logic\n\tthis.execute();\n\t// Create our elements\n\tthis.labelDomNode = this.document.createElement(\"label\");\n\tthis.labelDomNode.setAttribute(\"class\",this.radioClass);\n\tthis.inputDomNode = this.document.createElement(\"input\");\n\tthis.inputDomNode.setAttribute(\"type\",\"radio\");\n\tif(this.getValue() == this.radioValue) {\n\t\tthis.inputDomNode.setAttribute(\"checked\",\"true\");\n\t}\n\tthis.labelDomNode.appendChild(this.inputDomNode);\n\tthis.spanDomNode = this.document.createElement(\"span\");\n\tthis.labelDomNode.appendChild(this.spanDomNode);\n\t// Add a click event handler\n\t$tw.utils.addEventListeners(this.inputDomNode,[\n\t\t{name: \"change\", handlerObject: this, handlerMethod: \"handleChangeEvent\"}\n\t]);\n\t// Insert the label into the DOM and render any children\n\tparent.insertBefore(this.labelDomNode,nextSibling);\n\tthis.renderChildren(this.spanDomNode,null);\n\tthis.domNodes.push(this.labelDomNode);\n};\n\nRadioWidget.prototype.getValue = function() {\n\tvar tiddler = this.wiki.getTiddler(this.radioTitle);\n\treturn tiddler && tiddler.getFieldString(this.radioField);\n};\n\nRadioWidget.prototype.setValue = function() {\n\tif(this.radioField) {\n\t\tvar tiddler = this.wiki.getTiddler(this.radioTitle),\n\t\t\taddition = {};\n\t\taddition[this.radioField] = this.radioValue;\n\t\tthis.wiki.addTiddler(new $tw.Tiddler(tiddler,addition));\n\t}\n};\n\nRadioWidget.prototype.handleChangeEvent = function(event) {\n\tif(this.inputDomNode.checked) {\n\t\tthis.setValue();\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nRadioWidget.prototype.execute = function() {\n\t// Get the parameters from the attributes\n\tthis.radioTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.radioField = this.getAttribute(\"field\");\n\tthis.radioValue = this.getAttribute(\"value\");\n\tthis.radioClass = this.getAttribute(\"class\",\"\");\n\tif(this.radioClass !== \"\") {\n\t\tthis.radioClass += \" \";\n\t}\n\tthis.radioClass += \"tw-radio\";\n\t// Make the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nRadioWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.field || changedAttributes.value || changedAttributes[\"class\"]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\tvar refreshed = false;\n\t\tif(changedTiddlers[this.radioTitle]) {\n\t\t\tthis.inputDomNode.checked = this.getValue() === this.radioValue;\n\t\t\trefreshed = true;\n\t\t}\n\t\treturn this.refreshChildren(changedTiddlers) || refreshed;\n\t}\n};\n\nexports.radio = RadioWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/radio.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/raw.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/raw.js\ntype: application/javascript\nmodule-type: widget\n\nRaw widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar RawWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nRawWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nRawWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.execute();\n\tvar div = this.document.createElement(\"div\");\n\tdiv.innerHTML=this.parseTreeNode.html;\n\tparent.insertBefore(div,nextSibling);\n\tthis.domNodes.push(div);\t\n};\n\n/*\nCompute the internal state of the widget\n*/\nRawWidget.prototype.execute = function() {\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nRawWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nexports.raw = RawWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/raw.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/reveal.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/reveal.js\ntype: application/javascript\nmodule-type: widget\n\nReveal widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar RevealWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nRevealWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nRevealWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar domNode = this.document.createElement(this.parseTreeNode.isBlock ? \"div\" : \"span\");\n\tvar classes = this[\"class\"].split(\" \") || [];\n\tclasses.push(\"tw-reveal\");\n\tdomNode.className = classes.join(\" \");\n\tparent.insertBefore(domNode,nextSibling);\n\tthis.renderChildren(domNode,null);\n\tif(!domNode.isTiddlyWikiFakeDom && this.type === \"popup\" && this.isOpen) {\n\t\tthis.positionPopup(domNode);\n\t\t$tw.utils.addClass(domNode,\"tw-popup\"); // Make sure that clicks don't dismiss popups within the revealed content\n\t}\n\tif(!this.isOpen) {\n\t\tdomNode.setAttribute(\"hidden\",\"true\")\n\t}\n\tthis.domNodes.push(domNode);\n};\n\nRevealWidget.prototype.positionPopup = function(domNode) {\n\tdomNode.style.position = \"absolute\";\n\tdomNode.style.zIndex = \"1000\";\n\tswitch(this.position) {\n\t\tcase \"left\":\n\t\t\tdomNode.style.left = (this.popup.left - domNode.offsetWidth) + \"px\";\n\t\t\tdomNode.style.top = this.popup.top + \"px\";\n\t\t\tbreak;\n\t\tcase \"above\":\n\t\t\tdomNode.style.left = this.popup.left + \"px\";\n\t\t\tdomNode.style.top = (this.popup.top - domNode.offsetHeight) + \"px\";\n\t\t\tbreak;\n\t\tcase \"aboveright\":\n\t\t\tdomNode.style.left = (this.popup.left + this.popup.width) + \"px\";\n\t\t\tdomNode.style.top = (this.popup.top + this.popup.height - domNode.offsetHeight) + \"px\";\n\t\t\tbreak;\n\t\tcase \"right\":\n\t\t\tdomNode.style.left = (this.popup.left + this.popup.width) + \"px\";\n\t\t\tdomNode.style.top = this.popup.top + \"px\";\n\t\t\tbreak;\n\t\tcase \"belowleft\":\n\t\t\tdomNode.style.left = (this.popup.left + this.popup.width - domNode.offsetWidth) + \"px\";\n\t\t\tdomNode.style.top = (this.popup.top + this.popup.height) + \"px\";\n\t\t\tbreak;\n\t\tdefault: // Below\n\t\t\tdomNode.style.left = this.popup.left + \"px\";\n\t\t\tdomNode.style.top = (this.popup.top + this.popup.height) + \"px\";\n\t\t\tbreak;\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nRevealWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.state = this.getAttribute(\"state\");\n\tthis.type = this.getAttribute(\"type\");\n\tthis.text = this.getAttribute(\"text\");\n\tthis.position = this.getAttribute(\"position\");\n\tthis[\"class\"] = this.getAttribute(\"class\",\"\");\n\tthis[\"default\"] = this.getAttribute(\"default\",\"\");\n\tthis.animate = this.getAttribute(\"animate\",\"no\");\n\tthis.retain = this.getAttribute(\"retain\",\"no\");\n\tthis.openAnimation = this.animate === \"no\" ? undefined : \"open\";\n\tthis.closeAnimation = this.animate === \"no\" ? undefined : \"close\";\n\t// Compute the title of the state tiddler and read it\n\tthis.stateTitle = this.state;\n\tthis.readState();\n\t// Construct the child widgets\n\tvar childNodes = this.isOpen ? this.parseTreeNode.children : [];\n\tthis.hasChildNodes = this.isOpen;\n\tthis.makeChildWidgets(childNodes);\n};\n\n/*\nRead the state tiddler\n*/\nRevealWidget.prototype.readState = function() {\n\t// Read the information from the state tiddler\n\tif(this.stateTitle) {\n\t\tvar state = this.wiki.getTextReference(this.stateTitle,this[\"default\"],this.getVariable(\"currentTiddler\"));\n\t\tswitch(this.type) {\n\t\t\tcase \"popup\":\n\t\t\t\tthis.readPopupState(state);\n\t\t\t\tbreak;\n\t\t\tcase \"match\":\n\t\t\t\tthis.readMatchState(state);\n\t\t\t\tbreak;\n\t\t\tcase \"nomatch\":\n\t\t\t\tthis.readMatchState(state);\n\t\t\t\tthis.isOpen = !this.isOpen;\n\t\t\t\tbreak;\n\t\t}\n\t}\n};\n\nRevealWidget.prototype.readMatchState = function(state) {\n\tthis.isOpen = state === this.text;\n};\n\nRevealWidget.prototype.readPopupState = function(state) {\n\tvar popupLocationRegExp = /^\\((-?[0-9\\.E]+),(-?[0-9\\.E]+),(-?[0-9\\.E]+),(-?[0-9\\.E]+)\\)$/,\n\t\tmatch = popupLocationRegExp.exec(state);\n\t// Check if the state matches the location regexp\n\tif(match) {\n\t\t// If so, we're open\n\t\tthis.isOpen = true;\n\t\t// Get the location\n\t\tthis.popup = {\n\t\t\tleft: parseFloat(match[1]),\n\t\t\ttop: parseFloat(match[2]),\n\t\t\twidth: parseFloat(match[3]),\n\t\t\theight: parseFloat(match[4])\n\t\t};\n\t} else {\n\t\t// If not, we're closed\n\t\tthis.isOpen = false;\n\t}\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nRevealWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes[\"default\"] || changedAttributes.animate) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\tvar refreshed = false,\n\t\t\tcurrentlyOpen = this.isOpen;\n\t\tthis.readState();\n\t\tif(this.isOpen !== currentlyOpen) {\n\t\t\tif(this.retain === \"yes\") {\n\t\t\t\tthis.updateState();\n\t\t\t} else {\n\t\t\t\tthis.refreshSelf();\n\t\t\t\trefreshed = true;\n\t\t\t}\n\t\t}\n\t\treturn this.refreshChildren(changedTiddlers) || refreshed;\n\t}\n};\n\n/*\nCalled by refresh() to dynamically show or hide the content\n*/\nRevealWidget.prototype.updateState = function() {\n\t// Read the current state\n\tthis.readState();\n\t// Construct the child nodes if needed\n\tvar domNode = this.domNodes[0];\n\tif(this.isOpen && !this.hasChildNodes) {\n\t\tthis.hasChildNodes = true;\n\t\tthis.makeChildWidgets(this.parseTreeNode.children);\n\t\tthis.renderChildren(domNode,null);\n\t}\n\t// Animate our DOM node\n\tif(!domNode.isTiddlyWikiFakeDom && this.type === \"popup\" && this.isOpen) {\n\t\tthis.positionPopup(domNode);\n\t\t$tw.utils.addClass(domNode,\"tw-popup\"); // Make sure that clicks don't dismiss popups within the revealed content\n\n\t}\n\tif(this.isOpen) {\n\t\tdomNode.removeAttribute(\"hidden\");\n $tw.anim.perform(this.openAnimation,domNode);\n\t} else {\n\t\t$tw.anim.perform(this.closeAnimation,domNode,{callback: function() {\n\t\t\tdomNode.setAttribute(\"hidden\",\"true\");\n }});\n\t}\n};\n\nexports.reveal = RevealWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/reveal.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/scrollable.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/scrollable.js\ntype: application/javascript\nmodule-type: widget\n\nScrollable widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar ScrollableWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n\tthis.scaleFactor = 1;\n\tthis.addEventListeners([\n\t\t{type: \"tw-scroll\", handler: \"handleScrollEvent\"}\n\t]);\n\tif($tw.browser) {\n\t\tthis.requestAnimationFrame = window.requestAnimationFrame ||\n\t\t\twindow.webkitRequestAnimationFrame ||\n\t\t\twindow.mozRequestAnimationFrame ||\n\t\t\tfunction(callback) {\n\t\t\t\treturn window.setTimeout(callback, 1000/60);\n\t\t\t};\n\t\tthis.cancelAnimationFrame = window.cancelAnimationFrame ||\n\t\t\twindow.webkitCancelAnimationFrame ||\n\t\t\twindow.webkitCancelRequestAnimationFrame ||\n\t\t\twindow.mozCancelAnimationFrame ||\n\t\t\twindow.mozCancelRequestAnimationFrame ||\n\t\t\tfunction(id) {\n\t\t\t\twindow.clearTimeout(id);\n\t\t\t};\n\t}\n};\n\n/*\nInherit from the base widget class\n*/\nScrollableWidget.prototype = new Widget();\n\nScrollableWidget.prototype.cancelScroll = function() {\n\tif(this.idRequestFrame) {\n\t\tthis.cancelAnimationFrame.call(window,this.idRequestFrame);\n\t\tthis.idRequestFrame = null;\n\t}\n};\n\n/*\nHandle a scroll event\n*/\nScrollableWidget.prototype.handleScrollEvent = function(event) {\n\t// Pass the scroll event through if our offsetsize is larger than our scrollsize\n\tif(this.outerDomNode.scrollWidth <= this.outerDomNode.offsetWidth && this.outerDomNode.scrollHeight <= this.outerDomNode.offsetHeight && this.fallthrough === \"yes\") {\n\t\treturn true;\n\t}\n\tthis.scrollIntoView(event.target);\n\treturn false; // Handled event\n};\n\n/*\nScroll an element into view\n*/\nScrollableWidget.prototype.scrollIntoView = function(element) {\n\tvar duration = $tw.utils.getAnimationDuration();\n\tthis.cancelScroll();\n\tthis.startTime = Date.now();\n\tvar scrollPosition = {\n\t\tx: this.outerDomNode.scrollLeft,\n\t\ty: this.outerDomNode.scrollTop\n\t};\n\t// Get the client bounds of the element and adjust by the scroll position\n\tvar scrollableBounds = this.outerDomNode.getBoundingClientRect(),\n\t\tclientTargetBounds = element.getBoundingClientRect(),\n\t\tbounds = {\n\t\t\tleft: clientTargetBounds.left + scrollPosition.x - scrollableBounds.left,\n\t\t\ttop: clientTargetBounds.top + scrollPosition.y - scrollableBounds.top,\n\t\t\twidth: clientTargetBounds.width,\n\t\t\theight: clientTargetBounds.height\n\t\t};\n\t// We'll consider the horizontal and vertical scroll directions separately via this function\n\tvar getEndPos = function(targetPos,targetSize,currentPos,currentSize) {\n\t\t\t// If the target is already visible then stay where we are\n\t\t\tif(targetPos >= currentPos && (targetPos + targetSize) <= (currentPos + currentSize)) {\n\t\t\t\treturn currentPos;\n\t\t\t// If the target is above/left of the current view, then scroll to its top/left\n\t\t\t} else if(targetPos <= currentPos) {\n\t\t\t\treturn targetPos;\n\t\t\t// If the target is smaller than the window and the scroll position is too far up, then scroll till the target is at the bottom of the window\n\t\t\t} else if(targetSize < currentSize && currentPos < (targetPos + targetSize - currentSize)) {\n\t\t\t\treturn targetPos + targetSize - currentSize;\n\t\t\t// If the target is big, then just scroll to the top\n\t\t\t} else if(currentPos < targetPos) {\n\t\t\t\treturn targetPos;\n\t\t\t// Otherwise, stay where we are\n\t\t\t} else {\n\t\t\t\treturn currentPos;\n\t\t\t}\n\t\t},\n\t\tendX = getEndPos(bounds.left,bounds.width,scrollPosition.x,this.outerDomNode.offsetWidth),\n\t\tendY = getEndPos(bounds.top,bounds.height,scrollPosition.y,this.outerDomNode.offsetHeight);\n\t// Only scroll if necessary\n\tif(endX !== scrollPosition.x || endY !== scrollPosition.y) {\n\t\tvar self = this,\n\t\t\tdrawFrame;\n\t\tdrawFrame = function () {\n\t\t\tvar t;\n\t\t\tif(duration <= 0) {\n\t\t\t\tt = 1;\n\t\t\t} else {\n\t\t\t\tt = ((Date.now()) - self.startTime) / duration;\t\n\t\t\t}\n\t\t\tif(t >= 1) {\n\t\t\t\tself.cancelScroll();\n\t\t\t\tt = 1;\n\t\t\t}\n\t\t\tt = $tw.utils.slowInSlowOut(t);\n\t\t\tself.outerDomNode.scrollLeft = scrollPosition.x + (endX - scrollPosition.x) * t;\n\t\t\tself.outerDomNode.scrollTop = scrollPosition.y + (endY - scrollPosition.y) * t;\n\t\t\tif(t < 1) {\n\t\t\t\tself.idRequestFrame = self.requestAnimationFrame.call(window,drawFrame);\n\t\t\t}\n\t\t};\n\t\tdrawFrame();\n\t}\n};\n\n/*\nRender this widget into the DOM\n*/\nScrollableWidget.prototype.render = function(parent,nextSibling) {\n\tvar self = this;\n\t// Remember parent\n\tthis.parentDomNode = parent;\n\t// Compute attributes and execute state\n\tthis.computeAttributes();\n\tthis.execute();\n\t// Create elements\n\tthis.outerDomNode = this.document.createElement(\"div\");\n\t$tw.utils.setStyle(this.outerDomNode,[\n\t\t{overflowY: \"auto\"},\n\t\t{overflowX: \"auto\"},\n\t\t{webkitOverflowScrolling: \"touch\"}\n\t]);\n\tthis.innerDomNode = this.document.createElement(\"div\");\n\tthis.outerDomNode.appendChild(this.innerDomNode);\n\t// Assign classes\n\tthis.outerDomNode.className = this[\"class\"] || \"\";\n\t// Insert element\n\tparent.insertBefore(this.outerDomNode,nextSibling);\n\tthis.renderChildren(this.innerDomNode,null);\n\tthis.domNodes.push(this.outerDomNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nScrollableWidget.prototype.execute = function() {\n\t// Get attributes\n\tthis.fallthrough = this.getAttribute(\"fallthrough\",\"yes\");\n\tthis[\"class\"] = this.getAttribute(\"class\");\n\t// Make child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nScrollableWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes[\"class\"]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t}\n\treturn this.refreshChildren(changedTiddlers);\n};\n\nexports.scrollable = ScrollableWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/scrollable.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/set.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/set.js\ntype: application/javascript\nmodule-type: widget\n\nSet variable widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar SetWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nSetWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nSetWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nSetWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.setName = this.getAttribute(\"name\",\"currentTiddler\");\n\tthis.setValue = this.getAttribute(\"value\");\n\t// Set context variable\n\tthis.setVariable(this.setName,this.setValue,this.parseTreeNode.params);\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nSetWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.name || changedAttributes.value) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nexports.setvariable = SetWidget;\nexports.set = SetWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/set.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/filters/storyviews.js": {
"text": "/*\\\ntitle: $:/core/modules/filters/storyviews.js\ntype: application/javascript\nmodule-type: filteroperator\n\nFilter operator for returning the names of the story views in this wiki\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter function\n*/\nexports.storyviews = function(source,operator,options) {\n\tvar results = [],\n\t\tstoryviews = {};\n\t$tw.modules.applyMethods(\"storyview\",storyviews);\n\t$tw.utils.each(storyviews,function(info,name) {\n\t\tresults.push(name);\n\t});\n\tresults.sort();\n\treturn results;\n};\n\n})();\n",
"title": "$:/core/modules/filters/storyviews.js",
"type": "application/javascript",
"module-type": "filteroperator"
},
"$:/core/modules/widgets/text.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/text.js\ntype: application/javascript\nmodule-type: widget\n\nText node widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar TextNodeWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nTextNodeWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nTextNodeWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tvar text = this.getAttribute(\"text\",this.parseTreeNode.text),\n\t\ttextNode = this.document.createTextNode(text);\n\tparent.insertBefore(textNode,nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\n/*\nCompute the internal state of the widget\n*/\nTextNodeWidget.prototype.execute = function() {\n\t// Nothing to do for a text node\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nTextNodeWidget.prototype.refresh = function(changedTiddlers) {\n\treturn false;\n};\n\nexports.text = TextNodeWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/text.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/tiddler.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/tiddler.js\ntype: application/javascript\nmodule-type: widget\n\nTiddler widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar TiddlerWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nTiddlerWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nTiddlerWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nTiddlerWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.tiddlerTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\t// Set context variables\n\tthis.setVariable(\"currentTiddler\",this.tiddlerTitle);\n\tthis.setVariable(\"missingTiddlerClass\",(this.wiki.tiddlerExists(this.tiddlerTitle) || this.wiki.isShadowTiddler(this.tiddlerTitle)) ? \"tw-tiddler-exists\" : \"tw-tiddler-missing\");\n\tthis.setVariable(\"shadowTiddlerClass\",this.wiki.isShadowTiddler(this.tiddlerTitle) ? \"tw-tiddler-shadow\" : \"\");\n\tthis.setVariable(\"systemTiddlerClass\",this.wiki.isSystemTiddler(this.tiddlerTitle) ? \"tw-tiddler-system\" : \"\");\n\t// Construct the child widgets\n\tthis.makeChildWidgets();\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nTiddlerWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nexports.tiddler = TiddlerWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/tiddler.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/transclude.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/transclude.js\ntype: application/javascript\nmodule-type: widget\n\nTransclude widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar TranscludeWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nTranscludeWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nTranscludeWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nTranscludeWidget.prototype.execute = function() {\n\t// Get our parameters\n\tthis.transcludeTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.transcludeField = this.getAttribute(\"field\");\n\tthis.transcludeIndex = this.getAttribute(\"index\");\n\tthis.transcludeMode = this.getAttribute(\"mode\");\n\t// Check for recursion\n\tvar recursionMarker = this.makeRecursionMarker();;\n\tif(this.parentWidget && this.parentWidget.hasVariable(\"transclusion\",recursionMarker)) {\n\t\tthis.makeChildWidgets([{type: \"text\", text: \"Recursive transclusion error in transclude widget\"}]);\n\t\treturn;\n\t}\n\t// Set context variables for recursion detection\n\tthis.setVariable(\"transclusion\",recursionMarker);\n\t// Parse the text reference\n\tvar parseAsInline = !this.parseTreeNode.isBlock;\n\tif(this.transcludeMode === \"inline\") {\n\t\tparseAsInline = true;\n\t} else if(this.transcludeMode === \"block\") {\n\t\tparseAsInline = false;\n\t}\n\tvar parser = this.wiki.parseTextReference(\n\t\t\t\t\t\tthis.transcludeTitle,\n\t\t\t\t\t\tthis.transcludeField,\n\t\t\t\t\t\tthis.transcludeIndex,\n\t\t\t\t\t\t{parseAsInline: parseAsInline}),\n\t\tparseTreeNodes = parser ? parser.tree : this.parseTreeNode.children;\n\t// Construct the child widgets\n\tthis.makeChildWidgets(parseTreeNodes);\n};\n\n/*\nCompose a string comprising the title, field and/or index to identify this transclusion for recursion detection\n*/\nTranscludeWidget.prototype.makeRecursionMarker = function() {\n\tvar output = [];\n\toutput.push(\"{\");\n\toutput.push(this.getVariable(\"currentTiddler\",{defaultValue: \"\"}));\n\toutput.push(\"|\");\n\toutput.push(this.transcludeTitle || \"\");\n\toutput.push(\"|\");\n\toutput.push(this.transcludeField || \"\");\n\toutput.push(\"|\");\n\toutput.push(this.transcludeIndex || \"\");\n\toutput.push(\"}\");\n\treturn output.join(\"\");\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nTranscludeWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedTiddlers[this.transcludeTitle]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn this.refreshChildren(changedTiddlers);\t\t\n\t}\n};\n\nexports.transclude = TranscludeWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/transclude.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/view.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/view.js\ntype: application/javascript\nmodule-type: widget\n\nView widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nvar ViewWidget = function(parseTreeNode,options) {\n\tthis.initialise(parseTreeNode,options);\n};\n\n/*\nInherit from the base widget class\n*/\nViewWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nViewWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.computeAttributes();\n\tthis.execute();\n\tif(this.text) {\n\t\tvar textNode = this.document.createTextNode(this.text);\n\t\tparent.insertBefore(textNode,nextSibling);\n\t\tthis.domNodes.push(textNode);\n\t} else {\n\t\tthis.makeChildWidgets();\n\t\tthis.renderChildren(parent,nextSibling);\n\t}\n};\n\n/*\nCompute the internal state of the widget\n*/\nViewWidget.prototype.execute = function() {\n\t// Get parameters from our attributes\n\tthis.viewTitle = this.getAttribute(\"tiddler\",this.getVariable(\"currentTiddler\"));\n\tthis.viewField = this.getAttribute(\"field\",\"text\");\n\tthis.viewIndex = this.getAttribute(\"index\");\n\tthis.viewFormat = this.getAttribute(\"format\",\"text\");\n\tthis.viewTemplate = this.getAttribute(\"template\",\"\");\n\tswitch(this.viewFormat) {\n\t\tcase \"htmlwikified\":\n\t\t\tthis.text = this.getValueAsHtmlWikified();\n\t\t\tbreak;\n\t\tcase \"htmlencoded\":\n\t\t\tthis.text = this.getValueAsHtmlEncoded();\n\t\t\tbreak;\n\t\tcase \"urlencoded\":\n\t\t\tthis.text = this.getValueAsUrlEncoded();\n\t\t\tbreak;\n\t\tcase \"doubleurlencoded\":\n\t\t\tthis.text = this.getValueAsDoubleUrlEncoded();\n\t\t\tbreak;\n\t\tcase \"date\":\n\t\t\tthis.text = this.getValueAsDate(this.viewTemplate);\n\t\t\tbreak;\n\t\tcase \"relativedate\":\n\t\t\tthis.text = this.getValueAsRelativeDate();\n\t\t\tbreak;\n\t\tcase \"stripcomments\":\n\t\t\tthis.text = this.getValueAsStrippedComments();\n\t\t\tbreak;\n\t\tcase \"jsencoded\":\n\t\t\tthis.text = this.getValueAsJsEncoded();\n\t\t\tbreak;\n\t\tdefault: // \"text\"\n\t\t\tthis.text = this.getValueAsText();\n\t\t\tbreak;\n\t}\n};\n\n/*\nThe various formatter functions are baked into this widget for the moment. Eventually they will be replaced by macro functions\n*/\n\n/*\nRetrieve the value of the widget. Options are:\nasString: Optionally return the value as a string\n*/\nViewWidget.prototype.getValue = function(options) {\n\toptions = options || {};\n\tvar value = options.asString ? \"\" : undefined;\n\tif(this.viewIndex) {\n\t\tvalue = this.wiki.extractTiddlerDataItem(this.viewTitle,this.viewIndex);\n\t} else {\n\t\tvar tiddler = this.wiki.getTiddler(this.viewTitle);\n\t\tif(tiddler) {\n\t\t\tif(this.viewField === \"text\") {\n\t\t\t\t// Calling getTiddlerText() triggers lazy loading of skinny tiddlers\n\t\t\t\tvalue = this.wiki.getTiddlerText(this.viewTitle);\n\t\t\t} else {\n\t\t\t\tif($tw.utils.hop(tiddler.fields,this.viewField)) {\n\t\t\t\t\tif(options.asString) {\n\t\t\t\t\t\tvalue = tiddler.getFieldString(this.viewField);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = tiddler.fields[this.viewField];\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif(this.viewField === \"title\") {\n\t\t\t\tvalue = this.viewTitle;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n};\n\nViewWidget.prototype.getValueAsText = function() {\n\treturn this.getValue({asString: true});\n};\n\nViewWidget.prototype.getValueAsHtmlWikified = function() {\n\treturn this.wiki.renderText(\"text/html\",\"text/vnd.tiddlywiki\",this.getValueAsText(),{parentWidget: this});\n};\n\nViewWidget.prototype.getValueAsHtmlEncoded = function() {\n\treturn $tw.utils.htmlEncode(this.getValueAsText());\n};\n\nViewWidget.prototype.getValueAsUrlEncoded = function() {\n\treturn encodeURIComponent(this.getValueAsText());\n};\n\nViewWidget.prototype.getValueAsDoubleUrlEncoded = function() {\n\treturn encodeURIComponent(encodeURIComponent(this.getValueAsText()));\n};\n\nViewWidget.prototype.getValueAsDate = function(format) {\n\tformat = format || \"YYYY MM DD 0hh:0mm\";\n\tvar value = $tw.utils.parseDate(this.getValue());\n\tif(value && $tw.utils.isDate(value) && value.toString() !== \"Invalid Date\") {\n\t\treturn $tw.utils.formatDateString(value,format);\n\t} else {\n\t\treturn \"\";\n\t}\n};\n\nViewWidget.prototype.getValueAsRelativeDate = function(format) {\n\tvar value = $tw.utils.parseDate(this.getValue());\n\tif(value && $tw.utils.isDate(value) && value.toString() !== \"Invalid Date\") {\n\t\treturn $tw.utils.getRelativeDate((new Date()) - (new Date(value))).description;\n\t} else {\n\t\treturn \"\";\n\t}\n};\n\nViewWidget.prototype.getValueAsStrippedComments = function() {\n\tvar lines = this.getValueAsText().split(\"\\n\"),\n\t\tout = [];\n\tfor(var line=0; line<lines.length; line++) {\n\t\tvar text = lines[line];\n\t\tif(!/^\\s*\\/\\/#/.test(text)) {\n\t\t\tout.push(text);\n\t\t}\n\t}\n\treturn out.join(\"\\n\");\n};\n\nViewWidget.prototype.getValueAsJsEncoded = function() {\n\treturn $tw.utils.stringify(this.getValueAsText());\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nViewWidget.prototype.refresh = function(changedTiddlers) {\n\tvar changedAttributes = this.computeAttributes();\n\tif(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.template || changedAttributes.format || changedTiddlers[this.viewTitle]) {\n\t\tthis.refreshSelf();\n\t\treturn true;\n\t} else {\n\t\treturn false;\t\n\t}\n};\n\nexports.view = ViewWidget;\n\n})();\n",
"title": "$:/core/modules/widgets/view.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/widgets/widget.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/widget.js\ntype: application/javascript\nmodule-type: widget\n\nWidget base class\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nCreate a widget object for a parse tree node\n\tparseTreeNode: reference to the parse tree node to be rendered\n\toptions: see below\nOptions include:\n\twiki: mandatory reference to wiki associated with this render tree\n\tvariables: optional hashmap of context variables (see below)\n\tparentWidget: optional reference to a parent renderer node for the context chain\n\tdocument: optional document object to use instead of global document\nContext variables include:\n\tcurrentTiddler: title of the tiddler providing the context\n*/\nvar Widget = function(parseTreeNode,options) {\n\tif(arguments.length > 0) {\n\t\tthis.initialise(parseTreeNode,options);\n\t}\n};\n\n/*\nInitialise widget properties. These steps are pulled out of the constructor so that we can reuse them in subclasses\n*/\nWidget.prototype.initialise = function(parseTreeNode,options) {\n\toptions = options || {};\n\t// Save widget info\n\tthis.parseTreeNode = parseTreeNode;\n\tthis.wiki = options.wiki;\n\tthis.parentWidget = options.parentWidget;\n\tthis.variablesConstructor = function() {};\n\tthis.variablesConstructor.prototype = this.parentWidget ? this.parentWidget.variables : {};\n\tthis.variables = new this.variablesConstructor();\n\tthis.document = options.document;\n\tthis.attributes = {};\n\tthis.children = [];\n\tthis.domNodes = [];\n\tthis.eventListeners = {};\n\t// Hashmap of the widget classes\n\tif(!this.widgetClasses) {\n\t\tWidget.prototype.widgetClasses = $tw.modules.applyMethods(\"widget\");\n\t}\n};\n\n/*\nRender this widget into the DOM\n*/\nWidget.prototype.render = function(parent,nextSibling) {\n\tthis.parentDomNode = parent;\n\tthis.execute();\n\tthis.renderChildren(parent,nextSibling);\n};\n\n/*\nCompute the internal state of the widget\n*/\nWidget.prototype.execute = function() {\n\tthis.makeChildWidgets();\n};\n\n/*\nSet the value of a context variable\nname: name of the variable\nvalue: value of the variable\nparams: array of {name:, default:} for each parameter\n*/\nWidget.prototype.setVariable = function(name,value,params) {\n\tthis.variables[name] = {value: value, params: params};\n};\n\n/*\nGet the prevailing value of a context variable\nname: name of variable\noptions: see below\nOptions include\nparams: array of {name:, value:} for each parameter\ndefaultValue: default value if the variable is not defined\n*/\nWidget.prototype.getVariable = function(name,options) {\n\toptions = options || {};\n\tvar actualParams = options.params || [],\n\t\tparentWidget = this.parentWidget;\n\t// Check for the variable defined in the parent widget (or an ancestor in the prototype chain)\n\tif(parentWidget && name in parentWidget.variables) {\n\t\tvar variable = parentWidget.variables[name],\n\t\t\tvalue = variable.value;\n\t\t// Substitute any parameters specified in the definition\n\t\tvalue = this.substituteVariableParameters(value,variable.params,actualParams);\n\t\tvalue = this.substituteVariableReferences(value);\n\t\treturn value;\n\t}\n\t// If the variable doesn't exist in the parent widget then look for a macro module\n\treturn this.evaluateMacroModule(name,actualParams,options.defaultValue);\n};\n\nWidget.prototype.substituteVariableParameters = function(text,formalParams,actualParams) {\n\tif(formalParams) {\n\t\tvar nextAnonParameter = 0, // Next candidate anonymous parameter in macro call\n\t\t\tparamInfo, paramValue;\n\t\t// Step through each of the parameters in the macro definition\n\t\tfor(var p=0; p<formalParams.length; p++) {\n\t\t\t// Check if we've got a macro call parameter with the same name\n\t\t\tparamInfo = formalParams[p];\n\t\t\tparamValue = undefined;\n\t\t\tfor(var m=0; m<actualParams.length; m++) {\n\t\t\t\tif(actualParams[m].name === paramInfo.name) {\n\t\t\t\t\tparamValue = actualParams[m].value;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If not, use the next available anonymous macro call parameter\n\t\t\twhile(nextAnonParameter < actualParams.length && actualParams[nextAnonParameter].name) {\n\t\t\t\tnextAnonParameter++;\n\t\t\t}\n\t\t\tif(paramValue === undefined && nextAnonParameter < actualParams.length) {\n\t\t\t\tparamValue = actualParams[nextAnonParameter++].value;\n\t\t\t}\n\t\t\t// If we've still not got a value, use the default, if any\n\t\t\tparamValue = paramValue || paramInfo[\"default\"] || \"\";\n\t\t\t// Replace any instances of this parameter\n\t\t\ttext = text.replace(new RegExp(\"\\\\$\" + $tw.utils.escapeRegExp(paramInfo.name) + \"\\\\$\",\"mg\"),paramValue);\n\t\t}\n\t}\n\treturn text;\n};\n\nWidget.prototype.substituteVariableReferences = function(text) {\n\tvar self = this;\n\treturn text.replace(/\\$\\(([^\\)\\$]+)\\)\\$/g,function(match,p1,offset,string) {\n\t\treturn self.getVariable(p1,{defaultValue: \"\"});\n\t});\n};\n\nWidget.prototype.evaluateMacroModule = function(name,actualParams,defaultValue) {\n\tif($tw.utils.hop($tw.macros,name)) {\n\t\tvar macro = $tw.macros[name],\n\t\t\targs = [];\n\t\tif(macro.params.length > 0) {\n\t\t\tvar nextAnonParameter = 0, // Next candidate anonymous parameter in macro call\n\t\t\t\tparamInfo, paramValue;\n\t\t\t// Step through each of the parameters in the macro definition\n\t\t\tfor(var p=0; p<macro.params.length; p++) {\n\t\t\t\t// Check if we've got a macro call parameter with the same name\n\t\t\t\tparamInfo = macro.params[p];\n\t\t\t\tparamValue = undefined;\n\t\t\t\tfor(var m=0; m<actualParams.length; m++) {\n\t\t\t\t\tif(actualParams[m].name === paramInfo.name) {\n\t\t\t\t\t\tparamValue = actualParams[m].value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If not, use the next available anonymous macro call parameter\n\t\t\t\twhile(nextAnonParameter < actualParams.length && actualParams[nextAnonParameter].name) {\n\t\t\t\t\tnextAnonParameter++;\n\t\t\t\t}\n\t\t\t\tif(paramValue === undefined && nextAnonParameter < actualParams.length) {\n\t\t\t\t\tparamValue = actualParams[nextAnonParameter++].value;\n\t\t\t\t}\n\t\t\t\t// If we've still not got a value, use the default, if any\n\t\t\t\tparamValue = paramValue || paramInfo[\"default\"] || \"\";\n\t\t\t\t// Save the parameter\n\t\t\t\targs.push(paramValue);\n\t\t\t}\n\t\t}\n\t\telse for(var i=0; i<actualParams.length; ++i) {\n\t\t\targs.push(actualParams[i].value);\n\t\t}\n\t\treturn macro.run.apply(this,args)\n\t} else {\n\t\treturn defaultValue;\n\t}\n};\n\n/*\nCheck whether a given context variable value exists in the parent chain\n*/\nWidget.prototype.hasVariable = function(name,value) {\n\tvar node = this;\n\twhile(node) {\n\t\tif($tw.utils.hop(node.variables,name) && node.variables[name].value === value) {\n\t\t\treturn true;\n\t\t}\n\t\tnode = node.parentWidget;\n\t}\n\treturn false;\n};\n\n/*\nConstruct a qualifying string based on a hash of concatenating the values of a given variable in the parent chain\n*/\nWidget.prototype.getStateQualifier = function(name) {\n\tname = name || \"transclusion\";\n\tvar output = [],\n\t\tnode = this;\n\twhile(node && node.parentWidget) {\n\t\tif($tw.utils.hop(node.parentWidget.variables,name)) {\n\t\t\toutput.push(node.getVariable(name));\n\t\t}\n\t\tnode = node.parentWidget;\n\t}\n\treturn \"{\" + $tw.utils.hashString(output.join(\"\")) + \"}\";\n};\n\n/*\nCompute the current values of the attributes of the widget. Returns a hashmap of the names of the attributes that have changed\n*/\nWidget.prototype.computeAttributes = function() {\n\tvar changedAttributes = {},\n\t\tself = this,\n\t\tvalue;\n\t$tw.utils.each(this.parseTreeNode.attributes,function(attribute,name) {\n\t\tif(attribute.type === \"indirect\") {\n\t\t\tvalue = self.wiki.getTextReference(attribute.textReference,\"\",self.getVariable(\"currentTiddler\"));\n\t\t} else if(attribute.type === \"macro\") {\n\t\t\tvalue = self.getVariable(attribute.value.name,{params: attribute.value.params});\n\t\t} else { // String attribute\n\t\t\tvalue = attribute.value;\n\t\t}\n\t\t// Check whether the attribute has changed\n\t\tif(self.attributes[name] !== value) {\n\t\t\tself.attributes[name] = value;\n\t\t\tchangedAttributes[name] = true;\n\t\t}\n\t});\n\treturn changedAttributes;\n};\n\n/*\nCheck for the presence of an attribute\n*/\nWidget.prototype.hasAttribute = function(name) {\n\treturn $tw.utils.hop(this.attributes,name);\n};\n\n/*\nGet the value of an attribute\n*/\nWidget.prototype.getAttribute = function(name,defaultText) {\n\tif($tw.utils.hop(this.attributes,name)) {\n\t\treturn this.attributes[name];\n\t} else {\n\t\treturn defaultText;\n\t}\n};\n\n/*\nAssign the computed attributes of the widget to a domNode\noptions include:\nexcludeEventAttributes: ignores attributes whose name begins with \"on\"\n*/\nWidget.prototype.assignAttributes = function(domNode,options) {\n\toptions = options || {};\n\tvar self = this;\n\t$tw.utils.each(this.attributes,function(v,a) {\n\t\t// Check exclusions\n\t\tif(options.excludeEventAttributes && a.substr(0,2) === \"on\") {\n\t\t\tv = undefined;\n\t\t}\n\t\tif(v !== undefined) {\n\t\t\t// Setting certain attributes can cause a DOM error (eg xmlns on the svg element)\n\t\t\ttry {\n\t\t\t\tdomNode.setAttributeNS(null,a,v);\n\t\t\t} catch(e) {\n\t\t\t}\n\t\t}\n\t});\n};\n\n/*\nMake child widgets correspondng to specified parseTreeNodes\n*/\nWidget.prototype.makeChildWidgets = function(parseTreeNodes) {\n\tthis.children = [];\n\tvar self = this;\n\t$tw.utils.each(parseTreeNodes || (this.parseTreeNode && this.parseTreeNode.children),function(childNode) {\n\t\tself.children.push(self.makeChildWidget(childNode));\n\t});\n};\n\n/*\nConstruct the widget object for a parse tree node\n*/\nWidget.prototype.makeChildWidget = function(parseTreeNode) {\n\tvar WidgetClass = this.widgetClasses[parseTreeNode.type];\n\tif(!WidgetClass) {\n\t\tWidgetClass = this.widgetClasses[\"text\"];\n\t\tparseTreeNode = {type: \"text\", text: \"Undefined widget '\" + parseTreeNode.type + \"'\"};\n\t}\n\treturn new WidgetClass(parseTreeNode,{\n\t\twiki: this.wiki,\n\t\tvariables: {},\n\t\tparentWidget: this,\n\t\tdocument: this.document\n\t});\n};\n\n/*\nGet the next sibling of this widget\n*/\nWidget.prototype.nextSibling = function() {\n\tif(this.parentWidget) {\n\t\tvar index = this.parentWidget.children.indexOf(this);\n\t\tif(index !== -1 && index < this.parentWidget.children.length-1) {\n\t\t\treturn this.parentWidget.children[index+1];\n\t\t}\n\t}\n\treturn null;\n};\n\n/*\nGet the previous sibling of this widget\n*/\nWidget.prototype.previousSibling = function() {\n\tif(this.parentWidget) {\n\t\tvar index = this.parentWidget.children.indexOf(this);\n\t\tif(index !== -1 && index > 0) {\n\t\t\treturn this.parentWidget.children[index-1];\n\t\t}\n\t}\n\treturn null;\n};\n\n/*\nRender the children of this widget into the DOM\n*/\nWidget.prototype.renderChildren = function(parent,nextSibling) {\n\t$tw.utils.each(this.children,function(childWidget) {\n\t\tchildWidget.render(parent,nextSibling);\n\t});\n};\n\n/*\nAdd a list of event listeners from an array [{type:,handler:},...]\n*/\nWidget.prototype.addEventListeners = function(listeners) {\n\tvar self = this;\n\t$tw.utils.each(listeners,function(listenerInfo) {\n\t\tself.addEventListener(listenerInfo.type,listenerInfo.handler);\n\t});\n};\n\n/*\nAdd an event listener\n*/\nWidget.prototype.addEventListener = function(type,handler) {\n\tvar self = this;\n\tif(typeof handler === \"string\") { // The handler is a method name on this widget\n\t\tthis.eventListeners[type] = function(event) {\n\t\t\treturn self[handler].call(self,event);\n\t\t};\n\t} else { // The handler is a function\n\t\tthis.eventListeners[type] = function(event) {\n\t\t\treturn handler.call(self,event);\n\t\t}\n\n\t}\n};\n\n/*\nDispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget\n*/\nWidget.prototype.dispatchEvent = function(event) {\n\t// Dispatch the event if this widget handles it\n\tvar listener = this.eventListeners[event.type];\n\tif(listener) {\n\t\t// Don't propagate the event if the listener returned false\n\t\tif(!listener(event)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\t// Dispatch the event to the parent widget\n\tif(this.parentWidget) {\n\t\treturn this.parentWidget.dispatchEvent(event);\n\t}\n\treturn true;\n};\n\n/*\nSelectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n*/\nWidget.prototype.refresh = function(changedTiddlers) {\n\treturn this.refreshChildren(changedTiddlers);\n};\n\n/*\nRebuild a previously rendered widget\n*/\nWidget.prototype.refreshSelf = function() {\n\tvar nextSibling = this.findNextSiblingDomNode();\n\tthis.removeChildDomNodes();\n\tthis.render(this.parentDomNode,nextSibling);\n};\n\n/*\nRefresh all the children of a widget\n*/\nWidget.prototype.refreshChildren = function(changedTiddlers) {\n\tvar self = this,\n\t\trefreshed = false;\n\t$tw.utils.each(this.children,function(childWidget) {\n\t\trefreshed = childWidget.refresh(changedTiddlers) || refreshed;\n\t});\n\treturn refreshed;\n};\n\n/*\nFind the next sibling in the DOM to this widget. This is done by scanning the widget tree through all next siblings and their descendents that share the same parent DOM node\n*/\nWidget.prototype.findNextSiblingDomNode = function(startIndex) {\n\t// Refer to this widget by its index within its parents children\n\tvar parent = this.parentWidget,\n\t\tindex = startIndex !== undefined ? startIndex : parent.children.indexOf(this);\nif(index === -1) {\n\tthrow \"node not found in parents children\";\n}\n\t// Look for a DOM node in the later siblings\n\twhile(++index < parent.children.length) {\n\t\tvar domNode = parent.children[index].findFirstDomNode();\n\t\tif(domNode) {\n\t\t\treturn domNode;\n\t\t}\n\t}\n\t// Go back and look for later siblings of our parent if it has the same parent dom node\n\tvar grandParent = parent.parentWidget;\n\tif(grandParent && parent.parentDomNode === this.parentDomNode) {\n\t\tindex = grandParent.children.indexOf(parent);\n\t\treturn parent.findNextSiblingDomNode(index);\n\t}\n\treturn null;\n};\n\n/*\nFind the first DOM node generated by a widget or its children\n*/\nWidget.prototype.findFirstDomNode = function() {\n\t// Return the first dom node of this widget, if we've got one\n\tif(this.domNodes.length > 0) {\n\t\treturn this.domNodes[0];\n\t}\n\t// Otherwise, recursively call our children\n\tfor(var t=0; t<this.children.length; t++) {\n\t\tvar domNode = this.children[t].findFirstDomNode();\n\t\tif(domNode) {\n\t\t\treturn domNode;\n\t\t}\n\t}\n\treturn null;\n};\n\n/*\nRemove any DOM nodes created by this widget or its children\n*/\nWidget.prototype.removeChildDomNodes = function() {\n\t// If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case\n\tif(this.domNodes.length > 0) {\n\t\t$tw.utils.each(this.domNodes,function(domNode) {\n\t\t\tdomNode.parentNode.removeChild(domNode);\n\t\t});\n\t\tthis.domNodes = [];\n\t} else {\n\t\t// Otherwise, ask the child widgets to delete their DOM nodes\n\t\t$tw.utils.each(this.children,function(childWidget) {\n\t\t\tchildWidget.removeChildDomNodes();\n\t\t});\n\t}\n};\n\nexports.widget = Widget;\n\n})();\n",
"title": "$:/core/modules/widgets/widget.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/core/modules/wiki.js": {
"text": "/*\\\ntitle: $:/core/modules/wiki.js\ntype: application/javascript\nmodule-type: wikimethod\n\nExtension methods for the $tw.Wiki object\n\nAdds the following properties to the wiki object:\n\n* `eventListeners` is a hashmap by type of arrays of listener functions\n* `changedTiddlers` is a hashmap describing changes to named tiddlers since wiki change events were last dispatched. Each entry is a hashmap containing two fields:\n\tmodified: true/false\n\tdeleted: true/false\n* `changeCount` is a hashmap by tiddler title containing a numerical index that starts at zero and is incremented each time a tiddler is created changed or deleted\n* `caches` is a hashmap by tiddler title containing a further hashmap of named cache objects. Caches are automatically cleared when a tiddler is modified or deleted\n* `globalCache` is a hashmap by cache name of cache objects that are cleared whenever any tiddler change occurs\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar widget = require(\"$:/core/modules/widgets/widget.js\");\n\nvar USER_NAME_TITLE = \"$:/status/UserName\";\n\n/*\nGet the value of a text reference. Text references can have any of these forms:\n\t<tiddlertitle>\n\t<tiddlertitle>!!<fieldname>\n\t!!<fieldname> - specifies a field of the current tiddlers\n\t<tiddlertitle>##<index>\n*/\nexports.getTextReference = function(textRef,defaultText,currTiddlerTitle) {\n\tvar tr = $tw.utils.parseTextReference(textRef),\n\t\ttitle = tr.title || currTiddlerTitle;\n\tif(tr.field) {\n\t\tvar tiddler = this.getTiddler(title);\n\t\tif(tr.field === \"title\") { // Special case so we can return the title of a non-existent tiddler\n\t\t\treturn title;\n\t\t} else if(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) {\n\t\t\treturn tiddler.getFieldString(tr.field);\n\t\t} else {\n\t\t\treturn defaultText;\n\t\t}\n\t} else if(tr.index) {\n\t\treturn this.extractTiddlerDataItem(title,tr.index,defaultText);\n\t} else {\n\t\treturn this.getTiddlerText(title,defaultText);\n\t}\n};\n\nexports.setTextReference = function(textRef,value,currTiddlerTitle) {\n\tvar tr = $tw.utils.parseTextReference(textRef),\n\t\ttitle = tr.title || currTiddlerTitle;\n\t// Check if it is a reference to a tiddler field\n\tif(tr.index) {\n\t\tvar data = this.getTiddlerData(title,Object.create(null));\n\t\tdata[tr.index] = value;\n\t\tthis.setTiddlerData(title,data,this.getModificationFields());\n\t} else {\n\t\tvar tiddler = this.getTiddler(title),\n\t\t\tfields = {title: title};\n\t\tfields[tr.field || \"text\"] = value;\n\t\tthis.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));\n\t}\n};\n\nexports.deleteTextReference = function(textRef,currTiddlerTitle) {\n\tvar tr = $tw.utils.parseTextReference(textRef),\n\t\ttitle,tiddler,fields;\n\t// Check if it is a reference to a tiddler\n\tif(tr.title && !tr.field) {\n\t\tthis.deleteTiddler(tr.title);\n\t// Else check for a field reference\n\t} else if(tr.field) {\n\t\ttitle = tr.title || currTiddlerTitle;\n\t\ttiddler = this.getTiddler(title);\n\t\tif(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) {\n\t\t\tfields = Object.create(null);\n\t\t\tfields[tr.field] = undefined;\n\t\t\tthis.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));\n\t\t}\n\t}\n};\n\nexports.addEventListener = function(type,listener) {\n\tthis.eventListeners = this.eventListeners || {};\n\tthis.eventListeners[type] = this.eventListeners[type] || [];\n\tthis.eventListeners[type].push(listener);\t\n};\n\nexports.removeEventListener = function(type,listener) {\n\tvar listeners = this.eventListeners[type];\n\tif(listeners) {\n\t\tvar p = listeners.indexOf(listener);\n\t\tif(p !== -1) {\n\t\t\tlisteners.splice(p,1);\n\t\t}\n\t}\n};\n\nexports.dispatchEvent = function(type /*, args */) {\n\tvar args = Array.prototype.slice.call(arguments,1),\n\t\tlisteners = this.eventListeners[type];\n\tif(listeners) {\n\t\tfor(var p=0; p<listeners.length; p++) {\n\t\t\tvar listener = listeners[p];\n\t\t\tlistener.apply(listener,args);\n\t\t}\n\t}\n};\n\n/*\nCauses a tiddler to be marked as changed, incrementing the change count, and triggers event handlers.\nThis method should be called after the changes it describes have been made to the wiki.tiddlers[] array.\n\ttitle: Title of tiddler\n\tisDeleted: defaults to false (meaning the tiddler has been created or modified),\n\t\ttrue if the tiddler has been deleted\n*/\nexports.enqueueTiddlerEvent = function(title,isDeleted) {\n\t// Record the touch in the list of changed tiddlers\n\tthis.changedTiddlers = this.changedTiddlers || Object.create(null);\n\tthis.changedTiddlers[title] = this.changedTiddlers[title] || Object.create(null);\n\tthis.changedTiddlers[title][isDeleted ? \"deleted\" : \"modified\"] = true;\n\t// Increment the change count\n\tthis.changeCount = this.changeCount || Object.create(null);\n\tif($tw.utils.hop(this.changeCount,title)) {\n\t\tthis.changeCount[title]++;\n\t} else {\n\t\tthis.changeCount[title] = 1;\n\t}\n\t// Trigger events\n\tthis.eventListeners = this.eventListeners || [];\n\tif(!this.eventsTriggered) {\n\t\tvar self = this;\n\t\t$tw.utils.nextTick(function() {\n\t\t\tvar changes = self.changedTiddlers;\n\t\t\tself.changedTiddlers = Object.create(null);\n\t\t\tself.eventsTriggered = false;\n\t\t\tif($tw.utils.count(changes) > 0) {\n\t\t\t\tself.dispatchEvent(\"change\",changes);\n\t\t\t}\n\t\t});\n\t\tthis.eventsTriggered = true;\n\t}\n};\n\nexports.clearTiddlerEventQueue = function() {\n\tthis.changedTiddlers = Object.create(null);\n\tthis.changeCount = Object.create(null)\n};\n\nexports.getChangeCount = function(title) {\n\tthis.changeCount = this.changeCount || Object.create(null);\n\tif($tw.utils.hop(this.changeCount,title)) {\n\t\treturn this.changeCount[title];\n\t} else {\n\t\treturn 0;\n\t}\n};\n\n/*\nGenerate an unused title from the specified base\n*/\nexports.generateNewTitle = function(baseTitle,options) {\n\toptions = options || {};\n\tvar c = 0,\n\t title = baseTitle;\n\twhile(this.tiddlerExists(title) || this.isShadowTiddler(title)) {\n\t\ttitle = baseTitle + \n\t\t\t(options.prefix || \" \") + \n\t\t\t(++c);\n\t};\n\treturn title;\n};\n\nexports.isSystemTiddler = function(title) {\n\treturn title.indexOf(\"$:/\") === 0;\n};\n\nexports.isTemporaryTiddler = function(title) {\n\treturn title.indexOf(\"$:/temp/\") === 0;\n};\n\nexports.isImageTiddler = function(title) {\n\tvar tiddler = this.getTiddler(title);\n\tif(tiddler) {\t\t\n\t\tvar contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || \"text/vnd.tiddlywiki\"];\n\t\treturn !!contentTypeInfo && contentTypeInfo.flags.indexOf(\"image\") !== -1;\n\t} else {\n\t\treturn null;\n\t}\n};\n\n/*\nLike addTiddler() except it will silently reject any plugin tiddlers that are older than the currently loaded version. Returns true if the tiddler was imported\n*/\nexports.importTiddler = function(tiddler) {\n\tvar existingTiddler = this.getTiddler(tiddler.fields.title);\n\t// Check if we're dealing with a plugin\n\tif(tiddler && tiddler.hasField(\"plugin-type\") && tiddler.hasField(\"version\") && existingTiddler && existingTiddler.hasField(\"plugin-type\") && existingTiddler.hasField(\"version\")) {\n\t\t// Reject the incoming plugin if it is older\n\t\tif($tw.utils.checkVersions(existingTiddler.fields.version,tiddler.fields.version)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\t// Fall through to adding the tiddler\n\tthis.addTiddler(tiddler);\n\treturn true;\n};\n\n/*\nReturn a hashmap of the fields that should be set when a tiddler is created\n*/\nexports.getCreationFields = function() {\n\tvar fields = {\n\t\t\tcreated: new Date()\n\t\t},\n\t\tcreator = this.getTiddlerText(USER_NAME_TITLE);\n\tif(creator) {\n\t\tfields.creator = creator;\n\t}\n\treturn fields;\n};\n\n/*\nReturn a hashmap of the fields that should be set when a tiddler is modified\n*/\nexports.getModificationFields = function() {\n\tvar fields = Object.create(null),\n\t\tmodifier = this.getTiddlerText(USER_NAME_TITLE);\n\tfields.modified = new Date();\n\tif(modifier) {\n\t\tfields.modifier = modifier;\n\t}\n\treturn fields;\n};\n\n/*\nReturn a sorted array of tiddler titles. Options include:\nsortField: field to sort by\nexcludeTag: tag to exclude\nincludeSystem: whether to include system tiddlers (defaults to false)\n*/\nexports.getTiddlers = function(options) {\n\toptions = options || Object.create(null);\n\tvar self = this,\n\t\tsortField = options.sortField || \"title\",\n\t\ttiddlers = [], t, titles = [];\n\tthis.each(function(tiddler,title) {\n\t\tif(options.includeSystem || !self.isSystemTiddler(title)) {\n\t\t\tif(!options.excludeTag || !tiddler.hasTag(options.excludeTag)) {\n\t\t\t\ttiddlers.push(tiddler);\n\t\t\t}\n\t\t}\n\t});\n\ttiddlers.sort(function(a,b) {\n\t\tvar aa = a.fields[sortField].toLowerCase() || \"\",\n\t\t\tbb = b.fields[sortField].toLowerCase() || \"\";\n\t\tif(aa < bb) {\n\t\t\treturn -1;\n\t\t} else {\n\t\t\tif(aa > bb) {\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t});\n\tfor(t=0; t<tiddlers.length; t++) {\n\t\ttitles.push(tiddlers[t].fields.title);\n\t}\n\treturn titles;\n};\n\nexports.countTiddlers = function(excludeTag) {\n\tvar tiddlers = this.getTiddlers({excludeTag: excludeTag});\n\treturn $tw.utils.count(tiddlers);\n};\n\n/*\nReturns a function iterator(callback) that iterates through the specified titles, and invokes the callback with callback(tiddler,title)\n*/\nexports.makeTiddlerIterator = function(titles) {\n\tvar self = this;\n\tif(!$tw.utils.isArray(titles)) {\n\t\ttitles = Object.keys(titles);\n\t} else {\n\t\ttitles = titles.slice(0);\n\t}\n\treturn function(callback) {\n\t\ttitles.forEach(function(title) {\n\t\t\tcallback(self.getTiddler(title),title);\n\t\t});\n\t};\n};\n\n/*\nSort an array of tiddler titles by a specified field\n\ttitles: array of titles (sorted in place)\n\tsortField: name of field to sort by\n\tisDescending: true if the sort should be descending\n\tisCaseSensitive: true if the sort should consider upper and lower case letters to be different\n*/\nexports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,isNumeric) {\n\tvar self = this;\n\ttitles.sort(function(a,b) {\n\t\tif(sortField !== \"title\") {\n\t\t\ta = self.getTiddler(a).fields[sortField] || \"\";\n\t\t\tb = self.getTiddler(b).fields[sortField] || \"\";\n\t\t}\n\t\tif(isNumeric) {\n\t\t\ta = Number(a);\n\t\t\tb = Number(b);\n\t\t\treturn isDescending ? b - a : a - b;\n\t\t} else if($tw.utils.isDate(a) && $tw.utils.isDate(b)) {\n\t\t\treturn isDescending ? b - a : a - b;\n\t\t} else {\n\t\t\ta = String(a);\n\t\t\tb = String(b);\n\t\t\tif(!isCaseSensitive) {\n\t\t\t\ta = a.toLowerCase();\n\t\t\t\tb = b.toLowerCase();\n\t\t\t}\n\t\t\treturn isDescending ? b.localeCompare(a) : a.localeCompare(b);\n\t\t}\n\t});\n};\n\n/*\nFor every tiddler invoke a callback(title,tiddler) with `this` set to the wiki object. Options include:\nsortField: field to sort by\nexcludeTag: tag to exclude\nincludeSystem: whether to include system tiddlers (defaults to false)\n*/\nexports.forEachTiddler = function(/* [options,]callback */) {\n\tvar arg = 0,\n\t\toptions = arguments.length >= 2 ? arguments[arg++] : {},\n\t\tcallback = arguments[arg++],\n\t\ttitles = this.getTiddlers(options),\n\t\tt, tiddler;\n\tfor(t=0; t<titles.length; t++) {\n\t\ttiddler = this.getTiddler(titles[t]);\n\t\tif(tiddler) {\n\t\t\tcallback.call(this,tiddler.fields.title,tiddler);\n\t\t}\n\t}\n};\n\n/*\nReturn an array of tiddler titles that are directly linked from the specified tiddler\n*/\nexports.getTiddlerLinks = function(title) {\n\tvar self = this;\n\t// We'll cache the links so they only get computed if the tiddler changes\n\treturn this.getCacheForTiddler(title,\"links\",function() {\n\t\t// Parse the tiddler\n\t\tvar parser = self.parseTiddler(title);\n\t\t// Count up the links\n\t\tvar links = [],\n\t\t\tcheckParseTree = function(parseTree) {\n\t\t\t\tfor(var t=0; t<parseTree.length; t++) {\n\t\t\t\t\tvar parseTreeNode = parseTree[t];\n\t\t\t\t\tif(parseTreeNode.type === \"link\" && parseTreeNode.attributes.to && parseTreeNode.attributes.to.type === \"string\") {\n\t\t\t\t\t\tvar value = parseTreeNode.attributes.to.value;\n\t\t\t\t\t\tif(links.indexOf(value) === -1) {\n\t\t\t\t\t\t\tlinks.push(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(parseTreeNode.children) {\n\t\t\t\t\t\tcheckParseTree(parseTreeNode.children);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\tif(parser) {\n\t\t\tcheckParseTree(parser.tree);\n\t\t}\n\t\treturn links;\n\t});\n};\n\n/*\nReturn an array of tiddler titles that link to the specified tiddler\n*/\nexports.getTiddlerBacklinks = function(targetTitle) {\n\tvar self = this,\n\t\tbacklinks = [];\n\tthis.forEachTiddler(function(title,tiddler) {\n\t\tvar links = self.getTiddlerLinks(title);\n\t\tif(links.indexOf(targetTitle) !== -1) {\n\t\t\tbacklinks.push(title);\n\t\t}\n\t});\n\treturn backlinks;\n};\n\n/*\nReturn a hashmap of tiddler titles that are referenced but not defined. Each value is the number of times the missing tiddler is referenced\n*/\nexports.getMissingTitles = function() {\n\tvar self = this,\n\t\tmissing = [];\n// We should cache the missing tiddler list, even if we recreate it every time any tiddler is modified\n\tthis.forEachTiddler(function(title,tiddler) {\n\t\tvar links = self.getTiddlerLinks(title);\n\t\t$tw.utils.each(links,function(link) {\n\t\t\tif((!self.tiddlerExists(link) && !self.isShadowTiddler(link)) && missing.indexOf(link) === -1) {\n\t\t\t\tmissing.push(link);\n\t\t\t}\n\t\t});\n\t});\n\treturn missing;\n};\n\nexports.getOrphanTitles = function() {\n\tvar self = this,\n\t\torphans = this.getTiddlers();\n\tthis.forEachTiddler(function(title,tiddler) {\n\t\tvar links = self.getTiddlerLinks(title);\n\t\t$tw.utils.each(links,function(link) {\n\t\t\tvar p = orphans.indexOf(link);\n\t\t\tif(p !== -1) {\n\t\t\t\torphans.splice(p,1);\n\t\t\t}\n\t\t});\n\t});\n\treturn orphans; // Todo\n};\n\n/*\nRetrieves a list of the tiddler titles that are tagged with a given tag\n*/\nexports.getTiddlersWithTag = function(tag) {\n\tvar self = this;\n\treturn this.getGlobalCache(\"taglist-\" + tag,function() {\n\t\tvar tagmap = self.getTagMap();\n\t\treturn self.sortByList(tagmap[tag],tag);\n\t});\n};\n\n/*\nGet a hashmap by tag of arrays of tiddler titles\n*/\nexports.getTagMap = function() {\n\tvar self = this;\n\treturn this.getGlobalCache(\"tagmap\",function() {\n\t\tvar tags = Object.create(null),\n\t\t\tstoreTags = function(tagArray,title) {\n\t\t\t\tif(tagArray) {\n\t\t\t\t\tfor(var index=0; index<tagArray.length; index++) {\n\t\t\t\t\t\tvar tag = tagArray[index];\n\t\t\t\t\t\tif($tw.utils.hop(tags,tag)) {\n\t\t\t\t\t\t\ttags[tag].push(title)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttags[tag] = [title];\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\ttitle, tiddler;\n\t\t// Collect up all the tags\n\t\tself.eachShadow(function(tiddler,title) {\n\t\t\tif(!self.tiddlerExists(title)) {\n\t\t\t\ttiddler = self.getTiddler(title);\n\t\t\t\tstoreTags(tiddler.fields.tags,title);\n\t\t\t}\n\t\t});\n\t\tself.each(function(tiddler,title) {\n\t\t\tstoreTags(tiddler.fields.tags,title);\n\t\t});\n\t\treturn tags;\n\t});\n};\n\n/*\nLookup a given tiddler and return a list of all the tiddlers that include it in their list\n*/\nexports.findListingsOfTiddler = function(targetTitle) {\n\t// Get the list associated with the tag\n\tvar titles = [];\n\tthis.each(function(tiddler,title) {\n\t\tif($tw.utils.isArray(tiddler.fields.list) && tiddler.fields.list.indexOf(targetTitle) !== -1) {\n\t\t\ttitles.push(title);\n\t\t}\n\t});\n\treturn titles;\n};\n\n/*\nSorts an array of tiddler titles according to an ordered list\n*/\nexports.sortByList = function(array,listTitle) {\n\tvar list = this.getTiddlerList(listTitle);\n\tif(!array || array.length === 0) {\n\t\treturn [];\n\t} else {\n\t\tvar titles = [], t, title;\n\t\t// First place any entries that are present in the list\n\t\tfor(t=0; t<list.length; t++) {\n\t\t\ttitle = list[t];\n\t\t\tif(array.indexOf(title) !== -1) {\n\t\t\t\ttitles.push(title);\n\t\t\t}\n\t\t}\n\t\t// Then place any remaining entries\n\t\tfor(t=0; t<array.length; t++) {\n\t\t\ttitle = array[t];\n\t\t\tif(list.indexOf(title) === -1) {\n\t\t\t\ttitles.push(title);\n\t\t\t}\n\t\t}\n\t\t// Finally obey the list-before and list-after fields of each tiddler in turn\n\t\tvar sortedTitles = titles.slice(0);\n\t\tfor(t=0; t<sortedTitles.length; t++) {\n\t\t\ttitle = sortedTitles[t];\n\t\t\tvar currPos = titles.indexOf(title),\n\t\t\t\tnewPos = -1,\n\t\t\t\ttiddler = this.getTiddler(title);\n\t\t\tif(tiddler) {\n\t\t\t\tvar beforeTitle = tiddler.fields[\"list-before\"],\n\t\t\t\t\tafterTitle = tiddler.fields[\"list-after\"];\n\t\t\t\tif(beforeTitle === \"\") {\n\t\t\t\t\tnewPos = 0;\n\t\t\t\t} else if(beforeTitle) {\n\t\t\t\t\tnewPos = titles.indexOf(beforeTitle);\n\t\t\t\t} else if(afterTitle) {\n\t\t\t\t\tnewPos = titles.indexOf(afterTitle);\n\t\t\t\t\tif(newPos >= 0) {\n\t\t\t\t\t\t++newPos;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(newPos === -1) {\n\t\t\t\t\tnewPos = currPos;\n\t\t\t\t}\n\t\t\t\tif(newPos !== currPos) {\n\t\t\t\t\ttitles.splice(currPos,1);\n\t\t\t\t\tif(newPos >= currPos) {\n\t\t\t\t\t\tnewPos--;\n\t\t\t\t\t}\n\t\t\t\t\ttitles.splice(newPos,0,title);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn titles;\n\t}\n};\n\n/*\nRetrieve a tiddler as a JSON string of the fields\n*/\nexports.getTiddlerAsJson = function(title) {\n\tvar tiddler = this.getTiddler(title);\n\tif(tiddler) {\n\t\tvar fields = Object.create(null);\n\t\t$tw.utils.each(tiddler.fields,function(value,name) {\n\t\t\tfields[name] = tiddler.getFieldString(name);\n\t\t});\n\t\treturn JSON.stringify(fields);\n\t} else {\n\t\treturn JSON.stringify({title: title});\n\t}\n};\n\n/*\nGet a tiddlers content as a JavaScript object. How this is done depends on the type of the tiddler:\n\napplication/json: the tiddler JSON is parsed into an object\napplication/x-tiddler-dictionary: the tiddler is parsed as sequence of name:value pairs\n\nOther types currently just return null.\n*/\nexports.getTiddlerData = function(title,defaultData) {\n\tvar tiddler = this.getTiddler(title),\n\t\tdata;\n\tif(tiddler && tiddler.fields.text) {\n\t\tswitch(tiddler.fields.type) {\n\t\t\tcase \"application/json\":\n\t\t\t\t// JSON tiddler\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse(tiddler.fields.text);\n\t\t\t\t} catch(ex) {\n\t\t\t\t\treturn defaultData;\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\tcase \"application/x-tiddler-dictionary\":\n\t\t\t\treturn $tw.utils.parseFields(tiddler.fields.text);\n\t\t}\n\t}\n\treturn defaultData;\n};\n\n/*\nExtract an indexed field from within a data tiddler\n*/\nexports.extractTiddlerDataItem = function(title,index,defaultText) {\n\tvar data = this.getTiddlerData(title,Object.create(null)),\n\t\ttext;\n\tif(data && $tw.utils.hop(data,index)) {\n\t\ttext = data[index];\n\t}\n\tif(typeof text === \"string\" || typeof text === \"number\") {\n\t\treturn text.toString();\n\t} else {\n\t\treturn defaultText;\n\t}\n};\n\n/*\nSet a tiddlers content to a JavaScript object. Currently this is done by setting the tiddler's type to \"application/json\" and setting the text to the JSON text of the data.\ntitle: title of tiddler\ndata: object that can be serialised to JSON\nfields: optional hashmap of additional tiddler fields to be set\n*/\nexports.setTiddlerData = function(title,data,fields) {\n\tvar existingTiddler = this.getTiddler(title),\n\t\tnewFields = {\n\t\t\ttitle: title\n\t};\n\tif(existingTiddler && existingTiddler.fields.type === \"application/x-tiddler-dictionary\") {\n\t\tnewFields.text = $tw.utils.makeTiddlerDictionary(data);\n\t} else {\n\t\tnewFields.type = \"application/json\";\n\t\tnewFields.text = JSON.stringify(data,null,$tw.config.preferences.jsonSpaces);\n\t}\n\tthis.addTiddler(new $tw.Tiddler(existingTiddler,fields,newFields,this.getModificationFields()));\n};\n\n/*\nReturn the content of a tiddler as an array containing each line\n*/\nexports.getTiddlerList = function(title,field,index) {\n\tif(index) {\n\t\treturn $tw.utils.parseStringArray(this.extractTiddlerDataItem(title,index,\"\"));\n\t}\n\tfield = field || \"list\";\n\tvar tiddler = this.getTiddler(title);\n\tif(tiddler) {\n\t\treturn ($tw.utils.parseStringArray(tiddler.fields[field]) || []).slice(0);\n\t}\n\treturn [];\n};\n\n// Return a named global cache object. Global cache objects are cleared whenever a tiddler change occurs\nexports.getGlobalCache = function(cacheName,initializer) {\n\tthis.globalCache = this.globalCache || Object.create(null);\n\tif($tw.utils.hop(this.globalCache,cacheName)) {\n\t\treturn this.globalCache[cacheName];\n\t} else {\n\t\tthis.globalCache[cacheName] = initializer();\n\t\treturn this.globalCache[cacheName];\n\t}\n};\n\nexports.clearGlobalCache = function() {\n\tthis.globalCache = Object.create(null);\n}\n\n// Return the named cache object for a tiddler. If the cache doesn't exist then the initializer function is invoked to create it\nexports.getCacheForTiddler = function(title,cacheName,initializer) {\n\n// Temporarily disable caching so that tweakParseTreeNode() works\nreturn initializer();\n\n\tthis.caches = this.caches || Object.create(null);\n\tvar caches = this.caches[title];\n\tif(caches && caches[cacheName]) {\n\t\treturn caches[cacheName];\n\t} else {\n\t\tif(!caches) {\n\t\t\tcaches = Object.create(null);\n\t\t\tthis.caches[title] = caches;\n\t\t}\n\t\tcaches[cacheName] = initializer();\n\t\treturn caches[cacheName];\n\t}\n};\n\n// Clear all caches associated with a particular tiddler\nexports.clearCache = function(title) {\n\tthis.caches = this.caches || Object.create(null);\n\tif($tw.utils.hop(this.caches,title)) {\n\t\tdelete this.caches[title];\n\t}\n};\n\nexports.initParsers = function(moduleType) {\n\t// Install the parser modules\n\t$tw.Wiki.parsers = {};\n\tvar self = this;\n\t$tw.modules.forEachModuleOfType(\"parser\",function(title,module) {\n\t\tfor(var f in module) {\n\t\t\tif($tw.utils.hop(module,f)) {\n\t\t\t\t$tw.Wiki.parsers[f] = module[f]; // Store the parser class\n\t\t\t}\n\t\t}\n\t});\n};\n\n/*\nParse a block of text of a specified MIME type\n\ttype: content type of text to be parsed\n\ttext: text\n\toptions: see below\nOptions include:\n\tparseAsInline: if true, the text of the tiddler will be parsed as an inline run\n*/\nexports.old_parseText = function(type,text,options) {\n\toptions = options || {};\n\t// Select a parser\n\tvar Parser = $tw.Wiki.parsers[type];\n\tif(!Parser && $tw.config.fileExtensionInfo[type]) {\n\t\tParser = $tw.Wiki.parsers[$tw.config.fileExtensionInfo[type].type];\n\t}\n\tif(!Parser) {\n\t\tParser = $tw.Wiki.parsers[options.defaultType || \"text/vnd.tiddlywiki\"];\n\t}\n\tif(!Parser) {\n\t\treturn null;\n\t}\n\t// Return the parser instance\n\treturn new Parser(type,text,{\n\t\tparseAsInline: options.parseAsInline,\n\t\twiki: this\n\t});\n};\n\n/*\nParse a tiddler according to its MIME type\n*/\nexports.old_parseTiddler = function(title,options) {\n\toptions = options || {};\n\tvar cacheType = options.parseAsInline ? \"newInlineParseTree\" : \"newBlockParseTree\",\n\t\ttiddler = this.getTiddler(title),\n\t\tself = this;\n\treturn tiddler ? this.getCacheForTiddler(title,cacheType,function() {\n\t\t\treturn self.old_parseText(tiddler.fields.type,tiddler.fields.text,options);\n\t\t}) : null;\n};\n\nvar tweakMacroDefinition = function(nodeList) {\n\tif(nodeList && nodeList[0] && nodeList[0].type === \"macrodef\") {\n\t\tnodeList[0].type = \"set\";\n\t\tnodeList[0].attributes = {\n\t\t\tname: {type: \"string\", value: nodeList[0].name},\n\t\t\tvalue: {type: \"string\", value: nodeList[0].text}\n\t\t};\n\t\tnodeList[0].children = nodeList.slice(1);\n\t\tnodeList.splice(1,nodeList.length-1);\n\t\ttweakMacroDefinition(nodeList[0].children);\n\t}\n};\n\nvar tweakParser = function(parser) {\n\t// Move any macro definitions to contain the body tree\n\ttweakMacroDefinition(parser.tree);\n};\n\nexports.parseText = function(type,text,options) {\n\tvar parser = this.old_parseText(type,text,options);\n\tif(parser) {\n\t\ttweakParser(parser)\n\t};\n\treturn parser;\n};\n\nexports.parseTiddler = function(title,options) {\n\tvar parser = this.old_parseTiddler(title,options);\n\tif(parser) {\n\t\ttweakParser(parser)\n\t};\n\treturn parser;\n};\n\nexports.parseTextReference = function(title,field,index,options) {\n\tif(field === \"text\" || (!field && !index)) {\n\t\t// Force the tiddler to be lazily loaded\n\t\tthis.getTiddlerText(title);\n\t\t// Parse it\n\t\treturn this.parseTiddler(title,options);\n\t} else {\n\t\tvar text;\n\t\tif(field) {\n\t\t\tif(field === \"title\") {\n\t\t\t\ttext = title;\n\t\t\t} else {\n\t\t\t\tvar tiddler = this.getTiddler(title);\n\t\t\t\tif(!tiddler || !tiddler.hasField(field)) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\ttext = tiddler.fields[field];\n\t\t\t}\n\t\t\treturn this.parseText(\"text/vnd.tiddlywiki\",text.toString(),options);\n\t\t} else if(index) {\n\t\t\ttext = this.extractTiddlerDataItem(title,index,\"\");\n\t\t\tif(text === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn this.parseText(\"text/vnd.tiddlywiki\",text,options);\n\t\t}\n\t}\n};\n\n/*\nMake a widget tree for a parse tree\nparser: parser object\noptions: see below\nOptions include:\ndocument: optional document to use\nvariables: hashmap of variables to set\nparentWidget: optional parent widget for the root node\n*/\nexports.makeWidget = function(parser,options) {\n\toptions = options || {};\n\tvar widgetNode = {\n\t\t\ttype: \"widget\",\n\t\t\tchildren: []\n\t\t},\n\t\tcurrWidgetNode = widgetNode;\n\t// Create set variable widgets for each variable\n\t$tw.utils.each(options.variables,function(value,name) {\n\t\tvar setVariableWidget = {\n\t\t\ttype: \"set\",\n\t\t\tattributes: {\n\t\t\t\tname: {type: \"string\", value: name},\n\t\t\t\tvalue: {type: \"string\", value: value}\n\t\t\t},\n\t\t\tchildren: []\n\t\t};\n\t\tcurrWidgetNode.children = [setVariableWidget];\n\t\tcurrWidgetNode = setVariableWidget;\n\t});\n\t// Add in the supplied parse tree nodes\n\tcurrWidgetNode.children = parser ? parser.tree : [];\n\t// Create the widget\n\treturn new widget.widget(widgetNode,{\n\t\twiki: this,\n\t\tdocument: options.document || $tw.fakeDocument,\n\t\tparentWidget: options.parentWidget\n\t});\n};\n\n/*\nMake a widget tree for transclusion\ntitle: target tiddler title\noptions: as for wiki.makeWidget() (including parseAsInline)\n*/\nexports.makeTranscludeWidget = function(title,options) {\n\toptions = options || {};\n\tvar parseTree = {tree: [{\n\t\ttype: \"transclude\",\n\t\tattributes: {\n\t\t\ttiddler: {\n\t\t\t\tname: \"tiddler\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tvalue: title}},\n\t\tisBlock: !options.parseAsInline}\n\t]};\n\treturn $tw.wiki.makeWidget(parseTree,options);\n};\n\n/*\nParse text in a specified format and render it into another format\n\toutputType: content type for the output\n\ttextType: content type of the input text\n\ttext: input text\n\toptions: see below\nOptions include:\nvariables: hashmap of variables to set\nparentWidget: optional parent widget for the root node\n*/\nexports.renderText = function(outputType,textType,text,options) {\n\toptions = options || {};\n\tvar parser = this.parseText(textType,text,options),\n\t\twidgetNode = this.makeWidget(parser,options);\n\tvar container = $tw.fakeDocument.createElement(\"div\");\n\twidgetNode.render(container,null);\n\treturn outputType === \"text/html\" ? container.innerHTML : container.textContent;\n};\n\n/*\nParse text from a tiddler and render it into another format\n\toutputType: content type for the output\n\ttitle: title of the tiddler to be rendered\n\toptions: see below\nOptions include:\nvariables: hashmap of variables to set\nparentWidget: optional parent widget for the root node\n*/\nexports.renderTiddler = function(outputType,title,options) {\n\toptions = options || {};\n\tvar parser = this.parseTiddler(title,options),\n\t\twidgetNode = this.makeWidget(parser,options);\n\tvar container = $tw.fakeDocument.createElement(\"div\");\n\twidgetNode.render(container,null);\n\treturn outputType === \"text/html\" ? container.innerHTML : (outputType === \"text/plain-formatted\" ? container.formattedTextContent : container.textContent);\n};\n\n/*\nReturn an array of tiddler titles that match a search string\n\ttext: The text string to search for\n\toptions: see below\nOptions available:\n\tsource: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)\n\texclude: An array of tiddler titles to exclude from the search\n\tinvert: If true returns tiddlers that do not contain the specified string\n\tcaseSensitive: If true forces a case sensitive search\n\tliteral: If true, searches for literal string, rather than separate search terms\n*/\nexports.search = function(text,options) {\n\toptions = options || {};\n\tvar self = this,t;\n\t// Convert the search string into a regexp for each term\n\tvar terms, searchTermsRegExps,\n\t\tflags = options.caseSensitive ? \"\" : \"i\";\n\tif(options.literal) {\n\t\tif(text.length === 0) {\n\t\t\tsearchTermsRegExps = null;\n\t\t} else {\n\t\t\tsearchTermsRegExps = [new RegExp(\"(\" + $tw.utils.escapeRegExp(text) + \")\",flags)];\n\t\t}\n\t} else {\n\t\tterms = text.split(/ +/);\n\t\tif(terms.length === 1 && terms[0] === \"\") {\n\t\t\tsearchTermsRegExps = null;\n\t\t} else {\n\t\t\tsearchTermsRegExps = [];\n\t\t\tfor(t=0; t<terms.length; t++) {\n\t\t\t\tsearchTermsRegExps.push(new RegExp(\"(\" + $tw.utils.escapeRegExp(terms[t]) + \")\",flags));\n\t\t\t}\n\t\t}\n\t}\n\t// Function to check a given tiddler for the search term\n\tvar searchTiddler = function(title) {\n\t\tif(!searchTermsRegExps) {\n\t\t\treturn true;\n\t\t}\n\t\tvar tiddler = self.getTiddler(title);\n\t\tif(!tiddler) {\n\t\t\ttiddler = new $tw.Tiddler({title: title, text: \"\", type: \"text/vnd.tiddlywiki\"});\n\t\t}\n\t\tvar contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type] || $tw.config.contentTypeInfo[\"text/vnd.tiddlywiki\"],\n\t\t\tmatch;\n\t\tfor(var t=0; t<searchTermsRegExps.length; t++) {\n\t\t\t// Search title, tags and body\n\t\t\tmatch = false;\n\t\t\tif(contentTypeInfo.encoding === \"utf8\") {\n\t\t\t\tmatch = match || searchTermsRegExps[t].test(tiddler.fields.text);\n\t\t\t}\n\t\t\tvar tags = tiddler.fields.tags ? tiddler.fields.tags.join(\"\\0\") : \"\";\n\t\t\tmatch = match || searchTermsRegExps[t].test(tags) || searchTermsRegExps[t].test(tiddler.fields.title);\n\t\t\tif(!match) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t};\n\t// Loop through all the tiddlers doing the search\n\tvar results = [],\n\t\tsource = options.source || this.each;\n\tsource(function(tiddler,title) {\n\t\tif(!!searchTiddler(title) === !options.invert) {\n\t\t\tresults.push(title);\n\t\t}\n\t});\n\t// Remove any of the results we have to exclude\n\tif(options.exclude) {\n\t\tfor(t=0; t<options.exclude.length; t++) {\n\t\t\tvar p = results.indexOf(options.exclude[t]);\n\t\t\tif(p !== -1) {\n\t\t\t\tresults.splice(p,1);\n\t\t\t}\n\t\t}\n\t}\n\treturn results;\n};\n\n/*\nTrigger a load for a tiddler if it is skinny. Returns the text, or undefined if the tiddler is missing, null if the tiddler is being lazily loaded.\n*/\nexports.getTiddlerText = function(title,defaultText) {\n\tvar tiddler = this.getTiddler(title);\n\t// Return undefined if the tiddler isn't found\n\tif(!tiddler) {\n\t\treturn defaultText;\n\t}\n\tif(tiddler.fields.text !== undefined) {\n\t\t// Just return the text if we've got it\n\t\treturn tiddler.fields.text;\n\t} else {\n\t\t// Tell any listeners about the need to lazily load this tiddler\n\t\tthis.dispatchEvent(\"lazyLoad\",title);\n\t\t// Indicate that the text is being loaded\n\t\treturn null;\n\t}\n};\n\n/*\nRead an array of browser File objects, invoking callback(tiddlerFieldsArray) once they're all read\n*/\nexports.readFiles = function(files,callback) {\n\tvar result = [],\n\t\toutstanding = files.length;\n\tfor(var f=0; f<files.length; f++) {\n\t\tthis.readFile(files[f],function(tiddlerFieldsArray) {\n\t\t\tresult.push.apply(result,tiddlerFieldsArray);\n\t\t\tif(--outstanding === 0) {\n\t\t\t\tcallback(result);\n\t\t\t}\n\t\t});\n\t};\n\treturn files.length;\n};\n\n/*\nRead a browser File object, invoking callback(tiddlerFieldsArray) with an array of tiddler fields objects\n*/\nexports.readFile = function(file,callback) {\n\t// Get the type, falling back to the filename extension\n\tvar self = this,\n\t\ttype = file.type;\n\tif(type === \"\" || !type) {\n\t\tvar dotPos = file.name.lastIndexOf(\".\");\n\t\tif(dotPos !== -1) {\n\t\t\tvar fileExtensionInfo = $tw.config.fileExtensionInfo[file.name.substr(dotPos)];\n\t\t\tif(fileExtensionInfo) {\n\t\t\t\ttype = fileExtensionInfo.type;\n\t\t\t}\n\t\t}\n\t}\n\t// Figure out if we're reading a binary file\n\tvar contentTypeInfo = $tw.config.contentTypeInfo[type],\n\t\tisBinary = contentTypeInfo ? contentTypeInfo.encoding === \"base64\" : false;\n\t// Create the FileReader\n\tvar reader = new FileReader();\n\t// Onload\n\treader.onload = function(event) {\n\t\t// Deserialise the file contents\n\t\tvar text = event.target.result,\n\t\t\ttiddlerFields = {title: file.name || \"Untitled\", type: type};\n\t\t// Are we binary?\n\t\tif(isBinary) {\n\t\t\t// The base64 section starts after the first comma in the data URI\n\t\t\tvar commaPos = text.indexOf(\",\");\n\t\t\tif(commaPos !== -1) {\n\t\t\t\ttiddlerFields.text = text.substr(commaPos+1);\n\t\t\t\tcallback([tiddlerFields]);\n\t\t\t}\n\t\t} else {\n\t\t\t// Check whether this is an encrypted TiddlyWiki file\n\t\t\tvar encryptedJson = $tw.utils.extractEncryptedStoreArea(text);\n\t\t\tif(encryptedJson) {\n\t\t\t\t// If so, attempt to decrypt it with the current password\n\t\t\t\t$tw.utils.decryptStoreAreaInteractive(encryptedJson,function(tiddlers) {\n\t\t\t\t\tcallback(tiddlers);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Otherwise, just try to deserialise any tiddlers in the file\n\t\t\t\tcallback(self.deserializeTiddlers(type,text,tiddlerFields));\n\t\t\t}\n\t\t}\n\t};\n\t// Kick off the read\n\tif(isBinary) {\n\t\treader.readAsDataURL(file);\n\t} else {\n\t\treader.readAsText(file);\n\t}\n};\n\n/*\nCheck whether the specified draft tiddler has been modified\n*/\nexports.isDraftModified = function(title) {\n var tiddler = this.getTiddler(title);\n\tif(!tiddler.isDraft()) {\n\t\treturn false;\n\t}\n\tvar ignoredFields = [\"created\", \"modified\", \"title\", \"draft.title\", \"draft.of\", \"tags\"],\n\t\torigTiddler = this.getTiddler(tiddler.fields[\"draft.of\"]);\n\tif(!origTiddler) {\n\t\treturn true;\n\t}\n\tif(tiddler.fields[\"draft.title\"] !== tiddler.fields[\"draft.of\"]) {\n\t\treturn true;\n\t}\n\tif(!$tw.utils.isArrayEqual(tiddler.fields.tags,origTiddler.fields.tags)) {\n\t\treturn true;\n\t}\n\treturn !Object.keys(tiddler.fields).every(function(field) {\n\t\tif(ignoredFields.indexOf(field) >= 0) {\n\t\t\treturn true;\n\t\t}\n\t\treturn tiddler.fields[field] === origTiddler.fields[field];\n\t});\n};\n\n/*\nAdd a new record to the top of the history stack\ntitle: a title string or an array of title strings\nfromPageRect: page coordinates of the origin of the navigation\nhistoryTitle: title of history tiddler (defaults to $:/HistoryList)\n*/\nexports.addToHistory = function(title,fromPageRect,historyTitle) {\n\thistoryTitle = historyTitle || \"$:/HistoryList\";\n\tvar titles = $tw.utils.isArray(title) ? title : [title];\n\t// Add a new record to the top of the history stack\n\tvar historyList = this.getTiddlerData(historyTitle,[]);\n\t$tw.utils.each(titles,function(title) {\n\t\thistoryList.push({title: title, fromPageRect: fromPageRect});\n\t});\n\tthis.setTiddlerData(historyTitle,historyList,{\"current-tiddler\": titles[titles.length-1]});\n};\n\n})();\n",
"title": "$:/core/modules/wiki.js",
"type": "application/javascript",
"module-type": "wikimethod"
},
"$:/palettes/Blanca": {
"title": "$:/palettes/Blanca",
"name": "Blanca",
"description": "A clean white palette to let you focus",
"tags": "$:/tags/Palette",
"type": "application/x-tiddler-dictionary",
"text": "alert-background: #ffe476\nalert-border: #b99e2f\nalert-highlight: #881122\nalert-muted-foreground: #b99e2f\nbackground: #ffffff\nblockquote-bar: <<colour muted-foreground>>\ncode-background: #f7f7f9\ncode-border: #e1e1e8\ncode-foreground: #dd1144\ndownload-background: #66cccc\ndownload-foreground: <<colour background>>\ndragger-background: <<colour foreground>>\ndragger-foreground: <<colour background>>\ndropdown-background: <<colour background>>\ndropdown-border: <<colour muted-foreground>>\ndropdown-tab-background-selected: #fff\ndropdown-tab-background: #ececec\ndropzone-background: rgba(0,200,0,0.7)\nexternal-link-background-hover: \nexternal-link-background-visited: \nexternal-link-background: \nexternal-link-foreground-hover: \nexternal-link-foreground-visited: #0000aa\nexternal-link-foreground: #0000ee\nforeground: #333333\nmessage-background: #ecf2ff\nmessage-border: #cfd6e6\nmessage-foreground: #547599\nmodal-backdrop: <<colour foreground>>\nmodal-background: <<colour background>>\nmodal-border: #999999\nmodal-footer-background: #f5f5f5\nmodal-footer-border: #dddddd\nmodal-header-border: #eeeeee\nmuted-foreground: #999999\nnotification-background: #ffffdd\nnotification-border: #999999\npage-background: #ffffff\npre-background: #f5f5f5\npre-border: #cccccc\nprimary: #7897f3\nsidebar-button-foreground: <<colour foreground>>\nsidebar-controls-foreground-hover: #000000\nsidebar-controls-foreground: #ccc\nsidebar-foreground-shadow: rgba(255,255,255, 0.8)\nsidebar-foreground: #acacac\nsidebar-muted-foreground-hover: #444444\nsidebar-muted-foreground: #c0c0c0\nsidebar-tab-background-selected: #ffffff\nsidebar-tab-background: <<colour tab-background>>\nsidebar-tab-border-selected: <<colour tab-border-selected>>\nsidebar-tab-border: <<colour tab-border>>\nsidebar-tab-divider: <<colour tab-divider>>\nsidebar-tab-foreground-selected: \nsidebar-tab-foreground: <<colour tab-foreground>>\nsidebar-tiddler-link-foreground-hover: #444444\nsidebar-tiddler-link-foreground: #7897f3\nstatic-alert-foreground: #aaaaaa\ntab-background-selected: #fffffffff\ntab-background: #eeeeee\ntab-border-selected: #cccccc\ntab-border: #cccccc\ntab-divider: #d8d8d8\ntab-foreground-selected: <<colour tab-foreground>>\ntab-foreground: #666666\ntable-border: #dddddd\ntable-footer-background: #a8a8a8\ntable-header-background: #f0f0f0\ntag-background: #ffeedd\ntag-foreground: #000\ntiddler-background: <<colour background>>\ntiddler-border: #eee\ntiddler-controls-foreground-hover: #888888\ntiddler-controls-foreground-selected: #444444\ntiddler-controls-foreground: #cccccc\ntiddler-editor-background: #f8f8f8\ntiddler-editor-border-image: #ffffff\ntiddler-editor-border: #cccccc\ntiddler-editor-fields-even: #e0e8e0\ntiddler-editor-fields-odd: #f0f4f0\ntiddler-info-background: #f8f8f8\ntiddler-info-border: #dddddd\ntiddler-info-tab-background: #f8f8f8\ntiddler-link-background: <<colour background>>\ntiddler-link-foreground: <<colour primary>>\ntiddler-subtitle-foreground: #c0c0c0\ntiddler-title-foreground: #ff9900\ntoolbar-new-button:\ntoolbar-options-button:\ntoolbar-save-button:\ntoolbar-info-button:\ntoolbar-edit-button:\ntoolbar-close-button:\ntoolbar-delete-button:\ntoolbar-cancel-button:\ntoolbar-done-button:\nuntagged-background: #999999\nvery-muted-foreground: #888888\n"
},
"$:/palettes/Blue": {
"title": "$:/palettes/Blue",
"name": "Blue",
"description": "A blue theme",
"tags": "$:/tags/Palette",
"type": "application/x-tiddler-dictionary",
"text": "alert-background: #ffe476\nalert-border: #b99e2f\nalert-highlight: #881122\nalert-muted-foreground: #b99e2f\nbackground: #fff\nblockquote-bar: <<colour muted-foreground>>\ncode-background: #f7f7f9\ncode-border: #e1e1e8\ncode-foreground: #dd1144\ndownload-background: #34c734\ndownload-foreground: <<colour foreground>>\ndragger-background: <<colour foreground>>\ndragger-foreground: <<colour background>>\ndropdown-background: <<colour background>>\ndropdown-border: <<colour muted-foreground>>\ndropdown-tab-background-selected: #fff\ndropdown-tab-background: #ececec\ndropzone-background: rgba(0,200,0,0.7)\nexternal-link-background-hover: \nexternal-link-background-visited: \nexternal-link-background: \nexternal-link-foreground-hover: \nexternal-link-foreground-visited: #0000aa\nexternal-link-foreground: #0000ee\nforeground: #333353\nmessage-background: #ecf2ff\nmessage-border: #cfd6e6\nmessage-foreground: #547599\nmodal-backdrop: <<colour foreground>>\nmodal-background: <<colour background>>\nmodal-border: #999999\nmodal-footer-background: #f5f5f5\nmodal-footer-border: #dddddd\nmodal-header-border: #eeeeee\nmuted-foreground: #999999\nnotification-background: #ffffdd\nnotification-border: #999999\npage-background: #ddddff\npre-background: #f5f5f5\npre-border: #cccccc\nprimary: #5778d8\nsidebar-button-foreground: <<colour foreground>>\nsidebar-controls-foreground-hover: #000000\nsidebar-controls-foreground: #ffffff\nsidebar-foreground-shadow: rgba(255,255,255, 0.8)\nsidebar-foreground: #acacac\nsidebar-muted-foreground-hover: #444444\nsidebar-muted-foreground: #c0c0c0\nsidebar-tab-background-selected: <<colour page-background>>\nsidebar-tab-background: <<colour tab-background>>\nsidebar-tab-border-selected: <<colour tab-border-selected>>\nsidebar-tab-border: <<colour tab-border>>\nsidebar-tab-divider: <<colour tab-divider>>\nsidebar-tab-foreground-selected: \nsidebar-tab-foreground: <<colour tab-foreground>>\nsidebar-tiddler-link-foreground-hover: #444444\nsidebar-tiddler-link-foreground: #5959c0\nstatic-alert-foreground: #aaaaaa\ntab-background-selected: <<colour background>>\ntab-background: #ccccdd\ntab-border-selected: #ccccdd\ntab-border: #cccccc\ntab-divider: #d8d8d8\ntab-foreground-selected: <<colour tab-foreground>>\ntab-foreground: #666666\ntable-border: #dddddd\ntable-footer-background: #a8a8a8\ntable-header-background: #f0f0f0\ntag-background: #eeeeff\ntag-foreground: #000\ntiddler-background: <<colour background>>\ntiddler-border: <<colour background>>\ntiddler-controls-foreground-hover: #666666\ntiddler-controls-foreground-selected: #444444\ntiddler-controls-foreground: #cccccc\ntiddler-editor-background: #f8f8f8\ntiddler-editor-border-image: #ffffff\ntiddler-editor-border: #cccccc\ntiddler-editor-fields-even: #e0e8e0\ntiddler-editor-fields-odd: #f0f4f0\ntiddler-info-background: #ffffff\ntiddler-info-border: #dddddd\ntiddler-info-tab-background: #ffffff\ntiddler-link-background: <<colour background>>\ntiddler-link-foreground: <<colour primary>>\ntiddler-subtitle-foreground: #c0c0c0\ntiddler-title-foreground: #5959c0\ntoolbar-new-button: #5eb95e\ntoolbar-options-button: rgb(128, 88, 165)\ntoolbar-save-button: #0e90d2\ntoolbar-info-button: #0e90d2\ntoolbar-edit-button: rgb(243, 123, 29)\ntoolbar-close-button: #dd514c\ntoolbar-delete-button: #dd514c\ntoolbar-cancel-button: rgb(243, 123, 29)\ntoolbar-done-button: #5eb95e\nuntagged-background: #999999\nvery-muted-foreground: #888888\n"
},
"$:/palettes/Contrast": {
"title": "$:/palettes/Contrast",
"name": "Contrast",
"description": "High contrast and unambiguous",
"tags": "$:/tags/Palette",
"type": "application/x-tiddler-dictionary",
"text": "alert-background: #ffe476\nalert-border: #b99e2f\nalert-highlight: #881122\nalert-muted-foreground: #b99e2f\nbackground: #ffffff\nblockquote-bar: <<colour muted-foreground>>\ncode-background: #f7f7f9\ncode-border: #e1e1e8\ncode-foreground: #dd1144\ndownload-background: #34c734\ndownload-foreground: <<colour background>>\ndragger-background: <<colour foreground>>\ndragger-foreground: <<colour background>>\ndropdown-background: <<colour background>>\ndropdown-border: <<colour muted-foreground>>\ndropdown-tab-background-selected: #fff\ndropdown-tab-background: #ececec\ndropzone-background: rgba(0,200,0,0.7)\nexternal-link-background-hover: \nexternal-link-background-visited: \nexternal-link-background: \nexternal-link-foreground-hover: \nexternal-link-foreground-visited: #0000aa\nexternal-link-foreground: #0000ee\nforeground: #333333\nmessage-background: #ecf2ff\nmessage-border: #cfd6e6\nmessage-foreground: #547599\nmodal-backdrop: <<colour foreground>>\nmodal-background: <<colour background>>\nmodal-border: #999999\nmodal-footer-background: #f5f5f5\nmodal-footer-border: #dddddd\nmodal-header-border: #eeeeee\nmuted-foreground: #999999\nnotification-background: #ffffdd\nnotification-border: #999999\npage-background: #000000\npre-background: #f5f5f5\npre-border: #cccccc\nprimary: #5778d8\nsidebar-button-foreground: <<colour foreground>>\nsidebar-controls-foreground-hover: #000000\nsidebar-controls-foreground: #ffffff\nsidebar-foreground-shadow: rgba(255,0,0, 0.5)\nsidebar-foreground: #ffffff\nsidebar-muted-foreground-hover: #444444\nsidebar-muted-foreground: #c0c0c0\nsidebar-tab-background-selected: #ececec\nsidebar-tab-background: <<colour tab-background>>\nsidebar-tab-border-selected: <<colour tab-border-selected>>\nsidebar-tab-border: <<colour tab-border>>\nsidebar-tab-divider: <<colour tab-divider>>\nsidebar-tab-foreground-selected: \nsidebar-tab-foreground: <<colour tab-foreground>>\nsidebar-tiddler-link-foreground-hover: #444444\nsidebar-tiddler-link-foreground: #999999\nstatic-alert-foreground: #aaaaaa\ntab-background-selected: #ffffff\ntab-background: #d8d8d8\ntab-border-selected: #d8d8d8\ntab-border: #cccccc\ntab-divider: #d8d8d8\ntab-foreground-selected: <<colour tab-foreground>>\ntab-foreground: #666666\ntable-border: #dddddd\ntable-footer-background: #a8a8a8\ntable-header-background: #f0f0f0\ntag-background: #d5ad34\ntag-foreground: #ffffff\ntiddler-background: <<colour background>>\ntiddler-border: <<colour background>>\ntiddler-controls-foreground-hover: #888888\ntiddler-controls-foreground-selected: #444444\ntiddler-controls-foreground: #cccccc\ntiddler-editor-background: #f8f8f8\ntiddler-editor-border-image: #ffffff\ntiddler-editor-border: #cccccc\ntiddler-editor-fields-even: #e0e8e0\ntiddler-editor-fields-odd: #f0f4f0\ntiddler-info-background: #f8f8f8\ntiddler-info-border: #dddddd\ntiddler-info-tab-background: #f8f8f8\ntiddler-link-background: <<colour background>>\ntiddler-link-foreground: <<colour primary>>\ntiddler-subtitle-foreground: #c0c0c0\ntiddler-title-foreground: #182955\ntoolbar-new-button:\ntoolbar-options-button:\ntoolbar-save-button:\ntoolbar-info-button:\ntoolbar-edit-button:\ntoolbar-close-button:\ntoolbar-delete-button:\ntoolbar-cancel-button:\ntoolbar-done-button:\nuntagged-background: #999999\nvery-muted-foreground: #888888\n"
},
"$:/palettes/Rocker": {
"title": "$:/palettes/Rocker",
"name": "Rocker",
"description": "A dark theme",
"tags": "$:/tags/Palette",
"type": "application/x-tiddler-dictionary",
"text": "alert-background: #ffe476\nalert-border: #b99e2f\nalert-highlight: #881122\nalert-muted-foreground: #b99e2f\nbackground: #ffffff\nblockquote-bar: <<colour muted-foreground>>\ncode-background: #f7f7f9\ncode-border: #e1e1e8\ncode-foreground: #dd1144\ndownload-background: #34c734\ndownload-foreground: <<colour background>>\ndragger-background: <<colour foreground>>\ndragger-foreground: <<colour background>>\ndropdown-background: <<colour background>>\ndropdown-border: <<colour muted-foreground>>\ndropdown-tab-background-selected: #fff\ndropdown-tab-background: #ececec\ndropzone-background: rgba(0,200,0,0.7)\nexternal-link-background-hover: \nexternal-link-background-visited: \nexternal-link-background: \nexternal-link-foreground-hover: \nexternal-link-foreground-visited: #0000aa\nexternal-link-foreground: #0000ee\nforeground: #333333\nmessage-background: #ecf2ff\nmessage-border: #cfd6e6\nmessage-foreground: #547599\nmodal-backdrop: <<colour foreground>>\nmodal-background: <<colour background>>\nmodal-border: #999999\nmodal-footer-background: #f5f5f5\nmodal-footer-border: #dddddd\nmodal-header-border: #eeeeee\nmuted-foreground: #999999\nnotification-background: #ffffdd\nnotification-border: #999999\npage-background: #000\npre-background: #f5f5f5\npre-border: #cccccc\nprimary: #cc0000\nsidebar-button-foreground: <<colour foreground>>\nsidebar-controls-foreground-hover: #000000\nsidebar-controls-foreground: #ffffff\nsidebar-foreground-shadow: rgba(255,255,255, 0.0)\nsidebar-foreground: #acacac\nsidebar-muted-foreground-hover: #444444\nsidebar-muted-foreground: #c0c0c0\nsidebar-tab-background-selected: #000\nsidebar-tab-background: <<colour tab-background>>\nsidebar-tab-border-selected: <<colour tab-border-selected>>\nsidebar-tab-border: <<colour tab-border>>\nsidebar-tab-divider: <<colour tab-divider>>\nsidebar-tab-foreground-selected: \nsidebar-tab-foreground: <<colour tab-foreground>>\nsidebar-tiddler-link-foreground-hover: #ffbb99\nsidebar-tiddler-link-foreground: #cc0000\nstatic-alert-foreground: #aaaaaa\ntab-background-selected: #ffffff\ntab-background: #d8d8d8\ntab-border-selected: #d8d8d8\ntab-border: #cccccc\ntab-divider: #d8d8d8\ntab-foreground-selected: <<colour tab-foreground>>\ntab-foreground: #666666\ntable-border: #dddddd\ntable-footer-background: #a8a8a8\ntable-header-background: #f0f0f0\ntag-background: #ffbb99\ntag-foreground: #000\ntiddler-background: <<colour background>>\ntiddler-border: <<colour background>>\ntiddler-controls-foreground-hover: #888888\ntiddler-controls-foreground-selected: #444444\ntiddler-controls-foreground: #cccccc\ntiddler-editor-background: #f8f8f8\ntiddler-editor-border-image: #ffffff\ntiddler-editor-border: #cccccc\ntiddler-editor-fields-even: #e0e8e0\ntiddler-editor-fields-odd: #f0f4f0\ntiddler-info-background: #f8f8f8\ntiddler-info-border: #dddddd\ntiddler-info-tab-background: #f8f8f8\ntiddler-link-background: <<colour background>>\ntiddler-link-foreground: <<colour primary>>\ntiddler-subtitle-foreground: #c0c0c0\ntiddler-title-foreground: #cc0000\ntoolbar-new-button:\ntoolbar-options-button:\ntoolbar-save-button:\ntoolbar-info-button:\ntoolbar-edit-button:\ntoolbar-close-button:\ntoolbar-delete-button:\ntoolbar-cancel-button:\ntoolbar-done-button:\nuntagged-background: #999999\nvery-muted-foreground: #888888\n"
},
"$:/palettes/Vanilla": {
"title": "$:/palettes/Vanilla",
"name": "Vanilla",
"description": "Pale and unobtrusive",
"tags": "$:/tags/Palette",
"type": "application/x-tiddler-dictionary",
"text": "alert-background: #ffe476\nalert-border: #b99e2f\nalert-highlight: #881122\nalert-muted-foreground: #b99e2f\nbackground: #ffffff\nblockquote-bar: <<colour muted-foreground>>\ncode-background: #f7f7f9\ncode-border: #e1e1e8\ncode-foreground: #dd1144\ndownload-background: #34c734\ndownload-foreground: <<colour background>>\ndragger-background: <<colour foreground>>\ndragger-foreground: <<colour background>>\ndropdown-background: <<colour background>>\ndropdown-border: <<colour muted-foreground>>\ndropdown-tab-background-selected: #fff\ndropdown-tab-background: #ececec\ndropzone-background: rgba(0,200,0,0.7)\nexternal-link-background-hover: \nexternal-link-background-visited: \nexternal-link-background: \nexternal-link-foreground-hover: \nexternal-link-foreground-visited: #0000aa\nexternal-link-foreground: #0000ee\nforeground: #333333\nmessage-background: #ecf2ff\nmessage-border: #cfd6e6\nmessage-foreground: #547599\nmodal-backdrop: <<colour foreground>>\nmodal-background: <<colour background>>\nmodal-border: #999999\nmodal-footer-background: #f5f5f5\nmodal-footer-border: #dddddd\nmodal-header-border: #eeeeee\nmuted-foreground: #bbb\nnotification-background: #ffffdd\nnotification-border: #999999\npage-background: #ececec\npre-background: #f5f5f5\npre-border: #cccccc\nprimary: #5778d8\nsidebar-button-foreground: <<colour foreground>>\nsidebar-controls-foreground-hover: #000000\nsidebar-controls-foreground: #ffffff\nsidebar-foreground-shadow: rgba(255,255,255, 0.8)\nsidebar-foreground: #acacac\nsidebar-muted-foreground-hover: #444444\nsidebar-muted-foreground: #c0c0c0\nsidebar-tab-background-selected: #ececec\nsidebar-tab-background: <<colour tab-background>>\nsidebar-tab-border-selected: <<colour tab-border-selected>>\nsidebar-tab-border: <<colour tab-border>>\nsidebar-tab-divider: #e4e4e4\nsidebar-tab-foreground-selected: \nsidebar-tab-foreground: <<colour tab-foreground>>\nsidebar-tiddler-link-foreground-hover: #444444\nsidebar-tiddler-link-foreground: #999999\nstatic-alert-foreground: #aaaaaa\ntab-background-selected: #ffffff\ntab-background: #d8d8d8\ntab-border-selected: #d8d8d8\ntab-border: #cccccc\ntab-divider: #d8d8d8\ntab-foreground-selected: <<colour tab-foreground>>\ntab-foreground: #666666\ntable-border: #dddddd\ntable-footer-background: #a8a8a8\ntable-header-background: #f0f0f0\ntag-background: #d5ad34\ntag-foreground: #ffffff\ntiddler-background: <<colour background>>\ntiddler-border: <<colour background>>\ntiddler-controls-foreground-hover: #888888\ntiddler-controls-foreground-selected: #444444\ntiddler-controls-foreground: #cccccc\ntiddler-editor-background: #f8f8f8\ntiddler-editor-border-image: #ffffff\ntiddler-editor-border: #cccccc\ntiddler-editor-fields-even: #e0e8e0\ntiddler-editor-fields-odd: #f0f4f0\ntiddler-info-background: #f8f8f8\ntiddler-info-border: #dddddd\ntiddler-info-tab-background: #f8f8f8\ntiddler-link-background: <<colour background>>\ntiddler-link-foreground: <<colour primary>>\ntiddler-subtitle-foreground: #c0c0c0\ntiddler-title-foreground: #182955\ntoolbar-new-button:\ntoolbar-options-button:\ntoolbar-save-button:\ntoolbar-info-button:\ntoolbar-edit-button:\ntoolbar-close-button:\ntoolbar-delete-button:\ntoolbar-cancel-button:\ntoolbar-done-button:\nuntagged-background: #999999\nvery-muted-foreground: #888888\n"
},
"$:/core/templates/MOTW.html": {
"title": "$:/core/templates/MOTW.html",
"text": "\\rules only filteredtranscludeinline transcludeinline entity\n<!-- The following comment is called a MOTW comment and is necessary for the TiddlyIE Internet Explorer extension -->\n<!-- saved from url=(0021)http://tiddlywiki.com --> "
},
"$:/core/templates/alltiddlers.content": {
"title": "$:/core/templates/alltiddlers.content",
"text": "{{{ [!is[system]sort[title]] ||$:/core/templates/static-tiddler}}}"
},
"$:/core/templates/alltiddlers.template.html": {
"title": "$:/core/templates/alltiddlers.template.html",
"type": "text/vnd.tiddlywiki-html",
"text": "\\define tw-wikilink-template() #$uri_encoded$\n\\rules only filteredtranscludeinline transcludeinline\n<!doctype html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n<meta name=\"generator\" content=\"TiddlyWiki\" />\n<meta name=\"tiddlywiki-version\" content=\"{{$:/core/templates/version}}\" />\n<meta name=\"format-detection\" content=\"telephone=no\">\n<link id=\"faviconLink\" rel=\"shortcut icon\" href=\"favicon.ico\">\n<title>{{$:/core/wiki/title}}</title>\n<div id=\"styleArea\">\n{{$:/boot/boot.css||$:/core/templates/css-tiddler}}\n</div>\n<style type=\"text/css\">\n{{$:/core/ui/PageStylesheet||$:/core/templates/wikified-tiddler}}\n</style>\n</head>\n<body class=\"tw-body\">\n{{$:/StaticBanner||$:/core/templates/html-tiddler}}\n<section class=\"story-river\">\n{{$:/core/templates/alltiddlers.content||$:/core/templates/html-tiddler}}\n</section>\n</body>\n</html>\n"
},
"$:/core/templates/css-tiddler": {
"title": "$:/core/templates/css-tiddler",
"text": "<!--\n\nThis template is used for saving CSS tiddlers as a style tag with data attributes representing the tiddler fields.\n\n-->`<style`<$fields template=' data-tiddler-$name$=\"$encoded_value$\"'></$fields>` type=\"text/css\">`<$view field=\"text\" format=\"text\" />`</style>`"
},
"$:/core/templates/html-div-tiddler": {
"title": "$:/core/templates/html-div-tiddler",
"text": "<!--\n\nThis template is used for saving tiddlers as an HTML DIV tag with attributes representing the tiddler fields.\n\n-->`<div`<$fields template=' $name$=\"$encoded_value$\"'></$fields>`>\n<pre>`<$view field=\"text\" format=\"htmlencoded\" />`</pre>\n</div>`\n"
},
"$:/core/templates/html-tiddler": {
"title": "$:/core/templates/html-tiddler",
"text": "<!--\n\nThis template is used for saving tiddlers as raw HTML\n\n--><$view field=\"text\" format=\"htmlwikified\" />"
},
"$:/core/templates/javascript-tiddler": {
"title": "$:/core/templates/javascript-tiddler",
"text": "<!--\n\nThis template is used for saving JavaScript tiddlers as a script tag with data attributes representing the tiddler fields.\n\n-->`<script`<$fields template=' data-tiddler-$name$=\"$encoded_value$\"'></$fields>` type=\"text/javascript\">`<$view field=\"text\" format=\"text\" />`</script>`"
},
"$:/core/templates/module-tiddler": {
"title": "$:/core/templates/module-tiddler",
"text": "<!--\n\nThis template is used for saving JavaScript tiddlers as a script tag with data attributes representing the tiddler fields. The body of the tiddler is wrapped in a call to the `$tw.modules.define` function in order to define the body of the tiddler as a module\n\n-->`<script`<$fields template=' data-tiddler-$name$=\"$encoded_value$\"'></$fields>` type=\"text/javascript\" data-module=\"yes\">$tw.modules.define(\"`<$view field=\"title\" format=\"jsencoded\" />`\",\"`<$view field=\"module-type\" format=\"jsencoded\" />`\",function(module,exports,require) {`<$view field=\"text\" format=\"text\" />`});\n</script>`"
},
"$:/core/templates/plain-text-tiddler": {
"title": "$:/core/templates/plain-text-tiddler",
"text": "<$view field=\"text\" format=\"text\" />"
},
"$:/core/save/all": {
"title": "$:/core/save/all",
"text": "\\define saveTiddlerFilter()\n[is[tiddler]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]]\n\\end\n{{$:/core/templates/tiddlywiki5.html}}\n"
},
"$:/core/save/empty": {
"title": "$:/core/save/empty",
"text": "\\define saveTiddlerFilter()\n[is[system]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]]\n\\end\n{{$:/core/templates/tiddlywiki5.html}}\n"
},
"$:/core/save/lazy-images": {
"title": "$:/core/save/lazy-images",
"text": "\\define saveTiddlerFilter()\n[is[tiddler]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[!is[system]is[image]] +[sort[title]] \n\\end\n{{$:/core/templates/tiddlywiki5.html}}\n"
},
"$:/core/templates/split-recipe": {
"title": "$:/core/templates/split-recipe",
"text": "<$list filter=\"[!is[system]]\">\ntiddler: <$view field=\"title\" format=\"urlencoded\"/>.tid\n</$list>\n"
},
"$:/core/templates/static-tiddler": {
"title": "$:/core/templates/static-tiddler",
"text": "<a name=<<currentTiddler>>>\n<$transclude tiddler=\"$:/core/ui/ViewTemplate\"/>\n</a>"
},
"$:/core/templates/static.area": {
"title": "$:/core/templates/static.area",
"text": "<$reveal type=\"nomatch\" state=\"$:/isEncrypted\" text=\"yes\">\n{{$:/core/templates/static.content||$:/core/templates/html-tiddler}}\n</$reveal>\n<$reveal type=\"match\" state=\"$:/isEncrypted\" text=\"yes\">\nThis file contains an encrypted ~TiddlyWiki. Enable ~JavaScript and enter the decryption password when prompted.\n</$reveal>\n"
},
"$:/core/templates/static.content": {
"title": "$:/core/templates/static.content",
"type": "text/vnd.tiddlywiki",
"text": "<!-- For Google, and people without JavaScript-->\nThis [[TiddlyWiki|http://tiddlywiki.com]] contains the following tiddlers:\n\n<ul>\n<$list filter=<<saveTiddlerFilter>>>\n<li><$view field=\"title\" format=\"text\"></$view></li>\n</$list>\n</ul>\n"
},
"$:/core/templates/static.template.css": {
"title": "$:/core/templates/static.template.css",
"text": "{{$:/boot/boot.css||$:/core/templates/plain-text-tiddler}}\n\n{{$:/core/ui/PageStylesheet||$:/core/templates/wikified-tiddler}}\n"
},
"$:/core/templates/static.template.html": {
"title": "$:/core/templates/static.template.html",
"type": "text/vnd.tiddlywiki-html",
"text": "\\define tw-wikilink-template() static/$uri_doubleencoded$.html\n\\rules only filteredtranscludeinline transcludeinline\n<!doctype html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n<meta name=\"generator\" content=\"TiddlyWiki\" />\n<meta name=\"tiddlywiki-version\" content=\"{{$:/core/templates/version}}\" />\n<meta name=\"format-detection\" content=\"telephone=no\">\n<link id=\"faviconLink\" rel=\"shortcut icon\" href=\"favicon.ico\">\n<title>{{$:/core/wiki/title}}</title>\n<div id=\"styleArea\">\n{{$:/boot/boot.css||$:/core/templates/css-tiddler}}\n</div>\n<style type=\"text/css\">\n{{$:/core/ui/PageStylesheet||$:/core/templates/wikified-tiddler}}\n</style>\n</head>\n<body class=\"tw-body\">\n{{$:/StaticBanner||$:/core/templates/html-tiddler}}\n{{$:/core/ui/PageMacros||$:/core/templates/html-tiddler}}\n</body>\n</html>\n"
},
"$:/core/templates/static.tiddler.html": {
"title": "$:/core/templates/static.tiddler.html",
"text": "\\define tw-wikilink-template() $uri_doubleencoded$.html\n`<!doctype html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n<meta name=\"generator\" content=\"TiddlyWiki\" />\n<meta name=\"tiddlywiki-version\" content=\"`{{$:/core/templates/version}}`\" />\n<meta name=\"format-detection\" content=\"telephone=no\">\n<link id=\"faviconLink\" rel=\"shortcut icon\" href=\"favicon.ico\">\n<link rel=\"stylesheet\" href=\"static.css\">\n<title>`{{$:/core/wiki/title}}`</title>\n</head>\n<body class=\"tw-body\">\n`{{$:/StaticBanner||$:/core/templates/html-tiddler}}`\n<section class=\"story-river\">\n`<$view tiddler=\"$:/core/ui/ViewTemplate\" format=\"htmlwikified\"/>`\n</section>\n</body>\n</html>\n`"
},
"$:/core/templates/store.area.template.html": {
"title": "$:/core/templates/store.area.template.html",
"text": "<$reveal type=\"nomatch\" state=\"$:/isEncrypted\" text=\"yes\">\n`<div id=\"storeArea\" style=\"display:none;\">`\n<$list filter=<<saveTiddlerFilter>> template=\"$:/core/templates/html-div-tiddler\"/>\n`</div>`\n</$reveal>\n<$reveal type=\"match\" state=\"$:/isEncrypted\" text=\"yes\">\n`<!--~~ Encrypted tiddlers ~~-->`\n`<pre id=\"encryptedStoreArea\" type=\"text/plain\" style=\"display:none;\">`\n<$encrypt filter=<<saveTiddlerFilter>>/>\n`</pre>`\n</$reveal>"
},
"$:/core/templates/tid-tiddler": {
"title": "$:/core/templates/tid-tiddler",
"text": "<!--\n\nThis template is used for saving tiddlers in TiddlyWeb *.tid format\n\n--><$fields exclude='text bag' template='$name$: $value$\n'></$fields>`\n`<$view field=\"text\" format=\"text\" />"
},
"$:/core/templates/tiddler-metadata": {
"title": "$:/core/templates/tiddler-metadata",
"text": "<!--\n\nThis template is used for saving tiddler metadata *.meta files\n\n--><$fields exclude='text bag' template='$name$: $value$\n'></$fields>"
},
"$:/core/templates/tiddlywiki5.html": {
"title": "$:/core/templates/tiddlywiki5.html",
"text": "\\rules only filteredtranscludeinline transcludeinline\n<!doctype html>\n{{$:/core/templates/MOTW.html}}<html>\n<head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\t\t<!-- Force IE standards mode for Intranet and HTA - should be the first meta -->\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n<meta name=\"application-name\" content=\"TiddlyWiki\" />\n<meta name=\"generator\" content=\"TiddlyWiki\" />\n<meta name=\"tiddlywiki-version\" content=\"{{$:/core/templates/version}}\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />\n<meta name=\"format-detection\" content=\"telephone=no\" />\n<meta name=\"copyright\" content=\"{{$:/core/copyright.txt}}\" />\n<link id=\"faviconLink\" rel=\"shortcut icon\" href=\"favicon.ico\">\n<title>{{$:/core/wiki/title}}</title>\n<!--~~ This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ~~-->\n\n<!--~~ Raw markup ~~-->\n{{{ [tag[$:/core/wiki/rawmarkup]] ||$:/core/templates/plain-text-tiddler}}}\n</head>\n<body class=\"tw-body\">\n<!--~~ Static styles ~~-->\n<div id=\"styleArea\">\n{{$:/boot/boot.css||$:/core/templates/css-tiddler}}\n</div>\n<!--~~ Static content for Google and browsers without JavaScript ~~-->\n<noscript>\n<div id=\"splashArea\">\n{{$:/core/templates/static.area}}\n</div>\n</noscript>\n<!--~~ Ordinary tiddlers ~~-->\n{{$:/core/templates/store.area.template.html}}\n<!--~~ Library modules ~~-->\n<div id=\"libraryModules\" style=\"display:none;\">\n{{{ [is[system]type[application/javascript]library[yes]] ||$:/core/templates/javascript-tiddler}}}\n</div>\n<!--~~ Boot kernel prologue ~~-->\n<div id=\"bootKernelPrefix\" style=\"display:none;\">\n{{ $:/boot/bootprefix.js ||$:/core/templates/javascript-tiddler}}\n</div>\n<!--~~ Boot kernel ~~-->\n<div id=\"bootKernel\" style=\"display:none;\">\n{{ $:/boot/boot.js ||$:/core/templates/javascript-tiddler}}\n</div>\n</body>\n</html>\n"
},
"$:/core/templates/version": {
"title": "$:/core/templates/version",
"text": "<<version>>"
},
"$:/core/templates/wikified-tiddler": {
"title": "$:/core/templates/wikified-tiddler",
"text": "<$transclude />"
},
"$:/core/ui/AdvancedSearch/Filter": {
"title": "$:/core/ui/AdvancedSearch/Filter",
"tags": "$:/tags/AdvancedSearch",
"caption": "{{$:/language/Search/Filter/Caption}}",
"text": "\\define lingo-base() $:/language/Search/\n<$linkcatcher to=\"$:/temp/advancedsearch\">\n\n<<lingo Filter/Hint>>\n\n<div class=\"tw-search tw-advanced-search\"><$edit-text tiddler=\"$:/temp/advancedsearch\" type=\"search\" tag=\"input\"/> <$button popup=<<qualify \"$:/state/filterDropdown\">> class=\"btn-invisible\">{{$:/core/images/down-arrow}}</$button> <$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\"> <$link to=\"\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$link></$reveal></div>\n\n<div class=\"tw-block-dropdown-wrapper\">\n<$reveal state=<<qualify \"$:/state/filterDropdown\">> type=\"nomatch\" text=\"\" default=\"\">\n<div class=\"tw-block-dropdown tw-edit-type-dropdown\">\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/Filter]]\"><$link to={{!!filter}}><$transclude field=\"description\"/></$link>\n</$list>\n</div>\n</$reveal>\n</div>\n\n</$linkcatcher>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\">\n<div class=\"tw-search-results\">\n<<lingo Filter/Matches>>\n<$list filter={{$:/temp/advancedsearch}} template=\"$:/core/ui/ListItemTemplate\"/>\n</div>\n</$reveal>\n"
},
"$:/core/ui/AdvancedSearch/Shadows": {
"title": "$:/core/ui/AdvancedSearch/Shadows",
"tags": "$:/tags/AdvancedSearch",
"caption": "{{$:/language/Search/Shadows/Caption}}",
"text": "\\define lingo-base() $:/language/Search/\n<$linkcatcher to=\"$:/temp/advancedsearch\">\n\n<<lingo Shadows/Hint>>\n\n<div class=\"tw-search\"><$edit-text tiddler=\"$:/temp/advancedsearch\" type=\"search\" tag=\"input\"/><$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\"> <$link to=\"\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$link></$reveal></div>\n\n</$linkcatcher>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\">\n\n<div class=\"tw-search-results\">\n\n<<lingo Shadows/Matches>>\n\n<$list filter=\"[all[shadows]search{$:/temp/advancedsearch}sort[title]limit[250]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n\n</div>\n\n</$reveal>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"match\" text=\"\">\n\n</$reveal>\n"
},
"$:/core/ui/AdvancedSearch/Standard": {
"title": "$:/core/ui/AdvancedSearch/Standard",
"tags": "$:/tags/AdvancedSearch",
"caption": "{{$:/language/Search/Standard/Caption}}",
"text": "\\define lingo-base() $:/language/Search/\n<$linkcatcher to=\"$:/temp/advancedsearch\">\n\n<<lingo Standard/Hint>>\n\n<div class=\"tw-search\"><$edit-text tiddler=\"$:/temp/advancedsearch\" type=\"search\" tag=\"input\"/><$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\"> <$link to=\"\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$link></$reveal></div>\n\n</$linkcatcher>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\">\n\n<div class=\"tw-search-results\">\n\n<<lingo Standard/Matches>>\n\n<$list filter=\"[!is[system]search{$:/temp/advancedsearch}sort[title]limit[250]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n\n</div>\n\n</$reveal>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"match\" text=\"\">\n\n</$reveal>\n"
},
"$:/core/ui/AdvancedSearch/System": {
"title": "$:/core/ui/AdvancedSearch/System",
"tags": "$:/tags/AdvancedSearch",
"caption": "{{$:/language/Search/System/Caption}}",
"text": "\\define lingo-base() $:/language/Search/\n<$linkcatcher to=\"$:/temp/advancedsearch\">\n\n<<lingo System/Hint>>\n\n<div class=\"tw-search\"><$edit-text tiddler=\"$:/temp/advancedsearch\" type=\"search\" tag=\"input\"/><$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\"> <$link to=\"\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$link></$reveal></div>\n\n</$linkcatcher>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"nomatch\" text=\"\">\n\n<div class=\"tw-search-results\">\n\n<<lingo System/Matches>>\n\n<$list filter=\"[is[system]search{$:/temp/advancedsearch}sort[title]limit[250]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n\n</div>\n\n</$reveal>\n\n<$reveal state=\"$:/temp/advancedsearch\" type=\"match\" text=\"\">\n\n</$reveal>\n"
},
"$:/AdvancedSearch": {
"title": "$:/AdvancedSearch",
"text": "<div class=\"tw-advanced-search\">\n<<tabs \"[all[shadows+tiddlers]tag[$:/tags/AdvancedSearch]!has[draft.of]]\" \"$:/core/ui/AdvancedSearch/System\">>\n</div>\n"
},
"$:/core/ui/AlertTemplate": {
"title": "$:/core/ui/AlertTemplate",
"text": "<div class=\"tw-alert\">\n<div class=\"tw-alert-toolbar\">\n<$button message=\"tw-delete-tiddler\" class=\"btn-invisible\">\n{{$:/core/images/delete-button}}</$button>\n</div>\n<div class=\"tw-alert-subtitle\">\n<$view field=\"component\"/> - <$view field=\"modified\" format=\"date\" template=\"0hh:0mm:0ss DD MM YYYY\"/> <$reveal type=\"nomatch\" state=\"!!count\" text=\"\"><span class=\"tw-alert-highlight\">(count: <$view field=\"count\"/>)</span></$reveal>\n</div>\n<div class=\"tw-alert-body\">\n\n<$transclude/>\n\n</div>\n</div>\n"
},
"$:/core/ui/BinaryWarning": {
"title": "$:/core/ui/BinaryWarning",
"text": "\\define lingo-base() $:/language/BinaryWarning/\n<div class=\"tw-binary-warning\">\n\n<<lingo Prompt>>\n\n</div>\n"
},
"$:/core/ui/ControlPanel/Advanced/LoadedModules": {
"title": "$:/core/ui/ControlPanel/Advanced/LoadedModules",
"tags": "$:/tags/ControlPanel/Advanced",
"caption": "{{$:/language/ControlPanel/Advanced/LoadedModules/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Advanced/\n<<lingo LoadedModules/Hint>>\n\n{{$:/snippets/modules}}\n"
},
"$:/core/ui/ControlPanel/Advanced/Settings/NavigationAddressBar": {
"title": "$:/core/ui/ControlPanel/Advanced/Settings/NavigationAddressBar",
"tags": "$:/tags/ControlPanel/Advanced/Settings",
"caption": "{{$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/\n<<lingo Hint>>\n<$button popup=<<qualify \"$:/state/navaddressbarpopup\">> class=\"btn-invisible btn-dropdown\">\n<$view tiddler=\"$:/config/Navigation/UpdateAddressBar\" field=\"text\"/>:\n<$reveal state=\"$:/config/Navigation/UpdateAddressBar\" type=\"match\" text=\"no\">\n''<<lingo No/Description>>''\n</$reveal>\n<$reveal state=\"$:/config/Navigation/UpdateAddressBar\" type=\"match\" text=\"permalink\">\n''<<lingo Permalink/Description>>''\n</$reveal>\n<$reveal state=\"$:/config/Navigation/UpdateAddressBar\" type=\"match\" text=\"permaview\">\n''<<lingo Permaview/Description>>''\n</$reveal>\n{{$:/core/images/down-arrow}}\n</$button>\n<$reveal state=<<qualify \"$:/state/navaddressbarpopup\">> type=\"popup\" position=\"below\" animate=\"yes\" default=\"\">\n<$linkcatcher to=\"$:/config/Navigation/UpdateAddressBar\">\n<div class=\"tw-drop-down tw-edit-type-dropdown\">\n<$list filter=\"no permalink permaview\">\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</$list>\n</div>\n</$linkcatcher>\n</$reveal>\n"
},
"$:/core/ui/ControlPanel/Advanced/Settings/NavigationHistory": {
"title": "$:/core/ui/ControlPanel/Advanced/Settings/NavigationHistory",
"tags": "$:/tags/ControlPanel/Advanced/Settings",
"caption": "{{$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Advanced/Settings/NavigationHistory/\n<<lingo Hint>>\n<$button popup=<<qualify \"$:/state/navhistorypopup\">> class=\"btn-invisible btn-dropdown\">\n<$view tiddler=\"$:/config/Navigation/UpdateHistory\" field=\"text\"/>:\n<$reveal state=\"$:/config/Navigation/UpdateHistory\" type=\"match\" text=\"no\">\n''<<lingo No/Description>>''\n</$reveal>\n<$reveal state=\"$:/config/Navigation/UpdateHistory\" type=\"match\" text=\"yes\">\n''<<lingo Yes/Description>>''\n</$reveal>\n{{$:/core/images/down-arrow}}\n</$button>\n<$reveal state=<<qualify \"$:/state/navhistorypopup\">> type=\"popup\" position=\"below\" animate=\"yes\" default=\"\">\n<$linkcatcher to=\"$:/config/Navigation/UpdateHistory\">\n<div class=\"tw-drop-down tw-edit-type-dropdown\">\n<$list filter=\"no yes\">\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</$list>\n</div>\n</$linkcatcher>\n</$reveal>\n"
},
"$:/core/ui/ControlPanel/Advanced/Settings": {
"title": "$:/core/ui/ControlPanel/Advanced/Settings",
"tags": "$:/tags/ControlPanel/Advanced",
"caption": "{{$:/language/ControlPanel/Advanced/Settings/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Advanced/Settings/\n\n<<lingo Hint>>\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Advanced/Settings]]\">\n\n<div style=\"border-top:1px solid #eee;\">\n\n!! <$link><$transclude field=\"caption\"/></$link>\n\n<$transclude/>\n\n</div>\n\n</$list>\n"
},
"$:/core/ui/ControlPanel/Advanced/TiddlerFields": {
"title": "$:/core/ui/ControlPanel/Advanced/TiddlerFields",
"tags": "$:/tags/ControlPanel/Advanced",
"caption": "{{$:/language/ControlPanel/Advanced/TiddlerFields/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Advanced/\n\n<<lingo TiddlerFields/Hint>>\n\n{{$:/snippets/allfields}}"
},
"$:/core/ui/ControlPanel/Advanced": {
"title": "$:/core/ui/ControlPanel/Advanced",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Advanced/Caption}}",
"text": "{{$:/language/ControlPanel/Advanced/Hint}}\n\n<div class=\"tw-control-panel\">\n<<tabs \"[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Advanced]!has[draft.of]]\" \"$:/core/ui/ControlPanel/Advanced/TiddlerFields\">>\n</div>\n"
},
"$:/core/ui/ControlPanel/Appearance/Palette": {
"title": "$:/core/ui/ControlPanel/Appearance/Palette",
"tags": "$:/tags/ControlPanel/Appearance",
"caption": "{{$:/language/ControlPanel/Appearance/Palette/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/Palette/\n\n{{$:/snippets/paletteswitcher}}\n\n<$reveal type=\"nomatch\" state=\"$:/state/ShowPaletteEditor\" text=\"yes\">\n\n<$button set=\"$:/state/ShowPaletteEditor\" setTo=\"yes\"><<lingo ShowEditor/Caption>></$button>\n\n</$reveal>\n\n<$reveal type=\"match\" state=\"$:/state/ShowPaletteEditor\" text=\"yes\">\n\n<$button set=\"$:/state/ShowPaletteEditor\" setTo=\"no\"><<lingo HideEditor/Caption>></$button>\n{{$:/snippets/paletteeditor}}\n\n</$reveal>\n\n"
},
"$:/core/ui/ControlPanel/Appearance/StoryView": {
"title": "$:/core/ui/ControlPanel/Appearance/StoryView",
"tags": "$:/tags/ControlPanel/Appearance",
"caption": "{{$:/language/ControlPanel/Appearance/StoryView/Caption}}",
"text": "{{$:/snippets/viewswitcher}}\n"
},
"$:/core/ui/ControlPanel/Appearance/Theme": {
"title": "$:/core/ui/ControlPanel/Appearance/Theme",
"tags": "$:/tags/ControlPanel/Appearance",
"caption": "{{$:/language/ControlPanel/Appearance/Theme/Caption}}",
"text": "{{$:/snippets/themeswitcher}}\n"
},
"$:/core/ui/ControlPanel/Appearance": {
"title": "$:/core/ui/ControlPanel/Appearance",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Appearance/Caption}}",
"text": "{{$:/language/ControlPanel/Appearance/Hint}}\n\n<div class=\"tw-control-panel\">\n<<tabs \"[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Appearance]!has[draft.of]]\" \"$:/core/ui/ControlPanel/Appearance/Theme\">>\n</div>\n"
},
"$:/core/ui/ControlPanel/Basics": {
"title": "$:/core/ui/ControlPanel/Basics",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Basics/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Basics/\n|<<lingo Version/Prompt>> |''<<version>>'' |\n|<$link to=\"$:/SiteTitle\"><<lingo Title/Prompt>></$link> |<$edit-text tiddler=\"$:/SiteTitle\" default=\"\" tag=\"input\"/> |\n|<$link to=\"$:/SiteSubtitle\"><<lingo Subtitle/Prompt>></$link> |<$edit-text tiddler=\"$:/SiteSubtitle\" default=\"\" tag=\"input\"/> |\n|<$link to=\"$:/status/UserName\"><<lingo Username/Prompt>></$link> |<$edit-text tiddler=\"$:/status/UserName\" default=\"\" tag=\"input\"/> |\n|<$link to=\"$:/config/AnimationDuration\"><<lingo AnimDuration/Prompt>></$link> |<$edit-text tiddler=\"$:/config/AnimationDuration\" default=\"\" tag=\"input\"/> |\n|<$link to=\"$:/DefaultTiddlers\"><<lingo DefaultTiddlers/Prompt>></$link> |<<lingo DefaultTiddlers/TopHint>><br> <$edit-text tag=\"textarea\" tiddler=\"$:/DefaultTiddlers\"/><br>//<<lingo DefaultTiddlers/BottomHint>>// |\n|<<lingo Language/Prompt>> |{{$:/snippets/minilanguageswitcher}} |\n|<<lingo Tiddlers/Prompt>> |''<$count filter=\"[!is[system]]\"/>'' |\n|<<lingo Tags/Prompt>> |''<$count filter=\"[tags[]]\"/>'' |\n|<<lingo SystemTiddlers/Prompt>> |''<$count filter=\"[is[system]]\"/>'' |\n|<<lingo ShadowTiddlers/Prompt>> |''<$count filter=\"[all[shadows]]\"/>'' |\n|<<lingo OverriddenShadowTiddlers/Prompt>> |''<$count filter=\"[is[tiddler]is[shadow]]\"/>'' |\n"
},
"$:/core/ui/ControlPanel/Plugins": {
"title": "$:/core/ui/ControlPanel/Plugins",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Plugins/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Plugins/\n\\define plugin-table(type)\n<table>\n<tbody>\n<tr>\n<th>\n<<lingo Fields/Description>>\n</th>\n<th>\n<<lingo Fields/Version>>\n</th>\n</tr>\n<$list filter=\"[!has[draft.of]plugin-type[$type$]sort[description]]\">\n<tr>\n<td>\n<$link to={{!!title}}>\n''<$view field=\"description\"><$view field=\"title\"/></$view>''<br>\n<$view field=\"title\"/>\n</$link>\n</td>\n<td>\n<$view field=\"version\"/>\n</td>\n</tr>\n</$list>\n</tbody>\n</table>\n\\end\n\n! <<lingo Plugin/Prompt>>\n\n<<plugin-table plugin>>\n\n! <<lingo Theme/Prompt>>\n\n<<plugin-table theme>>\n\n! <<lingo Language/Prompt>>\n\n<<plugin-table language>>\n"
},
"$:/core/ui/ControlPanel/Saving": {
"title": "$:/core/ui/ControlPanel/Saving",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Saving/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Saving/\n\\define backupURL()\nhttp://$(userName)$.tiddlyspot.com/backup/\n\\end\n\\define backupLink()\n<$reveal type=\"nomatch\" state=\"$:/UploadName\" text=\"\">\n<$set name=\"userName\" value={{$:/UploadName}}>\n<a href=<<backupURL>>><$macrocall $name=\"backupURL\" $type=\"text/plain\" $output=\"text/plain\"/></a>\n</$set>\n</$reveal>\n\\end\n! <<lingo Saving/Heading>>\n\n|<<lingo AutoSave>> |{{$:/snippets/autosavestatus}} |\n\n! <<lingo TiddlySpot/Heading>>\n\n|<<lingo TiddlySpot/UserName>> |<$edit-text tiddler=\"$:/UploadName\" default=\"\" tag=\"input\"/> |\n|<<lingo TiddlySpot/Password>> |<$password name=\"upload\"/> |\n|<<lingo TiddlySpot/Backups>> |<<backupLink>> |\n\n!! <<lingo TiddlySpot/Advanced/Heading>>\n\n|<<lingo TiddlySpot/ServerURL>> |<$edit-text tiddler=\"$:/UploadURL\" default=\"\" tag=\"input\"/> |\n|<<lingo TiddlySpot/Filename>> |<$edit-text tiddler=\"$:/UploadFilename\" default=\"index.html\" tag=\"input\"/> |\n|<<lingo TiddlySpot/UploadDir>> |<$edit-text tiddler=\"$:/UploadDir\" default=\".\" tag=\"input\"/> |\n|<<lingo TiddlySpot/BackupDir>> |<$edit-text tiddler=\"$:/UploadBackupDir\" default=\".\" tag=\"input\"/> |\n\n<<lingo TiddlySpot/Hint>>\n\n"
},
"$:/core/ui/ControlPanel/Tools": {
"title": "$:/core/ui/ControlPanel/Tools",
"tags": "$:/tags/ControlPanel",
"caption": "{{$:/language/ControlPanel/Tools/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/Tools/\n! <<lingo Import/Heading>>\n\n<$browse/>\n\n<<lingo Import/Hint>>\n\n! <<lingo Export/Heading>>\n\n<$button message=\"tw-download-file\" param=\"$:/core/templates/alltiddlers.template.html\" class=\"btn-big-green\"><<lingo Export/AllAsStaticHTML/Caption>> {{$:/core/images/save-button}}</$button>\n\n! <<lingo Encryption/Heading>>\n\n{{$:/snippets/encryptionstatus}}\n"
},
"$:/ControlPanel": {
"title": "$:/ControlPanel",
"text": "<div class=\"tw-control-panel\">\n<<tabs \"[all[shadows+tiddlers]tag[$:/tags/ControlPanel]!has[draft.of]]\" \"$:/core/ui/ControlPanel/Basics\">>\n</div>\n"
},
"$:/core/ui/EditTemplate/body": {
"title": "$:/core/ui/EditTemplate/body",
"tags": "$:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/EditTemplate/\n<$reveal state=\"$:/state/showeditpreview\" type=\"match\" text=\"yes\">\n\n<em class=\"tw-edit\"><<lingo Body/Hint>></em> <$button type=\"set\" set=\"$:/state/showeditpreview\" setTo=\"no\"><<lingo Body/Preview/Button/Hide>></$button>\n\n<div class=\"tw-tiddler-preview\">\n<div class=\"tw-tiddler-preview-preview\">\n\n<$transclude />\n\n</div>\n\n<div class=\"tw-tiddler-preview-edit\">\n<$edit field=\"text\" class=\"tw-edit-texteditor\" placeholder={{$:/language/EditTemplate/Body/Placeholder}}/>\n\n</div>\n\n</div>\n\n</$reveal>\n\n<$reveal state=\"$:/state/showeditpreview\" type=\"nomatch\" text=\"yes\">\n\n<em class=\"tw-edit\"><<lingo Body/Hint>></em> <$button type=\"set\" set=\"$:/state/showeditpreview\" setTo=\"yes\"><<lingo Body/Preview/Button/Show>></$button>\n<$edit field=\"text\" class=\"tw-edit-texteditor\" placeholder={{$:/language/EditTemplate/Body/Placeholder}}/>\n\n</$reveal>\n"
},
"$:/core/ui/EditTemplate/controls": {
"title": "$:/core/ui/EditTemplate/controls",
"tags": "$:/tags/EditTemplate",
"text": "<span class=\"tw-tiddler-controls titlebar\"> <$list filter=\"[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]\" variable=\"listItem\"><$transclude tiddler=<<listItem>>/></$list> </span>\n"
},
"$:/core/ui/EditTemplate/fields": {
"title": "$:/core/ui/EditTemplate/fields",
"tags": "$:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/EditTemplate/\n<$fieldmangler>\n<div class=\"tw-edit-fields\">\n<table class=\"tw-edit-fields\">\n<tbody>\n<$list filter=\"[all[current]fields[]] -title -tags -text -creator -created -modified -modifier -type -[[draft.title]] -[[draft.of]] +[sort[title]]\" variable=\"currentField\">\n<tr class=\"tw-edit-field\">\n<td class=\"tw-edit-field-name\">\n<$text text=<<currentField>>/>:</td>\n<td class=\"tw-edit-field-value\">\n<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>\n</td>\n<td class=\"tw-edit-field-remove\">\n<$button message=\"tw-remove-field\" param=<<currentField>> class=\"btn-invisible\">{{$:/core/images/delete-button}}</$button>\n</td>\n</tr>\n</$list>\n</tbody>\n</table>\n</div>\n\n<div class=\"tw-edit-field-add\">\n<em class=\"tw-edit\">\n<<lingo Fields/Add/Prompt>>\n</em> <span class=\"tw-edit-field-add-name\">\n<$edit-text tiddler=\"$:/temp/newfieldname\" tag=\"input\" default=\"\" placeholder={{$:/language/EditTemplate/Fields/Add/Name/Placeholder}} class=\"tw-edit-texteditor\"/>\n</span> <span class=\"tw-edit-field-add-button\">\n<$button message=\"tw-add-field\" param={{$:/temp/newfieldname}} set=\"$:/temp/newfieldname\" setTo=\"\" class=\"\">\n<<lingo Fields/Add/Button>>\n</$button>\n</span>\n</div>\n\n</$fieldmangler>\n"
},
"$:/core/ui/EditTemplate/shadow": {
"title": "$:/core/ui/EditTemplate/shadow",
"tags": "$:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/EditTemplate/Shadow/\n<$list filter=\"[all[current]get[draft.of]is[shadow]!is[tiddler]]\">\n<div class=\"tw-message-box\">\n\n<<lingo Warning>>\n\n</div>\n</$list>\n\n<$list filter=\"[all[current]get[draft.of]is[shadow]is[tiddler]]\">\n<div class=\"tw-message-box\">\n\n<<lingo OverriddenWarning>>\n\n</div>\n</$list>\n"
},
"$:/core/ui/EditTemplate/tags": {
"title": "$:/core/ui/EditTemplate/tags",
"tags": "$:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/EditTemplate/\n\\define tag-styles()\nbackground-color:$(backgroundColor)$;\n\\end\n<div class=\"tw-edit-tags\">\n<$fieldmangler>\n<$list filter=\"[all[current]tags[]sort[title]]\" storyview=\"pop\"><$set name=\"backgroundColor\" value={{!!color}}><span style=<<tag-styles>> class=\"tw-tag-label\">\n<$view field=\"title\" format=\"text\" />\n<$button message=\"tw-remove-tag\" param={{!!title}} class=\"btn-invisible tw-remove-tag-button\">×</$button></span>\n</$set>\n</$list>\n\n<div class=\"tw-edit-add-tag\">\n<span class=\"tw-add-tag-name\">\n<$edit-text tiddler=\"$:/temp/NewTagName\" tag=\"input\" default=\"\" placeholder={{$:/language/EditTemplate/Tags/Add/Placeholder}} focusPopup=<<qualify \"$:/state/tagsAutoComplete\">> class=\"tw-edit-texteditor\"/>\n</span> <$button popup=<<qualify \"$:/state/tagsAutoComplete\">> class=\"btn-invisible btn-dropdown\">{{$:/core/images/down-arrow}}</$button> <span class=\"tw-add-tag-button\">\n<$button message=\"tw-add-tag\" param={{$:/temp/NewTagName}} set=\"$:/temp/NewTagName\" setTo=\"\" class=\"\">\n<<lingo Tags/Add/Button>>\n</$button>\n</span>\n</div>\n\n<div class=\"tw-block-dropdown-wrapper\">\n\n<$reveal state=<<qualify \"$:/state/tagsAutoComplete\">> type=\"nomatch\" text=\"\" default=\"\">\n\n<div class=\"tw-block-dropdown\">\n\n<$linkcatcher set=\"$:/temp/NewTagName\" setTo=\"\" message=\"tw-add-tag\">\n<$list filter=\"[!is[shadow]tags[]search{$:/temp/NewTagName}sort[title]]\">\n<$link>\n<$set name=\"backgroundColor\" value={{!!color}}>\n<span style=<<tag-styles>> class=\"tw-tag-label\">\n<$view field=\"title\" format=\"text\"/>\n</span>\n</$set>\n</$link>\n</$list>\n</$linkcatcher>\n\n</div>\n\n</$reveal>\n</div>\n</$fieldmangler>\n</div>"
},
"$:/core/ui/EditTemplate/title": {
"title": "$:/core/ui/EditTemplate/title",
"tags": "$:/tags/EditTemplate",
"text": "<$view field=\"title\"/>\n\n<$edit-text field=\"draft.title\" class=\"titlebar tw-edit-texteditor\"/>\n"
},
"$:/core/ui/EditTemplate/type": {
"title": "$:/core/ui/EditTemplate/type",
"tags": "$:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/EditTemplate/\n<p><$fieldmangler><em class=\"tw-edit\"><<lingo Type/Prompt>></em> <$edit-text field=\"type\" tag=\"input\" default=\"\" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<<qualify \"$:/state/typeDropdown\">> class=\"tw-edit-typeeditor\"/> <$button popup=<<qualify \"$:/state/typeDropdown\">> class=\"btn-invisible btn-dropdown\">{{$:/core/images/down-arrow}}</$button> <$button message=\"tw-remove-field\" param=\"type\" class=\"btn-invisible btn-icon\">{{$:/core/images/delete-button}}</$button></$fieldmangler></p>\n\n<div class=\"tw-block-dropdown-wrapper\">\n<$reveal state=<<qualify \"$:/state/typeDropdown\">> type=\"nomatch\" text=\"\" default=\"\">\n<div class=\"tw-block-dropdown tw-edit-type-dropdown\">\n<$linkcatcher to=\"!!type\">\n<$list filter=\"[all[shadows+tiddlers]prefix[$:/language/Docs/Types/]] +[sort[description]]\"><$link to={{!!name}}><$view field=\"description\"/> (<$view field=\"name\"/>)</$link>\n</$list>\n</$linkcatcher>\n</div>\n</$reveal>\n</div>"
},
"$:/core/ui/EditTemplate": {
"title": "$:/core/ui/EditTemplate",
"text": "\\define frame-classes()\ntw-tiddler-frame tw-tiddler-edit-frame $(missingTiddlerClass)$ $(shadowTiddlerClass)$ $(systemTiddlerClass)$\n\\end\n<div class=<<frame-classes>>>\n<$set name=\"storyTiddler\" value=<<currentTiddler>>>\n<$keyboard key=\"ctrl+enter\" message=\"tw-save-tiddler\">\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/EditTemplate]!has[draft.of]]\" variable=\"listItem\">\n<$transclude tiddler=<<listItem>>/>\n</$list>\n</$keyboard>\n</$set>\n</div>\n"
},
"$:/core/ui/EditToolbar/cancel": {
"title": "$:/core/ui/EditToolbar/cancel",
"tags": "$:/tags/EditToolbar",
"text": "<$button message=\"tw-cancel-tiddler\" class=\"btn-invisible\">{{$:/core/images/cancel-button}}</$button>"
},
"$:/core/ui/EditToolbar/delete": {
"title": "$:/core/ui/EditToolbar/delete",
"tags": "$:/tags/EditToolbar",
"text": "<$button message=\"tw-delete-tiddler\" class=\"btn-invisible\">{{$:/core/images/delete-button}}</$button>"
},
"$:/core/ui/EditToolbar/save": {
"title": "$:/core/ui/EditToolbar/save",
"tags": "$:/tags/EditToolbar",
"text": "<$button message=\"tw-save-tiddler\" class=\"btn-invisible\">{{$:/core/images/done-button}}</$button>"
},
"$:/core/Filters/AllTags": {
"title": "$:/core/Filters/AllTags",
"tags": "$:/tags/Filter",
"filter": "[tags[]!is[system]sort[title]]",
"description": "{{$:/language/Filters/AllTags}}",
"text": ""
},
"$:/core/Filters/AllTiddlers": {
"title": "$:/core/Filters/AllTiddlers",
"tags": "$:/tags/Filter",
"filter": "[!is[system]sort[title]]",
"description": "{{$:/language/Filters/AllTiddlers}}",
"text": ""
},
"$:/core/Filters/Drafts": {
"title": "$:/core/Filters/Drafts",
"tags": "$:/tags/Filter",
"filter": "[has[draft.of]sort[title]]",
"description": "{{$:/language/Filters/Drafts}}",
"text": ""
},
"$:/core/Filters/Missing": {
"title": "$:/core/Filters/Missing",
"tags": "$:/tags/Filter",
"filter": "[all[missing]sort[title]]",
"description": "{{$:/language/Filters/Missing}}",
"text": ""
},
"$:/core/Filters/Orphans": {
"title": "$:/core/Filters/Orphans",
"tags": "$:/tags/Filter",
"filter": "[all[orphans]sort[title]]",
"description": "{{$:/language/Filters/Orphans}}",
"text": ""
},
"$:/core/Filters/OverriddenShadowTiddlers": {
"title": "$:/core/Filters/OverriddenShadowTiddlers",
"tags": "$:/tags/Filter",
"filter": "[is[shadow]]",
"description": "{{$:/language/Filters/OverriddenShadowTiddlers}}",
"text": ""
},
"$:/core/Filters/RecentTiddlers": {
"title": "$:/core/Filters/RecentTiddlers",
"tags": "$:/tags/Filter",
"filter": "[!is[system]has[modified]!sort[modified]]",
"description": "{{$:/language/Filters/RecentTiddlers}}",
"text": ""
},
"$:/core/Filters/ShadowTiddlers": {
"title": "$:/core/Filters/ShadowTiddlers",
"tags": "$:/tags/Filter",
"filter": "[all[shadows]sort[title]]",
"description": "{{$:/language/Filters/ShadowTiddlers}}",
"text": ""
},
"$:/core/Filters/SystemTags": {
"title": "$:/core/Filters/SystemTags",
"tags": "$:/tags/Filter",
"filter": "[all[shadows+tiddlers]tags[]is[system]sort[title]]",
"description": "{{$:/language/Filters/SystemTags}}",
"text": ""
},
"$:/core/Filters/SystemTiddlers": {
"title": "$:/core/Filters/SystemTiddlers",
"tags": "$:/tags/Filter",
"filter": "[is[system]sort[title]]",
"description": "{{$:/language/Filters/SystemTiddlers}}",
"text": ""
},
"$:/core/ui/ListItemTemplate": {
"title": "$:/core/ui/ListItemTemplate",
"text": "<div class=\"tw-menu-list-item\">\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</div>"
},
"$:/core/ui/MissingTemplate": {
"title": "$:/core/ui/MissingTemplate",
"text": "<div class=\"tw-tiddler-missing\">\n<$button popup=<<qualify \"$:/state/missingpopup\">> class=\"btn-invisible tw-missing-tiddler-label\">\n<$view field=\"title\" format=\"text\" />\n</$button>\n<$reveal state=<<qualify \"$:/state/missingpopup\">> type=\"popup\" position=\"below\" animate=\"yes\">\n<div class=\"tw-drop-down\">\n<$transclude tiddler=\"$:/core/ui/ListItemTemplate\"/>\n<hr>\n<$list filter=\"[all[current]backlinks[]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n</div>\n</$reveal>\n</div>\n"
},
"$:/core/ui/MoreSideBar/All": {
"title": "$:/core/ui/MoreSideBar/All",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/All/Caption}}",
"text": "<$list filter=\"[!is[system]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/Drafts": {
"title": "$:/core/ui/MoreSideBar/Drafts",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Drafts/Caption}}",
"text": "<$list filter=\"[has[draft.of]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/Missing": {
"title": "$:/core/ui/MoreSideBar/Missing",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Missing/Caption}}",
"text": "<$list filter=\"[all[missing]sort[title]]\" template=\"$:/core/ui/MissingTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/Orphans": {
"title": "$:/core/ui/MoreSideBar/Orphans",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Orphans/Caption}}",
"text": "<$list filter=\"[all[orphans]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/Recent": {
"title": "$:/core/ui/MoreSideBar/Recent",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Recent/Caption}}",
"text": "{{$:/snippets/recentchanges}}\n"
},
"$:/core/ui/MoreSideBar/Shadows": {
"title": "$:/core/ui/MoreSideBar/Shadows",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Shadows/Caption}}",
"text": "<$list filter=\"[all[shadows]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/System": {
"title": "$:/core/ui/MoreSideBar/System",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/System/Caption}}",
"text": "<$list filter=\"[is[system]sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/MoreSideBar/Tags": {
"title": "$:/core/ui/MoreSideBar/Tags",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Tags/Caption}}",
"text": "\\define lingo-base() $:/language/SideBar/Tags/\n<$button to=\"$:/TagManager\" class=\"btn\"><<lingo TagManager/Caption>></$button>\n\n<$list filter=\"[tags[]!is[system]sort[title]]\">\n\n<$transclude tiddler=\"$:/core/ui/TagTemplate\"/> <small class=\"tw-menu-list-count\"><$count filter=\"[all[current]tagging[]]\"/></small>\n\n</$list>\n\n----\n\n{{$:/core/ui/UntaggedTemplate}} <small class=\"tw-menu-list-count\"><$count filter=\"[untagged[]!is[system]] -[tags[]]\"/></small>\n"
},
"$:/core/ui/MoreSideBar/Types": {
"title": "$:/core/ui/MoreSideBar/Types",
"tags": "$:/tags/MoreSideBar",
"caption": "{{$:/language/SideBar/Types/Caption}}",
"text": "<$list filter=\"[!is[system]has[type]each[type]sort[type]] -[type[text/vnd.tiddlywiki]]\">\n<div class=\"tw-menu-list-item\">\n<$view field=\"type\"/>\n<$list filter=\"[type{!!type}!is[system]sort[title]]\">\n<div class=\"tw-menu-list-subitem\">\n<$link to={{!!title}}><$view field=\"title\"/></$link>\n</div>\n</$list>\n</div>\n</$list>\n"
},
"$:/core/ui/PageControls/control-panel": {
"title": "$:/core/ui/PageControls/control-panel",
"tags": "$:/tags/PageControls",
"text": "<$button to=\"$:/ControlPanel\" class=\"btn-invisible\">{{$:/core/images/options-button}}</$button>"
},
"$:/core/ui/PageControls/new-tiddler": {
"title": "$:/core/ui/PageControls/new-tiddler",
"tags": "$:/tags/PageControls",
"text": "<$button message=\"tw-new-tiddler\" class=\"btn-invisible\">{{$:/core/images/new-button}}</$button>"
},
"$:/core/ui/PageControls/save-wiki": {
"title": "$:/core/ui/PageControls/save-wiki",
"tags": "$:/tags/PageControls",
"text": "<$button message=\"tw-save-wiki\" class=\"btn-invisible\">{{$:/core/images/save-button}}</$button>"
},
"$:/core/ui/PageMacros": {
"title": "$:/core/ui/PageMacros",
"text": "\\define colour(name)\n<$transclude tiddler={{$:/palette}} index=\"$name$\"/>\n\\end\n\n\\define color(name)\n<<colour $name$>>\n\\end\n\n\\define tabs(tabsList,default,state:\"$:/state/tab\",class)\n<div class=\"tw-tab-set $class$\">\n<div class=\"tw-tab-buttons $class$\">\n\t<$list filter=\"$tabsList$\" variable=\"currentTab\">\n\t\t<$button set=<<qualify \"$state$\">> setTo=<<currentTab>> default=\"$default$\" selectedClass=\"tw-tab-selected\">\n\t\t\t<$transclude tiddler=<<currentTab>> field=\"caption\">\n\t\t\t<$macrocall $name=\"currentTab\" $type=\"text/plain\" $output=\"text/plain\"/>\n\t\t\t</$transclude>\n\t\t</$button>\n\t</$list>\n</div><div class=\"tw-tab-divider $class$\"/><div class=\"tw-tab-content $class$\">\n\t<$list filter=\"$tabsList$\" variable=\"currentTab\">\n\t\t<$reveal type=\"match\" state=<<qualify \"$state$\">> text=<<currentTab>> default=\"$default$\">\n\t\t\t<$transclude tiddler=<<currentTab>> mode=\"block\"/>\n\t\t</$reveal>\n\t</$list>\n</div>\n</div>\n\\end\n\n\\define wikitext-example(src)\n```\n$src$\n```\n\nRenders as:\n\n$src$\n\nIn HTML:\n\n$$$text/vnd.tiddlywiki>text/html\n$src$\n$$$\n\n\\end\n\n\\define wikitext-example-without-html(src)\n```\n$src$\n```\n\nRenders as:\n\n$src$\n\n\\end\n\n\\define lingo-base()\n$:/lingo/\n\\end\n\n\\define lingo(title)\n{{$(lingo-base)$$title$}}\n\\end\n{{$:/core/ui/PageTemplate}}\n"
},
"$:/core/ui/PageStylesheet": {
"title": "$:/core/ui/PageStylesheet",
"text": "\\define colour(name)\n<$transclude tiddler={{$:/palette}} index=\"$name$\"/>\n\\end\n\\define color(name)\n<<colour $name$>>\n\\end\n\\define box-shadow(shadow)\n```\n -webkit-box-shadow: $shadow$;\n -moz-box-shadow: $shadow$;\n box-shadow: $shadow$;\n```\n\\end\n\\define filter(filter)\n```\n -webkit-filter: $filter$;\n -moz-filter: $filter$;\n filter: $filter$;\n```\n\\end\n\\define transition(transition)\n```\n -webkit-transition: $transition$;\n -moz-transition: $transition$;\n transition: $transition$;\n```\n\\end\n\\define transform-origin(origin)\n```\n -webkit-transform-origin: $origin$;\n -moz-transform-origin: $origin$;\n transform-origin: $origin$;\n```\n\\end\n\\define background-linear-gradient(gradient)\n```\nbackground-image: linear-gradient($gradient$);\nbackground-image: -o-linear-gradient($gradient$);\nbackground-image: -moz-linear-gradient($gradient$);\nbackground-image: -webkit-linear-gradient($gradient$);\nbackground-image: -ms-linear-gradient($gradient$);\n```\n\\end\n\\define datauri(title)\n<$macrocall $name=\"makedatauri\" type={{$title$!!type}} text={{$title$}}/>\n\\end\n\\define if-sidebar(text)\n<$reveal state=\"$:/state/sidebar\" type=\"match\" text=\"yes\" default=\"yes\">$text$</$reveal>\n\\end\n\\define if-no-sidebar(text)\n<$reveal state=\"$:/state/sidebar\" type=\"nomatch\" text=\"yes\" default=\"yes\">$text$</$reveal>\n\\end\n\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/stylesheet]]\">\n<$transclude/>\n</$list>\n"
},
"$:/core/ui/PageTemplate/alerts": {
"title": "$:/core/ui/PageTemplate/alerts",
"tags": "$:/tags/PageTemplate",
"text": "<div class=\"tw-alerts\">\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/Alert]!has[draft.of]]\" template=\"$:/core/ui/AlertTemplate\" storyview=\"pop\"/>\n\n</div>\n"
},
"$:/core/ui/PageTemplate/sidebar": {
"title": "$:/core/ui/PageTemplate/sidebar",
"tags": "$:/tags/PageTemplate",
"text": "<$scrollable fallthrough=\"no\" class=\"tw-sidebar-scrollable\">\n\n<div class=\"sidebar-header\">\n\n<$reveal state=\"$:/state/sidebar\" type=\"match\" text=\"yes\" default=\"yes\" retain=\"yes\">\n\n<div class=\"tw-site-title\">\n\n<$transclude tiddler=\"$:/SiteTitle\" mode=\"inline\"/>\n\n</div>\n\n<div class=\"tw-site-subtitle\">\n\n<$transclude tiddler=\"$:/SiteSubtitle\" mode=\"inline\"/>\n\n</div>\n\n<div class=\"tw-page-controls\">\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/PageControls]!has[draft.of]]\" variable=\"listItem\">\n\n<$transclude tiddler=<<listItem>> mode=\"inline\"/>\n\n</$list>\n\n</div>\n\n<$transclude tiddler=\"$:/core/ui/SideBarLists\" mode=\"inline\"/>\n\n</$reveal>\n\n</div>\n\n</$scrollable>"
},
"$:/core/ui/PageTemplate/story": {
"title": "$:/core/ui/PageTemplate/story",
"tags": "$:/tags/PageTemplate",
"text": "<section class=\"story-river\">\n\n<$list filter=\"[list[$:/StoryList]]\" history=\"$:/HistoryList\" template=\"$:/core/ui/ViewTemplate\" editTemplate=\"$:/core/ui/EditTemplate\" storyview={{$:/view}} />\n\n</section>\n"
},
"$:/core/ui/PageTemplate/topleftbar": {
"title": "$:/core/ui/PageTemplate/topleftbar",
"tags": "$:/tags/PageTemplate",
"text": "<span class=\"tw-topbar tw-topbar-left\">\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/TopLeftBar]!has[draft.of]]\" variable=\"listItem\">\n\n<$transclude tiddler=<<listItem>> mode=\"inline\"/>\n\n</$list>\n\n</span>\n"
},
"$:/core/ui/PageTemplate/toprightbar": {
"title": "$:/core/ui/PageTemplate/toprightbar",
"tags": "$:/tags/PageTemplate",
"text": "<span class=\"tw-topbar tw-topbar-right\">\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/TopRightBar]!has[draft.of]]\" variable=\"listItem\">\n\n<$transclude tiddler=<<listItem>> mode=\"inline\"/>\n\n</$list>\n\n</span>\n"
},
"$:/core/ui/PageTemplate": {
"title": "$:/core/ui/PageTemplate",
"text": "\\define containerClasses()\ntw-page-container tw-page-view-$(themeTitle)$ tw-language-$(languageTitle)$\n\\end\n\n<$set name=\"themeTitle\" value={{$:/view}}>\n\n<$set name=\"currentTiddler\" value={{$:/language}}>\n\n<$set name=\"languageTitle\" value={{!!name}}>\n\n<div class=<<containerClasses>>>\n\n<$navigator story=\"$:/StoryList\" history=\"$:/HistoryList\">\n\n<$dropzone>\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]\" variable=\"listItem\">\n\n<$transclude tiddler=<<listItem>>/>\n\n</$list>\n\n</$dropzone>\n\n</$navigator>\n\n</div>\n\n</$set>\n\n</$set>\n\n</$set>\n"
},
"$:/core/ui/SideBar/More": {
"title": "$:/core/ui/SideBar/More",
"tags": "$:/tags/SideBar",
"caption": "{{$:/language/SideBar/More/Caption}}",
"text": "<div class=\"tw-more-sidebar\">\n<<tabs \"[all[shadows+tiddlers]tag[$:/tags/MoreSideBar]!has[draft.of]]\" \"$:/core/ui/MoreSideBar/Tags\" \"$:/state/tab/moresidebar\" \"tw-vertical\">>\n</div>\n"
},
"$:/core/ui/SideBar/Open": {
"title": "$:/core/ui/SideBar/Open",
"tags": "$:/tags/SideBar",
"caption": "{{$:/language/SideBar/Open/Caption}}",
"text": "\\define lingo-base() $:/language/CloseAll/\n<$list filter=\"[list[$:/StoryList]]\" history=\"$:/HistoryList\" storyview=\"pop\">\n\n<$button message=\"tw-close-tiddler\" class=\"btn-invisible btn-mini\">×</$button> <$link to={{!!title}}><$view field=\"title\"/></$link>\n\n</$list>\n\n<$button message=\"tw-close-all-tiddlers\" class=\"btn-invisible btn-mini\"><<lingo Button>></$button>\n"
},
"$:/core/ui/SideBar/Recent": {
"title": "$:/core/ui/SideBar/Recent",
"tags": "$:/tags/SideBar",
"caption": "{{$:/language/SideBar/Recent/Caption}}",
"text": "{{$:/snippets/recentchanges}}\n"
},
"$:/core/ui/SideBar/Tools": {
"title": "$:/core/ui/SideBar/Tools",
"tags": "$:/tags/SideBar",
"caption": "{{$:/language/SideBar/Tools/Caption}}",
"text": "\\define lingo-base() $:/language/ControlPanel/\n<<lingo Tools/Import/Prompt>> <$browse/>\n\n---\n\n{{$:/snippets/encryptionstatus}}\n\n---\n\n<<lingo Basics/Version/Prompt>> <<version>>\n\n---\n\n{{$:/snippets/viewswitcher}}\n\n---\n\n{{$:/snippets/minithemeswitcher}}\n\n---\n\n{{$:/snippets/languageswitcher}}\n"
},
"$:/core/ui/SideBarLists": {
"title": "$:/core/ui/SideBarLists",
"text": "<div class=\"tw-sidebar-lists\">\n\t<div class=\"tw-search\">\n\t\t<$edit-text tiddler=\"$:/temp/search\" type=\"search\" tag=\"input\"/>\n\t\t<$reveal state=\"$:/temp/search\" type=\"nomatch\" text=\"\">\n\t\t\t<$linkcatcher to=\"$:/temp/search\">\n\t\t\t\t<$link to=\"\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$link>\n\t\t\t</$linkcatcher>\n\t\t</$reveal>\n\t\t<$reveal state=\"$:/temp/search\" type=\"match\" text=\"\"> <$link to=\"$:/AdvancedSearch\" class=\"btn-invisible\">…</$link>\n\t\t</$reveal>\n\t</div>\n\t<$reveal state=\"$:/temp/search\" type=\"nomatch\" text=\"\">\n\t\t<div class=\"tw-search-results\">\n\t\t\t{{$:/language/Search/Matches}}\n\t\t\t<$list filter=\"[!is[system]search{$:/temp/search}sort[title]limit[250]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n\t\t</div>\n\t</$reveal>\n\t<$reveal state=\"$:/temp/search\" type=\"match\" text=\"\">\n\t\t<<tabs \"[all[shadows+tiddlers]tag[$:/tags/SideBar]!has[draft.of]]\" \"$:/core/ui/SideBar/Open\" \"$:/state/tab/sidebar\">>\n\t</$reveal>\n</div>\n"
},
"$:/TagManager": {
"title": "$:/TagManager",
"text": "\\define lingo-base() $:/language/TagManager/\n\\define iconEditor(title)\n<$edit-text field=\"icon\" tag=\"input\" size=\"20\"/> <$button popup=<<qualify \"$:/state/iconDropdown/$title$\">> class=\"btn-invisible btn-dropdown\">{{$:/core/images/down-arrow}}</$button>\n<div class=\"tw-block-dropdown-wrapper\">\n<$reveal state=<<qualify \"$:/state/iconDropdown/$title$\">> type=\"nomatch\" text=\"\" default=\"\">\n<$linkcatcher to=\"$title$!!icon\">\n<div class=\"tw-block-dropdown tw-edit-type-dropdown\">\n<$list filter=\"[all[shadows+tiddlers]is[image]] [all[shadows+tiddlers]tag[$:/tags/Image]] +[sort[title]]\">\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</$list>\n</div>\n</$linkcatcher>\n</$reveal>\n</div>\n\\end\n<table>\n<tbody>\n<tr>\n<th><<lingo Tag/Heading>></th>\n<th><<lingo Count/Heading>></th>\n<th><<lingo Colour/Heading>></th>\n<th><<lingo Icon/Heading>></th>\n</tr>\n<$list filter=\"[tags[]!is[system]sort[title]]\">\n<tr>\n<td><$transclude tiddler=\"$:/core/ui/TagTemplate\"/></td>\n<td><$count filter=\"[all[current]tagging[]]\"/></td>\n<td><$edit-text field=\"color\" tag=\"input\" type=\"text\" size=\"9\"/> <$edit-text field=\"color\" tag=\"input\" type=\"color\"/></td>\n<td><$macrocall $name=\"iconEditor\" title={{!!title}}/></td>\n</tr>\n</$list>\n</tbody>\n</table>\n"
},
"$:/core/ui/TagTemplate": {
"title": "$:/core/ui/TagTemplate",
"text": "\\define tag-styles()\nbackground-color:$(backgroundColor)$;\n\\end\n<span class=\"tw-tag-list-item\">\n<$set name=\"backgroundColor\" value={{!!color}}>\n<$button popup=<<qualify \"$:/state/tagpopup\">> class=\"btn-invisible tw-tag-label\" style=<<tag-styles>>>\n<$transclude tiddler={{!!icon}}/> <$view field=\"title\" format=\"text\" />\n</$button>\n</$set>\n<$reveal state=<<qualify \"$:/state/tagpopup\">> type=\"popup\" position=\"below\" animate=\"yes\"><div class=\"tw-drop-down\"><$transclude tiddler=\"$:/core/ui/ListItemTemplate\"/>\n<hr>\n<$list filter=\"[all[current]tagging[]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n</div>\n</$reveal>\n</span>\n"
},
"$:/core/ui/TiddlerFieldTemplate": {
"title": "$:/core/ui/TiddlerFieldTemplate",
"text": "<tr class=\"tw-view-field\">\n<td class=\"tw-view-field-name\">\n<$text text=<<listItem>>/>\n</td>\n<td class=\"tw-view-field-value\">\n<$view field=<<listItem>>/>\n</td>\n</tr>"
},
"$:/core/ui/TiddlerFields": {
"title": "$:/core/ui/TiddlerFields",
"text": "<table class=\"tw-view-field-table\">\n<tbody>\n<$list filter=\"[all[current]fields[]sort[title]] -text\" template=\"$:/core/ui/TiddlerFieldTemplate\" variable=\"listItem\"/>\n</tbody>\n</table>\n"
},
"$:/core/ui/TiddlerInfo/Advanced/PluginInfo": {
"title": "$:/core/ui/TiddlerInfo/Advanced/PluginInfo",
"tags": "$:/tags/TiddlerInfo/Advanced",
"text": "\\define lingo-base() $:/language/TiddlerInfo/Advanced/PluginInfo/\n<$list filter=\"[all[current]has[plugin-type]]\">\n\n! <<lingo Heading>>\n\n<<lingo Hint>>\n<ul>\n<$list filter=\"[all[current]plugintiddlers[]sort[title]]\" emptyMessage=<<lingo Empty/Hint>>>\n<li>\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</li>\n</$list>\n</ul>\n\n</$list>\n"
},
"$:/core/ui/TiddlerInfo/Advanced/ShadowInfo": {
"title": "$:/core/ui/TiddlerInfo/Advanced/ShadowInfo",
"tags": "$:/tags/TiddlerInfo/Advanced",
"text": "\\define lingo-base() $:/language/TiddlerInfo/Advanced/ShadowInfo/\n<$set name=\"infoTiddler\" value=<<currentTiddler>>>\n\n''<<lingo Heading>>''\n\n<$list filter=\"[all[current]!is[shadow]]\">\n\n<<lingo NotShadow/Hint>>\n\n</$list>\n\n<$list filter=\"[all[current]is[shadow]]\">\n\n<<lingo Shadow/Hint>>\n\n<$list filter=\"[all[current]shadowsource[]]\">\n\n<$set name=\"pluginTiddler\" value=<<currentTiddler>>>\n<<lingo Shadow/Source>>\n</$set>\n\n</$list>\n\n<$list filter=\"[all[current]is[shadow]is[tiddler]]\">\n\n<<lingo OverriddenShadow/Hint>>\n\n</$list>\n\n\n</$list>\n</$set>\n"
},
"$:/core/ui/TiddlerInfo/Advanced": {
"title": "$:/core/ui/TiddlerInfo/Advanced",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/Advanced/Caption}}",
"text": "<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/TiddlerInfo/Advanced]!has[draft.of]]\" variable=\"listItem\">\n<$transclude tiddler=<<listItem>>/>\n\n</$list>\n"
},
"$:/core/ui/TiddlerInfo/Fields": {
"title": "$:/core/ui/TiddlerInfo/Fields",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/Fields/Caption}}",
"text": "<$transclude tiddler=\"$:/core/ui/TiddlerFields\"/>\n"
},
"$:/core/ui/TiddlerInfo/List": {
"title": "$:/core/ui/TiddlerInfo/List",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/List/Caption}}",
"text": "\\define lingo-base() $:/language/TiddlerInfo/\n<$list filter=\"[list{!!title}]\" emptyMessage=<<lingo List/Empty>> template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/TiddlerInfo/Listed": {
"title": "$:/core/ui/TiddlerInfo/Listed",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/Listed/Caption}}",
"text": "\\define lingo-base() $:/language/TiddlerInfo/\n<$list filter=\"[all[current]listed[]!is[system]]\" emptyMessage=<<lingo Listed/Empty>> template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/TiddlerInfo/References": {
"title": "$:/core/ui/TiddlerInfo/References",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/References/Caption}}",
"text": "\\define lingo-base() $:/language/TiddlerInfo/\n<$list filter=\"[all[current]backlinks[]sort[title]]\" emptyMessage=<<lingo References/Empty>> template=\"$:/core/ui/ListItemTemplate\">\n</$list>\n"
},
"$:/core/ui/TiddlerInfo/Tagging": {
"title": "$:/core/ui/TiddlerInfo/Tagging",
"tags": "$:/tags/TiddlerInfo",
"caption": "{{$:/language/TiddlerInfo/Tagging/Caption}}",
"text": "\\define lingo-base() $:/language/TiddlerInfo/\n<$list filter=\"[all[current]tagging[]]\" emptyMessage=<<lingo Tagging/Empty>> template=\"$:/core/ui/ListItemTemplate\"/>\n"
},
"$:/core/ui/TiddlerInfo": {
"title": "$:/core/ui/TiddlerInfo",
"text": "<<tabs \"[all[shadows+tiddlers]tag[$:/tags/TiddlerInfo]!has[draft.of]]\" \"$:/core/ui/TiddlerInfo/References\">>\n"
},
"$:/core/ui/TopBar/menu": {
"title": "$:/core/ui/TopBar/menu",
"tags": "$:/tags/TopRightBar",
"text": "<$reveal state=\"$:/state/sidebar\" type=\"nomatch\" text=\"no\">\n<$button set=\"$:/state/sidebar\" setTo=\"no\" class=\"btn-invisible\">{{$:/core/images/chevron-right}}</$button>\n</$reveal>\n<$reveal state=\"$:/state/sidebar\" type=\"match\" text=\"no\">\n<$button set=\"$:/state/sidebar\" setTo=\"yes\" class=\"btn-invisible\">{{$:/core/images/chevron-left}}</$button>\n</$reveal>\n"
},
"$:/core/ui/UntaggedTemplate": {
"title": "$:/core/ui/UntaggedTemplate",
"text": "\\define lingo-base() $:/language/SideBar/\n<$button popup=<<qualify \"$:/state/tagpopup\">> class=\"btn-invisible tw-untagged-label tw-tag-label\">\n<<lingo Tags/Untagged/Caption>>\n</$button>\n<$reveal state=<<qualify \"$:/state/tagpopup\">> type=\"popup\" position=\"below\">\n<div class=\"tw-drop-down\">\n<$list filter=\"[untagged[]!is[system]] -[tags[]] +[sort[title]]\" template=\"$:/core/ui/ListItemTemplate\"/>\n</div>\n</$reveal>\n"
},
"$:/core/ui/ViewTemplate/body": {
"title": "$:/core/ui/ViewTemplate/body",
"tags": "$:/tags/ViewTemplate",
"text": "<div class=\"body\">\n\n<$transclude>\n\n<$transclude tiddler=\"$:/language/MissingTiddler/Hint\"/>\n\n</$transclude>\n\n</div>\n"
},
"$:/core/ui/ViewTemplate/classic": {
"title": "$:/core/ui/ViewTemplate/classic",
"tags": "$:/tags/ViewTemplate $:/tags/EditTemplate",
"text": "\\define lingo-base() $:/language/ClassicWarning/\n<$list filter=\"[all[current]type[text/x-tiddlywiki]]\">\n<div class=\"tw-message-box\">\n\n<<lingo Hint>>\n\n<$button set=\"!!type\" setTo=\"text/vnd.tiddlywiki\"><<lingo Upgrade/Caption>></$button>\n\n</div>\n</$list>\n"
},
"$:/core/ui/ViewTemplate/subtitle": {
"title": "$:/core/ui/ViewTemplate/subtitle",
"tags": "$:/tags/ViewTemplate",
"text": "<div class=\"tw-subtitle\">\n<$link to={{!!modifier}}>\n<$view field=\"modifier\"/>\n</$link> <$view field=\"modified\" format=\"relativedate\"/>\n</div>\n"
},
"$:/core/ui/ViewTemplate/tags": {
"title": "$:/core/ui/ViewTemplate/tags",
"tags": "$:/tags/ViewTemplate",
"text": "<div class=\"tw-tags-wrapper\"><$list filter=\"[all[current]tags[]sort[title]]\" template=\"$:/core/ui/TagTemplate\" storyview=\"pop\"/></div>\n"
},
"$:/core/ui/ViewTemplate/title": {
"title": "$:/core/ui/ViewTemplate/title",
"tags": "$:/tags/ViewTemplate",
"text": "\\define title-styles()\nfill:$(foregroundColor)$;\n\\end\n<div class=\"tw-tiddler-title\">\n<div class=\"titlebar\">\n<span class=\"tw-tiddler-controls\">\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]]\" variable=\"listItem\"><$transclude tiddler=<<listItem>>/></$list>\n</span>\n<$set name=\"foregroundColor\" value={{!!color}}>\n<span style=<<title-styles>>>\n<$transclude tiddler={{!!icon}}/>\n</span>\n</$set>\n<$list filter=\"[all[current]removeprefix[$:/]]\">\n<span class=\"title\" title={{$:/language/SystemTiddler/Tooltip}}>\n<span class=\"tw-system-title-prefix\">$:/</span><$text text=<<currentTiddler>>/>\n</span>\n</$list>\n<$list filter=\"[all[current]!prefix[$:/]]\">\n<span class=\"title\">\n<$view field=\"title\"/>\n</span>\n</$list>\n</div>\n\n<$reveal type=\"nomatch\" text=\"\" default=\"\" state=<<tiddlerInfoState>> class=\"tw-tiddler-info tw-popup\" animate=\"yes\" retain=\"yes\">\n\n<$transclude tiddler=\"$:/core/ui/TiddlerInfo\"/>\n\n</$reveal>\n</div>"
},
"$:/core/ui/ViewTemplate": {
"title": "$:/core/ui/ViewTemplate",
"text": "\\define frame-classes()\ntw-tiddler-frame tw-tiddler-view-frame $(missingTiddlerClass)$ $(shadowTiddlerClass)$ $(systemTiddlerClass)$\n\\end\n<$set name=\"storyTiddler\" value=<<currentTiddler>>><$set name=\"tiddlerInfoState\" value=<<qualify \"$:/state/tiddlerInfo\">>><$tiddler tiddler=<<currentTiddler>>><div class=<<frame-classes>>><$list filter=\"[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]\" variable=\"listItem\"><$transclude tiddler=<<listItem>>/></$list>\n</div>\n</$tiddler></$set></$set>\n"
},
"$:/core/ui/ViewToolbar/close": {
"title": "$:/core/ui/ViewToolbar/close",
"tags": "$:/tags/ViewToolbar",
"text": "<$button message=\"tw-close-tiddler\" class=\"btn-invisible\">{{$:/core/images/close-button}}</$button>"
},
"$:/core/ui/ViewToolbar/edit": {
"title": "$:/core/ui/ViewToolbar/edit",
"tags": "$:/tags/ViewToolbar",
"text": "<$button message=\"tw-edit-tiddler\" class=\"btn-invisible\">{{$:/core/images/edit-button}}</$button>"
},
"$:/core/ui/ViewToolbar/info": {
"title": "$:/core/ui/ViewToolbar/info",
"tags": "$:/tags/ViewToolbar",
"text": "<$button popup=<<tiddlerInfoState>> class=\"btn-invisible\" selectedClass=\"tw-selected\">{{$:/core/images/info-button}}</$button>"
},
"$:/DefaultTiddlers": {
"title": "$:/DefaultTiddlers",
"text": "GettingStarted\n[!is[system]has[modified]!sort[modified]limit[25]]"
},
"$:/temp/advancedsearch": {
"title": "$:/temp/advancedsearch",
"text": ""
},
"$:/snippets/allfields": {
"title": "$:/snippets/allfields",
"text": "\\define renderfield(title)\n<tr class=\"tw-view-field\"><td class=\"tw-view-field-name\">''$title$'':</td><td class=\"tw-view-field-value\">//{{$:/language/Docs/Fields/$title$}}//</td></tr>\n\\end\n<table class=\"tw-view-field-table\"><tbody><$list filter=\"[fields[]sort[title]]\" variable=\"listItem\"><$macrocall $name=\"renderfield\" title=<<listItem>>/></$list>\n</tbody></table>\n"
},
"$:/snippets/autosavestatus": {
"title": "$:/snippets/autosavestatus",
"text": "\\define lingo-base() $:/language/ControlPanel/Saving/\n<$reveal type=\"match\" state=\"$:/config/AutoSave\" text=\"yes\">\n<<lingo AutoSave/Enabled/Prompt>>\n<$linkcatcher to=\"$:/config/AutoSave\"><$button to=\"no\"><<lingo AutoSave/Enabled/Button>>\n</$button></$linkcatcher>\n</$reveal>\n<$reveal type=\"nomatch\" state=\"$:/config/AutoSave\" text=\"yes\">\n<<lingo AutoSave/Disabled/Prompt>>\n<$linkcatcher to=\"$:/config/AutoSave\"><$button to=\"yes\"><<lingo AutoSave/Disabled/Button>></$button></$linkcatcher>\n</$reveal>"
},
"$:/config/AnimationDuration": {
"title": "$:/config/AnimationDuration",
"text": "400"
},
"$:/config/AutoSave": {
"title": "$:/config/AutoSave",
"text": "yes"
},
"$:/config/BitmapEditor/Colour": {
"title": "$:/config/BitmapEditor/Colour",
"text": "#ff0"
},
"$:/config/BitmapEditor/LineWidth": {
"title": "$:/config/BitmapEditor/LineWidth",
"text": "3"
},
"$:/config/Navigation/UpdateAddressBar": {
"title": "$:/config/Navigation/UpdateAddressBar",
"text": "permaview"
},
"$:/config/Navigation/UpdateHistory": {
"title": "$:/config/Navigation/UpdateHistory",
"text": "no"
},
"$:/config/SyncFilter": {
"title": "$:/config/SyncFilter",
"text": "[is[tiddler]] -[[$:/HistoryList]] -[[$:/StoryList]] -[[$:/isEncrypted]] -[prefix[$:/status]] -[prefix[$:/state]] -[prefix[$:/temp]]"
},
"$:/snippets/currpalettepreview": {
"title": "$:/snippets/currpalettepreview",
"text": "\\define swatchStyle()\nbackground-color: $(swatchColour)$;\n\\end\n\\define swatch(colour)\n<$set name=\"swatchColour\" value={{##$colour$}}>\n<div class=\"tw-swatch\" style=<<swatchStyle>>/>\n</$set>\n\\end\n<div class=\"tw-swatches-horiz\">\n<<swatch foreground>>\n<<swatch background>>\n<<swatch muted-foreground>>\n<<swatch primary>>\n<<swatch page-background>>\n<<swatch tab-background>>\n<<swatch tiddler-info-background>>\n</div>\n"
},
"$:/snippets/download-wiki-button": {
"title": "$:/snippets/download-wiki-button",
"text": "\\define lingo-base() $:/language/ControlPanel/Tools/Download/\n<$button message=\"tw-download-file\" param=\"$:/core/save/all\" class=\"btn-big-green\"><<lingo Full/Caption>> {{$:/core/images/save-button}}</$button>"
},
"$:/snippets/encryptionstatus": {
"title": "$:/snippets/encryptionstatus",
"text": "\\define lingo-base() $:/language/ControlPanel/Tools/Encryption/\n<$reveal type=\"match\" state=\"$:/isEncrypted\" text=\"yes\">\n<<lingo Enabled/Prompt>>\n<$button message=\"tw-clear-password\" class=\"btn btn-danger\"><<lingo ClearPassword/Button>></$button>\n<$button message=\"tw-set-password\" class=\"btn btn-warning\"><<lingo ChangePassword/Button>></$button>\n</$reveal>\n<$reveal type=\"nomatch\" state=\"$:/isEncrypted\" text=\"yes\">\n<<lingo Disabled/Prompt>>\n<$button message=\"tw-set-password\" class=\"btn btn-warning\"><<lingo SetPassword/Button>></$button>\n</$reveal>"
},
"$:/snippets/languageswitcher": {
"title": "$:/snippets/languageswitcher",
"text": "{{$:/language/ControlPanel/Basics/Language/Prompt}} <$view tiddler={{$:/language}} field=\"description\" format=\"text\"><$view tiddler={{$:/language}} field=\"name\" format=\"text\"><$view tiddler={{$:/language}} field=\"title\" format=\"text\"/></$view></$view>\n\n<$linkcatcher to=\"$:/language\">\n<$list filter=\"[[$:/languages/en-GB]] [plugin-type[language]sort[title]]\"><div><$reveal state=\"$:/language\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/language\" type=\"nomatch\" text={{!!title}}> </$reveal> <$link to={{!!title}}><$view field=\"description\" format=\"text\"><$view field=\"name\" format=\"text\"><$view field=\"title\" format=\"text\"/></$view></$view></$link></div>\n</$list>\n</$linkcatcher>"
},
"$:/snippets/minilanguageswitcher": {
"title": "$:/snippets/minilanguageswitcher",
"text": "<$linkcatcher to=\"$:/language\">\n<$list filter=\"[[$:/languages/en-GB]] [plugin-type[language]sort[title]]\"><div><$reveal state=\"$:/language\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/language\" type=\"nomatch\" text={{!!title}}> </$reveal> <$link to={{!!title}}><$view field=\"description\" format=\"text\"><$view field=\"name\" format=\"text\"><$view field=\"title\" format=\"text\"/></$view></$view></$link></div>\n</$list>\n</$linkcatcher>"
},
"$:/snippets/minithemeswitcher": {
"title": "$:/snippets/minithemeswitcher",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/Theme/\n<<lingo Prompt>> <$view tiddler={{$:/theme}} field=\"name\"/>\n\n<$linkcatcher to=\"$:/theme\">\n<$list filter=\"[plugin-type[theme]sort[title]]\"><div><$reveal state=\"$:/theme\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/theme\" type=\"nomatch\" text={{!!title}}> </$reveal> <$link to={{!!title}}><$view field=\"name\" format=\"text\"/></$link></div>\n</$list>\n</$linkcatcher>"
},
"$:/snippets/modules": {
"title": "$:/snippets/modules",
"text": "\\define describeModuleType(type)\n{{$:/language/Docs/ModuleTypes/$type$}}\n\\end\n<$list filter=\"[moduletypes[]]\">\n\n!! <$macrocall $name=\"currentTiddler\" $type=\"text/plain\" $output=\"text/plain\"/>\n\n<$macrocall $name=\"describeModuleType\" type=<<currentTiddler>>/>\n\n<ul><$list filter=\"[all[current]modules[]]\"><li><$link><<currentTiddler>></$link>\n</li>\n</$list>\n</ul>\n</$list>\n"
},
"$:/palette": {
"title": "$:/palette",
"text": "$:/palettes/Vanilla"
},
"$:/snippets/paletteeditor": {
"title": "$:/snippets/paletteeditor",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/Palette/Editor/\n\\define describePaletteColour(colour)\n{{$:/language/Docs/PaletteColours/$colour$}}\n\\end\n<$set name=\"currentTiddler\" value={{$:/palette}}>\n\n<<lingo Prompt>> <$link to={{$:/palette}}><$macrocall $name=\"currentTiddler\" $output=\"text/plain\"/></$link>\n\n<$list filter=\"[all[current]is[shadow]is[tiddler]]\" variable=\"listItem\">\n<<lingo Prompt/Modified>>\n<$button message=\"tw-delete-tiddler\" param={{$:/palette}}><<lingo Reset/Caption>></$button>\n</$list>\n\n<$list filter=\"[all[current]is[shadow]!is[tiddler]]\" variable=\"listItem\">\n<<lingo Clone/Prompt>>\n</$list>\n\n<$button message=\"tw-new-tiddler\" param={{$:/palette}}><<lingo Clone/Caption>></$button>\n\n<table>\n<tbody>\n<$list filter=\"[all[current]indexes[]]\" variable=\"colourName\">\n<tr>\n<td>\n''<$macrocall $name=\"describePaletteColour\" colour=<<colourName>>/>''<br/>\n<$macrocall $name=\"colourName\" $output=\"text/plain\"/>\n</td>\n<td>\n<$edit-text index=<<colourName>> tag=\"input\"/>\n<br>\n<$edit-text index=<<colourName>> type=\"color\" tag=\"input\"/>\n</td>\n</tr>\n</$list>\n</tbody>\n</table>\n</$set>\n"
},
"$:/snippets/palettepreview": {
"title": "$:/snippets/palettepreview",
"text": "<$set name=\"currentTiddler\" value={{$:/palette}}>\n<$transclude tiddler=\"$:/snippets/currpalettepreview\"/>\n</$set>\n"
},
"$:/snippets/paletteswitcher": {
"title": "$:/snippets/paletteswitcher",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/Palette/\n<<lingo Prompt>> <$view tiddler={{$:/palette}} field=\"name\"/>\n\n<$linkcatcher to=\"$:/palette\">\n<div class=\"tw-chooser\"><$list filter=\"[all[shadows+tiddlers]tag[$:/tags/Palette]sort[description]]\"><div class=\"tw-chooser-item\"><$link to={{!!title}}><div><$reveal state=\"$:/palette\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/palette\" type=\"nomatch\" text={{!!title}}> </$reveal> ''<$view field=\"name\" format=\"text\"/>'' - <$view field=\"description\" format=\"text\"/></div><$transclude tiddler=\"$:/snippets/currpalettepreview\"/></$link></div>\n</$list>\n</div>\n</$linkcatcher>"
},
"$:/snippets/recentchanges": {
"title": "$:/snippets/recentchanges",
"text": "<$list filter=\"[!is[system]has[modified]!sort[modified]limit[100]eachday[modified]]\">\n<div class=\"tw-menu-list-item\">\n<$view field=\"modified\" format=\"date\" template={{$:/language/RecentChanges/DateFormat}}/>\n<$list filter=\"[sameday{!!modified}!is[system]!sort[modified]]\">\n<div class=\"tw-menu-list-subitem\">\n<$link to={{!!title}}>\n<$view field=\"title\"/>\n</$link>\n</div>\n</$list>\n</div>\n</$list>\n"
},
"$:/temp/search": {
"title": "$:/temp/search",
"text": ""
},
"$:/tags/AdvancedSearch": {
"title": "$:/tags/AdvancedSearch",
"list": "[[$:/core/ui/AdvancedSearch/Standard]] [[$:/core/ui/AdvancedSearch/System]] [[$:/core/ui/AdvancedSearch/Shadows]] [[$:/core/ui/AdvancedSearch/Filter]]"
},
"$:/tags/ControlPanel": {
"title": "$:/tags/ControlPanel",
"list": "$:/core/ui/ControlPanel/Basics $:/core/ui/ControlPanel/Appearance $:/core/ui/ControlPanel/Saving $:/core/ui/ControlPanel/Plugins $:/core/ui/ControlPanel/Tools $:/core/ui/ControlPanel/Internals"
},
"$:/tags/EditTemplate": {
"title": "$:/tags/EditTemplate",
"list": "[[$:/core/ui/EditTemplate/controls]] [[$:/core/ui/EditTemplate/title]] [[$:/core/ui/EditTemplate/tags]] [[$:/core/ui/EditTemplate/shadow]] [[$:/core/ui/ViewTemplate/classic]] [[$:/core/ui/EditTemplate/body]] [[$:/core/ui/EditTemplate/type]] [[$:/core/ui/EditTemplate/fields]]"
},
"$:/tags/EditToolbar": {
"title": "$:/tags/EditToolbar",
"list": "[[$:/core/ui/EditToolbar/delete]] [[$:/core/ui/EditToolbar/cancel]] [[$:/core/ui/EditToolbar/save]]"
},
"$:/tags/MoreSideBar": {
"title": "$:/tags/MoreSideBar",
"list": "[[$:/core/ui/MoreSideBar/All]] [[$:/core/ui/MoreSideBar/Recent]] [[$:/core/ui/MoreSideBar/Tags]] [[$:/core/ui/MoreSideBar/Missing]] [[$:/core/ui/MoreSideBar/Drafts]] [[$:/core/ui/MoreSideBar/Orphans]] [[$:/core/ui/MoreSideBar/Types]] [[$:/core/ui/MoreSideBar/System]] [[$:/core/ui/MoreSideBar/Shadows]]",
"text": ""
},
"$:/tags/PageControls": {
"title": "$:/tags/PageControls",
"list": "[[$:/core/ui/PageControls/new-tiddler]] [[$:/core/ui/PageControls/control-panel]] [[$:/core/ui/PageControls/save-wiki]]"
},
"$:/tags/PageTemplate": {
"title": "$:/tags/PageTemplate",
"list": "[[$:/core/ui/PageTemplate/sidebar]] [[$:/core/ui/PageTemplate/story]] [[$:/core/ui/PageTemplate/alerts]] [[$:/core/ui/PageTemplate/topleftbar]] [[$:/core/ui/PageTemplate/toprightbar]]",
"text": ""
},
"$:/tags/SideBar": {
"title": "$:/tags/SideBar",
"list": "[[$:/core/ui/SideBar/Open]] [[$:/core/ui/SideBar/Recent]] [[$:/core/ui/SideBar/Tools]] [[$:/core/ui/SideBar/More]]",
"text": ""
},
"$:/tags/TiddlerInfo": {
"title": "$:/tags/TiddlerInfo",
"list": "[[$:/core/ui/TiddlerInfo/References]] [[$:/core/ui/TiddlerInfo/Tagging]] [[$:/core/ui/TiddlerInfo/List]] [[$:/core/ui/TiddlerInfo/Listed]] [[$:/core/ui/TiddlerInfo/Fields]]",
"text": ""
},
"$:/tags/TiddlerInfo/Advanced": {
"title": "$:/tags/TiddlerInfo/Advanced",
"list": "[[$:/core/ui/TiddlerInfo/Advanced/ShadowInfo]] [[$:/core/ui/TiddlerInfo/Advanced/PluginInfo]]"
},
"$:/tags/ViewTemplate": {
"title": "$:/tags/ViewTemplate",
"list": "[[$:/core/ui/ViewTemplate/title]] [[$:/core/ui/ViewTemplate/subtitle]] [[$:/core/ui/ViewTemplate/tags]] [[$:/core/ui/ViewTemplate/classic]] [[$:/core/ui/ViewTemplate/body]]"
},
"$:/tags/ViewToolbar": {
"title": "$:/tags/ViewToolbar",
"list": "[[$:/core/ui/ViewToolbar/info]] [[$:/core/ui/ViewToolbar/edit]] [[$:/core/ui/ViewToolbar/close]]"
},
"$:/snippets/themeswitcher": {
"title": "$:/snippets/themeswitcher",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/Theme/\n<<lingo Prompt>> <$view tiddler={{$:/theme}} field=\"name\"/>\n\n<$linkcatcher to=\"$:/theme\">\n<$list filter=\"[plugin-type[theme]sort[title]]\"><div><$reveal state=\"$:/theme\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/theme\" type=\"nomatch\" text={{!!title}}> </$reveal> <$link to={{!!title}}>''<$view field=\"name\" format=\"text\"/>'' <$view field=\"description\" format=\"text\"/></$link></div>\n</$list>\n</$linkcatcher>"
},
"$:/core/wiki/title": {
"title": "$:/core/wiki/title",
"type": "text/vnd.tiddlywiki",
"text": "{{$:/SiteTitle}} --- {{$:/SiteSubtitle}}"
},
"$:/view": {
"title": "$:/view",
"text": "classic"
},
"$:/snippets/viewswitcher": {
"title": "$:/snippets/viewswitcher",
"text": "\\define lingo-base() $:/language/ControlPanel/Appearance/StoryView/\n<<lingo Prompt>> {{$:/view}}\n\n<$linkcatcher to=\"$:/view\"><$list filter=\"[storyviews[]]\"><div><$reveal state=\"$:/view\" type=\"match\" text={{!!title}}>•</$reveal><$reveal state=\"$:/view\" type=\"nomatch\" text={{!!title}}> </$reveal> <$link to={{!!title}}><$view field=\"title\"/></$link>\n</div>\n</$list>\n</$linkcatcher>\n"
}
}
}
{
"tiddlers": {
"$:/plugins/kpe/jsxgraph/instructions": {
"title": "$:/plugins/kpe/jsxgraph/instructions",
"text": "! Usage\n\nIn your tiddler use the `jsxgraph` widget like this:\n\n```\n<$jsxgraph width=\"600px\" height=\"400px\">\nvar brd = JXG.JSXGraph.initBoard('ignored',\n {axis:true,originX: 250, originY: 250, unitX: 50, unitY: 25});\n...\n</$jsxgraph>\n```\n\nNote that the first argument to `initBoard()` will be ignored.\n\nCheck the demo at [[$:/plugins/kpe/jsxgraph/jsxgraph.demo.tid|$:/plugins/kpe/jsxgraph/jsxgraph.demo.tid]].\n"
},
"$:/plugins/kpe/jsxgraph/jsxgraph.demo.tid": {
"created": "20140520214706318",
"modified": "20140520221208420",
"title": "$:/plugins/kpe/jsxgraph/jsxgraph.demo.tid",
"type": "text/vnd.tiddlywiki",
"text": "<$jsxgraph height=\"400px\" width=\"600px\">\nvar addPoint = function(x) {\n p.push(brd.create('point',\n [x,(Math.random()-0.5)*3],{style:6}));\n brd.update();\n};\n\nvar brd = JXG.JSXGraph.initBoard('jxgbox',\n {axis:true,originX: 250, originY: 250, unitX: 50, unitY: 25});\nbrd.suspendUpdate();\nvar p = [];\np[0] = brd.create('point', [-4,2], {style:6});\np[1] = brd.create('point', [3,-1], {style:6});\naddPoint(-2);\naddPoint(0.5);\naddPoint(1);\nvar pol = JXG.Math.Numerics.lagrangePolynomial(p);\nvar g = brd.create('functiongraph', [pol, -10, 10], {strokeWidth:3});\nvar g2 = brd.create('functiongraph', [JXG.Math.Numerics.D(pol), -10, 10],\n {dash:3, strokeColor:'#ff0000'});\nbrd.unsuspendUpdate();\n</$jsxgraph>"
},
"$:/plugins/kpe/jsxgraph/jsxgraph.js": {
"text": "/*\\\ntitle: $:/plugins/kpe/jsxgraph/jsxgraph.js\ntype: application/javascript\nmodule-type: widget\n\nCreates a JSXGraph widget\n\n\\*/\n\n(function(){\n\n /*jslint node: true, browser: true */\n /*global $tw: false */\n \"use strict\";\n\n var uniqueID = 1;\n\n var Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n var JXG = require(\"$:/plugins/kpe/jsxgraph/lib/jsxgraphcore.js\");\n\n var JSXGraphWidget = function(parseTreeNode,options) {\n this.initialise(parseTreeNode,options);\n };\n\n /*\n Inherit from the base widget class\n */\n JSXGraphWidget.prototype = new Widget();\n\n /**\n * Intercepts the call to JSXGraph.initBoard() for replacing the first parameter.\n * @param {string} boardNodeID id of the the HTMLElement to rendered the JSXGraph into\n * @param {string} jxgScriptBody the script content\n * @returns {JXG.Board} the rendered JSXGraph board\n */\n JSXGraphWidget.prototype.processJXGScript = function(boardNodeID, jxgScriptBody){\n var result = null;\n var initBoardBackup;\n try{\n var doc = this.document;\n\n initBoardBackup = JXG.JSXGraph.initBoard;\n JXG.JSXGraph.initBoard = function(box, attributes){\n if(result != null) {\n throw new Error(\"Only board per jsxgraph widget is supported!\");\n }\n\n if($tw.fakeDocument === doc) {\n boardNodeID = null;\n attributes.document = {};\n JXG.merge(JXG.Options, {renderer:'no'});\n attributes.renderer = 'no';\n }\n\n result = initBoardBackup.call(this, boardNodeID, attributes);\n return result;\n };\n var jxgScript = new Function(\"JXG\", jxgScriptBody);\n jxgScript.call(null, JXG);\n } finally {\n JXG.JSXGraph.initBoard = initBoardBackup;\n }\n return result;\n };\n\n\n /*\n Render this widget into the DOM\n */\n JSXGraphWidget.prototype.render = function(parent,nextSibling) {\n this.parentDomNode = parent;\n this.computeAttributes();\n this.execute();\n\n var height = this.getAttribute(\"height\", \"500px\");\n var width = this.getAttribute(\"width\", \"500px\");\n var scriptBody = this.parseTreeNode.children[0].text;\n\n var divNode = this.document.createElement(\"div\");\n divNode.setAttribute(\"class\", \"jxgbox\");\n divNode.setAttribute(\"style\", \"height:\" + height + \";width:\" + width);\n divNode.setAttribute(\"id\", \"jxgbox_\" + uniqueID++);\n\n parent.insertBefore(divNode, nextSibling);\n this.domNodes.push(divNode);\n\n var board = this.processJXGScript(divNode.id, scriptBody);\n };\n\n /*\n Compute the internal state of the widget\n */\n JSXGraphWidget.prototype.execute = function() {\n // Nothing to do for a text node\n };\n\n /*\n Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering\n */\n JSXGraphWidget.prototype.refresh = function(changedTiddlers) {\n return false;\n };\n\n exports.jsxgraph = JSXGraphWidget;\n\n})();\n\n",
"title": "$:/plugins/kpe/jsxgraph/jsxgraph.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/plugins/kpe/jsxgraph/lib/jsxgraphcore.js": {
"type": "application/javascript",
"title": "$:/plugins/kpe/jsxgraph/lib/jsxgraphcore.js",
"module-type": "library",
"text": "/*\n JSXGraph 0.99.1\n\n Copyright 2008-2014\n Matthias Ehmann,\n Michael Gerhaeuser,\n Carsten Miller,\n Bianca Valentin,\n Alfred Wassermann,\n Peter Wilfahrt\n\n This file is part of JSXGraph.\n\n JSXGraph is free software dual licensed under the GNU LGPL or MIT License.\n\n You can redistribute it and/or modify it under the terms of the\n\n * GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version\n OR\n * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT\n\n JSXGraph is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License and\n the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>\n and <http://opensource.org/licenses/MIT/>.\n*/\n\n/**\n * almond 0.2.5 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.\n * Available via the MIT or new BSD license.\n * see: http://github.com/jrburke/almond for details\n */\n\n/**\n * UTF-8 Decoder by Bjoern Hoehrmann\n *\n * Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING\n * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n!function(){var requirejs,require,define;!function(t){function e(t,e){return g.call(t,e)}function i(t,e){var i,r,s,o,n,a,h,l,c,d,u=e&&e.split(\"/\"),p=m.map,f=p&&p[\"*\"]||{};if(t&&\".\"===t.charAt(0))if(e){for(u=u.slice(0,u.length-1),t=u.concat(t.split(\"/\")),l=0;l<t.length;l+=1)if(d=t[l],\".\"===d)t.splice(l,1),l-=1;else if(\"..\"===d){if(1===l&&(\"..\"===t[2]||\"..\"===t[0]))break;l>0&&(t.splice(l-1,2),l-=2)}t=t.join(\"/\")}else 0===t.indexOf(\"./\")&&(t=t.substring(2));if((u||f)&&p){for(i=t.split(\"/\"),l=i.length;l>0;l-=1){if(r=i.slice(0,l).join(\"/\"),u)for(c=u.length;c>0;c-=1)if(s=p[u.slice(0,c).join(\"/\")],s&&(s=s[r])){o=s,n=l;break}if(o)break;!a&&f&&f[r]&&(a=f[r],h=l)}!o&&a&&(o=a,n=h),o&&(i.splice(0,n,o),t=i.join(\"/\"))}return t}function r(e,i){return function(){return c.apply(t,v.call(arguments,0).concat([e,i]))}}function s(t){return function(e){return i(e,t)}}function o(t){return function(e){p[t]=e}}function n(i){if(e(f,i)){var r=f[i];delete f[i],b[i]=!0,l.apply(t,r)}if(!e(p,i)&&!e(b,i))throw new Error(\"No \"+i);return p[i]}function a(t){var e,i=t?t.indexOf(\"!\"):-1;return i>-1&&(e=t.substring(0,i),t=t.substring(i+1,t.length)),[e,t]}function h(t){return function(){return m&&m.config&&m.config[t]||{}}}var l,c,d,u,p={},f={},m={},b={},g=Object.prototype.hasOwnProperty,v=[].slice;d=function(t,e){var r,o=a(t),h=o[0];return t=o[1],h&&(h=i(h,e),r=n(h)),h?t=r&&r.normalize?r.normalize(t,s(e)):i(t,e):(t=i(t,e),o=a(t),h=o[0],t=o[1],h&&(r=n(h))),{f:h?h+\"!\"+t:t,n:t,pr:h,p:r}},u={require:function(t){return r(t)},exports:function(t){var e=p[t];return\"undefined\"!=typeof e?e:p[t]={}},module:function(t){return{id:t,uri:\"\",exports:p[t],config:h(t)}}},l=function(i,s,a,h){var l,c,m,g,v,C,y=[];if(h=h||i,\"function\"==typeof a){for(s=!s.length&&a.length?[\"require\",\"exports\",\"module\"]:s,v=0;v<s.length;v+=1)if(g=d(s[v],h),c=g.f,\"require\"===c)y[v]=u.require(i);else if(\"exports\"===c)y[v]=u.exports(i),C=!0;else if(\"module\"===c)l=y[v]=u.module(i);else if(e(p,c)||e(f,c)||e(b,c))y[v]=n(c);else{if(!g.p)throw new Error(i+\" missing \"+c);g.p.load(g.n,r(h,!0),o(c),{}),y[v]=p[c]}m=a.apply(p[i],y),i&&(l&&l.exports!==t&&l.exports!==p[i]?p[i]=l.exports:m===t&&C||(p[i]=m))}else i&&(p[i]=a)},requirejs=require=c=function(e,i,r,s,o){return\"string\"==typeof e?u[e]?u[e](i):n(d(e,i).f):(e.splice||(m=e,i.splice?(e=i,i=r,r=null):e=t),i=i||function(){},\"function\"==typeof r&&(r=s,s=o),s?l(t,e,i,r):setTimeout(function(){l(t,e,i,r)},4),c)},c.config=function(t){return m=t,m.deps&&c(m.deps,m.callback),c},define=function(t,i,r){i.splice||(r=i,i=[]),e(p,t)||e(f,t)||(f[t]=[t,i,r])},define.amd={jQuery:!0}}(),define(\"../node_modules/almond/almond\",function(){}),define(\"jxg\",[],function(){var t={};return\"object\"!=typeof JXG||JXG.extend||(t=JXG),t.extend=function(t,e,i,r){var s,o;i=i||!1,r=r||!1;for(s in e)(!i||i&&e.hasOwnProperty(s))&&(o=r?s.toLowerCase():s,t[o]=e[s])},t.extend(t,{boards:{},readers:{},elements:{},registerElement:function(t,e){t=t.toLowerCase(),this.elements[t]=e},registerReader:function(t,e){var i,r;for(i=0;i<e.length;i++)r=e[i].toLowerCase(),\"function\"!=typeof this.readers[r]&&(this.readers[r]=t)},shortcut:function(t,e){return function(){return t[e].apply(this,arguments)}},getRef:function(t,e){return t.select(e)},getReference:function(t,e){return t.select(e)},debugInt:function(){var t,e;for(t=0;t<arguments.length;t++)e=arguments[t],\"object\"==typeof window&&window.console&&console.log?console.log(e):\"object\"==typeof document&&document.getElementById(\"debug\")&&(document.getElementById(\"debug\").innerHTML+=e+\"<br/>\")},debugWST:function(){var e=new Error;t.debugInt.apply(this,arguments),e&&e.stack&&(t.debugInt(\"stacktrace\"),t.debugInt(e.stack.split(\"\\n\").slice(1).join(\"\\n\")))},debugLine:function(){var e=new Error;t.debugInt.apply(this,arguments),e&&e.stack&&t.debugInt(\"Called from\",e.stack.split(\"\\n\").slice(2,3).join(\"\\n\"))},debug:function(){t.debugInt.apply(this,arguments)}}),t}),define(\"base/constants\",[\"jxg\"],function(t){var e,i=0,r=99,s=1,o=!1,n=i+\".\"+r+\".\"+s+(o?\"-\"+o:\"\");return e={version:n,licenseText:\"JSXGraph v\"+n+\" Copyright (C) see http://jsxgraph.org\",COORDS_BY_USER:1,COORDS_BY_SCREEN:2,OBJECT_TYPE_ARC:1,OBJECT_TYPE_ARROW:2,OBJECT_TYPE_AXIS:3,OBJECT_TYPE_AXISPOINT:4,OBJECT_TYPE_TICKS:5,OBJECT_TYPE_CIRCLE:6,OBJECT_TYPE_CONIC:7,OBJECT_TYPE_CURVE:8,OBJECT_TYPE_GLIDER:9,OBJECT_TYPE_IMAGE:10,OBJECT_TYPE_LINE:11,OBJECT_TYPE_POINT:12,OBJECT_TYPE_SLIDER:13,OBJECT_TYPE_CAS:14,OBJECT_TYPE_GXTCAS:15,OBJECT_TYPE_POLYGON:16,OBJECT_TYPE_SECTOR:17,OBJECT_TYPE_TEXT:18,OBJECT_TYPE_ANGLE:19,OBJECT_TYPE_INTERSECTION:20,OBJECT_TYPE_TURTLE:21,OBJECT_TYPE_VECTOR:22,OBJECT_TYPE_OPROJECT:23,OBJECT_TYPE_GRID:24,OBJECT_TYPE_TANGENT:25,OBJECT_TYPE_HTMLSLIDER:26,OBJECT_CLASS_POINT:1,OBJECT_CLASS_LINE:2,OBJECT_CLASS_CIRCLE:3,OBJECT_CLASS_CURVE:4,OBJECT_CLASS_AREA:5,OBJECT_CLASS_OTHER:6,GENTYPE_ABC:1,GENTYPE_AXIS:2,GENTYPE_MID:3,GENTYPE_REFLECTION:4,GENTYPE_MIRRORPOINT:5,GENTYPE_TANGENT:6,GENTYPE_PARALLEL:7,GENTYPE_BISECTORLINES:8,GENTYPE_BOARDIMG:9,GENTYPE_BISECTOR:10,GENTYPE_NORMAL:11,GENTYPE_POINT:12,GENTYPE_GLIDER:13,GENTYPE_INTERSECTION:14,GENTYPE_CIRCLE:15,GENTYPE_CIRCLE2POINTS:16,GENTYPE_LINE:17,GENTYPE_TRIANGLE:18,GENTYPE_QUADRILATERAL:19,GENTYPE_TEXT:20,GENTYPE_POLYGON:21,GENTYPE_REGULARPOLYGON:22,GENTYPE_SECTOR:23,GENTYPE_ANGLE:24,GENTYPE_PLOT:25,GENTYPE_SLIDER:26,GENTYPE_TRUNCATE:27,GENTYPE_JCODE:28,GENTYPE_MOVEMENT:29,GENTYPE_COMBINED:30,GENTYPE_RULER:31,GENTYPE_SLOPETRIANGLE:32,GENTYPE_PERPSEGMENT:33,GENTYPE_DELETE:41,GENTYPE_COPY:42,GENTYPE_MIRROR:43,GENTYPE_ROTATE:44,GENTYPE_ABLATION:45,GENTYPE_MIGRATE:46,GENTYPE_CTX_TYPE_G:51,GENTYPE_CTX_TYPE_P:52,GENTYPE_CTX_TRACE:53,GENTYPE_CTX_VISIBILITY:54,GENTYPE_CTX_CCVISIBILITY:55,GENTYPE_CTX_MPVISIBILITY:56,GENTYPE_CTX_WITHLABEL:57,GENTYPE_CTX_LABEL:58,GENTYPE_CTX_FIXED:59,GENTYPE_CTX_STROKEWIDTH:60,GENTYPE_CTX_LABELSIZE:61,GENTYPE_CTX_SIZE:62,GENTYPE_CTX_FACE:63,GENTYPE_CTX_STRAIGHT:64,GENTYPE_CTX_ARROW:65,GENTYPE_CTX_COLOR:66,GENTYPE_CTX_RADIUS:67,GENTYPE_CTX_COORDS:68,GENTYPE_CTX_TEXT:69,GENTYPE_CTX_ANGLERADIUS:70,GENTYPE_CTX_DOTVISIBILITY:71,GENTYPE_CTX_FILLOPACITY:72,GENTYPE_CTX_PLOT:73,GENTYPE_CTX_SCALE:74,GENTYPE_CTX_INTVAL:75,GENTYPE_CTX_POINT1:76,GENTYPE_CTX_POINT2:77,GENTYPE_CTX_LABELSTICKY:78},t.extend(t,e),e}),define(\"utils/type\",[\"jxg\",\"base/constants\"],function(t,e){return t.extend(t,{isId:function(t,e){return\"string\"==typeof e&&!!t.objects[e]},isName:function(t,e){return\"string\"==typeof e&&!!t.elementsByName[e]},isGroup:function(t,e){return\"string\"==typeof e&&!!t.groups[e]},isString:function(t){return\"string\"==typeof t},isNumber:function(t){return\"number\"==typeof t||\"[Object Number]\"===Object.prototype.toString.call(t)},isFunction:function(t){return\"function\"==typeof t},isArray:function(t){var e;return e=Array.isArray?Array.isArray(t):null!==t&&\"object\"==typeof t&&\"function\"==typeof t.splice&&\"function\"==typeof t.join},isObject:function(e){return\"object\"==typeof e&&!t.isArray(e)},isPoint:function(t){return\"object\"==typeof t?t.elementClass===e.OBJECT_CLASS_POINT:!1},exists:function(t){return function(e){return!(e===t||null===e)}}(),def:function(e,i){return t.exists(e)?e:i},str2Bool:function(e){return t.exists(e)?\"boolean\"==typeof e?e:t.isString(e)?\"true\"===e.toLowerCase():!1:!0},createEvalFunction:function(e,i,r){var s,o=[];for(s=0;r>s;s++)o[s]=t.createFunction(i[s],e,\"\",!0);return function(t){return o[t]()}},createFunction:function(e,i,r,s){var o=null;return t.exists(s)&&!s||!t.isString(e)?t.isFunction(e)?o=e:t.isNumber(e)?o=function(){return e}:t.isString(e)&&(o=function(){return e}):o=i.jc.snippet(e,!0,r,!0),null!==o&&(o.origin=e),o},bind:function(t,e){return function(){return t.apply(e,arguments)}},evaluate:function(e){return t.isFunction(e)?e():e},indexOf:function(e,i,r){var s,o=t.exists(r);if(Array.indexOf&&!o)return e.indexOf(i);for(s=0;s<e.length;s++)if(o&&e[s][r]===i||!o&&e[s]===i)return s;return-1},eliminateDuplicates:function(t){var e,i=t.length,r=[],s={};for(e=0;i>e;e++)s[t[e]]=0;for(e in s)s.hasOwnProperty(e)&&r.push(e);return r},swap:function(t,e,i){var r;return r=t[e],t[e]=t[i],t[i]=r,t},uniqueArray:function(e){var i,r,s,o=[];if(0===e.length)return[];for(i=0;i<e.length;i++)for(s=t.isArray(e[i]),r=i+1;r<e.length;r++)s&&t.cmpArrays(e[i],e[r])?e[i]=[]:s||e[i]!==e[r]||(e[i]=\"\");for(r=0,i=0;i<e.length;i++)s=t.isArray(e[i]),s||\"\"===e[i]?s&&0!==e[i].length&&(o[r]=e[i].slice(0),r+=1):(o[r]=e[i],r+=1);return e=o,o},isInArray:function(e,i){return t.indexOf(e,i)>-1},coordsArrayToMatrix:function(t,e){var i,r=[],s=[];for(i=0;i<t.length;i++)e?(r.push(t[i].usrCoords[1]),s.push(t[i].usrCoords[2])):s.push([t[i].usrCoords[1],t[i].usrCoords[2]]);return e&&(s=[r,s]),s},cmpArrays:function(t,e){var i;if(t===e)return!0;if(t.length!==e.length)return!1;for(i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0},removeElementFromArray:function(t,e){var i;for(i=0;i<t.length;i++)if(t[i]===e)return t.splice(i,1),t;return t},trunc:function(e,i){return i=t.def(i,0),0===i?(e=~e,e=~e):e=e.toFixed(i),e},autoDigits:function(t){var e=Math.abs(t);return e=e>.1?t.toFixed(2):e>=.01?t.toFixed(4):e>=1e-4?t.toFixed(6):t},keys:function(t,e){var i,r=[];for(i in t)e?t.hasOwnProperty(i)&&r.push(i):r.push(i);return r},clone:function(t){var e={};return e.prototype=t,e},cloneAndCopy:function(t,e){var i,r=function(){};r.prototype=t;for(i in e)r[i]=e[i];return r},merge:function(t,e){var i,r;for(i in e)if(e.hasOwnProperty(i))if(this.isArray(e[i]))for(t[i]||(t[i]=[]),r=0;r<e[i].length;r++)t[i][r]=\"object\"==typeof e[i][r]?this.merge(t[i][r],e[i][r]):e[i][r];else\"object\"==typeof e[i]?(t[i]||(t[i]={}),t[i]=this.merge(t[i],e[i])):t[i]=e[i];return t},deepCopy:function(e,i,r){var s,o,n,a;if(r=r||!1,\"object\"!=typeof e||null===e)return e;if(this.isArray(e))for(s=[],o=0;o<e.length;o++)n=e[o],s[o]=\"object\"==typeof n?this.deepCopy(n):n;else{s={};for(o in e)a=r?o.toLowerCase():o,n=e[o],s[a]=\"object\"==typeof n?this.deepCopy(n):n;for(o in i)a=r?o.toLowerCase():o,n=i[o],s[a]=\"object\"==typeof n?t.isArray(n)||!t.exists(s[a])?this.deepCopy(n):this.deepCopy(s[a],n,r):n}return s},copyAttributes:function(e,i,r){var s,o,n,a,h,l={circle:1,curve:1,image:1,line:1,point:1,polygon:1,text:1,ticks:1,integral:1};for(n=arguments.length,s=3>n||l[r]?t.deepCopy(i.elements,null,!0):{},4>n&&this.exists(r)&&this.exists(i.layer[r])&&(s.layer=i.layer[r]),a=i,h=!0,o=2;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}for(h&&(s=t.deepCopy(s,a,!0)),a=e,h=!0,o=3;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}for(h&&this.extend(s,a,null,!0),a=i,h=!0,o=2;n>o;o++){if(!t.exists(a[arguments[o]])){h=!1;break}a=a[arguments[o]]}return h&&t.exists(a.label)&&(s.label=t.deepCopy(a.label,s.label)),s.label=t.deepCopy(i.label,s.label),s},toJSON:function(e,i){var r,s,o,n,a;if(i=t.def(i,!1),JSON.stringify&&!i)try{return n=JSON.stringify(e)}catch(h){}switch(typeof e){case\"object\":if(e){if(r=[],t.isArray(e)){for(o=0;o<e.length;o++)r.push(t.toJSON(e[o],i));return\"[\"+r.join(\",\")+\"]\"}for(s in e)if(e.hasOwnProperty(s)){try{a=t.toJSON(e[s],i)}catch(l){a=\"\"}i?r.push(s+\":\"+a):r.push('\"'+s+'\":'+a)}return\"{\"+r.join(\",\")+\"} \"}return\"null\";case\"string\":return\"'\"+e.replace(/([\"'])/g,\"\\\\$1\")+\"'\";case\"number\":case\"boolean\":return e.toString()}return\"0\"},clearVisPropOld:function(t){return t.visPropOld={strokecolor:\"\",strokeopacity:\"\",strokewidth:\"\",fillcolor:\"\",fillopacity:\"\",shadow:!1,firstarrow:!1,lastarrow:!1,cssclass:\"\",fontsize:-1,left:-1e5,top:-1e5},t},isInObject:function(t,e){var i;for(i in t)if(t.hasOwnProperty(i)&&t[i]===e)return!0;return!1},escapeHTML:function(t){return t.replace(/&/g,\"&\").replace(/</g,\"<\").replace(/>/g,\">\")},unescapeHTML:function(t){return t.replace(/<\\/?[^>]+>/gi,\"\").replace(/&/g,\"&\").replace(/</g,\"<\").replace(/>/g,\">\")},capitalize:function(t){return t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()},trimNumber:function(t){return t=t.replace(/^0+/,\"\"),t=t.replace(/0+$/,\"\"),(\".\"===t[t.length-1]||\",\"===t[t.length-1])&&(t=t.slice(0,-1)),(\".\"===t[0]||\",\"===t[0])&&(t=\"0\"+t),t},filterElements:function(t,e){var i,r,s,o,n,a,h,l=t.length,c=[];if(\"function\"!=typeof e&&\"object\"!=typeof e)return c;for(i=0;l>i;i++){if(h=!0,s=t[i],\"object\"==typeof e){for(r in e)if(e.hasOwnProperty(r)&&(o=r.toLowerCase(),n=\"function\"==typeof s[r]?s[r]():s[r],a=s.visProp&&\"function\"==typeof s.visProp[o]?s.visProp[o]():s.visProp&&s.visProp[o],h=\"function\"==typeof e[r]?e[r](n)||e[r](a):n===e[r]||a===e[r],!h))break}else\"function\"==typeof e&&(h=e(s));h&&c.push(s)}return c},trim:function(t){return t=t.replace(/^\\s+/,\"\"),t=t.replace(/\\s+$/,\"\")},sanitizeHTML:function(t,e){return\"function\"==typeof html_sanitize&&e?html_sanitize(t,function(){},function(t){return t}):(t&&(t=t.replace(/</g,\"<\").replace(/>/g,\">\")),t)},evalSlider:function(t){return t.type===e.OBJECT_TYPE_GLIDER&&\"function\"==typeof t.Value&&(t=t.Value()),t}}),t}),define(\"utils/env\",[\"jxg\",\"utils/type\"],function(t,e){return t.extend(t,{touchProperty:\"touches\",isBrowser:\"object\"==typeof window&&\"object\"==typeof document,supportsVML:function(){return this.isBrowser&&!!document.namespaces},supportsSVG:function(){return this.isBrowser&&document.implementation.hasFeature(\"http://www.w3.org/TR/SVG11/feature#BasicStructure\",\"1.1\")},supportsCanvas:function(){var t,e=!1;if(this.isNode())try{t=\"object\"==typeof module?module.require(\"canvas\"):require(\"canvas\"),e=!0}catch(i){}return e||this.isBrowser&&!!document.createElement(\"canvas\").getContext},isNode:function(){return!this.isBrowser&&(\"object\"==typeof module&&!!module.exports||\"object\"==typeof global&&global.requirejsVars&&!global.requirejsVars.isBrowser)},isWebWorker:function(){return!this.isBrowser&&\"object\"==typeof self&&\"function\"==typeof self.postMessage},supportsPointerEvents:function(){return t.isBrowser&&window.navigator&&(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)},isTouchDevice:function(){return this.isBrowser&&void 0!==window.ontouchstart},isAndroid:function(){return e.exists(navigator)&&navigator.userAgent.toLowerCase().indexOf(\"android\")>-1},isWebkitAndroid:function(){return this.isAndroid()&&navigator.userAgent.indexOf(\" AppleWebKit/\")>-1},isApple:function(){return e.exists(navigator)&&(navigator.userAgent.indexOf(\"iPad\")>-1||navigator.userAgent.indexOf(\"iPhone\")>-1)},isWebkitApple:function(){return this.isApple()&&navigator.userAgent.search(/Mobile\\/[0-9A-Za-z\\.]*Safari/)>-1},isMetroApp:function(){return\"object\"==typeof window&&window.clientInformation&&window.clientInformation.appName&&window.clientInformation.appName.indexOf(\"MSAppHost\")>-1},isMozilla:function(){return e.exists(navigator)&&navigator.userAgent.toLowerCase().indexOf(\"mozilla\")>-1&&-1===navigator.userAgent.toLowerCase().indexOf(\"apple\")},isFirefoxOS:function(){return e.exists(navigator)&&-1===navigator.userAgent.toLowerCase().indexOf(\"android\")&&-1===navigator.userAgent.toLowerCase().indexOf(\"apple\")&&navigator.userAgent.toLowerCase().indexOf(\"mobile\")>-1&&navigator.userAgent.toLowerCase().indexOf(\"mozilla\")>-1},ieVersion:function(){var t,e,i,r=3;if(\"object\"!=typeof document)return 0;e=document.createElement(\"div\"),i=e.getElementsByTagName(\"i\");do e.innerHTML=\"<!--[if gt IE \"+ ++r+\"]><\"+\"i><\"+\"/i><![endif]-->\";while(i[0]);return r>4?r:t}(),getDimensions:function(i,r){var s,o,n,a,h,l,c,d;if(!t.isBrowser||null===i)return{width:500,height:500};if(r=r||document,s=r.getElementById(i),!e.exists(s))throw new Error(\"\\nJSXGraph: HTML container element '\"+i+\"' not found.\");return o=s.style.display,\"none\"!==o&&null!==o?{width:s.offsetWidth,height:s.offsetHeight}:(n=s.style,a=n.visibility,h=n.position,l=n.display,n.visibility=\"hidden\",n.position=\"absolute\",n.display=\"block\",c=s.clientWidth,d=s.clientHeight,n.display=l,n.position=h,n.visibility=a,{width:c,height:d})},addEvent:function(t,i,r,s){var o=function(){return r.apply(s,arguments)};o.origin=r,s[\"x_internal\"+i]=s[\"x_internal\"+i]||[],s[\"x_internal\"+i].push(o),e.exists(t)&&e.exists(t.addEventListener)&&t.addEventListener(i,o,!1),e.exists(t)&&e.exists(t.attachEvent)&&t.attachEvent(\"on\"+i,o)},removeEvent:function(i,r,s,o){var n;if(!e.exists(o))return t.debug(\"no such owner\"),void 0;if(!e.exists(o[\"x_internal\"+r]))return t.debug(\"no such type: \"+r),void 0;if(!e.isArray(o[\"x_internal\"+r]))return t.debug(\"owner[x_internal + \"+r+\"] is not an array\"),void 0;if(n=e.indexOf(o[\"x_internal\"+r],s,\"origin\"),-1===n)return t.debug(\"no such event function in internal list: \"+s),void 0;try{e.exists(i)&&e.exists(i.removeEventListener)&&i.removeEventListener(r,o[\"x_internal\"+r][n],!1),e.exists(i)&&e.exists(i.detachEvent)&&i.detachEvent(\"on\"+r,o[\"x_internal\"+r][n])}catch(a){t.debug(\"event not registered in browser: (\"+r+\" -- \"+s+\")\")}o[\"x_internal\"+r].splice(n,1)},removeAllEvents:function(e,i,r){var s,o;if(r[\"x_internal\"+i]){for(o=r[\"x_internal\"+i].length,s=o-1;s>=0;s--)t.removeEvent(e,i,r[\"x_internal\"+i][s].origin,r);r[\"x_internal\"+i].length>0&&t.debug(\"removeAllEvents: Not all events could be removed.\")}},getPosition:function(i,r,s){var o,n,a,h=0,l=0;if(i||(i=window.event),s=s||document,a=i[t.touchProperty],e.exists(r)&&e.exists(a))if(-1===r){for(n=a.length,o=0;n>o;o++)if(a[o]){i=a[o];break}}else i=a[r];return i.pageX||i.pageY?(h=i.pageX,l=i.pageY):(i.clientX||i.clientY)&&(h=i.clientX+s.body.scrollLeft+s.documentElement.scrollLeft,l=i.clientY+s.body.scrollTop+s.documentElement.scrollTop),[h,l]},getOffset:function(t){var e,i=t,r=t,s=i.offsetLeft-i.scrollLeft,o=i.offsetTop-i.scrollTop;for(e=this.getCSSTransform([s,o],i),s=e[0],o=e[1],i=i.offsetParent;i;){for(s+=i.offsetLeft,o+=i.offsetTop,i.offsetParent&&(s+=i.clientLeft-i.scrollLeft,o+=i.clientTop-i.scrollTop),e=this.getCSSTransform([s,o],i),s=e[0],o=e[1],r=r.parentNode;r!==i;)s+=r.clientLeft-r.scrollLeft,o+=r.clientTop-r.scrollTop,e=this.getCSSTransform([s,o],r),s=e[0],o=e[1],r=r.parentNode;i=i.offsetParent}return[s,o]},getStyle:function(e,i){var r,s;return s=e.ownerDocument,window.getComputedStyle?r=s.defaultView.getComputedStyle(e,null).getPropertyValue(i):e.currentStyle&&t.ieVersion>=9?r=e.currentStyle[i]:e.style&&(i=i.replace(/-([a-z]|[0-9])/gi,function(t,e){return e.toUpperCase()}),r=e.style[i]),r},getProp:function(t,e){var i=parseInt(this.getStyle(t,e),10);return isNaN(i)?0:i},getCSSTransform:function(t,i){var r,s,o,n,a,h,l,c,d=[\"transform\",\"webkitTransform\",\"MozTransform\",\"msTransform\",\"oTransform\"];for(h=d.length,r=0,o=\"\";h>r;r++)if(e.exists(i.style[d[r]])){o=i.style[d[r]];break}if(\"\"!==o&&(a=o.indexOf(\"(\"),a>0)){for(h=o.length,n=o.substring(a+1,h-1),c=n.split(\",\"),s=0,l=c.length;l>s;s++)c[s]=parseFloat(c[s]);0===o.indexOf(\"matrix\")?(t[0]+=c[4],t[1]+=c[5]):0===o.indexOf(\"translateX\")?t[0]+=c[0]:0===o.indexOf(\"translateY\")?t[1]+=c[0]:0===o.indexOf(\"translate\")&&(t[0]+=c[0],t[1]+=c[1])}return t},getCSSTransformMatrix:function(t){var i,r,s,o,n,a,h,l,c=[\"transform\",\"webkitTransform\",\"MozTransform\",\"msTransform\",\"oTransform\"],d=[[1,0,0],[0,1,0],[0,0,1]];for(a=c.length,i=0,s=\"\";a>i;i++)if(e.exists(t.style[c[i]])){s=t.style[c[i]];break}if(\"\"!==s&&(n=s.indexOf(\"(\"),n>0)){for(a=s.length,o=s.substring(n+1,a-1),l=o.split(\",\"),r=0,h=l.length;h>r;r++)l[r]=parseFloat(l[r]);0===s.indexOf(\"matrix\")?d=[[1,0,0],[0,l[0],l[1]],[0,l[2],l[3]]]:0===s.indexOf(\"scaleX\")?d[1][1]=l[0]:0===s.indexOf(\"scaleY\")?d[2][2]=l[0]:0===s.indexOf(\"scale\")&&(d[1][1]=l[0],d[2][2]=l[1])}return d},timedChunk:function(t,e,i,r){var s=t.concat(),o=function(){var n=+new Date;do e.call(i,s.shift());while(s.length>0&&+new Date-n<300);s.length>0?window.setTimeout(o,1):r(t)};window.setTimeout(o,1)}}),t}),define(\"utils/xml\",[\"jxg\",\"utils/type\"],function(t,e){return t.XML={cleanWhitespace:function(t){for(var i=t.firstChild;e.exists(i);)3!==i.nodeType||/\\S/.test(i.nodeValue)?1===i.nodeType&&this.cleanWhitespace(i):t.removeChild(i),i=i.nextSibling},parse:function(t){var e,i,r;return r=\"function\"==typeof DOMParser||\"object\"==typeof DOMParser?DOMParser:function(){this.parseFromString=function(t){var e;return\"function\"==typeof ActiveXObject&&(e=new ActiveXObject(\"MSXML.DomDocument\"),e.loadXML(t)),e}},e=new r,i=e.parseFromString(t,\"text/xml\"),this.cleanWhitespace(i),i}},t.XML}),define(\"utils/event\",[\"jxg\",\"utils/type\"],function(t,e){return t.EventEmitter={eventHandlers:{},suspended:{},trigger:function(t,e){var i,r,s,o,n,a;for(n=t.length,r=0;n>r;r++)if(o=this.eventHandlers[t[r]],!this.suspended[t[r]]){if(this.suspended[t[r]]=!0,o)for(a=o.length,i=0;a>i;i++)s=o[i],s.handler.apply(s.context,e);this.suspended[t[r]]=!1}return this},on:function(t,i,r){return e.isArray(this.eventHandlers[t])||(this.eventHandlers[t]=[]),r=e.def(r,this),this.eventHandlers[t].push({handler:i,context:r}),this},off:function(t,i){var r;return t&&e.isArray(this.eventHandlers[t])?(i?(r=e.indexOf(this.eventHandlers[t],i,\"handler\"),r>-1&&this.eventHandlers[t].splice(r,1),0===this.eventHandlers[t].length&&delete this.eventHandlers[t]):delete this.eventHandlers[t],this):this},eventify:function(t){t.eventHandlers={},t.on=this.on,t.off=this.off,t.triggerEventHandlers=this.trigger,t.trigger=this.trigger,t.suspended={}}},t.EventEmitter}),define(\"math/math\",[\"jxg\"],function(t){var e,i=function(t){var i,r;return t.memo?t.memo:(i={},r=Array.prototype.join,t.memo=function(){var s=r.call(arguments);return i[s]!==e?i[s]:i[s]=t.apply(this,arguments)},t.memo)};return t.Math={eps:1e-6,mod:function(t,e){return t-Math.floor(t/e)*e},vector:function(t,e){var i,r;for(e=e||0,i=[],r=0;t>r;r++)i[r]=e;return i},matrix:function(t,e,i){var r,s,o;for(i=i||0,e=e||t,r=[],s=0;t>s;s++)for(r[s]=[],o=0;e>o;o++)r[s][o]=i;return r},identity:function(t,i){var r,s;for(i===e&&\"number\"!=typeof i&&(i=t),r=this.matrix(t,i),s=0;s<Math.min(t,i);s++)r[s][s]=1;return r},frustum:function(t,e,i,r,s,o){var n=this.matrix(4,4);return n[0][0]=2*s/(e-t),n[0][1]=0,n[0][2]=(e+t)/(e-t),n[0][3]=0,n[1][0]=0,n[1][1]=2*s/(r-i),n[1][2]=(r+i)/(r-i),n[1][3]=0,n[2][0]=0,n[2][1]=0,n[2][2]=-(o+s)/(o-s),n[2][3]=-(2*o*s)/(o-s),n[3][0]=0,n[3][1]=0,n[3][2]=-1,n[3][3]=0,n},projection:function(t,e,i,r){var s=i*Math.tan(t/2),o=s*e;return this.frustum(-o,o,-s,s,i,r)},matVecMult:function(t,e){var i,r,s,o=t.length,n=e.length,a=[];if(3===n)for(i=0;o>i;i++)a[i]=t[i][0]*e[0]+t[i][1]*e[1]+t[i][2]*e[2];else for(i=0;o>i;i++){for(r=0,s=0;n>s;s++)r+=t[i][s]*e[s];a[i]=r}return a},matMatMult:function(t,e){var i,r,s,o,n=t.length,a=n>0?e[0].length:0,h=e.length,l=this.matrix(n,a);for(i=0;n>i;i++)for(r=0;a>r;r++){for(s=0,o=0;h>o;o++)s+=t[i][o]*e[o][r];l[i][r]=s}return l},transpose:function(t){var e,i,r,s,o;for(s=t.length,o=t.length>0?t[0].length:0,e=this.matrix(o,s),i=0;o>i;i++)for(r=0;s>r;r++)e[i][r]=t[r][i];return e},inverse:function(t){var e,i,r,s,o,n,a,h=t.length,l=[],c=[],d=[];for(e=0;h>e;e++){for(l[e]=[],i=0;h>i;i++)l[e][i]=t[e][i];c[e]=e}for(i=0;h>i;i++){for(o=Math.abs(l[i][i]),n=i,e=i+1;h>e;e++)Math.abs(l[e][i])>o&&(o=Math.abs(l[e][i]),n=e);if(o<=this.eps)return[];if(n>i){for(r=0;h>r;r++)a=l[i][r],l[i][r]=l[n][r],l[n][r]=a;a=c[i],c[i]=c[n],c[n]=a}for(s=1/l[i][i],e=0;h>e;e++)l[e][i]*=s;for(l[i][i]=s,r=0;h>r;r++)if(r!==i){for(e=0;h>e;e++)e!==i&&(l[e][r]-=l[e][i]*l[i][r]);l[i][r]=-s*l[i][r]}}for(e=0;h>e;e++){for(r=0;h>r;r++)d[c[r]]=l[e][r];for(r=0;h>r;r++)l[e][r]=d[r]}return l},innerProduct:function(t,i,r){var s,o=0;for((r===e||\"number\"!=typeof r)&&(r=t.length),s=0;r>s;s++)o+=t[s]*i[s];return o},crossProduct:function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]},factorial:i(function(t){return 0>t?0/0:(t=Math.floor(t),0===t||1===t?1:t*this.factorial(t-1))}),binomial:i(function(t,e){var i,r;if(e>t||0>e)return 0/0;if(e=Math.round(e),t=Math.round(t),0===e||e===t)return 1;for(i=1,r=0;e>r;r++)i*=t-r,i/=r+1;return i}),cosh:function(t){return.5*(Math.exp(t)+Math.exp(-t))},sinh:function(t){return.5*(Math.exp(t)-Math.exp(-t))},pow:function(t,e){return 0===t?0===e?1:0:Math.floor(e)===e?Math.pow(t,e):t>0?Math.exp(e*Math.log(Math.abs(t))):0/0},log10:function(t){return Math.log(t)/Math.log(10)},log2:function(t){return Math.log(t)/Math.log(2)},squampow:function(t,e){var i;if(Math.floor(e)===e){for(i=1,0>e&&(t=1/t,e*=-1);0!==e;)1&e&&(i*=t),e>>=1,t*=t;return i}return this.pow(t,e)},normalize:function(t){var e,i,r=2*t[3],s=t[4]/r;return t[5]=s,t[6]=-t[1]/r,t[7]=-t[2]/r,1/0===s||isNaN(s)?(e=Math.sqrt(t[1]*t[1]+t[2]*t[2]),t[0]/=e,t[1]/=e,t[2]/=e,t[3]=0,t[4]=1):Math.abs(s)>=1?(t[0]=(t[6]*t[6]+t[7]*t[7]-s*s)/(2*s),t[1]=-t[6]/s,t[2]=-t[7]/s,t[3]=1/(2*s),t[4]=1):(i=0>=s?-1:1,t[0]=.5*i*(t[6]*t[6]+t[7]*t[7]-s*s),t[1]=-i*t[6],t[2]=-i*t[7],t[3]=i/2,t[4]=i*s),t},toGL:function(t){var e,i,r;if(e=\"function\"==typeof Float32Array?new Float32Array(16):new Array(16),4!==t.length&&4!==t[0].length)return e;for(i=0;4>i;i++)for(r=0;4>r;r++)e[i+4*r]=t[i][r];return e}},t.Math}),define(\"base/coords\",[\"jxg\",\"base/constants\",\"utils/event\",\"utils/type\",\"math/math\"],function(t,e,i,r,s){return t.Coords=function(t,e,s,o){this.board=s,this.usrCoords=[],this.scrCoords=[],this.emitter=!r.exists(o)||o,this.emitter&&i.eventify(this),this.setCoordinates(t,e,!0,!0)},t.extend(t.Coords.prototype,{normalizeUsrCoords:function(){var t=s.eps;Math.abs(this.usrCoords[0])>t&&(this.usrCoords[1]/=this.usrCoords[0],this.usrCoords[2]/=this.usrCoords[0],this.usrCoords[0]=1)},usr2screen:function(t){var e=Math.round,i=this.board,r=this.usrCoords,s=i.origin.scrCoords;null===t||t?(this.scrCoords[0]=e(r[0]),this.scrCoords[1]=e(r[0]*s[1]+r[1]*i.unitX),this.scrCoords[2]=e(r[0]*s[2]-r[2]*i.unitY)):(this.scrCoords[0]=r[0],this.scrCoords[1]=r[0]*s[1]+r[1]*i.unitX,this.scrCoords[2]=r[0]*s[2]-r[2]*i.unitY)},screen2usr:function(){var t=this.board.origin.scrCoords,e=this.scrCoords,i=this.board;this.usrCoords[0]=1,this.usrCoords[1]=(e[1]-t[1])/i.unitX,this.usrCoords[2]=(t[2]-e[2])/i.unitY},distance:function(t,i){var r,o,n=0,a=this.usrCoords,h=this.scrCoords;if(t===e.COORDS_BY_USER){if(r=i.usrCoords,o=a[0]-r[0],n=o*o,n>s.eps)return Number.POSITIVE_INFINITY;o=a[1]-r[1],n+=o*o,o=a[2]-r[2],n+=o*o}else r=i.scrCoords,o=h[1]-r[1],n+=o*o,o=h[2]-r[2],n+=o*o;return Math.sqrt(n)},setCoordinates:function(t,i,r,s){var o=this.usrCoords,n=this.scrCoords,a=[o[0],o[1],o[2]],h=[n[0],n[1],n[2]];return t===e.COORDS_BY_USER?(2===i.length?(o[0]=1,o[1]=i[0],o[2]=i[1]):(o[0]=i[0],o[1]=i[1],o[2]=i[2],this.normalizeUsrCoords()),this.usr2screen(r)):(n[1]=i[0],n[2]=i[1],this.screen2usr()),!this.emitter||s||h[1]===n[1]&&h[2]===n[2]||this.triggerEventHandlers([\"update\"],[a,h]),this},copy:function(t,e){return\"undefined\"==typeof e&&(e=0),this[t].slice(e)},__evt__update:function(){},__evt:function(){}}),t.Coords}),define(\"utils/color\",[\"jxg\",\"utils/type\",\"math/math\"],function(t,e,i){var r={aliceblue:\"f0f8ff\",antiquewhite:\"faebd7\",aqua:\"00ffff\",aquamarine:\"7fffd4\",azure:\"f0ffff\",beige:\"f5f5dc\",bisque:\"ffe4c4\",black:\"000000\",blanchedalmond:\"ffebcd\",blue:\"0000ff\",blueviolet:\"8a2be2\",brown:\"a52a2a\",burlywood:\"deb887\",cadetblue:\"5f9ea0\",chartreuse:\"7fff00\",chocolate:\"d2691e\",coral:\"ff7f50\",cornflowerblue:\"6495ed\",cornsilk:\"fff8dc\",crimson:\"dc143c\",cyan:\"00ffff\",darkblue:\"00008b\",darkcyan:\"008b8b\",darkgoldenrod:\"b8860b\",darkgray:\"a9a9a9\",darkgreen:\"006400\",darkkhaki:\"bdb76b\",darkmagenta:\"8b008b\",darkolivegreen:\"556b2f\",darkorange:\"ff8c00\",darkorchid:\"9932cc\",darkred:\"8b0000\",darksalmon:\"e9967a\",darkseagreen:\"8fbc8f\",darkslateblue:\"483d8b\",darkslategray:\"2f4f4f\",darkturquoise:\"00ced1\",darkviolet:\"9400d3\",deeppink:\"ff1493\",deepskyblue:\"00bfff\",dimgray:\"696969\",dodgerblue:\"1e90ff\",feldspar:\"d19275\",firebrick:\"b22222\",floralwhite:\"fffaf0\",forestgreen:\"228b22\",fuchsia:\"ff00ff\",gainsboro:\"dcdcdc\",ghostwhite:\"f8f8ff\",gold:\"ffd700\",goldenrod:\"daa520\",gray:\"808080\",green:\"008000\",greenyellow:\"adff2f\",honeydew:\"f0fff0\",hotpink:\"ff69b4\",indianred:\"cd5c5c\",indigo:\"4b0082\",ivory:\"fffff0\",khaki:\"f0e68c\",lavender:\"e6e6fa\",lavenderblush:\"fff0f5\",lawngreen:\"7cfc00\",lemonchiffon:\"fffacd\",lightblue:\"add8e6\",lightcoral:\"f08080\",lightcyan:\"e0ffff\",lightgoldenrodyellow:\"fafad2\",lightgrey:\"d3d3d3\",lightgreen:\"90ee90\",lightpink:\"ffb6c1\",lightsalmon:\"ffa07a\",lightseagreen:\"20b2aa\",lightskyblue:\"87cefa\",lightslateblue:\"8470ff\",lightslategray:\"778899\",lightsteelblue:\"b0c4de\",lightyellow:\"ffffe0\",lime:\"00ff00\",limegreen:\"32cd32\",linen:\"faf0e6\",magenta:\"ff00ff\",maroon:\"800000\",mediumaquamarine:\"66cdaa\",mediumblue:\"0000cd\",mediumorchid:\"ba55d3\",mediumpurple:\"9370d8\",mediumseagreen:\"3cb371\",mediumslateblue:\"7b68ee\",mediumspringgreen:\"00fa9a\",mediumturquoise:\"48d1cc\",mediumvioletred:\"c71585\",midnightblue:\"191970\",mintcream:\"f5fffa\",mistyrose:\"ffe4e1\",moccasin:\"ffe4b5\",navajowhite:\"ffdead\",navy:\"000080\",oldlace:\"fdf5e6\",olive:\"808000\",olivedrab:\"6b8e23\",orange:\"ffa500\",orangered:\"ff4500\",orchid:\"da70d6\",palegoldenrod:\"eee8aa\",palegreen:\"98fb98\",paleturquoise:\"afeeee\",palevioletred:\"d87093\",papayawhip:\"ffefd5\",peachpuff:\"ffdab9\",peru:\"cd853f\",pink:\"ffc0cb\",plum:\"dda0dd\",powderblue:\"b0e0e6\",purple:\"800080\",red:\"ff0000\",rosybrown:\"bc8f8f\",royalblue:\"4169e1\",saddlebrown:\"8b4513\",salmon:\"fa8072\",sandybrown:\"f4a460\",seagreen:\"2e8b57\",seashell:\"fff5ee\",sienna:\"a0522d\",silver:\"c0c0c0\",skyblue:\"87ceeb\",slateblue:\"6a5acd\",slategray:\"708090\",snow:\"fffafa\",springgreen:\"00ff7f\",steelblue:\"4682b4\",tan:\"d2b48c\",teal:\"008080\",thistle:\"d8bfd8\",tomato:\"ff6347\",turquoise:\"40e0d0\",violet:\"ee82ee\",violetred:\"d02090\",wheat:\"f5deb3\",white:\"ffffff\",whitesmoke:\"f5f5f5\",yellow:\"ffff00\",yellowgreen:\"9acd32\"},s=[{re:/^\\s*rgba\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*([\\d\\.]{1,3})\\s*\\)\\s*$/,example:[\"rgba(123, 234, 45, 0.5)\",\"rgba(255,234,245,1.0)\"],process:function(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}},{re:/^\\s*rgb\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)\\s*$/,example:[\"rgb(123, 234, 45)\",\"rgb(255,234,245)\"],process:function(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}},{re:/^(\\w{2})(\\w{2})(\\w{2})$/,example:[\"#00ff00\",\"336699\"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\\w{1})(\\w{1})(\\w{1})$/,example:[\"#fb0\",\"f0f\"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}];return t.rgbParser=function(t,i,o){var n,a,h,l,c,d,u,p,f,m=t,b=!1;if(!e.exists(t))return[];if(e.exists(i)&&e.exists(o)&&(m=[t,i,o]),n=m,e.isArray(n)){for(d=0;3>d;d++)b=b||/\\./.test(m[d].toString());for(d=0;3>d;d++)b=b&&m[d]>=0&&m[d]<=1;return b?[Math.ceil(255*m[0]),Math.ceil(255*m[1]),Math.ceil(255*m[2])]:m}for(\"string\"==typeof m&&(n=m),\"#\"===n.charAt(0)&&(n=n.substr(1,6)),n=n.replace(/ /g,\"\").toLowerCase(),n=r[n]||n,d=0;d<s.length;d++)h=s[d].re,l=s[d].process,c=h.exec(n),c&&(a=l(c),u=a[0],p=a[1],f=a[2]);return isNaN(u)||isNaN(p)||isNaN(f)?[]:(u=0>u||isNaN(u)?0:u>255?255:u,p=0>p||isNaN(p)?0:p>255?255:p,f=0>f||isNaN(f)?0:f>255?255:f,[u,p,f])},t.rgb2css=function(e,i,r){var s;return s=t.rgbParser(e,i,r),\"rgb(\"+s[0]+\", \"+s[1]+\", \"+s[2]+\")\"},t.rgb2hex=function(e,i,r){var s,o,n;return s=t.rgbParser(e,i,r),o=s[1],n=s[2],s=s[0],s=s.toString(16),o=o.toString(16),n=n.toString(16),1===s.length&&(s=\"0\"+s),1===o.length&&(o=\"0\"+o),1===n.length&&(n=\"0\"+n),\"#\"+s+o+n},t.hex2rgb=function(e){var i;return i=t.rgbParser(e),\"rgb(\"+i[0]+\", \"+i[1]+\", \"+i[2]+\")\"},t.hsv2rgb=function(t,e,r){var s,o,n,a,h,l,c,d,u;if(t=(t%360+360)%360,0===e){if(!(isNaN(t)||t<i.eps))return\"#ffffff\";s=r,o=r,n=r}else switch(l=t>=360?0:t,l/=60,h=Math.floor(l),a=l-h,c=r*(1-e),d=r*(1-e*a),u=r*(1-e*(1-a)),h){case 0:s=r,o=u,n=c;break;case 1:s=d,o=r,n=c;break;case 2:s=c,o=r,n=u;break;case 3:s=c,o=d,n=r;break;case 4:s=u,o=c,n=r;break;case 5:s=r,o=c,n=d}return s=Math.round(255*s).toString(16),s=2===s.length?s:1===s.length?\"0\"+s:\"00\",o=Math.round(255*o).toString(16),o=2===o.length?o:1===o.length?\"0\"+o:\"00\",n=Math.round(255*n).toString(16),n=2===n.length?n:1===n.length?\"0\"+n:\"00\",[\"#\",s,o,n].join(\"\")},t.rgb2hsv=function(e,i,r){var s,o,n,a,h,l,c,d,u,p,f,m,b;return s=t.rgbParser(e,i,r),o=s[1],n=s[2],s=s[0],a=s/255,h=o/255,l=n/255,m=Math.max(s,o,n),b=Math.min(s,o,n),c=m/255,d=b/255,f=c,p=0,f>0&&(p=(f-d)/f),u=1/(c-d),p>0&&(u=m===s?(h-l)*u:m===o?2+(l-a)*u:4+(a-h)*u),u*=60,0>u&&(u+=360),m===b&&(u=0),[u,p,f]},t.rgb2LMS=function(e,i,r){var s,o,n,a,h,l,c,d=[[.05059983,.08585369,.0095242],[.01893033,.08925308,.01370054],[.00292202,.00975732,.07145979]];\nreturn s=t.rgbParser(e,i,r),o=s[1],n=s[2],s=s[0],s=Math.pow(s,.476190476),o=Math.pow(o,.476190476),n=Math.pow(n,.476190476),a=s*d[0][0]+o*d[0][1]+n*d[0][2],h=s*d[1][0]+o*d[1][1]+n*d[1][2],l=s*d[2][0]+o*d[2][1]+n*d[2][2],c=[a,h,l],c.l=a,c.m=h,c.s=l,c},t.LMS2rgb=function(t,e,i){var r,s,o,n,a=[[30.830854,-29.832659,1.610474],[-6.481468,17.715578,-2.532642],[-.37569,-1.199062,14.273846]],h=function(t){for(var e=127,i=64;i>0;){if(Math.pow(e,.476190476)>t)e-=i;else{if(Math.pow(e+1,.476190476)>t)return e;e+=i}i/=2}return 254===e&&t>13.994955247?255:e};return r=t*a[0][0]+e*a[0][1]+i*a[0][2],s=t*a[1][0]+e*a[1][1]+i*a[1][2],o=t*a[2][0]+e*a[2][1]+i*a[2][2],r=h(r),s=h(s),o=h(o),n=[r,s,o],n.r=r,n.g=s,n.b=o,n},t.rgba2rgbo=function(t){var e;return 9===t.length&&\"#\"===t.charAt(0)?(e=parseInt(t.substr(7,2).toUpperCase(),16)/255,t=t.substr(0,7)):e=1,[t,e]},t.rgbo2rgba=function(t,e){var i;return\"none\"===t?t:(i=Math.round(255*e).toString(16),1===i.length&&(i=\"0\"+i),t+i)},t.rgb2bw=function(e){var i,r,s,o=\"0123456789ABCDEF\";return\"none\"===e?e:(s=t.rgbParser(e),i=Math.floor(.3*s[0]+.59*s[1]+.11*s[2]),r=o.charAt(15&i>>4)+o.charAt(15&i),e=\"#\"+r+r+r)},t.rgb2cb=function(e,i){var r,s,o,n,a,h,l,c,d,u,p,f,m,b=\"0123456789ABCDEF\";if(\"none\"===e)return e;switch(a=t.rgb2LMS(e),s=a[0],o=a[1],n=a[2],i=i.toLowerCase()){case\"protanopia\":l=-.06150039994295001,c=.08277001656812001,d=-.013200141220000003,u=.05858939668799999,p=-.07934519995360001,f=.013289415272000003,m=.6903216543277437,h=n/o,s=m>h?-(c*o+d*n)/l:-(p*o+f*n)/u;break;case\"tritanopia\":l=-.00058973116217,c=.007690316482,d=-.01011703519052,u=.025495080838999994,p=-.0422740347,f=.017005316784,m=.8349489908460004,h=o/s,n=m>h?-(l*s+c*o)/d:-(u*s+p*o)/f;break;default:l=-.06150039994295001,c=.08277001656812001,d=-.013200141220000003,u=.05858939668799999,p=-.07934519995360001,f=.013289415272000003,m=.5763833686400911,h=n/s,o=m>h?-(l*s+d*n)/c:-(u*s+f*n)/p}return r=t.LMS2rgb(s,o,n),h=b.charAt(15&r[0]>>4)+b.charAt(15&r[0]),e=\"#\"+h,h=b.charAt(15&r[1]>>4)+b.charAt(15&r[1]),e+=h,h=b.charAt(15&r[2]>>4)+b.charAt(15&r[2]),e+=h},t.autoHighlight=function(e){var i=t.rgba2rgbo(e),r=i[0],s=i[1];return\"#\"===e.charAt(0)?(s*=.3>s?1.333333:.666666,t.rgbo2rgba(r,s)):e},t}),define(\"options\",[\"jxg\",\"base/constants\",\"math/math\",\"utils/color\",\"utils/type\"],function(t,e,i,r,s){return t.Options={jc:{enabled:!0,compile:!0},board:{boundingBox:[-5,5,5,-5],zoomFactor:1,zoomX:1,zoomY:1,showCopyright:!0,axis:!1,showNavigation:!0,showReload:!1,showClearTraces:!1,keepAspectRatio:!1,document:!1,takeFirst:!1,takeSizeFromFile:!1,renderer:\"svg\",animationDelay:35,registerEvents:!0,minimizeReflow:\"svg\",offsetX:0,offsetY:0,zoom:{factorX:1.25,factorY:1.25,wheel:!1,needshift:!1,eps:.1},pan:{needShift:!0,needTwoFingers:!0,enabled:!0}},navbar:{strokeColor:\"#333333\",fillColor:\"transparent\",highlightFillColor:\"#aaaaaa\",padding:\"2px\",position:\"absolute\",fontSize:\"14px\",cursor:\"pointer\",zIndex:\"100\",right:\"5px\",bottom:\"5px\"},elements:{strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",fillColor:\"red\",highlightFillColor:\"none\",strokeOpacity:1,highlightStrokeOpacity:1,fillOpacity:1,highlightFillOpacity:1,strokeWidth:2,highlightStrokeWidth:2,fixed:!1,frozen:!1,withLabel:!1,visible:!0,priv:!1,layer:0,dash:0,shadow:!1,trace:!1,traceAttributes:{},highlight:!0,needsRegularUpdate:!0,snapToGrid:!1,scalable:!0,draft:{draft:!1,strokeColor:\"#565656\",fillColor:\"#565656\",strokeOpacity:.8,fillOpacity:.8,strokeWidth:1},isLabel:!1},ticks:{generateLabelValue:null,drawLabels:!1,label:{},anchor:\"left\",drawZero:!1,insertTicks:!1,minTicksDistance:10,minorHeight:4,majorHeight:10,tickEndings:[1,1],minorTicks:4,scale:1,scaleSymbol:\"\",labels:[],maxLabelLength:5,precision:3,ticksDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:\"black\",highlightStrokeColor:\"#888888\",includeBoundaries:!1},hatch:{drawLabels:!1,drawZero:!0,majorHeight:20,anchor:\"middle\",strokeWidth:2,strokeColor:\"blue\",ticksDistance:.2},precision:{touch:30,touchMax:100,mouse:4,epsilon:1e-4,hasPoint:4},layer:{numlayers:20,text:9,point:9,glider:9,arc:8,line:7,circle:6,curve:5,turtle:5,polygon:3,sector:3,angle:3,integral:3,axis:2,grid:1,image:0,trace:0},angle:{withLabel:!0,radius:.5,type:\"sector\",orthoType:\"square\",orthoSensitivity:1,fillColor:\"#FF7F00\",highlightFillColor:\"#FF7F00\",strokeColor:\"#FF7F00\",fillOpacity:.3,highlightFillOpacity:.3,radiuspoint:{withLabel:!1,visible:!1,name:\"\"},pointsquare:{withLabel:!1,visible:!1,name:\"\"},dot:{visible:!1,strokeColor:\"none\",fillColor:\"black\",size:2,face:\"o\",withLabel:!1,name:\"\"},label:{position:\"top\",offset:[0,0],strokeColor:\"#0000FF\"}},arc:{label:{},firstArrow:!1,lastArrow:!1,fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",useDirection:!1},axis:{name:\"\",needsRegularUpdate:!1,strokeWidth:1,strokeColor:\"#666666\",highlightStrokeWidth:1,highlightStrokeColor:\"#888888\",withTicks:!0,straightFirst:!0,straightLast:!0,lastArrow:!0,withLabel:!1,scalable:!1,ticks:{label:{offset:[4,-9],parse:!1},needsRegularUpdate:!1,strokeWidth:1,strokeColor:\"#666666\",highlightStrokeColor:\"#888888\",drawLabels:!0,drawZero:!1,insertTicks:!0,minTicksDistance:10,minorHeight:10,majorHeight:-1,tickEndings:[0,1],minorTicks:4,ticksDistance:1,strokeOpacity:.25},point1:{needsRegularUpdate:!1},point2:{needsRegularUpdate:!1},label:{position:\"lft\",offset:[10,10]}},bisector:{strokeColor:\"#000000\",point:{visible:!1,fixed:!1,withLabel:!1,name:\"\"}},bisectorlines:{line1:{strokeColor:\"black\"},line2:{strokeColor:\"black\"}},chart:{chartStyle:\"line\",colors:[\"#B02B2C\",\"#3F4C6B\",\"#C79810\",\"#D15600\",\"#FFFF88\",\"#C3D9FF\",\"#4096EE\",\"#008C00\"],highlightcolors:null,fillcolor:null,highlightonsector:!1,highlightbysize:!1,label:{}},circle:{hasInnerPoints:!1,fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",center:{visible:!1,withLabel:!1,fixed:!1,name:\"\"},label:{position:\"urt\"}},circumcircle:{fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",center:{visible:!1,fixed:!1,withLabel:!1,name:\"\"}},circumcirclearc:{fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",center:{visible:!1,withLabel:!1,fixed:!1,name:\"\"}},circumcirclesector:{useDirection:!0,fillColor:\"#00FF00\",highlightFillColor:\"#00FF00\",fillOpacity:.3,highlightFillOpacity:.3,strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",point:{visible:!1,fixed:!1,withLabel:!1,name:\"\"}},conic:{fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",foci:{fixed:!1,visible:!1,withLabel:!1,name:\"\"}},curve:{strokeWidth:1,strokeColor:\"#0000ff\",fillColor:\"none\",fixed:!0,useQDT:!1,handDrawing:!1,curveType:null,RDPsmoothing:!1,numberPointsHigh:1600,numberPointsLow:400,doAdvancedPlot:!0,doAdvancedPlotOld:!1,label:{position:\"lft\"}},glider:{label:{}},grid:{needsRegularUpdate:!1,hasGrid:!1,gridX:1,gridY:1,strokeColor:\"#C0C0C0\",strokeOpacity:.5,strokeWidth:1,dash:0,snapToGrid:!1,snapSizeX:10,snapSizeY:10},htmlslider:{widthRange:100,widthOut:34,step:.01,frozen:!0,isLabel:!1,strokeColor:\"black\",display:\"html\",anchorX:\"left\",anchorY:\"middle\",withLabel:!1},image:{imageString:null,fillOpacity:1,cssClass:\"JXGimage\",highlightCssClass:\"JXGimageHighlight\",rotate:0,snapSizeX:1,snapSizeY:1},incircle:{fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#C3D9FF\",center:{visible:!1,fixed:!1,withLabel:!1,name:\"\"}},inequality:{fillColor:\"red\",fillOpacity:.2,strokeColor:\"none\",inverse:!1},infobox:{fontSize:12,isLabel:!1,strokeColor:\"#bbbbbb\",display:\"html\",anchorX:\"left\",anchorY:\"middle\",cssClass:\"JXGinfobox\",rotate:0,visible:!0,parse:!1},integral:{axis:\"x\",withLabel:!0,strokeWidth:0,strokeOpacity:0,fillOpacity:.8,curveLeft:{visible:!0,withLabel:!1,layer:9},baseLeft:{visible:!1,fixed:!1,withLabel:!1,name:\"\"},curveRight:{visible:!0,withLabel:!1,layer:9},baseRight:{visible:!1,fixed:!1,withLabel:!1,name:\"\"},label:{fontSize:20}},intersection:{alwaysIntersect:!0},label:{strokeColor:\"black\",strokeOpacity:1,highlightStrokeOpacity:.666666,highlightStrokeColor:\"black\",fixed:!0,position:\"urt\",offset:[10,10]},legend:{style:\"vertical\",labels:[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\"],colors:[\"#B02B2C\",\"#3F4C6B\",\"#C79810\",\"#D15600\",\"#FFFF88\",\"#C3D9FF\",\"#4096EE\",\"#008C00\"]},line:{firstArrow:!1,lastArrow:!1,straightFirst:!0,straightLast:!0,fillColor:\"none\",highlightFillColor:\"none\",strokeColor:\"#0000ff\",highlightStrokeColor:\"#888888\",withTicks:!1,point1:{visible:!1,withLabel:!1,fixed:!1,name:\"\"},point2:{visible:!1,withLabel:!1,fixed:!1,name:\"\"},ticks:{drawLabels:!0,label:{offset:[4,-9]},drawZero:!1,insertTicks:!1,minTicksDistance:50,minorHeight:4,majorHeight:-1,minorTicks:4,defaultDistance:1,strokeOpacity:.3},label:{position:\"llft\"},snapToGrid:!1,snapSizeX:1,snapSizeY:1,touchFirstPoint:!1,touchLastPoint:!1},locus:{translateToOrigin:!1,translateTo10:!1,stretch:!1,toOrigin:null,to10:null},normal:{strokeColor:\"#000000\",point:{visible:!1,fixed:!1,withLabel:!1,name:\"\"}},orthogonalprojection:{},parallel:{strokeColor:\"#000000\",point:{visible:!1,fixed:!1,withLabel:!1,name:\"\"},label:{position:\"llft\"}},perpendicular:{strokeColor:\"#000000\",straightFirst:!0,straightLast:!0},perpendicularsegment:{strokeColor:\"#000000\",straightFirst:!1,straightLast:!1,point:{visible:!1,fixed:!0,withLabel:!1,name:\"\"}},point:{withLabel:!0,label:{},style:5,face:\"o\",size:3,fillColor:\"#ff0000\",highlightFillColor:\"#EEEEEE\",strokeWidth:2,strokeColor:\"#ff0000\",highlightStrokeColor:\"#C3D9FF\",zoom:!1,showInfobox:!0,infoboxDigits:\"auto\",draft:!1,attractors:[],attractorUnit:\"user\",attractorDistance:0,snatchDistance:0,snapToGrid:!1,snapSizeX:1,snapSizeY:1,snapToPoints:!1},polygon:{hasInnerPoints:!1,fillColor:\"#00FF00\",highlightFillColor:\"#00FF00\",fillOpacity:.3,highlightFillOpacity:.3,withLines:!0,borders:{withLabel:!1,strokeWidth:1,highlightStrokeWidth:1,layer:5,label:{position:\"top\"}},vertices:{withLabel:!0,strokeColor:\"#ff0000\",fillColor:\"#ff0000\",fixed:!0},label:{offset:[0,0]}},prescribedangle:{anglepoint:{size:2,visible:!1,withLabel:!1}},riemannsum:{withLabel:!1,fillOpacity:.3,fillColor:\"#ffff00\"},sector:{fillColor:\"#00FF00\",highlightFillColor:\"#00FF00\",fillOpacity:.3,highlightFillOpacity:.3,highlightOnSector:!1,radiuspoint:{visible:!1,withLabel:!1},center:{visible:!1,withLabel:!1},anglepoint:{visible:!1,withLabel:!1},label:{offset:[0,0]}},segment:{label:{position:\"top\"}},semicircle:{midpoint:{visible:!1,withLabel:!1,fixed:!1,name:\"\"}},slider:{snapWidth:-1,precision:2,firstArrow:!1,lastArrow:!1,withTicks:!0,withLabel:!0,layer:9,showInfobox:!1,name:\"\",visible:!0,strokeColor:\"#000000\",highlightStrokeColor:\"#888888\",fillColor:\"#ffffff\",highlightFillColor:\"none\",size:6,point1:{needsRegularUpdate:!1,showInfobox:!1,withLabel:!1,visible:!1,fixed:!0,name:\"\"},point2:{needsRegularUpdate:!1,showInfobox:!1,withLabel:!1,visible:!1,fixed:!0,name:\"\"},baseline:{needsRegularUpdate:!1,fixed:!0,name:\"\",strokeWidth:1,strokeColor:\"#000000\",highlightStrokeColor:\"#888888\"},ticks:{needsRegularUpdate:!1,fixed:!0,drawLabels:!1,drawZero:!0,insertTicks:!0,minorHeight:4,majorHeight:10,minorTicks:0,defaultDistance:1,strokeOpacity:1,strokeWidth:1,strokeColor:\"#000000\"},highline:{strokeWidth:3,fixed:!0,name:\"\",strokeColor:\"#000000\",highlightStrokeColor:\"#888888\"},label:{strokeColor:\"#000000\"}},slopetriangle:{fillColor:\"red\",fillOpacity:.4,highlightFillColor:\"red\",highlightFillOpacity:.3,glider:{fixed:!0,visible:!1,withLabel:!1},baseline:{visible:!1,withLabel:!1,name:\"\"},basepoint:{visible:!1,withLabel:!1,name:\"\"},toppoint:{visible:!1,withLabel:!1,name:\"\"},label:{visible:!0}},stepfunction:{},tapemeasure:{strokeColor:\"#000000\",strokeWidth:2,highlightStrokeColor:\"#000000\",withTicks:!0,withLabel:!0,precision:2,point1:{strokeColor:\"#000000\",fillColor:\"#ffffff\",fillOpacity:0,highlightFillOpacity:.1,size:6,snapToPoints:!0,attractorUnit:\"screen\",attractorDistance:20,showInfobox:!1,withLabel:!1,name:\"\"},point2:{strokeColor:\"#000000\",fillColor:\"#ffffff\",fillOpacity:0,highlightFillOpacity:.1,size:6,snapToPoints:!0,attractorUnit:\"screen\",attractorDistance:20,showInfobox:!1,withLabel:!1,name:\"\"},ticks:{drawLabels:!1,drawZero:!0,insertTicks:!0,minorHeight:8,majorHeight:16,minorTicks:4,tickEndings:[0,1],defaultDistance:.1,strokeOpacity:1,strokeWidth:1,strokeColor:\"#000000\"},label:{position:\"top\"}},text:{fontSize:12,digits:2,parse:!0,useCaja:!1,isLabel:!1,strokeColor:\"black\",highlightStrokeColor:\"black\",highlightStrokeOpacity:.666666,useASCIIMathML:!1,useMathJax:!1,display:\"html\",anchorX:\"left\",anchorY:\"middle\",cssClass:\"JXGtext\",highlightCssClass:\"JXGtext\",dragArea:\"all\",withLabel:!1,rotate:0,visible:!0,snapSizeX:1,snapSizeY:1},tracecurve:{strokeColor:\"#000000\",fillColor:\"none\",numberPoints:100},turtle:{strokeWidth:1,fillColor:\"none\",strokeColor:\"#000000\",arrow:{strokeWidth:2,withLabel:!1,strokeColor:\"#ff0000\"}},shortcuts:{color:[\"strokeColor\",\"fillColor\"],opacity:[\"strokeOpacity\",\"fillOpacity\"],highlightColor:[\"highlightStrokeColor\",\"highlightFillColor\"],highlightOpacity:[\"highlightStrokeOpacity\",\"highlightFillOpacity\"],strokeWidth:[\"strokeWidth\",\"highlightStrokeWidth\"]}},t.Validator=function(){var e,r=function(t){return/^[0-9]+px$/.test(t)},o=function(t){return\"html\"===t||\"internal\"===t},n=function(t){return s.isString(t)},a=function(e){return s.exists(t.normalizePointFace(e))},h=function(t){return Math.abs(t-Math.round(t))<i.eps},l=function(t){return h(t)&&t>0},c=function(t){return\"vml\"===t||\"svg\"===t||\"canvas\"===t||\"no\"===t},d=function(t){return t>0},u=function(t){return t>=0},p={},f={attractorDistance:u,color:n,defaultDistance:s.isNumber,display:o,doAdvancedPlot:!1,draft:!1,drawLabels:!1,drawZero:!1,face:a,factor:s.isNumber,fillColor:n,fillOpacity:s.isNumber,firstArrow:!1,fontSize:h,dash:h,gridX:s.isNumber,gridY:s.isNumber,hasGrid:!1,highlightFillColor:n,highlightFillOpacity:s.isNumber,highlightStrokeColor:n,highlightStrokeOpacity:s.isNumber,insertTicks:!1,lastArrow:!1,majorHeight:h,minorHeight:h,minorTicks:l,minTicksDistance:l,numberPointsHigh:l,numberPointsLow:l,opacity:s.isNumber,radius:s.isNumber,RDPsmoothing:!1,renderer:c,right:r,showCopyright:!1,showInfobox:!1,showNavigation:!1,size:h,snapSizeX:d,snapSizeY:d,snapWidth:s.isNumber,snapToGrid:!1,snatchDistance:u,straightFirst:!1,straightLast:!1,stretch:!1,strokeColor:n,strokeOpacity:s.isNumber,strokeWidth:h,takeFirst:!1,takeSizeFromFile:!1,to10:!1,toOrigin:!1,translateTo10:!1,translateToOrigin:!1,useASCIIMathML:!1,useDirection:!1,useMathJax:!1,withLabel:!1,withTicks:!1,zoom:!1};for(e in f)f.hasOwnProperty(e)&&(p[e.toLowerCase()]=f[e]);return p}(),t.normalizePointFace=function(t){var e={cross:\"x\",x:\"x\",circle:\"o\",o:\"o\",square:\"[]\",\"[]\":\"[]\",plus:\"+\",\"+\":\"+\",diamond:\"<>\",\"<>\":\"<>\",triangleup:\"^\",a:\"^\",\"^\":\"^\",triangledown:\"v\",v:\"v\",triangleleft:\"<\",\"<\":\"<\",triangleright:\">\",\">\":\">\"};return e[t]},t.useStandardOptions=function(i){var r,s,o,n,a=t.Options,h=i.hasGrid;i.options.grid.hasGrid=a.grid.hasGrid,i.options.grid.gridX=a.grid.gridX,i.options.grid.gridY=a.grid.gridY,i.options.grid.gridColor=a.grid.gridColor,i.options.grid.gridOpacity=a.grid.gridOpacity,i.options.grid.gridDash=a.grid.gridDash,i.options.grid.snapToGrid=a.grid.snapToGrid,i.options.grid.snapSizeX=a.grid.SnapSizeX,i.options.grid.snapSizeY=a.grid.SnapSizeY,i.takeSizeFromFile=a.takeSizeFromFile,n=function(t,e){t.visProp.fillcolor=e.fillColor,t.visProp.highlightfillcolor=e.highlightFillColor,t.visProp.strokecolor=e.strokeColor,t.visProp.highlightstrokecolor=e.highlightStrokeColor};for(r in i.objects)if(i.objects.hasOwnProperty(r))if(o=i.objects[r],o.elementClass===e.OBJECT_CLASS_POINT)n(o,a.point);else if(o.elementClass===e.OBJECT_CLASS_LINE)for(n(o,a.line),s=0;s<o.ticks.length;s++)o.ticks[s].majorTicks=a.line.ticks.majorTicks,o.ticks[s].minTicksDistance=a.line.ticks.minTicksDistance,o.ticks[s].visProp.minorheight=a.line.ticks.minorHeight,o.ticks[s].visProp.majorheight=a.line.ticks.majorHeight;else o.elementClass===e.OBJECT_CLASS_CIRCLE?n(o,a.circle):o.type===e.OBJECT_TYPE_ANGLE?n(o,a.angle):o.type===e.OBJECT_TYPE_ARC?n(o,a.arc):o.type===e.OBJECT_TYPE_POLYGON?n(o,a.polygon):o.type===e.OBJECT_TYPE_CONIC?n(o,a.conic):o.type===e.OBJECT_TYPE_CURVE?n(o,a.curve):o.type===e.OBJECT_TYPE_SECTOR&&(o.arc.visProp.fillcolor=a.sector.fillColor,o.arc.visProp.highlightfillcolor=a.sector.highlightFillColor,o.arc.visProp.fillopacity=a.sector.fillOpacity,o.arc.visProp.highlightfillopacity=a.sector.highlightFillOpacity);i.fullUpdate(),h&&!i.hasGrid?i.removeGrids(i):!h&&i.hasGrid&&i.create(\"grid\",[])},t.useBlackWhiteOptions=function(e){var i=t.Options;i.point.fillColor=r.rgb2bw(i.point.fillColor),i.point.highlightFillColor=r.rgb2bw(i.point.highlightFillColor),i.point.strokeColor=r.rgb2bw(i.point.strokeColor),i.point.highlightStrokeColor=r.rgb2bw(i.point.highlightStrokeColor),i.line.fillColor=r.rgb2bw(i.line.fillColor),i.line.highlightFillColor=r.rgb2bw(i.line.highlightFillColor),i.line.strokeColor=r.rgb2bw(i.line.strokeColor),i.line.highlightStrokeColor=r.rgb2bw(i.line.highlightStrokeColor),i.circle.fillColor=r.rgb2bw(i.circle.fillColor),i.circle.highlightFillColor=r.rgb2bw(i.circle.highlightFillColor),i.circle.strokeColor=r.rgb2bw(i.circle.strokeColor),i.circle.highlightStrokeColor=r.rgb2bw(i.circle.highlightStrokeColor),i.arc.fillColor=r.rgb2bw(i.arc.fillColor),i.arc.highlightFillColor=r.rgb2bw(i.arc.highlightFillColor),i.arc.strokeColor=r.rgb2bw(i.arc.strokeColor),i.arc.highlightStrokeColor=r.rgb2bw(i.arc.highlightStrokeColor),i.polygon.fillColor=r.rgb2bw(i.polygon.fillColor),i.polygon.highlightFillColor=r.rgb2bw(i.polygon.highlightFillColor),i.sector.fillColor=r.rgb2bw(i.sector.fillColor),i.sector.highlightFillColor=r.rgb2bw(i.sector.highlightFillColor),i.curve.strokeColor=r.rgb2bw(i.curve.strokeColor),i.grid.gridColor=r.rgb2bw(i.grid.gridColor),t.useStandardOptions(e)},t.Options.normalizePointFace=t.normalizePointFace,t.Options}),define(\"math/numerics\",[\"utils/type\",\"math/math\"],function(t,e){var i={rk4:{s:4,A:[[0,0,0,0],[.5,0,0,0],[0,.5,0,0],[0,0,1,0]],b:[1/6,1/3,1/3,1/6],c:[0,.5,.5,1]},heun:{s:2,A:[[0,0],[1,0]],b:[.5,.5],c:[0,1]},euler:{s:1,A:[[0]],b:[1],c:[0]}};return e.Numerics={Gauss:function(i,r){var s,o,n,a,h,l=e.eps,c=i.length>0?i[0].length:0;if(c!==r.length||c!==i.length)throw new Error(\"JXG.Math.Numerics.Gauss: Dimensions don't match. A must be a square matrix and b must be of the same length as A.\");for(a=[],h=r.slice(0,c),s=0;c>s;s++)a[s]=i[s].slice(0,c);for(o=0;c>o;o++){for(s=c-1;s>o;s--)if(Math.abs(a[s][o])>l)if(Math.abs(a[o][o])<l)t.swap(a,s,o),t.swap(h,s,o);else for(a[s][o]/=a[o][o],h[s]-=a[s][o]*h[o],n=o+1;c>n;n++)a[s][n]-=a[s][o]*a[o][n];if(Math.abs(a[o][o])<l)throw new Error(\"JXG.Math.Numerics.Gauss(): The given matrix seems to be singular.\")}return this.backwardSolve(a,h,!0),h},backwardSolve:function(t,e,i){var r,s,o,n,a;for(r=i?e:e.slice(0,e.length),s=t.length,o=t.length>0?t[0].length:0,n=s-1;n>=0;n--){for(a=o-1;a>n;a--)r[n]-=t[n][a]*r[a];r[n]/=t[n][n]}return r},gaussBareiss:function(t){var i,r,s,o,n,a,h,l,c,d=e.eps;if(h=t.length,0>=h)return 0;for(t[0].length<h&&(h=t[0].length),l=[],o=0;h>o;o++)l[o]=t[o].slice(0,h);for(r=1,s=1,i=0;h-1>i;i++){if(a=l[i][i],Math.abs(a)<d){for(o=i+1;h>o&&!(Math.abs(l[o][i])>=d);o++);if(o===h)return 0;for(n=i;h>n;n++)c=l[o][n],l[o][n]=l[i][n],l[i][n]=c;s=-s,a=l[i][i]}for(o=i+1;h>o;o++)for(n=i+1;h>n;n++)c=a*l[o][n]-l[o][i]*l[i][n],l[o][n]=c/r;r=a}return s*l[h-1][h-1]},det:function(t){var e=t.length;return 2===e&&2===t[0].length?t[0][0]*t[1][1]-t[1][0]*t[0][1]:this.gaussBareiss(t)},Jacobi:function(t){var i,r,s,o,n,a,h,l,c,d=e.eps,u=0,p=t.length,f=[[0,0,0],[0,0,0],[0,0,0]],m=[[0,0,0],[0,0,0],[0,0,0]],b=0;for(i=0;p>i;i++){for(r=0;p>r;r++)f[i][r]=0,m[i][r]=t[i][r],u+=Math.abs(m[i][r]);f[i][i]=1}if(1===p)return[m,f];if(0>=u)return[m,f];u/=p*p;do{for(l=0,c=0,r=1;p>r;r++)for(i=0;r>i;i++)if(o=Math.abs(m[i][r]),o>c&&(c=o),l+=o,o>=d){for(o=.5*Math.atan2(2*m[i][r],m[i][i]-m[r][r]),n=Math.sin(o),a=Math.cos(o),s=0;p>s;s++)h=m[s][i],m[s][i]=a*h+n*m[s][r],m[s][r]=-n*h+a*m[s][r],h=f[s][i],f[s][i]=a*h+n*f[s][r],f[s][r]=-n*h+a*f[s][r];for(m[i][i]=a*m[i][i]+n*m[r][i],m[r][r]=-n*m[i][r]+a*m[r][r],m[i][r]=0,s=0;p>s;s++)m[i][s]=m[s][i],m[r][s]=m[s][r]}b+=1}while(Math.abs(l)/u>d&&2e3>b);return[m,f]},NewtonCotes:function(t,e,i){var r,s,o,n=0,a=i&&\"number\"==typeof i.number_of_nodes?i.number_of_nodes:28,h={trapez:!0,simpson:!0,milne:!0},l=i&&i.integration_type&&h.hasOwnProperty(i.integration_type)&&h[i.integration_type]?i.integration_type:\"milne\",c=(t[1]-t[0])/a;switch(l){case\"trapez\":for(n=.5*(e(t[0])+e(t[1])),r=t[0],s=0;a-1>s;s++)r+=c,n+=e(r);n*=c;break;case\"simpson\":if(a%2>0)throw new Error(\"JSXGraph: INT_SIMPSON requires config.number_of_nodes dividable by 2.\");for(o=a/2,n=e(t[0])+e(t[1]),r=t[0],s=0;o-1>s;s++)r+=2*c,n+=2*e(r);for(r=t[0]-c,s=0;o>s;s++)r+=2*c,n+=4*e(r);n*=c/3;break;default:if(a%4>0)throw new Error(\"JSXGraph: Error in INT_MILNE: config.number_of_nodes must be a multiple of 4\");for(o=.25*a,n=7*(e(t[0])+e(t[1])),r=t[0],s=0;o-1>s;s++)r+=4*c,n+=14*e(r);for(r=t[0]-3*c,s=0;o>s;s++)r+=4*c,n+=32*(e(r)+e(r+2*c));for(r=t[0]-2*c,s=0;o>s;s++)r+=4*c,n+=12*e(r);n*=2*c/45}return n},I:function(t,e){return this.NewtonCotes(t,e,{number_of_nodes:16,integration_type:\"milne\"})},Newton:function(i,r,s){var o,n=0,a=e.eps,h=i.apply(s,[r]),l=1;for(t.isArray(r)&&(r=r[0]);50>n&&Math.abs(h)>a;)o=this.D(i,s)(r),l+=2,Math.abs(o)>a?r-=h/o:r+=.2*Math.random()-1,h=i.apply(s,[r]),l+=1,n+=1;return r},root:function(t,e,i){return this.fzero(t,e,i)},generalizedNewton:function(t,i,r,s){var o,n,a,h,l,c,d,u,p,f,m,b,g,v,C=0;for(this.generalizedNewton.t1memo?(o=this.generalizedNewton.t1memo,n=this.generalizedNewton.t2memo):(o=r,n=s),u=t.X(o)-i.X(n),p=t.Y(o)-i.Y(n),f=u*u+p*p,m=this.D(t.X,t),b=this.D(i.X,i),g=this.D(t.Y,t),v=this.D(i.Y,i);f>e.eps&&10>C;)a=m(o),h=-b(n),l=g(o),c=-v(n),d=a*c-h*l,o-=(c*u-h*p)/d,n-=(a*p-l*u)/d,u=t.X(o)-i.X(n),p=t.Y(o)-i.Y(n),f=u*u+p*p,C+=1;return this.generalizedNewton.t1memo=o,this.generalizedNewton.t2memo=n,Math.abs(o)<Math.abs(n)?[t.X(o),t.Y(o)]:[i.X(n),i.Y(n)]},Neville:function(t){var i=[],r=function(r){return function(s,o){var n,a,h,l=e.binomial,c=t.length,d=c-1,u=0,p=0;if(!o)for(h=1,n=0;c>n;n++)i[n]=l(d,n)*h,h*=-1;for(a=s,n=0;c>n;n++){if(0===a)return t[n][r]();h=i[n]/a,a-=1,u+=t[n][r]()*h,p+=h}return u/p}},s=r(\"X\"),o=r(\"Y\");return[s,o,0,function(){return t.length-1}]},splineDef:function(t,e){var i,r,s,o=Math.min(t.length,e.length),n=[],a=[],h=[],l=[],c=[],d=[];if(2===o)return[0,0];for(r=0;o>r;r++)i={X:t[r],Y:e[r]},h.push(i);for(h.sort(function(t,e){return t.X-e.X}),r=0;o>r;r++)t[r]=h[r].X,e[r]=h[r].Y;for(r=0;o-1>r;r++)l.push(t[r+1]-t[r]);for(r=0;o-2>r;r++)c.push(6*(e[r+2]-e[r+1])/l[r+1]-6*(e[r+1]-e[r])/l[r]);for(n.push(2*(l[0]+l[1])),a.push(c[0]),r=0;o-3>r;r++)s=l[r+1]/n[r],n.push(2*(l[r+1]+l[r+2])-s*l[r+1]),a.push(c[r+1]-s*a[r]);for(d[o-3]=a[o-3]/n[o-3],r=o-4;r>=0;r--)d[r]=(a[r]-l[r+1]*d[r+1])/n[r];for(r=o-3;r>=0;r--)d[r+1]=d[r];return d[0]=0,d[o-1]=0,d},splineEval:function(e,i,r,s){var o,n,a,h,l,c,d,u=Math.min(i.length,r.length),p=1,f=!1,m=[];for(t.isArray(e)?(p=e.length,f=!0):e=[e],o=0;p>o;o++){if(e[o]<i[0]||i[o]>i[u-1])return 0/0;for(n=1;u>n&&!(e[o]<=i[n]);n++);n-=1,a=r[n],h=(r[n+1]-r[n])/(i[n+1]-i[n])-(i[n+1]-i[n])/6*(s[n+1]+2*s[n]),l=s[n]/2,c=(s[n+1]-s[n])/(6*(i[n+1]-i[n])),d=e[o]-i[n],m.push(a+(h+(l+c*d)*d)*d)}return f?m:m[0]},generatePolynomialTerm:function(t,e,i,r){var s,o=[];for(s=e;s>=0;s--)o=o.concat([\"(\",t[s].toPrecision(r),\")\"]),s>1?o=o.concat([\"*\",i,\"<sup>\",s,\"<\",\"/sup> + \"]):1===s&&(o=o.concat([\"*\",i,\" + \"]));return o.join(\"\")},lagrangePolynomial:function(t){var e=[],i=function(i,r){var s,o,n,a,h,l,c=t.length,d=0,u=0;if(!r){for(s=0;c>s;s++){for(e[s]=1,a=t[s].X(),n=0;c>n;n++)n!==s&&(e[s]*=a-t[n].X());e[s]=1/e[s]}for(l=[],o=0;c>o;o++)l.push([1])}for(s=0;c>s;s++){if(a=t[s].X(),i===a)return t[s].Y();h=e[s]/(i-a),u+=h,d+=h*t[s].Y()}return d/u};return i.getTerm=function(){return\"\"},i},CardinalSpline:function(e,i){var r,s,o,n=[],a={},h={};return o=t.isFunction(i)?i:function(){return i},s=function(t){return function(i,s){var l,c,d=e.length,u=o();if(2>d)return 0/0;if(!s)for(a[t]=function(){return 2*e[0][t]()-e[1][t]()},h[t]=function(){return 2*e[d-1][t]()-e[d-2][t]()},r=[a].concat(e,[h]),n[t]=[],l=0;d-1>l;l++)n[t][l]=[1/u*r[l+1][t](),-r[l][t]()+r[l+2][t](),2*r[l][t]()+(-3/u+1)*r[l+1][t]()+(3/u-2)*r[l+2][t]()-r[l+3][t](),-r[l][t]()+(2/u-1)*r[l+1][t]()+(-2/u+1)*r[l+2][t]()+r[l+3][t]()];return d+=2,isNaN(i)?0/0:0>=i?r[1][t]():i>=d-3?r[d-2][t]():(l=Math.floor(i),l===i?r[l][t]():(i-=l,c=n[t][l],u*(((c[3]*i+c[2])*i+c[1])*i+c[0])))}},[s(\"X\"),s(\"Y\"),0,function(){return e.length-1}]},CatmullRomSpline:function(t){return this.CardinalSpline(t,.5)},regressionPolynomial:function(i,r,s){var o,n,a,h,l,c,d=\"\";if(t.isPoint(i)&&\"function\"==typeof i.Value)n=function(){return i.Value()};else if(t.isFunction(i))n=i;else{if(!t.isNumber(i))throw new Error(\"JSXGraph: Can't create regressionPolynomial from degree of type'\"+typeof i+\"'.\");n=function(){return i}}if(3===arguments.length&&t.isArray(r)&&t.isArray(s))l=0;else if(2===arguments.length&&t.isArray(r)&&r.length>0&&t.isPoint(r[0]))l=1;else{if(!(2===arguments.length&&t.isArray(r)&&r.length>0&&r[0].usrCoords&&r[0].scrCoords))throw new Error(\"JSXGraph: Can't create regressionPolynomial. Wrong parameters.\");l=2}return c=function(i,c){var u,p,f,m,b,g,v,C,y,P=r.length;if(y=Math.floor(n()),!c){if(1===l)for(a=[],h=[],u=0;P>u;u++)a[u]=r[u].X(),h[u]=r[u].Y();if(2===l)for(a=[],h=[],u=0;P>u;u++)a[u]=r[u].usrCoords[1],h[u]=r[u].usrCoords[2];if(0===l)for(a=[],h=[],u=0;P>u;u++)t.isFunction(r[u])?a.push(r[u]()):a.push(r[u]),t.isFunction(s[u])?h.push(s[u]()):h.push(s[u]);for(f=[],p=0;P>p;p++)f.push([1]);for(u=1;y>=u;u++)for(p=0;P>p;p++)f[p][u]=f[p][u-1]*a[p];b=h,m=e.transpose(f),g=e.matMatMult(m,f),v=e.matVecMult(m,b),o=e.Numerics.Gauss(g,v),d=e.Numerics.generatePolynomialTerm(o,y,\"x\",3)}for(C=o[y],u=y-1;u>=0;u--)C=C*i+o[u];return C},c.getTerm=function(){return d},c},bezier:function(t){var e,i,r=function(r){return function(s,o){var n=3*Math.floor(s),a=s%1,h=1-a;return o||(i=3*Math.floor((t.length-1)/3),e=Math.floor(i/3)),0>s?t[0][r]():s>=e?t[i][r]():isNaN(s)?0/0:h*h*(h*t[n][r]()+3*a*t[n+1][r]())+(3*h*t[n+2][r]()+a*t[n+3][r]())*a*a}};return[r(\"X\"),r(\"Y\"),0,function(){return Math.floor(t.length/3)}]},bspline:function(t,e){var i,r=[],s=function(t,e){var i,r=[];for(i=0;t+e+1>i;i++)r[i]=e>i?0:t>=i?i-e+1:t-e+2;return r},o=function(t,e,i,r,s){var o,n,a,h,l,c=[];for(c[s]=e[s]<=t&&t<e[s+1]?1:0,o=2;r>=o;o++)for(n=s-o+1;s>=n;n++)a=s-o+1>=n||0>n?0:c[n],h=n>=s?0:c[n+1],l=e[n+o-1]-e[n],c[n]=0===l?0:(t-e[n])/l*a,l=e[n+o]-e[n+1],0!==l&&(c[n]+=(e[n+o]-t)/l*h);return c},n=function(n){return function(a){var h,l,c,d=t.length,u=d-1,p=e;if(0>=u)return 0/0;if(p>=u+2&&(p=u+1),0>=a)return t[0][n]();if(a>=u-p+2)return t[u][n]();for(c=Math.floor(a)+p-1,i=s(u,p),r=o(a,i,u,p,c),h=0,l=c-p+1;c>=l;l++)d>l&&l>=0&&(h+=t[l][n]()*r[l]);return h}};return[n(\"X\"),n(\"Y\"),0,function(){return t.length-1}]},D:function(e,i){var r=1e-5,s=1/(2*r);return t.exists(i)?function(t,o){return(e.apply(i,[t+r,o])-e.apply(i,[t-r,o]))*s}:function(t,i){return(e(t+r,i)-e(t-r,i))*s}},riemann:function(t,e,i,r,s){var o,n,a,h,l,c,d=[],u=[],p=0,f=r,m=0;if(e=Math.round(e),d[p]=f,u[p]=0,e>0)for(l=(s-r)/e,h=.01*l,o=0;e>o;o++){if(\"right\"===i)c=t(f+l);else if(\"middle\"===i)c=t(f+.5*l);else if(\"left\"===i||\"trapezoidal\"===i)c=t(f);else if(\"lower\"===i)for(c=t(f),n=f+h;f+l>=n;n+=h)a=t(n),c>a&&(c=a);else if(\"upper\"===i)for(c=t(f),n=f+h;f+l>=n;n+=h)a=t(n),a>c&&(c=a);else c=\"random\"===i?t(f+l*Math.random()):\"simpson\"===i?(t(f)+4*t(f+.5*l)+t(f+l))/6:t(f);p+=1,d[p]=f,u[p]=c,p+=1,f+=l,\"trapezoidal\"===i&&(c=t(f)),d[p]=f,u[p]=c,p+=1,d[p]=f,u[p]=0,m+=c*l}return[d,u,m]},riemannsum:function(t,e,i,r,s){var o,n,a,h,l,c,d=0,u=r;if(e=Math.floor(e),e>0)for(l=(s-r)/e,h=.01*l,o=0;e>o;o++){if(\"right\"===i)c=t(u+l);else if(\"middle\"===i)c=t(u+.5*l);else if(\"trapezoidal\"===i)c=.5*(t(u+l)+t(u));else if(\"left\"===i)c=t(u);else if(\"lower\"===i)for(c=t(u),n=u+h;u+l>=n;n+=h)a=t(n),c>a&&(c=a);else if(\"upper\"===i)for(c=t(u),n=u+h;u+l>=n;n+=h)a=t(n),a>c&&(c=a);else c=\"random\"===i?t(u+l*Math.random()):\"simpson\"===i?(t(u)+4*t(u+.5*l)+t(u+l))/6:t(u);d+=l*c,u+=l}return d},rungeKutta:function(e,r,s,o,n){var a,h,l,c,d,u,p=[],f=[],m=(s[1]-s[0])/o,b=s[0],g=r.length,v=[],C=0;for(t.isString(e)&&(e=i[e]||i.euler),u=e.s,a=0;g>a;a++)p[a]=r[a];for(h=0;o>h;h++){for(v[C]=[],a=0;g>a;a++)v[C][a]=p[a];for(C+=1,c=[],l=0;u>l;l++){for(a=0;g>a;a++)f[a]=0;for(d=0;l>d;d++)for(a=0;g>a;a++)f[a]+=e.A[l][d]*m*c[d][a];for(a=0;g>a;a++)f[a]+=p[a];c.push(n(b+e.c[l]*m,f))}for(a=0;g>a;a++)f[a]=0;for(d=0;u>d;d++)for(a=0;g>a;a++)f[a]+=e.b[d]*c[d][a];for(a=0;g>a;a++)p[a]=p[a]+m*f[a];b+=m}return v},maxIterationsRoot:80,maxIterationsMinimize:500,fzero:function(i,r,s){var o,n,a,h,l,c,d,u,p,f,m,b,g,v,C,y,P,_,S,E,O=e.eps,w=this.maxIterationsRoot,T=0,x=0;if(t.isArray(r)){if(r.length<2)throw new Error(\"JXG.Math.Numerics.fzero: length of array x0 has to be at least two.\");o=r[0],h=i.call(s,o),x+=1,n=r[1],l=i.call(s,n),x+=1}else{for(o=r,h=i.call(s,o),x+=1,d=0===o?1:o,u=[.9*d,1.1*d,d-1,d+1,.5*d,1.5*d,-d,2*d,-10*d,10*d],f=u.length,p=0;f>p&&(n=u[p],l=i.call(s,n),x+=1,!(0>=h*l));p++);o>n&&(m=o,o=n,n=m,b=h,h=l,l=b)}if(h*l>0)return t.isArray(r)?this.fminbr(i,[o,n],s):this.Newton(i,o,s);for(a=o,c=h;w>T;){if(g=n-o,Math.abs(c)<Math.abs(l)&&(o=n,n=a,a=o,h=l,l=c,c=h),P=2*O*Math.abs(n)+.5*O,E=.5*(a-n),Math.abs(E)<=P&&Math.abs(l)<=O)return n;Math.abs(g)>=P&&Math.abs(h)>Math.abs(l)&&(C=a-n,o===a?(v=l/h,_=C*v,S=1-v):(S=h/c,v=l/c,y=l/h,_=y*(C*S*(S-v)-(n-o)*(v-1)),S=(S-1)*(v-1)*(y-1)),_>0?S=-S:_=-_,_<.75*C*S-.5*Math.abs(P*S)&&_<Math.abs(.5*g*S)&&(E=_/S)),Math.abs(E)<P&&(E=E>0?P:-P),o=n,h=l,n+=E,l=i.call(s,n),x+=1,(l>0&&c>0||0>l&&0>c)&&(a=o,c=h),T++}return n},fminbr:function(i,r,s){var o,n,a,h,l,c,d,u,p,f,m,b,g,v,C,y,P=.5*(3-Math.sqrt(5)),_=e.eps,S=e.eps,E=this.maxIterationsMinimize,O=0,w=0;if(!t.isArray(r)||r.length<2)throw new Error(\"JXG.Math.Numerics.fminbr: length of array x0 has to be at least two.\");for(o=r[0],n=r[1],h=o+P*(n-o),d=i.call(s,h),w+=1,a=h,l=h,c=d,u=d;E>O;){if(p=n-o,f=.5*(o+n),m=S*Math.abs(a)+_/3,Math.abs(a-f)+.5*p<=2*m)return a;b=P*(f>a?n-a:o-a),Math.abs(a-l)>=m&&(C=(a-l)*(c-d),v=(a-h)*(c-u),g=(a-h)*v-(a-l)*C,v=2*(v-C),v>0?g=-g:v=-v,Math.abs(g)<Math.abs(b*v)&&g>v*(o-a+2*m)&&v*(n-a-2*m)>g&&(b=g/v)),Math.abs(b)<m&&(b=b>0?m:-m),C=a+b,y=i.call(s,C),w+=1,c>=y?(a>C?n=a:o=a,h=l,l=a,a=C,d=u,u=c,c=y):(a>C?o=C:n=C,u>=y||l===a?(h=l,l=C,d=u,u=y):(d>=y||h===a||h===l)&&(h=C,d=y)),O+=1}return a},RamerDouglasPeuker:function(t,i){var r,s,o,n=[],a=function(t,i,r){var s,o,n,a,h,l,c,d,u,p,f,m=0,b=i;if(2>r-i)return[-1,0];if(n=t[i].scrCoords,a=t[r].scrCoords,isNaN(n[1]+n[2]+a[1]+a[2]))return[0/0,r];for(o=i+1;r>o;o++)h=t[o].scrCoords,l=h[1]-n[1],c=h[2]-n[2],d=a[1]-n[1],u=a[2]-n[2],p=d*d+u*u,p>=e.eps?(f=(l*d+c*u)/p,0>f?f=0:f>1&&(f=1),l-=f*d,c-=f*u,s=l*l+c*c):(f=0,s=l*l+c*c),s>m&&(m=s,b=o);return[Math.sqrt(m),b]},h=function(t,e,i,r,s){var o=a(t,e,i);o[0]>r?(h(t,e,o[1],r,s),h(t,o[1],i,r,s)):s.push(t[i])};for(o=t.length,r=0;o>r&&isNaN(t[r].scrCoords[1]+t[r].scrCoords[2]);)r+=1;for(s=o-1;s>r&&isNaN(t[s].scrCoords[1]+t[s].scrCoords[2]);)s-=1;return r>s||r===o||(n[0]=t[r],h(t,r,s,i,n)),n}},e.Numerics}),define(\"math/geometry\",[\"jxg\",\"base/constants\",\"base/coords\",\"math/math\",\"math/numerics\",\"utils/type\",\"utils/expect\"],function(t,e,i,r,s,o,n){return r.Geometry={},t.extend(r.Geometry,{angle:function(t,e,i){var r,s,o,n,a=[],h=[],l=[];return t.coords?(a[0]=t.coords.usrCoords[1],a[1]=t.coords.usrCoords[2]):(a[0]=t[0],a[1]=t[1]),e.coords?(h[0]=e.coords.usrCoords[1],h[1]=e.coords.usrCoords[2]):(h[0]=e[0],h[1]=e[1]),i.coords?(l[0]=i.coords.usrCoords[1],l[1]=i.coords.usrCoords[2]):(l[0]=i[0],l[1]=i[1]),r=a[0]-h[0],s=a[1]-h[1],o=l[0]-h[0],n=l[1]-h[1],Math.atan2(r*n-s*o,r*o+s*n)},trueAngle:function(t,e,i){return 57.29577951308232*this.rad(t,e,i)},rad:function(t,e,i){var r,s,o,n,a,h,l;return t.coords?(r=t.coords.usrCoords[1],s=t.coords.usrCoords[2]):(r=t[0],s=t[1]),e.coords?(o=e.coords.usrCoords[1],n=e.coords.usrCoords[2]):(o=e[0],n=e[1]),i.coords?(a=i.coords.usrCoords[1],h=i.coords.usrCoords[2]):(a=i[0],h=i[1]),l=Math.atan2(h-n,a-o)-Math.atan2(s-n,r-o),0>l&&(l+=6.283185307179586),l\n},angleBisector:function(t,r,s,n){var a,h,l,c,d,u=t.coords.usrCoords,p=r.coords.usrCoords,f=s.coords.usrCoords;return o.exists(n)||(n=t.board),0===p[0]?new i(e.COORDS_BY_USER,[1,.5*(u[1]+f[1]),.5*(u[2]+f[2])],n):(c=u[1]-p[1],d=u[2]-p[2],a=Math.atan2(d,c),c=f[1]-p[1],d=f[2]-p[2],h=Math.atan2(d,c),l=.5*(a+h),a>h&&(l+=Math.PI),c=Math.cos(l)+p[1],d=Math.sin(l)+p[2],new i(e.COORDS_BY_USER,[1,c,d],n))},reflection:function(t,r,s){var n,a,h,l,c,d,u,p=r.coords.usrCoords,f=t.point1.coords.usrCoords,m=t.point2.coords.usrCoords;return o.exists(s)||(s=r.board),c=m[1]-f[1],d=m[2]-f[2],n=p[1]-f[1],a=p[2]-f[2],u=(c*a-d*n)/(c*c+d*d),h=p[1]+2*u*d,l=p[2]-2*u*c,new i(e.COORDS_BY_USER,[h,l],s)},rotation:function(t,r,s,n){var a,h,l,c,d,u,p=r.coords.usrCoords,f=t.coords.usrCoords;return o.exists(n)||(n=r.board),a=p[1]-f[1],h=p[2]-f[2],l=Math.cos(s),c=Math.sin(s),d=a*l-h*c+f[1],u=a*c+h*l+f[2],new i(e.COORDS_BY_USER,[d,u],n)},perpendicular:function(t,e,s){var n,a,h,l,c,d=t.point1.coords.usrCoords,u=t.point2.coords.usrCoords,p=e.coords.usrCoords;return o.exists(s)||(s=e.board),e===t.point1?(n=d[1]+u[2]-d[2],a=d[2]-u[1]+d[1],c=d[0]*u[0],Math.abs(c)<r.eps&&(n=u[2],a=-u[1]),l=[c,n,a],h=!0):e===t.point2?(n=u[1]+d[2]-u[2],a=u[2]-d[1]+u[1],c=d[0]*u[0],Math.abs(c)<r.eps&&(n=d[2],a=-d[1]),l=[c,n,a],h=!1):Math.abs(r.innerProduct(p,t.stdform,3))<r.eps?(n=p[1]+u[2]-p[2],a=p[2]-u[1]+p[1],c=u[0],Math.abs(c)<r.eps&&(n=u[2],a=-u[1]),h=!0,Math.abs(c)>r.eps&&Math.abs(n-p[1])<r.eps&&Math.abs(a-p[2])<r.eps&&(n=p[1]+d[2]-p[2],a=p[2]-d[1]+p[1],h=!1),l=[c,n,a]):(l=[0,t.stdform[1],t.stdform[2]],l=r.crossProduct(l,p),l=r.crossProduct(l,t.stdform),h=!0),[new i(o.COORDS_BY_USER,l,s),h]},circumcenterMidpoint:t.shortcut(r.Geometry,\"circumcenter\"),circumcenter:function(t,s,n,a){var h,l,c,d,u=t.coords.usrCoords,p=s.coords.usrCoords,f=n.coords.usrCoords;return o.exists(a)||(a=t.board),h=[p[0]-u[0],-p[2]+u[2],p[1]-u[1]],l=[.5*(u[0]+p[0]),.5*(u[1]+p[1]),.5*(u[2]+p[2])],c=r.crossProduct(h,l),h=[f[0]-p[0],-f[2]+p[2],f[1]-p[1]],l=[.5*(p[0]+f[0]),.5*(p[1]+f[1]),.5*(p[2]+f[2])],d=r.crossProduct(h,l),new i(e.COORDS_BY_USER,r.crossProduct(c,d),a)},distance:function(t,e,i){var r,s=0;for(i||(i=Math.min(t.length,e.length)),r=0;i>r;r++)s+=(t[r]-e[r])*(t[r]-e[r]);return Math.sqrt(s)},affineDistance:function(t,e,i){var s;return s=this.distance(t,e,i),s>r.eps&&(Math.abs(t[0])<r.eps||Math.abs(e[0])<r.eps)?1/0:s},sortVertices:function(t){var e,i,s=n.each(t,n.coordsArray),a=s.length;for(e=1;a>e;e++)(s[e][2]<s[0][2]||Math.abs(s[e][2]-s[0][2])<r.eps&&s[e][1]<s[0][1])&&(s=o.swap(s,e,0));return i=s.shift(),s.sort(function(t,e){var r=Math.atan2(t[2]-i[2],t[1]-i[1]),s=Math.atan2(e[2]-i[2],e[1]-i[1]);return r-s}),s.unshift(i),s.unshift(s[s.length-1]),s},signedTriangle:function(t,e,i){var r=n.coordsArray(t),s=n.coordsArray(e),o=n.coordsArray(i);return.5*((s[1]-r[1])*(o[2]-r[2])-(s[2]-r[2])*(o[1]-r[1]))},signedPolygon:function(t,e){var i,r,s=0,o=n.each(t,n.coordsArray);for(e?o.unshift(o[o.length-1]):o=this.sortVertices(o),r=o.length,i=1;r>i;i++)s+=o[i-1][1]*o[i][2]-o[i][1]*o[i-1][2];return.5*s},GrahamScan:function(t){var e,i=1,r=n.each(t,n.coordsArray),s=r.length;for(r=this.sortVertices(r),s=r.length,e=2;s>e;e++){for(;this.signedTriangle(r[i-1],r[i],r[e])<=0;)if(i>1)i-=1;else{if(e===s-1)break;e+=1}i+=1,r=o.swap(r,i,e)}return r.slice(0,i)},calcStraight:function(t,i,s,n){var a,h,l,c,d,u,p,f,m,b;if(o.exists(n)||(n=10),u=t.visProp.straightfirst,p=t.visProp.straightlast,Math.abs(i.scrCoords[0])<r.eps&&(u=!0),Math.abs(s.scrCoords[0])<r.eps&&(p=!0),(u||p)&&(f=[],f[0]=t.stdform[0]-t.stdform[1]*t.board.origin.scrCoords[1]/t.board.unitX+t.stdform[2]*t.board.origin.scrCoords[2]/t.board.unitY,f[1]=t.stdform[1]/t.board.unitX,f[2]=-t.stdform[2]/t.board.unitY,!isNaN(f[0]+f[1]+f[2]))){if(a=!1,h=!1,a=!u&&Math.abs(i.usrCoords[0])>=r.eps&&i.scrCoords[1]>=0&&i.scrCoords[1]<=t.board.canvasWidth&&i.scrCoords[2]>=0&&i.scrCoords[2]<=t.board.canvasHeight,h=!p&&Math.abs(s.usrCoords[0])>=r.eps&&s.scrCoords[1]>=0&&s.scrCoords[1]<=t.board.canvasWidth&&s.scrCoords[2]>=0&&s.scrCoords[2]<=t.board.canvasHeight,l=this.meetLineBoard(f,t.board,n),c=l[0],d=l[1],!a&&!h){if(!u&&p&&!this.isSameDirection(i,s,c)&&!this.isSameDirection(i,s,d))return;if(u&&!p&&!this.isSameDirection(s,i,c)&&!this.isSameDirection(s,i,d))return}a?h||(b=this.isSameDir(i,s,c,d)?d:c):h?m=this.isSameDir(i,s,c,d)?c:d:this.isSameDir(i,s,c,d)?(m=c,b=d):(b=c,m=d),m&&i.setCoordinates(e.COORDS_BY_USER,m.usrCoords),b&&s.setCoordinates(e.COORDS_BY_USER,b.usrCoords)}},calcLineDelimitingPoints:function(t,i,s){var o,n,a,h,l,c,d,u,p,f,m=!1,b=!1;if(c=t.visProp.straightfirst,d=t.visProp.straightlast,Math.abs(i.scrCoords[0])<r.eps&&(c=!0),Math.abs(s.scrCoords[0])<r.eps&&(d=!0),u=[],u[0]=t.stdform[0]-t.stdform[1]*t.board.origin.scrCoords[1]/t.board.unitX+t.stdform[2]*t.board.origin.scrCoords[2]/t.board.unitY,u[1]=t.stdform[1]/t.board.unitX,u[2]=-t.stdform[2]/t.board.unitY,!isNaN(u[0]+u[1]+u[2])){if(m=!c,b=!d,n=t.board.getBoundingBox(),a=t.getSlope(),a>=0?(h=this.projectPointToLine({coords:{usrCoords:[1,n[2],n[1]]}},t,t.board),l=this.projectPointToLine({coords:{usrCoords:[1,n[0],n[3]]}},t,t.board)):(h=this.projectPointToLine({coords:{usrCoords:[1,n[0],n[1]]}},t,t.board),l=this.projectPointToLine({coords:{usrCoords:[1,n[2],n[3]]}},t,t.board)),!m&&!b){if(!c&&!d){if(o=i.distance(e.COORDS_BY_USER,s),Math.abs(i.distance(e.COORDS_BY_USER,h)+h.distance(e.COORDS_BY_USER,s)-o)>r.eps)return;if(Math.abs(i.distance(e.COORDS_BY_USER,l)+l.distance(e.COORDS_BY_USER,s)-o)>r.eps)return}if(!c&&d&&!this.isSameDirection(i,s,h)&&!this.isSameDirection(i,s,l))return;if(c&&!d&&!this.isSameDirection(s,i,h)&&!this.isSameDirection(s,i,l))return}m?b||(f=this.isSameDir(i,s,h,l)?l:h):b?p=this.isSameDir(i,s,h,l)?h:l:this.isSameDir(i,s,h,l)?(p=h,f=l):(f=h,p=l),p&&i.setCoordinates(e.COORDS_BY_USER,p.usrCoords),f&&s.setCoordinates(e.COORDS_BY_USER,f.usrCoords)}},isSameDir:function(t,e,i,s){var o=e.usrCoords[1]-t.usrCoords[1],n=e.usrCoords[2]-t.usrCoords[2],a=s.usrCoords[1]-i.usrCoords[1],h=s.usrCoords[2]-i.usrCoords[2];return Math.abs(e.usrCoords[0])<r.eps&&(o=e.usrCoords[1],n=e.usrCoords[2]),Math.abs(t.usrCoords[0])<r.eps&&(o=-t.usrCoords[1],n=-t.usrCoords[2]),o*a+n*h>=0},isSameDirection:function(t,e,i){var s,o,n,a,h=!1;return s=e.usrCoords[1]-t.usrCoords[1],o=e.usrCoords[2]-t.usrCoords[2],n=i.usrCoords[1]-t.usrCoords[1],a=i.usrCoords[2]-t.usrCoords[2],Math.abs(s)<r.eps&&(s=0),Math.abs(o)<r.eps&&(o=0),Math.abs(n)<r.eps&&(n=0),Math.abs(a)<r.eps&&(a=0),s>=0&&n>=0?h=o>=0&&a>=0||0>=o&&0>=a:0>=s&&0>=n&&(h=o>=0&&a>=0||0>=o&&0>=a),h},meet:function(t,e,i,s){var o,n=r.eps;return o=Math.abs(t[3])<n&&Math.abs(e[3])<n?this.meetLineLine(t,e,i,s):Math.abs(t[3])>=n&&Math.abs(e[3])<n?this.meetLineCircle(e,t,i,s):Math.abs(t[3])<n&&Math.abs(e[3])>=n?this.meetLineCircle(t,e,i,s):this.meetCircleCircle(t,e,i,s)},meetLineBoard:function(t,s,n){var a,h,l,c,d=[];for(o.exists(n)||(n=0),d[0]=r.crossProduct(t,[n,0,1]),d[1]=r.crossProduct(t,[n,1,0]),d[2]=r.crossProduct(t,[-n-s.canvasHeight,0,1]),d[3]=r.crossProduct(t,[-n-s.canvasWidth,1,0]),l=0;4>l;l++)if(Math.abs(d[l][0])>r.eps){for(c=2;c>0;c--)d[l][c]/=d[l][0];d[l][0]=1}return Math.abs(d[1][0])<r.eps?(a=d[0],h=d[2]):Math.abs(d[0][0])<r.eps?(a=d[1],h=d[3]):d[1][2]<0?(a=d[0],h=d[3][2]>s.canvasHeight?d[2]:d[3]):d[1][2]>s.canvasHeight?(a=d[2],h=d[3][2]<0?d[0]:d[3]):(a=d[1],h=d[3][2]<0?d[0]:d[3][2]>s.canvasHeight?d[2]:d[3]),a=new i(e.COORDS_BY_SCREEN,a.slice(1),s),h=new i(e.COORDS_BY_SCREEN,h.slice(1),s),[a,h]},meetLineLine:function(t,s,o,n){var a=r.crossProduct(t,s);return Math.abs(a[0])>r.eps&&(a[1]/=a[0],a[2]/=a[0],a[0]=1),new i(e.COORDS_BY_USER,a,n)},meetLineCircle:function(t,s,o,n){var a,h,l,c,d,u,p,f,m,b;return s[4]<r.eps?Math.abs(r.innerProduct([1,s[6],s[7]],t,3))<r.eps?new i(e.COORDS_BY_USER,s.slice(6,8),n):new i(e.COORDS_BY_USER,[0/0,0/0],n):(l=s[0],h=s.slice(1,3),a=s[3],c=t[0],d=t.slice(1,3),u=a,p=h[0]*d[1]-h[1]*d[0],f=a*c*c-(h[0]*d[0]+h[1]*d[1])*c+l,m=p*p-4*u*f,m>=0?(m=Math.sqrt(m),b=[(-p+m)/(2*u),(-p-m)/(2*u)],0===o?new i(e.COORDS_BY_USER,[-b[0]*-d[1]-c*d[0],-b[0]*d[0]-c*d[1]],n):new i(e.COORDS_BY_USER,[-b[1]*-d[1]-c*d[0],-b[1]*d[0]-c*d[1]],n)):new i(e.COORDS_BY_USER,[0,0,0],n))},meetCircleCircle:function(t,s,o,n){var a;return t[4]<r.eps?Math.abs(this.distance(t.slice(6,2),s.slice(6,8))-s[4])<r.eps?new i(e.COORDS_BY_USER,t.slice(6,8),n):new i(e.COORDS_BY_USER,[0,0,0],n):s[4]<r.eps?Math.abs(this.distance(s.slice(6,2),t.slice(6,8))-t[4])<r.eps?new i(e.COORDS_BY_USER,s.slice(6,8),n):new i(e.COORDS_BY_USER,[0,0,0],n):(a=[s[3]*t[0]-t[3]*s[0],s[3]*t[1]-t[3]*s[1],s[3]*t[2]-t[3]*s[2],0,1,1/0,1/0,1/0],a=r.normalize(a),this.meetLineCircle(a,t,o,n))},meetCurveCurve:function(t,r,n,a,h,l){var c;return c=o.exists(l)&&\"newton\"===l?s.generalizedNewton(t,r,n,a):3===t.bezierDegree&&3===r.bezierDegree?this.meetBezierCurveRedBlueSegments(t,r,n):this.meetCurveRedBlueSegments(t,r,n),new i(e.COORDS_BY_USER,c,h)},meetCurveLine:function(t,i,r,s,n){var a,h,l=[0,0/0,0/0];return o.exists(s)||(s=t.board),t.elementClass===e.OBJECT_CLASS_CURVE?(a=t,h=i):(a=i,h=t),l=\"plot\"===a.visProp.curvetype?this.meetCurveLineDiscrete(a,h,r,s,!n):this.meetCurveLineContinuous(a,h,r,s)},meetCurveLineContinuous:function(t,o,n,a,h){var l,c,d,u,p,f,m,b=10*r.eps;return u=this.meetCurveLineDiscrete(t,o,n,a,h),p=u.usrCoords[1],f=u.usrCoords[2],c=function(e){var i=p-t.X(e),r=f-t.Y(e);return Math.sqrt(i*i+r*r)},d=function(e){var i=o.stdform[0]+o.stdform[1]*t.X(e)+o.stdform[2]*t.Y(e);return i*i},l=s.root(c,[t.minX(),t.maxX()]),l=s.root(d,l),m=Math.abs(d(l))>b?0/0:1,new i(e.COORDS_BY_USER,[m,t.X(l),t.Y(l)],a)},meetCurveLineContinuousOld:function(t,o,n,a){var h,l,c,d,u,p,f,m,b,g,v,C,y=10*r.eps;if(d=function(e){var i=o.stdform[0]+o.stdform[1]*t.X(e)+o.stdform[2]*t.Y(e);return i*i},this.meetCurveLineContinuous.t1memo?(b=this.meetCurveLineContinuous.t1memo,h=s.root(d,b)):(b=t.minX(),g=t.maxX(),h=s.root(d,[b,g])),this.meetCurveLineContinuous.t1memo=h,v=t.X(h),C=t.Y(h),1===n){if(this.meetCurveLineContinuous.t2memo&&(b=this.meetCurveLineContinuous.t2memo),l=s.root(d,b),!(Math.abs(l-h)>.1&&Math.abs(v-t.X(l))>.1&&Math.abs(C-t.Y(l))>.1))for(f=20,m=(t.maxX()-t.minX())/f,p=t.minX(),c=0;f>c&&(l=s.root(d,[p,p+m]),!(Math.abs(d(l))<=y&&Math.abs(l-h)>.1&&Math.abs(v-t.X(l))>.1&&Math.abs(C-t.Y(l))>.1));c++)p+=m;h=l,this.meetCurveLineContinuous.t2memo=h}return u=Math.abs(d(h))>y?0/0:1,new i(e.COORDS_BY_USER,[u,t.X(h),t.Y(h)],a)},meetCurveLineDiscrete:function(t,s,o,n,a){var h,l,c,d,u,p,f,m,b=0,g=t.numberPoints;for(p=new i(e.COORDS_BY_USER,[0,0/0,0/0],n),d=t.points[0].usrCoords,h=1;g>h;h++)if(c=d.slice(0),d=t.points[h].usrCoords,f=this.distance(c,d),f>r.eps)for(3===t.bezierDegree?(m=this.meetBeziersegmentBeziersegment([t.points[h-1].usrCoords.slice(1),t.points[h].usrCoords.slice(1),t.points[h+1].usrCoords.slice(1),t.points[h+2].usrCoords.slice(1)],[s.point1.coords.usrCoords.slice(1),s.point2.coords.usrCoords.slice(1)],a),h+=2):m=[this.meetSegmentSegment(c,d,s.point1.coords.usrCoords,s.point2.coords.usrCoords)],l=0;l<m.length;l++)if(u=m[l],0<=u[1]&&u[1]<=1){if(b===o)return a&&(!s.visProp.straightfirst&&u[2]<0||!s.visProp.straightlast&&u[2]>1)?p:p=new i(e.COORDS_BY_USER,u[0],n);b+=1}return p},meetCurveRedBlueSegments:function(t,e,i){var r,s,o,n,a,h,l,c,d,u=0,p=e.points.length,f=t.points.length;if(1>=p||1>=f)return[0,0/0,0/0];for(r=1;f>r;r++)for(o=t.points[r-1].usrCoords,n=t.points[r].usrCoords,c=Math.min(o[1],n[1]),d=Math.max(o[1],n[1]),h=e.points[0].usrCoords,s=1;p>s;s++)if(a=h,h=e.points[s].usrCoords,Math.min(a[1],h[1])<d&&Math.max(a[1],h[1])>c&&(l=this.meetSegmentSegment(o,n,a,h),l[1]>=0&&l[2]>=0&&(l[1]<1&&l[2]<1||r===f-1&&1===l[1]||s===p-1&&1===l[2]))){if(u===i)return l[0];u++}return[0,0/0,0/0]},meetSegmentSegment:function(t,e,i,s){var o,n,a,h=r.crossProduct(t,e),l=r.crossProduct(i,s),c=r.crossProduct(h,l),d=c[0];return Math.abs(d)<r.eps?[c,1/0,1/0]:(a=[i[1]-t[1],i[2]-t[2]],o=(a[0]*(s[2]-i[2])-a[1]*(s[1]-i[1]))/d,n=(a[0]*(e[2]-t[2])-a[1]*(e[1]-t[1]))/d,[c,o,n])},_bezierSplit:function(t){var e,i,r,s,o,n;return e=[.5*(t[0][0]+t[1][0]),.5*(t[0][1]+t[1][1])],i=[.5*(t[1][0]+t[2][0]),.5*(t[1][1]+t[2][1])],r=[.5*(t[2][0]+t[3][0]),.5*(t[2][1]+t[3][1])],s=[.5*(e[0]+i[0]),.5*(e[1]+i[1])],o=[.5*(i[0]+r[0]),.5*(i[1]+r[1])],n=[.5*(s[0]+o[0]),.5*(s[1]+o[1])],[[t[0],e,s,n],[n,o,r,t[3]]]},_bezierBbox:function(t){var e=[];return 4===t.length?(e[0]=Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),e[1]=Math.max(t[0][1],t[1][1],t[2][1],t[3][1]),e[2]=Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),e[3]=Math.min(t[0][1],t[1][1],t[2][1],t[3][1])):(e[0]=Math.min(t[0][0],t[1][0]),e[1]=Math.max(t[0][1],t[1][1]),e[2]=Math.max(t[0][0],t[1][0]),e[3]=Math.min(t[0][1],t[1][1])),e},_bezierOverlap:function(t,e){return t[2]>=e[0]&&t[0]<=e[2]&&t[1]>=e[3]&&t[3]<=e[1]},_bezierListConcat:function(t,e,i,r){var s,n=o.exists(r),a=0,h=e.length,l=t.length;for(l>0&&(1===t[l-1][1]&&0===e[0][1]||n&&1===t[l-1][2]&&0===e[0][2])&&(a=1),s=a;h>s;s++)n&&(e[s][2]*=.5,e[s][2]+=r),e[s][1]*=.5,e[s][1]+=i,t.push(e[s])},_bezierMeetSubdivision:function(t,e,i){var r,s,o,n,a,h,l,c,d,u,p,f,m=[],b=5;return s=this._bezierBbox(e),r=this._bezierBbox(t),this._bezierOverlap(s,r)?b>i?(o=this._bezierSplit(t),h=o[0],l=o[1],o=this._bezierSplit(e),n=o[0],a=o[1],this._bezierListConcat(m,this._bezierMeetSubdivision(h,n,i+1),0,0),this._bezierListConcat(m,this._bezierMeetSubdivision(h,a,i+1),0,.5),this._bezierListConcat(m,this._bezierMeetSubdivision(l,n,i+1),.5,0),this._bezierListConcat(m,this._bezierMeetSubdivision(l,a,i+1),.5,.5),m):(p=[1].concat(t[0]),f=[1].concat(t[3]),d=[1].concat(e[0]),u=[1].concat(e[3]),c=this.meetSegmentSegment(p,f,d,u),c[1]>=0&&c[2]>=0&&c[1]<=1&&c[2]<=1?[c]:[]):[]},_bezierLineMeetSubdivision:function(t,e,i,r){var s,o,n,a,h,l,c,d,u,p,f=[],m=5;return s=this._bezierBbox(e),o=this._bezierBbox(t),r&&!this._bezierOverlap(o,s)?[]:m>i?(n=this._bezierSplit(t),a=n[0],h=n[1],this._bezierListConcat(f,this._bezierLineMeetSubdivision(a,e,i+1),0),this._bezierListConcat(f,this._bezierLineMeetSubdivision(h,e,i+1),.5),f):(u=[1].concat(t[0]),p=[1].concat(t[3]),c=[1].concat(e[0]),d=[1].concat(e[1]),l=this.meetSegmentSegment(u,p,c,d),l[1]>=0&&l[1]<=1&&(!r||l[2]>=0&&l[2]<=1)?[l]:[])},meetBeziersegmentBeziersegment:function(t,e,i){var r,s,o;for(r=4===t.length&&4===e.length?this._bezierMeetSubdivision(t,e,0):this._bezierLineMeetSubdivision(t,e,0,i),r.sort(function(t,e){return 1e7*(t[1]-e[1])+(t[2]-e[2])}),s=[],o=0;o<r.length;o++)(0===o||r[o][1]!==r[o-1][1]||r[o][2]!==r[o-1][2])&&s.push(r[o]);return s},meetBezierCurveRedBlueSegments:function(t,e,i){var r,s,o,n,a,h,l,c=e.points.length,d=t.points.length,u=[];if(4>c||4>d)return[0,0/0,0/0];for(s=0;d-3>s;s+=3)for(r=t.points,n=[[r[s].usrCoords[1],r[s].usrCoords[2]],[r[s+1].usrCoords[1],r[s+1].usrCoords[2]],[r[s+2].usrCoords[1],r[s+2].usrCoords[2]],[r[s+3].usrCoords[1],r[s+3].usrCoords[2]]],h=this._bezierBbox(n),o=0;c-3>o;o+=3)if(r=e.points,a=[[r[o].usrCoords[1],r[o].usrCoords[2]],[r[o+1].usrCoords[1],r[o+1].usrCoords[2]],[r[o+2].usrCoords[1],r[o+2].usrCoords[2]],[r[o+3].usrCoords[1],r[o+3].usrCoords[2]]],l=this._bezierBbox(a),this._bezierOverlap(h,l)&&(u=u.concat(this.meetBeziersegmentBeziersegment(n,a)),u.length>i))return u[i][0];return u.length>i?u[i][0]:[0,0/0,0/0]},bezierSegmentEval:function(t,e){var i,r,s,o=1-t;return r=0,s=0,i=o*o*o,r+=i*e[0][0],s+=i*e[0][1],i=3*t*o*o,r+=i*e[1][0],s+=i*e[1][1],i=3*t*t*o,r+=i*e[2][0],s+=i*e[2][1],i=t*t*t,r+=i*e[3][0],s+=i*e[3][1],[1,r,s]},bezierArc:function(t,e,i,s,o){var n,a,h,l,c,d,u,p,f,m,b,g,v,C,y,P,_,S=.5*Math.PI,E=e[1],O=e[2],w=e[0],T=[],x=[];for(c=this.distance(e,t),E/=w,O/=w,d=this.rad(t.slice(1),e.slice(1),i.slice(1)),-1===o&&(d=2*Math.PI-d),n=t,n[1]/=n[0],n[2]/=n[0],n[0]/=n[0],l=n.slice(0),s?(T=[E,E+.333*(n[1]-E),E+.666*(n[1]-E),n[1]],x=[O,O+.333*(n[2]-O),O+.666*(n[2]-O),n[2]]):(T=[n[1]],x=[n[2]]);d>r.eps;)d>S?(u=S,d-=S):(u=d,d=0),p=Math.cos(o*u),f=Math.sin(o*u),_=[[1,0,0],[E*(1-p)+O*f,p,-f],[O*(1-p)-E*f,f,p]],y=r.matVecMult(_,n),l=[y[0]/y[0],y[1]/y[0],y[2]/y[0]],m=n[1]-E,b=n[2]-O,g=l[1]-E,v=l[2]-O,P=Math.sqrt((m+g)*(m+g)+(b+v)*(b+v)),C=Math.abs(v-b)>r.eps?8*((m+g)*(c/P-.5)/(v-b))/3:8*((b+v)*(c/P-.5)/(m-g))/3,a=[1,n[1]-C*b,n[2]+C*m],h=[1,l[1]+C*v,l[2]-C*g],T=T.concat([a[1],h[1],l[1]]),x=x.concat([a[2],h[2],l[2]]),n=l.slice(0);return s&&(T=T.concat([l[1]+.333*(E-l[1]),l[1]+.666*(E-l[1]),E]),x=x.concat([l[2]+.333*(O-l[2]),l[2]+.666*(O-l[2]),O])),[T,x]},projectPointToCircle:function(t,s,n){var a,h,l,c,d,u=s.center.coords.usrCoords;return o.exists(n)||(n=t.board),o.isPoint(t)?(a=t.coords.distance(e.COORDS_BY_USER,s.center.coords),h=t.coords.usrCoords):(a=t.distance(e.COORDS_BY_USER,s.center.coords),h=t.usrCoords),Math.abs(a)<r.eps&&(a=r.eps),d=s.Radius()/a,l=u[1]+d*(h[1]-u[1]),c=u[2]+d*(h[2]-u[2]),new i(e.COORDS_BY_USER,[l,c],n)},projectPointToLine:function(t,e,i){var s=[0,e.stdform[1],e.stdform[2]];return o.exists(i)||(i=t.board),s=r.crossProduct(s,t.coords.usrCoords),this.meetLineLine(s,e.stdform,0,i)},projectCoordsToSegment:function(t,e,i){var s,o,n=[i[1]-e[1],i[2]-e[2]],a=[t[1]-e[1],t[2]-e[2]];return Math.abs(n[0])<r.eps&&Math.abs(n[1])<r.eps?[e,0]:(s=r.innerProduct(a,n),o=r.innerProduct(n,n),s/=o,[[1,s*n[0]+e[1],s*n[1]+e[2]],s])},projectCoordsToBeziersegment:function(e,i,r){var s,o=function(t){var s=[1,i.X(r+t),i.Y(r+t)];return s[1]-=e[1],s[2]-=e[2],s[1]*s[1]+s[2]*s[2]};return s=t.Math.Numerics.fminbr(o,[0,1]),[[1,i.X(s+r),i.Y(s+r)],s]},projectPointToCurve:function(t,e,i){o.exists(i)||(i=t.board);var r=t.X(),s=t.Y(),n=t.position||0,a=this.projectCoordsToCurve(r,s,n,e,i);return t.position=a[1],a[0]},projectCoordsToCurve:function(t,r,n,a,h){var l,c,d,u,p,f,m,b,g,v,C,y,P,_,S,E,O,w,T,x=Number.POSITIVE_INFINITY;if(o.exists(h)||(h=a.board),\"plot\"===a.visProp.curvetype){if(n=0,p=x,l=0===a.numberPoints?[0,1,1]:[a.Z(0),a.X(0),a.Y(0)],a.numberPoints>1)for(b=[1,t,r],3===a.bezierDegree?u=0:C=[a.Z(0),a.X(0),a.Y(0)],d=0;d<a.numberPoints-1;d++)3===a.bezierDegree?P=this.projectCoordsToBeziersegment(b,a,u):(y=[a.Z(d+1),a.X(d+1),a.Y(d+1)],P=this.projectCoordsToSegment(b,C,y)),m=P[1],g=P[0],m>=0&&1>=m?(f=this.distance(g,b),v=d+m):0>m?(g=C,f=this.distance(C,b),v=d):m>1&&d===a.numberPoints-2&&(g=y,f=this.distance(g,b),v=a.numberPoints-1),p>f&&(p=f,n=v,l=g),3===a.bezierDegree?(u++,d+=2):C=y;c=new i(e.COORDS_BY_USER,l,h)}else{for(_=function(e){var i=t-a.X(e),s=r-a.Y(e);return i*i+s*s},O=_(n),T=50,w=(a.maxX()-a.minX())/T,S=a.minX(),d=0;T>d;d++)E=_(S),O>E&&(n=S,O=E),S+=w;n=s.fminbr(_,[n-w,n+w]),n<a.minX()&&(n=a.maxX()+n-a.minX()),n>a.maxX()&&(n=a.minX()+n-a.maxX()),c=new i(e.COORDS_BY_USER,[a.X(n),a.Y(n)],h)}return[a.updateTransform(c),n]},projectPointToTurtle:function(t,r,s){var n,a,h,l,c,d,u,p,f=0,m=0,b=Number.POSITIVE_INFINITY,g=r.objects.length;for(o.exists(s)||(s=t.board),c=0;g>c;c++)u=r.objects[c],u.elementClass===e.OBJECT_CLASS_CURVE&&(n=this.projectPointToCurve(t,u),d=this.distance(n.usrCoords,t.coords.usrCoords),b>d&&(h=n.usrCoords[1],l=n.usrCoords[2],a=t.position,b=d,p=u,m=f),f+=u.numberPoints);return n=new i(e.COORDS_BY_USER,[h,l],s),t.position=a+m,p.updateTransform(n)},projectPointToPoint:function(t,e){return e.coords},projectPointToBoard:function(t,e){var i,s,o,n=e||t.board,a=[[1,1,0,0,3,0,1],[-1,2,1,0,1,2,1],[-1,1,2,2,1,2,3],[1,2,3,0,3,2,3]],h=t.coords||t,l=n.getBoundingBox();for(i=0;4>i;i++)o=a[i],o[0]*h.usrCoords[o[1]]<o[0]*l[o[2]]&&(s=r.crossProduct([1,l[o[3]],l[o[4]]],[1,l[o[5]],l[o[6]]]),s[3]=0,s=r.normalize(s),h=this.projectPointToLine({coords:h,board:n},{stdform:s}));return h},distPointLine:function(t,e){var i,s=e[1],o=e[2],n=e[0];return Math.abs(s)+Math.abs(o)<r.eps?Number.POSITIVE_INFINITY:(i=s*t[1]+o*t[2]+n,s*=s,o*=o,Math.abs(i)/Math.sqrt(s+o))},reuleauxPolygon:function(t,e){var i,s=2*Math.PI,o=s/e,n=(e-1)/2,a=0,h=function(h,l){return function(c,d){var u=(c%s+s)%s,p=Math.floor(u/o)%e;return d||(a=t[0].Dist(t[n]),i=r.Geometry.rad([t[0].X()+1,t[0].Y()],t[0],t[n%e])),isNaN(p)?p:(u=.5*u+.5*p*o+i,t[p][h]()+a*Math[l](u))}};return[h(\"X\",\"cos\"),h(\"Y\",\"sin\"),0,s]}}),r.Geometry}),define(\"parser/geonext\",[\"jxg\",\"base/constants\",\"utils/type\"],function(t,e,i){return t.GeonextParser={replacePow:function(t){var e,i,r,s,o,n,a,h,l,c,d;for(t=t.replace(/(\\s*)\\^(\\s*)/g,\"^\"),l=t.indexOf(\"^\");l>=0;){if(h=t.slice(0,l),c=t.slice(l+1),\")\"===h.charAt(h.length-1)){for(e=1,i=h.length-2;i>=0&&e>0;)r=h.charAt(i),\")\"===r?e++:\"(\"===r&&(e-=1),i-=1;if(0!==e)throw new Error(\"JSXGraph: Missing '(' in expression\");for(s=\"\",n=h.substring(0,i+1),a=i;a>=0&&n.substr(a,1).match(/([\\w\\.]+)/);)s=RegExp.$1+s,a-=1;s+=h.substring(i+1,h.length),s=s.replace(/([\\(\\)\\+\\*\\%\\^\\-\\/\\]\\[])/g,\"\\\\$1\")}else s=\"[\\\\w\\\\.]+\";if(c.match(/^([\\w\\.]*\\()/)){for(e=1,i=RegExp.$1.length;i<c.length&&e>0;)r=c.charAt(i),\")\"===r?e-=1:\"(\"===r&&(e+=1),i+=1;if(0!==e)throw new Error(\"JSXGraph: Missing ')' in expression\");o=c.substring(0,i),o=o.replace(/([\\(\\)\\+\\*\\%\\^\\-\\/\\[\\]])/g,\"\\\\$1\")}else o=\"[\\\\w\\\\.]+\";d=new RegExp(\"(\"+s+\")\\\\^(\"+o+\")\"),t=t.replace(d,\"pow($1,$2)\"),l=t.indexOf(\"^\")}return t},replaceIf:function(t){var e,i,r,s,o,n,a,h,l,c=\"\",d=null,u=null,p=null;if(r=t.indexOf(\"If(\"),0>r)return t;for(t=t.replace(/\"\"/g,\"0\");r>=0;){for(e=t.slice(0,r),i=t.slice(r+3),o=1,s=0,n=-1,a=-1;s<i.length&&o>0;)h=i.charAt(s),\")\"===h?o-=1:\"(\"===h?o+=1:\",\"===h&&1===o&&(0>n?n=s:a=s),s+=1;if(l=i.slice(0,s-1),i=i.slice(s),0>n)return\"\";if(0>a)return\"\";d=l.slice(0,n),u=l.slice(n+1,a),p=l.slice(a+1),d=this.replaceIf(d),u=this.replaceIf(u),p=this.replaceIf(p),c+=e+\"((\"+d+\")?\"+\"(\"+u+\"):(\"+p+\"))\",t=i,d=null,u=null,r=t.indexOf(\"If(\")}return c+=i},replaceNameById:function(t,e,i){var r,s,o,n,a=0,h=[\"X\",\"Y\",\"L\",\"V\"],l=function(t){return i?\"$('\"+t+\"')\":t};for(n=0;n<h.length;n++)for(a=t.indexOf(h[n]+\"(\");a>=0;)a>=0&&(r=t.indexOf(\")\",a+2),r>=0&&(s=t.slice(a+2,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+2)+(i?\"$('\":\"\")+l(o.id)+t.slice(r)))),r=t.indexOf(\")\",a+2),a=t.indexOf(h[n]+\"(\",r);for(a=t.indexOf(\"Dist(\");a>=0;)a>=0&&(r=t.indexOf(\",\",a+5),r>=0&&(s=t.slice(a+5,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+5)+l(o.id)+t.slice(r)))),r=t.indexOf(\",\",a+5),a=t.indexOf(\",\",r),r=t.indexOf(\")\",a+1),r>=0&&(s=t.slice(a+1,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+l(o.id)+t.slice(r))),r=t.indexOf(\")\",a+1),a=t.indexOf(\"Dist(\",r);for(h=[\"Deg\",\"Rad\"],n=0;n<h.length;n++)for(a=t.indexOf(h[n]+\"(\");a>=0;)a>=0&&(r=t.indexOf(\",\",a+4),r>=0&&(s=t.slice(a+4,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+4)+l(o.id)+t.slice(r)))),r=t.indexOf(\",\",a+4),a=t.indexOf(\",\",r),r=t.indexOf(\",\",a+1),r>=0&&(s=t.slice(a+1,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+l(o.id)+t.slice(r))),r=t.indexOf(\",\",a+1),a=t.indexOf(\",\",r),r=t.indexOf(\")\",a+1),r>=0&&(s=t.slice(a+1,r),s=s.replace(/\\\\(['\"])?/g,\"$1\"),o=e.elementsByName[s],o&&(t=t.slice(0,a+1)+l(o.id)+t.slice(r))),r=t.indexOf(\")\",a+1),a=t.indexOf(h[n]+\"(\",r);return t},replaceIdByObj:function(t){var e=/(X|Y|L)\\(([\\w_]+)\\)/g;return t=t.replace(e,\"$('$2').$1()\"),e=/(V)\\(([\\w_]+)\\)/g,t=t.replace(e,\"$('$2').Value()\"),e=/(Dist)\\(([\\w_]+),([\\w_]+)\\)/g,t=t.replace(e,\"dist($('$2'), $('$3'))\"),e=/(Deg)\\(([\\w_]+),([ \\w\\[\\w_]+),([\\w_]+)\\)/g,t=t.replace(e,\"deg($('$2'),$('$3'),$('$4'))\"),e=/Rad\\(([\\w_]+),([\\w_]+),([\\w_]+)\\)/g,t=t.replace(e,\"rad($('$1'),$('$2'),$('$3'))\"),e=/N\\((.+)\\)/g,t=t.replace(e,\"($1)\")},geonext2JS:function(t,e){var i,r,s,o=[\"Abs\",\"ACos\",\"ASin\",\"ATan\",\"Ceil\",\"Cos\",\"Exp\",\"Factorial\",\"Floor\",\"Log\",\"Max\",\"Min\",\"Random\",\"Round\",\"Sin\",\"Sqrt\",\"Tan\",\"Trunc\"],n=[\"abs\",\"acos\",\"asin\",\"atan\",\"ceil\",\"cos\",\"exp\",\"factorial\",\"floor\",\"log\",\"max\",\"min\",\"random\",\"round\",\"sin\",\"sqrt\",\"tan\",\"ceil\"];for(t=t.replace(/</g,\"<\"),t=t.replace(/>/g,\">\"),t=t.replace(/&/g,\"&\"),r=t,r=this.replaceNameById(r,e),r=this.replaceIf(r),r=this.replacePow(r),r=this.replaceIdByObj(r),s=0;s<o.length;s++)i=new RegExp([\"(\\\\W|^)(\",o[s],\")\"].join(\"\"),\"ig\"),r=r.replace(i,[\"$1\",n[s]].join(\"\"));return r=r.replace(/True/g,\"true\"),r=r.replace(/False/g,\"false\"),r=r.replace(/fasle/g,\"false\"),r=r.replace(/Pi/g,\"PI\"),r=r.replace(/\"/g,\"'\")},findDependencies:function(t,r,s){var o,n,a,h;i.exists(s)||(s=t.board),o=s.elementsByName;for(n in o)o.hasOwnProperty(n)&&n!==t.name&&(o[n].type===e.OBJECT_TYPE_TEXT?o[n].visProp.islabel||(h=n.replace(/\\[/g,\"\\\\[\"),h=h.replace(/\\]/g,\"\\\\]\"),a=new RegExp(\"\\\\(([\\\\w\\\\[\\\\]'_ ]+,)*(\"+h+\")(,[\\\\w\\\\[\\\\]'_ ]+)*\\\\)\",\"g\"),r.search(a)>=0&&o[n].addChild(t)):(h=n.replace(/\\[/g,\"\\\\[\"),h=h.replace(/\\]/g,\"\\\\]\"),a=new RegExp(\"\\\\(([\\\\w\\\\[\\\\]'_ ]+,)*(\"+h+\")(,[\\\\w\\\\[\\\\]'_ ]+)*\\\\)\",\"g\"),r.search(a)>=0&&o[n].addChild(t)))},gxt2jc:function(t,e){var i;return t=t.replace(/</g,\"<\"),t=t.replace(/>/g,\">\"),t=t.replace(/&/g,\"&\"),i=t,i=this.replaceNameById(i,e,!0),i=i.replace(/True/g,\"true\"),i=i.replace(/False/g,\"false\"),i=i.replace(/fasle/g,\"false\")}},t.GeonextParser}),define(\"base/element\",[\"jxg\",\"base/constants\",\"base/coords\",\"math/math\",\"options\",\"parser/geonext\",\"utils/event\",\"utils/color\",\"utils/type\"],function(t,e,i,r,s,o,n,a,h){return t.GeometryElement=function(t,i,r,s){var o,a,l;if(this.needsUpdate=!0,this.isDraggable=!1,this.isReal=!0,this.childElements={},this.hasLabel=!1,this.highlighted=!1,this.notExistingParents={},this.traces={},this.numTraces=0,this.transformations=[],this.baseElement=null,this.descendants={},this.ancestors={},this.symbolic={},this.rendNode=null,this.elType=\"\",this.dump=!0,this.subs={},this._pos=-1,this.stdform=[1,0,0,0,1,1,0,0],this.methodMap={setLabel:\"setLabelText\",label:\"label\",setName:\"setName\",getName:\"getName\",addTransform:\"addTransform\",setProperty:\"setAttribute\",setAttribute:\"setAttribute\",animate:\"animate\",on:\"on\",off:\"off\",trigger:\"trigger\"},this.quadraticform=[[1,0,0],[0,1,0],[0,0,1]],this.visProp={},n.eventify(this),this.mouseover=!1,this.lastDragTime=new Date,arguments.length>0){this.board=t,this.type=r,this.elementClass=s||e.OBJECT_CLASS_OTHER,this.id=i.id,o=i.name,h.exists(o)||(o=this.board.generateName(this)),\"\"!==o&&(this.board.elementsByName[o]=this),this.name=o,this.needsRegularUpdate=i.needsregularupdate,h.clearVisPropOld(this),l=this.resolveShortcuts(i);for(a in l)l.hasOwnProperty(a)&&this._set(a,l[a]);this.visProp.draft=l.draft&&l.draft.draft,this.visProp.gradientangle=\"270\",this.visProp.gradientsecondopacity=this.visProp.fillopacity,this.visProp.gradientpositionx=.5,this.visProp.gradientpositiony=.5}},t.extend(t.GeometryElement.prototype,{addChild:function(t){var e,i;this.childElements[t.id]=t,this.addDescendants(t),t.ancestors[this.id]=this;for(e in this.descendants)if(this.descendants.hasOwnProperty(e)){this.descendants[e].ancestors[this.id]=this;for(i in this.ancestors)this.ancestors.hasOwnProperty(i)&&(this.descendants[e].ancestors[this.ancestors[i].id]=this.ancestors[i])}for(e in this.ancestors)if(this.ancestors.hasOwnProperty(e))for(i in this.descendants)this.descendants.hasOwnProperty(i)&&(this.ancestors[e].descendants[this.descendants[i].id]=this.descendants[i]);return this},addDescendants:function(t){var e;this.descendants[t.id]=t;for(e in t.childElements)t.childElements.hasOwnProperty(e)&&this.addDescendants(t.childElements[e]);return this},removeChild:function(t){return delete this.childElements[t.id],this.removeDescendants(t),delete t.ancestors[this.id],this},removeDescendants:function(t){var e;delete this.descendants[t.id];for(e in t.childElements)t.childElements.hasOwnProperty(e)&&this.removeDescendants(t.childElements[e]);return this},countChildren:function(){var t,e,i=0;e=this.childElements;for(t in e)e.hasOwnProperty(t)&&t.indexOf(\"Label\")<0&&i++;return i},getName:function(){return this.name},addTransform:function(){return this},draggable:function(){return this.isDraggable&&!this.visProp.fixed&&!this.visProp.frozen&&this.type!==e.OBJECT_TYPE_GLIDER},generatePolynomial:function(){return[]},animate:function(t,i,r){r=r||{};var s,o,n,h=this.board.attr.animationdelay,l=Math.ceil(i/h),c=this,d=function(t,e,i){var r,s,o,h,d;for(r=a.rgb2hsv(t),s=a.rgb2hsv(e),o=(s[0]-r[0])/l,h=(s[1]-r[1])/l,d=(s[2]-r[2])/l,c.animationData[i]=[],n=0;l>n;n++)c.animationData[i][l-n-1]=a.hsv2rgb(r[0]+(n+1)*o,r[1]+(n+1)*h,r[2]+(n+1)*d)},u=function(t,e,i,r){var s,o;if(t=parseFloat(t),e=parseFloat(e),!isNaN(t)&&!isNaN(e))for(o=(e-t)/l,c.animationData[i]=[],n=0;l>n;n++)s=t+(n+1)*o,c.animationData[i][l-n-1]=r?Math.floor(s):s};this.animationData={};for(s in t)if(t.hasOwnProperty(s))switch(o=s.toLowerCase()){case\"strokecolor\":case\"fillcolor\":d(this.visProp[o],t[s],o);break;case\"size\":if(this.elementClass!==e.OBJECT_CLASS_POINT)break;u(this.visProp[o],t[s],o,!0);break;case\"strokeopacity\":case\"strokewidth\":case\"fillopacity\":u(this.visProp[o],t[s],o,!1)}return this.animationCallback=r.callback,this.board.addAnimation(this),this},update:function(){return this.visProp.trace&&this.cloneToBackground(),this},updateRenderer:function(){return this},hideElement:function(){return this.visProp.visible=!1,this.board.renderer.hide(this),h.exists(this.label)&&this.hasLabel&&(this.label.hiddenByParent=!0,this.label.visProp.visible&&this.label.hideElement()),this},showElement:function(){return this.visProp.visible=!0,this.board.renderer.show(this),h.exists(this.label)&&this.hasLabel&&this.label.hiddenByParent&&(this.label.hiddenByParent=!1,this.label.visProp.visible||this.label.showElement().updateRenderer()),this},_set:function(t,e){t=t.toLocaleLowerCase(),this.visProp.hasOwnProperty(t)&&t.indexOf(\"color\")>=0&&h.isString(e)&&9===e.length&&\"#\"===e.charAt(0)?(e=a.rgba2rgbo(e),this.visProp[t]=e[0],this.visProp[t.replace(\"color\",\"opacity\")]=e[1]):this.visProp[t]=e},resolveShortcuts:function(t){var e,i;for(e in s.shortcuts)if(s.shortcuts.hasOwnProperty(e)&&h.exists(t[e]))for(i=0;i<s.shortcuts[e].length;i++)h.exists(t[s.shortcuts[e][i]])||(t[s.shortcuts[e][i]]=t[e]);return t},setLabelText:function(t){return h.exists(this.label)&&(t=t.replace(/</g,\"<\").replace(/>/g,\">\"),this.label.setText(t)),this},setName:function(t){t=t.replace(/</g,\"<\").replace(/>/g,\">\"),this.setLabelText(t),this.setAttribute({name:t})},setProperty:t.shortcut(t.GeometryElement.prototype,\"setAttribute\"),setAttribute:function(){var i,r,s,o,n,l,c,d={},u=function(t){return function(){return t}};for(i=0;i<arguments.length;i++)o=arguments[i],h.isString(o)?(l=o.split(\":\"),d[h.trim(l[0])]=h.trim(l[1])):h.isArray(o)?d[o[0]]=o[1]:t.extend(d,o);d=this.resolveShortcuts(d);for(i in d)if(d.hasOwnProperty(i)){switch(r=i.replace(/\\s+/g,\"\").toLowerCase(),s=d[i],c=this.visProp[r],r){case\"name\":c=this.name,delete this.board.elementsByName[this.name],this.name=s,this.board.elementsByName[this.name]=this;break;case\"needsregularupdate\":this.needsRegularUpdate=!(\"false\"===s||s===!1),this.board.renderer.setBuffering(this,this.needsRegularUpdate?\"auto\":\"static\");break;case\"labelcolor\":s=a.rgba2rgbo(s),n=s[1],s=s[0],0===n&&h.exists(this.label)&&this.hasLabel&&this.label.hideElement(),h.exists(this.label)&&this.hasLabel&&(this.label.visProp.strokecolor=s,this.board.renderer.setObjectStrokeColor(this.label,s,n)),this.type===e.OBJECT_TYPE_TEXT&&(this.visProp.strokecolor=s,this.visProp.strokeopacity=n,this.board.renderer.setObjectStrokeColor(this,this.visProp.strokecolor,this.visProp.strokeopacity));break;case\"infoboxtext\":this.infoboxText=\"string\"==typeof s?s:!1;break;case\"visible\":\"false\"===s||s===!1?(this.visProp.visible=!1,this.hideElement()):(\"true\"===s||s===!0)&&(this.visProp.visible=!0,this.showElement());break;case\"face\":this.elementClass===e.OBJECT_CLASS_POINT&&(this.visProp.face=s,this.board.renderer.changePointStyle(this));break;case\"trace\":\"false\"===s||s===!1?(this.clearTrace(),this.visProp.trace=!1):this.visProp.trace=!0;break;case\"gradient\":this.visProp.gradient=s,this.board.renderer.setGradient(this);break;case\"gradientsecondcolor\":s=a.rgba2rgbo(s),this.visProp.gradientsecondcolor=s[0],this.visProp.gradientsecondopacity=s[1],this.board.renderer.updateGradient(this);break;case\"gradientsecondopacity\":this.visProp.gradientsecondopacity=s,this.board.renderer.updateGradient(this);break;case\"withlabel\":this.visProp.withlabel=s,s?this.label?this.visProp.visible&&this.label.showElement():(this.createLabel(),this.visProp.visible||this.label.hideElement()):this.label&&this.hasLabel&&this.label.hideElement(),this.hasLabel=s;\nbreak;case\"radius\":(this.type===e.OBJECT_TYPE_ANGLE||this.type===e.OBJECT_TYPE_SECTOR)&&this.setRadius(s);break;case\"rotate\":(this.type===e.OBJECT_TYPE_TEXT&&\"internal\"===this.visProp.display||this.type===e.OBJECT_TYPE_IMAGE)&&this.addRotation(s);break;case\"ticksdistance\":this.type===e.OBJECT_TYPE_TICKS&&\"number\"==typeof s&&(this.ticksFunction=u(s));break;case\"generatelabelvalue\":this.type===e.OBJECT_TYPE_TICKS&&\"function\"==typeof s&&(this.generateLabelValue=s);break;case\"onpolygon\":this.type===e.OBJECT_TYPE_GLIDER&&(this.onPolygon=!!s);break;default:h.exists(this.visProp[r])&&(!t.Validator[r]||t.Validator[r]&&t.Validator[r](s)||t.Validator[r]&&h.isFunction(s)&&t.Validator[r](s()))&&(s=s.toLowerCase&&\"false\"===s.toLowerCase()?!1:s,this._set(r,s))}this.triggerEventHandlers([\"attribute:\"+r],[c,s,this])}return this.triggerEventHandlers([\"attribute\"],[d,this]),this.visProp.needsregularupdate?this.board.update(this):this.board.fullUpdate(),this},getProperty:t.shortcut(t.GeometryElement.prototype,\"getAttribute\"),getAttribute:function(t){var e;switch(t=t.toLowerCase()){case\"needsregularupdate\":e=this.needsRegularUpdate;break;case\"labelcolor\":e=this.label.visProp.strokecolor;break;case\"infoboxtext\":e=this.infoboxText;break;case\"withlabel\":e=this.hasLabel;break;default:e=this.visProp[t]}return e},setDash:function(t){return this.setAttribute({dash:t}),this},prepareUpdate:function(){return this.needsUpdate=!0,this},remove:function(){return this.board.renderer.remove(this.board.renderer.getElementById(this.id)),this.hasLabel&&this.board.renderer.remove(this.board.renderer.getElementById(this.label.id)),this},getTextAnchor:function(){return new i(e.COORDS_BY_USER,[0,0],this.board)},getLabelAnchor:function(){return new i(e.COORDS_BY_USER,[0,0],this.board)},setArrow:function(t,e){return this.visProp.firstarrow=t,this.visProp.lastarrow=e,this.prepareUpdate().update(),this},createGradient:function(){(\"linear\"===this.visProp.gradient||\"radial\"===this.visProp.gradient)&&this.board.renderer.setGradient(this)},createLabel:function(){var e,i=this;return t.elements.text?(e=h.deepCopy(this.visProp.label,null),e.id=this.id+\"Label\",e.isLabel=!0,e.visible=this.visProp.visible,e.anchor=this,e.priv=this.visProp.priv,this.visProp.withlabel&&(this.label=t.elements.text(this.board,[0,0,function(){return\"function\"==typeof i.name?i.name():i.name}],e),this.label.needsUpdate=!0,this.label.update(),this.label.dump=!1,this.visProp.visible||(this.label.hiddenByParent=!0,this.label.visProp.visible=!1),this.hasLabel=!0)):t.debug(\"JSXGraph: Can't create label: text element is not available. Make sure you include base/text\"),this},highlight:function(t){return t=h.def(t,!1),!this.visProp.highlight||this.highlighted&&!t||(this.highlighted=!0,this.board.highlightedObjects[this.id]=this,this.board.renderer.highlight(this)),this},noHighlight:function(){return this.highlighted&&(this.highlighted=!1,delete this.board.highlightedObjects[this.id],this.board.renderer.noHighlight(this)),this},clearTrace:function(){var t;for(t in this.traces)this.traces.hasOwnProperty(t)&&this.board.renderer.remove(this.traces[t]);return this.numTraces=0,this},cloneToBackground:function(){return this},bounds:function(){return[0,0,0,0]},normalize:function(){return this.stdform=r.normalize(this.stdform),this},toJSON:function(){var t,e,i=['{\"name\":',this.name];i.push(', \"id\":'+this.id),t=[];for(e in this.visProp)this.visProp.hasOwnProperty(e)&&h.exists(this.visProp[e])&&t.push('\"'+e+'\":'+this.visProp[e]);return i.push(', \"visProp\":{'+t.toString()+\"}\"),i.push(\"}\"),i.join(\"\")},addRotation:function(t){var i,r,s,o,n,a=this;return(this.type===e.OBJECT_TYPE_TEXT&&\"internal\"===this.visProp.display||this.type===e.OBJECT_TYPE_IMAGE)&&0!==t&&(i=this.board.create(\"transform\",[function(){return-a.X()},function(){return-a.Y()}],{type:\"translate\"}),r=this.board.create(\"transform\",[function(){return a.X()},function(){return a.Y()}],{type:\"translate\"}),s=this.board.create(\"transform\",[function(){return a.board.unitX/a.board.unitY},function(){return 1}],{type:\"scale\"}),o=this.board.create(\"transform\",[function(){return a.board.unitY/a.board.unitX},function(){return 1}],{type:\"scale\"}),n=this.board.create(\"transform\",[t*Math.PI/180],{type:\"rotate\"}),i.bindTo(this),s.bindTo(this),n.bindTo(this),o.bindTo(this),r.bindTo(this)),this},highlightStrokeColor:function(t){return this.setAttribute({highlightStrokeColor:t}),this},strokeColor:function(t){return this.setAttribute({strokeColor:t}),this},strokeWidth:function(t){return this.setAttribute({strokeWidth:t}),this},fillColor:function(t){return this.setAttribute({fillColor:t}),this},highlightFillColor:function(t){return this.setAttribute({highlightFillColor:t}),this},labelColor:function(t){return this.setAttribute({labelColor:t}),this},dash:function(t){return this.setAttribute({dash:t}),this},visible:function(t){return this.setAttribute({visible:t}),this},shadow:function(t){return this.setAttribute({shadow:t}),this},getType:function(){return this.elType},getParents:function(){return h.isArray(this.parents)?this.parents:[]},snapToGrid:function(){return this},snapToPoints:function(){return this},getAttributes:function(){var t,e=h.deepCopy(this.visProp),i=[\"attractors\",\"snatchdistance\",\"traceattributes\",\"frozen\",\"shadow\",\"gradientangle\",\"gradientsecondopacity\",\"gradientpositionx\",\"gradientpositiony\",\"needsregularupdate\",\"zoom\",\"layer\",\"offset\"];for(e.id=this.id,e.name=this.name,t=0;t<i.length;t++)delete e[i[t]];return e},hasPoint:function(){return!1},handleSnapToGrid:function(i){var r,s,o,n=this.visProp.snapsizex,a=this.visProp.snapsizey;return t.exists(this.coords)?((this.visProp.snaptogrid||i===!0)&&(r=this.coords.usrCoords[1],s=this.coords.usrCoords[2],0>=n&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks&&(o=this.board.defaultAxes.x.defaultTicks,n=o.ticksDelta*(o.visProp.minorticks+1)),0>=a&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks&&(o=this.board.defaultAxes.y.defaultTicks,a=o.ticksDelta*(o.visProp.minorticks+1)),n>0&&a>0&&this.coords.setCoordinates(e.COORDS_BY_USER,[Math.round(r/n)*n,Math.round(s/a)*a])),this):this},addEvent:t.shortcut(t.GeometryElement.prototype,\"on\"),removeEvent:t.shortcut(t.GeometryElement.prototype,\"off\"),__evt__over:function(){},__evt__mouseover:function(){},__evt__out:function(){},__evt__mouseout:function(){},__evt__move:function(){},__evt__mousemove:function(){},__evt__drag:function(){},__evt__mousedrag:function(){},__evt__touchdrag:function(){},__evt__down:function(){},__evt__mousedown:function(){},__evt__touchdown:function(){},__evt__up:function(){},__evt__mouseup:function(){},__evt__touchup:function(){},__evt__attribute:function(){},__evt__attribute_:function(){},__evt:function(){}}),t.GeometryElement}),define(\"base/transformation\",[\"jxg\",\"base/constants\",\"math/math\",\"utils/type\"],function(t,e,i,r){return t.Transformation=function(t,i,r){this.elementClass=e.OBJECT_CLASS_OTHER,this.matrix=[[1,0,0],[0,1,0],[0,0,1]],this.board=t,this.isNumericMatrix=!1,this.setMatrix(t,i,r),this.methodMap={apply:\"apply\",applyOnce:\"applyOnce\",bindTo:\"bindTo\",bind:\"bind\",melt:\"melt\"}},t.Transformation.prototype={},t.extend(t.Transformation.prototype,{update:function(){return this},setMatrix:function(t,e,s){var o;for(this.isNumericMatrix=!0,o=0;o<s.length;o++)if(\"number\"!=typeof s[o]){this.isNumericMatrix=!1;break}if(\"translate\"===e){if(2!==s.length)throw new Error(\"JSXGraph: translate transformation needs 2 parameters.\");this.evalParam=r.createEvalFunction(t,s,2),this.update=function(){this.matrix[1][0]=this.evalParam(0),this.matrix[2][0]=this.evalParam(1)}}else if(\"scale\"===e){if(2!==s.length)throw new Error(\"JSXGraph: scale transformation needs 2 parameters.\");this.evalParam=r.createEvalFunction(t,s,2),this.update=function(){this.matrix[1][1]=this.evalParam(0),this.matrix[2][2]=this.evalParam(1)}}else if(\"reflect\"===e)s.length<4&&(s[0]=t.select(s[0])),2===s.length&&(s[1]=t.select(s[1])),4===s.length&&(this.evalParam=r.createEvalFunction(t,s,4)),this.update=function(){var t,e,r,o,n,a,h,l;1===s.length?h=s[0].stdform:2===s.length?h=i.crossProduct(s[1].coords.usrCoords,s[0].coords.usrCoords):4===s.length&&(h=i.crossProduct([1,this.evalParam(2),this.evalParam(3)],[1,this.evalParam(0),this.evalParam(1)])),t=h[1],e=h[2],r=h[0],l=[-r*t,-r*e,t*t+e*e],a=l[2],o=l[0]/l[2],n=l[1]/l[2],t=-h[2],e=h[1],this.matrix[1][1]=(t*t-e*e)/a,this.matrix[1][2]=2*t*e/a,this.matrix[2][1]=this.matrix[1][2],this.matrix[2][2]=-this.matrix[1][1],this.matrix[1][0]=o*(1-this.matrix[1][1])-n*this.matrix[1][2],this.matrix[2][0]=n*(1-this.matrix[2][2])-o*this.matrix[2][1]};else if(\"rotate\"===e)3===s.length?this.evalParam=r.createEvalFunction(t,s,3):s.length>0&&s.length<=2&&(this.evalParam=r.createEvalFunction(t,s,1),2===s.length&&(s[1]=t.select(s[1]))),this.update=function(){var t,e,i=this.evalParam(0),r=Math.cos(i),o=Math.sin(i);this.matrix[1][1]=r,this.matrix[1][2]=-o,this.matrix[2][1]=o,this.matrix[2][2]=r,s.length>1&&(3===s.length?(t=this.evalParam(1),e=this.evalParam(2)):(t=s[1].X(),e=s[1].Y()),this.matrix[1][0]=t*(1-r)+e*o,this.matrix[2][0]=e*(1-r)-t*o)};else if(\"shear\"===e){if(2!==s.length)throw new Error(\"JSXGraph: shear transformation needs 2 parameters.\");this.evalParam=r.createEvalFunction(t,s,2),this.update=function(){this.matrix[1][2]=this.evalParam(0),this.matrix[2][1]=this.evalParam(1)}}else if(\"generic\"===e){if(9!==s.length)throw new Error(\"JSXGraph: generic transformation needs 9 parameters.\");this.evalParam=r.createEvalFunction(t,s,9),this.update=function(){this.matrix[0][0]=this.evalParam(0),this.matrix[0][1]=this.evalParam(1),this.matrix[0][2]=this.evalParam(2),this.matrix[1][0]=this.evalParam(3),this.matrix[1][1]=this.evalParam(4),this.matrix[1][2]=this.evalParam(5),this.matrix[2][0]=this.evalParam(6),this.matrix[2][1]=this.evalParam(7),this.matrix[2][2]=this.evalParam(8)}}},apply:function(t,e){return this.update(),r.exists(e)?i.matVecMult(this.matrix,t.initialCoords.usrCoords):i.matVecMult(this.matrix,t.coords.usrCoords)},applyOnce:function(t){var s,o,n;for(r.isArray(t)||(t=[t]),o=t.length,n=0;o>n;n++)this.update(),s=i.matVecMult(this.matrix,t[n].coords.usrCoords),t[n].coords.setCoordinates(e.COORDS_BY_USER,s)},bindTo:function(t){var e,i;if(r.isArray(t))for(i=t.length,e=0;i>e;e++)t[e].transformations.push(this);else t.transformations.push(this)},setProperty:function(){},setAttribute:function(){},melt:function(t){var e,i,r,s,o,n,a=[];for(i=t.matrix.length,r=this.matrix[0].length,e=0;i>e;e++)a[e]=[];for(this.update(),t.update(),e=0;i>e;e++)for(n=0;r>n;n++){for(o=0,s=0;i>s;s++)o+=t.matrix[e][s]*this.matrix[s][n];a[e][n]=o}return this.update=function(){var t=this.matrix.length,i=this.matrix[0].length;for(e=0;t>e;e++)for(n=0;i>n;n++)this.matrix[e][n]=a[e][n]},this}}),t.createTransform=function(e,i,r){return new t.Transformation(e,r.type,i)},t.registerElement(\"transform\",t.createTransform),{Transformation:t.Transformation,createTransform:t.createTransform}}),define(\"base/point\",[\"jxg\",\"options\",\"math/math\",\"math/geometry\",\"math/numerics\",\"base/coords\",\"base/constants\",\"base/element\",\"parser/geonext\",\"utils/type\",\"base/transformation\"],function(t,e,i,r,s,o,n,a,h,l){return t.Point=function(t,e,i){this.constructor(t,i,n.OBJECT_TYPE_POINT,n.OBJECT_CLASS_POINT),l.exists(e)||(e=[0,0]),this.coords=new o(n.COORDS_BY_USER,e,this.board),this.initialCoords=new o(n.COORDS_BY_USER,e,this.board),this.position=null,this.onPolygon=!1,this.slideObject=null,this.slideObjects=[],this.needsUpdateFromParent=!0,this.Xjc=null,this.Yjc=null,this.methodMap=l.deepCopy(this.methodMap,{move:\"moveTo\",moveTo:\"moveTo\",moveAlong:\"moveAlong\",visit:\"visit\",glide:\"makeGlider\",makeGlider:\"makeGlider\",X:\"X\",Y:\"Y\",free:\"free\",setPosition:\"setGliderPosition\",setGliderPosition:\"setGliderPosition\",addConstraint:\"addConstraint\",dist:\"Dist\",onPolygon:\"onPolygon\"}),this.group=[],this.elType=\"point\",this.id=this.board.setId(this,\"P\"),this.board.renderer.drawPoint(this),this.board.finalizeAdding(this),this.createLabel()},t.Point.prototype=new a,t.extend(t.Point.prototype,{hasPoint:function(t,e){var i,r=this.coords.scrCoords;return i=parseFloat(this.visProp.size)+.5*parseFloat(this.visProp.strokewidth),i<this.board.options.precision.hasPoint&&(i=this.board.options.precision.hasPoint),Math.abs(r[1]-t)<i+2&&Math.abs(r[2]-e)<i+2},updateConstraint:function(){return this},update:function(t){return this.needsUpdate?(l.exists(t)||(t=!1),this.type===n.OBJECT_TYPE_GLIDER&&(t?this.updateGliderFromParent():this.updateGlider()),(this.type===n.OBJECT_TYPE_CAS||this.type===n.OBJECT_TYPE_INTERSECTION||this.type===n.OBJECT_TYPE_AXISPOINT)&&this.updateConstraint(),this.updateTransform(),this.visProp.trace&&this.cloneToBackground(!0),this):this},updateGlider:function(){var t,e,s,a,h,l,c,d,u,p,f,m,b,g,v,C,y,P=!1,_=this.slideObject;if(this.needsUpdateFromParent=!1,_.elementClass===n.OBJECT_CLASS_CIRCLE)C=r.projectPointToCircle(this,_,this.board),y=r.rad([_.center.X()+1,_.center.Y()],_.center,this);else if(_.elementClass===n.OBJECT_CLASS_LINE){if(this.onPolygon){if(e=_.point1.coords.usrCoords,s=_.point2.coords.usrCoords,t=1,a=s[t]-e[t],Math.abs(a)<i.eps&&(t=2,a=s[t]-e[t]),c=r.projectPointToLine(this,_,this.board),d=(c.usrCoords[t]-e[t])/a,l=_.parentPolygon,0>d){for(t=0;t<l.borders.length;t++)if(_===l.borders[t]){_=l.borders[(t-1+l.borders.length)%l.borders.length];break}}else if(d>1)for(t=0;t<l.borders.length;t++)if(_===l.borders[t]){_=l.borders[(t+1+l.borders.length)%l.borders.length];break}_.id!==this.slideObject.id&&(this.slideObject=_)}e=_.point1.coords,s=_.point2.coords,a=e.distance(n.COORDS_BY_USER,s),a<i.eps?(C=e,P=!0,y=0):(C=r.projectPointToLine(this,_,this.board),e=e.usrCoords.slice(0),s=s.usrCoords.slice(0),Math.abs(s[0])<i.eps?(t=1,a=s[t],Math.abs(a)<i.eps&&(t=2,a=s[t]),a=(C.usrCoords[t]-e[t])/a,u=a>=0?1:-1,a=Math.abs(a),y=u*a/(a+1)):Math.abs(e[0])<i.eps?(t=1,a=e[t],Math.abs(a)<i.eps&&(t=2,a=e[t]),a=(C.usrCoords[t]-s[t])/a,y=0>a?(1-2*a)/(1-a):1/(a+1)):(t=1,a=s[t]-e[t],Math.abs(a)<i.eps&&(t=2,a=s[t]-e[t]),y=(C.usrCoords[t]-e[t])/a)),this.visProp.snapwidth>0&&Math.abs(this._smax-this._smin)>=i.eps&&(y=Math.max(Math.min(y,1),0),h=y*(this._smax-this._smin)+this._smin,h=Math.round(h/this.visProp.snapwidth)*this.visProp.snapwidth,y=(h-this._smin)/(this._smax-this._smin),this.update(!0)),e=_.point1.coords,!_.visProp.straightfirst&&Math.abs(e.usrCoords[0])>i.eps&&0>y&&(C=e,P=!0,y=0),s=_.point2.coords,!_.visProp.straightlast&&Math.abs(s.usrCoords[0])>i.eps&&y>1&&(C=s,P=!0,y=1)}else _.type===n.OBJECT_TYPE_TURTLE?(this.updateConstraint(),C=r.projectPointToTurtle(this,_,this.board),y=this.position):_.elementClass===n.OBJECT_CLASS_CURVE?_.type===n.OBJECT_TYPE_ARC||_.type===n.OBJECT_TYPE_SECTOR?(C=r.projectPointToCircle(this,_,this.board),m=r.rad(_.radiuspoint,_.center,this),p=0,f=r.rad(_.radiuspoint,_.center,_.anglepoint),y=m,(\"minor\"===_.visProp.type&&f>Math.PI||\"major\"===_.visProp.type&&f<Math.PI)&&(p=f,f=2*Math.PI),(p>m||m>f)&&(y=f,(p>m&&m>.5*p||m>f&&m>.5*f+Math.PI)&&(y=p),this.needsUpdateFromParent=!0,this.updateGliderFromParent())):(this.updateConstraint(),_.transformations.length>0?(_.updateTransformMatrix(),v=i.inverse(_.transformMat),g=i.matVecMult(v,this.coords.usrCoords),b=new o(n.COORDS_BY_USER,g,this.board).usrCoords,g=r.projectCoordsToCurve(b[1],b[2],this.position||0,_,this.board),C=g[0],y=g[1]):(C=r.projectPointToCurve(this,_,this.board),y=this.position)):_.elementClass===n.OBJECT_CLASS_POINT&&(C=r.projectPointToPoint(this,_,this.board),y=this.position);this.coords.setCoordinates(n.COORDS_BY_USER,C.usrCoords,P),this.position=y},updateGliderFromParent:function(){var t,e,s,o,a,h,l,c,d=this.slideObject;return this.needsUpdateFromParent?(d.elementClass===n.OBJECT_CLASS_CIRCLE?(s=d.Radius(),a=[d.center.X()+s*Math.cos(this.position),d.center.Y()+s*Math.sin(this.position)]):d.elementClass===n.OBJECT_CLASS_LINE?(t=d.point1.coords.usrCoords,e=d.point2.coords.usrCoords,Math.abs(e[0])<i.eps?(o=Math.min(Math.abs(this.position),1-i.eps),o/=1-o,this.position<0&&(o=-o),a=[t[0]+o*e[0],t[1]+o*e[1],t[2]+o*e[2]]):Math.abs(t[0])<i.eps?(o=Math.max(this.position,i.eps),o=Math.min(o,2-i.eps),o=o>1?(o-1)/(o-2):(1-o)/o,a=[e[0]+o*t[0],e[1]+o*t[1],e[2]+o*t[2]]):(o=this.position,a=[t[0]+o*(e[0]-t[0]),t[1]+o*(e[1]-t[1]),t[2]+o*(e[2]-t[2])])):d.type===n.OBJECT_TYPE_TURTLE?(this.coords.setCoordinates(n.COORDS_BY_USER,[d.Z(this.position),d.X(this.position),d.Y(this.position)]),this.updateConstraint(),a=r.projectPointToTurtle(this,d,this.board).usrCoords):d.elementClass===n.OBJECT_CLASS_CURVE?(this.coords.setCoordinates(n.COORDS_BY_USER,[d.Z(this.position),d.X(this.position),d.Y(this.position)]),d.type===n.OBJECT_TYPE_ARC||d.type===n.OBJECT_TYPE_SECTOR?(h=r.rad([d.center.X()+1,d.center.Y()],d.center,d.radiuspoint),l=0,c=r.rad(d.radiuspoint,d.center,d.anglepoint),(\"minor\"===d.visProp.type&&c>Math.PI||\"major\"===d.visProp.type&&c<Math.PI)&&(l=c,c=2*Math.PI),(this.position<l||this.position>c)&&(this.position=c,(this.position<l&&this.position>.5*l||this.position>c&&this.position>.5*c+Math.PI)&&(this.position=l)),s=d.Radius(),a=[d.center.X()+s*Math.cos(this.position+h),d.center.Y()+s*Math.sin(this.position+h)]):(this.updateConstraint(),a=r.projectPointToCurve(this,d,this.board).usrCoords)):d.elementClass===n.OBJECT_CLASS_POINT&&(a=r.projectPointToPoint(this,d,this.board).usrCoords),this.coords.setCoordinates(n.COORDS_BY_USER,a,!1),void 0):(this.needsUpdateFromParent=!0,void 0)},updateRenderer:function(){var t;return this.needsUpdate?(this.visProp.visible&&this.visProp.size>0&&(t=this.isReal,this.isReal=!isNaN(this.coords.usrCoords[1]+this.coords.usrCoords[2]),this.isReal=Math.abs(this.coords.usrCoords[0])>i.eps?this.isReal:!1,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.show(this.label)),this.board.renderer.updatePoint(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.hide(this.label))),this.hasLabel&&this.visProp.visible&&this.label&&this.label.visProp.visible&&this.isReal&&(this.label.update(),this.board.renderer.updateText(this.label)),this.needsUpdate=!1,this):this},X:function(){return this.coords.usrCoords[1]},Y:function(){return this.coords.usrCoords[2]},Z:function(){return this.coords.usrCoords[0]},XEval:function(){return this.coords.usrCoords[1]},YEval:function(){return this.coords.usrCoords[2]},ZEval:function(){return this.coords.usrCoords[0]},bounds:function(){return this.coords.usrCoords.slice(1).concat(this.coords.usrCoords.slice(1))},Dist:function(t){var e,i,r=0/0,s=t.coords.usrCoords,o=this.coords.usrCoords;return this.isReal&&t.isReal&&(i=o[0]-s[0],e=i*i,i=o[1]-s[1],e+=i*i,i=o[2]-s[2],e+=i*i,r=Math.sqrt(e)),r},snapToGrid:function(t){return this.handleSnapToGrid(t)},handleSnapToPoints:function(t){var e,i,s,o=0,a=1/0,h=null;if(this.visProp.snaptopoints||t){for(e=0;e<this.board.objectsList.length;e++)i=this.board.objectsList[e],i.elementClass===n.OBJECT_CLASS_POINT&&i!==this&&i.visProp.visible&&(s=r.projectPointToPoint(this,i,this.board),o=\"screen\"===this.visProp.attractorunit?s.distance(n.COORDS_BY_SCREEN,this.coords):s.distance(n.COORDS_BY_USER,this.coords),o<this.visProp.attractordistance&&a>o&&(a=o,h=s));null!==h&&this.coords.setCoordinates(n.COORDS_BY_USER,h.usrCoords)}return this},snapToPoints:function(t){return this.handleSnapToPoints(t)},handleAttractors:function(){var t,e,i,s=0,o=this.visProp.attractors.length;if(0!==this.visProp.attractordistance){for(t=0;o>t;t++)if(e=this.board.select(this.visProp.attractors[t]),l.exists(e)&&e!==this){if(e.elementClass===n.OBJECT_CLASS_POINT?i=r.projectPointToPoint(this,e,this.board):e.elementClass===n.OBJECT_CLASS_LINE?i=r.projectPointToLine(this,e,this.board):e.elementClass===n.OBJECT_CLASS_CIRCLE?i=r.projectPointToCircle(this,e,this.board):e.elementClass===n.OBJECT_CLASS_CURVE?i=r.projectPointToCurve(this,e,this.board):e.type===n.OBJECT_TYPE_TURTLE&&(i=r.projectPointToTurtle(this,e,this.board)),s=\"screen\"===this.visProp.attractorunit?i.distance(n.COORDS_BY_SCREEN,this.coords):i.distance(n.COORDS_BY_USER,this.coords),s<this.visProp.attractordistance){(this.type!==n.OBJECT_TYPE_GLIDER||this.slideObject!==e)&&this.makeGlider(e);break}e===this.slideObject&&s>=this.visProp.snatchdistance&&this.popSlideObject()}return this}},setPositionDirectly:function(t,e){var r,s;if(this.coords,this.coords.setCoordinates(t,e),this.handleSnapToGrid(),this.handleSnapToPoints(),this.handleAttractors(),0===this.group.length){for(r=this.transformations.length-1;r>=0;r--)t===n.COORDS_BY_SCREEN?s=new o(t,e,this.board).usrCoords:(2===e.length&&(e=[1].concat(e)),s=e),this.initialCoords.setCoordinates(n.COORDS_BY_USER,i.matVecMult(i.inverse(this.transformations[r].matrix),s));this.update()}return this.board.isSuspendedUpdate&&this.type===n.OBJECT_TYPE_GLIDER&&this.updateGlider(),e},setPositionByTransform:function(t,e){var i;return e=new o(t,e,this.board),i=this.board.create(\"transform\",e.usrCoords.slice(1),{type:\"translate\"}),this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix?this.transformations[this.transformations.length-1].melt(i):this.addTransform(this,i),this.update(),this},setPosition:function(t,e){return this.setPositionDirectly(t,e)},setGliderPosition:function(t){return this.type===n.OBJECT_TYPE_GLIDER&&(this.position=t,this.board.update()),this},makeGlider:function(t){var e=this.board.select(t);if(!l.exists(e))throw new Error(\"JSXGraph: slide object undefined.\");if(e.type===n.OBJECT_TYPE_TICKS)throw new Error(\"JSXGraph: gliders on ticks are not possible.\");return this.slideObject=this.board.select(t),this.slideObjects.push(this.slideObject),this.type=n.OBJECT_TYPE_GLIDER,this.elType=\"glider\",this.visProp.snapwidth=-1,this.slideObject.addChild(this),this.isDraggable=!0,this.generatePolynomial=function(){return this.slideObject.generatePolynomial(this)},this.updateGlider(),this.needsUpdateFromParent=!0,this.updateGliderFromParent(),this},popSlideObject:function(){this.slideObjects.length>0&&(this.slideObjects.pop(),this.slideObject.removeChild(this),0===this.slideObjects.length?(this.elType=\"point\",this.type=n.OBJECT_TYPE_POINT,this.slideObject=null):this.slideObject=this.slideObjects[this.slideObjects.length-1])},free:function(){var t,e;if(this.type!==n.OBJECT_TYPE_GLIDER){if(this.transformations.length=0,this.isDraggable)return;this.isDraggable=!0,this.type=n.OBJECT_TYPE_POINT,this.XEval=function(){return this.coords.usrCoords[1]},this.YEval=function(){return this.coords.usrCoords[2]},this.ZEval=function(){return this.coords.usrCoords[0]},this.Xjc=null,this.Yjc=null}for(t in this.board.objects)this.board.objects.hasOwnProperty(t)&&(e=this.board.objects[t],e.descendants&&(delete e.descendants[this.id],delete e.childElements[this.id],this.hasLabel&&(delete e.descendants[this.label.id],delete e.childElements[this.label.id])));this.ancestors={},this.slideObject=null,this.slideObjects=[],this.elType=\"point\",this.type=n.OBJECT_TYPE_POINT},addConstraint:function(t){var e,i,r=[],s=[\"X\",\"Y\"],o=function(t){return function(){return t}},a=function(t){return function(){return t.Value()}};for(this.type=n.OBJECT_TYPE_CAS,this.isDraggable=!1,e=0;e<t.length;e++)i=t[e],\"string\"==typeof i?(r[e]=this.board.jc.snippet(i,!0,null,!0),2===t.length&&(this[s[e]+\"jc\"]=t[e])):\"function\"==typeof i?r[e]=i:\"number\"==typeof i?r[e]=o(i):\"object\"==typeof i&&\"function\"==typeof i.Value&&(r[e]=a(i)),r[e].origin=i;return 1===t.length?this.updateConstraint=function(){var t=r[0]();l.isArray(t)?this.coords.setCoordinates(n.COORDS_BY_USER,t):this.coords=t}:2===t.length?(this.XEval=r[0],this.YEval=r[1],this.parents=[r[0].origin,r[1].origin],this.updateConstraint=function(){this.coords.setCoordinates(n.COORDS_BY_USER,[this.XEval(),this.YEval()])}):(this.ZEval=r[0],this.XEval=r[1],this.YEval=r[2],this.parents=[r[0].origin,r[1].origin,r[2].origin],this.updateConstraint=function(){this.coords.setCoordinates(n.COORDS_BY_USER,[this.ZEval(),this.XEval(),this.YEval()])}),this.update(),this.board.isSuspendedUpdate||this.updateRenderer(),this},updateTransform:function(){var t,e;if(0===this.transformations.length||null===this.baseElement)return this;for(t=this===this.baseElement?this.transformations[0].apply(this.baseElement,\"self\"):this.transformations[0].apply(this.baseElement),this.coords.setCoordinates(n.COORDS_BY_USER,t),e=1;e<this.transformations.length;e++)this.coords.setCoordinates(n.COORDS_BY_USER,this.transformations[e].apply(this));return this},addTransform:function(t,e){var i,r=l.isArray(e)?e:[e],s=r.length;for(0===this.transformations.length&&(this.baseElement=t),i=0;s>i;i++)this.transformations.push(r[i]);return this},startAnimation:function(t,e){var i=this;return this.type!==n.OBJECT_TYPE_GLIDER||l.exists(this.intervalCode)||(this.intervalCode=window.setInterval(function(){i._anim(t,e)},250),l.exists(this.intervalCount)||(this.intervalCount=0)),this},stopAnimation:function(){return l.exists(this.intervalCode)&&(window.clearInterval(this.intervalCode),delete this.intervalCode),this},moveAlong:function(t,e,i){i=i||{};var r,o,a=[],h=[],c=this.board.attr.animationdelay,d=e/c,u=function(e,i){return function(){return t[e][i]}};if(l.isArray(t)){for(r=0;r<t.length;r++)h[r]=l.isPoint(t[r])?t[r]:{elementClass:n.OBJECT_CLASS_POINT,X:u(r,0),Y:u(r,1)};if(e=e||0,0===e)return this.setPosition(n.COORDS_BY_USER,[h[h.length-1].X(),h[h.length-1].Y()]),this.board.update(this);if(!l.exists(i.interpolate)||i.interpolate)for(o=s.Neville(h),r=0;d>r;r++)a[r]=[],a[r][0]=o[0]((d-r)/d*o[3]()),a[r][1]=o[1]((d-r)/d*o[3]());else for(r=0;d>r;r++)a[r]=[],a[r][0]=t[Math.floor((d-r)/d*(t.length-1))][0],a[r][1]=t[Math.floor((d-r)/d*(t.length-1))][1];this.animationPath=a}else l.isFunction(t)&&(this.animationPath=t,this.animationStart=(new Date).getTime());return this.animationCallback=i.callback,this.board.addAnimation(this),this},moveTo:function(t,e,r){r=r||{},t=new o(n.COORDS_BY_USER,t,this.board);var s,a=this.board.attr.animationdelay,h=Math.ceil(e/a),c=[],d=this.coords.usrCoords[1],u=this.coords.usrCoords[2],p=t.usrCoords[1]-d,f=t.usrCoords[2]-u,m=function(t){return r.effect&&\"<>\"===r.effect?Math.pow(Math.sin(t/h*Math.PI/2),2):t/h};if(!l.exists(e)||0===e||Math.abs(t.usrCoords[0]-this.coords.usrCoords[0])>i.eps)return this.setPosition(n.COORDS_BY_USER,t.usrCoords),this.board.update(this);if(Math.abs(p)<i.eps&&Math.abs(f)<i.eps)return this;for(s=h;s>=0;s--)c[h-s]=[t.usrCoords[0],d+p*m(s),u+f*m(s)];return this.animationPath=c,this.animationCallback=r.callback,this.board.addAnimation(this),this},visit:function(t,e,i){t=new o(n.COORDS_BY_USER,t,this.board);var r,s,a,h=this.board.attr.animationdelay,c=[],d=this.coords.usrCoords[1],u=this.coords.usrCoords[2],p=t.usrCoords[1]-d,f=t.usrCoords[2]-u,m=function(t){var e=a/2>t?2*t/a:2*(a-t)/a;return i.effect&&\"<>\"===i.effect?Math.pow(Math.sin(e*Math.PI/2),2):e};for(\"number\"==typeof i?i={repeat:i}:(i=i||{},l.exists(i.repeat)||(i.repeat=1)),a=Math.ceil(e/(h*i.repeat)),s=0;s<i.repeat;s++)for(r=a;r>=0;r--)c[s*(a+1)+a-r]=[t.usrCoords[0],d+p*m(r),u+f*m(r)];return this.animationPath=c,this.animationCallback=i.callback,this.board.addAnimation(this),this},_anim:function(t,e){var i,s,o,a,h,l,c,d,u=1;return this.intervalCount+=1,this.intervalCount>e&&(this.intervalCount=0),this.slideObject.elementClass===n.OBJECT_CLASS_LINE?(i=this.slideObject.point1.coords.distance(n.COORDS_BY_SCREEN,this.slideObject.point2.coords),s=this.slideObject.getSlope(),1/0!==s?(h=Math.atan(s),o=Math.round(this.intervalCount/e*i*Math.cos(h)),a=Math.round(this.intervalCount/e*i*Math.sin(h))):(o=0,a=Math.round(this.intervalCount/e*i)),0>t?(l=this.slideObject.point2,this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]>0?u=-1:0===this.slideObject.point2.coords.scrCoords[1]-this.slideObject.point1.coords.scrCoords[1]&&this.slideObject.point2.coords.scrCoords[2]-this.slideObject.point1.coords.scrCoords[2]>0&&(u=-1)):(l=this.slideObject.point1,this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]>0?u=-1:0===this.slideObject.point1.coords.scrCoords[1]-this.slideObject.point2.coords.scrCoords[1]&&this.slideObject.point1.coords.scrCoords[2]-this.slideObject.point2.coords.scrCoords[2]>0&&(u=-1)),this.coords.setCoordinates(n.COORDS_BY_SCREEN,[l.coords.scrCoords[1]+u*o,l.coords.scrCoords[2]+u*a])):this.slideObject.elementClass===n.OBJECT_CLASS_CURVE?(c=t>0?Math.round(this.intervalCount/e*this.board.canvasWidth):Math.round((e-this.intervalCount)/e*this.board.canvasWidth),this.coords.setCoordinates(n.COORDS_BY_SCREEN,[c,0]),this.coords=r.projectPointToCurve(this,this.slideObject,this.board)):this.slideObject.elementClass===n.OBJECT_CLASS_CIRCLE&&(h=0>t?2*(this.intervalCount/e)*Math.PI:2*((e-this.intervalCount)/e)*Math.PI,d=this.slideObject.Radius(),this.coords.setCoordinates(n.COORDS_BY_USER,[this.slideObject.center.coords.usrCoords[1]+d*Math.cos(h),this.slideObject.center.coords.usrCoords[2]+d*Math.sin(h)])),this.board.update(this),this},setStyle:function(t){var e=[\"cross\",\"cross\",\"cross\",\"circle\",\"circle\",\"circle\",\"circle\",\"square\",\"square\",\"square\",\"plus\",\"plus\",\"plus\"],i=[2,3,4,1,2,3,4,2,3,4,2,3,4];return this.visProp.face=e[t],this.visProp.size=i[t],this.board.renderer.changePointStyle(this),this},normalizeFace:function(t){return e.normalizePointFace(t)},remove:function(){this.hasLabel&&this.board.renderer.remove(this.board.renderer.getElementById(this.label.id)),this.board.renderer.remove(this.board.renderer.getElementById(this.id))},getTextAnchor:function(){return this.coords},getLabelAnchor:function(){return this.coords},face:function(t){this.setAttribute({face:t})},size:function(t){this.setAttribute({size:t})},cloneToBackground:function(){var t={};return t.id=this.id+\"T\"+this.numTraces,this.numTraces+=1,t.coords=this.coords,t.visProp=l.deepCopy(this.visProp,this.visProp.traceattributes,!0),t.visProp.layer=this.board.options.layer.trace,t.elementClass=n.OBJECT_CLASS_POINT,t.board=this.board,l.clearVisPropOld(t),this.board.renderer.drawPoint(t),this.traces[t.id]=t.rendNode,this},getParents:function(){var t=[this.Z(),this.X(),this.Y()];return this.parents&&(t=this.parents),this.type===n.OBJECT_TYPE_GLIDER&&(t=[this.X(),this.Y(),this.slideObject.id]),t}}),t.createPoint=function(e,i,r){var s,o,n,a=!1;for(n=l.copyAttributes(r,e.options,\"point\"),1===i.length&&l.isArray(i[0])&&i[0].length>1&&i[0].length<4&&(i=i[0]),o=0;o<i.length;o++)(\"function\"==typeof i[o]||\"string\"==typeof i[o])&&(a=!0);if(a)s=new t.Point(e,[0/0,0/0],n),s.addConstraint(i);else if(l.isNumber(i[0])&&l.isNumber(i[1]))s=new t.Point(e,i,n),l.exists(n.slideobject)?s.makeGlider(n.slideobject):s.baseElement=s,s.isDraggable=!0;else{if(\"object\"!=typeof i[0]||\"object\"!=typeof i[1])throw new Error(\"JSXGraph: Can't create point with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [x,y], [z,x,y], [point,transformation]\");s=new t.Point(e,[0,0],n),s.addTransform(i[0],i[1]),s.isDraggable=!1,s.parents=[i[0].id]}return e.isSuspendedUpdate||(s.handleSnapToGrid(),s.handleSnapToPoints(),s.handleAttractors()),s},t.createGlider=function(t,e,i){var r,s=l.copyAttributes(i,t.options,\"glider\");return r=1===e.length?t.create(\"point\",[0,0],s):t.create(\"point\",e.slice(0,2),s),r.makeGlider(e[e.length-1]),r},t.createIntersectionPoint=function(t,e,i){var s,a,h,c,d,u,p=l.copyAttributes(i,t.options,\"intersection\");e.push(0,0),s=t.create(\"point\",[0,0,0],p),a=t.select(e[0]),h=t.select(e[1]),d=e[2]||0,u=e[3]||0,c=a.elementClass===n.OBJECT_CLASS_CURVE&&h.elementClass===n.OBJECT_CLASS_CURVE?function(){return r.meetCurveCurve(a,h,d,u,a.board)}:a.elementClass===n.OBJECT_CLASS_CURVE&&h.elementClass===n.OBJECT_CLASS_LINE||h.elementClass===n.OBJECT_CLASS_CURVE&&a.elementClass===n.OBJECT_CLASS_LINE?function(){return r.meetCurveLine(a,h,d,a.board,s.visProp.alwaysintersect)}:a.elementClass===n.OBJECT_CLASS_LINE&&h.elementClass===n.OBJECT_CLASS_LINE?function(){var t,e,i=a.visProp.straightfirst,l=h.visProp.straightfirst,c=a.visProp.straightlast,u=h.visProp.straightlast;\nreturn s.visProp.alwaysintersect||i&&c&&l&&u?r.meet(a.stdform,h.stdform,d,a.board):(t=r.meetSegmentSegment(a.point1.coords.usrCoords,a.point2.coords.usrCoords,h.point1.coords.usrCoords,h.point2.coords.usrCoords,a.board),e=!i&&t[1]<0||!c&&t[1]>1||!l&&t[2]<0||!u&&t[2]>1?[0,0/0,0/0]:t[0],new o(n.COORDS_BY_USER,e,a.board))}:function(){return r.meet(a.stdform,h.stdform,d,a.board)},s.addConstraint([c]);try{a.addChild(s),h.addChild(s)}catch(f){throw new Error(\"JSXGraph: Can't create 'intersection' with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\")}return s.type=n.OBJECT_TYPE_INTERSECTION,s.elType=\"intersection\",s.parents=[a.id,h.id,d,u],s.generatePolynomial=function(){var t=a.generatePolynomial(s),e=h.generatePolynomial(s);return 0===t.length||0===e.length?[]:[t[0],e[0]]},s},t.createOtherIntersectionPoint=function(t,e,s){var o,a,h,c;if(3!==e.length||!l.isPoint(e[2])||e[0].elementClass!==n.OBJECT_CLASS_LINE&&e[0].elementClass!==n.OBJECT_CLASS_CIRCLE||e[1].elementClass!==n.OBJECT_CLASS_LINE&&e[1].elementClass!==n.OBJECT_CLASS_CIRCLE)throw new Error(\"JSXGraph: Can't create 'other intersection point' with parent types '\"+typeof e[0]+\"', '\"+typeof e[1]+\"'and '\"+typeof e[2]+\"'.\"+\"\\nPossible parent types: [circle|line,circle|line,point]\");return a=t.select(e[0]),h=t.select(e[1]),c=t.select(e[2]),o=t.create(\"point\",[function(){var t=r.meet(a.stdform,h.stdform,0,a.board);return Math.abs(c.X()-t.usrCoords[1])>i.eps||Math.abs(c.Y()-t.usrCoords[2])>i.eps||Math.abs(c.Z()-t.usrCoords[0])>i.eps?t:r.meet(a.stdform,h.stdform,1,a.board)}],s),o.type=n.OBJECT_TYPE_INTERSECTION,o.elType=\"otherintersection\",o.parents=[a.id,h.id,c],a.addChild(o),h.addChild(o),o.generatePolynomial=function(){var t=a.generatePolynomial(o),e=h.generatePolynomial(o);return 0===t.length||0===e.length?[]:[t[0],e[0]]},o},t.createPolePoint=function(e,i,r){var s,o,a;if(2!==i.length||(i[0].type!==n.OBJECT_TYPE_CONIC&&i[0].elementClass!==n.OBJECT_CLASS_CIRCLE||i[1].elementClass!==n.OBJECT_CLASS_LINE)&&(i[0].elementClass!==n.OBJECT_CLASS_LINE||i[1].type!==n.OBJECT_TYPE_CONIC&&i[1].elementClass!==n.OBJECT_CLASS_CIRCLE))throw new Error(\"JSXGraph: Can't create 'pole point' with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent type: [conic|circle,line], [line,conic|circle]\");return i[1].elementClass===n.OBJECT_CLASS_LINE?(o=e.select(i[0]),a=e.select(i[1])):(o=e.select(i[1]),a=e.select(i[0])),s=e.create(\"point\",[function(){var e=o.quadraticform,i=a.stdform.slice(0,3);return[t.Math.Numerics.det([i,e[1],e[2]]),t.Math.Numerics.det([e[0],i,e[2]]),t.Math.Numerics.det([e[0],e[1],i])]}],r),s.elType=\"polepoint\",s.parents=[o.id,a.id],o.addChild(s),a.addChild(s),s},t.registerElement(\"point\",t.createPoint),t.registerElement(\"glider\",t.createGlider),t.registerElement(\"intersection\",t.createIntersectionPoint),t.registerElement(\"otherintersection\",t.createOtherIntersectionPoint),t.registerElement(\"polepoint\",t.createPolePoint),{Point:t.Point,createPoint:t.createPoint,createGlider:t.createGlider,createIntersection:t.createIntersectionPoint,createOtherIntersection:t.createOtherIntersectionPoint,createPolePoint:t.createPolePoint}}),define(\"utils/expect\",[\"jxg\",\"utils/type\",\"base/constants\",\"base/coords\",\"base/point\"],function(t,e,i,r){var s={each:function(t,e,i){var r,s=[];for(r=0;r<t.length;r++)s.push(e.call(this,t[r],i));return s},coords:function(t,e){var s=t;return t&&t.elementClass===i.OBJECT_CLASS_POINT?s=t.coords:t.usrCoords&&t.scrCoords&&t.usr2screen&&(s=t),e&&(s=new r(i.COORDS_BY_USER,s.usrCoords,s.board)),s},coordsArray:function(t,i){var r;return r=e.isArray(t)?t:this.coords(t).usrCoords,r.length<3&&r.unshift(1),i&&(r=[r[0],r[1],r[2]]),r}};return t.Expect=s,s}),define(\"math/qdt\",[\"math/math\",\"utils/type\"],function(t,e){var i=function(t){this.capacity=10,this.points=[],this.xlb=t[0],this.xub=t[2],this.ylb=t[3],this.yub=t[1],this.northWest=null,this.northEast=null,this.southEast=null,this.southWest=null};return e.extend(i.prototype,{contains:function(t,e){return this.xlb<t&&t<=this.xub&&this.ylb<e&&e<=this.yub},insert:function(t){return this.contains(t.usrCoords[1],t.usrCoords[2])?this.points.length<this.capacity?(this.points.push(t),!0):(null===this.northWest&&this.subdivide(),this.northWest.insert(t)?!0:this.northEast.insert(t)?!0:this.southEast.insert(t)?!0:this.southWest.insert(t)?!0:!1):!1},subdivide:function(){var t,e=this.points.length,r=this.xlb+(this.xub-this.xlb)/2,s=this.ylb+(this.yub-this.ylb)/2;for(this.northWest=new i([this.xlb,this.yub,r,s]),this.northEast=new i([r,this.yub,this.xub,s]),this.southEast=new i([this.xlb,s,r,this.ylb]),this.southWest=new i([r,s,this.xub,this.ylb]),t=0;e>t;t+=1)this.northWest.insert(this.points[t]),this.northEast.insert(this.points[t]),this.southEast.insert(this.points[t]),this.southWest.insert(this.points[t])},_query:function(t,e){var i;if(this.contains(t,e)){if(null===this.northWest)return this;if(i=this.northWest._query(t,e))return i;if(i=this.northEast._query(t,e))return i;if(i=this.southEast._query(t,e))return i;if(i=this.southWest._query(t,e))return i}return!1},query:function(t,i){var r,s;return e.exists(i)?(r=t,s=i):(r=t.usrCoords[1],s=t.usrCoords[2]),this._query(r,s)}}),t.Quadtree=i,i}),define(\"math/statistics\",[\"jxg\",\"base/constants\",\"math/math\",\"utils/type\"],function(t,e,i,r){return i.Statistics={sum:function(t){var e,i=t.length,r=0;for(e=0;i>e;e++)r+=t[e];return r},prod:function(t){var e,i=t.length,r=1;for(e=0;i>e;e++)r*=t[e];return r},mean:function(t){return t.length>0?this.sum(t)/t.length:0},median:function(t){var e,i;return t.length>0?(e=t.slice(0),e.sort(function(t,e){return t-e}),i=e.length,1===i%2?e[parseInt(.5*i,10)]:.5*(e[.5*i-1]+e[.5*i])):0},variance:function(t){var e,i,r,s=t.length;if(s>1){for(e=this.mean(t),i=0,r=0;s>r;r++)i+=(t[r]-e)*(t[r]-e);return i/(t.length-1)}return 0},sd:function(t){return Math.sqrt(this.variance(t))},weightedMean:function(t,e){if(t.length!==e.length)throw new Error(\"JSXGraph error (Math.Statistics.weightedMean): Array dimension mismatch.\");return t.length>0?this.mean(this.multiply(t,e)):0},max:function(t){return Math.max.apply(this,t)},min:function(t){return Math.min.apply(this,t)},range:function(t){return[this.min(t),this.max(t)]},abs:function(t){var e,i,s;if(r.isArray(t))for(i=t.length,s=[],e=0;i>e;e++)s[e]=Math.abs(t[e]);else s=Math.abs(t);return s},add:function(t,e){var i,s,o=[];if(t=r.evalSlider(t),e=r.evalSlider(e),r.isArray(t)&&r.isNumber(e))for(s=t.length,i=0;s>i;i++)o[i]=t[i]+e;else if(r.isNumber(t)&&r.isArray(e))for(s=e.length,i=0;s>i;i++)o[i]=t+e[i];else if(r.isArray(t)&&r.isArray(e))for(s=Math.min(t.length,e.length),i=0;s>i;i++)o[i]=t[i]+e[i];else o=t+e;return o},div:function(t,e){var i,s,o=[];if(t=r.evalSlider(t),e=r.evalSlider(e),r.isArray(t)&&r.isNumber(e))for(s=t.length,i=0;s>i;i++)o[i]=t[i]/e;else if(r.isNumber(t)&&r.isArray(e))for(s=e.length,i=0;s>i;i++)o[i]=t/e[i];else if(r.isArray(t)&&r.isArray(e))for(s=Math.min(t.length,e.length),i=0;s>i;i++)o[i]=t[i]/e[i];else o=t/e;return o},divide:t.shortcut(i.Statistics,\"div\"),mod:function(t,e,s){var o,n,a=[],h=function(t,e){return t%e};if(s=r.def(s,!1),s&&(h=i.mod),t=r.evalSlider(t),e=r.evalSlider(e),r.isArray(t)&&r.isNumber(e))for(n=t.length,o=0;n>o;o++)a[o]=h(t[o],e);else if(r.isNumber(t)&&r.isArray(e))for(n=e.length,o=0;n>o;o++)a[o]=h(t,e[o]);else if(r.isArray(t)&&r.isArray(e))for(n=Math.min(t.length,e.length),o=0;n>o;o++)a[o]=h(t[o],e[o]);else a=h(t,e);return a},multiply:function(t,e){var i,s,o=[];if(t=r.evalSlider(t),e=r.evalSlider(e),r.isArray(t)&&r.isNumber(e))for(s=t.length,i=0;s>i;i++)o[i]=t[i]*e;else if(r.isNumber(t)&&r.isArray(e))for(s=e.length,i=0;s>i;i++)o[i]=t*e[i];else if(r.isArray(t)&&r.isArray(e))for(s=Math.min(t.length,e.length),i=0;s>i;i++)o[i]=t[i]*e[i];else o=t*e;return o},subtract:function(t,e){var i,s,o=[];if(t=r.evalSlider(t),e=r.evalSlider(e),r.isArray(t)&&r.isNumber(e))for(s=t.length,i=0;s>i;i++)o[i]=t[i]-e;else if(r.isNumber(t)&&r.isArray(e))for(s=e.length,i=0;s>i;i++)o[i]=t-e[i];else if(r.isArray(t)&&r.isArray(e))for(s=Math.min(t.length,e.length),i=0;s>i;i++)o[i]=t[i]-e[i];else o=t-e;return o},TheilSenRegression:function(t){var e,r,s=[],o=[],n=[];for(e=0;e<t.length;e++){for(o.length=0,r=0;r<t.length;r++)Math.abs(t[r].usrCoords[1]-t[e].usrCoords[1])>i.eps&&(o[r]=(t[r].usrCoords[2]-t[e].usrCoords[2])/(t[r].usrCoords[1]-t[e].usrCoords[1]));s[e]=this.median(o),n.push(t[e].usrCoords[2]-s[e]*t[e].usrCoords[1])}return[this.median(n),this.median(s),-1]}},i.Statistics}),define(\"utils/zip\",[\"jxg\"],function(t){var e=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],r=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],n=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],a=256;return t.Util=t.Util||{},t.Util.Unzip=function(h){function l(){return j+=8,L>B?h[B++]:-1}function c(){Y=1}function d(){var t;try{return j++,t=1&Y,Y>>=1,0===Y&&(Y=l(),t=1&Y,Y=128|Y>>1),t}catch(e){throw e}}function u(t){var i=0,r=t;try{for(;r--;)i=i<<1|d();t&&(i=e[i]>>8-t)}catch(s){throw s}return i}function p(){k=0}function f(t){S++,N[k++]=t,x.push(String.fromCharCode(t)),32768===k&&(k=0)}function m(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1}function b(){for(;;){if(G[U]>=w)return-1;if(O[G[U]]===U)return G[U]++;G[U]++}}function g(){var t,e=J[X];if(17===U)return-1;if(X++,U++,t=b(),t>=0)e.b0=t;else if(e.b0=32768,g())return-1;if(t=b(),t>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=J[X],e.jumppos=X,g())return-1;return U--,0}function v(t,e,i){var r;for(J=t,X=0,O=i,w=e,r=0;17>r;r++)G[r]=0;return U=0,g()?-1:0}function C(t){for(var e,i,r,s=0,o=t[s];;)if(r=d()){if(!(32768&o.b1))return o.b1;for(o=o.jump,e=t.length,i=0;e>i;i++)if(t[i]===o){s=i;break}}else{if(!(32768&o.b0))return o.b0;s++,o=t[s]}}function y(){var a,h,b,g,y,P,_,S,E,O,w,T,x,A,M,R,L;do if(a=d(),b=u(2),0===b)for(c(),O=l(),O|=l()<<8,T=l(),T|=l()<<8,65535&(O^~T)&&t.debug(\"BlockLen checksum mismatch\\n\");O--;)h=l(),f(h);else if(1===b)for(;;)if(y=e[u(7)]>>1,y>23?(y=y<<1|d(),y>199?(y-=128,y=y<<1|d()):(y-=48,y>143&&(y+=136))):y+=256,256>y)f(y);else{if(256===y)break;for(y-=257,E=u(r[y])+i[y],y=e[u(5)]>>3,o[y]>8?(w=u(8),w|=u(o[y]-8)<<8):w=u(o[y]),w+=s[y],y=0;E>y;y++)h=N[32767&k-w],f(h)}else if(2===b){for(_=new Array(320),A=257+u(5),M=1+u(5),R=4+u(4),y=0;19>y;y++)_[y]=0;for(y=0;R>y;y++)_[n[y]]=u(3);for(E=I.length,g=0;E>g;g++)I[g]=new m;if(v(I,19,_,0))return p(),1;for(x=A+M,g=0,L=-1;x>g;)if(L++,y=C(I),16>y)_[g++]=y;else if(16===y){if(y=3+u(2),g+y>x)return p(),1;for(P=g?_[g-1]:0;y--;)_[g++]=P}else{if(y=17===y?3+u(3):11+u(7),g+y>x)return p(),1;for(;y--;)_[g++]=0}for(E=D.length,g=0;E>g;g++)D[g]=new m;if(v(D,A,_,0))return p(),1;for(E=D.length,g=0;E>g;g++)I[g]=new m;for(S=[],g=A;g<_.length;g++)S[g-A]=_[g];if(v(I,M,S,0))return p(),1;for(;;)if(y=C(D),y>=256){if(y-=256,0===y)break;for(y-=1,E=u(r[y])+i[y],y=C(I),o[y]>8?(w=u(8),w|=u(o[y]-8)<<8):w=u(o[y]),w+=s[y];E--;)h=N[32767&k-w],f(h)}else f(y)}while(!a);return p(),c(),0}function P(){var t,e,i,r,s,o,n,h,c=[];try{if(x=[],R=!1,c[0]=l(),c[1]=l(),120===c[0]&&218===c[1]&&(y(),M[A]=[x.join(\"\"),\"geonext.gxt\"],A++),31===c[0]&&139===c[1]&&(T(),M[A]=[x.join(\"\"),\"file\"],A++),80===c[0]&&75===c[1]&&(R=!0,c[2]=l(),c[3]=l(),3===c[2]&&4===c[3])){for(c[0]=l(),c[1]=l(),_=l(),_|=l()<<8,h=l(),h|=l()<<8,l(),l(),l(),l(),n=l(),n|=l()<<8,n|=l()<<16,n|=l()<<24,o=l(),o|=l()<<8,o|=l()<<16,o|=l()<<24,s=l(),s|=l()<<8,s|=l()<<16,s|=l()<<24,r=l(),r|=l()<<8,i=l(),i|=l()<<8,t=0,F=[];r--;)e=l(),\"/\"===e|\":\"===e?t=0:a-1>t&&(F[t++]=String.fromCharCode(e));for(E||(E=F),t=0;i>t;)e=l(),t++;S=0,8===h&&(y(),M[A]=new Array(2),M[A][0]=x.join(\"\"),M[A][1]=F.join(\"\"),A++),T()}}catch(d){throw d}}var _,S,E,O,w,T,x=[],A=0,M=[],N=new Array(32768),k=0,R=!1,L=h.length,B=0,Y=1,j=0,D=new Array(288),I=new Array(32),X=0,J=null,U=(new Array(64),new Array(64),0),G=new Array(17),F=[];G[0]=0,T=function(){var t,e,i,r,s,o,n=[];if(8&_&&(n[0]=l(),n[1]=l(),n[2]=l(),n[3]=l(),80===n[0]&&75===n[1]&&7===n[2]&&8===n[3]?(t=l(),t|=l()<<8,t|=l()<<16,t|=l()<<24):t=n[0]|n[1]<<8|n[2]<<16|n[3]<<24,e=l(),e|=l()<<8,e|=l()<<16,e|=l()<<24,i=l(),i|=l()<<8,i|=l()<<16,i|=l()<<24),R&&P(),n[0]=l(),8===n[0]){if(_=l(),l(),l(),l(),l(),l(),r=l(),4&_)for(n[0]=l(),n[2]=l(),U=n[0]+256*n[1],s=0;U>s;s++)l();if(8&_)for(s=0,F=[],o=l();o;)(\"7\"===o||\":\"===o)&&(s=0),a-1>s&&(F[s++]=o),o=l();if(16&_)for(o=l();o;)o=l();2&_&&(l(),l()),y(),t=l(),t|=l()<<8,t|=l()<<16,t|=l()<<24,i=l(),i|=l()<<8,i|=l()<<16,i|=l()<<24,R&&P()}},t.Util.Unzip.prototype.unzipFile=function(t){var e;for(this.unzip(),e=0;e<M.length;e++)if(M[e][1]===t)return M[e][0];return\"\"},t.Util.Unzip.prototype.unzip=function(){return P(),M}},t.Util}),define(\"utils/encoding\",[\"jxg\"],function(t){var e=0,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3,11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,0,12,24,36,60,96,84,12,12,12,48,72,12,12,12,12,12,12,12,12,12,12,12,12,12,0,12,12,12,12,12,0,12,0,12,12,12,24,12,12,12,12,12,24,12,24,12,12,12,12,12,12,12,12,12,24,12,12,12,12,12,24,12,12,12,12,12,12,12,24,12,12,12,12,12,12,12,12,12,36,12,36,12,12,12,36,12,12,12,12,12,36,12,36,12,12,12,36,12,12,12,12,12,12,12,12,12,12];return t.Util=t.Util||{},t.Util.UTF8={encode:function(t){var e,i,r=\"\",s=t.length;if(t=t.replace(/\\r\\n/g,\"\\n\"),\"function\"==typeof unescape&&\"function\"==typeof encodeURIComponent)return unescape(encodeURIComponent(t));for(e=0;s>e;e++)i=t.charCodeAt(e),128>i?r+=String.fromCharCode(i):i>127&&2048>i?(r+=String.fromCharCode(192|i>>6),r+=String.fromCharCode(128|63&i)):(r+=String.fromCharCode(224|i>>12),r+=String.fromCharCode(128|63&i>>6),r+=String.fromCharCode(128|63&i));return r},decode:function(t){var r,s,o,n=0,a=0,h=e,l=[],c=t.length,d=[];for(r=0;c>r;r++)s=t.charCodeAt(r),o=i[s],a=h!==e?63&s|a<<6:255>>o&s,h=i[256+h+o],h===e&&(a>65535?l.push(55232+(a>>10),56320+(1023&a)):l.push(a),n++,0===n%1e4&&(d.push(String.fromCharCode.apply(null,l)),l=[]));return d.push(String.fromCharCode.apply(null,l)),d.join(\"\")},asciiCharCodeAt:function(t,e){var i=t.charCodeAt(e);if(i>255)switch(i){case 8364:i=128;break;case 8218:i=130;break;case 402:i=131;break;case 8222:i=132;break;case 8230:i=133;break;case 8224:i=134;break;case 8225:i=135;break;case 710:i=136;break;case 8240:i=137;break;case 352:i=138;break;case 8249:i=139;break;case 338:i=140;break;case 381:i=142;break;case 8216:i=145;break;case 8217:i=146;break;case 8220:i=147;break;case 8221:i=148;break;case 8226:i=149;break;case 8211:i=150;break;case 8212:i=151;break;case 732:i=152;break;case 8482:i=153;break;case 353:i=154;break;case 8250:i=155;break;case 339:i=156;break;case 382:i=158;break;case 376:i=159}return i}},t.Util.UTF8}),define(\"utils/base64\",[\"jxg\",\"utils/encoding\"],function(t,e){function i(t,e){return 255&t.charCodeAt(e)}function r(t,e){var i=s.indexOf(t.charAt(e));if(-1===i)throw new Error(\"JSXGraph/utils/base64: Can't decode string (invalid character).\");return i}var s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=\"=\";return t.Util=t.Util||{},t.Util.Base64={encode:function(t){var r,n,a,h,l,c=[];for(l=e.encode(t),a=l.length,h=a%3,r=0;a-h>r;r+=3)n=i(l,r)<<16|i(l,r+1)<<8|i(l,r+2),c.push(s.charAt(n>>18),s.charAt(63&n>>12),s.charAt(63&n>>6),s.charAt(63&n));switch(h){case 1:n=i(l,a-1),c.push(s.charAt(n>>2),s.charAt(63&n<<4),o,o);break;case 2:n=i(l,a-2)<<8|i(l,a-1),c.push(s.charAt(n>>10),s.charAt(63&n>>4),s.charAt(63&n<<2),o)}return c.join(\"\")},decode:function(t,i){var s,n,a,h,l,c,d=[],u=[];if(s=t.replace(/[^A-Za-z0-9\\+\\/=]/g,\"\"),a=s.length,0!==a%4)throw new Error(\"JSXGraph/utils/base64: Can't decode string (invalid input length).\");for(s.charAt(a-1)===o&&(h=1,s.charAt(a-2)===o&&(h=2),a-=4),n=0;a>n;n+=4)l=r(s,n)<<18|r(s,n+1)<<12|r(s,n+2)<<6|r(s,n+3),u.push(l>>16,255&l>>8,255&l),0===n%1e4&&(d.push(String.fromCharCode.apply(null,u)),u=[]);switch(h){case 1:l=r(s,a)<<12|r(s,a+1)<<6|r(s,a+2),u.push(l>>10,255&l>>2);break;case 2:l=r(s,n)<<6|r(s,n+1),u.push(l>>4)}return d.push(String.fromCharCode.apply(null,u)),c=d.join(\"\"),i&&(c=e.decode(c)),c},decodeAsArray:function(t){var e,i=this.decode(t),r=[],s=i.length;for(e=0;s>e;e++)r[e]=i.charCodeAt(e);return r}},t.Util.Base64}),define(\"server/server\",[\"jxg\",\"utils/zip\",\"utils/base64\",\"utils/type\"],function(t,e,i,r){return t.Server={modules:{},runningCalls:{},handleError:function(e){t.debug(\"error occured, server says: \"+e.message)},callServer:function(s,o,n,a){var h,l,c,d,u,p,f;a=a||!1,d=\"\";for(f in n)n.hasOwnProperty(f)&&(d+=\"&\"+escape(f)+\"=\"+escape(n[f]));p=r.toJSON(n);do u=s+Math.floor(4096*Math.random());while(r.exists(this.runningCalls[u]));return this.runningCalls[u]={action:s},r.exists(n.module)&&(this.runningCalls[u].module=n.module),h=t.serverBase+\"JXGServer.py\",l=\"action=\"+escape(s)+\"&id=\"+u+\"&dataJSON=\"+escape(i.encode(p)),this.cbp=function(t){var s,n,a,h,l,c,d,u;if(s=new e.Unzip(i.decodeAsArray(t)).unzip(),r.isArray(s)&&s.length>0&&(s=s[0][0]),r.exists(s))if(n=window.JSON&&window.JSON.parse?window.JSON.parse(s):new Function(\"return \"+s)(),\"error\"===n.type)this.handleError(n);else if(\"response\"===n.type){for(c=n.id,d=0;d<n.fields.length;d++)a=n.fields[d],h=a.namespace+(\"object\"==typeof new Function(\"return \"+a.namespace)()?\".\":\".prototype.\")+a.name+\" = \"+a.value,new Function(h)();for(d=0;d<n.handler.length;d++){for(a=n.handler[d],l=[],u=0;u<a.parameters.length;u++)l[u]='\"'+a.parameters[u]+'\": '+a.parameters[u];h=\"if(typeof JXG.Server.modules.\"+this.runningCalls[c].module+' == \"undefined\")'+\"JXG.Server.modules.\"+this.runningCalls[c].module+\" = {};\",h+=\"JXG.Server.modules.\"+this.runningCalls[c].module+\".\"+a.name+\"_cb = \"+a.callback+\";\",h+=\"JXG.Server.modules.\"+this.runningCalls[c].module+\".\"+a.name+\" = function (\"+a.parameters.join(\",\")+\", __JXGSERVER_CB__, __JXGSERVER_SYNC) {\"+'if(typeof __JXGSERVER_CB__ == \"undefined\") __JXGSERVER_CB__ = JXG.Server.modules.'+this.runningCalls[c].module+\".\"+a.name+\"_cb;\"+\"var __JXGSERVER_PAR__ = {\"+l.join(\",\")+', \"module\": \"'+this.runningCalls[c].module+'\", \"handler\": \"'+a.name+'\" };'+'JXG.Server.callServer(\"exec\", __JXGSERVER_CB__, __JXGSERVER_PAR__, __JXGSERVER_SYNC);'+\"};\",new Function(h)()}delete this.runningCalls[c],o(n.data)}},this.cb=t.bind(this.cbp,this),window.XMLHttpRequest?(c=new XMLHttpRequest,c.overrideMimeType(\"text/plain; charset=iso-8859-1\")):c=new ActiveXObject(\"Microsoft.XMLHTTP\"),c&&(c.open(\"POST\",h,!a),c.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\"),a||(c.onreadystatechange=function(t){return function(){return 4===c.readyState&&200===c.status?(t(c.responseText),!0):!1}}(this.cb)),c.send(l),a)?(this.cb(c.responseText),!0):!1},loadModule_cb:function(e){var i;for(i=0;i<e.length;i++)t.debug(e[i].name+\": \"+e[i].value)},loadModule:function(e){return t.Server.callServer(\"load\",t.Server.loadModule_cb,{module:e},!0)}},t.Server.load=t.Server.loadModule,t.Server}),define(\"math/symbolic\",[\"jxg\",\"base/constants\",\"base/coords\",\"math/math\",\"math/geometry\",\"server/server\",\"utils/type\"],function(t,e,i,r,s,o,n){var a;return r.Symbolic={generateSymbolicCoordinatesPartial:function(t,e,i,r){var s,o,a,h=e.ancestors,l=0,c=function(t){var e;return e=\"underscore\"===r?i+\"_{\"+t+\"}\":\"brace\"===r?i+\"[\"+t+\"]\":i+t};t.listOfFreePoints=[],t.listOfDependantPoints=[];for(o in h)if(h.hasOwnProperty(o)&&(s=0,n.isPoint(h[o]))){for(a in h[o].ancestors)h[o].ancestors.hasOwnProperty(a)&&s++;0===s?(h[o].symbolic.x=h[o].coords.usrCoords[1],h[o].symbolic.y=h[o].coords.usrCoords[2],t.listOfFreePoints.push(h[o])):(l+=1,h[o].symbolic.x=c(l),l+=1,h[o].symbolic.y=c(l),t.listOfDependantPoints.push(h[o]))}return n.isPoint(e)&&(e.symbolic.x=\"x\",e.symbolic.y=\"y\"),l},clearSymbolicCoordinates:function(t){var e=function(t){var e,i=t&&t.length||0;for(e=0;i>e;e++)n.isPoint(t[e])&&(t[e].symbolic.x=\"\",t[e].symbolic.y=\"\")};e(t.listOfFreePoints),e(t.listOfDependantPoints),delete t.listOfFreePoints,delete t.listOfDependantPoints},generatePolynomials:function(t,e,i){var r,s,o,a,h=e.ancestors,l=[],c=[];i&&this.generateSymbolicCoordinatesPartial(t,e,\"u\",\"brace\"),h[e.id]=e;for(r in h)if(h.hasOwnProperty(r)&&(a=0,l=[],n.isPoint(h[r]))){for(s in h[r].ancestors)h[r].ancestors.hasOwnProperty(s)&&a++;if(a>0)for(l=h[r].generatePolynomial(),o=0;o<l.length;o++)c.push(l[o])}return i&&this.clearSymbolicCoordinates(t),c},geometricLocusByGroebnerBase:function(t,h){var l,c,d,u,p,f,m,b,g,v,C,y,P,_=t.options.locus,S={},E=this.generateSymbolicCoordinatesPartial(t,h,\"u\",\"brace\"),O=new i(e.COORDS_BY_USR,[0,0],t),w=new i(e.COORDS_BY_USR,[t.canvasWidth,t.canvasHeight],t),T=1,x=0,A=0,M=0;if(o.modules.geoloci===a&&o.loadModule(\"geoloci\"),o.modules.geoloci===a)throw new Error(\"JSXGraph: Unable to load JXG.Server module 'geoloci.py'.\");if(m=O.usrCoords[1],b=w.usrCoords[1],g=w.usrCoords[2],v=O.usrCoords[2],_.translateToOrigin&&t.listOfFreePoints.length>0){for(u=_.toOrigin!==a&&null!==_.toOrigin&&n.isInArray(t.listOfFreePoints,_.toOrigin.id)?_.toOrigin:t.listOfFreePoints[0],x=u.symbolic.x,A=u.symbolic.y,f=0;f<t.listOfFreePoints.length;f++)t.listOfFreePoints[f].symbolic.x-=x,t.listOfFreePoints[f].symbolic.y-=A;if(m-=x,b-=x,g-=A,v-=A,_.translateTo10&&t.listOfFreePoints.length>1){for(p=_.to10!==a&&null!==_.to10&&_.to10.id!==_.toOrigin.id&&n.isInArray(t.listOfFreePoints,_.to10.id)?_.to10:t.listOfFreePoints[0].id===u.id?t.listOfFreePoints[1]:t.listOfFreePoints[0],M=s.rad([1,0],[0,0],[p.symbolic.x,p.symbolic.y]),C=Math.cos(-M),y=Math.sin(-M),f=0;f<t.listOfFreePoints.length;f++)P=t.listOfFreePoints[f].symbolic.x,t.listOfFreePoints[f].symbolic.x=C*t.listOfFreePoints[f].symbolic.x-y*t.listOfFreePoints[f].symbolic.y,t.listOfFreePoints[f].symbolic.y=y*P+C*t.listOfFreePoints[f].symbolic.y;if(p.symbolic.y=0,P=m,m=C*m-y*g,g=y*P+C*g,P=b,b=C*b-y*v,v=y*P+C*v,_.stretch&&Math.abs(p.symbolic.x)>r.eps){for(T=p.symbolic.x,f=0;f<t.listOfFreePoints.length;f++)t.listOfFreePoints[f].symbolic.x/=T,t.listOfFreePoints[f].symbolic.y/=T;for(f=0;f<t.objectsList.length;f++)t.objectsList[f].elementClass===e.OBJECT_CLASS_CIRCLE&&\"pointRadius\"===t.objectsList[f].method&&(S[f]=t.objectsList[f].radius,t.objectsList[f].radius/=T);m/=T,b/=T,g/=T,v/=T,p.symbolic.x=1}}for(f=0;f<t.listOfFreePoints.length;f++)P=t.listOfFreePoints[f].symbolic.x,Math.abs(P)<r.eps&&(t.listOfFreePoints[f].symbolic.x=0),Math.abs(P-Math.round(P))<r.eps&&(t.listOfFreePoints[f].symbolic.x=Math.round(P)),P=t.listOfFreePoints[f].symbolic.y,Math.abs(P)<r.eps&&(t.listOfFreePoints[f].symbolic.y=0),Math.abs(P-Math.round(P))<r.eps&&(t.listOfFreePoints[f].symbolic.y=Math.round(P))}l=this.generatePolynomials(t,h),c=l.join(\",\"),this.cbp=function(t){d=t},this.cb=n.bind(this.cbp,this),o.modules.geoloci.lociCoCoA(m,b,g,v,E,c,T,M,x,A,this.cb,!0),this.clearSymbolicCoordinates(t);for(f in S)S.hasOwnProperty(f)&&(t.objects[f].radius=S[f]);return d}},r.Symbolic}),define(\"math/poly\",[\"jxg\",\"math/math\",\"utils/type\"],function(t,e,i){return e.Poly={},e.Poly.Ring=function(t){this.vars=t},t.extend(e.Poly.Ring.prototype,{}),e.Poly.Monomial=function(t,e,r){var s;if(!i.exists(t))throw new Error(\"JSXGraph error: In JXG.Math.Poly.monomial missing parameter 'ring'.\");for(i.isArray(r)||(r=[]),r=r.slice(0,t.vars.length),s=r.length;s<t.vars.length;s++)r.push(0);this.ring=t,this.coefficient=e||0,this.exponents=i.deepCopy(r)},t.extend(e.Poly.Monomial.prototype,{copy:function(){return new e.Poly.Monomial(this.ring,this.coefficient,this.exponents)},print:function(){var t,e=[];for(t=0;t<this.ring.vars.length;t++)e.push(this.ring.vars[t]+\"^\"+this.exponents[t]);return this.coefficient+\"*\"+e.join(\"*\")}}),e.Poly.Polynomial=function(t,e){var r,s=function(){};if(!i.exists(t))throw new Error(\"JSXGraph error: In JXG.Math.Poly.polynomial missing parameter 'ring'.\");r=i.exists(e)&&\"string\"==typeof e?s(e):[],this.ring=t,this.monomials=r},t.extend(e.Poly.Polynomial.prototype,{findSignature:function(t){var e;for(e=0;e<this.monomials.length;e++)if(i.cmpArrays(this.monomials[e].exponents,t))return e;return-1},addSubMonomial:function(t,e){var i;i=this.findSignature(t.exponents),i>-1?this.monomials[i].coefficient+=e*t.coefficient:(t.coefficient*=e,this.monomials.push(t))},add:function(t){var e;if(!i.exists(t)||t.ring!==this.ring)throw new Error(\"JSXGraph error: In JXG.Math.Poly.polynomial.add either summand is undefined or rings don't match.\");if(i.isArray(t.exponents))this.addSubMonomial(t,1);else for(e=0;e<t.monomials.length;e++)this.addSubMonomial(t.monomials[e],1)},sub:function(t){var e;if(!i.exists(t)||t.ring!==this.ring)throw new Error(\"JSXGraph error: In JXG.Math.Poly.polynomial.sub either summand is undefined or rings don't match.\");if(i.isArray(t.exponents))this.addSubMonomial(t,-1);else for(e=0;e<t.monomials.length;e++)this.addSubMonomial(t.monomials[e],-1)},copy:function(){var t,i;for(i=new e.Poly.Polynomial(this.ring),t=0;t<this.monomials.length;t++)i.monomials.push(this.monomials[t].copy());return i},print:function(){var t,e=[];for(t=0;t<this.monomials.length;t++)e.push(\"(\"+this.monomials[t].print()+\")\");return e.join(\"+\")}}),e.Poly}),define(\"math/complex\",[\"jxg\",\"math/math\"],function(t){return t.Complex=function(t,e){this.isComplex=!0,t&&t.isComplex&&(e=t.imaginary,t=t.real),this.real=t||0,this.imaginary=e||0,this.absval=0,this.angle=0},t.extend(t.Complex.prototype,{toString:function(){return this.real+\" + \"+this.imaginary+\"i\"},add:function(t){return\"number\"==typeof t?this.real+=t:(this.real+=t.real,this.imaginary+=t.imaginary),this},sub:function(t){return\"number\"==typeof t?this.real-=t:(this.real-=t.real,this.imaginary-=t.imaginary),this},mult:function(t){var e,i;return\"number\"==typeof t?(this.real*=t,this.imaginary*=t):(e=this.real,i=this.imaginary,this.real=e*t.real-i*t.imaginary,this.imaginary=e*t.imaginary+i*t.real),this},div:function(t){var e,i,r;if(\"number\"==typeof t){if(Math.abs(t)<Math.eps)return this.real=1/0,this.imaginary=1/0,this;this.real/=t,this.imaginary/=t}else{if(Math.abs(t.real)<Math.eps&&Math.abs(t.imaginary)<Math.eps)return this.real=1/0,this.imaginary=1/0,this;e=t.real*t.real+t.imaginary*t.imaginary,r=this.real,i=this.imaginary,this.real=(r*t.real+i*t.imaginary)/e,this.imaginary=(i*t.real-r*t.imaginary)/e}return this},conj:function(){return this.imaginary*=-1,this}}),t.C={},t.C.add=function(e,i){var r=new t.Complex(e);return r.add(i),r},t.C.sub=function(e,i){var r=new t.Complex(e);return r.sub(i),r},t.C.mult=function(e,i){var r=new t.Complex(e);return r.mult(i),r},t.C.div=function(e,i){var r=new t.Complex(e);return r.div(i),r},t.C.conj=function(e){var i=new t.Complex(e);return i.conj(),i},t.C.abs=function(e){var i=new t.Complex(e);return i.conj(),i.mult(e),Math.sqrt(i.real)},t.Complex.C=t.C,t.Complex}),define(\"renderer/abstract\",[\"jxg\",\"options\",\"base/coords\",\"base/constants\",\"math/math\",\"math/geometry\",\"utils/type\",\"utils/env\"],function(t,e,i,r,s,o,n,a){return t.AbstractRenderer=function(){this.vOffsetText=0,this.enhancedRendering=!0,this.container=null,this.type=\"\"},t.extend(t.AbstractRenderer.prototype,{_updateVisual:function(t,e,i){(i||this.enhancedRendering)&&(e=e||{},t.visProp.draft?this.setDraft(t):(e.stroke||(this.setObjectStrokeColor(t,t.visProp.strokecolor,t.visProp.strokeopacity),this.setObjectStrokeWidth(t,t.visProp.strokewidth)),e.fill||this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity),e.dash||this.setDashStyle(t,t.visProp),e.shadow||this.setShadow(t),e.gradient||this.setShadow(t)))},drawPoint:function(t){var i,r=e.normalizePointFace(t.visProp.face);i=\"o\"===r?\"ellipse\":\"[]\"===r?\"rect\":\"path\",t.rendNode=this.appendChildPrim(this.createPrim(i,t.id),t.visProp.layer),this.appendNodesToElement(t,i),this._updateVisual(t,{dash:!0,shadow:!0},!0),this.updatePoint(t)},updatePoint:function(t){var i=t.visProp.size,r=e.normalizePointFace(t.visProp.face);isNaN(t.coords.scrCoords[2]+t.coords.scrCoords[1])||(this._updateVisual(t,{dash:!1,shadow:!1}),i*=t.board&&t.board.options.point.zoom?Math.sqrt(t.board.zoomX*t.board.zoomY):1,\"o\"===r?this.updateEllipsePrim(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2],i+1,i+1):\"[]\"===r?this.updateRectPrim(t.rendNode,t.coords.scrCoords[1]-i,t.coords.scrCoords[2]-i,2*i,2*i):this.updatePathPrim(t.rendNode,this.updatePathStringPoint(t,i,r),t.board),this.setShadow(t))},changePointStyle:function(t){var e=this.getElementById(t.id);n.exists(e)&&this.remove(e),this.drawPoint(t),n.clearVisPropOld(t),t.visProp.visible||this.hide(t),t.visProp.draft&&this.setDraft(t)},drawLine:function(t){t.rendNode=this.appendChildPrim(this.createPrim(\"line\",t.id),t.visProp.layer),this.appendNodesToElement(t,\"lines\"),this.updateLine(t)},updateLine:function(t){var e,s,n,a,h,l,c,d,u=new i(r.COORDS_BY_USER,t.point1.coords.usrCoords,t.board),p=new i(r.COORDS_BY_USER,t.point2.coords.usrCoords,t.board),f=10,m=null;(t.visProp.firstarrow||t.visProp.lastarrow)&&(m=-4),o.calcStraight(t,u,p,m),h=l=c=d=0,(t.visProp.lastarrow||t.visProp.firstarrow)&&(s=t.point1.visProp.size,n=t.point2.visProp.size,e=s+n,t.visProp.lastarrow&&t.visProp.touchlastpoint&&(a=u.distance(r.COORDS_BY_SCREEN,p),a>e&&(c=(p.scrCoords[1]-u.scrCoords[1])*n/a,d=(p.scrCoords[2]-u.scrCoords[2])*n/a,p=new i(r.COORDS_BY_SCREEN,[p.scrCoords[1]-c,p.scrCoords[2]-d],t.board))),t.visProp.firstarrow&&t.visProp.touchfirstpoint&&(a=u.distance(r.COORDS_BY_SCREEN,p),a>e&&(h=(p.scrCoords[1]-u.scrCoords[1])*s/a,l=(p.scrCoords[2]-u.scrCoords[2])*s/a,u=new i(r.COORDS_BY_SCREEN,[u.scrCoords[1]+h,u.scrCoords[2]+l],t.board))),e=Math.max(3*parseInt(t.visProp.strokewidth,10),f),a=u.distance(r.COORDS_BY_SCREEN,p),t.visProp.lastarrow&&\"vml\"!==t.board.renderer.type&&a>=f&&(c=(p.scrCoords[1]-u.scrCoords[1])*e/a,d=(p.scrCoords[2]-u.scrCoords[2])*e/a),t.visProp.firstarrow&&\"vml\"!==t.board.renderer.type&&a>=f&&(h=(p.scrCoords[1]-u.scrCoords[1])*e/a,l=(p.scrCoords[2]-u.scrCoords[2])*e/a)),this.updateLinePrim(t.rendNode,u.scrCoords[1]+h,u.scrCoords[2]+l,p.scrCoords[1]-c,p.scrCoords[2]-d,t.board),this.makeArrows(t),this._updateVisual(t)},drawTicks:function(t){t.rendNode=this.appendChildPrim(this.createPrim(\"path\",t.id),t.visProp.layer),this.appendNodesToElement(t,\"path\")},updateTicks:function(){},drawCurve:function(t){t.rendNode=this.appendChildPrim(this.createPrim(\"path\",t.id),t.visProp.layer),this.appendNodesToElement(t,\"path\"),this._updateVisual(t,{shadow:!0},!0),this.updateCurve(t)},updateCurve:function(t){this._updateVisual(t),t.visProp.handdrawing?this.updatePathPrim(t.rendNode,this.updatePathStringBezierPrim(t),t.board):this.updatePathPrim(t.rendNode,this.updatePathStringPrim(t),t.board),t.numberPoints>1&&this.makeArrows(t)},drawEllipse:function(t){t.rendNode=this.appendChildPrim(this.createPrim(\"ellipse\",t.id),t.visProp.layer),this.appendNodesToElement(t,\"ellipse\"),this.updateEllipse(t)},updateEllipse:function(t){this._updateVisual(t);\nvar e=t.Radius();e>0&&Math.abs(t.center.coords.usrCoords[0])>s.eps&&!isNaN(e+t.center.coords.scrCoords[1]+t.center.coords.scrCoords[2])&&e*t.board.unitX<2e6&&this.updateEllipsePrim(t.rendNode,t.center.coords.scrCoords[1],t.center.coords.scrCoords[2],e*t.board.unitX,e*t.board.unitY)},drawPolygon:function(t){t.rendNode=this.appendChildPrim(this.createPrim(\"polygon\",t.id),t.visProp.layer),this.appendNodesToElement(t,\"polygon\"),this.updatePolygon(t)},updatePolygon:function(t){this._updateVisual(t,{stroke:!0,dash:!0}),this.updatePolygonPrim(t.rendNode,t)},displayCopyright:function(){},drawInternalText:function(){},updateInternalText:function(){},drawText:function(t){var e,i;\"html\"===t.visProp.display&&a.isBrowser?(e=this.container.ownerDocument.createElement(\"div\"),e.style.position=\"absolute\",e.className=t.visProp.cssclass,i=\"\"===this.container.style.zIndex?0:parseInt(this.container.style.zIndex,10),e.style.zIndex=i+t.board.options.layer.text,this.container.appendChild(e),e.setAttribute(\"id\",this.container.id+\"_\"+t.id)):e=this.drawInternalText(t),t.rendNode=e,t.htmlStr=\"\",this.updateText(t)},updateText:function(t){var e,i,r=t.plaintext;t.visProp.visible&&(this.updateTextStyle(t,!1),\"html\"===t.visProp.display?(isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||(i=t.coords.scrCoords[1],i=Math.abs(i)<1e6?i:1e6,e=\"right\"===t.visProp.anchorx?Math.floor(t.board.canvasWidth-i):\"middle\"===t.visProp.anchorx?Math.floor(i-.5*t.size[0]):Math.floor(i),t.visPropOld.left!==t.visProp.anchorx+e&&(\"right\"===t.visProp.anchorx?(t.rendNode.style.right=e+\"px\",t.rendNode.style.left=\"auto\"):(t.rendNode.style.left=e+\"px\",t.rendNode.style.right=\"auto\"),t.visPropOld.left=t.visProp.anchorx+e),i=t.coords.scrCoords[2]+this.vOffsetText,i=Math.abs(i)<1e6?i:1e6,e=\"bottom\"===t.visProp.anchory?Math.floor(t.board.canvasHeight-i):\"middle\"===t.visProp.anchory?Math.floor(i-.5*t.size[1]):Math.floor(i),t.visPropOld.top!==t.visProp.anchory+e&&(\"bottom\"===t.visProp.anchory?(t.rendNode.style.top=\"auto\",t.rendNode.style.bottom=e+\"px\"):(t.rendNode.style.bottom=\"auto\",t.rendNode.style.top=e+\"px\"),t.visPropOld.top=t.visProp.anchory+e)),t.htmlStr!==r&&(t.rendNode.innerHTML=r,t.htmlStr=r,t.visProp.usemathjax?MathJax.Hub.Queue([\"Typeset\",MathJax.Hub,t.rendNode]):t.visProp.useasciimathml&&AMprocessNode(t.rendNode,!1)),this.transformImage(t,t.transformations)):this.updateInternalText(t))},updateTextStyle:function(t,e){var i,r,s,o,h=t.visProp,l=a.isBrowser?h.display:\"internal\";if(e?(s=h.highlightstrokecolor,r=h.highlightstrokeopacity,o=h.highlightcssclass):(s=h.strokecolor,r=h.strokeopacity,o=h.cssclass),(\"html\"===l||\"canvas\"!==this.type&&\"no\"!==this.type)&&(i=n.evaluate(t.visProp.fontsize),t.visPropOld.fontsize!==i)){t.needsSizeUpdate=!0;try{t.rendNode.style.fontSize=i+\"px\"}catch(c){t.rendNode.style.fontSize=i}t.visPropOld.fontsize=i}return\"html\"===l?(t.visPropOld.cssclass!==o&&(t.rendNode.className=o,t.visPropOld.cssclass=o,t.needsSizeUpdate=!0),this.setObjectStrokeColor(t,s,r)):this.updateInternalTextStyle(t,s,r),this},updateInternalTextStyle:function(t,e,i){this.setObjectStrokeColor(t,e,i)},drawImage:function(){},updateImage:function(t){this.updateRectPrim(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1],t.size[0],t.size[1]),this.updateImageURL(t),this.transformImage(t,t.transformations),this._updateVisual(t,{stroke:!0,dash:!0},!0)},joinTransforms:function(t,e){var i,r=[[1,0,0],[0,1,0],[0,0,1]],o=t.board.origin.scrCoords[1],n=t.board.origin.scrCoords[2],a=t.board.unitX,h=t.board.unitY,l=[[1,0,0],[-o,1,0],[-n,0,1]],c=[[1,0,0],[0,1/a,0],[0,0,-1/h]],d=[[1,0,0],[0,a,0],[0,0,-h]],u=[[1,0,0],[o,1,0],[n,0,1]],p=e.length;for(i=0;p>i;i++)r=s.matMatMult(l,r),r=s.matMatMult(c,r),r=s.matMatMult(e[i].matrix,r),r=s.matMatMult(d,r),r=s.matMatMult(u,r);return r},transformImage:function(){},updateImageURL:function(){},updateImageStyle:function(t,e){t.rendNode.className=e?t.visProp.highlightcssclass:t.visProp.cssclass},appendChildPrim:function(){},appendNodesToElement:function(){},createPrim:function(){return null},remove:function(){},makeArrows:function(){},updateEllipsePrim:function(){},updateLinePrim:function(){},updatePathPrim:function(){},updatePathStringPoint:function(){},updatePathStringPrim:function(){},updatePathStringBezierPrim:function(){},updatePolygonPrim:function(){},updateRectPrim:function(){},setPropertyPrim:function(){},show:function(){},hide:function(){},setBuffering:function(){},setDashStyle:function(){},setDraft:function(t){if(t.visProp.draft){var e=t.board.options.elements.draft.color,i=t.board.options.elements.draft.opacity;t.type===r.OBJECT_TYPE_POLYGON?this.setObjectFillColor(t,e,i):(t.elementClass===r.OBJECT_CLASS_POINT?this.setObjectFillColor(t,e,i):this.setObjectFillColor(t,\"none\",0),this.setObjectStrokeColor(t,e,i),this.setObjectStrokeWidth(t,t.board.options.elements.draft.strokeWidth))}},removeDraft:function(t){t.type===r.OBJECT_TYPE_POLYGON?this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity):(t.type===r.OBJECT_CLASS_POINT&&this.setObjectFillColor(t,t.visProp.fillcolor,t.visProp.fillopacity),this.setObjectStrokeColor(t,t.visProp.strokecolor,t.visProp.strokeopacity),this.setObjectStrokeWidth(t,t.visProp.strokewidth))},setGradient:function(){},updateGradient:function(){},setObjectFillColor:function(){},setObjectStrokeColor:function(){},setObjectStrokeWidth:function(){},setShadow:function(){},highlight:function(t){var e,i=t.visProp;if(!i.draft){if(t.type===r.OBJECT_TYPE_POLYGON)for(this.setObjectFillColor(t,i.highlightfillcolor,i.highlightfillopacity),e=0;e<t.borders.length;e++)this.setObjectStrokeColor(t.borders[e],t.borders[e].visProp.highlightstrokecolor,t.borders[e].visProp.highlightstrokeopacity);else t.type===r.OBJECT_TYPE_TEXT?this.updateTextStyle(t,!0):t.type===r.OBJECT_TYPE_IMAGE?this.updateImageStyle(t,!0):(this.setObjectStrokeColor(t,i.highlightstrokecolor,i.highlightstrokeopacity),this.setObjectFillColor(t,i.highlightfillcolor,i.highlightfillopacity));i.highlightstrokewidth&&this.setObjectStrokeWidth(t,Math.max(i.highlightstrokewidth,i.strokewidth))}return this},noHighlight:function(t){var e,i=t.visProp;if(!t.visProp.draft){if(t.type===r.OBJECT_TYPE_POLYGON)for(this.setObjectFillColor(t,i.fillcolor,i.fillopacity),e=0;e<t.borders.length;e++)this.setObjectStrokeColor(t.borders[e],t.borders[e].visProp.strokecolor,t.borders[e].visProp.strokeopacity);else t.type===r.OBJECT_TYPE_TEXT?this.updateTextStyle(t,!1):t.type===r.OBJECT_TYPE_IMAGE?this.updateImageStyle(t,!1):(this.setObjectStrokeColor(t,i.strokecolor,i.strokeopacity),this.setObjectFillColor(t,i.fillcolor,i.fillopacity));this.setObjectStrokeWidth(t,i.strokewidth)}return this},suspendRedraw:function(){},unsuspendRedraw:function(){},drawZoomBar:function(t){var e,i,r=function(t){t||(t=window.event),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0},s=function(s,o){var n;n=e.createElement(\"span\"),i.appendChild(n),n.appendChild(t.containerObj.ownerDocument.createTextNode(s)),a.addEvent(n,\"mouseover\",function(){this.style.backgroundColor=t.options.navbar.highlightFillColor},n),a.addEvent(n,\"mouseover\",function(){this.style.backgroundColor=t.options.navbar.highlightFillColor},n),a.addEvent(n,\"mouseout\",function(){this.style.backgroundColor=t.options.navbar.fillColor},n),a.addEvent(n,\"click\",o,t),a.addEvent(n,\"mouseup\",r,t),a.addEvent(n,\"mousedown\",r,t),a.addEvent(n,\"touchend\",r,t),a.addEvent(n,\"touchstart\",r,t)};a.isBrowser&&(e=t.containerObj.ownerDocument,i=e.createElement(\"div\"),i.setAttribute(\"id\",t.containerObj.id+\"_navigationbar\"),i.style.color=t.options.navbar.strokeColor,i.style.backgroundColor=t.options.navbar.fillColor,i.style.padding=t.options.navbar.padding,i.style.position=t.options.navbar.position,i.style.fontSize=t.options.navbar.fontSize,i.style.cursor=t.options.navbar.cursor,i.style.zIndex=t.options.navbar.zIndex,t.containerObj.appendChild(i),i.style.right=t.options.navbar.right,i.style.bottom=t.options.navbar.bottom,t.attr.showreload&&s(\" ↻ \",function(){t.reload()}),t.attr.showcleartraces&&s(\" ⊗ \",function(){t.clearTraces()}),t.attr.shownavigation&&(s(\" – \",t.zoomOut),s(\" o \",t.zoom100),s(\" + \",t.zoomIn),s(\" ← \",t.clickLeftArrow),s(\" ↓ \",t.clickUpArrow),s(\" ↑ \",t.clickDownArrow),s(\" → \",t.clickRightArrow)))},getElementById:function(t){return this.container.ownerDocument.getElementById(this.container.id+\"_\"+t)},removeToInsertLater:function(t){var e=t.parentNode,i=t.nextSibling;return e.removeChild(t),function(){i?e.insertBefore(t,i):e.appendChild(t)}},resize:function(){},createTouchpoints:function(){},showTouchpoint:function(){},hideTouchpoint:function(){},updateTouchpoint:function(){}}),t.AbstractRenderer}),define(\"renderer/no\",[\"jxg\",\"renderer/abstract\"],function(t,e){return t.NoRenderer=function(){this.enhancedRendering=!1,this.type=\"no\"},t.extend(t.NoRenderer.prototype,{drawPoint:function(){},updatePoint:function(){},changePointStyle:function(){},drawLine:function(){},updateLine:function(){},drawTicks:function(){},updateTicks:function(){},drawCurve:function(){},updateCurve:function(){},drawEllipse:function(){},updateEllipse:function(){},drawPolygon:function(){},updatePolygon:function(){},displayCopyright:function(){},drawInternalText:function(){},updateInternalText:function(){},drawText:function(){},updateText:function(){},updateTextStyle:function(){},updateInternalTextStyle:function(){},drawImage:function(){},updateImage:function(){},transformImage:function(){},updateImageURL:function(){},appendChildPrim:function(){},appendNodesToElement:function(){},createPrim:function(){return null},remove:function(){},makeArrows:function(){},updateEllipsePrim:function(){},updateLinePrim:function(){},updatePathPrim:function(){},updatePathStringPoint:function(){},updatePathStringPrim:function(){},updatePathStringBezierPrim:function(){},updatePolygonPrim:function(){},updateRectPrim:function(){},setPropertyPrim:function(){},show:function(){},hide:function(){},setBuffering:function(){},setDashStyle:function(){},setDraft:function(){},removeDraft:function(){},setGradient:function(){},updateGradient:function(){},setObjectFillColor:function(){},setObjectStrokeColor:function(){},setObjectStrokeWidth:function(){},setShadow:function(){},highlight:function(){},noHighlight:function(){},suspendRedraw:function(){},unsuspendRedraw:function(){},drawZoomBar:function(){},getElementById:function(){return null},resize:function(){},removeToInsertLater:function(){return function(){}}}),t.NoRenderer.prototype=new e,t.NoRenderer}),define(\"reader/file\",[\"jxg\",\"utils/env\",\"utils/type\",\"utils/encoding\",\"utils/base64\"],function(t,e,i,r,s){return t.FileReader={parseFileContent:function(e,o,n,a,h){var l=!1;i.exists(a)||(a=!0);try{l=new XMLHttpRequest,\"raw\"===n.toLowerCase()?l.overrideMimeType(\"text/plain; charset=iso-8859-1\"):l.overrideMimeType(\"text/xml; charset=iso-8859-1\")}catch(c){try{l=new ActiveXObject(\"Msxml2.XMLHTTP\")}catch(d){try{l=new ActiveXObject(\"Microsoft.XMLHTTP\")}catch(u){l=!1}}}if(!l)return t.debug(\"AJAX not activated!\"),void 0;l.open(\"GET\",e,a),this.cbp=\"raw\"===n.toLowerCase()?function(){var t=l;4===t.readyState&&o(t.responseText)}:function(){var t=l,e=\"\";4===t.readyState&&(e=!i.exists(t.responseStream)||\"PK\"!==t.responseText.slice(0,2)&&31!==r.asciiCharCodeAt(t.responseText.slice(0,1),0)?t.responseText:s.decode(jxgBinFileReader(t)),this.parseString(e,o,n,h))},this.cb=i.bind(this.cbp,this),l.onreadystatechange=this.cb;try{l.send(null)}catch(p){throw new Error(\"JSXGraph: A problem occurred while trying to read '\"+e+\"'.\")}},parseString:function(e,r,s,o){var n,a;if(s=s.toLowerCase(),n=t.readers[s],!i.exists(n))throw new Error(\"JSXGraph: There is no reader available for '\"+s+\"'.\");a=new n(r,e),a.read(),\"function\"==typeof o&&o(r)}},!e.isMetroApp()&&e.isBrowser&&\"object\"==typeof navigator&&/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)&&document&&document.write&&document.write('<script type=\"text/vbscript\">\\nFunction Base64Encode(inData)\\n Const Base64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"\\n Dim cOut, sOut, I\\n For I = 1 To LenB(inData) Step 3\\n Dim nGroup, pOut, sGroup\\n nGroup = &H10000 * AscB(MidB(inData, I, 1)) + _\\n &H100 * MyASC(MidB(inData, I + 1, 1)) + MyASC(MidB(inData, I + 2, 1))\\n nGroup = Oct(nGroup)\\n nGroup = String(8 - Len(nGroup), \"0\") & nGroup\\n pOut = Mid(Base64, CLng(\"&o\" & Mid(nGroup, 1, 2)) + 1, 1) + _\\n Mid(Base64, CLng(\"&o\" & Mid(nGroup, 3, 2)) + 1, 1) + _\\n Mid(Base64, CLng(\"&o\" & Mid(nGroup, 5, 2)) + 1, 1) + _\\n Mid(Base64, CLng(\"&o\" & Mid(nGroup, 7, 2)) + 1, 1)\\n sOut = sOut + pOut\\n Next\\n Select Case LenB(inData) Mod 3\\n Case 1: \\'8 bit final\\n sOut = Left(sOut, Len(sOut) - 2) + \"==\"\\n Case 2: \\'16 bit final\\n sOut = Left(sOut, Len(sOut) - 1) + \"=\"\\n End Select\\n Base64Encode = sOut\\nEnd Function\\n\\nFunction MyASC(OneChar)\\n If OneChar = \"\" Then MyASC = 0 Else MyASC = AscB(OneChar)\\nEnd Function\\n\\nFunction jxgBinFileReader(xhr)\\n Dim byteString\\n Dim b64String\\n Dim i\\n byteString = xhr.responseBody\\n ReDim byteArray(LenB(byteString))\\n For i = 1 To LenB(byteString)\\n byteArray(i-1) = AscB(MidB(byteString, i, 1))\\n Next\\n b64String = Base64Encode(byteString)\\n jxgBinFileReader = b64String\\nEnd Function\\n</script>\\n'),t.FileReader}),define(\"base/text\",[\"jxg\",\"base/constants\",\"base/coords\",\"base/element\",\"parser/geonext\",\"math/statistics\",\"utils/env\",\"utils/type\"],function(t,e,i,r,s,o,n,a){return t.Text=function(t,r,s,o){return this.constructor(t,o,e.OBJECT_TYPE_TEXT,e.OBJECT_CLASS_OTHER),this.content=\"\",this.plaintext=\"\",this.plaintextOld=null,this.isDraggable=!1,this.needsSizeUpdate=!1,this.element=this.board.select(o.anchor),this.hiddenByParent=!1,this.element?(this.relativeCoords=this.visProp.islabel?new i(e.COORDS_BY_SCREEN,[parseFloat(s[0]),parseFloat(s[1])],this.board):new i(e.COORDS_BY_USER,[parseFloat(s[0]),parseFloat(s[1])],this.board),this.element.addChild(this),this.X=function(){var t,r,s;return this.visProp.islabel?(t=parseFloat(this.visProp.offset[0]),s=this.element.getLabelAnchor(),r=new i(e.COORDS_BY_SCREEN,[t+this.relativeCoords.scrCoords[1]+s.scrCoords[1],0],this.board),r.usrCoords[1]):(s=this.element.getTextAnchor(),this.relativeCoords.usrCoords[1]+s.usrCoords[1])},this.Y=function(){var t,r,s;return this.visProp.islabel?(t=-parseFloat(this.visProp.offset[1]),s=this.element.getLabelAnchor(),r=new i(e.COORDS_BY_SCREEN,[0,t+this.relativeCoords.scrCoords[2]+s.scrCoords[2]],this.board),r.usrCoords[2]):(s=this.element.getTextAnchor(),this.relativeCoords.usrCoords[2]+s.usrCoords[2])},this.coords=new i(e.COORDS_BY_SCREEN,[0,0],this.board),this.isDraggable=!0):(a.isNumber(s[0])&&a.isNumber(s[1])&&(this.isDraggable=!0),this.X=a.createFunction(s[0],this.board,null,!0),this.Y=a.createFunction(s[1],this.board,null,!0),this.coords=new i(e.COORDS_BY_USER,[this.X(),this.Y()],this.board)),this.Z=a.createFunction(1,this.board,\"\"),this.size=[1,1],this.id=this.board.setId(this,\"T\"),this._setUpdateText(r),this.updateText(),this.board.renderer.drawText(this),this.visProp.visible||this.board.renderer.hide(this),\"string\"==typeof this.content&&this.notifyParents(this.content),this.elType=\"text\",this.methodMap=a.deepCopy(this.methodMap,{setText:\"setTextJessieCode\",free:\"free\",move:\"setCoords\"}),this},t.Text.prototype=new r,t.extend(t.Text.prototype,{hasPoint:function(t,e){var i,r,s,o,n=this.board.options.precision.hasPoint;return i=\"right\"===this.visProp.anchorx?this.coords.scrCoords[1]-this.size[0]:\"middle\"===this.visProp.anchorx?this.coords.scrCoords[1]-.5*this.size[0]:this.coords.scrCoords[1],r=i+this.size[0],o=\"top\"===this.visProp.anchory?this.coords.scrCoords[2]+this.size[1]:\"middle\"===this.visProp.anchory?this.coords.scrCoords[2]+.5*this.size[1]:this.coords.scrCoords[2],s=o-this.size[1],\"all\"===this.visProp.dragarea?t>=i-n&&r+n>t&&e>=s-n&&o+n>=e:e>=s-n&&o+n>=e&&(t>=i-n&&i+2*n>=t||t>=r-2*n&&r+n>=t)},_setUpdateText:function(t){var e;\"function\"==typeof t?this.updateText=function(){this.plaintext=this.convertGeonext2CSS(t())}:a.isString(t)&&!this.visProp.parse?this.updateText=function(){this.plaintext=t}:(this.content=a.isNumber(t)?t.toFixed(this.visProp.digits):this.visProp.useasciimathml?\"'`\"+t+\"`'\":this.generateTerm(t),e=this.board.jc.snippet(this.content,!0,\"\",!1),this.updateText=function(){this.plaintext=e()})},_setText:function(t){return this._setUpdateText(t),this.updateText(),this.prepareUpdate().update().updateRenderer(),this.board.infobox&&this.id===this.board.infobox.id||this.updateSize(),this},setTextJessieCode:function(t){var e;return this.visProp.castext=t,e=\"function\"==typeof t?function(){return a.sanitizeHTML(t())}:a.isNumber(t)?t:a.sanitizeHTML(t),this._setText(e)},setText:function(t){return this._setText(t)},updateSize:function(){var e,i,r;if(!n.isBrowser||\"no\"===this.board.renderer.type)return this;if(\"html\"===this.visProp.display||\"vml\"===this.board.renderer.type)t.exists(this.rendNode.offsetWidth)?(i=[this.rendNode.offsetWidth,this.rendNode.offsetHeight],0===i[0]&&0===i[1]?(r=this,window.setTimeout(function(){r.size=[r.rendNode.offsetWidth,r.rendNode.offsetHeight]},0)):this.size=i):this.size=this.crudeSizeEstimate();else if(\"internal\"===this.visProp.display)if(\"svg\"===this.board.renderer.type)try{e=this.rendNode.getBBox(),this.size=[e.width,e.height]}catch(s){}else\"canvas\"===this.board.renderer.type&&(this.size=this.crudeSizeEstimate());return this},crudeSizeEstimate:function(){return[.45*parseFloat(this.visProp.fontsize)*this.plaintext.length,.9*parseFloat(this.visProp.fontsize)]},utf8_decode:function(t){return t.replace(/&#x(\\w+);/g,function(t,e){return String.fromCharCode(parseInt(e,16))})},replaceSub:function(t){if(!t.indexOf)return t;for(var e,i=t.indexOf(\"_{\");i>=0;)t=t.substr(0,i)+t.substr(i).replace(/_\\{/,\"<sub>\"),e=t.substr(i).indexOf(\"}\"),e>=0&&(t=t.substr(0,e)+t.substr(e).replace(/\\}/,\"</sub>\")),i=t.indexOf(\"_{\");for(i=t.indexOf(\"_\");i>=0;)t=t.substr(0,i)+t.substr(i).replace(/_(.?)/,\"<sub>$1</sub>\"),i=t.indexOf(\"_\");return t},replaceSup:function(t){if(!t.indexOf)return t;for(var e,i=t.indexOf(\"^{\");i>=0;)t=t.substr(0,i)+t.substr(i).replace(/\\^\\{/,\"<sup>\"),e=t.substr(i).indexOf(\"}\"),e>=0&&(t=t.substr(0,e)+t.substr(e).replace(/\\}/,\"</sup>\")),i=t.indexOf(\"^{\");for(i=t.indexOf(\"^\");i>=0;)t=t.substr(0,i)+t.substr(i).replace(/\\^(.?)/,\"<sup>$1</sup>\"),i=t.indexOf(\"^\");return t},getSize:function(){return this.size},setCoords:function(t,i){return a.isArray(t)&&t.length>1&&(i=t[1],t=t[0]),this.X=function(){return t},this.Y=function(){return i},this.coords.setCoordinates(e.COORDS_BY_USER,[t,i]),this.prepareUpdate().update().updateRenderer(),this},free:function(){this.X=a.createFunction(this.X(),this.board,\"\"),this.Y=a.createFunction(this.Y(),this.board,\"\"),this.isDraggable=!0},update:function(){return this.needsUpdate&&(this.visProp.frozen||this.updateCoords(),this.updateText(),\"internal\"===this.visProp.display&&(this.plaintext=this.utf8_decode(this.plaintext)),this.checkForSizeUpdate(),this.needsSizeUpdate&&this.updateSize(),this.updateTransform()),this},checkForSizeUpdate:function(){this.board.infobox&&this.id===this.board.infobox.id?this.needsSizeUpdate=!1:(this.needsSizeUpdate=this.plaintextOld!==this.plaintext,this.needsSizeUpdate&&(this.plaintextOld=this.plaintext))},updateCoords:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.X(),this.Y()])},updateRenderer:function(){return this.needsUpdate&&(this.board.renderer.updateText(this),this.needsUpdate=!1),this},updateTransform:function(){var t;if(0===this.transformations.length)return this;for(t=0;t<this.transformations.length;t++)this.transformations[t].update();return this},generateTerm:function(t){var e,i,r,o,n='\"\"';if(t=t||\"\",t=t.replace(/\\r/g,\"\"),t=t.replace(/\\n/g,\"\"),t=t.replace(/\"/g,\"'\"),t=t.replace(/'/g,\"\\\\'\"),t=t.replace(/&arc;/g,\"∠\"),t=t.replace(/<arc\\s*\\/>/g,\"∠\"),t=t.replace(/<arc\\s*\\/>/g,\"∠\"),t=t.replace(/<sqrt\\s*\\/>/g,\"√\"),t=t.replace(/<value>/g,\"<value>\"),t=t.replace(/<\\/value>/g,\"</value>\"),r=t.indexOf(\"<value>\"),o=t.indexOf(\"</value>\"),r>=0)for(;r>=0;)n+=' + \"'+this.replaceSub(this.replaceSup(t.slice(0,r)))+'\"',i=t.slice(r+7,o),e=s.geonext2JS(i,this.board),e=e.replace(/\\\\\"/g,\"'\"),e=e.replace(/\\\\'/g,\"'\"),n+=e.indexOf(\"toFixed\")<0?a.isNumber(a.bind(this.board.jc.snippet(e,!0,\"\",!1),this)())?\"+(\"+e+\").toFixed(\"+this.visProp.digits+\")\":\"+(\"+e+\")\":\"+(\"+e+\")\",t=t.slice(o+8),r=t.indexOf(\"<value>\"),o=t.indexOf(\"</value>\");return n+=' + \"'+this.replaceSub(this.replaceSup(t))+'\"',n=this.convertGeonext2CSS(n),n=n.replace(/&/g,\"&\"),n=n.replace(/\"/g,\"'\")},convertGeonext2CSS:function(t){return\"string\"==typeof t&&(t=t.replace(/<overline>/g,\"<span style=text-decoration:overline>\"),t=t.replace(/<overline>/g,\"<span style=text-decoration:overline>\"),t=t.replace(/<\\/overline>/g,\"</span>\"),t=t.replace(/<\\/overline>/g,\"</span>\"),t=t.replace(/<arrow>/g,\"<span style=text-decoration:overline>\"),t=t.replace(/<arrow>/g,\"<span style=text-decoration:overline>\"),t=t.replace(/<\\/arrow>/g,\"</span>\"),t=t.replace(/<\\/arrow>/g,\"</span>\")),t},notifyParents:function(t){var e,i=null;t=t.replace(/<value>/g,\"<value>\"),t=t.replace(/<\\/value>/g,\"</value>\");do e=/<value>([\\w\\s\\*\\/\\^\\-\\+\\(\\)\\[\\],<>=!]+)<\\/value>/,i=e.exec(t),null!==i&&(s.findDependencies(this,i[1],this.board),t=t.substr(i.index),t=t.replace(e,\"\"));while(null!==i);return this},bounds:function(){var t=this.coords.usrCoords;return this.visProp.islabel?[0,0,0,0]:[t[1],t[2]+this.size[1],t[1]+this.size[0],t[2]]},setPositionDirectly:function(t,r,s){var n,h,l=new i(t,r,this.board),c=new i(t,s,this.board);return this.relativeCoords?this.visProp.islabel?(n=o.subtract(l.scrCoords,c.scrCoords),this.relativeCoords.scrCoords[1]+=n[1],this.relativeCoords.scrCoords[2]+=n[2]):(n=o.subtract(l.usrCoords,c.usrCoords),this.relativeCoords.usrCoords[1]+=n[1],this.relativeCoords.usrCoords[2]+=n[2]):(n=o.subtract(l.usrCoords,c.usrCoords),h=[this.Z(),this.X(),this.Y()],this.X=a.createFunction(h[1]+n[1],this.board,\"\"),this.Y=a.createFunction(h[2]+n[2],this.board,\"\"),this.visProp.snaptogrid&&(this.coords.setCoordinates(e.COORDS_BY_USER,l.usrCoords),this.snapToGrid(),this.X=a.createFunction(this.coords.usrCoords[1],this.board,\"\"),this.Y=a.createFunction(this.coords.usrCoords[2],this.board,\"\"))),this},snapToGrid:function(){return this.handleSnapToGrid()}}),t.createText=function(e,i,r){var s,o=a.copyAttributes(r,e.options,\"text\");return o.anchor=o.parent||o.anchor,s=new t.Text(e,i[i.length-1],i,o),\"function\"!=typeof i[i.length-1]&&(s.parents=i),0!==a.evaluate(o.rotate)&&\"internal\"===o.display&&s.addRotation(a.evaluate(o.rotate)),s},t.registerElement(\"text\",t.createText),t.createHTMLSlider=function(e,i,r){var s,o,h=a.copyAttributes(r,e.options,\"htmlslider\");if(2!==i.length||2!==i[0].length||3!==i[1].length)throw new Error(\"JSXGraph: Can't create htmlslider with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parents are: [[x,y], [min, start, max]]\");return h.anchor=h.parent||h.anchor,h.fixed=h.fixed||!0,o=[i[0][0],i[0][1],'<form style=\"display:inline\"><input type=\"range\" /><span></span><input type=\"text\" /></form>'],s=t.createText(e,o,h),s.type=a.OBJECT_TYPE_HTMLSLIDER,s.rendNodeForm=s.rendNode.childNodes[0],s.rendNodeForm.id=s.rendNode.id+\"_form\",s.rendNodeRange=s.rendNodeForm.childNodes[0],s.rendNodeRange.id=s.rendNode.id+\"_range\",s.rendNodeRange.min=i[1][0],s.rendNodeRange.max=i[1][2],s.rendNodeRange.step=h.step,s.rendNodeRange.value=i[1][1],s.rendNodeLabel=s.rendNodeForm.childNodes[1],s.rendNodeLabel.id=s.rendNode.id+\"_label\",h.withlabel&&(s.rendNodeLabel.innerHTML=s.name+\"=\"),s.rendNodeOut=s.rendNodeForm.childNodes[2],s.rendNodeOut.id=s.rendNode.id+\"_out\",s.rendNodeOut.value=i[1][1],s.rendNodeRange.style.width=h.widthrange+\"px\",s.rendNodeRange.style.verticalAlign=\"middle\",s.rendNodeOut.style.width=h.widthout+\"px\",s._val=i[1][1],t.supportsVML()?n.addEvent(s.rendNodeForm,\"change\",function(){this._val=1*this.rendNodeRange.value,this.rendNodeOut.value=this.rendNodeRange.value,this.board.update()},s):n.addEvent(s.rendNodeForm,\"input\",function(){this._val=1*this.rendNodeRange.value,this.rendNodeOut.value=this.rendNodeRange.value,this.board.update()},s),s.Value=function(){return this._val},s},t.registerElement(\"htmlslider\",t.createHTMLSlider),{Text:t.Text,createText:t.createText,createHTMLSlider:t.createHTMLSlider}}),define(\"utils/uuid\",[\"jxg\"],function(t){var e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",i=e.split(\"\");return t.Util=t.Util||{},t.Util.genUUID=function(){var t,e,r=[],s=0;for(e=0;36>e;e++)8===e||13===e||18===e||23===e?r[e]=\"-\":14===e?r[e]=\"4\":(2>=s&&(s=0|33554432+16777216*Math.random()),t=15&s,s>>=4,r[e]=i[19===e?8|3&t:t]);return r.join(\"\")},t.Util}),define(\"parser/jessiecode\",[\"jxg\",\"base/constants\",\"base/text\",\"math/math\",\"math/geometry\",\"math/statistics\",\"utils/type\",\"utils/uuid\",\"utils/env\"],function(JXG,Const,Text,Mat,Geometry,Statistics,Type,UUID,Env){var priv={modules:{math:Mat,\"math/geometry\":Geometry,\"math/statistics\":Statistics,\"math/numerics\":Mat.Numerics}};JXG.JessieCode=function(t,e){this.scope={id:0,hasChild:!0,args:[],locals:{},context:null,previous:null},this.scopes=[],this.scopes.push(this.scope),this.dpstack=[[]],this.pscope=0,this.propstack=[{}],this.propscope=0,this.lhs=[],this.isLHS=!1,this.warnLog=\"jcwarn\",this.$log=[],this.builtIn=this.defineBuiltIn(),this.board=null,this.lineToElement={},this.parCurLine=1,this.parCurColumn=0,this.line=1,this.col=1,this.code=\"\",\"string\"==typeof t&&this.parse(t,e)},JXG.extend(JXG.JessieCode.prototype,{node:function(t,e,i){return{type:t,value:e,children:i}},createNode:function(t,e){var i,r=this.node(t,e,[]);for(i=2;i<arguments.length;i++)r.children.push(arguments[i]);return r.line=this.parCurLine,r.col=this.parCurColumn,r},pushScope:function(t){var e={args:t,locals:{},context:null,previous:this.scope};return this.scope.hasChild=!0,this.scope=e,e.id=this.scopes.push(e)-1,e},popScope:function(){var t=this.scope.previous;return this.scope=null!==t?t:this.scope,this.scope},getElementById:function(t){return this.board.objects[t]},log:function(){this.$log.push(arguments),\"object\"==typeof console&&console.log&&console.log.apply(console,arguments)},creator:function(){var t,e={};return t=function(t){var i;return\"function\"==typeof e[this.board.id+t]?i=e[this.board.id+t]:(i=function(e){return function(i,r){var s;return s=Type.exists(r)?r:{name:0!==e.lhs[e.scope]?e.lhs[e.scope]:\"\"},e.board.create(t,i,s)}}(this),i.creator=!0,e[this.board.id+t]=i),i},t.clearCache=function(){e={}},t}(),letvar:function(t,e){this.builtIn[t]&&this._warn('\"'+t+'\" is a predefined value.'),this.scope.locals[t]=e},isLocalVariable:function(t){for(var e=this.scope;null!==e;){if(Type.exists(e.locals[t]))return e;e=e.previous}return null},isParameter:function(t){for(var e=this.scope;null!==e;){if(Type.indexOf(e.args,t)>-1)return e;e=e.previous}return null},isCreator:function(t){return!!JXG.elements[t]},isMathMethod:function(t){return\"E\"!==t&&!!Math[t]},isBuiltIn:function(t){return!!this.builtIn[t]},getvar:function(t,e){var i,r;return e=Type.def(e,!1),i=this.isLocalVariable(t),null!==i?i.locals[t]:this.isCreator(t)?this.creator(t):this.isBuiltIn(t)?this.builtIn[t]:this.isMathMethod(t)?Math[t]:e||(i=this.board.select(t),i===t)?r:i},resolve:function(t){for(var e=this.scope;null!==e;){if(Type.exists(e.locals[t]))return e.locals[t];e=e.previous}},getvarJS:function(t,e,i){var r,s=\"\";return e=Type.def(e,!1),i=Type.def(i,!1),r=this.isParameter(t),null!==r?t:(r=this.isLocalVariable(t),null===r||i?this.isCreator(t)?\"(function () { var a = Array.prototype.slice.call(arguments, 0), props = \"+(i?\"a.pop()\":\"{}\")+\"; return $jc$.board.create.apply($jc$.board, ['\"+t+\"'].concat([a, props])); })\":(i&&this._error(\"Syntax error (attribute values are allowed with element creators only)\"),this.isBuiltIn(t)?this.builtIn[t].src||this.builtIn[t]:this.isMathMethod(t)?\"Math.\"+t:e?\"\":(Type.isId(this.board,t)?s=\"$jc$.board.objects['\"+t+\"']\":Type.isName(this.board,t)?s=\"$jc$.board.elementsByName['\"+t+\"']\":Type.isGroup(this.board,t)&&(s=\"$jc$.board.groups['\"+t+\"']\"),s)):\"$jc$.resolve('\"+t+\"')\")},makeMap:function(t){return t.isMap=!0,t},functionCodeJS:function(t){var e=t.children[0].join(\", \"),i=\"\",r=\"\";return\"op_map\"===t.value&&(i=\"{ return \",r=\" }\"),\"function (\"+e+\") {\\n\"+\"var $oldscope$ = $jc$.scope;\\n\"+\"$jc$.scope = $jc$.scopes[\"+this.scope.id+\"];\\n\"+\"var r = (function () \"+i+this.compile(t.children[1],!0)+r+\")();\\n\"+\"$jc$.scope = $oldscope$;\\n\"+\"return r;\\n\"+\"}\"},defineFunction:function(node){var fun,i,bo=\"\",bc=\"\",list=node.children[0],scope=this.pushScope(list);if(this.board.options.jc.compile){for(this.isLHS=!1,i=0;i<list.length;i++)scope.locals[list[i]]=list[i];this.replaceNames(node.children[1]),fun=function($jc$,list){var fun,p=list.join(\", \"),str=\"var f = \"+$jc$.functionCodeJS(node)+\"; f;\";try{return fun=eval(str)}catch(e){return $jc$._warn(\"error compiling function\\n\\n\"+str+\"\\n\\n\"+e.toString()),function(){}}}(this,list),this.popScope()}else fun=function(t,e,i){return function(){var r,s;for(s=e.scope,e.scope=e.scopes[i],r=0;r<t.length;r++)e.scope.locals[t[r]]=arguments[r];return r=e.execute(node.children[1]),e.scope=s,r}}(list,this,scope.id);return fun.node=node,fun.scope=scope,fun.toJS=fun.toString,fun.toString=function(t){return function(){return t.compile(t.replaceIDs(Type.deepCopy(node)))}}(this),fun.deps={},this.collectDependencies(node.children[1],fun.deps),fun},mergeAttributes:function(){var t,e={};for(t=0;t<arguments.length;t++)e=Type.deepCopy(e,arguments[t],!0);return e},setProp:function(t,e,i){var r,s,o={};t.elementClass!==Const.OBJECT_CLASS_POINT||\"X\"!==e&&\"Y\"!==e?t.type!==Const.OBJECT_TYPE_TEXT||\"X\"!==e&&\"Y\"!==e?t.type&&t.elementClass&&t.visProp?Type.exists(t[t.methodMap[e]])&&\"function\"!=typeof t[t.methodMap[e]]?t[t.methodMap[e]]=i:(o[e]=i,t.setProperty(o)):t[e]=i:(\"number\"==typeof i?t[e]=function(){return i}:\"function\"==typeof i?(t.isDraggable=!1,t[e]=i):\"string\"==typeof i&&(t.isDraggable=!1,t[e]=Type.createFunction(i,this.board,null,!0),t[e+\"jc\"]=i),t[e].origin=i,this.board.update()):(e=e.toLowerCase(),t.isDraggable&&\"number\"==typeof i?(r=\"x\"===e?i:t.X(),s=\"y\"===e?i:t.Y(),t.setPosition(Const.COORDS_BY_USER,[r,s])):!t.isDraggable||\"function\"!=typeof i&&\"string\"!=typeof i?t.isDraggable||(r=\"x\"===e?i:t.XEval.origin,s=\"y\"===e?i:t.YEval.origin,t.addConstraint([r,s])):(r=\"x\"===e?i:t.coords.usrCoords[1],s=\"y\"===e?i:t.coords.usrCoords[2],t.addConstraint([r,s])),this.board.update())},parse:function(t,e,i){var r,s,o,n,a=t.replace(/\\r\\n/g,\"\\n\").split(\"\\n\"),h=[];i||(this.code+=t+\"\\n\"),Text&&(s=Text.Text.prototype.setText,Text.Text.prototype.setText=Text.Text.prototype.setTextJessieCode);try{for(Type.exists(e)||(e=!1),r=0;r<a.length;r++)e&&(a[r]=JXG.GeonextParser.geonext2JS(a[r],this.board)),h.push(a[r]);t=h.join(\"\\n\"),o=parser.parse(t),n=this.execute(o)}finally{Text&&(Text.Text.prototype.setText=s)}return n},snippet:function(t,e,i,r){var s;return e=Type.def(e,!0),i=Type.def(i,\"\"),r=Type.def(r,!1),s=(e?\" function (\"+i+\") { return \":\"\")+t+(e?\"; }\":\"\")+\";\",this.parse(s,r,!0)},replaceIDs:function(t){var e,i;if(t.replaced&&(i=this.board.objects[t.children[1][0].value],Type.exists(i)&&\"\"!==i.name&&(t.type=\"node_var\",t.value=i.name,t.children.length=0,delete t.replaced)),t.children)for(e=t.children.length;e>0;e--)Type.exists(t.children[e-1])&&(t.children[e-1]=this.replaceIDs(t.children[e-1]));return t},replaceNames:function(t){var e,i;if(i=t.value,\"node_op\"===t.type&&\"op_lhs\"===i&&1===t.children.length?this.isLHS=!0:\"node_var\"===t.type&&(this.isLHS?this.letvar(i,!0):!Type.exists(this.getvar(i,!0))&&Type.exists(this.board.elementsByName[i])&&(t=this.createReplacementNode(t))),t.children)for(e=t.children.length;e>0;e--)Type.exists(t.children[e-1])&&(t.children[e-1]=this.replaceNames(t.children[e-1]));return\"node_op\"===t.type&&\"op_lhs\"===t.value&&1===t.children.length&&(this.isLHS=!1),t},createReplacementNode:function(t){var e=t.value,i=this.board.elementsByName[e];\nreturn t=this.createNode(\"node_op\",\"op_execfun\",this.createNode(\"node_var\",\"$\"),[this.createNode(\"node_str\",i.id)]),t.replaced=!0,t},collectDependencies:function(t,e){var i,r,s;if(r=t.value,\"node_var\"===t.type&&(s=this.getvar(r),s&&s.visProp&&s.type&&s.elementClass&&s.id&&(e[s.id]=s)),\"node_op\"===t.type&&\"op_execfun\"===t.value&&t.children.length>1&&\"$\"===t.children[0].value&&t.children[1].length>0&&(s=t.children[1][0].value,e[s]=this.board.objects[s]),t.children)for(i=t.children.length;i>0;i--)Type.exists(t.children[i-1])&&this.collectDependencies(t.children[i-1],e)},resolveProperty:function(t,e,i){return i=Type.def(i,!1),t&&t.methodMap&&(Type.exists(t.subs)&&Type.exists(t.subs[e])?t=t.subs:Type.exists(t.methodMap[e])?e=t.methodMap[e]:(t=t.visProp,e=e.toLowerCase())),Type.exists(t)||this._error(t+\" is not an object\"),Type.exists(t[e])||this._error(\"unknown property \"+e),i&&\"function\"==typeof t[e]?function(){return t[e].apply(t,arguments)}:t[e]},getLHS:function(t){var e;if(\"node_var\"===t.type)e={o:this.scope.locals,what:t.value};else if(\"node_op\"===t.type&&\"op_property\"===t.value)e={o:this.execute(t.children[0]),what:t.children[1]};else{if(\"node_op\"!==t.type||\"op_extvalue\"!==t.value)throw new Error(\"Syntax error: Invalid left-hand side of assignment.\");e={o:this.execute(t.children[0]),what:this.execute(t.children[1])}}return e},getLHSCompiler:function(t,e){var i;if(\"node_var\"===t.type)i=t.value;else if(\"node_op\"===t.type&&\"op_property\"===t.value)i=[this.compile(t.children[0],e),\"'\"+t.children[1]+\"'\"];else{if(\"node_op\"!==t.type||\"op_extvalue\"!==t.value)throw new Error(\"Syntax error: Invalid left-hand side of assignment.\");i=[this.compile(t.children[0]),\"node_const\"===t.children[1].type?t.children[1].value:this.compile(t.children[1],e)]}return i},execute:function(t){var e,i,r,s,o,n,a,h,l,c,d,u=[];if(e=0,!t)return e;switch(this.line=t.line,this.col=t.col,t.type){case\"node_op\":switch(t.value){case\"op_none\":t.children[0]&&this.execute(t.children[0]),t.children[1]&&(e=this.execute(t.children[1]));break;case\"op_assign\":i=this.getLHS(t.children[0]),this.lhs[this.scope.id]=i[1],i.o.type&&i.o.elementClass&&i.o.methodMap&&\"label\"===i.what&&this._error(\"Left-hand side of assignment is read-only.\"),e=this.execute(t.children[1]),i.o!==this.scope.locals||Type.isArray(i.o)&&\"number\"==typeof i.what?this.setProp(i.o,i.what,e):this.letvar(i.what,e),this.lhs[this.scope.id]=0;break;case\"op_if\":this.execute(t.children[0])&&(e=this.execute(t.children[1]));break;case\"op_conditional\":case\"op_if_else\":e=this.execute(t.children[0])?this.execute(t.children[1]):this.execute(t.children[2]);break;case\"op_while\":for(;this.execute(t.children[0]);)this.execute(t.children[1]);break;case\"op_do\":do this.execute(t.children[0]);while(this.execute(t.children[1]));break;case\"op_for\":for(this.execute(t.children[0]);this.execute(t.children[1]);this.execute(t.children[2]))this.execute(t.children[3]);break;case\"op_proplst\":t.children[0]&&this.execute(t.children[0]),t.children[1]&&this.execute(t.children[1]);break;case\"op_emptyobject\":e={};break;case\"op_proplst_val\":this.propstack.push({}),this.propscope++,this.execute(t.children[0]),e=this.propstack[this.propscope],this.propstack.pop(),this.propscope--;break;case\"op_prop\":this.propstack[this.propscope][t.children[0]]=this.execute(t.children[1]);break;case\"op_array\":for(e=[],o=t.children[0].length,r=0;o>r;r++)e.push(this.execute(t.children[0][r]));break;case\"op_extvalue\":e=this.execute(t.children[0]),r=this.execute(t.children[1]),e=\"number\"==typeof r&&Math.abs(Math.round(r)-r)<Mat.eps?e[r]:n;break;case\"op_return\":if(0!==this.scope)return this.execute(t.children[0]);this._error(\"Unexpected return.\");break;case\"op_map\":t.children[1].isMath||this._error(\"In a map only function calls and mathematical expressions are allowed.\"),l=this.defineFunction(t),l.isMap=!0,e=l;break;case\"op_function\":l=this.defineFunction(t),l.isMap=!1,e=l;break;case\"op_execfun\":if(this.dpstack.push([]),this.pscope++,a=t.children[1],Type.exists(t.children[2]))if(t.children[3])for(h=t.children[2],c={},r=0;r<h.length;r++)c=Type.deepCopy(c,this.execute(h[r]),!0);else c=this.execute(t.children[2]);for(l=this.execute(t.children[0]),d=l&&l.sc?l.sc:this,!l.creator&&Type.exists(t.children[2])&&this._error(\"Unexpected value. Only element creators are allowed to have a value after the function call.\"),r=0;r<a.length;r++)u[r]=this.execute(a[r]),this.dpstack[this.pscope].push({line:t.children[1][r].line,col:t.children[1][r].ecol});if(\"function\"!=typeof l||l.creator)if(\"function\"==typeof l&&l.creator){s=this.line;try{for(e=l(u,c),e.jcLineStart=s,e.jcLineEnd=t.eline,r=s;r<=t.line;r++)this.lineToElement[r]=e;e.debugParents=this.dpstack[this.pscope]}catch(p){this._error(p.toString())}}else this._error(\"Function '\"+l+\"' is undefined.\");else e=l.apply(d,u);this.dpstack.pop(),this.pscope--;break;case\"op_property\":s=this.execute(t.children[0]),i=t.children[1],e=this.resolveProperty(s,i,!1),Type.exists(e)&&(e.sc=s);break;case\"op_use\":this._warn(\"Use of the 'use' operator is deprecated.\"),this.use(t.children[0].toString());break;case\"op_delete\":this._warn(\"Use of the 'delete' operator is deprecated. Please use the remove() function.\"),i=this.getvar(t.children[0]),e=this.del(i);break;case\"op_equ\":e=this.execute(t.children[0])==this.execute(t.children[1]);break;case\"op_neq\":e=this.execute(t.children[0])!=this.execute(t.children[1]);break;case\"op_approx\":e=Math.abs(this.execute(t.children[0])-this.execute(t.children[1]))<Mat.eps;break;case\"op_grt\":e=this.execute(t.children[0])>this.execute(t.children[1]);break;case\"op_lot\":e=this.execute(t.children[0])<this.execute(t.children[1]);break;case\"op_gre\":e=this.execute(t.children[0])>=this.execute(t.children[1]);break;case\"op_loe\":e=this.execute(t.children[0])<=this.execute(t.children[1]);break;case\"op_or\":e=this.execute(t.children[0])||this.execute(t.children[1]);break;case\"op_and\":e=this.execute(t.children[0])&&this.execute(t.children[1]);break;case\"op_not\":e=!this.execute(t.children[0]);break;case\"op_add\":e=this.add(this.execute(t.children[0]),this.execute(t.children[1]));break;case\"op_sub\":e=this.sub(this.execute(t.children[0]),this.execute(t.children[1]));break;case\"op_div\":e=this.div(this.execute(t.children[0]),this.execute(t.children[1]));break;case\"op_mod\":e=this.mod(this.execute(t.children[0]),this.execute(t.children[1]),!0);break;case\"op_mul\":e=this.mul(this.execute(t.children[0]),this.execute(t.children[1]));break;case\"op_exp\":e=this.pow(this.execute(t.children[0]),this.execute(t.children[1]));break;case\"op_neg\":e=-1*this.execute(t.children[0])}break;case\"node_var\":e=this.getvar(t.value);break;case\"node_const\":e=Number(t.value);break;case\"node_const_bool\":e=t.value;break;case\"node_str\":e=t.value.replace(/\\\\(.)/,\"$1\")}return e},compile:function(t,e){var i,r,s,o,n=\"\";if(Type.exists(e)||(e=!1),!t)return n;switch(t.type){case\"node_op\":switch(t.value){case\"op_none\":t.children[0]&&(n=this.compile(t.children[0],e)),t.children[1]&&(n+=this.compile(t.children[1],e));break;case\"op_assign\":e?(i=this.getLHSCompiler(t.children[0]),Type.isArray(i)?n=\"$jc$.setProp(\"+i[0]+\", \"+i[1]+\", \"+this.compile(t.children[1],e)+\");\\n\":(this.isLocalVariable(i)!==this.scope&&(this.scope.locals[i]=!0),n=\"$jc$.scopes[\"+this.scope.id+\"].locals['\"+i+\"'] = \"+this.compile(t.children[1],e)+\";\\n\")):(i=this.compile(t.children[0]),n=i+\" = \"+this.compile(t.children[1],e)+\";\\n\");break;case\"op_if\":n=\" if (\"+this.compile(t.children[0],e)+\") \"+this.compile(t.children[1],e);break;case\"op_if_else\":n=\" if (\"+this.compile(t.children[0],e)+\")\"+this.compile(t.children[1],e),n+=\" else \"+this.compile(t.children[2],e);break;case\"op_conditional\":n=\"((\"+this.compile(t.children[0],e)+\")?(\"+this.compile(t.children[1],e),n+=\"):(\"+this.compile(t.children[2],e)+\"))\";break;case\"op_while\":n=\" while (\"+this.compile(t.children[0],e)+\") {\\n\"+this.compile(t.children[1],e)+\"}\\n\";break;case\"op_do\":n=\" do {\\n\"+this.compile(t.children[0],e)+\"} while (\"+this.compile(t.children[1],e)+\");\\n\";break;case\"op_for\":n=\" for (\"+this.compile(t.children[0],e)+\"; \"+this.compile(t.children[1],e)+\"; \"+this.compile(t.children[2],e)+\") {\\n\"+this.compile(t.children[3],e)+\"\\n}\\n\";break;case\"op_proplst\":t.children[0]&&(n=this.compile(t.children[0],e)+\", \"),n+=this.compile(t.children[1],e);break;case\"op_prop\":n=t.children[0]+\": \"+this.compile(t.children[1],e);break;case\"op_emptyobject\":n=e?\"{}\":\"<< >>\";break;case\"op_proplst_val\":n=this.compile(t.children[0],e);break;case\"op_array\":for(s=[],r=0;r<t.children[0].length;r++)s.push(this.compile(t.children[0][r]),e);n=\"[\"+s.join(\", \")+\"]\";break;case\"op_extvalue\":n=this.compile(t.children[0],e)+\"[\"+this.compile(t.children[1],e)+\"]\";break;case\"op_return\":n=\" return \"+this.compile(t.children[0],e)+\";\\n\";break;case\"op_map\":t.children[1].isMath||this._error(\"In a map only function calls and mathematical expressions are allowed.\"),s=t.children[0],n=e?\" $jc$.makeMap(function (\"+s.join(\", \")+\") { return \"+this.compile(t.children[1],e)+\"; })\":\"map (\"+s.join(\", \")+\") -> \"+this.compile(t.children[1],e);break;case\"op_function\":s=t.children[0],o=this.pushScope(s),n=e?this.functionCodeJS(t):\" function (\"+s.join(\", \")+\") \"+this.compile(t.children[1],e),this.popScope();break;case\"op_execfunmath\":console.log(\"TODO\"),n=\"-1\";break;case\"op_execfun\":if(t.children[2]){for(s=[],r=0;r<t.children[2].length;r++)s.push(this.compile(t.children[2][r],e));e&&(i=\"$jc$.mergeAttributes(\"+s.join(\", \")+\")\")}for(t.children[0].withProps=!!t.children[2],s=[],r=0;r<t.children[1].length;r++)s.push(this.compile(t.children[1][r],e));n=this.compile(t.children[0],e)+\"(\"+s.join(\", \")+(t.children[2]&&e?\", \"+i:\"\")+\")\"+(t.children[2]&&!e?i:\"\"),e&&\"$\"===t.children[0].value&&(n=\"$jc$.board.objects[\"+this.compile(t.children[1][0],e)+\"]\");break;case\"op_property\":n=e&&\"X\"!==t.children[1]&&\"Y\"!==t.children[1]?\"$jc$.resolveProperty(\"+this.compile(t.children[0],e)+\", '\"+t.children[1]+\"', true)\":this.compile(t.children[0],e)+\".\"+t.children[1];break;case\"op_use\":this._warn(\"Use of the 'use' operator is deprecated.\"),n=e?\"$jc$.use('\":\"use('\",n+=t.children[0].toString()+\"');\";break;case\"op_delete\":this._warn(\"Use of the 'delete' operator is deprecated. Please use the remove() function.\"),n=e?\"$jc$.del(\":\"remove(\",n+=this.compile(t.children[0],e)+\")\";break;case\"op_equ\":n=\"(\"+this.compile(t.children[0],e)+\" == \"+this.compile(t.children[1],e)+\")\";break;case\"op_neq\":n=\"(\"+this.compile(t.children[0],e)+\" != \"+this.compile(t.children[1],e)+\")\";break;case\"op_approx\":n=\"(\"+this.compile(t.children[0],e)+\" ~= \"+this.compile(t.children[1],e)+\")\";break;case\"op_grt\":n=\"(\"+this.compile(t.children[0],e)+\" > \"+this.compile(t.children[1],e)+\")\";break;case\"op_lot\":n=\"(\"+this.compile(t.children[0],e)+\" < \"+this.compile(t.children[1],e)+\")\";break;case\"op_gre\":n=\"(\"+this.compile(t.children[0],e)+\" >= \"+this.compile(t.children[1],e)+\")\";break;case\"op_loe\":n=\"(\"+this.compile(t.children[0],e)+\" <= \"+this.compile(t.children[1],e)+\")\";break;case\"op_or\":n=\"(\"+this.compile(t.children[0],e)+\" || \"+this.compile(t.children[1],e)+\")\";break;case\"op_and\":n=\"(\"+this.compile(t.children[0],e)+\" && \"+this.compile(t.children[1],e)+\")\";break;case\"op_not\":n=\"!(\"+this.compile(t.children[0],e)+\")\";break;case\"op_add\":n=e?\"$jc$.add(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\")\":\"(\"+this.compile(t.children[0],e)+\" + \"+this.compile(t.children[1],e)+\")\";break;case\"op_sub\":n=e?\"$jc$.sub(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\")\":\"(\"+this.compile(t.children[0],e)+\" - \"+this.compile(t.children[1],e)+\")\";break;case\"op_div\":n=e?\"$jc$.div(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\")\":\"(\"+this.compile(t.children[0],e)+\" / \"+this.compile(t.children[1],e)+\")\";break;case\"op_mod\":n=e?\"$jc$.mod(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\", true)\":\"(\"+this.compile(t.children[0],e)+\" % \"+this.compile(t.children[1],e)+\")\";break;case\"op_mul\":n=e?\"$jc$.mul(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\")\":\"(\"+this.compile(t.children[0],e)+\" * \"+this.compile(t.children[1],e)+\")\";break;case\"op_exp\":n=e?\"$jc$.pow(\"+this.compile(t.children[0],e)+\", \"+this.compile(t.children[1],e)+\")\":\"(\"+this.compile(t.children[0],e)+\"^\"+this.compile(t.children[1],e)+\")\";break;case\"op_neg\":n=\"(-\"+this.compile(t.children[0],e)+\")\"}break;case\"node_var\":n=e?this.getvarJS(t.value,!1,t.withProps):t.value;break;case\"node_const\":n=t.value;break;case\"node_const_bool\":n=t.value;break;case\"node_str\":n=\"'\"+t.value+\"'\"}return t.needsBrackets&&(n=\"{\\n\"+n+\"}\\n\"),n},X:function(t){return t.X()},Y:function(t){return t.Y()},V:function(t){return t.Value()},L:function(t){return t.L()},dist:function(t,e){return Type.exists(t)&&Type.exists(t.Dist)||this._error(\"Error: Can't calculate distance.\"),t.Dist(e)},add:function(t,e){var i,r,s;if(t=Type.evalSlider(t),e=Type.evalSlider(e),Type.isArray(t)&&Type.isArray(e))for(r=Math.min(t.length,e.length),s=[],i=0;r>i;i++)s[i]=t[i]+e[i];else Type.isNumber(t)&&Type.isNumber(e)?s=t+e:Type.isString(t)||Type.isString(e)?s=t.toString()+e.toString():this._error(\"Operation + not defined on operands \"+typeof t+\" and \"+typeof e);return s},sub:function(t,e){var i,r,s;if(t=Type.evalSlider(t),e=Type.evalSlider(e),Type.isArray(t)&&Type.isArray(e))for(r=Math.min(t.length,e.length),s=[],i=0;r>i;i++)s[i]=t[i]-e[i];else Type.isNumber(t)&&Type.isNumber(e)?s=t-e:this._error(\"Operation - not defined on operands \"+typeof t+\" and \"+typeof e);return s},mul:function(t,e){var i,r,s;if(t=Type.evalSlider(t),e=Type.evalSlider(e),Type.isArray(t)&&Type.isNumber(e)&&(i=t,t=e,e=t),Type.isArray(t)&&Type.isArray(e))r=Math.min(t.length,e.length),s=Mat.innerProduct(t,e,r);else if(Type.isNumber(t)&&Type.isArray(e))for(r=e.length,s=[],i=0;r>i;i++)s[i]=t*e[i];else Type.isNumber(t)&&Type.isNumber(e)?s=t*e:this._error(\"Operation * not defined on operands \"+typeof t+\" and \"+typeof e);return s},div:function(t,e){var i,r,s;if(t=Type.evalSlider(t),e=Type.evalSlider(e),Type.isArray(t)&&Type.isNumber(e))for(r=t.length,s=[],i=0;r>i;i++)s[i]=t[i]/e;else Type.isNumber(t)&&Type.isNumber(e)?s=t/e:this._error(\"Operation * not defined on operands \"+typeof t+\" and \"+typeof e);return s},mod:function(t,e){var i,r,s;if(t=Type.evalSlider(t),e=Type.evalSlider(e),Type.isArray(t)&&Type.isNumber(e))for(r=t.length,s=[],i=0;r>i;i++)s[i]=Mat.mod(t[i],e,!0);else Type.isNumber(t)&&Type.isNumber(e)?s=Mat.mod(t,e,!0):this._error(\"Operation * not defined on operands \"+typeof t+\" and \"+typeof e);return s},pow:function(t,e){return t=Type.evalSlider(t),e=Type.evalSlider(e),Math.pow(t,e)},ifthen:function(t,e,i){return t?e:i},del:function(t){\"object\"==typeof t&&JXG.exists(t.type)&&JXG.exists(t.elementClass)&&this.board.removeObject(t)},use:function(t){var e,i,r=!1;if(\"string\"==typeof t){for(e in JXG.boards)if(JXG.boards.hasOwnProperty(e)&&JXG.boards[e].container===t){i=JXG.boards[e],r=!0;break}}else i=t,r=!0;r?(this.board=i,this.builtIn.$board=i,this.builtIn.$board.src=\"$jc$.board\"):this._error(\"Board '\"+t+\"' not found!\")},findSymbol:function(t,e){var i,r;for(e=Type.def(e,-1),r=-1===e?this.scope:this.scopes[e];null!==r;){for(i in r.locals)if(r.locals.hasOwnProperty(i)&&r.locals[i]===t)return[i,r];r=r.previous}return[]},importModule:function(t){return priv.modules[t.toLowerCase()]},defineBuiltIn:function(){var t=this,e={PI:Math.PI,EULER:Math.E,X:t.X,Y:t.Y,V:t.V,L:t.L,dist:t.dist,rad:Geometry.rad,deg:Geometry.trueAngle,factorial:Mat.factorial,trunc:Type.trunc,ln:Math.log,log10:Mat.log10,lg:Mat.log10,log2:Mat.log2,lb:Mat.log2,ld:Mat.log2,IfThen:t.ifthen,\"import\":t.importModule,use:t.use,remove:t.del,$:t.getElementById,$board:t.board,$log:t.log};return e.rad.sc=Geometry,e.deg.sc=Geometry,e.factorial.sc=Mat,e.X.src=\"$jc$.X\",e.Y.src=\"$jc$.Y\",e.V.src=\"$jc$.V\",e.L.src=\"$jc$.L\",e.dist.src=\"$jc$.dist\",e.rad.src=\"JXG.Math.Geometry.rad\",e.deg.src=\"JXG.Math.Geometry.trueAngle\",e.factorial.src=\"JXG.Math.factorial\",e.trunc.src=\"JXG.trunc\",e.ln.src=\"Math.log\",e.log10.src=\"JXG.Math.log10\",e.lg.src=\"JXG.Math.log10\",e.log2.src=\"JXG.Math.log2\",e.lb.src=\"JXG.Math.log2\",e.ld.src=\"JXG.Math.log2\",e[\"import\"].src=\"$jc$.importModule\",e.use.src=\"$jc$.use\",e.remove.src=\"$jc$.del\",e.IfThen.src=\"$jc$.ifthen\",e.$.src=\"(function (n) { return $jc$.board.select(n); })\",e.$board&&(e.$board.src=\"$jc$.board\"),e.$log.src=\"$jc$.log\",e},_debug:function(t){\"object\"==typeof console?console.log(t):Env.isBrowser&&document&&null!==document.getElementById(\"debug\")&&(document.getElementById(\"debug\").innerHTML+=t+\"<br />\")},_error:function(t){var e=new Error(\"Error(\"+this.line+\"): \"+t);throw e.line=this.line,e},_warn:function(t){\"object\"==typeof console?console.log(\"Warning(\"+this.line+\"): \"+t):Env.isBrowser&&document&&null!==document.getElementById(this.warnLog)&&(document.getElementById(this.warnLog).innerHTML+=\"Warning(\"+this.line+\"): \"+t+\"<br />\")},_log:function(t){\"object\"!=typeof window&&\"object\"==typeof self&&self.postMessage?self.postMessage({type:\"log\",msg:\"Log: \"+t.toString()}):console.log(\"Log: \",arguments)}});var parser=function(){function t(){this.yy={}}var e={trace:function(){},yy:{},symbols_:{error:2,Program:3,StatementList:4,EOF:5,IfStatement:6,IF:7,\"(\":8,Expression:9,\")\":10,Statement:11,ELSE:12,LoopStatement:13,WHILE:14,FOR:15,\";\":16,DO:17,UnaryStatement:18,USE:19,IDENTIFIER:20,DELETE:21,ReturnStatement:22,RETURN:23,EmptyStatement:24,StatementBlock:25,\"{\":26,\"}\":27,ExpressionStatement:28,AssignmentExpression:29,ConditionalExpression:30,LeftHandSideExpression:31,\"=\":32,LogicalORExpression:33,\"?\":34,\":\":35,LogicalANDExpression:36,\"||\":37,EqualityExpression:38,\"&&\":39,RelationalExpression:40,\"==\":41,\"!=\":42,\"~=\":43,AdditiveExpression:44,\"<\":45,\">\":46,\"<=\":47,\">=\":48,MultiplicativeExpression:49,\"+\":50,\"-\":51,UnaryExpression:52,\"*\":53,\"/\":54,\"%\":55,ExponentExpression:56,\"^\":57,\"!\":58,MemberExpression:59,CallExpression:60,PrimaryExpression:61,FunctionExpression:62,MapExpression:63,\".\":64,\"[\":65,\"]\":66,BasicLiteral:67,ObjectLiteral:68,ArrayLiteral:69,NullLiteral:70,BooleanLiteral:71,StringLiteral:72,NumberLiteral:73,NULL:74,TRUE:75,FALSE:76,STRING:77,NUMBER:78,NAN:79,INFINITY:80,ElementList:81,\"<<\":82,\">>\":83,PropertyList:84,Property:85,\",\":86,PropertyName:87,Arguments:88,AttributeList:89,Attribute:90,FUNCTION:91,ParameterDefinitionList:92,MAP:93,\"->\":94,$accept:0,$end:1},terminals_:{2:\"error\",5:\"EOF\",7:\"IF\",8:\"(\",10:\")\",12:\"ELSE\",14:\"WHILE\",15:\"FOR\",16:\";\",17:\"DO\",19:\"USE\",20:\"IDENTIFIER\",21:\"DELETE\",23:\"RETURN\",26:\"{\",27:\"}\",32:\"=\",34:\"?\",35:\":\",37:\"||\",39:\"&&\",41:\"==\",42:\"!=\",43:\"~=\",45:\"<\",46:\">\",47:\"<=\",48:\">=\",50:\"+\",51:\"-\",53:\"*\",54:\"/\",55:\"%\",57:\"^\",58:\"!\",64:\".\",65:\"[\",66:\"]\",74:\"NULL\",75:\"TRUE\",76:\"FALSE\",77:\"STRING\",78:\"NUMBER\",79:\"NAN\",80:\"INFINITY\",82:\"<<\",83:\">>\",86:\",\",91:\"FUNCTION\",93:\"MAP\",94:\"->\"},productions_:[0,[3,2],[6,5],[6,7],[13,5],[13,9],[13,7],[18,2],[18,2],[22,2],[22,3],[24,1],[25,3],[4,2],[4,0],[11,1],[11,1],[11,1],[11,1],[11,1],[11,1],[11,1],[28,2],[9,1],[29,1],[29,3],[30,1],[30,5],[33,1],[33,3],[36,1],[36,3],[38,1],[38,3],[38,3],[38,3],[40,1],[40,3],[40,3],[40,3],[40,3],[44,1],[44,3],[44,3],[49,1],[49,3],[49,3],[49,3],[56,1],[56,3],[52,1],[52,2],[52,2],[52,2],[31,1],[31,1],[59,1],[59,1],[59,1],[59,3],[59,4],[61,1],[61,1],[61,1],[61,1],[61,3],[67,1],[67,1],[67,1],[67,1],[70,1],[71,1],[71,1],[72,1],[73,1],[73,1],[73,1],[69,2],[69,3],[68,2],[68,3],[84,1],[84,3],[85,3],[87,1],[87,1],[87,1],[60,2],[60,3],[60,2],[60,4],[60,3],[88,2],[88,3],[89,1],[89,3],[90,1],[90,1],[81,1],[81,3],[62,4],[62,5],[63,6],[92,1],[92,3]],performAction:function(t,e,s,o,n,a,h){var l=a.length-1;switch(n){case 1:return a[l-1];case 2:this.$=i.createNode(r(h[l-4]),\"node_op\",\"op_if\",a[l-2],a[l]);break;case 3:this.$=i.createNode(r(h[l-6]),\"node_op\",\"op_if_else\",a[l-4],a[l-2],a[l]);break;case 4:this.$=i.createNode(r(h[l-4]),\"node_op\",\"op_while\",a[l-2],a[l]);break;case 5:this.$=i.createNode(r(h[l-8]),\"node_op\",\"op_for\",a[l-6],a[l-4],a[l-2],a[l]);break;case 6:this.$=i.createNode(r(h[l-6]),\"node_op\",\"op_do\",a[l-5],a[l-2]);break;case 7:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_use\",a[l]);break;case 8:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_delete\",a[l]);break;case 9:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_return\",void 0);break;case 10:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_return\",a[l-1]);break;case 11:this.$=i.createNode(r(h[l]),\"node_op\",\"op_none\");break;case 12:this.$=a[l-1],this.$.needsBrackets=!0;break;case 13:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_none\",a[l-1],a[l]);break;case 14:this.$=i.createNode(r(h[l]),\"node_op\",\"op_none\");break;case 15:this.$=a[l];break;case 16:this.$=a[l];break;case 17:this.$=a[l];break;case 18:this.$=a[l];break;case 19:this.$=a[l];break;case 20:this.$=a[l];break;case 21:this.$=a[l];break;case 22:this.$=a[l-1];break;case 23:this.$=a[l];break;case 24:this.$=a[l];break;case 25:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_assign\",a[l-2],a[l]),this.$.isMath=!1;break;case 26:this.$=a[l];break;case 27:this.$=i.createNode(r(h[l-4]),\"node_op\",\"op_conditional\",a[l-4],a[l-2],a[l]),this.$.isMath=!1;break;case 28:this.$=a[l];break;case 29:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_or\",a[l-2],a[l]),this.$.isMath=!1;break;case 30:this.$=a[l];break;case 31:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_and\",a[l-2],a[l]),this.$.isMath=!1;break;case 32:this.$=a[l];break;case 33:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_equ\",a[l-2],a[l]),this.$.isMath=!1;break;case 34:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_neq\",a[l-2],a[l]),this.$.isMath=!1;break;case 35:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_approx\",a[l-2],a[l]),this.$.isMath=!1;break;case 36:this.$=a[l];break;case 37:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_lot\",a[l-2],a[l]),this.$.isMath=!1;break;case 38:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_grt\",a[l-2],a[l]),this.$.isMath=!1;break;case 39:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_loe\",a[l-2],a[l]),this.$.isMath=!1;break;case 40:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_gre\",a[l-2],a[l]),this.$.isMath=!1;break;case 41:this.$=a[l];break;case 42:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_add\",a[l-2],a[l]),this.$.isMath=!0;break;case 43:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_sub\",a[l-2],a[l]),this.$.isMath=!0;break;case 44:this.$=a[l];break;case 45:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_mul\",a[l-2],a[l]),this.$.isMath=!0;break;case 46:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_div\",a[l-2],a[l]),this.$.isMath=!0;break;case 47:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_mod\",a[l-2],a[l]),this.$.isMath=!0;break;case 48:this.$=a[l];break;case 49:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_exp\",a[l-2],a[l]),this.$.isMath=!0;break;case 50:this.$=a[l];break;case 51:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_not\",a[l]),this.$.isMath=!1;break;case 52:this.$=a[l];break;case 53:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_neg\",a[l]),this.$.isMath=!0;break;case 54:this.$=a[l];break;case 55:this.$=a[l];break;case 56:this.$=a[l];break;case 57:this.$=a[l],this.$.isMath=!1;break;case 58:this.$=a[l];break;case 59:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_property\",a[l-2],a[l]),this.$.isMath=!0;break;case 60:this.$=i.createNode(r(h[l-3]),\"node_op\",\"op_extvalue\",a[l-3],a[l-1]),this.$.isMath=!0;break;case 61:this.$=i.createNode(r(h[l]),\"node_var\",a[l]);break;case 62:this.$=a[l];break;case 63:this.$=a[l],this.$.isMath=!1;break;case 64:this.$=a[l],this.$.isMath=!1;break;case 65:this.$=a[l-1];break;case 66:this.$=a[l],this.$.isMath=!1;break;case 67:this.$=a[l],this.$.isMath=!1;break;case 68:this.$=a[l],this.$.isMath=!1;break;case 69:this.$=a[l],this.$.isMath=!0;break;case 70:this.$=i.createNode(r(h[l]),\"node_const\",null);break;case 71:this.$=i.createNode(r(h[l]),\"node_const_bool\",!0);break;case 72:this.$=i.createNode(r(h[l]),\"node_const_bool\",!1);break;case 73:this.$=i.createNode(r(h[l]),\"node_str\",a[l].substring(1,a[l].length-1));break;case 74:this.$=i.createNode(r(h[l]),\"node_const\",parseFloat(a[l]));break;case 75:this.$=i.createNode(r(h[l]),\"node_const\",0/0);break;case 76:this.$=i.createNode(r(h[l]),\"node_const\",1/0);break;case 77:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_array\",[]);break;case 78:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_array\",a[l-1]);break;case 79:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_emptyobject\",{});break;case 80:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_proplst_val\",a[l-1]);break;case 81:this.$=a[l];break;case 82:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_proplst\",a[l-2],a[l]);break;case 83:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_prop\",a[l-2],a[l]);break;case 84:this.$=a[l];break;case 85:this.$=a[l];break;case 86:this.$=a[l];break;case 87:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_execfun\",a[l-1],a[l]),this.$.isMath=!0;break;case 88:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_execfun\",a[l-2],a[l-1],a[l],!0),this.$.isMath=!1;break;case 89:this.$=i.createNode(r(h[l-1]),\"node_op\",\"op_execfun\",a[l-1],a[l]),this.$.isMath=!0;break;case 90:this.$=i.createNode(r(h[l-3]),\"node_op\",\"op_extvalue\",a[l-3],a[l-1]),this.$.isMath=!0;break;case 91:this.$=i.createNode(r(h[l-2]),\"node_op\",\"op_property\",a[l-2],a[l]),this.$.isMath=!0;break;case 92:this.$=[];break;case 93:this.$=a[l-1];break;case 94:this.$=[a[l]];break;case 95:this.$=a[l-2].concat(a[l]);break;case 96:this.$=i.createNode(r(h[l]),\"node_var\",a[l]),this.$.isMath=!0;break;case 97:this.$=a[l],this.$.isMath=!1;break;case 98:this.$=[a[l]];break;case 99:this.$=a[l-2].concat(a[l]);break;case 100:this.$=i.createNode(r(h[l-3]),\"node_op\",\"op_function\",[],a[l]),this.$.isMath=!1;break;case 101:this.$=i.createNode(r(h[l-4]),\"node_op\",\"op_function\",a[l-2],a[l]),this.$.isMath=!1;break;case 102:this.$=i.createNode(r(h[l-5]),\"node_op\",\"op_map\",a[l-3],a[l]);break;case 103:this.$=[a[l]];break;case 104:this.$=a[l-2].concat(a[l])}},table:[{3:1,4:2,5:[2,14],7:[2,14],8:[2,14],14:[2,14],15:[2,14],16:[2,14],17:[2,14],19:[2,14],20:[2,14],21:[2,14],23:[2,14],26:[2,14],50:[2,14],51:[2,14],58:[2,14],65:[2,14],74:[2,14],75:[2,14],76:[2,14],77:[2,14],78:[2,14],79:[2,14],80:[2,14],82:[2,14],91:[2,14],93:[2,14]},{1:[3]},{5:[1,3],6:6,7:[1,13],8:[1,37],9:20,11:4,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{1:[2,1]},{5:[2,13],7:[2,13],8:[2,13],14:[2,13],15:[2,13],16:[2,13],17:[2,13],19:[2,13],20:[2,13],21:[2,13],23:[2,13],26:[2,13],27:[2,13],50:[2,13],51:[2,13],58:[2,13],65:[2,13],74:[2,13],75:[2,13],76:[2,13],77:[2,13],78:[2,13],79:[2,13],80:[2,13],82:[2,13],91:[2,13],93:[2,13]},{5:[2,15],7:[2,15],8:[2,15],12:[2,15],14:[2,15],15:[2,15],16:[2,15],17:[2,15],19:[2,15],20:[2,15],21:[2,15],23:[2,15],26:[2,15],27:[2,15],50:[2,15],51:[2,15],58:[2,15],65:[2,15],74:[2,15],75:[2,15],76:[2,15],77:[2,15],78:[2,15],79:[2,15],80:[2,15],82:[2,15],91:[2,15],93:[2,15]},{5:[2,16],7:[2,16],8:[2,16],12:[2,16],14:[2,16],15:[2,16],16:[2,16],17:[2,16],19:[2,16],20:[2,16],21:[2,16],23:[2,16],26:[2,16],27:[2,16],50:[2,16],51:[2,16],58:[2,16],65:[2,16],74:[2,16],75:[2,16],76:[2,16],77:[2,16],78:[2,16],79:[2,16],80:[2,16],82:[2,16],91:[2,16],93:[2,16]},{5:[2,17],7:[2,17],8:[2,17],12:[2,17],14:[2,17],15:[2,17],16:[2,17],17:[2,17],19:[2,17],20:[2,17],21:[2,17],23:[2,17],26:[2,17],27:[2,17],50:[2,17],51:[2,17],58:[2,17],65:[2,17],74:[2,17],75:[2,17],76:[2,17],77:[2,17],78:[2,17],79:[2,17],80:[2,17],82:[2,17],91:[2,17],93:[2,17]},{5:[2,18],7:[2,18],8:[2,18],12:[2,18],14:[2,18],15:[2,18],16:[2,18],17:[2,18],19:[2,18],20:[2,18],21:[2,18],23:[2,18],26:[2,18],27:[2,18],50:[2,18],51:[2,18],58:[2,18],65:[2,18],74:[2,18],75:[2,18],76:[2,18],77:[2,18],78:[2,18],79:[2,18],80:[2,18],82:[2,18],91:[2,18],93:[2,18]},{5:[2,19],7:[2,19],8:[2,19],12:[2,19],14:[2,19],15:[2,19],16:[2,19],17:[2,19],19:[2,19],20:[2,19],21:[2,19],23:[2,19],26:[2,19],27:[2,19],50:[2,19],51:[2,19],58:[2,19],65:[2,19],74:[2,19],75:[2,19],76:[2,19],77:[2,19],78:[2,19],79:[2,19],80:[2,19],82:[2,19],91:[2,19],93:[2,19]},{5:[2,20],7:[2,20],8:[2,20],12:[2,20],14:[2,20],15:[2,20],16:[2,20],17:[2,20],19:[2,20],20:[2,20],21:[2,20],23:[2,20],26:[2,20],27:[2,20],50:[2,20],51:[2,20],58:[2,20],65:[2,20],74:[2,20],75:[2,20],76:[2,20],77:[2,20],78:[2,20],79:[2,20],80:[2,20],82:[2,20],91:[2,20],93:[2,20]},{5:[2,21],7:[2,21],8:[2,21],12:[2,21],14:[2,21],15:[2,21],16:[2,21],17:[2,21],19:[2,21],20:[2,21],21:[2,21],23:[2,21],26:[2,21],27:[2,21],50:[2,21],51:[2,21],58:[2,21],65:[2,21],74:[2,21],75:[2,21],76:[2,21],77:[2,21],78:[2,21],79:[2,21],80:[2,21],82:[2,21],91:[2,21],93:[2,21]},{4:61,7:[2,14],8:[2,14],14:[2,14],15:[2,14],16:[2,14],17:[2,14],19:[2,14],20:[2,14],21:[2,14],23:[2,14],26:[2,14],27:[2,14],50:[2,14],51:[2,14],58:[2,14],65:[2,14],74:[2,14],75:[2,14],76:[2,14],77:[2,14],78:[2,14],79:[2,14],80:[2,14],82:[2,14],91:[2,14],93:[2,14]},{8:[1,62]},{8:[1,63]},{8:[1,64]},{6:6,7:[1,13],8:[1,37],9:20,11:65,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{20:[1,66]},{20:[1,67]},{8:[1,37],9:69,16:[1,68],20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{16:[1,70]},{5:[2,11],7:[2,11],8:[2,11],12:[2,11],14:[2,11],15:[2,11],16:[2,11],17:[2,11],19:[2,11],20:[2,11],21:[2,11],23:[2,11],26:[2,11],27:[2,11],50:[2,11],51:[2,11],58:[2,11],65:[2,11],74:[2,11],75:[2,11],76:[2,11],77:[2,11],78:[2,11],79:[2,11],80:[2,11],82:[2,11],91:[2,11],93:[2,11]},{8:[2,23],10:[2,23],16:[2,23],32:[2,23],34:[2,23],35:[2,23],37:[2,23],39:[2,23],41:[2,23],42:[2,23],43:[2,23],45:[2,23],46:[2,23],47:[2,23],48:[2,23],50:[2,23],51:[2,23],53:[2,23],54:[2,23],55:[2,23],57:[2,23],64:[2,23],65:[2,23],66:[2,23],83:[2,23],86:[2,23]},{8:[2,24],10:[2,24],16:[2,24],32:[2,24],34:[2,24],35:[2,24],37:[2,24],39:[2,24],41:[2,24],42:[2,24],43:[2,24],45:[2,24],46:[2,24],47:[2,24],48:[2,24],50:[2,24],51:[2,24],53:[2,24],54:[2,24],55:[2,24],57:[2,24],64:[2,24],65:[2,24],66:[2,24],83:[2,24],86:[2,24]},{8:[2,48],10:[2,48],16:[2,48],32:[1,71],34:[2,48],35:[2,48],37:[2,48],39:[2,48],41:[2,48],42:[2,48],43:[2,48],45:[2,48],46:[2,48],47:[2,48],48:[2,48],50:[2,48],51:[2,48],53:[2,48],54:[2,48],55:[2,48],57:[1,72],64:[2,48],65:[2,48],66:[2,48],83:[2,48],86:[2,48]},{8:[2,26],10:[2,26],16:[2,26],32:[2,26],34:[1,73],35:[2,26],37:[1,74],39:[2,26],41:[2,26],42:[2,26],43:[2,26],45:[2,26],46:[2,26],47:[2,26],48:[2,26],50:[2,26],51:[2,26],53:[2,26],54:[2,26],55:[2,26],57:[2,26],64:[2,26],65:[2,26],66:[2,26],83:[2,26],86:[2,26]},{8:[1,78],10:[2,54],16:[2,54],32:[2,54],34:[2,54],35:[2,54],37:[2,54],39:[2,54],41:[2,54],42:[2,54],43:[2,54],45:[2,54],46:[2,54],47:[2,54],48:[2,54],50:[2,54],51:[2,54],53:[2,54],54:[2,54],55:[2,54],57:[2,54],64:[1,75],65:[1,76],66:[2,54],83:[2,54],86:[2,54],88:77},{8:[1,78],10:[2,55],16:[2,55],32:[2,55],34:[2,55],35:[2,55],37:[2,55],39:[2,55],41:[2,55],42:[2,55],43:[2,55],45:[2,55],46:[2,55],47:[2,55],48:[2,55],50:[2,55],51:[2,55],53:[2,55],54:[2,55],55:[2,55],57:[2,55],64:[1,81],65:[1,80],66:[2,55],83:[2,55],86:[2,55],88:79},{8:[2,28],10:[2,28],16:[2,28],32:[2,28],34:[2,28],35:[2,28],37:[2,28],39:[1,82],41:[2,28],42:[2,28],43:[2,28],45:[2,28],46:[2,28],47:[2,28],48:[2,28],50:[2,28],51:[2,28],53:[2,28],54:[2,28],55:[2,28],57:[2,28],64:[2,28],65:[2,28],66:[2,28],83:[2,28],86:[2,28]},{8:[2,56],10:[2,56],16:[2,56],32:[2,56],34:[2,56],35:[2,56],37:[2,56],39:[2,56],41:[2,56],42:[2,56],43:[2,56],45:[2,56],46:[2,56],47:[2,56],48:[2,56],50:[2,56],51:[2,56],53:[2,56],54:[2,56],55:[2,56],57:[2,56],64:[2,56],65:[2,56],66:[2,56],83:[2,56],86:[2,56]},{8:[2,57],10:[2,57],16:[2,57],32:[2,57],34:[2,57],35:[2,57],37:[2,57],39:[2,57],41:[2,57],42:[2,57],43:[2,57],45:[2,57],46:[2,57],47:[2,57],48:[2,57],50:[2,57],51:[2,57],53:[2,57],54:[2,57],55:[2,57],57:[2,57],64:[2,57],65:[2,57],66:[2,57],83:[2,57],86:[2,57]},{8:[2,58],10:[2,58],16:[2,58],32:[2,58],34:[2,58],35:[2,58],37:[2,58],39:[2,58],41:[2,58],42:[2,58],43:[2,58],45:[2,58],46:[2,58],47:[2,58],48:[2,58],50:[2,58],51:[2,58],53:[2,58],54:[2,58],55:[2,58],57:[2,58],64:[2,58],65:[2,58],66:[2,58],83:[2,58],86:[2,58]},{8:[2,30],10:[2,30],16:[2,30],32:[2,30],34:[2,30],35:[2,30],37:[2,30],39:[2,30],41:[1,83],42:[1,84],43:[1,85],45:[2,30],46:[2,30],47:[2,30],48:[2,30],50:[2,30],51:[2,30],53:[2,30],54:[2,30],55:[2,30],57:[2,30],64:[2,30],65:[2,30],66:[2,30],83:[2,30],86:[2,30]},{8:[2,61],10:[2,61],16:[2,61],32:[2,61],34:[2,61],35:[2,61],37:[2,61],39:[2,61],41:[2,61],42:[2,61],43:[2,61],45:[2,61],46:[2,61],47:[2,61],48:[2,61],50:[2,61],51:[2,61],53:[2,61],54:[2,61],55:[2,61],57:[2,61],64:[2,61],65:[2,61],66:[2,61],83:[2,61],86:[2,61]},{8:[2,62],10:[2,62],16:[2,62],32:[2,62],34:[2,62],35:[2,62],37:[2,62],39:[2,62],41:[2,62],42:[2,62],43:[2,62],45:[2,62],46:[2,62],47:[2,62],48:[2,62],50:[2,62],51:[2,62],53:[2,62],54:[2,62],55:[2,62],57:[2,62],64:[2,62],65:[2,62],66:[2,62],83:[2,62],86:[2,62]},{8:[2,63],10:[2,63],16:[2,63],32:[2,63],34:[2,63],35:[2,63],37:[2,63],39:[2,63],41:[2,63],42:[2,63],43:[2,63],45:[2,63],46:[2,63],47:[2,63],48:[2,63],50:[2,63],51:[2,63],53:[2,63],54:[2,63],55:[2,63],57:[2,63],64:[2,63],65:[2,63],66:[2,63],83:[2,63],86:[2,63]},{8:[2,64],10:[2,64],16:[2,64],32:[2,64],34:[2,64],35:[2,64],37:[2,64],39:[2,64],41:[2,64],42:[2,64],43:[2,64],45:[2,64],46:[2,64],47:[2,64],48:[2,64],50:[2,64],51:[2,64],53:[2,64],54:[2,64],55:[2,64],57:[2,64],64:[2,64],65:[2,64],66:[2,64],83:[2,64],86:[2,64]},{8:[1,37],9:86,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,87]},{8:[1,88]},{8:[2,32],10:[2,32],16:[2,32],32:[2,32],34:[2,32],35:[2,32],37:[2,32],39:[2,32],41:[2,32],42:[2,32],43:[2,32],45:[1,89],46:[1,90],47:[1,91],48:[1,92],50:[2,32],51:[2,32],53:[2,32],54:[2,32],55:[2,32],57:[2,32],64:[2,32],65:[2,32],66:[2,32],83:[2,32],86:[2,32]},{8:[2,66],10:[2,66],16:[2,66],32:[2,66],34:[2,66],35:[2,66],37:[2,66],39:[2,66],41:[2,66],42:[2,66],43:[2,66],45:[2,66],46:[2,66],47:[2,66],48:[2,66],50:[2,66],51:[2,66],53:[2,66],54:[2,66],55:[2,66],57:[2,66],64:[2,66],65:[2,66],66:[2,66],83:[2,66],86:[2,66]},{8:[2,67],10:[2,67],16:[2,67],32:[2,67],34:[2,67],35:[2,67],37:[2,67],39:[2,67],41:[2,67],42:[2,67],43:[2,67],45:[2,67],46:[2,67],47:[2,67],48:[2,67],50:[2,67],51:[2,67],53:[2,67],54:[2,67],55:[2,67],57:[2,67],64:[2,67],65:[2,67],66:[2,67],83:[2,67],86:[2,67]},{8:[2,68],10:[2,68],16:[2,68],32:[2,68],34:[2,68],35:[2,68],37:[2,68],39:[2,68],41:[2,68],42:[2,68],43:[2,68],45:[2,68],46:[2,68],47:[2,68],48:[2,68],50:[2,68],51:[2,68],53:[2,68],54:[2,68],55:[2,68],57:[2,68],64:[2,68],65:[2,68],66:[2,68],83:[2,68],86:[2,68]},{8:[2,69],10:[2,69],16:[2,69],32:[2,69],34:[2,69],35:[2,69],37:[2,69],39:[2,69],41:[2,69],42:[2,69],43:[2,69],45:[2,69],46:[2,69],47:[2,69],48:[2,69],50:[2,69],51:[2,69],53:[2,69],54:[2,69],55:[2,69],57:[2,69],64:[2,69],65:[2,69],66:[2,69],83:[2,69],86:[2,69]},{20:[1,97],72:98,73:99,77:[1,51],78:[1,52],79:[1,53],80:[1,54],83:[1,93],84:94,85:95,87:96},{8:[1,37],20:[1,33],29:102,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],66:[1,100],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],81:101,82:[1,45],91:[1,38],93:[1,39]},{8:[2,36],10:[2,36],16:[2,36],32:[2,36],34:[2,36],35:[2,36],37:[2,36],39:[2,36],41:[2,36],42:[2,36],43:[2,36],45:[2,36],46:[2,36],47:[2,36],48:[2,36],50:[1,103],51:[1,104],53:[2,36],54:[2,36],55:[2,36],57:[2,36],64:[2,36],65:[2,36],66:[2,36],83:[2,36],86:[2,36]},{8:[2,70],10:[2,70],16:[2,70],32:[2,70],34:[2,70],35:[2,70],37:[2,70],39:[2,70],41:[2,70],42:[2,70],43:[2,70],45:[2,70],46:[2,70],47:[2,70],48:[2,70],50:[2,70],51:[2,70],53:[2,70],54:[2,70],55:[2,70],57:[2,70],64:[2,70],65:[2,70],66:[2,70],83:[2,70],86:[2,70]},{8:[2,71],10:[2,71],16:[2,71],32:[2,71],34:[2,71],35:[2,71],37:[2,71],39:[2,71],41:[2,71],42:[2,71],43:[2,71],45:[2,71],46:[2,71],47:[2,71],48:[2,71],50:[2,71],51:[2,71],53:[2,71],54:[2,71],55:[2,71],57:[2,71],64:[2,71],65:[2,71],66:[2,71],83:[2,71],86:[2,71]},{8:[2,72],10:[2,72],16:[2,72],32:[2,72],34:[2,72],35:[2,72],37:[2,72],39:[2,72],41:[2,72],42:[2,72],43:[2,72],45:[2,72],46:[2,72],47:[2,72],48:[2,72],50:[2,72],51:[2,72],53:[2,72],54:[2,72],55:[2,72],57:[2,72],64:[2,72],65:[2,72],66:[2,72],83:[2,72],86:[2,72]},{8:[2,73],10:[2,73],16:[2,73],32:[2,73],34:[2,73],35:[2,73],37:[2,73],39:[2,73],41:[2,73],42:[2,73],43:[2,73],45:[2,73],46:[2,73],47:[2,73],48:[2,73],50:[2,73],51:[2,73],53:[2,73],54:[2,73],55:[2,73],57:[2,73],64:[2,73],65:[2,73],66:[2,73],83:[2,73],86:[2,73]},{8:[2,74],10:[2,74],16:[2,74],32:[2,74],34:[2,74],35:[2,74],37:[2,74],39:[2,74],41:[2,74],42:[2,74],43:[2,74],45:[2,74],46:[2,74],47:[2,74],48:[2,74],50:[2,74],51:[2,74],53:[2,74],54:[2,74],55:[2,74],57:[2,74],64:[2,74],65:[2,74],66:[2,74],83:[2,74],86:[2,74]},{8:[2,75],10:[2,75],16:[2,75],32:[2,75],34:[2,75],35:[2,75],37:[2,75],39:[2,75],41:[2,75],42:[2,75],43:[2,75],45:[2,75],46:[2,75],47:[2,75],48:[2,75],50:[2,75],51:[2,75],53:[2,75],54:[2,75],55:[2,75],57:[2,75],64:[2,75],65:[2,75],66:[2,75],83:[2,75],86:[2,75]},{8:[2,76],10:[2,76],16:[2,76],32:[2,76],34:[2,76],35:[2,76],37:[2,76],39:[2,76],41:[2,76],42:[2,76],43:[2,76],45:[2,76],46:[2,76],47:[2,76],48:[2,76],50:[2,76],51:[2,76],53:[2,76],54:[2,76],55:[2,76],57:[2,76],64:[2,76],65:[2,76],66:[2,76],83:[2,76],86:[2,76]},{8:[2,41],10:[2,41],16:[2,41],32:[2,41],34:[2,41],35:[2,41],37:[2,41],39:[2,41],41:[2,41],42:[2,41],43:[2,41],45:[2,41],46:[2,41],47:[2,41],48:[2,41],50:[2,41],51:[2,41],53:[1,105],54:[1,106],55:[1,107],57:[2,41],64:[2,41],65:[2,41],66:[2,41],83:[2,41],86:[2,41]},{8:[2,44],10:[2,44],16:[2,44],32:[2,44],34:[2,44],35:[2,44],37:[2,44],39:[2,44],41:[2,44],42:[2,44],43:[2,44],45:[2,44],46:[2,44],47:[2,44],48:[2,44],50:[2,44],51:[2,44],53:[2,44],54:[2,44],55:[2,44],57:[2,44],64:[2,44],65:[2,44],66:[2,44],83:[2,44],86:[2,44]},{8:[2,50],10:[2,50],16:[2,50],32:[2,50],34:[2,50],35:[2,50],37:[2,50],39:[2,50],41:[2,50],42:[2,50],43:[2,50],45:[2,50],46:[2,50],47:[2,50],48:[2,50],50:[2,50],51:[2,50],53:[2,50],54:[2,50],55:[2,50],57:[2,50],64:[2,50],65:[2,50],66:[2,50],83:[2,50],86:[2,50]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:108,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:110,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:111,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{6:6,7:[1,13],8:[1,37],9:20,11:4,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],27:[1,112],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:113,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:114,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:115,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{14:[1,116]},{5:[2,7],7:[2,7],8:[2,7],12:[2,7],14:[2,7],15:[2,7],16:[2,7],17:[2,7],19:[2,7],20:[2,7],21:[2,7],23:[2,7],26:[2,7],27:[2,7],50:[2,7],51:[2,7],58:[2,7],65:[2,7],74:[2,7],75:[2,7],76:[2,7],77:[2,7],78:[2,7],79:[2,7],80:[2,7],82:[2,7],91:[2,7],93:[2,7]},{5:[2,8],7:[2,8],8:[2,8],12:[2,8],14:[2,8],15:[2,8],16:[2,8],17:[2,8],19:[2,8],20:[2,8],21:[2,8],23:[2,8],26:[2,8],27:[2,8],50:[2,8],51:[2,8],58:[2,8],65:[2,8],74:[2,8],75:[2,8],76:[2,8],77:[2,8],78:[2,8],79:[2,8],80:[2,8],82:[2,8],91:[2,8],93:[2,8]},{5:[2,9],7:[2,9],8:[2,9],12:[2,9],14:[2,9],15:[2,9],16:[2,9],17:[2,9],19:[2,9],20:[2,9],21:[2,9],23:[2,9],26:[2,9],27:[2,9],50:[2,9],51:[2,9],58:[2,9],65:[2,9],74:[2,9],75:[2,9],76:[2,9],77:[2,9],78:[2,9],79:[2,9],80:[2,9],82:[2,9],91:[2,9],93:[2,9]},{16:[1,117]},{5:[2,22],7:[2,22],8:[2,22],12:[2,22],14:[2,22],15:[2,22],16:[2,22],17:[2,22],19:[2,22],20:[2,22],21:[2,22],23:[2,22],26:[2,22],27:[2,22],50:[2,22],51:[2,22],58:[2,22],65:[2,22],74:[2,22],75:[2,22],76:[2,22],77:[2,22],78:[2,22],79:[2,22],80:[2,22],82:[2,22],91:[2,22],93:[2,22]},{8:[1,37],20:[1,33],29:118,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:119,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],29:120,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,36:121,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{20:[1,122]},{8:[1,37],9:123,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,87],10:[2,87],16:[2,87],20:[1,126],32:[2,87],34:[2,87],35:[2,87],37:[2,87],39:[2,87],41:[2,87],42:[2,87],43:[2,87],45:[2,87],46:[2,87],47:[2,87],48:[2,87],50:[2,87],51:[2,87],53:[2,87],54:[2,87],55:[2,87],57:[2,87],64:[2,87],65:[2,87],66:[2,87],68:127,82:[1,45],83:[2,87],86:[2,87],89:124,90:125},{8:[1,37],10:[1,128],20:[1,33],29:102,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],81:129,82:[1,45],91:[1,38],93:[1,39]},{8:[2,89],10:[2,89],16:[2,89],32:[2,89],34:[2,89],35:[2,89],37:[2,89],39:[2,89],41:[2,89],42:[2,89],43:[2,89],45:[2,89],46:[2,89],47:[2,89],48:[2,89],50:[2,89],51:[2,89],53:[2,89],54:[2,89],55:[2,89],57:[2,89],64:[2,89],65:[2,89],66:[2,89],83:[2,89],86:[2,89]},{8:[1,37],9:130,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{20:[1,131]},{8:[1,37],20:[1,33],31:109,38:132,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,40:133,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,40:134,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,40:135,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{10:[1,136]},{10:[1,137],20:[1,139],92:138},{20:[1,139],92:140},{8:[1,37],20:[1,33],31:109,44:141,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,44:142,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,44:143,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,44:144,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,79],10:[2,79],16:[2,79],32:[2,79],34:[2,79],35:[2,79],37:[2,79],39:[2,79],41:[2,79],42:[2,79],43:[2,79],45:[2,79],46:[2,79],47:[2,79],48:[2,79],50:[2,79],51:[2,79],53:[2,79],54:[2,79],55:[2,79],57:[2,79],64:[2,79],65:[2,79],66:[2,79],83:[2,79],86:[2,79]},{83:[1,145],86:[1,146]},{83:[2,81],86:[2,81]},{35:[1,147]},{35:[2,84]},{35:[2,85]},{35:[2,86]},{8:[2,77],10:[2,77],16:[2,77],32:[2,77],34:[2,77],35:[2,77],37:[2,77],39:[2,77],41:[2,77],42:[2,77],43:[2,77],45:[2,77],46:[2,77],47:[2,77],48:[2,77],50:[2,77],51:[2,77],53:[2,77],54:[2,77],55:[2,77],57:[2,77],64:[2,77],65:[2,77],66:[2,77],83:[2,77],86:[2,77]},{66:[1,148],86:[1,149]},{10:[2,98],66:[2,98],86:[2,98]},{8:[1,37],20:[1,33],31:109,49:150,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,49:151,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:152,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:153,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],31:109,50:[1,59],51:[1,60],52:154,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,51],10:[2,51],16:[2,51],32:[2,51],34:[2,51],35:[2,51],37:[2,51],39:[2,51],41:[2,51],42:[2,51],43:[2,51],45:[2,51],46:[2,51],47:[2,51],48:[2,51],50:[2,51],51:[2,51],53:[2,51],54:[2,51],55:[2,51],57:[2,51],64:[2,51],65:[2,51],66:[2,51],83:[2,51],86:[2,51]},{8:[2,48],10:[2,48],16:[2,48],32:[2,48],34:[2,48],35:[2,48],37:[2,48],39:[2,48],41:[2,48],42:[2,48],43:[2,48],45:[2,48],46:[2,48],47:[2,48],48:[2,48],50:[2,48],51:[2,48],53:[2,48],54:[2,48],55:[2,48],57:[1,72],64:[2,48],65:[2,48],66:[2,48],83:[2,48],86:[2,48]},{8:[2,52],10:[2,52],16:[2,52],32:[2,52],34:[2,52],35:[2,52],37:[2,52],39:[2,52],41:[2,52],42:[2,52],43:[2,52],45:[2,52],46:[2,52],47:[2,52],48:[2,52],50:[2,52],51:[2,52],53:[2,52],54:[2,52],55:[2,52],57:[2,52],64:[2,52],65:[2,52],66:[2,52],83:[2,52],86:[2,52]},{8:[2,53],10:[2,53],16:[2,53],32:[2,53],34:[2,53],35:[2,53],37:[2,53],39:[2,53],41:[2,53],42:[2,53],43:[2,53],45:[2,53],46:[2,53],47:[2,53],48:[2,53],50:[2,53],51:[2,53],53:[2,53],54:[2,53],55:[2,53],57:[2,53],64:[2,53],65:[2,53],66:[2,53],83:[2,53],86:[2,53]},{5:[2,12],7:[2,12],8:[2,12],10:[2,12],12:[2,12],14:[2,12],15:[2,12],16:[2,12],17:[2,12],19:[2,12],20:[2,12],21:[2,12],23:[2,12],26:[2,12],27:[2,12],32:[2,12],34:[2,12],35:[2,12],37:[2,12],39:[2,12],41:[2,12],42:[2,12],43:[2,12],45:[2,12],46:[2,12],47:[2,12],48:[2,12],50:[2,12],51:[2,12],53:[2,12],54:[2,12],55:[2,12],57:[2,12],58:[2,12],64:[2,12],65:[2,12],66:[2,12],74:[2,12],75:[2,12],76:[2,12],77:[2,12],78:[2,12],79:[2,12],80:[2,12],82:[2,12],83:[2,12],86:[2,12],91:[2,12],93:[2,12]},{10:[1,155]},{10:[1,156]},{16:[1,157]},{8:[1,158]},{5:[2,10],7:[2,10],8:[2,10],12:[2,10],14:[2,10],15:[2,10],16:[2,10],17:[2,10],19:[2,10],20:[2,10],21:[2,10],23:[2,10],26:[2,10],27:[2,10],50:[2,10],51:[2,10],58:[2,10],65:[2,10],74:[2,10],75:[2,10],76:[2,10],77:[2,10],78:[2,10],79:[2,10],80:[2,10],82:[2,10],91:[2,10],93:[2,10]},{8:[2,25],10:[2,25],16:[2,25],32:[2,25],34:[2,25],35:[2,25],37:[2,25],39:[2,25],41:[2,25],42:[2,25],43:[2,25],45:[2,25],46:[2,25],47:[2,25],48:[2,25],50:[2,25],51:[2,25],53:[2,25],54:[2,25],55:[2,25],57:[2,25],64:[2,25],65:[2,25],66:[2,25],83:[2,25],86:[2,25]},{8:[2,49],10:[2,49],16:[2,49],32:[2,49],34:[2,49],35:[2,49],37:[2,49],39:[2,49],41:[2,49],42:[2,49],43:[2,49],45:[2,49],46:[2,49],47:[2,49],48:[2,49],50:[2,49],51:[2,49],53:[2,49],54:[2,49],55:[2,49],57:[2,49],64:[2,49],65:[2,49],66:[2,49],83:[2,49],86:[2,49]},{35:[1,159]},{8:[2,29],10:[2,29],16:[2,29],32:[2,29],34:[2,29],35:[2,29],37:[2,29],39:[1,82],41:[2,29],42:[2,29],43:[2,29],45:[2,29],46:[2,29],47:[2,29],48:[2,29],50:[2,29],51:[2,29],53:[2,29],54:[2,29],55:[2,29],57:[2,29],64:[2,29],65:[2,29],66:[2,29],83:[2,29],86:[2,29]},{8:[2,59],10:[2,59],16:[2,59],32:[2,59],34:[2,59],35:[2,59],37:[2,59],39:[2,59],41:[2,59],42:[2,59],43:[2,59],45:[2,59],46:[2,59],47:[2,59],48:[2,59],50:[2,59],51:[2,59],53:[2,59],54:[2,59],55:[2,59],57:[2,59],64:[2,59],65:[2,59],66:[2,59],83:[2,59],86:[2,59]},{66:[1,160]},{8:[2,88],10:[2,88],16:[2,88],32:[2,88],34:[2,88],35:[2,88],37:[2,88],39:[2,88],41:[2,88],42:[2,88],43:[2,88],45:[2,88],46:[2,88],47:[2,88],48:[2,88],50:[2,88],51:[2,88],53:[2,88],54:[2,88],55:[2,88],57:[2,88],64:[2,88],65:[2,88],66:[2,88],83:[2,88],86:[1,161]},{8:[2,94],10:[2,94],16:[2,94],32:[2,94],34:[2,94],35:[2,94],37:[2,94],39:[2,94],41:[2,94],42:[2,94],43:[2,94],45:[2,94],46:[2,94],47:[2,94],48:[2,94],50:[2,94],51:[2,94],53:[2,94],54:[2,94],55:[2,94],57:[2,94],64:[2,94],65:[2,94],66:[2,94],83:[2,94],86:[2,94]},{8:[2,96],10:[2,96],16:[2,96],32:[2,96],34:[2,96],35:[2,96],37:[2,96],39:[2,96],41:[2,96],42:[2,96],43:[2,96],45:[2,96],46:[2,96],47:[2,96],48:[2,96],50:[2,96],51:[2,96],53:[2,96],54:[2,96],55:[2,96],57:[2,96],64:[2,96],65:[2,96],66:[2,96],83:[2,96],86:[2,96]},{8:[2,97],10:[2,97],16:[2,97],32:[2,97],34:[2,97],35:[2,97],37:[2,97],39:[2,97],41:[2,97],42:[2,97],43:[2,97],45:[2,97],46:[2,97],47:[2,97],48:[2,97],50:[2,97],51:[2,97],53:[2,97],54:[2,97],55:[2,97],57:[2,97],64:[2,97],65:[2,97],66:[2,97],83:[2,97],86:[2,97]},{8:[2,92],10:[2,92],16:[2,92],20:[2,92],32:[2,92],34:[2,92],35:[2,92],37:[2,92],39:[2,92],41:[2,92],42:[2,92],43:[2,92],45:[2,92],46:[2,92],47:[2,92],48:[2,92],50:[2,92],51:[2,92],53:[2,92],54:[2,92],55:[2,92],57:[2,92],64:[2,92],65:[2,92],66:[2,92],82:[2,92],83:[2,92],86:[2,92]},{10:[1,162],86:[1,149]},{66:[1,163]},{8:[2,91],10:[2,91],16:[2,91],32:[2,91],34:[2,91],35:[2,91],37:[2,91],39:[2,91],41:[2,91],42:[2,91],43:[2,91],45:[2,91],46:[2,91],47:[2,91],48:[2,91],50:[2,91],51:[2,91],53:[2,91],54:[2,91],55:[2,91],57:[2,91],64:[2,91],65:[2,91],66:[2,91],83:[2,91],86:[2,91]},{8:[2,31],10:[2,31],16:[2,31],32:[2,31],34:[2,31],35:[2,31],37:[2,31],39:[2,31],41:[1,83],42:[1,84],43:[1,85],45:[2,31],46:[2,31],47:[2,31],48:[2,31],50:[2,31],51:[2,31],53:[2,31],54:[2,31],55:[2,31],57:[2,31],64:[2,31],65:[2,31],66:[2,31],83:[2,31],86:[2,31]},{8:[2,33],10:[2,33],16:[2,33],32:[2,33],34:[2,33],35:[2,33],37:[2,33],39:[2,33],41:[2,33],42:[2,33],43:[2,33],45:[1,89],46:[1,90],47:[1,91],48:[1,92],50:[2,33],51:[2,33],53:[2,33],54:[2,33],55:[2,33],57:[2,33],64:[2,33],65:[2,33],66:[2,33],83:[2,33],86:[2,33]},{8:[2,34],10:[2,34],16:[2,34],32:[2,34],34:[2,34],35:[2,34],37:[2,34],39:[2,34],41:[2,34],42:[2,34],43:[2,34],45:[1,89],46:[1,90],47:[1,91],48:[1,92],50:[2,34],51:[2,34],53:[2,34],54:[2,34],55:[2,34],57:[2,34],64:[2,34],65:[2,34],66:[2,34],83:[2,34],86:[2,34]},{8:[2,35],10:[2,35],16:[2,35],32:[2,35],34:[2,35],35:[2,35],37:[2,35],39:[2,35],41:[2,35],42:[2,35],43:[2,35],45:[1,89],46:[1,90],47:[1,91],48:[1,92],50:[2,35],51:[2,35],53:[2,35],54:[2,35],55:[2,35],57:[2,35],64:[2,35],65:[2,35],66:[2,35],83:[2,35],86:[2,35]},{8:[2,65],10:[2,65],16:[2,65],32:[2,65],34:[2,65],35:[2,65],37:[2,65],39:[2,65],41:[2,65],42:[2,65],43:[2,65],45:[2,65],46:[2,65],47:[2,65],48:[2,65],50:[2,65],51:[2,65],53:[2,65],54:[2,65],55:[2,65],57:[2,65],64:[2,65],65:[2,65],66:[2,65],83:[2,65],86:[2,65]},{25:164,26:[1,12]},{10:[1,165],86:[1,166]},{10:[2,103],86:[2,103]},{10:[1,167],86:[1,166]},{8:[2,37],10:[2,37],16:[2,37],32:[2,37],34:[2,37],35:[2,37],37:[2,37],39:[2,37],41:[2,37],42:[2,37],43:[2,37],45:[2,37],46:[2,37],47:[2,37],48:[2,37],50:[1,103],51:[1,104],53:[2,37],54:[2,37],55:[2,37],57:[2,37],64:[2,37],65:[2,37],66:[2,37],83:[2,37],86:[2,37]},{8:[2,38],10:[2,38],16:[2,38],32:[2,38],34:[2,38],35:[2,38],37:[2,38],39:[2,38],41:[2,38],42:[2,38],43:[2,38],45:[2,38],46:[2,38],47:[2,38],48:[2,38],50:[1,103],51:[1,104],53:[2,38],54:[2,38],55:[2,38],57:[2,38],64:[2,38],65:[2,38],66:[2,38],83:[2,38],86:[2,38]},{8:[2,39],10:[2,39],16:[2,39],32:[2,39],34:[2,39],35:[2,39],37:[2,39],39:[2,39],41:[2,39],42:[2,39],43:[2,39],45:[2,39],46:[2,39],47:[2,39],48:[2,39],50:[1,103],51:[1,104],53:[2,39],54:[2,39],55:[2,39],57:[2,39],64:[2,39],65:[2,39],66:[2,39],83:[2,39],86:[2,39]},{8:[2,40],10:[2,40],16:[2,40],32:[2,40],34:[2,40],35:[2,40],37:[2,40],39:[2,40],41:[2,40],42:[2,40],43:[2,40],45:[2,40],46:[2,40],47:[2,40],48:[2,40],50:[1,103],51:[1,104],53:[2,40],54:[2,40],55:[2,40],57:[2,40],64:[2,40],65:[2,40],66:[2,40],83:[2,40],86:[2,40]},{8:[2,80],10:[2,80],16:[2,80],32:[2,80],34:[2,80],35:[2,80],37:[2,80],39:[2,80],41:[2,80],42:[2,80],43:[2,80],45:[2,80],46:[2,80],47:[2,80],48:[2,80],50:[2,80],51:[2,80],53:[2,80],54:[2,80],55:[2,80],57:[2,80],64:[2,80],65:[2,80],66:[2,80],83:[2,80],86:[2,80]},{20:[1,97],72:98,73:99,77:[1,51],78:[1,52],79:[1,53],80:[1,54],85:168,87:96},{8:[1,37],20:[1,33],29:169,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,78],10:[2,78],16:[2,78],32:[2,78],34:[2,78],35:[2,78],37:[2,78],39:[2,78],41:[2,78],42:[2,78],43:[2,78],45:[2,78],46:[2,78],47:[2,78],48:[2,78],50:[2,78],51:[2,78],53:[2,78],54:[2,78],55:[2,78],57:[2,78],64:[2,78],65:[2,78],66:[2,78],83:[2,78],86:[2,78]},{8:[1,37],20:[1,33],29:170,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,42],10:[2,42],16:[2,42],32:[2,42],34:[2,42],35:[2,42],37:[2,42],39:[2,42],41:[2,42],42:[2,42],43:[2,42],45:[2,42],46:[2,42],47:[2,42],48:[2,42],50:[2,42],51:[2,42],53:[1,105],54:[1,106],55:[1,107],57:[2,42],64:[2,42],65:[2,42],66:[2,42],83:[2,42],86:[2,42]},{8:[2,43],10:[2,43],16:[2,43],32:[2,43],34:[2,43],35:[2,43],37:[2,43],39:[2,43],41:[2,43],42:[2,43],43:[2,43],45:[2,43],46:[2,43],47:[2,43],48:[2,43],50:[2,43],51:[2,43],53:[1,105],54:[1,106],55:[1,107],57:[2,43],64:[2,43],65:[2,43],66:[2,43],83:[2,43],86:[2,43]},{8:[2,45],10:[2,45],16:[2,45],32:[2,45],34:[2,45],35:[2,45],37:[2,45],39:[2,45],41:[2,45],42:[2,45],43:[2,45],45:[2,45],46:[2,45],47:[2,45],48:[2,45],50:[2,45],51:[2,45],53:[2,45],54:[2,45],55:[2,45],57:[2,45],64:[2,45],65:[2,45],66:[2,45],83:[2,45],86:[2,45]},{8:[2,46],10:[2,46],16:[2,46],32:[2,46],34:[2,46],35:[2,46],37:[2,46],39:[2,46],41:[2,46],42:[2,46],43:[2,46],45:[2,46],46:[2,46],47:[2,46],48:[2,46],50:[2,46],51:[2,46],53:[2,46],54:[2,46],55:[2,46],57:[2,46],64:[2,46],65:[2,46],66:[2,46],83:[2,46],86:[2,46]},{8:[2,47],10:[2,47],16:[2,47],32:[2,47],34:[2,47],35:[2,47],37:[2,47],39:[2,47],41:[2,47],42:[2,47],43:[2,47],45:[2,47],46:[2,47],47:[2,47],48:[2,47],50:[2,47],51:[2,47],53:[2,47],54:[2,47],55:[2,47],57:[2,47],64:[2,47],65:[2,47],66:[2,47],83:[2,47],86:[2,47]},{6:6,7:[1,13],8:[1,37],9:20,11:171,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{6:6,7:[1,13],8:[1,37],9:20,11:172,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:173,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:174,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],20:[1,33],29:175,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[2,60],10:[2,60],16:[2,60],32:[2,60],34:[2,60],35:[2,60],37:[2,60],39:[2,60],41:[2,60],42:[2,60],43:[2,60],45:[2,60],46:[2,60],47:[2,60],48:[2,60],50:[2,60],51:[2,60],53:[2,60],54:[2,60],55:[2,60],57:[2,60],64:[2,60],65:[2,60],66:[2,60],83:[2,60],86:[2,60]},{20:[1,126],68:127,82:[1,45],90:176},{8:[2,93],10:[2,93],16:[2,93],20:[2,93],32:[2,93],34:[2,93],35:[2,93],37:[2,93],39:[2,93],41:[2,93],42:[2,93],43:[2,93],45:[2,93],46:[2,93],47:[2,93],48:[2,93],50:[2,93],51:[2,93],53:[2,93],54:[2,93],55:[2,93],57:[2,93],64:[2,93],65:[2,93],66:[2,93],82:[2,93],83:[2,93],86:[2,93]},{8:[2,90],10:[2,90],16:[2,90],32:[2,90],34:[2,90],35:[2,90],37:[2,90],39:[2,90],41:[2,90],42:[2,90],43:[2,90],45:[2,90],46:[2,90],47:[2,90],48:[2,90],50:[2,90],51:[2,90],53:[2,90],54:[2,90],55:[2,90],57:[2,90],64:[2,90],65:[2,90],66:[2,90],83:[2,90],86:[2,90]},{8:[2,100],10:[2,100],16:[2,100],32:[2,100],34:[2,100],35:[2,100],37:[2,100],39:[2,100],41:[2,100],42:[2,100],43:[2,100],45:[2,100],46:[2,100],47:[2,100],48:[2,100],50:[2,100],51:[2,100],53:[2,100],54:[2,100],55:[2,100],57:[2,100],64:[2,100],65:[2,100],66:[2,100],83:[2,100],86:[2,100]},{25:177,26:[1,12]},{20:[1,178]},{94:[1,179]},{83:[2,82],86:[2,82]},{83:[2,83],86:[2,83]},{10:[2,99],66:[2,99],86:[2,99]},{5:[2,2],7:[2,2],8:[2,2],12:[1,180],14:[2,2],15:[2,2],16:[2,2],17:[2,2],19:[2,2],20:[2,2],21:[2,2],23:[2,2],26:[2,2],27:[2,2],50:[2,2],51:[2,2],58:[2,2],65:[2,2],74:[2,2],75:[2,2],76:[2,2],77:[2,2],78:[2,2],79:[2,2],80:[2,2],82:[2,2],91:[2,2],93:[2,2]},{5:[2,4],7:[2,4],8:[2,4],12:[2,4],14:[2,4],15:[2,4],16:[2,4],17:[2,4],19:[2,4],20:[2,4],21:[2,4],23:[2,4],26:[2,4],27:[2,4],50:[2,4],51:[2,4],58:[2,4],65:[2,4],74:[2,4],75:[2,4],76:[2,4],77:[2,4],78:[2,4],79:[2,4],80:[2,4],82:[2,4],91:[2,4],93:[2,4]},{16:[1,181]},{10:[1,182]},{8:[2,27],10:[2,27],16:[2,27],32:[2,27],34:[2,27],35:[2,27],37:[2,27],39:[2,27],41:[2,27],42:[2,27],43:[2,27],45:[2,27],46:[2,27],47:[2,27],48:[2,27],50:[2,27],51:[2,27],53:[2,27],54:[2,27],55:[2,27],57:[2,27],64:[2,27],65:[2,27],66:[2,27],83:[2,27],86:[2,27]},{8:[2,95],10:[2,95],16:[2,95],32:[2,95],34:[2,95],35:[2,95],37:[2,95],39:[2,95],41:[2,95],42:[2,95],43:[2,95],45:[2,95],46:[2,95],47:[2,95],48:[2,95],50:[2,95],51:[2,95],53:[2,95],54:[2,95],55:[2,95],57:[2,95],64:[2,95],65:[2,95],66:[2,95],83:[2,95],86:[2,95]},{8:[2,101],10:[2,101],16:[2,101],32:[2,101],34:[2,101],35:[2,101],37:[2,101],39:[2,101],41:[2,101],42:[2,101],43:[2,101],45:[2,101],46:[2,101],47:[2,101],48:[2,101],50:[2,101],51:[2,101],53:[2,101],54:[2,101],55:[2,101],57:[2,101],64:[2,101],65:[2,101],66:[2,101],83:[2,101],86:[2,101]},{10:[2,104],86:[2,104]},{8:[1,37],9:183,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{6:6,7:[1,13],8:[1,37],9:20,11:184,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{8:[1,37],9:185,20:[1,33],29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{16:[1,186]},{8:[2,102],10:[2,102],16:[2,102],32:[2,102],34:[2,102],35:[2,102],37:[2,102],39:[2,102],41:[2,102],42:[2,102],43:[2,102],45:[2,102],46:[2,102],47:[2,102],48:[2,102],50:[2,102],51:[2,102],53:[2,102],54:[2,102],55:[2,102],57:[2,102],64:[2,102],65:[2,102],66:[2,102],83:[2,102],86:[2,102]},{5:[2,3],7:[2,3],8:[2,3],12:[2,3],14:[2,3],15:[2,3],16:[2,3],17:[2,3],19:[2,3],20:[2,3],21:[2,3],23:[2,3],26:[2,3],27:[2,3],50:[2,3],51:[2,3],58:[2,3],65:[2,3],74:[2,3],75:[2,3],76:[2,3],77:[2,3],78:[2,3],79:[2,3],80:[2,3],82:[2,3],91:[2,3],93:[2,3]},{10:[1,187]},{5:[2,6],7:[2,6],8:[2,6],12:[2,6],14:[2,6],15:[2,6],16:[2,6],17:[2,6],19:[2,6],20:[2,6],21:[2,6],23:[2,6],26:[2,6],27:[2,6],50:[2,6],51:[2,6],58:[2,6],65:[2,6],74:[2,6],75:[2,6],76:[2,6],77:[2,6],78:[2,6],79:[2,6],80:[2,6],82:[2,6],91:[2,6],93:[2,6]},{6:6,7:[1,13],8:[1,37],9:20,11:188,13:7,14:[1,14],15:[1,15],16:[1,21],17:[1,16],18:8,19:[1,17],20:[1,33],21:[1,18],22:9,23:[1,19],24:11,25:5,26:[1,12],28:10,29:22,30:23,31:24,33:25,36:28,38:32,40:40,44:47,49:55,50:[1,59],51:[1,60],52:56,56:57,58:[1,58],59:26,60:27,61:29,62:30,63:31,65:[1,46],67:34,68:35,69:36,70:41,71:42,72:43,73:44,74:[1,48],75:[1,49],76:[1,50],77:[1,51],78:[1,52],79:[1,53],80:[1,54],82:[1,45],91:[1,38],93:[1,39]},{5:[2,5],7:[2,5],8:[2,5],12:[2,5],14:[2,5],15:[2,5],16:[2,5],17:[2,5],19:[2,5],20:[2,5],21:[2,5],23:[2,5],26:[2,5],27:[2,5],50:[2,5],51:[2,5],58:[2,5],65:[2,5],74:[2,5],75:[2,5],76:[2,5],77:[2,5],78:[2,5],79:[2,5],80:[2,5],82:[2,5],91:[2,5],93:[2,5]}],defaultActions:{3:[2,1],97:[2,84],98:[2,85],99:[2,86]},parseError:function(t,e){if(!e.recoverable)throw new Error(t);\nthis.trace(t)},parse:function(t){function e(){var t;return t=i.lexer.lex()||u,\"number\"!=typeof t&&(t=i.symbols_[t]||t),t}var i=this,r=[0],s=[null],o=[],n=this.table,a=\"\",h=0,l=0,c=0,d=2,u=1,p=o.slice.call(arguments,1);this.lexer.setInput(t),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,\"undefined\"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var f=this.lexer.yylloc;o.push(f);var m=this.lexer.options&&this.lexer.options.ranges;this.parseError=\"function\"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var b,g,v,C,y,P,_,S,E,O={};;){if(v=r[r.length-1],this.defaultActions[v]?C=this.defaultActions[v]:((null===b||\"undefined\"==typeof b)&&(b=e()),C=n[v]&&n[v][b]),\"undefined\"==typeof C||!C.length||!C[0]){var w=\"\";E=[];for(P in n[v])this.terminals_[P]&&P>d&&E.push(\"'\"+this.terminals_[P]+\"'\");w=this.lexer.showPosition?\"Parse error on line \"+(h+1)+\":\\n\"+this.lexer.showPosition()+\"\\nExpecting \"+E.join(\", \")+\", got '\"+(this.terminals_[b]||b)+\"'\":\"Parse error on line \"+(h+1)+\": Unexpected \"+(b==u?\"end of input\":\"'\"+(this.terminals_[b]||b)+\"'\"),this.parseError(w,{text:this.lexer.match,token:this.terminals_[b]||b,line:this.lexer.yylineno,loc:f,expected:E})}if(C[0]instanceof Array&&C.length>1)throw new Error(\"Parse Error: multiple actions possible at state: \"+v+\", token: \"+b);switch(C[0]){case 1:r.push(b),s.push(this.lexer.yytext),o.push(this.lexer.yylloc),r.push(C[1]),b=null,g?(b=g,g=null):(l=this.lexer.yyleng,a=this.lexer.yytext,h=this.lexer.yylineno,f=this.lexer.yylloc,c>0&&c--);break;case 2:if(_=this.productions_[C[1]][1],O.$=s[s.length-_],O._$={first_line:o[o.length-(_||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(_||1)].first_column,last_column:o[o.length-1].last_column},m&&(O._$.range=[o[o.length-(_||1)].range[0],o[o.length-1].range[1]]),y=this.performAction.apply(O,[a,l,h,this.yy,C[1],s,o].concat(p)),\"undefined\"!=typeof y)return y;_&&(r=r.slice(0,2*-1*_),s=s.slice(0,-1*_),o=o.slice(0,-1*_)),r.push(this.productions_[C[1]][0]),s.push(O.$),o.push(O._$),S=n[r[r.length-2]][r[r.length-1]],r.push(S);break;case 3:return!0}}return!0}},i={node:function(t,e,i){return{type:t,value:e,children:i}},createNode:function(t,e,i){var r,s=this.node(e,i,[]);for(r=3;r<arguments.length;r++)s.children.push(arguments[r]);return s.line=t[0],s.col=t[1],s.eline=t[2],s.ecol=t[3],s}},r=function(t){return[t.first_line,t.first_column,t.last_line,t.last_column]},s=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t){return this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=\"\",this.conditionStack=[\"INITIAL\"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var e=t.match(/(?:\\r\\n?|\\n).*/g);return e?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\\r\\n?|\\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e-1),this.offset-=e;var r=this.match.split(/(?:\\r\\n?|\\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===r.length?this.yylloc.first_column:0)+r[r.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError(\"Lexical error on line \"+(this.yylineno+1)+\". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n\"+this.showPosition(),{text:\"\",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?\"...\":\"\")+t.substr(-20).replace(/\\n/g,\"\")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?\"...\":\"\")).replace(/\\n/g,\"\")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join(\"-\");return t+this.upcomingInput()+\"\\n\"+e+\"^\"},test_match:function(t,e){var i,r,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),r=t[0].match(/(?:\\r\\n?|\\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\\r?\\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var o in s)this[o]=s[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,i,r;this._more||(this.yytext=\"\",this.match=\"\");for(var s=this._currentRules(),o=0;o<s.length;o++)if(i=this._input.match(this.rules[s[o]]),i&&(!e||i[0].length>e[0].length)){if(e=i,r=o,this.options.backtrack_lexer){if(t=this.test_match(i,s[o]),t!==!1)return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?(t=this.test_match(e,s[r]),t!==!1?t:!1):\"\"===this._input?this.EOF:this.parseError(\"Lexical error on line \"+(this.yylineno+1)+\". Unrecognized text.\\n\"+this.showPosition(),{text:\"\",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:\"INITIAL\"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,i,r){switch(i){case 0:break;case 1:return 78;case 2:return 78;case 3:return 77;case 4:return 77;case 5:break;case 6:break;case 7:return 7;case 8:return 12;case 9:return 14;case 10:return 17;case 11:return 15;case 12:return 91;case 13:return 93;case 14:return 19;case 15:return 23;case 16:return 21;case 17:return 75;case 18:return 76;case 19:return 74;case 20:return 80;case 21:return 94;case 22:return 82;case 23:return 83;case 24:return 26;case 25:return 27;case 26:return 16;case 27:return\"#\";case 28:return 34;case 29:return 35;case 30:return 79;case 31:return 64;case 32:return 65;case 33:return 66;case 34:return 8;case 35:return 10;case 36:return 58;case 37:return 57;case 38:return 53;case 39:return 54;case 40:return 55;case 41:return 50;case 42:return 51;case 43:return 47;case 44:return 45;case 45:return 48;case 46:return 46;case 47:return 41;case 48:return 43;case 49:return 42;case 50:return 39;case 51:return 37;case 52:return 32;case 53:return 86;case 54:return 5;case 55:return 20;case 56:return\"INVALID\"}},rules:[/^(?:\\s+)/,/^(?:[0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+\\b)/,/^(?:[0-9]+)/,/^(?:\"(\\\\[\"]|[^\"])*\")/,/^(?:'(\\\\[']|[^'])*')/,/^(?:\\/\\/.*)/,/^(?:\\/\\*(.|\\n|\\r)*?\\*\\/)/,/^(?:if\\b)/,/^(?:else\\b)/,/^(?:while\\b)/,/^(?:do\\b)/,/^(?:for\\b)/,/^(?:function\\b)/,/^(?:map\\b)/,/^(?:use\\b)/,/^(?:return\\b)/,/^(?:delete\\b)/,/^(?:true\\b)/,/^(?:false\\b)/,/^(?:null\\b)/,/^(?:Infinity\\b)/,/^(?:->)/,/^(?:<<)/,/^(?:>>)/,/^(?:\\{)/,/^(?:\\})/,/^(?:;)/,/^(?:#)/,/^(?:\\?)/,/^(?::)/,/^(?:NaN\\b)/,/^(?:\\.)/,/^(?:\\[)/,/^(?:\\])/,/^(?:\\()/,/^(?:\\))/,/^(?:!)/,/^(?:\\^)/,/^(?:\\*)/,/^(?:\\/)/,/^(?:%)/,/^(?:\\+)/,/^(?:-)/,/^(?:<=)/,/^(?:<)/,/^(?:>=)/,/^(?:>)/,/^(?:==)/,/^(?:~=)/,/^(?:!=)/,/^(?:&&)/,/^(?:\\|\\|)/,/^(?:=)/,/^(?:,)/,/^(?:$)/,/^(?:[A-Za-z_\\$][A-Za-z0-9_]*)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],inclusive:!0}}};return t}();return e.lexer=s,t.prototype=e,e.Parser=t,new t}();return\"undefined\"!=typeof require&&\"undefined\"!=typeof exports&&(exports.parser=parser,exports.Parser=parser.Parser,exports.parse=function(){return parser.parse.apply(parser,arguments)},exports.main=function(t){t[1]||(console.log(\"Usage: \"+t[0]+\" FILE\"),process.exit(1));var e=require(\"fs\").readFileSync(require(\"path\").normalize(t[1]),\"utf8\");return exports.parser.parse(e)},\"undefined\"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1))),parser.yy.parseError=parser.parseError,JXG.JessieCode}),define(\"base/ticks\",[\"jxg\",\"math/math\",\"math/geometry\",\"base/constants\",\"base/element\",\"base/coords\",\"utils/type\",\"base/text\"],function(t,e,i,r,s,o,n,a){return t.Ticks=function(t,i,s){if(this.constructor(t.board,s,r.OBJECT_TYPE_TICKS,r.OBJECT_CLASS_OTHER),this.line=t,this.board=this.line.board,this.ticksFunction=null,this.fixedTicks=null,this.equidistant=!1,n.isFunction(i))throw this.ticksFunction=i,new Error(\"Function arguments are no longer supported.\");n.isArray(i)?this.fixedTicks=i:((Math.abs(i)<e.eps||0>i)&&(i=s.defaultdistance),this.ticksFunction=function(){return i},this.equidistant=!0),this.minTicksDistance=s.minticksdistance,this.ticks=[],this.ticksDelta=1,this.labels=[],this.labelsRepo=[],this.labelCounter=0,this.id=this.line.addTicks(this),this.board.setId(this,\"Ti\")},t.Ticks.prototype=new s,t.extend(t.Ticks.prototype,{hasPoint:function(t,i){var s,o,n=this.ticks&&this.ticks.length||0,a=this.board.options.precision.hasPoint;if(!this.line.visProp.scalable)return!1;if(0!==this.line.stdform[1]&&0!==this.line.stdform[2]&&this.line.type!==r.OBJECT_TYPE_AXIS)return!1;for(s=0;n>s;s++)if(o=this.ticks[s],o[2]&&!(0===this.line.stdform[1]&&Math.abs(o[0][0]-this.line.point1.coords.scrCoords[1])<e.eps||0===this.line.stdform[2]&&Math.abs(o[1][0]-this.line.point1.coords.scrCoords[2])<e.eps)&&(Math.abs(o[0][0]-o[0][1])>=1||Math.abs(o[1][0]-o[1][1])>=1))if(0===this.line.stdform[1]){if(Math.abs(i-.5*(o[1][0]+o[1][1]))<2*a&&o[0][0]-a<t&&t<o[0][1]+a)return!0}else if(0===this.line.stdform[2]&&Math.abs(t-.5*(o[0][0]+o[0][1]))<2*a&&o[1][0]-a<i&&i<o[1][1]+a)return!0;return!1},setPositionDirectly:function(t,i,r){var s,n,a=new o(t,i,this.board),h=new o(t,r,this.board),l=this.board.getBoundingBox();return this.line.visProp.scalable?(Math.abs(this.line.stdform[1])<e.eps&&Math.abs(a.usrCoords[1]*h.usrCoords[1])>e.eps?(s=h.usrCoords[1]/a.usrCoords[1],l[0]*=s,l[2]*=s,this.board.setBoundingBox(l,!1)):Math.abs(this.line.stdform[2])<e.eps&&Math.abs(a.usrCoords[2]*h.usrCoords[2])>e.eps&&(n=h.usrCoords[2]/a.usrCoords[2],l[3]*=n,l[1]*=n,this.board.setBoundingBox(l,!1)),this):this},calculateTicksCoordinates:function(){var t,i,r,s=this.labelsRepo.length;if(this.setTicksSizeVariables(),!(Math.abs(this.dx)<e.eps&&Math.abs(this.dy)<e.eps))for(t=this.getZeroCoordinates(),i=this.getLowerAndUpperBounds(t),this.removeTickLabels(),this.ticks=[],this.labels=[],this.equidistant?this.generateEquidistantTicks(t,i):this.generateFixedTicks(t,i),r=s;r<this.labelsRepo.length;r++)this.labelsRepo[r].setAttribute({visible:!1})},setTicksSizeVariables:function(){var t,e=.5*this.visProp.majorheight,i=.5*this.visProp.minorheight;this.dxMaj=this.line.stdform[1],this.dyMaj=this.line.stdform[2],this.dxMin=this.dxMaj,this.dyMin=this.dyMaj,this.dx=this.dxMaj,this.dy=this.dyMaj,t=Math.sqrt(this.dxMaj*this.dxMaj*this.board.unitX*this.board.unitX+this.dyMaj*this.dyMaj*this.board.unitY*this.board.unitY),this.dxMaj*=e/t*this.board.unitX,this.dyMaj*=e/t*this.board.unitY,this.dxMin*=i/t*this.board.unitX,this.dyMin*=i/t*this.board.unitY,this.minStyle=\"finite\",this.visProp.minorheight<0&&(this.minStyle=\"infinite\"),this.majStyle=\"finite\",this.visProp.majorheight<0&&(this.majStyle=\"infinite\")},getZeroCoordinates:function(){return this.line.type===r.OBJECT_TYPE_AXIS?i.projectPointToLine({coords:{usrCoords:[1,0,0]}},this.line,this.board):\"right\"===this.visProp.anchor?this.line.point2.coords:\"middle\"===this.visProp.anchor?new o(r.COORDS_BY_USER,[(this.line.point1.coords.usrCoords[1]+this.line.point2.coords.usrCoords[1])/2,(this.line.point1.coords.usrCoords[2]+this.line.point2.coords.usrCoords[2])/2],this.board):this.line.point1.coords},getLowerAndUpperBounds:function(t){var s,n,a,h,l=new o(r.COORDS_BY_USER,this.line.point1.coords.usrCoords,this.board),c=new o(r.COORDS_BY_USER,this.line.point2.coords.usrCoords,this.board),d=Math.abs(l.usrCoords[0])>=e.eps&&l.scrCoords[1]>=0&&l.scrCoords[1]<=this.board.canvasWidth&&l.scrCoords[2]>=0&&l.scrCoords[2]<=this.board.canvasHeight,u=Math.abs(c.usrCoords[0])>=e.eps&&c.scrCoords[1]>=0&&c.scrCoords[1]<=this.board.canvasWidth&&c.scrCoords[2]>=0&&c.scrCoords[2]<=this.board.canvasHeight;return i.calcLineDelimitingPoints(this.line,l,c),a=this.getDistanceFromZero(t,l),h=this.getDistanceFromZero(t,c),h>a?(s=a,this.line.visProp.straightfirst||!d||this.visProp.includeboundaries||(s+=e.eps),n=h,this.line.visProp.straightlast||!u||this.visProp.includeboundaries||(n-=e.eps)):a>h?(s=h,this.line.visProp.straightlast||!u||this.visProp.includeboundaries||(s+=e.eps),n=a,this.line.visProp.straightfirst||!d||this.visProp.includeboundaries||(n-=e.eps)):(s=0,n=0),{lower:s,upper:n}},getDistanceFromZero:function(t,s){var o=t.distance(r.COORDS_BY_USER,s);return this.line.type===r.OBJECT_TYPE_AXIS?(t.usrCoords[1]>s.usrCoords[1]||Math.abs(t.usrCoords[1]-s.usrCoords[1])<e.eps&&t.usrCoords[2]>s.usrCoords[2])&&(o*=-1):\"right\"===this.visProp.anchor?i.isSameDirection(t,this.line.point1.coords,s)&&(o*=-1):i.isSameDirection(t,this.line.point2.coords,s)||(o*=-1),o},generateEquidistantTicks:function(t,i){var s,n=this.line.point1,a=(this.line.point2,this.getXandYdeltas()),h=n.coords.distance(r.COORDS_BY_SCREEN,new o(r.COORDS_BY_USER,[n.coords.usrCoords[1]+a.x,n.coords.usrCoords[2]+a.y],this.board)),l=this.equidistant?this.ticksFunction(1):this.ticksDelta;for(l*=this.visProp.scale,this.visProp.insertticks&&this.minTicksDistance>e.eps?l*=this.adjustTickDistance(l,h,t,a):this.visProp.insertticks||(l/=this.visProp.minorticks+1),this.ticksDelta=l,s=0,this.visProp.drawzero||(s=l);s<=i.upper;)s>=i.lower&&this.processTickPosition(t,s,l,a),s+=l;for(s=-l;s>=i.lower;)s<=i.upper&&this.processTickPosition(t,s,l,a),s-=l},adjustTickDistance:function(t,e,i,s){for(var n,a,h=1,l=5;e>4*this.minTicksDistance;)h/=10,n=i.usrCoords[1]+s.x*t*h,a=i.usrCoords[2]+s.y*t*h,e=i.distance(r.COORDS_BY_SCREEN,new o(r.COORDS_BY_USER,[n,a],this.board));for(;e<=this.minTicksDistance;)h*=l,l=5===l?2:5,n=i.usrCoords[1]+s.x*t*h,a=i.usrCoords[2]+s.y*t*h,e=i.distance(r.COORDS_BY_SCREEN,new o(r.COORDS_BY_USER,[n,a],this.board));return h},processTickPosition:function(t,e,i,s){var n,a,h,l,c;n=t.usrCoords[1]+e*s.x,a=t.usrCoords[2]+e*s.y,h=new o(r.COORDS_BY_USER,[n,a],this.board),h.major=0===Math.round(e/i)%(this.visProp.minorticks+1),l=this.tickEndings(h,h.major),3===l.length&&(this.ticks.push(l),h.major&&this.visProp.drawlabels?(c=this.generateLabelText(h,t),this.labels.push(this.generateLabel(c,h,this.ticks.length))):this.labels.push(null))},generateFixedTicks:function(t,e){var i,s,a,h,l,c,d=n.isArray(this.visProp.labels),u=this.getXandYdeltas();for(a=0;a<this.fixedTicks.length;a++)l=t.usrCoords[1]+this.fixedTicks[a]*u.x,c=t.usrCoords[2]+this.fixedTicks[a]*u.y,i=new o(r.COORDS_BY_USER,[l,c],this.board),h=this.tickEndings(i,!0),3===h.length&&this.fixedTicks[a]>=e.lower&&this.fixedTicks[a]<=e.upper&&(this.ticks.push(h),!this.visProp.drawlabels||d&&!n.exists(this.visProp.labels[a])?this.labels.push(null):(s=d?this.visProp.labels[a]:this.fixedTicks[a],this.labels.push(this.generateLabel(this.generateLabelText(i,t,s),i,a))))},getXandYdeltas:function(){var t,i,s=this.line.point1.Dist(this.line.point2);return this.line.type===r.OBJECT_TYPE_AXIS?(t=this.line.point1.coords.usrCoords,i=this.line.point2.coords.usrCoords,(t[1]>i[1]||Math.abs(t[1]-i[1])<e.eps&&t[2]>i[2])&&(t=this.line.point2.coords.usrCoords,i=this.line.point1.coords.usrCoords)):(t=this.line.point1.coords.usrCoords,i=this.line.point2.coords.usrCoords),{x:(i[1]-t[1])/s,y:(i[2]-t[2])/s}},tickEndings:function(t,e){var r,s,o,n,a,h,l=this.board.canvasWidth,c=this.board.canvasHeight,d=[-1e3*l,-1e3*c],u=[-1e3*l,-1e3*c],p=!1;return r=t.scrCoords,e?(n=this.dxMaj,a=this.dyMaj,h=this.majStyle):(n=this.dxMin,a=this.dyMin,h=this.minStyle),s=[-a*r[1]-n*r[2],a,n],\"infinite\"===h?(o=i.meetLineBoard(s,this.board),d[0]=o[0].scrCoords[1],d[1]=o[1].scrCoords[1],u[0]=o[0].scrCoords[2],u[1]=o[1].scrCoords[2]):(d[0]=r[1]+n*this.visProp.tickendings[0],u[0]=r[2]-a*this.visProp.tickendings[0],d[1]=r[1]-n*this.visProp.tickendings[1],u[1]=r[2]+a*this.visProp.tickendings[1]),p=d[0]>=0&&d[0]<=l&&u[0]>=0&&u[0]<=c||d[1]>=0&&d[1]<=l&&u[1]>=0&&u[1]<=c,p?[d,u,e]:[]},generateLabelText:function(t,i,r){var s,o=this.getDistanceFromZero(i,t);return Math.abs(o)<e.eps?s=\"0\":(n.exists(r)||(r=o/this.visProp.scale),s=r.toString(),n.isNumber(r)&&((s.length>this.visProp.maxlabellength||-1!==s.indexOf(\"e\"))&&(s=r.toPrecision(this.visProp.precision).toString()),s.indexOf(\".\")>-1&&-1===s.indexOf(\"e\")&&(s=s.replace(/0+$/,\"\"),s=s.replace(/\\.$/,\"\"))),this.visProp.scalesymbol.length>0&&(\"1\"===s?s=this.visProp.scalesymbol:\"-1\"===s?s=\"-\"+this.visProp.scalesymbol:\"0\"!==s&&(s+=this.visProp.scalesymbol))),s},generateLabel:function(t,e,i){var r,s={isLabel:!0,layer:this.board.options.layer.line,highlightStrokeColor:this.board.options.text.strokeColor,highlightStrokeWidth:this.board.options.text.strokeWidth,highlightStrokeOpacity:this.board.options.text.strokeOpacity,visible:this.visProp.visible,priv:this.visProp.priv};return s=n.deepCopy(s,this.visProp.label),this.labelsRepo.length>0?(r=this.labelsRepo.pop(),r.setText(t),r.setAttribute(s)):(this.labelCounter+=1,s.id=this.id+i+\"Label\"+this.labelCounter,r=a.createText(this.board,[e.usrCoords[1],e.usrCoords[2],t],s)),r.isDraggable=!1,r.dump=!1,r.distanceX=this.visProp.label.offset[0],r.distanceY=this.visProp.label.offset[1],r.setCoords(e.usrCoords[1]+r.distanceX/this.board.unitX,e.usrCoords[2]+r.distanceY/this.board.unitY),r},removeTickLabels:function(){var t;if(n.exists(this.labels)&&(this.board.needsFullUpdate||this.needsRegularUpdate||this.needsUpdate)&&(\"canvas\"!==this.board.renderer.type||\"internal\"!==this.board.options.text.display))for(t=0;t<this.labels.length;t++)n.exists(this.labels[t])&&this.labelsRepo.push(this.labels[t])},update:function(){return this.needsUpdate&&0!==this.board.canvasWidth&&0!==this.board.canvasHeight&&this.calculateTicksCoordinates(),this},updateRenderer:function(){return this.needsUpdate&&(this.board.renderer.updateTicks(this),this.needsUpdate=!1),this},hideElement:function(){var t;for(this.visProp.visible=!1,this.board.renderer.hide(this),t=0;t<this.labels.length;t++)n.exists(this.labels[t])&&this.labels[t].hideElement();return this},showElement:function(){var t;for(this.visProp.visible=!0,this.board.renderer.show(this),t=0;t<this.labels.length;t++)n.exists(this.labels[t])&&this.labels[t].showElement();return this}}),t.createTicks=function(e,i,s){var o,a,h=n.copyAttributes(s,e.options,\"ticks\");if(a=i.length<2?h.ticksdistance:i[1],i[0].elementClass!==r.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create Ticks with parent types '\"+typeof i[0]+\"'.\");return o=new t.Ticks(i[0],a,h),\"function\"==typeof h.generatelabelvalue&&(o.generateLabelValue=h.generatelabelvalue),o.isDraggable=!0,o},t.createHatchmark=function(t,e,i){var s,o,a,h,l,c,d=[],u=n.copyAttributes(i,t.options,\"hatch\");if(e[0].elementClass!==r.OBJECT_CLASS_LINE||\"number\"!=typeof e[1])throw new Error(\"JSXGraph: Can't create Hatch mark with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\");for(s=e[1],h=u.ticksdistance,l=(s-1)*h,a=-l/2,o=0;s>o;o++)d[o]=a+o*h;c=t.create(\"ticks\",[e[0],d],u),c.elType=\"hatch\"},t.registerElement(\"ticks\",t.createTicks),t.registerElement(\"hash\",t.createHatchmark),t.registerElement(\"hatch\",t.createHatchmark),{Ticks:t.Ticks,createTicks:t.createTicks,createHashmark:t.createHatchmark,createHatchmark:t.createHatchmark}}),define(\"base/line\",[\"jxg\",\"math/math\",\"math/geometry\",\"math/numerics\",\"math/statistics\",\"base/constants\",\"base/coords\",\"base/element\",\"utils/type\",\"base/transformation\",\"base/point\",\"base/ticks\"],function(t,e,i,r,s,o,n,a,h,l,c){return t.Line=function(e,i,r,s){this.constructor(e,s,o.OBJECT_TYPE_LINE,o.OBJECT_CLASS_LINE),this.point1=this.board.select(i),this.point2=this.board.select(r),this.ticks=[],this.defaultTicks=null,this.parentPolygon=null,this.id=this.board.setId(this,\"L\"),this.board.renderer.drawLine(this),this.board.finalizeAdding(this),this.elType=\"line\",this.point1.addChild(this),this.point2.addChild(this),this.updateStdform(),this.createLabel(),this.methodMap=t.deepCopy(this.methodMap,{point1:\"point1\",point2:\"point2\",getSlope:\"getSlope\",getRise:\"getRise\",getYIntersect:\"getRise\",getAngle:\"getAngle\",L:\"L\",length:\"L\",addTicks:\"addTicks\",removeTicks:\"removeTicks\",removeAllTicks:\"removeAllTicks\"})},t.Line.prototype=new a,t.extend(t.Line.prototype,{hasPoint:function(t,r){var s,a,h,l,c,d,u,p=[],f=[1,t,r];return p[0]=this.stdform[0]-this.stdform[1]*this.board.origin.scrCoords[1]/this.board.unitX+this.stdform[2]*this.board.origin.scrCoords[2]/this.board.unitY,p[1]=this.stdform[1]/this.board.unitX,p[2]=this.stdform[2]/-this.board.unitY,s=i.distPointLine(f,p),isNaN(s)||s>this.board.options.precision.hasPoint?!1:this.visProp.straightfirst&&this.visProp.straightlast?!0:(h=this.point1.coords,l=this.point2.coords,a=[0,p[1],p[2]],a=e.crossProduct(a,f),a=e.crossProduct(a,p),a[1]/=a[0],a[2]/=a[0],a[0]=1,a=new n(o.COORDS_BY_SCREEN,a.slice(1),this.board).usrCoords,c=h.distance(o.COORDS_BY_USER,l),h=h.usrCoords.slice(0),l=l.usrCoords.slice(0),c<e.eps?d=0:(c===Number.POSITIVE_INFINITY&&(c=1/e.eps,Math.abs(l[0])<e.eps?(c/=i.distance([0,0,0],l),l=[1,h[1]+l[1]*c,h[2]+l[2]*c]):(c/=i.distance([0,0,0],h),h=[1,l[1]+h[1]*c,l[2]+h[2]*c])),u=1,c=l[u]-h[u],Math.abs(c)<e.eps&&(u=2,c=l[u]-h[u]),d=(a[u]-h[u])/c),!this.visProp.straightfirst&&0>d?!1:!this.visProp.straightlast&&d>1?!1:!0)},update:function(){var t;return this.needsUpdate?(this.constrained&&(\"function\"==typeof this.funps?(t=this.funps(),t&&t.length&&2===t.length&&(this.point1=t[0],this.point2=t[1])):(\"function\"==typeof this.funp1&&(t=this.funp1(),h.isPoint(t)?this.point1=t:t&&t.length&&2===t.length&&this.point1.setPositionDirectly(o.COORDS_BY_USER,t)),\"function\"==typeof this.funp2&&(t=this.funp2(),h.isPoint(t)?this.point2=t:t&&t.length&&2===t.length&&this.point2.setPositionDirectly(o.COORDS_BY_USER,t)))),this.updateSegmentFixedLength(),this.updateStdform(),this.visProp.trace&&this.cloneToBackground(!0),this):this},updateSegmentFixedLength:function(){var t,i,r,s,n,a,h,l;return this.hasFixedLength?(t=this.point1.Dist(this.point2),i=this.fixedLength(),r=this.fixedLengthOldCoords[0].distance(o.COORDS_BY_USER,this.point1.coords),s=this.fixedLengthOldCoords[1].distance(o.COORDS_BY_USER,this.point2.coords),(r>e.eps||s>e.eps||t!==i)&&(n=this.point1.isDraggable&&this.point1.type!==o.OBJECT_TYPE_GLIDER&&!this.point1.visProp.fixed,a=this.point2.isDraggable&&this.point2.type!==o.OBJECT_TYPE_GLIDER&&!this.point2.visProp.fixed,t>e.eps?r>s&&a||s>=r&&a&&!n?(this.point2.setPositionDirectly(o.COORDS_BY_USER,[this.point1.X()+(this.point2.X()-this.point1.X())*i/t,this.point1.Y()+(this.point2.Y()-this.point1.Y())*i/t]),this.point2.prepareUpdate().updateRenderer()):(s>=r&&n||r>s&&n&&!a)&&(this.point1.setPositionDirectly(o.COORDS_BY_USER,[this.point2.X()+(this.point1.X()-this.point2.X())*i/t,this.point2.Y()+(this.point1.Y()-this.point2.Y())*i/t]),this.point1.prepareUpdate().updateRenderer()):(h=Math.random()-.5,l=Math.random()-.5,t=Math.sqrt(h*h+l*l),a?(this.point2.setPositionDirectly(o.COORDS_BY_USER,[this.point1.X()+h*i/t,this.point1.Y()+l*i/t]),this.point2.prepareUpdate().updateRenderer()):n&&(this.point1.setPositionDirectly(o.COORDS_BY_USER,[this.point2.X()+h*i/t,this.point2.Y()+l*i/t]),this.point1.prepareUpdate().updateRenderer())),this.fixedLengthOldCoords[0].setCoordinates(o.COORDS_BY_USER,this.point1.coords.usrCoords),this.fixedLengthOldCoords[1].setCoordinates(o.COORDS_BY_USER,this.point2.coords.usrCoords)),this):this},updateStdform:function(){var t=e.crossProduct(this.point1.coords.usrCoords,this.point2.coords.usrCoords);this.stdform[0]=t[0],this.stdform[1]=t[1],this.stdform[2]=t[2],this.stdform[3]=0,this.normalize()},updateRenderer:function(){var t;return this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.isReal=!isNaN(this.point1.coords.usrCoords[1]+this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[1]+this.point2.coords.usrCoords[2])&&e.innerProduct(this.stdform,this.stdform,3)>=e.eps*e.eps,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.show(this.label)),this.board.renderer.updateLine(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.hide(this.label)),this.needsUpdate=!1),this.hasLabel&&this.label.visProp.visible&&this.isReal&&(this.label.update(),this.board.renderer.updateText(this.label)),this},generatePolynomial:function(t){var e=this.point1.symbolic.x,i=this.point1.symbolic.y,r=this.point2.symbolic.x,s=this.point2.symbolic.y,o=t.symbolic.x,n=t.symbolic.y;return[[\"(\",i,\")*(\",o,\")-(\",i,\")*(\",r,\")+(\",n,\")*(\",r,\")-(\",e,\")*(\",n,\")+(\",e,\")*(\",s,\")-(\",o,\")*(\",s,\")\"].join(\"\")]},getRise:function(){return Math.abs(this.stdform[2])>=e.eps?-this.stdform[0]/this.stdform[2]:1/0},getSlope:function(){return Math.abs(this.stdform[2])>=e.eps?-this.stdform[1]/this.stdform[2]:1/0},getAngle:function(){return Math.atan2(-this.stdform[1],this.stdform[2])},setStraight:function(t,e){return this.visProp.straightfirst=t,this.visProp.straightlast=e,this.board.renderer.updateLine(this),this},getTextAnchor:function(){return new n(o.COORDS_BY_USER,[.5*(this.point2.X()+this.point1.X()),.5*(this.point2.Y()+this.point1.Y())],this.board)},setLabelRelativeCoords:function(t){h.exists(this.label)&&(this.label.relativeCoords=new n(o.COORDS_BY_SCREEN,[t[0],-t[1]],this.board))},getLabelAnchor:function(){var t,r,s=0,a=0,l=0,c=new n(o.COORDS_BY_USER,this.point1.coords.usrCoords,this.board),d=new n(o.COORDS_BY_USER,this.point2.coords.usrCoords,this.board);if((this.visProp.straightfirst||this.visProp.straightlast)&&i.calcStraight(this,c,d,0),c=c.scrCoords,d=d.scrCoords,!h.exists(this.label))return new n(o.COORDS_BY_SCREEN,[0/0,0/0],this.board);switch(this.label.visProp.position){case\"lft\":case\"llft\":case\"ulft\":c[1]<=d[1]?(t=c[1],r=c[2]):(t=d[1],r=d[2]);break;case\"rt\":case\"lrt\":case\"urt\":c[1]>d[1]?(t=c[1],r=c[2]):(t=d[1],r=d[2]);break;default:t=.5*(c[1]+d[1]),r=.5*(c[2]+d[2])}return(this.visProp.straightfirst||this.visProp.straightlast)&&(h.exists(this.label)&&(a=parseFloat(this.label.visProp.offset[0]),l=parseFloat(this.label.visProp.offset[1]),s=this.label.visProp.fontsize),Math.abs(t)<e.eps?t=a:this.board.canvasWidth+e.eps>t&&t>this.board.canvasWidth-s-e.eps&&(t=this.board.canvasWidth-a-s),e.eps+s>r&&r>-e.eps?r=l+s:this.board.canvasHeight+e.eps>r&&r>this.board.canvasHeight-s-e.eps&&(r=this.board.canvasHeight-l)),new n(o.COORDS_BY_SCREEN,[t,r],this.board)},cloneToBackground:function(){var t,e,i,r={};return r.id=this.id+\"T\"+this.numTraces,r.elementClass=o.OBJECT_CLASS_LINE,this.numTraces++,r.point1=this.point1,r.point2=this.point2,r.stdform=this.stdform,r.board=this.board,r.visProp=h.deepCopy(this.visProp,this.visProp.traceattributes,!0),r.visProp.layer=this.board.options.layer.trace,h.clearVisPropOld(r),e=this.getSlope(),t=this.getRise(),r.getSlope=function(){return e},r.getRise=function(){return t},i=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawLine(r),this.board.renderer.enhancedRendering=i,this.traces[r.id]=r.rendNode,this},addTransform:function(t){var e,i=h.isArray(t)?t:[t],r=i.length;for(e=0;r>e;e++)this.point1.transformations.push(i[e]),this.point2.transformations.push(i[e]);return this},setPosition:function(t,e){var i;return e=new n(t,e,this.board),i=this.board.create(\"transform\",e.usrCoords.slice(1),{type:\"translate\"}),this.point1.transformations.length>0&&this.point1.transformations[this.point1.transformations.length-1].isNumericMatrix?this.point1.transformations[this.point1.transformations.length-1].melt(i):this.point1.addTransform(this.point1,i),this.point2.transformations.length>0&&this.point2.transformations[this.point2.transformations.length-1].isNumericMatrix?this.point2.transformations[this.point2.transformations.length-1].melt(i):this.point2.addTransform(this.point2,i),this},setPositionDirectly:function(t,e,i){var r,o,a=new n(t,e,this.board),h=new n(t,i,this.board);return this.point1.draggable()&&this.point2.draggable()?(r=s.subtract(a.usrCoords,h.usrCoords),o=this.board.create(\"transform\",r.slice(1),{type:\"translate\"}),o.applyOnce([this.point1,this.point2]),this):this},snapToGrid:function(r){var a,h,l,c,d,u,p,f,m,b;return this.visProp.snaptogrid?this.parents.length<3?(this.point1.handleSnapToGrid(!0),this.point2.handleSnapToGrid(!0)):t.exists(r)&&(m=this.visProp.snapsizex,b=this.visProp.snapsizey,a=new n(o.COORDS_BY_SCREEN,[r.Xprev,r.Yprev],this.board),p=a.usrCoords[1],f=a.usrCoords[2],0>=m&&this.board.defaultAxes&&this.board.defaultAxes.x.defaultTicks&&(u=this.board.defaultAxes.x.defaultTicks,m=u.ticksDelta*(u.visProp.minorticks+1)),0>=b&&this.board.defaultAxes&&this.board.defaultAxes.y.defaultTicks&&(u=this.board.defaultAxes.y.defaultTicks,b=u.ticksDelta*(u.visProp.minorticks+1)),m>0&&b>0&&(d=[0,this.stdform[1],this.stdform[2]],d=e.crossProduct(d,a.usrCoords),h=i.meetLineLine(d,this.stdform,0,this.board),l=s.subtract([1,Math.round(p/m)*m,Math.round(f/b)*b],h.usrCoords),c=this.board.create(\"transform\",l.slice(1),{type:\"translate\"}),c.applyOnce([this.point1,this.point2]))):(this.point1.snapToGrid(),this.point2.snapToGrid()),this},snapToPoints:function(){var t=this.visProp.snaptopoints;return this.parents.length<3&&(this.point1.handleSnapToPoints(t),this.point2.handleSnapToPoints(t)),this},X:function(t){var i,r=this.stdform[2];return i=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[1]:this.point2.coords.usrCoords[1],t=2*(t-.5),(1-Math.abs(t))*i-t*r},Y:function(t){var i,r=this.stdform[1];return i=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[2]:this.point2.coords.usrCoords[2],t=2*(t-.5),(1-Math.abs(t))*i+t*r},Z:function(t){var i=Math.abs(this.point1.coords.usrCoords[0])>e.eps?this.point1.coords.usrCoords[0]:this.point2.coords.usrCoords[0];return t=2*(t-.5),(1-Math.abs(t))*i},L:function(){return this.point1.Dist(this.point2)},minX:function(){return 0},maxX:function(){return 1},bounds:function(){var t=this.point1.coords.usrCoords,e=this.point2.coords.usrCoords;\nreturn[Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[1],e[1]),Math.min(t[2],e[2])]},addTicks:function(t){return\"\"!==t.id&&h.exists(t.id)||(t.id=this.id+\"_ticks_\"+(this.ticks.length+1)),this.board.renderer.drawTicks(t),this.ticks.push(t),t.id},remove:function(){this.removeAllTicks(),a.prototype.remove.call(this)},removeAllTicks:function(){var t;for(t=this.ticks.length;t>0;t--)this.removeTicks(this.ticks[t-1]);this.ticks=[],this.board.update()},removeTicks:function(t){var e,i;for(h.exists(this.defaultTicks)&&this.defaultTicks===t&&(this.defaultTicks=null),e=this.ticks.length;e>0;e--)if(this.ticks[e-1]===t){if(this.board.removeObject(this.ticks[e-1]),this.ticks[e-1].ticks)for(i=0;i<this.ticks[e-1].ticks.length;i++)h.exists(this.ticks[e-1].labels[i])&&this.board.removeObject(this.ticks[e-1].labels[i]);delete this.ticks[e-1];break}},hideElement:function(){var t;for(a.prototype.hideElement.call(this),t=0;t<this.ticks.length;t++)this.ticks[t].hideElement()},showElement:function(){var t;for(a.prototype.showElement.call(this),t=0;t<this.ticks.length;t++)this.ticks[t].showElement()}}),t.createLine=function(e,i,r){var s,n,a,l,d,u,p,f=[],m=!1;if(2===i.length){if(h.isArray(i[0])&&i[0].length>1)u=h.copyAttributes(r,e.options,\"line\",\"point1\"),a=e.create(\"point\",i[0],u);else if(h.isString(i[0])||i[0].elementClass===o.OBJECT_CLASS_POINT)a=e.select(i[0]);else if(\"function\"==typeof i[0]&&i[0]().elementClass===o.OBJECT_CLASS_POINT)a=i[0](),m=!0;else{if(\"function\"!=typeof i[0]||!i[0]().length||2!==i[0]().length)throw new Error(\"JSXGraph: Can't create line with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]\");u=h.copyAttributes(r,e.options,\"line\",\"point1\"),a=c.createPoint(e,i[0](),u),m=!0}if(h.isArray(i[1])&&i[1].length>1)u=h.copyAttributes(r,e.options,\"line\",\"point2\"),l=e.create(\"point\",i[1],u);else if(h.isString(i[1])||i[1].elementClass===o.OBJECT_CLASS_POINT)l=e.select(i[1]);else if(\"function\"==typeof i[1]&&i[1]().elementClass===o.OBJECT_CLASS_POINT)l=i[1](),m=!0;else{if(\"function\"!=typeof i[1]||!i[1]().length||2!==i[1]().length)throw new Error(\"JSXGraph: Can't create line with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]\");u=h.copyAttributes(r,e.options,\"line\",\"point2\"),l=c.createPoint(e,i[1](),u),m=!0}u=h.copyAttributes(r,e.options,\"line\"),n=new t.Line(e,a,l,u),m?(n.constrained=!0,n.funp1=i[0],n.funp2=i[1]):n.isDraggable=!0,n.constrained||(n.parents=[a.id,l.id])}else if(3===i.length){for(p=!0,d=0;3>d;d++)if(\"number\"==typeof i[d])f[d]=h.createFunction(i[d]);else{if(\"function\"!=typeof i[d])throw new Error(\"JSXGraph: Can't create line with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"' and '\"+typeof i[2]+\"'.\"+\"\\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]\");f[d]=i[d],p=!1}u=h.copyAttributes(r,e.options,\"line\",\"point1\"),a=p?e.create(\"point\",[f[2]()*f[2]()+f[1]()*f[1](),f[2]()-f[1]()*f[0]()+f[2](),-f[1]()-f[2]()*f[0]()-f[1]()],u):e.create(\"point\",[function(){return.5*(f[2]()*f[2]()+f[1]()*f[1]())},function(){return.5*(f[2]()-f[1]()*f[0]()+f[2]())},function(){return.5*(-f[1]()-f[2]()*f[0]()-f[1]())}],u),u=h.copyAttributes(r,e.options,\"line\",\"point2\"),l=p?e.create(\"point\",[f[2]()*f[2]()+f[1]()*f[1](),-f[1]()*f[0]()+f[2](),-f[2]()*f[0]()-f[1]()],u):e.create(\"point\",[function(){return f[2]()*f[2]()+f[1]()*f[1]()},function(){return-f[1]()*f[0]()+f[2]()},function(){return-f[2]()*f[0]()-f[1]()}],u),a.prepareUpdate().update(),l.prepareUpdate().update(),u=h.copyAttributes(r,e.options,\"line\"),n=new t.Line(e,a,l,u),n.isDraggable=p,p&&(n.parents=[f[0](),f[1](),f[2]()])}else if(1===i.length&&\"function\"==typeof i[0]&&2===i[0]().length&&i[0]()[0].elementClass===o.OBJECT_CLASS_POINT&&i[0]()[1].elementClass===o.OBJECT_CLASS_POINT)s=i[0](),u=h.copyAttributes(r,e.options,\"line\"),n=new t.Line(e,s[0],s[1],u),n.constrained=!0,n.funps=i[0];else{if(1!==i.length||\"function\"!=typeof i[0]||3!==i[0]().length||\"number\"!=typeof i[0]()[0]||\"number\"!=typeof i[0]()[1]||\"number\"!=typeof i[0]()[2])throw new Error(\"JSXGraph: Can't create line with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,point], [[x1,y1],[x2,y2]], [a,b,c]\");s=i[0],u=h.copyAttributes(r,e.options,\"line\",\"point1\"),a=e.create(\"point\",[function(){var t=s();return[.5*(t[2]*t[2]+t[1]*t[1]),.5*(t[2]-t[1]*t[0]+t[2]),.5*(-t[1]-t[2]*t[0]-t[1])]}],u),u=h.copyAttributes(r,e.options,\"line\",\"point2\"),l=e.create(\"point\",[function(){var t=s();return[t[2]*t[2]+t[1]*t[1],-t[1]*t[0]+t[2],-t[2]*t[0]-t[1]]}],u),u=h.copyAttributes(r,e.options,\"line\"),n=new t.Line(e,a,l,u),n.constrained=!0,n.funps=i[0]}return n},t.registerElement(\"line\",t.createLine),t.createSegment=function(t,e,i){var r,s;if(i.straightFirst=!1,i.straightLast=!1,s=h.copyAttributes(i,t.options,\"segment\"),r=t.create(\"line\",e.slice(0,2),s),3===e.length){if(r.hasFixedLength=!0,h.isNumber(e[2]))r.fixedLength=function(){return e[2]};else{if(!h.isFunction(e[2]))throw new Error(\"JSXGraph: Can't create segment with third parent type '\"+typeof e[2]+\"'.\"+\"\\nPossible third parent types: number or function\");r.fixedLength=e[2]}r.fixedLengthOldCoords=[],r.fixedLengthOldCoords[0]=new n(o.COORDS_BY_USER,r.point1.coords.usrCoords.slice(1,3),t),r.fixedLengthOldCoords[1]=new n(o.COORDS_BY_USER,r.point2.coords.usrCoords.slice(1,3),t)}return r.elType=\"segment\",r},t.registerElement(\"segment\",t.createSegment),t.createArrow=function(t,e,i){var r;return i.firstArrow=!1,i.lastArrow=!0,r=t.create(\"line\",e,i).setStraight(!1,!1),r.type=o.OBJECT_TYPE_VECTOR,r.elType=\"arrow\",r},t.registerElement(\"arrow\",t.createArrow),t.createAxis=function(t,e,i){var r,s,n,a;if(!h.isArray(e[0])&&!h.isPoint(e[0])||!h.isArray(e[1])&&!h.isPoint(e[1]))throw new Error(\"JSXGraph: Can't create axis with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,point], [[x1,y1],[x2,y2]]\");r=h.copyAttributes(i,t.options,\"axis\"),s=t.create(\"line\",e,r),s.type=o.OBJECT_TYPE_AXIS,s.isDraggable=!1,s.point1.isDraggable=!1,s.point2.isDraggable=!1;for(n in s.ancestors)s.ancestors.hasOwnProperty(n)&&(s.ancestors[n].type=o.OBJECT_TYPE_AXISPOINT);return r=h.copyAttributes(i,t.options,\"axis\",\"ticks\"),a=h.exists(r.ticksdistance)?r.ticksdistance:h.isArray(r.ticks)?r.ticks:1,s.defaultTicks=t.create(\"ticks\",[s,a],r),s.defaultTicks.dump=!1,s.elType=\"axis\",s.subs={ticks:s.defaultTicks},s},t.registerElement(\"axis\",t.createAxis),t.createTangent=function(t,i,s){var n,a,l,c,d,u,p,f;if(1===i.length)n=i[0],a=n.slideObject;else{if(2!==i.length)throw new Error(\"JSXGraph: Can't create tangent with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [glider], [point,line|curve|circle|conic]\");if(h.isPoint(i[0]))n=i[0],a=i[1];else{if(!h.isPoint(i[1]))throw new Error(\"JSXGraph: Can't create tangent with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [glider], [point,line|curve|circle|conic]\");a=i[0],n=i[1]}}if(a.elementClass===o.OBJECT_CLASS_LINE?(f=t.create(\"line\",[a.point1,a.point2],s),f.glider=n):a.elementClass===o.OBJECT_CLASS_CURVE&&a.type!==o.OBJECT_TYPE_CONIC?\"plot\"!==a.visProp.curvetype?(l=a.X,c=a.Y,f=t.create(\"line\",[function(){return-n.X()*r.D(c)(n.position)+n.Y()*r.D(l)(n.position)},function(){return r.D(c)(n.position)},function(){return-r.D(l)(n.position)}],s),n.addChild(f),f.glider=n):(f=t.create(\"line\",[function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?1:a.Y(t)*a.X(t+1)-a.X(t)*a.Y(t+1)},function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?0:a.Y(t+1)-a.Y(t)},function(){var t=Math.floor(n.position);return t===a.numberPoints-1&&t--,0>t?0:a.X(t)-a.X(t+1)}],s),n.addChild(f),f.glider=n):a.type===o.OBJECT_TYPE_TURTLE?(f=t.create(\"line\",[function(){var t=Math.floor(n.position);for(u=0;u<a.objects.length;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(t<p.numberPoints)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?1:p.Y(t)*p.X(t+1)-p.X(t)*p.Y(t+1)},function(){var t=Math.floor(n.position);for(u=0;u<a.objects.length;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(t<p.numberPoints)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?0:p.Y(t+1)-p.Y(t)},function(){var t=Math.floor(n.position);for(u=0;u<a.objects.length;u++)if(p=a.objects[u],p.type===o.OBJECT_TYPE_CURVE){if(t<p.numberPoints)break;t-=p.numberPoints}return t===p.numberPoints-1&&t--,0>t?0:p.X(t)-p.X(t+1)}],s),n.addChild(f),f.glider=n):(a.elementClass===o.OBJECT_CLASS_CIRCLE||a.type===o.OBJECT_TYPE_CONIC)&&(f=t.create(\"line\",[function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[0]},function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[1]},function(){return e.matVecMult(a.quadraticform,n.coords.usrCoords)[2]}],s),n.addChild(f),f.glider=n),!h.exists(f))throw new Error(\"JSXGraph: Couldn't create tangent with the given parents.\");for(f.elType=\"tangent\",f.type=o.OBJECT_TYPE_TANGENT,f.parents=[],d=0;d<i.length;d++)f.parents.push(i[d].id);return f},t.createRadicalAxis=function(e,i,r){var s,n,a;if(2!==i.length||i[0].elementClass!==o.OBJECT_CLASS_CIRCLE||i[1].elementClass!==o.OBJECT_CLASS_CIRCLE)throw new Error(\"JSXGraph: Can't create 'radical axis' with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent type: [circle,circle]\");return n=e.select(i[0]),a=e.select(i[1]),s=e.create(\"line\",[function(){var e=n.stdform,i=a.stdform;return t.Math.matVecMult(t.Math.transpose([e.slice(0,3),i.slice(0,3)]),[i[3],-e[3]])}],r),s.elType=\"radicalaxis\",s.parents=[n.id,a.id],n.addChild(s),a.addChild(s),s},t.createPolarLine=function(t,e,i){var r,s,n;if(2!==e.length||(e[0].type!==o.OBJECT_TYPE_CONIC&&e[0].elementClass!==o.OBJECT_CLASS_CIRCLE||e[1].elementClass!==o.OBJECT_CLASS_POINT)&&(e[0].elementClass!==o.OBJECT_CLASS_POINT||e[1].type!==o.OBJECT_TYPE_CONIC&&e[1].elementClass!==o.OBJECT_CLASS_CIRCLE))throw new Error(\"JSXGraph: Can't create 'polar line' with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent type: [conic|circle,point], [point,conic|circle]\");return e[1].elementClass===o.OBJECT_CLASS_POINT?(s=t.select(e[0]),n=t.select(e[1])):(s=t.select(e[1]),n=t.select(e[0])),r=t.create(\"tangent\",[s,n],i),r.elType=\"polarline\",r},t.registerElement(\"tangent\",t.createTangent),t.registerElement(\"polar\",t.createTangent),t.registerElement(\"radicalaxis\",t.createRadicalAxis),t.registerElement(\"polarline\",t.createPolarLine),{Line:t.Line,createLine:t.createLine,createTangent:t.createTangent,createPolar:t.createTangent,createSegment:t.createSegment,createAxis:t.createAxis,createArrow:t.createArrow,createRadicalAxis:t.createRadicalAxis,createPolarLine:t.createPolarLine}}),define(\"base/circle\",[\"jxg\",\"base/element\",\"base/coords\",\"base/constants\",\"parser/geonext\",\"math/geometry\",\"math/statistics\",\"utils/type\",\"base/transformation\",\"base/point\"],function(t,e,i,r,s,o,n,a){return t.Circle=function(t,e,i,s,o){this.constructor(t,o,r.OBJECT_TYPE_CIRCLE,r.OBJECT_CLASS_CIRCLE),this.method=e,this.midpoint=this.board.select(i),this.center=this.board.select(i),this.point2=null,this.radius=0,this.line=null,this.circle=null,\"twoPoints\"===e?(this.point2=t.select(s),this.radius=this.Radius()):\"pointRadius\"===e?(this.gxtterm=s,this.updateRadius=a.createFunction(s,this.board,null,!0),this.updateRadius()):\"pointLine\"===e?(this.line=t.select(s),this.radius=this.line.point1.coords.distance(r.COORDS_BY_USER,this.line.point2.coords)):\"pointCircle\"===e&&(this.circle=t.select(s),this.radius=this.circle.Radius()),this.id=this.board.setId(this,\"C\"),this.board.renderer.drawEllipse(this),this.board.finalizeAdding(this),this.createGradient(),this.elType=\"circle\",this.createLabel(),this.center.addChild(this),\"pointRadius\"===e?this.notifyParents(s):\"pointLine\"===e?this.line.addChild(this):\"pointCircle\"===e?this.circle.addChild(this):\"twoPoints\"===e&&this.point2.addChild(this),this.methodMap=a.deepCopy(this.methodMap,{setRadius:\"setRadius\",getRadius:\"getRadius\",radius:\"Radius\",center:\"center\",line:\"line\",point2:\"point2\"})},t.Circle.prototype=new e,t.extend(t.Circle.prototype,{hasPoint:function(t,e){var s=this.board.options.precision.hasPoint/this.board.unitX,o=this.center.coords.usrCoords,n=new i(r.COORDS_BY_SCREEN,[t,e],this.board),a=this.Radius(),h=Math.sqrt((o[1]-n.usrCoords[1])*(o[1]-n.usrCoords[1])+(o[2]-n.usrCoords[2])*(o[2]-n.usrCoords[2]));return this.visProp.hasinnerpoints?a+s>h:Math.abs(h-a)<s},generatePolynomial:function(t){var e=this.center.symbolic.x,i=this.center.symbolic.y,r=t.symbolic.x,s=t.symbolic.y,o=this.generateRadiusSquared();return\"\"===o?[]:[\"((\"+r+\")-(\"+e+\"))^2 + ((\"+s+\")-(\"+i+\"))^2 - (\"+o+\")\"]},generateRadiusSquared:function(){var t,e,i,r,s,o,n=\"\";return\"twoPoints\"===this.method?(t=this.center.symbolic.x,e=this.center.symbolic.y,i=this.point2.symbolic.x,r=this.point2.symbolic.y,n=\"((\"+i+\")-(\"+t+\"))^2 + ((\"+r+\")-(\"+e+\"))^2\"):\"pointRadius\"===this.method?\"number\"==typeof this.radius&&(n=(this.radius*this.radius).toString()):\"pointLine\"===this.method?(i=this.line.point1.symbolic.x,r=this.line.point1.symbolic.y,s=this.line.point2.symbolic.x,o=this.line.point2.symbolic.y,n=\"((\"+i+\")-(\"+s+\"))^2 + ((\"+r+\")-(\"+o+\"))^2\"):\"pointCircle\"===this.method&&(n=this.circle.Radius()),n},update:function(){return this.needsUpdate&&(this.visProp.trace&&this.cloneToBackground(!0),\"pointLine\"===this.method?this.radius=this.line.point1.coords.distance(r.COORDS_BY_USER,this.line.point2.coords):\"pointCircle\"===this.method?this.radius=this.circle.Radius():\"pointRadius\"===this.method&&(this.radius=this.updateRadius()),this.updateStdform(),this.updateQuadraticform()),this},updateQuadraticform:function(){var t=this.center,e=t.X(),i=t.Y(),r=this.Radius();this.quadraticform=[[e*e+i*i-r*r,-e,-i],[-e,1,0],[-i,0,1]]},updateStdform:function(){this.stdform[3]=.5,this.stdform[4]=this.Radius(),this.stdform[1]=-this.center.coords.usrCoords[1],this.stdform[2]=-this.center.coords.usrCoords[2],this.normalize()},updateRenderer:function(){var t;this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.isReal=!isNaN(this.center.coords.usrCoords[1]+this.center.coords.usrCoords[2]+this.Radius())&&this.center.isReal,this.isReal?(t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.show(this.label)),this.board.renderer.updateEllipse(this)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.hide(this.label)),this.needsUpdate=!1),this.hasLabel&&this.label.visProp.visible&&this.isReal&&(this.label.update(),this.board.renderer.updateText(this.label))},notifyParents:function(t){\"string\"==typeof t&&s.findDependencies(this,t,this.board)},setRadius:function(t){return this.updateRadius=a.createFunction(t,this.board,null,!0),this.board.update(),this},Radius:function(t){return a.exists(t)?(this.setRadius(t),this.Radius()):\"twoPoints\"===this.method?0===o.distance(this.point2.coords.usrCoords,[0,0,0])||0===o.distance(this.center.coords.usrCoords,[0,0,0])?0/0:this.center.Dist(this.point2):\"pointLine\"===this.method||\"pointCircle\"===this.method?this.radius:\"pointRadius\"===this.method?this.updateRadius():0/0},getRadius:function(){return this.Radius()},getTextAnchor:function(){return this.center.coords},getLabelAnchor:function(){var t,e,s=this.Radius(),o=this.center.coords.usrCoords;switch(this.visProp.label.position){case\"lft\":t=o[1]-s,e=o[2];break;case\"llft\":t=o[1]-Math.sqrt(.5)*s,e=o[2]-Math.sqrt(.5)*s;break;case\"rt\":t=o[1]+s,e=o[2];break;case\"lrt\":t=o[1]+Math.sqrt(.5)*s,e=o[2]-Math.sqrt(.5)*s;break;case\"urt\":t=o[1]+Math.sqrt(.5)*s,e=o[2]+Math.sqrt(.5)*s;break;case\"top\":t=o[1],e=o[2]+s;break;case\"bot\":t=o[1],e=o[2]-s;break;default:t=o[1]-Math.sqrt(.5)*s,e=o[2]+Math.sqrt(.5)*s}return new i(r.COORDS_BY_USER,[t,e],this.board)},cloneToBackground:function(){var t,e=this.Radius(),i={id:this.id+\"T\"+this.numTraces,elementClass:r.OBJECT_CLASS_CIRCLE,center:{coords:this.center.coords},Radius:function(){return e},getRadius:function(){return e},board:this.board,visProp:a.deepCopy(this.visProp,this.visProp.traceattributes,!0)};return i.visProp.layer=this.board.options.layer.trace,this.numTraces++,a.clearVisPropOld(i),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawEllipse(i),this.board.renderer.enhancedRendering=t,this.traces[i.id]=i.rendNode,this},addTransform:function(t){var e,i=a.isArray(t)?t:[t],r=i.length;for(e=0;r>e;e++)this.center.transformations.push(i[e]),\"twoPoints\"===this.method&&this.point2.transformations.push(i[e]);return this},snapToGrid:function(){var t=this.visProp.snaptogrid;return this.center.snapToGrid(t),\"twoPoints\"===this.method&&this.point2.snapToGrid(t),this},snapToPoints:function(){var t=this.visProp.snaptopoints;return this.center.handleSnapToPoints(t),\"twoPoints\"===this.method&&this.point2.handleSnapToPoints(t),this},setPosition:function(t,e){var r;return e=new i(t,e,this.board),r=this.board.create(\"transform\",e.usrCoords.slice(1),{type:\"translate\"}),this.addTransform(r),this},setPositionDirectly:function(t,e,r){var s,o,a,h,l,c=this.parents.length;for(l=[],s=0;c>s;s++){if(o=this.board.select(this.parents[s]),!o.draggable())return this;l.push(o)}return e=new i(t,e,this.board),r=new i(t,r,this.board),a=n.subtract(e.usrCoords,r.usrCoords),h=this.board.create(\"transform\",a.slice(1),{type:\"translate\"}),h.applyOnce(l),this},X:function(t){return this.Radius()*Math.cos(2*t*Math.PI)+this.center.coords.usrCoords[1]},Y:function(t){return this.Radius()*Math.sin(2*t*Math.PI)+this.center.coords.usrCoords[2]},Z:function(){return 1},minX:function(){return 0},maxX:function(){return 1},Area:function(){var t=this.Radius();return t*t*Math.PI},bounds:function(){var t=this.center.coords.usrCoords,e=this.Radius();return[t[1]-e,t[2]+e,t[1]+e,t[2]-e]}}),t.createCircle=function(e,i,s){var o,n,h,l,c=!0;for(n=[],h=0;h<i.length;h++)a.isPoint(i[h])?n[h]=i[h]:a.isArray(i[h])&&i[h].length>1?(l=a.copyAttributes(s,e.options,\"circle\",\"center\"),n[h]=e.create(\"point\",i[h],l)):n[h]=i[h];if(l=a.copyAttributes(s,e.options,\"circle\"),2===i.length&&a.isPoint(n[0])&&a.isPoint(n[1]))o=new t.Circle(e,\"twoPoints\",n[0],n[1],l);else if((a.isNumber(n[0])||a.isFunction(n[0])||a.isString(n[0]))&&a.isPoint(n[1]))o=new t.Circle(e,\"pointRadius\",n[1],n[0],l);else if((a.isNumber(n[1])||a.isFunction(n[1])||a.isString(n[1]))&&a.isPoint(n[0]))o=new t.Circle(e,\"pointRadius\",n[0],n[1],l);else if(n[0].elementClass===r.OBJECT_CLASS_CIRCLE&&a.isPoint(n[1]))o=new t.Circle(e,\"pointCircle\",n[1],n[0],l);else if(n[1].elementClass===r.OBJECT_CLASS_CIRCLE&&a.isPoint(n[0]))o=new t.Circle(e,\"pointCircle\",n[0],n[1],l);else if(n[0].elementClass===r.OBJECT_CLASS_LINE&&a.isPoint(n[1]))o=new t.Circle(e,\"pointLine\",n[1],n[0],l);else if(n[1].elementClass===r.OBJECT_CLASS_LINE&&a.isPoint(n[0]))o=new t.Circle(e,\"pointLine\",n[0],n[1],l);else{if(!(3===i.length&&a.isPoint(n[0])&&a.isPoint(n[1])&&a.isPoint(n[2])))throw new Error(\"JSXGraph: Can't create circle with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,point], [point,number], [point,function], [point,circle], [point,point,point]\");if(!t.elements.circumcircle)throw new Error(\"JSXGraph: Can't create circle with three points. Please include the circumcircle element (element/composition).\");o=t.elements.circumcircle(e,n,l)}for(o.isDraggable=c,o.parents=[],h=0;h<i.length;h++)i[h].id&&o.parents.push(i[h].id);return o.elType=\"circle\",o},t.registerElement(\"circle\",t.createCircle),{Circle:t.Circle,createCircle:t.createCircle}}),define(\"base/composition\",[\"jxg\",\"utils/type\"],function(t,e){return t.Composition=function(t){var i,r=this,s=[\"setAttribute\",\"prepareUpdate\",\"updateRenderer\",\"update\",\"highlight\",\"noHighlight\"],o=function(t){return function(){var i;for(i in r.elements)r.elements.hasOwnProperty(i)&&e.exists(r.elements[i][t])&&r.elements[i][t].apply(r.elements[i],arguments);return r}};for(i=0;i<s.length;i++)this[s[i]]=o(s[i]);this.elements={},this.objects=this.elements,this.elementsByName={},this.objectsList=[],this.groups={},this.methodMap={setAttribute:\"setAttribute\",setProperty:\"setAttribute\",add:\"add\",remove:\"remove\",select:\"select\"};for(i in t)t.hasOwnProperty(i)&&this.add(i,t[i]);this.dump=!0,this.subs={}},t.extend(t.Composition.prototype,{add:function(t,i){return!e.exists(this[t])&&e.exists(i)?(e.exists(i.id)?this.elements[i.id]=i:this.elements[t]=i,e.exists(i.name)&&(this.elementsByName[i.name]=i),i.on(\"attribute:name\",this.nameListener,this),this.objectsList.push(i),this[t]=i,this.methodMap[t]=i,!0):!1},remove:function(t){var e,i=!1;for(e in this.elements)if(this.elements.hasOwnProperty(e)&&this.elements[e].id===this[t].id){i=!0;break}return i&&(delete this.elements[this[t].id],delete this[t]),i},nameListener:function(t,e,i){delete this.elementsByName[t],this.elementsByName[e]=i},select:function(i){return e.exists(t.Board)?t.Board.prototype.select.call(this,i):new t.Composition},getParents:function(){return this.parents},getType:function(){return this.elType},getAttributes:function(){var t,e={};for(t in this.subs)this.subs.hasOwnProperty(t)&&(e[t]=this.subs[t].visProp);return this.attr}}),t.Composition}),define(\"base/curve\",[\"jxg\",\"base/constants\",\"base/coords\",\"base/element\",\"math/math\",\"math/statistics\",\"math/numerics\",\"math/geometry\",\"parser/geonext\",\"utils/type\",\"base/transformation\",\"math/qdt\"],function(t,e,i,r,s,o,n,a,h,l,c,d){return t.Curve=function(t,i,r){this.constructor(t,r,e.OBJECT_TYPE_CURVE,e.OBJECT_CLASS_CURVE),this.points=[],this.numberPoints=this.visProp.numberpointshigh,this.bezierDegree=1,this.dataX=null,this.dataY=null,this.qdt=null,this.varname=l.exists(i[0])?i[0]:\"x\",this.xterm=i[1],this.yterm=i[2],this.generateTerm(this.varname,this.xterm,this.yterm,i[3],i[4]),this.updateCurve(),this.id=this.board.setId(this,\"G\"),this.board.renderer.drawCurve(this),this.board.finalizeAdding(this),this.createGradient(),this.elType=\"curve\",this.createLabel(),\"string\"==typeof this.xterm&&this.notifyParents(this.xterm),\"string\"==typeof this.yterm&&this.notifyParents(this.yterm),this.methodMap=l.deepCopy(this.methodMap,{generateTerm:\"generateTerm\",setTerm:\"generateTerm\"})},t.Curve.prototype=new r,t.extend(t.Curve.prototype,{minX:function(){var t;return\"polar\"===this.visProp.curvetype?0:(t=new i(e.COORDS_BY_SCREEN,[0,0],this.board,!1),t.usrCoords[1])},maxX:function(){var t;return\"polar\"===this.visProp.curvetype?2*Math.PI:(t=new i(e.COORDS_BY_SCREEN,[this.board.canvasWidth,0],this.board,!1),t.usrCoords[1])},Z:function(){return 1},hasPoint:function(t,r,o){var n,h,c,d,u,p,f,m,b,g,v,C,y=this.visProp.numberpointslow,P=(this.maxX()-this.minX())/y,_=this.board.options.precision.hasPoint/this.board.unitX,S=1/0,E=!0;if(h=new i(e.COORDS_BY_SCREEN,[t,r],this.board,!1),t=h.usrCoords[1],r=h.usrCoords[2],this.transformations.length>0&&(this.updateTransformMatrix(),d=s.inverse(this.transformMat),u=s.matVecMult(d,[1,t,r]),t=u[1],r=u[2]),\"parameter\"===this.visProp.curvetype||\"polar\"===this.visProp.curvetype)for(_*=_,p=0,n=this.minX();y>p;p++){if(m=this.X(n,E),b=this.Y(n,E),S=(t-m)*(t-m)+(r-b)*(r-b),_>S)return!0;n+=P}else if(\"plot\"===this.visProp.curvetype||\"functiongraph\"===this.visProp.curvetype){for((!l.exists(o)||0>o)&&(o=0),l.exists(this.qdt)&&this.visProp.useqdt&&3!==this.bezierDegree?(C=this.qdt.query(new i(e.COORDS_BY_USER,[t,r],this.board)),v=C.points,c=v.length):(v=this.points,c=this.numberPoints-1),p=o;c>p;p++)for(g=[],3===this.bezierDegree?g.push(a.projectCoordsToBeziersegment([1,t,r],this,p)):C?(v[p].prev&&g.push(a.projectCoordsToSegment([1,t,r],v[p].prev.usrCoords,v[p].usrCoords)),v[p].next&&v[p+1]!==v[p].next&&g.push(a.projectCoordsToSegment([1,t,r],v[p].usrCoords,v[p].next.usrCoords))):g.push(a.projectCoordsToSegment([1,t,r],v[p].usrCoords,v[p+1].usrCoords)),f=0;f<g.length;f++)if(g[f][1]>=0&&g[f][1]<=1&&a.distance([1,t,r],g[f][0],3)<=_)return!0;return!1}return _>S},allocatePoints:function(){var t,r;if(r=this.numberPoints,this.points.length<this.numberPoints)for(t=this.points.length;r>t;t++)this.points[t]=new i(e.COORDS_BY_USER,[0,0],this.board,!1)},update:function(){return this.needsUpdate&&(this.visProp.trace&&this.cloneToBackground(!0),this.updateCurve()),this},updateRenderer:function(){var t;return this.needsUpdate&&this.visProp.visible&&(t=this.isReal,this.checkReal(),(this.isReal||t)&&this.board.renderer.updateCurve(this),this.isReal?t!==this.isReal&&(this.board.renderer.show(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.show(this.label.content)):t!==this.isReal&&(this.board.renderer.hide(this),this.hasLabel&&this.label.visProp.visible&&this.board.renderer.hide(this.label)),this.hasLabel&&l.exists(this.label.visProp)&&this.label.visProp.visible&&(this.label.update(),this.board.renderer.updateText(this.label))),this},updateDataArray:function(){},updateCurve:function(){var t,i,r,s,o,n,a=!1;if(this.updateTransformMatrix(),this.updateDataArray(),i=this.minX(),r=this.maxX(),l.exists(this.dataX))for(this.numberPoints=this.dataX.length,t=this.numberPoints,this.allocatePoints(),n=0;t>n;n++)s=n,l.exists(this.dataY)?(o=n,this.points[n].setCoordinates(e.COORDS_BY_USER,[this.dataX[n],this.dataY[n]],!1)):(o=this.X(s),this.points[n].setCoordinates(e.COORDS_BY_USER,[this.dataX[n],this.Y(o,a)],!1)),this.updateTransform(this.points[n]),a=!0;else{if(this.visProp.doadvancedplot?this.updateParametricCurve(i,r,t):this.visProp.doadvancedplotold?this.updateParametricCurveOld(i,r,t):(this.numberPoints=this.board.updateQuality===this.board.BOARD_QUALITY_HIGH?this.visProp.numberpointshigh:this.visProp.numberpointslow,this.allocatePoints(),this.updateParametricCurveNaive(i,r,this.numberPoints)),t=this.numberPoints,this.visProp.useqdt&&this.board.updateQuality===this.board.BOARD_QUALITY_HIGH)for(this.qdt=new d(this.board.getBoundingBox()),n=0;n<this.points.length;n++)this.qdt.insert(this.points[n]),n>0&&(this.points[n].prev=this.points[n-1]),t-1>n&&(this.points[n].next=this.points[n+1]);for(n=0;t>n;n++)this.updateTransform(this.points[n])}return this},updateTransformMatrix:function(){var t,e,i=this.transformations.length;for(this.transformMat=[[1,0,0],[0,1,0],[0,0,1]],e=0;i>e;e++)t=this.transformations[e],t.update(),this.transformMat=s.matMatMult(t.matrix,this.transformMat);return this},checkReal:function(){var t,e,i=!1,r=this.numberPoints;for(t=0;r>t;t++)if(e=this.points[t].usrCoords,!isNaN(e[1])&&!isNaN(e[2])&&Math.abs(e[0])>s.eps){i=!0;break}this.isReal=i},updateParametricCurveNaive:function(t,i,r){var s,o,n=!1,a=(i-t)/r;for(s=0;r>s;s++)o=t+s*a,this.points[s].setCoordinates(e.COORDS_BY_USER,[this.X(o,n),this.Y(o,n)],!1),n=!0;return this},updateParametricCurveOld:function(t,r){var o,n,a,h,l,c,d,u,p,f,m,b,g,v=!1,C=new i(e.COORDS_BY_USER,[0,0],this.board,!1),y=[],P=[],_=[],S=[],E=!1,O=0,w=function(t,e,i){var r,o,n=i[1]-t[1],a=i[2]-t[2],h=e[0]-t[1],l=e[1]-t[2],c=h*h+l*l;return c>=s.eps&&(r=(n*h+a*l)/c,r>0&&(1>=r?(n-=r*h,a-=r*l):(n-=h,a-=l))),o=n*n+a*a,Math.sqrt(o)};for(this.board.updateQuality===this.board.BOARD_QUALITY_LOW?(m=15,b=10,g=10):(m=21,b=.7,g=.7),S[0]=r-t,o=1;m>o;o++)S[o]=.5*S[o-1];o=1,y[0]=1,P[0]=0,n=t,C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1),v=!0,d=C.scrCoords[1],u=C.scrCoords[2],a=n,n=r,C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1),l=C.scrCoords[1],c=C.scrCoords[2],_[0]=[l,c],p=1,f=0,this.points=[],this.points[O++]=new i(e.COORDS_BY_SCREEN,[d,u],this.board,!1);do{for(E=this.isDistOK(l-d,c-u,b,g)||this.isSegmentOutside(d,u,l,c);m>f&&(!E||6>f)&&(7>=f||this.isSegmentDefined(d,u,l,c));)y[p]=o,P[p]=f,_[p]=[l,c],p+=1,o=2*o-1,f++,n=t+o*S[f],C.setCoordinates(e.COORDS_BY_USER,[this.X(n,v),this.Y(n,v)],!1,!0),l=C.scrCoords[1],c=C.scrCoords[2],E=this.isDistOK(l-d,c-u,b,g)||this.isSegmentOutside(d,u,l,c);O>1&&(h=w(this.points[O-2].scrCoords,[l,c],this.points[O-1].scrCoords),.015>h&&(O-=1)),this.points[O]=new i(e.COORDS_BY_SCREEN,[l,c],this.board,!1),O+=1,d=l,u=c,a=n,p-=1,l=_[p][0],c=_[p][1],f=P[p]+1,o=2*y[p]}while(p>0&&5e5>O);return this.numberPoints=this.points.length,this},isSegmentOutside:function(t,e,i,r){return 0>e&&0>r||e>this.board.canvasHeight&&r>this.board.canvasHeight||0>t&&0>i||t>this.board.canvasWidth&&i>this.board.canvasWidth},isDistOK:function(t,e,i,r){return Math.abs(t)<i&&Math.abs(e)<r&&!isNaN(t+e)},isSegmentDefined:function(t,e,i,r){return!(isNaN(t+e)&&isNaN(i+r))},_insertPoint:function(t){var e=!isNaN(this._lastCrds[1]+this._lastCrds[2]),i=!isNaN(t.scrCoords[1]+t.scrCoords[2]);(!i&&e||i&&(!e||Math.abs(t.scrCoords[1]-this._lastCrds[1])>.7||Math.abs(t.scrCoords[2]-this._lastCrds[2])>.7))&&(this.points.push(t),this._lastCrds=t.copy(\"scrCoords\"))},_borderCase:function(t,r,s,o,n,a,h){var l,c,d,u,p,f=null,m=5,b=70,g=!1;if(h<this.smoothLevel){if(c=new i(e.COORDS_BY_USER,[0,0],this.board,!1),isNaN(t[1]+t[2])&&!isNaN(s[1]+s[2]+r[1]+r[2]))for(u=0;b>u;++u){p=0;do l=.5*(o+a),c.setCoordinates(e.COORDS_BY_USER,[this.X(l,!0),this.Y(l,!0)],!1),d=c.scrCoords,g=isNaN(d[1]+d[2]),g&&(o=l),++p;while(g&&m>p);if(!(m>p))break;a=l,f=d.slice()}else if(isNaN(r[1]+r[2])&&!isNaN(s[1]+s[2]+t[1]+t[2]))for(u=0;b>u;++u){p=0;do l=.5*(a+n),c.setCoordinates(e.COORDS_BY_USER,[this.X(l,!0),this.Y(l,!0)],!1),d=c.scrCoords,g=isNaN(d[1]+d[2]),g&&(n=l),++p;while(g&&m>p);if(!(m>p))break;a=l,f=d.slice()}if(null!==f)return this._insertPoint(new i(e.COORDS_BY_SCREEN,f.slice(1),this.board,!1)),!0}return!1},_triangleDists:function(t,e,i){var r,s,o,n,h;return r=[t[0]*e[0],.5*(t[1]+e[1]),.5*(t[2]+e[2])],s=a.distance(t,e,3),o=a.distance(t,i,3),n=a.distance(i,e,3),h=a.distance(i,r,3),[s,o,n,h]},_plotRecursive:function(t,r,s,o,n,a){var h,l,c,d,u,p,f=0,m=.5,b=new i(e.COORDS_BY_USER,[0,0],this.board,!1);if(!(this.numberPoints>65536))return h=.5*(r+o),b.setCoordinates(e.COORDS_BY_USER,[this.X(h,!0),this.Y(h,!0)],!1),l=b.scrCoords,this._borderCase(t,s,l,r,o,h,n)?this:(c=this._triangleDists(t,s,l),d=n<this.smoothLevel&&c[3]<a,u=n<this.jumpLevel&&(c[2]>.99*c[0]||c[1]>.99*c[0]||1/0===c[0]||1/0===c[1]||1/0===c[2]),p=n<this.smoothLevel+2&&c[0]<m*(c[1]+c[2]),p&&(f=0,d=!1),--n,u?this._insertPoint(new i(e.COORDS_BY_SCREEN,[0/0,0/0],this.board,!1)):f>=n||d?this._insertPoint(b):(this._plotRecursive(t,r,l,h,n,a),this._insertPoint(b),this._plotRecursive(l,h,s,o,n,a)),this)},updateParametricCurve:function(t,r){var s,o,n,a,h,l,c=!1,d=new i(e.COORDS_BY_USER,[0,0],this.board,!1),u=new i(e.COORDS_BY_USER,[0,0],this.board,!1);return this.board.updateQuality===this.board.BOARD_QUALITY_LOW?(h=12,l=3,this.smoothLevel=h-5,this.jumpLevel=5):(h=17,l=.9,this.smoothLevel=h-9,this.jumpLevel=3),this.points=[],this._lastCrds=[0,0/0,0/0],s=t,d.setCoordinates(e.COORDS_BY_USER,[this.X(s,c),this.Y(s,c)],!1),n=d.copy(\"scrCoords\"),c=!0,o=r,u.setCoordinates(e.COORDS_BY_USER,[this.X(o,c),this.Y(o,c)],!1),a=u.copy(\"scrCoords\"),this.points.push(d),this._plotRecursive(n,s,a,o,h,l),this.points.push(u),this.numberPoints=this.points.length,this},updateTransform:function(t){var i,r=this.transformations.length;return r>0&&(i=s.matVecMult(this.transformMat,t.usrCoords),t.setPosition(e.COORDS_BY_USER,[i[1],i[2]])),t},addTransform:function(t){var e,i=l.isArray(t)?t:[t],r=i.length;for(e=0;r>e;e++)this.transformations.push(i[e]);return this},setPosition:function(t,e){var r,s,o,n=0;for(l.exists(this.parents)&&(n=this.parents.length),o=0;n>o;o++)if(s=this.board.select(this.parents[o]),!s.draggable())return this;if(e=new i(t,e,this.board,!1),r=this.board.create(\"transform\",e.usrCoords.slice(1),{type:\"translate\"}),n>0)for(o=0;n>o;o++)s=this.board.select(this.parents[o]),r.applyOnce(s);else this.transformations.length>0&&this.transformations[this.transformations.length-1].isNumericMatrix?this.transformations[this.transformations.length-1].melt(r):this.addTransform(r);return this},setPositionDirectly:function(t,r,s){var n=new i(t,r,this.board,!1),a=new i(t,s,this.board,!1),h=o.subtract(n.usrCoords,a.usrCoords);return this.setPosition(e.COORDS_BY_USER,h),this},interpolationFunctionFromArray:function(t){var e=\"data\"+t;return function(t){var i,r,s,o,n=this[e],a=n.length,h=[];\nif(isNaN(t))return 0/0;if(0>t)return l.isFunction(n[0])?n[0]():n[0];if(3===this.bezierDegree){if(a/=3,t>=a)return l.isFunction(n[n.length-1])?n[n.length-1]():n[n.length-1];for(i=3*Math.floor(t),s=t%1,o=1-s,r=0;4>r;r++)h[r]=l.isFunction(n[i+r])?n[i+r]():n[i+r];return o*o*(o*h[0]+3*s*h[1])+(3*o*h[2]+s*h[3])*s*s}if(i=t>a-2?a-2:parseInt(Math.floor(t),10),i===t)return l.isFunction(n[i])?n[i]():n[i];for(r=0;2>r;r++)h[r]=l.isFunction(n[i+r])?n[i+r]():n[i+r];return h[0]+(h[1]-h[0])*(t-i)}},generateTerm:function(t,e,i,r,s){var o,n;l.isArray(e)?(this.dataX=e,this.numberPoints=this.dataX.length,this.X=this.interpolationFunctionFromArray(\"X\"),this.visProp.curvetype=\"plot\",this.isDraggable=!0):(this.X=l.createFunction(e,this.board,t),l.isString(e)?this.visProp.curvetype=\"functiongraph\":(l.isFunction(e)||l.isNumber(e))&&(this.visProp.curvetype=\"parameter\"),this.isDraggable=!0),l.isArray(i)?(this.dataY=i,this.Y=this.interpolationFunctionFromArray(\"Y\")):this.Y=l.createFunction(i,this.board,t),l.isFunction(e)&&l.isArray(i)&&(o=l.createFunction(i[0],this.board,\"\"),n=l.createFunction(i[1],this.board,\"\"),this.X=function(t){return e(t)*Math.cos(t)+o()},this.Y=function(t){return e(t)*Math.sin(t)+n()},this.visProp.curvetype=\"polar\"),l.exists(r)&&(this.minX=l.createFunction(r,this.board,\"\")),l.exists(s)&&(this.maxX=l.createFunction(s,this.board,\"\"))},notifyParents:function(t){h.findDependencies(this,t,this.board)},getLabelAnchor:function(){var t,r,s,o=.05*this.board.canvasWidth,n=.05*this.board.canvasHeight,h=.95*this.board.canvasWidth,l=.95*this.board.canvasHeight;switch(this.visProp.label.position){case\"ulft\":r=o,s=n;break;case\"llft\":r=o,s=l;break;case\"rt\":r=h,s=.5*l;break;case\"lrt\":r=h,s=l;break;case\"urt\":r=h,s=n;break;case\"top\":r=.5*h,s=n;break;case\"bot\":r=.5*h,s=l;break;default:r=o,s=.5*l}return t=new i(e.COORDS_BY_SCREEN,[r,s],this.board,!1),a.projectCoordsToCurve(t.usrCoords[1],t.usrCoords[2],0,this,this.board)[0]},cloneToBackground:function(){var t,i={id:this.id+\"T\"+this.numTraces,elementClass:e.OBJECT_CLASS_CURVE,points:this.points.slice(0),bezierDegree:this.bezierDegree,numberPoints:this.numberPoints,board:this.board,visProp:l.deepCopy(this.visProp,this.visProp.traceattributes,!0)};return i.visProp.layer=this.board.options.layer.trace,i.visProp.curvetype=this.visProp.curvetype,this.numTraces++,l.clearVisPropOld(i),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawCurve(i),this.board.renderer.enhancedRendering=t,this.traces[i.id]=i.rendNode,this},bounds:function(){var t,e=1/0,i=-1/0,r=1/0,s=-1/0,o=this.points.length;for(t=0;o>t;t++)e>this.points[t].usrCoords[1]&&(e=this.points[t].usrCoords[1]),i<this.points[t].usrCoords[1]&&(i=this.points[t].usrCoords[1]),r>this.points[t].usrCoords[2]&&(r=this.points[t].usrCoords[2]),s<this.points[t].usrCoords[2]&&(s=this.points[t].usrCoords[2]);return[e,s,i,r]}}),t.createCurve=function(e,i,r){var s=l.copyAttributes(r,e.options,\"curve\");return new t.Curve(e,[\"x\"].concat(i),s)},t.registerElement(\"curve\",t.createCurve),t.createFunctiongraph=function(e,i,r){var s,o=[\"x\",\"x\"].concat(i);return s=l.copyAttributes(r,e.options,\"curve\"),s.curvetype=\"functiongraph\",new t.Curve(e,o,s)},t.registerElement(\"functiongraph\",t.createFunctiongraph),t.registerElement(\"plot\",t.createFunctiongraph),t.createSpline=function(t,e,i){var r;return r=function(){var t,i=[],r=[];return function(s,o){var a;if(!o){if(i=[],r=[],2===e.length&&l.isArray(e[0])&&l.isArray(e[1])&&e[0].length===e[1].length)for(a=0;a<e[0].length;a++)\"function\"==typeof e[0][a]?i.push(e[0][a]()):i.push(e[0][a]),\"function\"==typeof e[1][a]?r.push(e[1][a]()):r.push(e[1][a]);else for(a=0;a<e.length;a++)if(l.isPoint(e[a]))i.push(e[a].X()),r.push(e[a].Y());else if(l.isArray(e[a])&&2===e[a].length)for(a=0;a<e.length;a++)\"function\"==typeof e[a][0]?i.push(e[a][0]()):i.push(e[a][0]),\"function\"==typeof e[a][1]?r.push(e[a][1]()):r.push(e[a][1]);t=n.splineDef(i,r)}return n.splineEval(s,i,r,t)}},t.create(\"curve\",[\"x\",r()],i)},t.registerElement(\"spline\",t.createSpline),t.createRiemannsum=function(t,e,i){var r,s,o,a,h,c;if(c=l.copyAttributes(i,t.options,\"riemannsum\"),c.curvetype=\"plot\",o=e[0],r=l.createFunction(e[1],t,\"\"),!l.exists(r))throw new Error(\"JSXGraph: JXG.createRiemannsum: argument '2' n has to be number or function.\\nPossible parent types: [function,n:number|function,type,start:number|function,end:number|function]\");if(s=l.createFunction(e[2],t,\"\",!1),!l.exists(s))throw new Error(\"JSXGraph: JXG.createRiemannsum: argument 3 'type' has to be string or function.\\nPossible parent types: [function,n:number|function,type,start:number|function,end:number|function]\");return a=[[0],[0]].concat(e.slice(3)),h=t.create(\"curve\",a,c),h.sum=0,h.Value=function(){return this.sum},h.updateDataArray=function(){var t=n.riemann(o,r(),s(),this.minX(),this.maxX());this.dataX=t[0],this.dataY=t[1],this.sum=t[2]},h},t.registerElement(\"riemannsum\",t.createRiemannsum),t.createTracecurve=function(t,i,r){var s,o,n,a;if(2!==i.length)throw new Error(\"JSXGraph: Can't create trace curve with given parent'\\nPossible parent types: [glider, point]\");if(o=t.select(i[0]),n=t.select(i[1]),o.type!==e.OBJECT_TYPE_GLIDER||!l.isPoint(n))throw new Error(\"JSXGraph: Can't create trace curve with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [glider, point]\");return a=l.copyAttributes(r,t.options,\"tracecurve\"),a.curvetype=\"plot\",s=t.create(\"curve\",[[0],[0]],a),s.updateDataArray=function(){var t,i,r,s,h,l,c,d,u,p=a.numberpoints,f=o.position,m=o.slideObject,b=m.minX(),g=m.maxX();for(i=(g-b)/p,this.dataX=[],this.dataY=[],m.elementClass!==e.OBJECT_CLASS_CURVE&&p++,t=0;p>t;t++){r=b+t*i,l=m.X(r)/m.Z(r),c=m.Y(r)/m.Z(r),o.setPositionDirectly(e.COORDS_BY_USER,[l,c]),d=!1;for(s in this.board.objects)if(this.board.objects.hasOwnProperty(s)&&(h=this.board.objects[s],h===o&&(d=!0),d&&h.needsRegularUpdate&&(u=h.visProp.trace,h.visProp.trace=!1,h.needsUpdate=!0,h.update(!0),h.visProp.trace=u,h===n)))break;this.dataX[t]=n.X(),this.dataY[t]=n.Y()}o.position=f,d=!1;for(s in this.board.objects)if(this.board.objects.hasOwnProperty(s)&&(h=this.board.objects[s],h===o&&(d=!0),d&&h.needsRegularUpdate&&(u=h.visProp.trace,h.visProp.trace=!1,h.needsUpdate=!0,h.update(!0),h.visProp.trace=u,h===n)))break},s},t.registerElement(\"tracecurve\",t.createTracecurve),t.createStepfunction=function(t,e,i){var r,s;if(2!==e.length)throw new Error(\"JSXGraph: Can't create step function with given parent'\\nPossible parent types: [array, array|function]\");return s=l.copyAttributes(i,t.options,\"stepfunction\"),r=t.create(\"curve\",e,s),r.updateDataArray=function(){var t,e=0,i=this.xterm.length;if(this.dataX=[],this.dataY=[],0!==i)for(this.dataX[e]=this.xterm[0],this.dataY[e]=this.yterm[0],++e,t=1;i>t;++t)this.dataX[e]=this.xterm[t],this.dataY[e]=this.dataY[e-1],++e,this.dataX[e]=this.xterm[t],this.dataY[e]=this.yterm[t],++e},r},t.registerElement(\"stepfunction\",t.createStepfunction),{Curve:t.Curve,createCurve:t.createCurve,createFunctiongraph:t.createFunctiongraph,createPlot:t.createPlot,createSpline:t.createSpline,createRiemannsum:t.createRiemannsum,createTracecurve:t.createTracecurve,createStepfunction:t.createStepfunction}}),define(\"element/composition\",[\"jxg\",\"math/math\",\"math/geometry\",\"math/numerics\",\"math/statistics\",\"base/coords\",\"utils/type\",\"base/constants\",\"base/point\",\"base/line\",\"base/circle\",\"base/transformation\",\"base/composition\",\"base/curve\",\"base/text\"],function(t,e,i,r,s,o,n,a,h,l,c,d,u){return t.createOrthogonalProjection=function(t,e,r){var s,o,h,l;if(n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],s=e[1];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create perpendicular point with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,line]\");o=e[1],s=e[0]}return l=n.copyAttributes(r,t.options,\"orthogonalprojection\"),h=t.create(\"point\",[function(){return i.projectPointToLine(o,s,t)}],l),o.addChild(h),s.addChild(h),h.elType=\"orthogonalprojection\",h.parents=[o.id,h.id],h.update(),h.generatePolynomial=function(){var t=s.point1.symbolic.x,e=s.point1.symbolic.y,i=s.point2.symbolic.x,r=s.point2.symbolic.y,n=o.symbolic.x,a=o.symbolic.y,l=h.symbolic.x,c=h.symbolic.y,d=\"(\"+e+\")*(\"+l+\")-(\"+e+\")*(\"+i+\")+(\"+c+\")*(\"+i+\")-(\"+t+\")*(\"+c+\")+(\"+t+\")*(\"+r+\")-(\"+l+\")*(\"+r+\")\",u=\"(\"+a+\")*(\"+e+\")-(\"+a+\")*(\"+r+\")-(\"+c+\")*(\"+e+\")+(\"+c+\")*(\"+r+\")+(\"+n+\")*(\"+t+\")-(\"+n+\")*(\"+i+\")-(\"+l+\")*(\"+t+\")+(\"+l+\")*(\"+i+\")\";return[d,u]},h},t.createPerpendicular=function(t,e,i){var r,s,o,h;if(e[0]=t.select(e[0]),e[1]=t.select(e[1]),n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)s=e[1],r=e[0];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create perpendicular with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [line,point]\");s=e[0],r=e[1]}return h=n.copyAttributes(i,t.options,\"perpendicular\"),o=l.createLine(t,[function(){return s.stdform[2]*r.X()-s.stdform[1]*r.Y()},function(){return-s.stdform[2]*r.Z()},function(){return s.stdform[1]*r.Z()}],h),o.elType=\"perpendicular\",o.parents=[s.id,r.id],o},t.createPerpendicularPoint=function(t,e,r){var s,o,h;if(n.isPoint(e[0])&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],s=e[1];else{if(!n.isPoint(e[1])||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create perpendicular point with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,line]\");o=e[1],s=e[0]}return h=t.create(\"point\",[function(){return i.perpendicular(s,o,t)[0]}],r),o.addChild(h),s.addChild(h),h.elType=\"perpendicularpoint\",h.parents=[o.id,s.id],h.update(),h.generatePolynomial=function(){var t=s.point1.symbolic.x,e=s.point1.symbolic.y,i=s.point2.symbolic.x,r=s.point2.symbolic.y,n=o.symbolic.x,a=o.symbolic.y,l=h.symbolic.x,c=h.symbolic.y,d=\"(\"+e+\")*(\"+l+\")-(\"+e+\")*(\"+i+\")+(\"+c+\")*(\"+i+\")-(\"+t+\")*(\"+c+\")+(\"+t+\")*(\"+r+\")-(\"+l+\")*(\"+r+\")\",u=\"(\"+a+\")*(\"+e+\")-(\"+a+\")*(\"+r+\")-(\"+c+\")*(\"+e+\")+(\"+c+\")*(\"+r+\")+(\"+n+\")*(\"+t+\")-(\"+n+\")*(\"+i+\")-(\"+l+\")*(\"+t+\")+(\"+l+\")*(\"+i+\")\";return[d,u]},h},t.createPerpendicularSegment=function(e,r,s){var o,h,c,d,u;if(r[0]=e.select(r[0]),r[1]=e.select(r[1]),n.isPoint(r[0])&&r[1].elementClass===a.OBJECT_CLASS_LINE)h=r[1],o=r[0];else{if(!n.isPoint(r[1])||r[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create perpendicular with parent types '\"+typeof r[0]+\"' and '\"+typeof r[1]+\"'.\"+\"\\nPossible parent types: [line,point]\");h=r[0],o=r[1]}return u=n.copyAttributes(s,e.options,\"perpendicularsegment\",\"point\"),d=t.createPerpendicularPoint(e,[h,o],u),d.dump=!1,n.exists(s.layer)||(s.layer=e.options.layer.line),u=n.copyAttributes(s,e.options,\"perpendicularsegment\"),c=l.createLine(e,[function(){return i.perpendicular(h,o,e)[1]?[d,o]:[o,d]}],u),c.point=d,c.elType=\"perpendicularsegment\",c.parents=[o.id,h.id],c.subs={point:d},c},t.createMidpoint=function(t,i,r){var s,o,h;if(2===i.length&&n.isPoint(i[0])&&n.isPoint(i[1]))s=i[0],o=i[1];else{if(1!==i.length||i[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create midpoint.\\nPossible parent types: [point,point], [line]\");s=i[0].point1,o=i[0].point2}return h=t.create(\"point\",[function(){var t=s.coords.usrCoords[1]+o.coords.usrCoords[1];return isNaN(t)||Math.abs(s.coords.usrCoords[0])<e.eps||Math.abs(o.coords.usrCoords[0])<e.eps?0/0:.5*t},function(){var t=s.coords.usrCoords[2]+o.coords.usrCoords[2];return isNaN(t)||Math.abs(s.coords.usrCoords[0])<e.eps||Math.abs(o.coords.usrCoords[0])<e.eps?0/0:.5*t}],r),s.addChild(h),o.addChild(h),h.elType=\"midpoint\",h.parents=[s.id,o.id],h.prepareUpdate().update(),h.generatePolynomial=function(){var t=s.symbolic.x,e=s.symbolic.y,i=o.symbolic.x,r=o.symbolic.y,n=h.symbolic.x,a=h.symbolic.y,l=\"(\"+e+\")*(\"+n+\")-(\"+e+\")*(\"+i+\")+(\"+a+\")*(\"+i+\")-(\"+t+\")*(\"+a+\")+(\"+t+\")*(\"+r+\")-(\"+n+\")*(\"+r+\")\",c=\"(\"+t+\")^2 - 2*(\"+t+\")*(\"+n+\")+(\"+e+\")^2-2*(\"+e+\")*(\"+a+\")-(\"+i+\")^2+2*(\"+i+\")*(\"+n+\")-(\"+r+\")^2+2*(\"+r+\")*(\"+a+\")\";return[l,c]},h},t.createParallelPoint=function(t,e,i){var r,s,o,n;if(3===e.length&&e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT)r=e[0],s=e[1],o=e[2];else if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_LINE)o=e[0],r=e[1].point1,s=e[1].point2;else{if(e[1].elementClass!==a.OBJECT_CLASS_POINT||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create parallel point with parent types '\"+typeof e[0]+\"', '\"+typeof e[1]+\"' and '\"+typeof e[2]+\"'.\"+\"\\nPossible parent types: [line,point], [point,point,point]\");o=e[1],r=e[0].point1,s=e[0].point2}return n=t.create(\"point\",[function(){return o.coords.usrCoords[1]+s.coords.usrCoords[1]-r.coords.usrCoords[1]},function(){return o.coords.usrCoords[2]+s.coords.usrCoords[2]-r.coords.usrCoords[2]}],i),r.addChild(n),s.addChild(n),o.addChild(n),n.elType=\"parallelpoint\",n.parents=[r.id,s.id,o.id],n.prepareUpdate().update(),n.generatePolynomial=function(){var t=r.symbolic.x,e=r.symbolic.y,i=s.symbolic.x,a=s.symbolic.y,h=o.symbolic.x,l=o.symbolic.y,c=n.symbolic.x,d=n.symbolic.y,u=\"(\"+a+\")*(\"+c+\")-(\"+a+\")*(\"+h+\")-(\"+e+\")*(\"+c+\")+(\"+e+\")*(\"+h+\")-(\"+d+\")*(\"+i+\")+(\"+d+\")*(\"+t+\")+(\"+l+\")*(\"+i+\")-(\"+l+\")*(\"+t+\")\",p=\"(\"+d+\")*(\"+t+\")-(\"+d+\")*(\"+h+\")-(\"+a+\")*(\"+t+\")+(\"+a+\")*(\"+h+\")-(\"+c+\")*(\"+e+\")+(\"+c+\")*(\"+l+\")+(\"+i+\")*(\"+e+\")-(\"+i+\")*(\"+l+\")\";return[u,p]},n},t.createParallel=function(t,i,r){var s,o,h,l,c;return s=null,3===i.length?(s=i[2],l=function(){return e.crossProduct(i[0].coords.usrCoords,i[1].coords.usrCoords)}):i[0].elementClass===a.OBJECT_CLASS_POINT?(s=i[0],l=function(){return i[1].stdform}):i[1].elementClass===a.OBJECT_CLASS_POINT&&(s=i[1],l=function(){return i[0].stdform}),n.exists(r.layer)||(r.layer=t.options.layer.line),c=n.copyAttributes(r,t.options,\"parallel\",\"point\"),o=t.create(\"point\",[function(){return e.crossProduct([1,0,0],l())}],c),o.isDraggable=!0,c=n.copyAttributes(r,t.options,\"parallel\"),h=t.create(\"line\",[s,o],c),h.elType=\"parallel\",h.parents=[i[0].id,i[1].id],3===i.length&&h.parents.push(i[2].id),h.point=o,h},t.createArrowParallel=function(e,i,r){var s;try{return r.firstArrow=!1,r.lastArrow=!0,s=t.createParallel(e,i,r).setAttribute({straightFirst:!1,straightLast:!1}),s.elType=\"arrowparallel\",s}catch(o){throw new Error(\"JSXGraph: Can't create arrowparallel with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [line,point], [point,point,point]\")}},t.createNormal=function(t,i,s){var o,h,l,c,d,u,p,f,m;if(1===i.length)o=i[0],h=o.slideObject;else{if(2!==i.length)throw new Error(\"JSXGraph: Can't create normal with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,line], [point,circle], [glider]\");if(n.isPoint(i[0]))o=i[0],h=i[1];else{if(!n.isPoint(i[1]))throw new Error(\"JSXGraph: Can't create normal with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,line], [point,circle], [glider]\");h=i[0],o=i[1]}}if(p=n.copyAttributes(s,t.options,\"normal\"),h.elementClass===a.OBJECT_CLASS_LINE)m=n.copyAttributes(s,t.options,\"normal\",\"point\"),f=t.create(\"point\",[function(){var t=e.crossProduct([1,0,0],h.stdform);return[t[0],-t[2],t[1]]}],m),f.isDraggable=!0,l=t.create(\"line\",[o,f],p),l.point=f;else if(h.elementClass===a.OBJECT_CLASS_CIRCLE)l=t.create(\"line\",[h.midpoint,o],p);else if(h.elementClass===a.OBJECT_CLASS_CURVE)\"plot\"!==h.visProp.curvetype?(d=h.X,u=h.Y,l=t.create(\"line\",[function(){return-o.X()*r.D(d)(o.position)-o.Y()*r.D(u)(o.position)},function(){return r.D(d)(o.position)},function(){return r.D(u)(o.position)}],p)):l=t.create(\"line\",[function(){var t=Math.floor(o.position),e=o.position-t;return t===h.numberPoints-1&&(t-=1,e=1),0>t?1:(h.Y(t)+e*(h.Y(t+1)-h.Y(t)))*(h.Y(t)-h.Y(t+1))-(h.X(t)+e*(h.X(t+1)-h.X(t)))*(h.X(t+1)-h.X(t))},function(){var t=Math.floor(o.position);return t===h.numberPoints-1&&(t-=1),0>t?0:h.X(t+1)-h.X(t)},function(){var t=Math.floor(o.position);return t===h.numberPoints-1&&(t-=1),0>t?0:h.Y(t+1)-h.Y(t)}],p);else{if(h.type!==a.OBJECT_TYPE_TURTLE)throw new Error(\"JSXGraph: Can't create normal with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,line], [point,circle], [glider]\");l=t.create(\"line\",[function(){var t,e,i=Math.floor(o.position),r=o.position-i;for(e=0;e<h.objects.length;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(i<t.numberPoints)break;i-=t.numberPoints}return i===t.numberPoints-1&&(i-=1,r=1),0>i?1:(t.Y(i)+r*(t.Y(i+1)-t.Y(i)))*(t.Y(i)-t.Y(i+1))-(t.X(i)+r*(t.X(i+1)-t.X(i)))*(t.X(i+1)-t.X(i))},function(){var t,e,i=Math.floor(o.position);for(e=0;e<h.objects.length;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(i<t.numberPoints)break;i-=t.numberPoints}return i===t.numberPoints-1&&(i-=1),0>i?0:t.X(i+1)-t.X(i)},function(){var t,e,i=Math.floor(o.position);for(e=0;e<h.objects.length;e++)if(t=h.objects[e],t.type===a.OBJECT_TYPE_CURVE){if(i<t.numberPoints)break;i-=t.numberPoints}return i===t.numberPoints-1&&(i-=1),0>i?0:t.Y(i+1)-t.Y(i)}],p)}for(l.parents=[],c=0;c<i.length;c++)l.parents.push(i[c].id);return l.elType=\"normal\",l},t.createBisector=function(t,e,r){var s,o,h,c;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT){for(c=n.copyAttributes(r,t.options,\"bisector\",\"point\"),c.snapToGrid=!1,s=t.create(\"point\",[function(){return i.angleBisector(e[0],e[1],e[2],t)}],c),s.dump=!1,h=0;3>h;h++)e[h].addChild(s);return n.exists(r.layer)||(r.layer=t.options.layer.line),c=n.copyAttributes(r,t.options,\"bisector\"),o=l.createLine(t,[e[1],s],c),o.point=s,o.elType=\"bisector\",o.parents=[e[0].id,e[1].id,e[2].id],o.subs={point:s},o}throw new Error(\"JSXGraph: Can't create angle bisector with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,point,point]\")},t.createAngularBisectorsOfTwoLines=function(t,e,i){var r,s,o,h,l=t.select(e[0]),c=t.select(e[1]);if(l.elementClass!==a.OBJECT_CLASS_LINE||c.elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create angle bisectors of two lines with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [line,line]\");return n.exists(i.layer)||(i.layer=t.options.layer.line),o=n.copyAttributes(i,t.options,\"bisectorlines\",\"line1\"),r=t.create(\"line\",[function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[0]/t-c.stdform[0]/e},function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[1]/t-c.stdform[1]/e},function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[2]/t-c.stdform[2]/e}],o),n.exists(i.layer)||(i.layer=t.options.layer.line),o=n.copyAttributes(i,t.options,\"bisectorlines\",\"line2\"),s=t.create(\"line\",[function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[0]/t+c.stdform[0]/e},function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[1]/t+c.stdform[1]/e},function(){var t=Math.sqrt(l.stdform[1]*l.stdform[1]+l.stdform[2]*l.stdform[2]),e=Math.sqrt(c.stdform[1]*c.stdform[1]+c.stdform[2]*c.stdform[2]);return l.stdform[2]/t+c.stdform[2]/e}],o),h=new u({line1:r,line2:s}),r.dump=!1,s.dump=!1,h.elType=\"bisectorlines\",h.parents=[l.id,c.id],h.subs={line1:r,line2:s},h},t.createCircumcenter=function(t,e,r){var s,o,n,l,c;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_POINT&&e[2].elementClass===a.OBJECT_CLASS_POINT){for(n=e[0],l=e[1],c=e[2],s=h.createPoint(t,[function(){return i.circumcenterMidpoint(n,l,c,t)}],r),o=0;3>o;o++)e[o].addChild(s);return s.elType=\"circumcenter\",s.parents=[n.id,l.id,c.id],s.generatePolynomial=function(){var t=n.symbolic.x,e=n.symbolic.y,i=l.symbolic.x,r=l.symbolic.y,o=c.symbolic.x,a=c.symbolic.y,h=s.symbolic.x,d=s.symbolic.y,u=[\"((\",h,\")-(\",t,\"))^2+((\",d,\")-(\",e,\"))^2-((\",h,\")-(\",i,\"))^2-((\",d,\")-(\",r,\"))^2\"].join(\"\"),p=[\"((\",h,\")-(\",t,\"))^2+((\",d,\")-(\",e,\"))^2-((\",h,\")-(\",o,\"))^2-((\",d,\")-(\",a,\"))^2\"].join(\"\");return[u,p]},s}throw new Error(\"JSXGraph: Can't create circumcircle midpoint with parent types '\"+typeof e[0]+\"', '\"+typeof e[1]+\"' and '\"+typeof e[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\")},t.createIncenter=function(t,e,i){var r,s,h,l;if(!(e.length>=3&&n.isPoint(e[0])&&n.isPoint(e[1])&&n.isPoint(e[2])))throw new Error(\"JSXGraph: Can't create incenter with parent types '\"+typeof e[0]+\"', '\"+typeof e[1]+\"' and '\"+typeof e[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\");return s=e[0],h=e[1],l=e[2],r=t.create(\"point\",[function(){var e,i,r;return e=Math.sqrt((h.X()-l.X())*(h.X()-l.X())+(h.Y()-l.Y())*(h.Y()-l.Y())),i=Math.sqrt((s.X()-l.X())*(s.X()-l.X())+(s.Y()-l.Y())*(s.Y()-l.Y())),r=Math.sqrt((h.X()-s.X())*(h.X()-s.X())+(h.Y()-s.Y())*(h.Y()-s.Y())),new o(a.COORDS_BY_USER,[(e*s.X()+i*h.X()+r*l.X())/(e+i+r),(e*s.Y()+i*h.Y()+r*l.Y())/(e+i+r)],t)}],i),r.elType=\"incenter\",r.parents=[e[0].id,e[1].id,e[2].id],r},t.createCircumcircle=function(e,i,r){var s,o,a;try{a=n.copyAttributes(r,e.options,\"circumcircle\",\"center\"),s=t.createCircumcenter(e,i,a),s.dump=!1,n.exists(r.layer)||(r.layer=e.options.layer.circle),a=n.copyAttributes(r,e.options,\"circumcircle\"),o=c.createCircle(e,[s,i[0]],a),o.elType=\"circumcircle\",o.parents=[i[0].id,i[1].id,i[2].id],o.subs={center:s}}catch(h){throw new Error(\"JSXGraph: Can't create circumcircle with parent types '\"+typeof i[0]+\"', '\"+typeof i[1]+\"' and '\"+typeof i[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\")}return o},t.createIncircle=function(e,i,r){var s,o,a;try{a=n.copyAttributes(r,e.options,\"incircle\",\"center\"),s=t.createIncenter(e,i,a),s.dump=!1,n.exists(r.layer)||(r.layer=e.options.layer.circle),a=n.copyAttributes(r,e.options,\"incircle\"),o=c.createCircle(e,[s,function(){var t=Math.sqrt((i[1].X()-i[2].X())*(i[1].X()-i[2].X())+(i[1].Y()-i[2].Y())*(i[1].Y()-i[2].Y())),e=Math.sqrt((i[0].X()-i[2].X())*(i[0].X()-i[2].X())+(i[0].Y()-i[2].Y())*(i[0].Y()-i[2].Y())),r=Math.sqrt((i[1].X()-i[0].X())*(i[1].X()-i[0].X())+(i[1].Y()-i[0].Y())*(i[1].Y()-i[0].Y())),s=(t+e+r)/2;return Math.sqrt((s-t)*(s-e)*(s-r)/s)}],a),o.elType=\"incircle\",o.parents=[i[0].id,i[1].id,i[2].id],o.center=s,o.subs={center:s}}catch(h){throw new Error(\"JSXGraph: Can't create circumcircle with parent types '\"+typeof i[0]+\"', '\"+typeof i[1]+\"' and '\"+typeof i[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\")}return o},t.createReflection=function(t,e,i){var r,s,o,n;if(e[0].elementClass===a.OBJECT_CLASS_POINT&&e[1].elementClass===a.OBJECT_CLASS_LINE)s=e[0],r=e[1];else{if(e[1].elementClass!==a.OBJECT_CLASS_POINT||e[0].elementClass!==a.OBJECT_CLASS_LINE)throw new Error(\"JSXGraph: Can't create reflection point with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [line,point]\");s=e[1],r=e[0]}return n=d.createTransform(t,[r],{type:\"reflect\"}),o=h.createPoint(t,[s,n],i),s.addChild(o),r.addChild(o),o.elType=\"reflection\",o.parents=[e[0].id,e[1].id],o.prepareUpdate().update(),o.generatePolynomial=function(){var t=r.point1.symbolic.x,e=r.point1.symbolic.y,i=r.point2.symbolic.x,n=r.point2.symbolic.y,a=s.symbolic.x,h=s.symbolic.y,l=o.symbolic.x,c=o.symbolic.y,d=[\"((\",c,\")-(\",h,\"))*((\",e,\")-(\",n,\"))+((\",t,\")-(\",i,\"))*((\",l,\")-(\",a,\"))\"].join(\"\"),u=[\"((\",l,\")-(\",t,\"))^2+((\",c,\")-(\",e,\"))^2-((\",a,\")-(\",t,\"))^2-((\",h,\")-(\",e,\"))^2\"].join(\"\");return[d,u]},o},t.createMirrorPoint=function(t,e,r){var s,o;if(!n.isPoint(e[0])||!n.isPoint(e[1]))throw new Error(\"JSXGraph: Can't create mirror point with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,point]\");for(s=h.createPoint(t,[function(){return i.rotation(e[0],e[1],Math.PI,t)}],r),o=0;2>o;o++)e[o].addChild(s);return s.elType=\"mirrorpoint\",s.parents=[e[0].id,e[1].id],s.prepareUpdate().update(),s},t.createIntegral=function(e,i,s){var h,l,c,d,u,p,f,m,b,g,v,C,y,P,_=null;if(n.isArray(i[0])&&i[1].elementClass===a.OBJECT_CLASS_CURVE)h=i[0],l=i[1];else{if(!n.isArray(i[1])||i[0].elementClass!==a.OBJECT_CLASS_CURVE)throw new Error(\"JSXGraph: Can't create integral with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [[number|function,number|function],curve]\");h=i[1],l=i[0]}return c=n.copyAttributes(s,e.options,\"integral\"),c.withLabel=!1,P=e.create(\"curve\",[[0],[0]],c),d=h[0],u=h[1],n.isFunction(d)?(p=d,f=function(){return l.Y(p())},d=p()):(p=d,f=l.Y(d)),n.isFunction(u)?(m=u,b=function(){return l.Y(m())},u=m()):(m=u,b=l.Y(u)),c=n.copyAttributes(s,e.options,\"integral\",\"curveLeft\"),g=e.create(\"glider\",[p,f,l],c),n.isFunction(p)&&g.hideElement(),c=n.copyAttributes(s,e.options,\"integral\",\"baseLeft\"),v=e.create(\"point\",[function(){return\"y\"===P.visProp.axis?0:g.X()},function(){return\"y\"===P.visProp.axis?g.Y():0}],c),c=n.copyAttributes(s,e.options,\"integral\",\"curveRight\"),C=e.create(\"glider\",[m,b,l],c),n.isFunction(m)&&C.hideElement(),c=n.copyAttributes(s,e.options,\"integral\",\"baseRight\"),y=e.create(\"point\",[function(){return\"y\"===P.visProp.axis?0:C.X()},function(){return\"y\"===P.visProp.axis?C.Y():0}],c),c=n.copyAttributes(s,e.options,\"integral\"),c.withlabel!==!1&&\"y\"!==c.axis&&(c=n.copyAttributes(s,e.options,\"integral\",\"label\"),c=n.copyAttributes(c,e.options,\"label\"),_=e.create(\"text\",[function(){var t=new o(a.COORDS_BY_SCREEN,[this.visProp.offset[0]+this.board.origin.scrCoords[1],0],this.board,!1);return C.X()+t.usrCoords[1]},function(){var t=new o(a.COORDS_BY_SCREEN,[0,this.visProp.offset[1]+this.board.origin.scrCoords[2]],this.board,!1);return C.Y()+t.usrCoords[2]},function(){var t=r.I([v.X(),y.X()],l.Y);return\"∫ = \"+t.toFixed(4)}],c),_.dump=!1,g.addChild(_),C.addChild(_)),g.dump=!1,v.dump=!1,C.dump=!1,y.dump=!1,P.elType=\"integral\",P.parents=[l.id,h],P.subs={curveLeft:g,baseLeft:v,curveRight:C,baseRight:y},c.withLabel&&(P.subs.label=_),P.Value=function(){return r.I([v.X(),y.X()],l.Y)},P.updateDataArray=function(){var t,e,i,r,s,o,n,a,h;if(\"y\"===this.visProp.axis){for(g.Y()<C.Y()?(o=g.X(),a=g.Y(),n=C.X(),h=C.Y()):(o=C.X(),a=C.Y(),n=g.X(),h=g.Y()),r=Math.min(o,n),s=Math.max(o,n),t=[0,o],e=[a,a],i=0;i<l.numberPoints;i++)a<=l.points[i].usrCoords[2]&&r<=l.points[i].usrCoords[1]&&l.points[i].usrCoords[2]<=h&&l.points[i].usrCoords[1]<=s&&(t.push(l.points[i].usrCoords[1]),e.push(l.points[i].usrCoords[2]));t.push(n),e.push(h),t.push(0),e.push(h),t.push(0),e.push(a)}else{for(v.X()<y.X()?(r=v.X(),s=y.X()):(r=y.X(),s=v.X()),t=[r,r],e=[0,l.Y(r)],i=0;i<l.numberPoints;i++)r<=l.points[i].usrCoords[1]&&l.points[i].usrCoords[1]<=s&&(t.push(l.points[i].usrCoords[1]),e.push(l.points[i].usrCoords[2]));t.push(s),e.push(l.Y(s)),t.push(s),e.push(0),t.push(r),e.push(0)}this.dataX=t,this.dataY=e},g.addChild(P),C.addChild(P),P.baseLeft=v,P.baseRight=y,P.curveLeft=g,P.curveRight=C,P.methodMap=t.deepCopy(P.methodMap,{curveLeft:\"curveLeft\",baseLeft:\"baseLeft\",curveRight:\"curveRight\",baseRight:\"baseRight\",Value:\"Value\"}),P.label=_,P},t.createGrid=function(t,e,i){var r,s;return s=n.copyAttributes(i,t.options,\"grid\"),r=t.create(\"curve\",[[null],[null]],s),r.elType=\"grid\",r.parents=[],r.type=a.OBJECT_TYPE_GRID,r.updateDataArray=function(){var e,i,s,h,l,c=this.visProp.gridx,d=this.visProp.gridy;for(h=n.isArray(this.visProp.topleft)?new o(this.visProp.tltype||a.COORDS_BY_USER,this.visProp.topleft,t):new o(a.COORDS_BY_SCREEN,[0,0],t),l=n.isArray(this.visProp.bottomright)?new o(this.visProp.brtype||a.COORDS_BY_USER,this.visProp.bottomright,t):new o(a.COORDS_BY_SCREEN,[t.canvasWidth,t.canvasHeight],t),t.options.grid.hasGrid=!0,h.setCoordinates(a.COORDS_BY_USER,[Math.floor(h.usrCoords[1]/c)*c,Math.ceil(h.usrCoords[2]/d)*d]),l.setCoordinates(a.COORDS_BY_USER,[Math.ceil(l.usrCoords[1]/c)*c,Math.floor(l.usrCoords[2]/d)*d]),r.dataX=[],r.dataY=[],e=h.usrCoords[2],i=l.usrCoords[2],h.usrCoords[2]<l.usrCoords[2]&&(e=l.usrCoords[2],i=h.usrCoords[2]),s=e;s>i-d;s-=d)r.dataX.push(h.usrCoords[1],l.usrCoords[1],0/0),r.dataY.push(s,s,0/0);for(e=h.usrCoords[1],i=l.usrCoords[1],h.usrCoords[1]>l.usrCoords[1]&&(e=l.usrCoords[1],i=h.usrCoords[1]),s=e;i+c>s;s+=c)r.dataX.push(s,s,0/0),r.dataY.push(h.usrCoords[2],l.usrCoords[2],0/0)},r.hasPoint=function(){return!1},t.grids.push(r),r},t.createInequality=function(t,r,o){var h,l,c;if(c=n.copyAttributes(o,t.options,\"inequality\"),r[0].elementClass===a.OBJECT_CLASS_LINE)l=t.create(\"curve\",[[],[]],c),l.hasPoint=function(){return!1},l.updateDataArray=function(){var o,n,h,l=t.getBoundingBox(),d=c.inverse?-1:1,u=1.5,p=u*Math.max(l[2]-l[0],l[1]-l[3]),f={coords:{usrCoords:[1,(l[0]+l[2])/2,c.inverse?l[1]:l[3]]}},m=r[0].stdform.slice(1),b=m;m[1]>0&&(m=s.multiply(m,-1),b=m),h=u*Math.max(i.perpendicular(r[0],f,t)[0].distance(a.COORDS_BY_USER,f.coords),p),h*=d,f={coords:{usrCoords:[1,(l[0]+l[2])/2,(l[1]+l[3])/2]}},f=Math.abs(e.innerProduct(f.coords.usrCoords,r[0].stdform,3))>=e.eps?i.perpendicular(r[0],f,t)[0].usrCoords:f.coords.usrCoords,o=[1,f[1]+m[1]*p,f[2]-m[0]*p],n=[1,f[1]-b[1]*p,f[2]+b[0]*p],this.dataX=[o[1],o[1]+m[0]*h,n[1]+b[0]*h,n[1],o[1]],this.dataY=[o[2],o[2]+m[1]*h,n[2]+b[1]*h,n[2],o[2]]};else if(h=n.createFunction(r[0]),!n.exists(h))throw new Error(\"JSXGraph: Can't create area with the given parents.\\nPossible parent types: [line], [function]\");return l},t.registerElement(\"arrowparallel\",t.createArrowParallel),t.registerElement(\"bisector\",t.createBisector),t.registerElement(\"bisectorlines\",t.createAngularBisectorsOfTwoLines),t.registerElement(\"circumcircle\",t.createCircumcircle),t.registerElement(\"circumcirclemidpoint\",t.createCircumcenter),t.registerElement(\"circumcenter\",t.createCircumcenter),t.registerElement(\"incenter\",t.createIncenter),t.registerElement(\"incircle\",t.createIncircle),t.registerElement(\"integral\",t.createIntegral),t.registerElement(\"midpoint\",t.createMidpoint),t.registerElement(\"mirrorpoint\",t.createMirrorPoint),t.registerElement(\"normal\",t.createNormal),t.registerElement(\"orthogonalprojection\",t.createOrthogonalProjection),t.registerElement(\"parallel\",t.createParallel),t.registerElement(\"parallelpoint\",t.createParallelPoint),t.registerElement(\"perpendicular\",t.createPerpendicular),t.registerElement(\"perpendicularpoint\",t.createPerpendicularPoint),t.registerElement(\"perpendicularsegment\",t.createPerpendicularSegment),t.registerElement(\"reflection\",t.createReflection),t.registerElement(\"grid\",t.createGrid),t.registerElement(\"inequality\",t.createInequality),{createArrowParallel:t.createArrowParallel,createBisector:t.createBisector,createAngularBisectorOfTwoLines:t.createAngularBisectorsOfTwoLines,createCircumcircle:t.createCircumcircle,createCircumcenter:t.createCircumcenter,createIncenter:t.createIncenter,createIncircle:t.createIncircle,createIntegral:t.createIntegral,createMidpoint:t.createMidpoint,createMirrorPoint:t.createMirrorPoint,createNormal:t.createNormal,createOrthogonalProjection:t.createOrthogonalProjection,createParallel:t.createParallel,createParallelPoint:t.createParallelPoint,createPerpendicular:t.createPerpendicular,createPerpendicularPoint:t.createPerpendicularPoint,createPerpendicularSegmen:t.createPerpendicularSegment,createReflection:t.createReflection,createGrid:t.createGrid,createInequality:t.createInequality}}),define(\"base/board\",[\"jxg\",\"base/constants\",\"base/coords\",\"options\",\"math/numerics\",\"math/math\",\"math/geometry\",\"math/complex\",\"parser/jessiecode\",\"parser/geonext\",\"utils/color\",\"utils/type\",\"utils/event\",\"utils/env\",\"base/transformation\",\"base/point\",\"base/line\",\"base/text\",\"element/composition\",\"base/composition\"],function(t,e,i,r,s,o,n,a,h,l,c,d,u,p,f,m,b,g,v,C){return t.Board=function(t,i,s,o,n,a,l,c,f,m,b){if(this.BOARD_MODE_NONE=0,this.BOARD_MODE_DRAG=1,this.BOARD_MODE_MOVE_ORIGIN=2,this.BOARD_QUALITY_LOW=1,this.BOARD_QUALITY_HIGH=2,this.BOARD_MODE_ZOOM=17,this.document=b.document||document,this.container=t,this.containerObj=p.isBrowser?this.document.getElementById(this.container):null,p.isBrowser&&null===this.containerObj)throw new Error(\"\\nJSXGraph: HTML container element '\"+t+\"' not found.\");\nthis.renderer=i,this.grids=[],this.options=d.deepCopy(r),this.attr=b,this.dimension=2,this.jc=new h,this.jc.use(this),this.origin={},this.origin.usrCoords=[1,0,0],this.origin.scrCoords=[1,o[0],o[1]],this.zoomX=n,this.zoomY=a,this.unitX=l*this.zoomX,this.unitY=c*this.zoomY,this.canvasWidth=f,this.canvasHeight=m,this.id=d.exists(s)&&\"\"!==s&&p.isBrowser&&!d.exists(this.document.getElementById(s))?s:this.generateId(),u.eventify(this),this.hooks=[],this.dependentBoards=[],this.inUpdate=!1,this.objects={},this.objectsList=[],this.groups={},this.animationObjects={},this.highlightedObjects={},this.numObjects=0,this.elementsByName={},this.mode=this.BOARD_MODE_NONE,this.updateQuality=this.BOARD_QUALITY_HIGH,this.isSuspendedRedraw=!1,this.calculateSnapSizes(),this.drag_dx=0,this.drag_dy=0,this.drag_position=[0,0],this.mouse={},this.touches=[],this.xmlString=\"\",this.cPos=[],this.touchMoveLast=0,this.positionAccessLast=0,this.downObjects=[],this.attr.showcopyright&&this.renderer.displayCopyright(e.licenseText,parseInt(this.options.text.fontSize,10)),this.needsFullUpdate=!1,this.reducedUpdate=!1,this.currentCBDef=\"none\",this.geonextCompatibilityMode=!1,this.options.text.useASCIIMathML&&translateASCIIMath?init():this.options.text.useASCIIMathML=!1,this.hasMouseHandlers=!1,this.hasTouchHandlers=!1,this.hasPointerHandlers=!1,this.hasGestureHandlers=!1,this.hasMouseUp=!1,this.hasTouchEnd=!1,this.hasPointerUp=!1,this.attr.registerevents&&this.addEventHandlers(),this.methodMap={update:\"update\",fullUpdate:\"fullUpdate\",on:\"on\",off:\"off\",trigger:\"trigger\",setView:\"setBoundingBox\",setBoundingBox:\"setBoundingBox\",migratePoint:\"migratePoint\",colorblind:\"emulateColorblindness\",suspendUpdate:\"suspendUpdate\",unsuspendUpdate:\"unsuspendUpdate\",clearTraces:\"clearTraces\",left:\"clickLeftArrow\",right:\"clickRightArrow\",up:\"clickUpArrow\",down:\"clickDownArrow\",zoomIn:\"zoomIn\",zoomOut:\"zoomOut\",zoom100:\"zoom100\",zoomElements:\"zoomElements\",remove:\"removeObject\",removeObject:\"removeObject\"}},t.extend(t.Board.prototype,{generateName:function(t){var i,r,s=2,o=\"\",n=\"\",a=[],h=\"\";if(t.type===e.OBJECT_TYPE_TICKS)return\"\";for(i=t.elementClass===e.OBJECT_CLASS_POINT?[\"\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"]:t.type===e.OBJECT_TYPE_ANGLE?[\"\",\"α\",\"β\",\"γ\",\"δ\",\"ε\",\"ζ\",\"η\",\"θ\",\"ι\",\"κ\",\"λ\",\"μ\",\"ν\",\"ξ\",\"ο\",\"π\",\"ρ\",\"σ\",\"τ\",\"υ\",\"φ\",\"χ\",\"ψ\",\"ω\"]:[\"\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"],t.elementClass!==e.OBJECT_CLASS_POINT&&t.elementClass!==e.OBJECT_CLASS_LINE&&t.type!==e.OBJECT_TYPE_ANGLE&&(o=t.type===e.OBJECT_TYPE_POLYGON?\"P_{\":t.elementClass===e.OBJECT_CLASS_CIRCLE?\"k_{\":t.type===e.OBJECT_TYPE_TEXT?\"t_{\":\"s_{\",n=\"}\"),r=0;s>r;r++)a[r]=0;for(;a[s-1]<i.length;){for(a[0]=1;a[0]<i.length;a[0]++){for(h=o,r=s;r>0;r--)h+=i[a[r-1]];if(!d.exists(this.elementsByName[h+n]))return h+n}for(a[0]=i.length,r=1;s>r;r++)a[r-1]===i.length&&(a[r-1]=1,a[r]+=1)}return\"\"},generateId:function(){for(var e=1;d.exists(t.boards[\"jxgBoard\"+e]);)e=Math.round(65535*Math.random());return\"jxgBoard\"+e},setId:function(t,e){var i=this.numObjects,r=t.id;return this.numObjects+=1,\"\"!==r&&d.exists(r)||(r=this.id+e+i),t.id=r,this.objects[r]=t,t._pos=this.objectsList.length,this.objectsList[this.objectsList.length]=t,r},finalizeAdding:function(t){t.visProp.visible||this.renderer.hide(t)},finalizeLabel:function(t){!t.hasLabel||t.label.visProp.islabel||t.label.visProp.visible||this.renderer.hide(t.label)},getCoordsTopLeftCorner:function(){var t,e,i,r,s,o=this.document.documentElement||this.document.body.parentNode,n=this.document.body,a=this.containerObj;return this.cPos.length>0&&(this.mode===this.BOARD_MODE_DRAG||this.mode===this.BOARD_MODE_MOVE_ORIGIN||(new Date).getTime()-this.positionAccessLast<500)?this.cPos:(this.positionAccessLast=(new Date).getTime(),a.getBoundingClientRect?(r=\"number\"==typeof window.pageXOffset?window.pageXOffset:\"number\"===o.ScrollLeft?o.ScrollLeft:this.document.body.scrollLeft,s=\"number\"==typeof window.pageYOffset?window.pageYOffset:\"number\"===o.ScrollTop?o.ScrollTop:this.document.body.scrollTop,i=a.getBoundingClientRect(),t=[i.left+r,i.top+s],t[0]+=p.getProp(a,\"border-left-width\"),t[1]+=p.getProp(a,\"border-top-width\"),\"vml\"!==this.renderer.type&&(t[0]+=p.getProp(a,\"padding-left\"),t[1]+=p.getProp(a,\"padding-top\")),this.cpos=t,this.cpos):(t=p.getOffset(a),e=this.document.documentElement.ownerDocument,!this.containerObj.currentStyle&&e.defaultView&&(t[0]+=p.getProp(o,\"margin-left\"),t[1]+=p.getProp(o,\"margin-top\"),t[0]+=p.getProp(o,\"border-left-width\"),t[1]+=p.getProp(o,\"border-top-width\"),t[0]+=p.getProp(o,\"padding-left\"),t[1]+=p.getProp(o,\"padding-top\")),n&&(t[0]+=p.getProp(n,\"left\"),t[1]+=p.getProp(n,\"top\")),\"object\"==typeof google&&google.translate&&(t[0]+=10,t[1]+=25),t[0]+=p.getProp(a,\"border-left-width\"),t[1]+=p.getProp(a,\"border-top-width\"),\"vml\"!==this.renderer.type&&(t[0]+=p.getProp(a,\"padding-left\"),t[1]+=p.getProp(a,\"padding-top\")),t[0]+=this.attr.offsetx,t[1]+=this.attr.offsety,this.cPos=t,t))},getMousePosition:function(t,e){var i,r,s=this.getCoordsTopLeftCorner();return i=p.getPosition(t,e,this.document),d.exists(this.cssTransMat)||this.updateCSSTransforms(),r=[1,i[0]-s[0],i[1]-s[1]],r=o.matVecMult(this.cssTransMat,r),r[1]/=r[0],r[2]/=r[0],[r[1],r[2]]},initMoveOrigin:function(t,e){this.drag_dx=t-this.origin.scrCoords[1],this.drag_dy=e-this.origin.scrCoords[2],this.mode=this.BOARD_MODE_MOVE_ORIGIN,this.updateQuality=this.BOARD_QUALITY_LOW},initMoveObject:function(t,i,r,s){var o,n,a,h=[],l=this.objectsList.length,c={visProp:{layer:-1e4}};for(n=0;l>n;n++)o=this.objectsList[n],a=o.hasPoint&&o.hasPoint(t,i),o.visProp.visible&&a&&(o.triggerEventHandlers([s+\"down\",\"down\"],[r]),this.downObjects.push(o)),(!this.geonextCompatibilityMode||o.elementClass!==e.OBJECT_CLASS_POINT&&o.type!==e.OBJECT_TYPE_TEXT)&&this.geonextCompatibilityMode||!o.isDraggable||!o.visProp.visible||o.visProp.fixed||o.visProp.frozen||!a||(o.visProp.layer>c.visProp.layer||o.visProp.layer===c.visProp.layer&&o.lastDragTime.getTime()>=c.lastDragTime.getTime())&&(d.exists(c.label)&&o===c.label||(c=o,h[0]=c));return h.length>0&&(this.mode=this.BOARD_MODE_DRAG),this.attr.takefirst&&(h.length=1),h},moveObject:function(t,r,s,o,a){var h,l=new i(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(t,r),this),c=s.obj;c&&(this.drag_position=[l.scrCoords[1],l.scrCoords[2]],c.type!==e.OBJECT_TYPE_GLIDER?(isNaN(s.targets[0].Xprev+s.targets[0].Yprev)||c.setPositionDirectly(e.COORDS_BY_SCREEN,[l.scrCoords[1],l.scrCoords[2]],[s.targets[0].Xprev,s.targets[0].Yprev]),s.targets[0].Xprev=l.scrCoords[1],s.targets[0].Yprev=l.scrCoords[2],c.prepareUpdate().update(!1).updateRenderer()):c.type===e.OBJECT_TYPE_GLIDER&&(h=c.coords,c.setPositionDirectly(e.COORDS_BY_USER,l.usrCoords.slice(1)),0!==c.group.length?(c.slideObject.elementClass===e.OBJECT_CLASS_CIRCLE?c.coords.setCoordinates(e.COORDS_BY_USER,n.projectPointToCircle(c,c.slideObject,this).usrCoords,!1):c.slideObject.elementClass===e.OBJECT_CLASS_LINE&&c.coords.setCoordinates(e.COORDS_BY_USER,n.projectPointToLine(c,c.slideObject,this).usrCoords,!1),c.group[c.group.length-1].dX=c.coords.scrCoords[1]-h.scrCoords[1],c.group[c.group.length-1].dY=c.coords.scrCoords[2]-h.scrCoords[2],c.group[c.group.length-1].update(this)):c.prepareUpdate().update(!1).updateRenderer()),c.triggerEventHandlers([a+\"drag\",\"drag\"],[o]),this.updateInfobox(c),this.update(),c.highlight(!0),c.lastDragTime=new Date)},twoFingerMove:function(t,r,s,o){var n,a,h;d.exists(s)&&d.exists(s.obj)&&(h=s.obj,n=new i(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(t[0],t[1]),this),a=new i(e.COORDS_BY_SCREEN,this.getScrCoordsOfMouse(r[0],r[1]),this),h.elementClass===e.OBJECT_CLASS_LINE||h.type===e.OBJECT_TYPE_POLYGON?this.twoFingerTouchObject(n,a,s,h):h.elementClass===e.OBJECT_CLASS_CIRCLE&&this.twoFingerTouchCircle(n,a,s,h),h.triggerEventHandlers([\"touchdrag\",\"drag\"],[o]),s.targets[0].Xprev=n.scrCoords[1],s.targets[0].Yprev=n.scrCoords[2],s.targets[1].Xprev=a.scrCoords[1],s.targets[1].Yprev=a.scrCoords[2])},twoFingerTouchObject:function(t,r,s,a){var h,l,c,u,p,f,m,b,g,v,C,y,P,_,S,E;if(d.exists(s.targets[0])&&d.exists(s.targets[1])&&!isNaN(s.targets[0].Xprev+s.targets[0].Yprev+s.targets[1].Xprev+s.targets[1].Yprev)){if(h=t.usrCoords,l=r.usrCoords,c=new i(e.COORDS_BY_SCREEN,[s.targets[0].Xprev,s.targets[0].Yprev],this).usrCoords,u=new i(e.COORDS_BY_SCREEN,[s.targets[1].Xprev,s.targets[1].Yprev],this).usrCoords,f=[1,.5*(c[1]+u[1]),.5*(c[2]+u[2])],p=[1,.5*(h[1]+l[1]),.5*(h[2]+l[2])],b=o.crossProduct(c,u),m=o.crossProduct(h,l),v=o.crossProduct(b,m),Math.abs(v[0])<o.eps)return;v[1]/=v[0],v[2]/=v[0],C=n.rad(f.slice(1),v.slice(1),p.slice(1)),y=this.create(\"transform\",[C,v[1],v[2]],{type:\"rotate\"}),y.update(),f=o.matVecMult(y.matrix,f),f[1]/=f[0],f[2]/=f[0],P=this.create(\"transform\",[p[1]-f[1],p[2]-f[2]],{type:\"translate\"}),P.update(),y.melt(P),a.visProp.scalable&&(g=n.distance(h,l)/n.distance(c,u),_=this.create(\"transform\",[-p[1],-p[2]],{type:\"translate\"}),S=this.create(\"transform\",[g,g],{type:\"scale\"}),E=this.create(\"transform\",[p[1],p[2]],{type:\"translate\"}),y.melt(_).melt(S).melt(E)),a.elementClass===e.OBJECT_CLASS_LINE?y.applyOnce([a.point1,a.point2]):a.type===e.OBJECT_TYPE_POLYGON&&y.applyOnce(a.vertices.slice(0,-1)),this.update(),a.highlight(!0)}},twoFingerTouchCircle:function(t,r,s,o){var a,h,l,c,u,p,f,m,b,g,v;\"pointCircle\"!==o.method&&\"pointLine\"!==o.method&&d.exists(s.targets[0])&&d.exists(s.targets[1])&&!isNaN(s.targets[0].Xprev+s.targets[0].Yprev+s.targets[1].Xprev+s.targets[1].Yprev)&&(a=t.usrCoords,h=r.usrCoords,l=new i(e.COORDS_BY_SCREEN,[s.targets[0].Xprev,s.targets[0].Yprev],this).usrCoords,c=new i(e.COORDS_BY_SCREEN,[s.targets[1].Xprev,s.targets[1].Yprev],this).usrCoords,f=this.create(\"transform\",[a[1]-l[1],a[2]-l[2]],{type:\"translate\"}),p=n.rad(c.slice(1),a.slice(1),h.slice(1)),m=this.create(\"transform\",[-a[1],-a[2]],{type:\"translate\"}),b=this.create(\"transform\",[p],{type:\"rotate\"}),f.melt(m).melt(b),o.visProp.scalable&&(u=n.distance(a,h)/n.distance(l,c),g=this.create(\"transform\",[u,u],{type:\"scale\"}),f.melt(g)),v=this.create(\"transform\",[a[1],a[2]],{type:\"translate\"}),f.melt(v),f.applyOnce([o.center]),\"twoPoints\"===o.method?f.applyOnce([o.point2]):\"pointRadius\"===o.method&&d.isNumber(o.updateRadius.origin)&&o.setRadius(o.radius*u),this.update(o.center),o.highlight(!0))},highlightElements:function(t,e,i,r){var s,o,n,a={},h=this.objectsList.length;for(s=0;h>s;s++)o=this.objectsList[s],n=o.id,d.exists(o.hasPoint)&&o.visProp.visible&&o.hasPoint(t,e)&&(this.updateInfobox(o),d.exists(this.highlightedObjects[n])||(a[n]=o,o.highlight(),this.triggerEventHandlers([\"mousehit\",\"hit\"],[i,o,r])),o.mouseover?o.triggerEventHandlers([\"mousemove\",\"move\"],[i]):(o.triggerEventHandlers([\"mouseover\",\"over\"],[i]),o.mouseover=!0));for(s=0;h>s;s++)o=this.objectsList[s],n=o.id,o.mouseover&&(a[n]||(o.triggerEventHandlers([\"mouseout\",\"out\"],[i]),o.mouseover=!1))},saveStartPos:function(i,r){var s,o,n=[];if(i.type===e.OBJECT_TYPE_TICKS)n.push([1,0/0,0/0]);else if(i.elementClass===e.OBJECT_CLASS_LINE)n.push(i.point1.coords.usrCoords),n.push(i.point2.coords.usrCoords);else if(i.elementClass===e.OBJECT_CLASS_CIRCLE)n.push(i.center.coords.usrCoords),\"twoPoints\"===i.method&&n.push(i.point2.coords.usrCoords);else if(i.type===e.OBJECT_TYPE_POLYGON)for(o=i.vertices.length-1,s=0;o>s;s++)n.push(i.vertices[s].coords.usrCoords);else if(i.elementClass===e.OBJECT_CLASS_POINT||i.type===e.OBJECT_TYPE_GLIDER)n.push(i.coords.usrCoords);else try{n.push(i.coords.usrCoords)}catch(a){t.debug(\"JSXGraph+ saveStartPos: obj.coords.usrCoords not available: \"+a)}for(o=n.length,s=0;o>s;s++)r.Zstart.push(n[s][0]),r.Xstart.push(n[s][1]),r.Ystart.push(n[s][2])},mouseOriginMoveStart:function(t){var e,i=this.attr.pan.enabled&&(!this.attr.pan.needshift||t.shiftKey);return i&&(e=this.getMousePosition(t),this.initMoveOrigin(e[0],e[1])),i},mouseOriginMove:function(t){var e,i=this.mode===this.BOARD_MODE_MOVE_ORIGIN;return i&&(e=this.getMousePosition(t),this.moveOrigin(e[0],e[1],!0)),i},touchOriginMoveStart:function(e){var i,r=e[t.touchProperty],s=2===r.length&&n.distance([r[0].screenX,r[0].screenY],[r[1].screenX,r[1].screenY])<80,o=this.attr.pan.enabled&&(!this.attr.pan.needtwofingers||s);return o&&(i=this.getMousePosition(e,0),this.initMoveOrigin(i[0],i[1])),o},touchOriginMove:function(t){var e,i=this.mode===this.BOARD_MODE_MOVE_ORIGIN;return i&&(e=this.getMousePosition(t,0),this.moveOrigin(e[0],e[1],!0)),i},originMoveEnd:function(){this.updateQuality=this.BOARD_QUALITY_HIGH,this.mode=this.BOARD_MODE_NONE},addEventHandlers:function(){p.supportsPointerEvents()?this.addPointerEventHandlers():(this.addMouseEventHandlers(),this.addTouchEventHandlers())},addPointerEventHandlers:function(){!this.hasPointerHandlers&&p.isBrowser&&(window.navigator.pointerEnabled?(p.addEvent(this.containerObj,\"pointerdown\",this.pointerDownListener,this),p.addEvent(this.containerObj,\"pointermove\",this.pointerMoveListener,this)):(p.addEvent(this.containerObj,\"MSPointerDown\",this.pointerDownListener,this),p.addEvent(this.containerObj,\"MSPointerMove\",this.pointerMoveListener,this)),this.hasPointerHandlers=!0)},addMouseEventHandlers:function(){!this.hasMouseHandlers&&p.isBrowser&&(p.addEvent(this.containerObj,\"mousedown\",this.mouseDownListener,this),p.addEvent(this.containerObj,\"mousemove\",this.mouseMoveListener,this),p.addEvent(this.containerObj,\"mousewheel\",this.mouseWheelListener,this),p.addEvent(this.containerObj,\"DOMMouseScroll\",this.mouseWheelListener,this),this.hasMouseHandlers=!0,this.containerObj.oncontextmenu=function(t){return d.exists(t)&&t.preventDefault(),!1})},addTouchEventHandlers:function(t){!this.hasTouchHandlers&&p.isBrowser&&(p.addEvent(this.containerObj,\"touchstart\",this.touchStartListener,this),p.addEvent(this.containerObj,\"touchmove\",this.touchMoveListener,this),(!d.exists(t)||t)&&(p.addEvent(this.containerObj,\"gesturestart\",this.gestureStartListener,this),p.addEvent(this.containerObj,\"gesturechange\",this.gestureChangeListener,this),this.hasGestureHandlers=!0),this.hasTouchHandlers=!0)},removePointerEventHandlers:function(){this.hasPointerHandlers&&p.isBrowser&&(window.navigator.pointerEnabled?(p.removeEvent(this.containerObj,\"pointerdown\",this.pointerDownListener,this),p.removeEvent(this.containerObj,\"pointermove\",this.pointerMoveListener,this)):(p.removeEvent(this.containerObj,\"MSPointerDown\",this.pointerDownListener,this),p.removeEvent(this.containerObj,\"MSPointerMove\",this.pointerMoveListener,this)),this.hasPointerUp&&(window.navigator.pointerEnabled?p.removeEvent(this.document,\"pointerup\",this.pointerUpListener,this):p.removeEvent(this.document,\"MSPointerUp\",this.pointerUpListener,this),this.hasPointerUp=!1),this.hasPointerHandlers=!1)},removeMouseEventHandlers:function(){this.hasMouseHandlers&&p.isBrowser&&(p.removeEvent(this.containerObj,\"mousedown\",this.mouseDownListener,this),p.removeEvent(this.containerObj,\"mousemove\",this.mouseMoveListener,this),this.hasMouseUp&&(p.removeEvent(this.document,\"mouseup\",this.mouseUpListener,this),this.hasMouseUp=!1),p.removeEvent(this.containerObj,\"mousewheel\",this.mouseWheelListener,this),p.removeEvent(this.containerObj,\"DOMMouseScroll\",this.mouseWheelListener,this),this.hasMouseHandlers=!1)},removeTouchEventHandlers:function(){this.hasTouchHandlers&&p.isBrowser&&(p.removeEvent(this.containerObj,\"touchstart\",this.touchStartListener,this),p.removeEvent(this.containerObj,\"touchmove\",this.touchMoveListener,this),this.hasTouchEnd&&(p.removeEvent(this.document,\"touchend\",this.touchEndListener,this),this.hasTouchEnd=!1),this.hasGestureHandlers&&(p.removeEvent(this.containerObj,\"gesturestart\",this.gestureStartListener,this),p.removeEvent(this.containerObj,\"gesturechange\",this.gestureChangeListener,this),this.hasGestureHandlers=!1),this.hasTouchHandlers=!1)},removeEventHandlers:function(){this.removeMouseEventHandlers(),this.removeTouchEventHandlers(),this.removePointerEventHandlers()},clickLeftArrow:function(){return this.moveOrigin(this.origin.scrCoords[1]+.1*this.canvasWidth,this.origin.scrCoords[2]),!1},clickRightArrow:function(){return this.moveOrigin(this.origin.scrCoords[1]-.1*this.canvasWidth,this.origin.scrCoords[2]),!1},clickUpArrow:function(){return this.moveOrigin(this.origin.scrCoords[1],this.origin.scrCoords[2]-.1*this.canvasHeight),!1},clickDownArrow:function(){return this.moveOrigin(this.origin.scrCoords[1],this.origin.scrCoords[2]+.1*this.canvasHeight),!1},gestureChangeListener:function(t){var r,s=this.attr.zoom.factorx,o=this.attr.zoom.factory;return this.attr.zoom.wheel?(t.preventDefault(),this.mode===this.BOARD_MODE_ZOOM&&(r=new i(e.COORDS_BY_SCREEN,this.getMousePosition(t),this),this.attr.zoom.factorx=t.scale/this.prevScale,this.attr.zoom.factory=t.scale/this.prevScale,this.zoomIn(r.usrCoords[1],r.usrCoords[2]),this.prevScale=t.scale,this.attr.zoom.factorx=s,this.attr.zoom.factory=o),!1):!0},gestureStartListener:function(t){return this.attr.zoom.wheel?(t.preventDefault(),this.prevScale=1,this.mode===this.BOARD_MODE_NONE&&(this.mode=this.BOARD_MODE_ZOOM),!1):!0},pointerDownListener:function(e,i){var r,s,o,n,a,h,l,c,d=this.options.precision.touch;if(this.hasPointerUp||(window.navigator.pointerEnabled?p.addEvent(this.document,\"pointerup\",this.pointerUpListener,this):p.addEvent(this.document,\"MSPointerUp\",this.pointerUpListener,this),this.hasPointerUp=!0),this.hasMouseHandlers&&this.removeMouseEventHandlers(),this.hasTouchHandlers&&this.removeTouchEventHandlers(),this.document.selection&&\"function\"==typeof this.document.selection.empty?this.document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),t.isBrowser&&window.navigator.msMaxTouchPoints&&window.navigator.msMaxTouchPoints>1&&(this.options.precision.hasPoint=d),n=this.getMousePosition(e),i?(a=[i],this.mode=this.BOARD_MODE_DRAG):a=this.initMoveObject(n[0],n[1],e,\"mouse\"),a.length>0){for(l=a[a.length-1],h=!1,r=0;r<this.touches.length;r++)if(this.touches[r].obj===l){s=r,o=this.touches[r].targets.push({num:e.pointerId,X:n[0],Y:n[1],Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]})-1,h=!0;break}h||(o=0,s=this.touches.push({obj:l,targets:[{num:e.pointerId,X:n[0],Y:n[1],Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}]})-1),this.dehighlightAll(),l.highlight(!0),this.saveStartPos(l,this.touches[s].targets[o]),e&&e.preventDefault?e.preventDefault():window.event&&(window.event.returnValue=!1)}return this.touches.length>0&&(e.preventDefault(),e.stopPropagation()),this.mode===this.BOARD_MODE_NONE&&this.mouseOriginMoveStart(e)?(this.triggerEventHandlers([\"touchstart\",\"down\",\"pointerdown\",\"MSPointerDown\"],[e]),!1):(this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers([\"touchstart\",\"down\",\"pointerdown\",\"MSPointerDown\"],[e]),c)},pointerMoveListener:function(e){var i,r,s;if(e[t.touchProperty],this.mode!==this.BOARD_MODE_DRAG&&(this.dehighlightAll(),this.renderer.hide(this.infobox)),this.mode!==this.BOARD_MODE_NONE&&(e.preventDefault(),e.stopPropagation()),t.isBrowser&&window.navigator.msMaxTouchPoints&&window.navigator.msMaxTouchPoints>1&&(this.options.precision.hasPoint=this.options.precision.touch),this.updateQuality=this.BOARD_QUALITY_LOW,!this.mouseOriginMove(e))if(this.mode===this.BOARD_MODE_DRAG){for(i=0;i<this.touches.length;i++)for(r=0;r<this.touches[i].targets.length;r++)if(this.touches[i].targets[r].num===e.pointerId){1===this.touches[i].targets.length?(this.touches[i].targets[r].X=e.pageX,this.touches[i].targets[r].Y=e.pageY,s=this.getMousePosition(e),this.moveObject(s[0],s[1],this.touches[i],e,\"touch\")):2===this.touches[i].targets.length&&this.touches[i].targets[0].num>-1&&this.touches[i].targets[1].num>-1&&(this.touches[i].targets[r].X=e.pageX,this.touches[i].targets[r].Y=e.pageY,this.twoFingerMove(this.getMousePosition({pageX:this.touches[i].targets[0].X,pageY:this.touches[i].targets[0].Y}),this.getMousePosition({pageX:this.touches[i].targets[1].X,pageY:this.touches[i].targets[1].Y}),this.touches[i],e));break}}else s=this.getMousePosition(e),this.highlightElements(s[0],s[1],e,-1);return this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers([\"touchmove\",\"move\",\"pointermove\",\"MSPointerMove\"],[e,this.mode]),this.mode===this.BOARD_MODE_NONE},pointerUpListener:function(t){var e,i,r;if(this.options.precision.touch,this.triggerEventHandlers([\"touchend\",\"up\",\"pointerup\",\"MSPointerUp\"],[t]),this.renderer.hide(this.infobox),t)for(e=0;e<this.touches.length;e++)for(i=0;i<this.touches[e].targets.length;i++)if(this.touches[e].targets[i].num===t.pointerId){this.touches[e].targets.splice(i,1),0===this.touches[e].targets.length&&this.touches.splice(e,1);break}for(e=this.downObjects.length-1;e>-1;e--){for(r=!1,i=0;i<this.touches.length;i++)this.touches[i].obj.id===this.downObjects[e].id&&(r=!0);r||(this.downObjects[e].triggerEventHandlers([\"touchend\",\"up\",\"pointerup\",\"MSPointerUp\"],[t]),this.downObjects[e].snapToGrid(),this.downObjects[e].snapToPoints(),this.downObjects.splice(e,1))}return 0===this.touches.length&&(this.hasPointerUp&&(window.navigator.pointerEnabled?p.removeEvent(this.document,\"pointerup\",this.pointerUpListener,this):p.removeEvent(this.document,\"MSPointerUp\",this.pointerUpListener,this),this.hasPointerUp=!1),this.dehighlightAll(),this.updateQuality=this.BOARD_QUALITY_HIGH,this.originMoveEnd(),this.update()),!0},touchStartListener:function(i){var s,o,n,a,h,l,c,u,f,m,b=this.options.precision.touch,g=i[t.touchProperty];for(this.hasTouchEnd||(p.addEvent(this.document,\"touchend\",this.touchEndListener,this),this.hasTouchEnd=!0),this.hasMouseHandlers&&this.removeMouseEventHandlers(),this.document.selection&&\"function\"==typeof this.document.selection.empty?this.document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),this.options.precision.hasPoint=this.options.precision.touch,s=0;s<g.length;s++)g[s].jxg_isused=!1;for(s=0;s<this.touches.length;s++)for(a=0;a<this.touches[s].targets.length;a++){this.touches[s].targets[a].num=-1,b=this.options.precision.touch;do{for(h=0;h<g.length;h++)if(Math.abs(Math.pow(g[h].screenX-this.touches[s].targets[a].X,2)+Math.pow(g[h].screenY-this.touches[s].targets[a].Y,2))<b*b){this.touches[s].targets[a].num=h,this.touches[s].targets[a].X=g[h].screenX,this.touches[s].targets[a].Y=g[h].screenY,g[h].jxg_isused=!0;break}b*=2}while(-1===this.touches[s].targets[a].num&&b<this.options.precision.touchMax);-1===this.touches[s].targets[a].num&&(t.debug(\"i couldn't find a targettouches for target no \"+a+\" on \"+this.touches[s].obj.name+\" (\"+this.touches[s].obj.id+\"). Removed the target.\"),t.debug(\"eps = \"+b+\", touchMax = \"+r.precision.touchMax),this.touches[s].targets.splice(s,1))}for(s=0;s<g.length;s++)if(!g[s].jxg_isused){if(o=this.getMousePosition(i,s),n=this.initMoveObject(o[0],o[1],i,\"touch\"),0!==n.length)if(c=n[n.length-1],d.isPoint(c)||c.type===e.OBJECT_TYPE_TEXT||c.type===e.OBJECT_TYPE_TICKS||c.type===e.OBJECT_TYPE_IMAGE)f=[{num:s,X:g[s].screenX,Y:g[s].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}],this.saveStartPos(c,f[0]),this.touches.push({obj:c,targets:f}),c.highlight(!0);else if(c.elementClass===e.OBJECT_CLASS_LINE||c.elementClass===e.OBJECT_CLASS_CIRCLE||c.type===e.OBJECT_TYPE_POLYGON){for(u=!1,a=0;a<this.touches.length;a++)c.id===this.touches[a].obj.id&&(u=!0,1===this.touches[a].targets.length&&(m={num:s,X:g[s].screenX,Y:g[s].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]},this.saveStartPos(c,m),this.touches[a].targets.push(m)),g[s].jxg_isused=!0);u||(f=[{num:s,X:g[s].screenX,Y:g[s].screenY,Xprev:0/0,Yprev:0/0,Xstart:[],Ystart:[],Zstart:[]}],this.saveStartPos(c,f[0]),this.touches.push({obj:c,targets:f}),c.highlight(!0))}g[s].jxg_isused=!0}return this.touches.length>0&&(i.preventDefault(),i.stopPropagation()),this.mode===this.BOARD_MODE_NONE&&this.touchOriginMoveStart(i)?(this.triggerEventHandlers([\"touchstart\",\"down\"],[i]),!1):(p.isWebkitAndroid()&&(l=new Date,this.touchMoveLast=l.getTime()-200),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers([\"touchstart\",\"down\"],[i]),this.touches.length>0)},touchMoveListener:function(e){var i,r,s,o=e[t.touchProperty];if(this.mode!==this.BOARD_MODE_NONE&&(e.preventDefault(),e.stopPropagation()),p.isWebkitAndroid()){if(s=new Date,s=s.getTime(),s-this.touchMoveLast<80)return this.updateQuality=this.BOARD_QUALITY_HIGH,this.triggerEventHandlers([\"touchmove\",\"move\"],[e,this.mode]),!1;this.touchMoveLast=s}if(this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.touch,this.updateQuality=this.BOARD_QUALITY_LOW,!this.touchOriginMove(e)&&this.mode===this.BOARD_MODE_DRAG)for(i=0;i<this.touches.length;i++)1===this.touches[i].targets.length?o[this.touches[i].targets[0].num]&&(this.touches[i].targets[0].X=o[this.touches[i].targets[0].num].screenX,this.touches[i].targets[0].Y=o[this.touches[i].targets[0].num].screenY,r=this.getMousePosition(e,this.touches[i].targets[0].num),this.moveObject(r[0],r[1],this.touches[i],e,\"touch\")):2===this.touches[i].targets.length&&this.touches[i].targets[0].num>-1&&this.touches[i].targets[1].num>-1&&o[this.touches[i].targets[0].num]&&o[this.touches[i].targets[1].num]&&(this.touches[i].targets[0].X=o[this.touches[i].targets[0].num].screenX,this.touches[i].targets[0].Y=o[this.touches[i].targets[0].num].screenY,this.touches[i].targets[1].X=o[this.touches[i].targets[1].num].screenX,this.touches[i].targets[1].Y=o[this.touches[i].targets[1].num].screenY,this.twoFingerMove(this.getMousePosition(e,this.touches[i].targets[0].num),this.getMousePosition(e,this.touches[i].targets[1].num),this.touches[i],e));return this.mode!==this.BOARD_MODE_DRAG&&this.renderer.hide(this.infobox),this.options.precision.hasPoint=this.options.precision.mouse,this.triggerEventHandlers([\"touchmove\",\"move\"],[e,this.mode]),this.mode===this.BOARD_MODE_NONE},touchEndListener:function(i){var r,s,o,n,a,h=this.options.precision.touch,l=[],c=i&&i[t.touchProperty];if(this.triggerEventHandlers([\"touchend\",\"up\"],[i]),this.renderer.hide(this.infobox),c&&c.length>0){for(r=0;r<this.touches.length;r++)l[r]=this.touches[r];for(this.touches.length=0,r=0;r<c.length;r++)c[r].jxg_isused=!1;for(r=0;r<l.length;r++){for(n=!1,a=0,s=0;s<l[r].targets.length;s++)for(l[r].targets[s].found=!1,o=0;o<c.length;o++)if(Math.abs(Math.pow(c[o].screenX-l[r].targets[s].X,2)+Math.pow(c[o].screenY-l[r].targets[s].Y,2))<h*h){l[r].targets[s].found=!0,l[r].targets[s].num=o,l[r].targets[s].X=c[o].screenX,l[r].targets[s].Y=c[o].screenY,a+=1;break}if(d.isPoint(l[r].obj)?n=l[r].targets[0]&&l[r].targets[0].found:l[r].obj.elementClass===e.OBJECT_CLASS_LINE?n=l[r].targets[0]&&l[r].targets[0].found||l[r].targets[1]&&l[r].targets[1].found:l[r].obj.elementClass===e.OBJECT_CLASS_CIRCLE&&(n=1===a||3===a),n)for(this.touches.push({obj:l[r].obj,targets:[]}),s=0;s<l[r].targets.length;s++)l[r].targets[s].found&&this.touches[this.touches.length-1].targets.push({num:l[r].targets[s].num,X:l[r].targets[s].screenX,Y:l[r].targets[s].screenY,Xprev:0/0,Yprev:0/0,Xstart:l[r].targets[s].Xstart,Ystart:l[r].targets[s].Ystart,Zstart:l[r].targets[s].Zstart});else l[r].obj.noHighlight()}}else this.touches.length=0;for(r=this.downObjects.length-1;r>-1;r--){for(n=!1,s=0;s<this.touches.length;s++)this.touches[s].obj.id===this.downObjects[r].id&&(n=!0);n||(this.downObjects[r].triggerEventHandlers([\"touchup\",\"up\"],[i]),this.downObjects[r].snapToGrid(),this.downObjects[r].snapToPoints(),this.downObjects.splice(r,1))}return c&&0!==c.length||(this.hasTouchEnd&&(p.removeEvent(this.document,\"touchend\",this.touchEndListener,this),this.hasTouchEnd=!1),this.dehighlightAll(),this.updateQuality=this.BOARD_QUALITY_HIGH,this.originMoveEnd(),this.update()),!0},mouseDownListener:function(t){var e,i,r;return this.document.selection&&\"function\"==typeof this.document.selection.empty?this.document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges(),this.hasMouseUp?void 0:(p.addEvent(this.document,\"mouseup\",this.mouseUpListener,this),this.hasMouseUp=!0,e=this.getMousePosition(t),i=this.initMoveObject(e[0],e[1],t,\"mouse\"),0===i.length?(this.mode=this.BOARD_MODE_NONE,r=!0):(this.mouse={obj:null,targets:[{X:e[0],Y:e[1],Xprev:0/0,Yprev:0/0}]},this.mouse.obj=i[i.length-1],this.dehighlightAll(),this.mouse.obj.highlight(!0),this.mouse.targets[0].Xstart=[],this.mouse.targets[0].Ystart=[],this.mouse.targets[0].Zstart=[],this.saveStartPos(this.mouse.obj,this.mouse.targets[0]),t&&t.preventDefault?t.preventDefault():window.event&&(window.event.returnValue=!1)),this.mode===this.BOARD_MODE_NONE&&(r=this.mouseOriginMoveStart(t)),this.triggerEventHandlers([\"mousedown\",\"down\"],[t]),r)},mouseUpListener:function(t){var e;for(this.triggerEventHandlers([\"mouseup\",\"up\"],[t]),this.updateQuality=this.BOARD_QUALITY_HIGH,this.mouse&&this.mouse.obj&&(this.mouse.obj.snapToGrid(this.mouse.targets[0]),this.mouse.obj.snapToPoints()),this.originMoveEnd(),this.dehighlightAll(),this.update(),e=0;e<this.downObjects.length;e++)this.downObjects[e].triggerEventHandlers([\"mouseup\",\"up\"],[t]);this.downObjects.length=0,this.hasMouseUp&&(p.removeEvent(this.document,\"mouseup\",this.mouseUpListener,this),this.hasMouseUp=!1),this.mouse=null},mouseMoveListener:function(t){var e;e=this.getMousePosition(t),this.updateQuality=this.BOARD_QUALITY_LOW,this.mode!==this.BOARD_MODE_DRAG&&(this.dehighlightAll(),this.renderer.hide(this.infobox)),this.mouseOriginMove(t)||(this.mode===this.BOARD_MODE_DRAG?this.moveObject(e[0],e[1],this.mouse,t,\"mouse\"):this.highlightElements(e[0],e[1],t,-1)),this.updateQuality=this.BOARD_QUALITY_HIGH,this.triggerEventHandlers([\"mousemove\",\"move\"],[t,this.mode])},mouseWheelListener:function(t){if(!this.attr.zoom.wheel||this.attr.zoom.needshift&&!t.shiftKey)return!0;t=t||window.event;var r=t.detail?-t.detail:t.wheelDelta/40,s=new i(e.COORDS_BY_SCREEN,this.getMousePosition(t),this);return r>0?this.zoomIn(s.usrCoords[1],s.usrCoords[2]):this.zoomOut(s.usrCoords[1],s.usrCoords[2]),t.preventDefault(),!1},updateInfobox:function(t){var i,r,s,o;return t.visProp.showinfobox?(t.elementClass===e.OBJECT_CLASS_POINT&&(s=t.coords.usrCoords[1],o=t.coords.usrCoords[2],this.infobox.setCoords(s+this.infobox.distanceX/this.unitX,o+this.infobox.distanceY/this.unitY),\"string\"!=typeof t.infoboxText?(\"auto\"===t.visProp.infoboxdigits?(i=d.autoDigits(s),r=d.autoDigits(o)):d.isNumber(t.visProp.infoboxdigits)?(i=s.toFixed(t.visProp.infoboxdigits),r=o.toFixed(t.visProp.infoboxdigits)):(i=s,r=o),this.highlightInfobox(i,r,t)):this.highlightCustomInfobox(t.infoboxText,t),this.renderer.show(this.infobox)),this):this},highlightCustomInfobox:function(t){return this.infobox.setText(t),this},highlightInfobox:function(t,e,i){return this.highlightCustomInfobox(\"(\"+t+\", \"+e+\")\",i),this},dehighlightAll:function(){var t,e,i=!1;for(t in this.highlightedObjects)this.highlightedObjects.hasOwnProperty(t)&&(e=this.highlightedObjects[t],(this.hasMouseHandlers||this.hasPointerHandlers)&&e.noHighlight(),i=!0);return this.highlightedObjects={},\"canvas\"===this.renderer.type&&i&&(this.prepareUpdate(),this.renderer.suspendRedraw(this),this.updateRenderer(),this.renderer.unsuspendRedraw()),this},getScrCoordsOfMouse:function(t,e){return[t,e]},getUsrCoordsOfMouse:function(t){var r=this.getCoordsTopLeftCorner(),s=p.getPosition(t,null,this.document),o=s[0]-r[0],n=s[1]-r[1],a=new i(e.COORDS_BY_SCREEN,[o,n],this);return a.usrCoords.slice(1)},getAllUnderMouse:function(t){var e=this.getAllObjectsUnderMouse(t);return e.push(this.getUsrCoordsOfMouse(t)),e},getAllObjectsUnderMouse:function(t){var e,i,r=this.getCoordsTopLeftCorner(),s=p.getPosition(t,null,this.document),o=s[0]-r[0],n=s[1]-r[1],a=[],h=this.objectsList.length;for(e=0;h>e;e++)i=this.objectsList[e],i.visProp.visible&&i.hasPoint&&i.hasPoint(o,n)&&(a[a.length]=i);\nreturn a},updateCoords:function(){var t,e,i=this.objectsList.length;for(e=0;i>e;e++)t=this.objectsList[e],d.exists(t.coords)&&(t.visProp.frozen?t.coords.screen2usr():t.coords.usr2screen());return this},moveOrigin:function(t,e,i){return d.exists(t)&&d.exists(e)&&(this.origin.scrCoords[1]=t,this.origin.scrCoords[2]=e,i&&(this.origin.scrCoords[1]-=this.drag_dx,this.origin.scrCoords[2]-=this.drag_dy)),this.updateCoords().clearTraces().fullUpdate(),this.triggerEventHandlers([\"boundingbox\"]),this},addConditions:function(e){var i,r,s,o,n,a,h,l=[],u=\"var el, x, y, c, rgbo;\\n\",p=e.indexOf(\"<data>\"),f=e.indexOf(\"</data>\"),m=function(e,i,r,s){return function(){var o,n;o=e.select(i.id),n=o.coords.usrCoords[s],2===s?o.setPositionDirectly(t.COORDS_BY_USER,[r(),n]):o.setPositionDirectly(t.COORDS_BY_USER,[n,r()]),o.prepareUpdate().update()}},b=function(t,e,i){return function(){var r,s;r=t.select(e.id),s=i(),r.setAttribute({visible:s})}},g=function(t,e,i,r){return function(){var s,o;s=t.select(e.id),o=i(),\"strokewidth\"===r?s.visProp.strokewidth=o:(o=c.rgba2rgbo(o),s.visProp[r+\"color\"]=o[0],s.visProp[r+\"opacity\"]=o[1])}},v=function(t,e,i){return function(){var r=t.select(e.id);r.position=i()}},C=function(t,e,i){return function(){var r=t.select(e.id);r.setStyle(i())}};if(!(0>p)){for(;p>=0;){if(i=e.slice(p+6,f),r=i.indexOf(\"=\"),s=i.slice(0,r),o=i.slice(r+1),r=s.indexOf(\".\"),n=s.slice(0,r),a=this.elementsByName[d.unescapeHTML(n)],h=s.slice(r+1).replace(/\\s+/g,\"\").toLowerCase(),o=d.createFunction(o,this,\"\",!0),d.exists(this.elementsByName[n]))switch(u+='el = this.objects[\"'+a.id+'\"];\\n',h){case\"x\":l.push(m(this,a,o,2));break;case\"y\":l.push(m(this,a,o,1));break;case\"visible\":l.push(b(this,a,o));break;case\"position\":l.push(v(this,a,o));break;case\"stroke\":l.push(g(this,a,o,\"stroke\"));break;case\"style\":l.push(C(this,a,o));break;case\"strokewidth\":l.push(g(this,a,o,\"strokewidth\"));break;case\"fill\":l.push(g(this,a,o,\"fill\"));break;case\"label\":break;default:t.debug(\"property '\"+h+\"' in conditions not yet implemented:\"+o)}else t.debug(\"debug conditions: |\"+n+\"| undefined\");e=e.slice(f+7),p=e.indexOf(\"<data>\"),f=e.indexOf(\"</data>\")}this.updateConditions=function(){var t;for(t=0;t<l.length;t++)l[t]();return this.prepareUpdate().updateElements(),!0},this.updateConditions()}},updateConditions:function(){return!1},calculateSnapSizes:function(){var t=new i(e.COORDS_BY_USER,[0,0],this),r=new i(e.COORDS_BY_USER,[this.options.grid.gridX,this.options.grid.gridY],this),s=t.scrCoords[1]-r.scrCoords[1],o=t.scrCoords[2]-r.scrCoords[2];for(this.options.grid.snapSizeX=this.options.grid.gridX;Math.abs(s)>25;)this.options.grid.snapSizeX*=2,s/=2;for(this.options.grid.snapSizeY=this.options.grid.gridY;Math.abs(o)>25;)this.options.grid.snapSizeY*=2,o/=2;return this},applyZoom:function(){return this.updateCoords().calculateSnapSizes().clearTraces().fullUpdate(),this},zoomIn:function(t,e){var i=this.getBoundingBox(),r=this.attr.zoom.factorx,s=this.attr.zoom.factory,o=(i[2]-i[0])*(1-1/r),n=(i[1]-i[3])*(1-1/s),a=.5,h=.5;return\"number\"==typeof t&&\"number\"==typeof e&&(a=(t-i[0])/(i[2]-i[0]),h=(i[1]-e)/(i[1]-i[3])),this.setBoundingBox([i[0]+o*a,i[1]-n*h,i[2]-o*(1-a),i[3]+n*(1-h)],!1),this.zoomX*=r,this.zoomY*=s,this.applyZoom(),!1},zoomOut:function(t,e){var i=this.getBoundingBox(),r=this.attr.zoom.factorx,s=this.attr.zoom.factory,o=(i[2]-i[0])*(1-r),n=(i[1]-i[3])*(1-s),a=.5,h=.5;return this.zoomX<this.attr.zoom.eps||this.zoomY<this.attr.zoom.eps?!1:(\"number\"==typeof t&&\"number\"==typeof e&&(a=(t-i[0])/(i[2]-i[0]),h=(i[1]-e)/(i[1]-i[3])),this.setBoundingBox([i[0]+o*a,i[1]-n*h,i[2]-o*(1-a),i[3]+n*(1-h)],!1),this.zoomX/=r,this.zoomY/=s,this.applyZoom(),!1)},zoom100:function(){var t=this.getBoundingBox(),e=.5*(t[2]-t[0])*(1-this.zoomX),i=.5*(t[1]-t[3])*(1-this.zoomY);return this.setBoundingBox([t[0]+e,t[1]-i,t[2]-e,t[3]+i],!1),this.zoomX=1,this.zoomY=1,this.applyZoom(),!1},zoomAllPoints:function(){var t,e,i,r,s,o=0,n=0,a=0,h=0,l=this.objectsList.length;for(t=0;l>t;t++)s=this.objectsList[t],d.isPoint(s)&&s.visProp.visible&&(s.coords.usrCoords[1]<o?o=s.coords.usrCoords[1]:s.coords.usrCoords[1]>n&&(n=s.coords.usrCoords[1]),s.coords.usrCoords[2]>h?h=s.coords.usrCoords[2]:s.coords.usrCoords[2]<a&&(a=s.coords.usrCoords[2]));return e=50,i=e/this.unitX,r=e/this.unitY,this.zoomX=1,this.zoomY=1,this.setBoundingBox([o-i,h+r,n+i,a-r],!0),this.applyZoom(),this},zoomElements:function(t){var e,i,r,s,o=[0,0,0,0],n=[1,-1,-1,1];if(!d.isArray(t)||0===t.length)return this;for(e=0;e<t.length;e++)if(r=this.select(t[e]),s=r.bounds(),d.isArray(s))if(d.isArray(o))for(i=0;4>i;i++)n[i]*s[i]<n[i]*o[i]&&(o[i]=s[i]);else o=s;if(d.isArray(o)){for(i=0;4>i;i++)o[i]-=n[i];this.zoomX=1,this.zoomY=1,this.setBoundingBox(o,!0)}return this},setZoom:function(t,e){var i=this.attr.zoom.factorx,r=this.attr.zoom.factory;return this.attr.zoom.factorx=t/this.zoomX,this.attr.zoom.factory=e/this.zoomY,this.zoomIn(),this.attr.zoom.factorx=i,this.attr.zoom.factory=r,this},removeObject:function(e){var i,r;if(d.isArray(e)){for(r=0;r<e.length;r++)this.removeObject(e[r]);return this}if(e=this.select(e),!d.exists(e)||d.isString(e))return this;try{for(i in e.childElements)e.childElements.hasOwnProperty(i)&&e.childElements[i].board.removeObject(e.childElements[i]);for(i in this.objects)this.objects.hasOwnProperty(i)&&d.exists(this.objects[i].childElements)&&(delete this.objects[i].childElements[e.id],delete this.objects[i].descendants[e.id]);if(e._pos>-1)for(this.objectsList.splice(e._pos,1),i=e._pos;i<this.objectsList.length;i++)this.objectsList[i]._pos--;else t.debug(\"Board.removeObject: object \"+e.id+\" not found in list.\");delete this.objects[e.id],delete this.elementsByName[e.name],e.visProp&&e.visProp.trace&&e.clearTrace(),d.exists(e.remove)&&e.remove()}catch(s){t.debug(e.id+\": Could not be removed: \"+s)}return this.update(),this},removeAncestors:function(t){var e;for(e in t.ancestors)t.ancestors.hasOwnProperty(e)&&this.removeAncestors(t.ancestors[e]);return this.removeObject(t),this},initGeonextBoard:function(){var t,e,i;return t=this.create(\"point\",[0,0],{id:this.id+\"g00e0\",name:\"Ursprung\",withLabel:!1,visible:!1,fixed:!0}),e=this.create(\"point\",[1,0],{id:this.id+\"gX0e0\",name:\"Punkt_1_0\",withLabel:!1,visible:!1,fixed:!0}),i=this.create(\"point\",[0,1],{id:this.id+\"gY0e0\",name:\"Punkt_0_1\",withLabel:!1,visible:!1,fixed:!0}),this.create(\"line\",[t,e],{id:this.id+\"gXLe0\",name:\"X-Achse\",withLabel:!1,visible:!1}),this.create(\"line\",[t,i],{id:this.id+\"gYLe0\",name:\"Y-Achse\",withLabel:!1,visible:!1}),this},initInfobox:function(){var t=d.copyAttributes({},this.options,\"infobox\");return t.id=this.id+\"_infobox\",this.infobox=this.create(\"text\",[0,0,\"0,0\"],t),this.infobox.distanceX=-20,this.infobox.distanceY=25,this.infobox.dump=!1,this.renderer.hide(this.infobox),this},resizeContainer:function(t,e,i){return this.canvasWidth=parseInt(t,10),this.canvasHeight=parseInt(e,10),i||(this.containerObj.style.width=this.canvasWidth+\"px\",this.containerObj.style.height=this.canvasHeight+\"px\"),this.renderer.resize(this.canvasWidth,this.canvasHeight),this},showDependencies:function(){var t,e,i,r,s;e=\"<p>\\n\";for(t in this.objects)if(this.objects.hasOwnProperty(t)){s=0;for(i in this.objects[t].childElements)this.objects[t].childElements.hasOwnProperty(i)&&(s+=1);s>=0&&(e+=\"<strong>\"+this.objects[t].id+\":<\"+\"/strong> \");for(i in this.objects[t].childElements)this.objects[t].childElements.hasOwnProperty(i)&&(e+=this.objects[t].childElements[i].id+\"(\"+this.objects[t].childElements[i].name+\")\"+\", \");e+=\"<p>\\n\"}return e+=\"</p>\\n\",r=window.open(),r.document.open(),r.document.write(e),r.document.close(),this},showXML:function(){var t=window.open(\"\");return t.document.open(),t.document.write(\"<pre>\"+d.escapeHTML(this.xmlString)+\"<\"+\"/pre>\"),t.document.close(),this},prepareUpdate:function(){var t,e,i=this.objectsList.length;for(t=0;i>t;t++)e=this.objectsList[t],e.needsUpdate=e.needsRegularUpdate||this.needsFullUpdate;return this},updateElements:function(t){var e,i;for(t=this.select(t),e=0;e<this.objectsList.length;e++)i=this.objectsList[e],i.update(!d.exists(t)||i.id!==t.id);for(e in this.groups)this.groups.hasOwnProperty(e)&&this.groups[e].update(t);return this},updateRenderer:function(){var t,e,i=this.objectsList.length;if(\"canvas\"===this.renderer.type)this.updateRendererCanvas();else for(t=0;i>t;t++)e=this.objectsList[t],e.updateRenderer();return this},updateRendererCanvas:function(){var t,e,i,r,s,o=this.objectsList.length,n=this.options.layer,a=this.options.layer.numlayers,h=Number.NEGATIVE_INFINITY;for(i=0;a>i;i++){r=Number.POSITIVE_INFINITY;for(s in n)n.hasOwnProperty(s)&&n[s]>h&&n[s]<r&&(r=n[s]);for(h=r,t=0;o>t;t++)e=this.objectsList[t],e.visProp.layer===r&&e.prepareUpdate().updateRenderer()}return this},addHook:function(t,e,i){return e=d.def(e,\"update\"),i=d.def(i,this),this.hooks.push([e,t]),this.on(e,t,i),this.hooks.length-1},addEvent:t.shortcut(t.Board.prototype,\"on\"),removeHook:function(t){return this.hooks[t]&&(this.off(this.hooks[t][0],this.hooks[t][1]),this.hooks[t]=null),this},removeEvent:t.shortcut(t.Board.prototype,\"off\"),updateHooks:function(){var t=Array.prototype.slice.call(arguments,0);return t[0]=d.def(t[0],\"update\"),this.triggerEventHandlers([t[0]],arguments),this},addChild:function(t){return d.exists(t)&&d.exists(t.containerObj)&&(this.dependentBoards.push(t),this.update()),this},removeChild:function(t){var e;for(e=this.dependentBoards.length-1;e>=0;e--)this.dependentBoards[e]===t&&this.dependentBoards.splice(e,1);return this},update:function(t){var e,i,r,s;if(this.inUpdate||this.isSuspendedUpdate)return this;for(this.inUpdate=!0,\"all\"===this.attr.minimizereflow&&this.containerObj&&\"vml\"!==this.renderer.type&&(s=this.renderer.removeToInsertLater(this.containerObj)),\"svg\"===this.attr.minimizereflow&&\"svg\"===this.renderer.type&&(s=this.renderer.removeToInsertLater(this.renderer.svgRoot)),this.prepareUpdate().updateElements(t).updateConditions(),this.renderer.suspendRedraw(this),this.updateRenderer(),this.renderer.unsuspendRedraw(),this.triggerEventHandlers([\"update\"],[]),s&&s(),i=this.dependentBoards.length,e=0;i>e;e++)r=this.dependentBoards[e],d.exists(r)&&r!==this&&(r.updateQuality=this.updateQuality,r.prepareUpdate().updateElements().updateConditions(),r.renderer.suspendRedraw(),r.updateRenderer(),r.renderer.unsuspendRedraw(),r.triggerEventHandlers([\"update\"],[]));return this.inUpdate=!1,this},fullUpdate:function(){return this.needsFullUpdate=!0,this.update(),this.needsFullUpdate=!1,this},addGrid:function(){return this.create(\"grid\",[]),this},removeGrids:function(){var t;for(t=0;t<this.grids.length;t++)this.removeObject(this.grids[t]);return this.grids.length=0,this.update(),this},create:function(e,i,r){var s,o;for(e=e.toLowerCase(),d.exists(i)||(i=[]),d.exists(r)||(r={}),o=0;o<i.length;o++)\"string\"!=typeof i[o]||\"text\"===e&&2===o||(i[o]=this.select(i[o]));if(\"function\"!=typeof t.elements[e])throw new Error(\"JSXGraph: create: Unknown element type given: \"+e);return s=t.elements[e](this,i,r),d.exists(s)?(s.prepareUpdate&&s.update&&s.updateRenderer&&s.prepareUpdate().update().updateRenderer(),s):(t.debug(\"JSXGraph: create: failure creating \"+e),s)},createElement:t.shortcut(t.Board.prototype,\"create\"),clearTraces:function(){var t;for(t=0;t<this.objectsList.length;t++)this.objectsList[t].clearTrace();return this.numTraces=0,this},suspendUpdate:function(){return this.inUpdate||(this.isSuspendedUpdate=!0),this},unsuspendUpdate:function(){return this.isSuspendedUpdate&&(this.isSuspendedUpdate=!1,this.update()),this},setBoundingBox:function(t,e){var i,r,s=p.getDimensions(this.container,this.document);return d.isArray(t)?(this.plainBB=t,this.canvasWidth=parseInt(s.width,10),this.canvasHeight=parseInt(s.height,10),r=this.canvasWidth,i=this.canvasHeight,e?(this.unitX=r/(t[2]-t[0]),this.unitY=i/(t[1]-t[3]),Math.abs(this.unitX)<Math.abs(this.unitY)?this.unitY=Math.abs(this.unitX)*this.unitY/Math.abs(this.unitY):this.unitX=Math.abs(this.unitY)*this.unitX/Math.abs(this.unitX)):(this.unitX=r/(t[2]-t[0]),this.unitY=i/(t[1]-t[3])),this.moveOrigin(-this.unitX*t[0],this.unitY*t[1]),this):this},getBoundingBox:function(){var t=new i(e.COORDS_BY_SCREEN,[0,0],this),r=new i(e.COORDS_BY_SCREEN,[this.canvasWidth,this.canvasHeight],this);return[t.usrCoords[1],t.usrCoords[2],r.usrCoords[1],r.usrCoords[2]]},addAnimation:function(t){var e=this;return this.animationObjects[t.id]=t,this.animationIntervalCode||(this.animationIntervalCode=window.setInterval(function(){e.animate()},t.board.attr.animationdelay)),this},stopAllAnimation:function(){var t;for(t in this.animationObjects)this.animationObjects.hasOwnProperty(t)&&d.exists(this.animationObjects[t])&&(this.animationObjects[t]=null,delete this.animationObjects[t]);return window.clearInterval(this.animationIntervalCode),delete this.animationIntervalCode,this},animate:function(){var t,i,r,s,o,n,a,h,l=0,c=null;for(i in this.animationObjects)if(this.animationObjects.hasOwnProperty(i)&&d.exists(this.animationObjects[i])){if(l+=1,r=this.animationObjects[i],r.animationPath&&(s=d.isFunction(r.animationPath)?r.animationPath((new Date).getTime()-r.animationStart):r.animationPath.pop(),!d.exists(s)||!d.isArray(s)&&isNaN(s)?delete r.animationPath:(r.setPositionDirectly(e.COORDS_BY_USER,s),r.prepareUpdate().update().updateRenderer(),c=r)),r.animationData){a=0;for(o in r.animationData)r.animationData.hasOwnProperty(o)&&(n=r.animationData[o].pop(),d.exists(n)?(a+=1,t={},t[o]=n,r.setAttribute(t)):delete r.animationData[n]);0===a&&delete r.animationData}d.exists(r.animationData)||d.exists(r.animationPath)||(this.animationObjects[i]=null,delete this.animationObjects[i],d.exists(r.animationCallback)&&(h=r.animationCallback,r.animationCallback=null,h()))}return 0===l?(window.clearInterval(this.animationIntervalCode),delete this.animationIntervalCode):this.update(c),this},migratePoint:function(e,i,r){var s,o,n,a,h,l,c=!1;e=this.select(e),i=this.select(i),t.exists(e.label)&&(l=e.label.id,c=!0,this.removeObject(e.label));for(o in e.childElements)if(e.childElements.hasOwnProperty(o)){s=e.childElements[o],a=!1;for(n in s)s.hasOwnProperty(n)&&s[n]===e&&(s[n]=i,a=!0);for(a&&delete e.childElements[o],h=0;h<s.parents.length;h++)s.parents[h]===e.id&&(s.parents[h]=i.id);i.addChild(s)}return r&&(c&&(delete i.childElements[l],delete i.descendants[l]),i.label&&this.removeObject(i.label),delete this.elementsByName[i.name],i.name=e.name,c&&i.createLabel()),this.removeObject(e),d.exists(i.name)&&\"\"!==i.name&&(this.elementsByName[i.name]=i),this.update(),this},emulateColorblindness:function(e){var i,r;if(d.exists(e)||(e=\"none\"),this.currentCBDef===e)return this;for(i in this.objects)this.objects.hasOwnProperty(i)&&(r=this.objects[i],\"none\"!==e?(\"none\"===this.currentCBDef&&(r.visPropOriginal={strokecolor:r.visProp.strokecolor,fillcolor:r.visProp.fillcolor,highlightstrokecolor:r.visProp.highlightstrokecolor,highlightfillcolor:r.visProp.highlightfillcolor}),r.setAttribute({strokecolor:c.rgb2cb(r.visPropOriginal.strokecolor,e),fillcolor:c.rgb2cb(r.visPropOriginal.fillcolor,e),highlightstrokecolor:c.rgb2cb(r.visPropOriginal.highlightstrokecolor,e),highlightfillcolor:c.rgb2cb(r.visPropOriginal.highlightfillcolor,e)})):d.exists(r.visPropOriginal)&&t.extend(r.visProp,r.visPropOriginal));return this.currentCBDef=e,this.update(),this},select:function(e){var i,r,s,o,n=e;if(null===n)return n;if(\"string\"==typeof n&&\"\"!==n)d.exists(this.objects[n])?n=this.objects[n]:d.exists(this.elementsByName[n])?n=this.elementsByName[n]:d.exists(this.groups[n])&&(n=this.groups[n]);else if(\"function\"==typeof n||\"object\"==typeof n&&!t.isArray(n)&&\"function\"!=typeof n.setAttribute){for(i=d.filterElements(this.objectsList,n),r={},o=i.length,s=0;o>s;s++)r[i[s].id]=i[s];n=new C(r)}else\"object\"==typeof n&&t.exists(n.id)&&!t.exists(this.objects[n.id])&&(n=null);return n},hasPoint:function(e,i){var r=e,s=i,o=this.getBoundingBox();return t.exists(e)&&t.isArray(e.usrCoords)&&(r=e.usrCoords[1],s=e.usrCoords[2]),\"number\"==typeof r&&\"number\"==typeof s&&o[0]<r&&r<o[2]&&o[1]>s&&s>o[3]?!0:!1},updateCSSTransforms:function(){var t=this.containerObj,e=t,i=t;for(this.cssTransMat=p.getCSSTransformMatrix(e),e=e.offsetParent;e;){for(this.cssTransMat=o.matMatMult(p.getCSSTransformMatrix(e),this.cssTransMat),i=i.parentNode;i!==e;)this.cssTransMat=o.matMatMult(p.getCSSTransformMatrix(e),this.cssTransMat),i=i.parentNode;e=e.offsetParent}return this.cssTransMat=o.inverse(this.cssTransMat),this},__evt__down:function(){},__evt__mousedown:function(){},__evt__touchstart:function(){},__evt__up:function(){},__evt__mouseup:function(){},__evt__touchend:function(){},__evt__move:function(){},__evt__mousemove:function(){},__evt__touchmove:function(){},__evt__hit:function(){},__evt__mousehit:function(){},__evt__update:function(){},__evt__boundingbox:function(){},__evt:function(){},createRoulette:function(t,e,i,r,o,n,h){var l=this,c=function(){var c,d=0,u=0,p=0,f=i,m=s.root(function(i){var r=t.X(f),s=t.Y(f),o=e.X(i),n=e.Y(i);return(r-o)*(r-o)+(s-n)*(s-n)},[0,2*Math.PI]),b=0,g=0,v=l.create(\"transform\",[function(){return d}],{type:\"rotate\"}),C=l.create(\"transform\",[function(){return d},function(){return t.X(f)},function(){return t.Y(f)}],{type:\"rotate\"}),y=l.create(\"transform\",[function(){return u},function(){return p}],{type:\"translate\"}),P=function(t,e,i){var r=s.D(t.X)(e),o=s.D(t.Y)(e),n=s.D(t.X)(i),a=s.D(t.Y)(i),h=s.D(t.X)(.5*(e+i)),l=s.D(t.Y)(.5*(e+i)),c=Math.sqrt(r*r+o*o),d=Math.sqrt(n*n+a*a),u=Math.sqrt(h*h+l*l);return(c+4*u+d)*(i-e)/6},_=function(t){return c-P(e,m,t)},S=Math.PI/18,E=9*S,O=null;return this.rolling=function(){var i,n,O,w,T;b=f+o*r,c=P(t,f,b),g=s.root(_,m),i=new a(t.X(b),t.Y(b)),n=new a(e.X(g),e.Y(g)),O=new a(s.D(t.X)(b),s.D(t.Y)(b)),w=new a(s.D(e.X)(g),s.D(e.Y)(g)),T=a.C.div(O,w),d=Math.atan2(T.imaginary,T.real),T.div(a.C.abs(T)),T.mult(n),u=i.real-T.real,p=i.imaginary-T.imaginary,-S>d&&d>-E?(d=-S,C.applyOnce(h)):d>S&&E>d?(d=S,C.applyOnce(h)):(v.applyOnce(h),y.applyOnce(h),f=b,m=g),l.update()},this.start=function(){return n>0&&(O=window.setInterval(this.rolling,n)),this},this.stop=function(){return window.clearInterval(O),this},this};return new c}}),t.Board}),define(\"renderer/svg\",[\"jxg\",\"options\",\"renderer/abstract\",\"base/constants\",\"utils/type\",\"utils/env\",\"utils/color\",\"math/numerics\"],function(t,e,i,r,s,o,n,a){return t.SVGRenderer=function(t,i){var r;for(this.type=\"svg\",this.svgRoot=null,this.svgNamespace=\"http://www.w3.org/2000/svg\",this.xlinkNamespace=\"http://www.w3.org/1999/xlink\",this.container=t,this.container.style.MozUserSelect=\"none\",this.container.style.overflow=\"hidden\",\"\"===this.container.style.position&&(this.container.style.position=\"relative\"),this.svgRoot=this.container.ownerDocument.createElementNS(this.svgNamespace,\"svg\"),this.svgRoot.style.overflow=\"hidden\",this.svgRoot.style.width=i.width+\"px\",this.svgRoot.style.height=i.height+\"px\",this.container.appendChild(this.svgRoot),this.defs=this.container.ownerDocument.createElementNS(this.svgNamespace,\"defs\"),this.svgRoot.appendChild(this.defs),this.filter=this.container.ownerDocument.createElementNS(this.svgNamespace,\"filter\"),this.filter.setAttributeNS(null,\"id\",this.container.id+\"_\"+\"f1\"),this.filter.setAttributeNS(null,\"width\",\"300%\"),this.filter.setAttributeNS(null,\"height\",\"300%\"),this.filter.setAttributeNS(null,\"filterUnits\",\"userSpaceOnUse\"),this.feOffset=this.container.ownerDocument.createElementNS(this.svgNamespace,\"feOffset\"),this.feOffset.setAttributeNS(null,\"result\",\"offOut\"),this.feOffset.setAttributeNS(null,\"in\",\"SourceAlpha\"),this.feOffset.setAttributeNS(null,\"dx\",\"5\"),this.feOffset.setAttributeNS(null,\"dy\",\"5\"),this.filter.appendChild(this.feOffset),this.feGaussianBlur=this.container.ownerDocument.createElementNS(this.svgNamespace,\"feGaussianBlur\"),this.feGaussianBlur.setAttributeNS(null,\"result\",\"blurOut\"),this.feGaussianBlur.setAttributeNS(null,\"in\",\"offOut\"),this.feGaussianBlur.setAttributeNS(null,\"stdDeviation\",\"3\"),this.filter.appendChild(this.feGaussianBlur),this.feBlend=this.container.ownerDocument.createElementNS(this.svgNamespace,\"feBlend\"),this.feBlend.setAttributeNS(null,\"in\",\"SourceGraphic\"),this.feBlend.setAttributeNS(null,\"in2\",\"blurOut\"),this.feBlend.setAttributeNS(null,\"mode\",\"normal\"),this.filter.appendChild(this.feBlend),this.defs.appendChild(this.filter),this.layer=[],r=0;r<e.layer.numlayers;r++)this.layer[r]=this.container.ownerDocument.createElementNS(this.svgNamespace,\"g\"),this.svgRoot.appendChild(this.layer[r]);this.dashArray=[\"2, 2\",\"5, 5\",\"10, 10\",\"20, 20\",\"20, 10, 10, 10\",\"20, 5, 10, 5\"]},t.SVGRenderer.prototype=new i,t.extend(t.SVGRenderer.prototype,{_createArrowHead:function(t,e){var i,r,o,n,a=t.id+\"Triangle\";return s.exists(e)&&(a+=e),i=this.createPrim(\"marker\",a),i.setAttributeNS(null,\"stroke\",s.evaluate(t.visProp.strokecolor)),i.setAttributeNS(null,\"stroke-opacity\",s.evaluate(t.visProp.strokeopacity)),i.setAttributeNS(null,\"fill\",s.evaluate(t.visProp.strokecolor)),i.setAttributeNS(null,\"fill-opacity\",s.evaluate(t.visProp.strokeopacity)),i.setAttributeNS(null,\"stroke-width\",0),i.setAttributeNS(null,\"orient\",\"auto\"),i.setAttributeNS(null,\"markerUnits\",\"strokeWidth\"),o=parseInt(t.visProp.strokewidth,10),i.setAttributeNS(null,\"viewBox\",-o+\" \"+-o+\" \"+10*o+\" \"+10*o),n=Math.max(3*o,10),i.setAttributeNS(null,\"markerHeight\",n),i.setAttributeNS(null,\"markerWidth\",n),r=this.container.ownerDocument.createElementNS(this.svgNamespace,\"path\"),\"End\"===e?(i.setAttributeNS(null,\"refY\",5),i.setAttributeNS(null,\"refX\",10),r.setAttributeNS(null,\"d\",\"M 10 0 L 0 5 L 10 10 z\")):(i.setAttributeNS(null,\"refY\",5),i.setAttributeNS(null,\"refX\",0),r.setAttributeNS(null,\"d\",\"M 0 0 L 10 5 L 0 10 z\")),i.appendChild(r),i},_setArrowAtts:function(t,e,i,r){var s,o;t&&(t.setAttributeNS(null,\"stroke\",e),t.setAttributeNS(null,\"stroke-opacity\",i),t.setAttributeNS(null,\"fill\",e),t.setAttributeNS(null,\"fill-opacity\",i),t.setAttributeNS(null,\"stroke-width\",0),s=r,t.setAttributeNS(null,\"viewBox\",-s+\" \"+-s+\" \"+10*s+\" \"+10*s),o=Math.max(3*s,10),t.setAttributeNS(null,\"markerHeight\",o),t.setAttributeNS(null,\"markerWidth\",o))},updateTicks:function(t){var e,i,r,o,n,a=\"\",h=t.ticks.length;for(e=0;h>e;e++)i=t.ticks[e],o=i[0],n=i[1],\"number\"==typeof o[0]&&\"number\"==typeof o[1]&&(a+=\"M \"+o[0]+\" \"+n[0]+\" L \"+o[1]+\" \"+n[1]+\" \");r=t.rendNode,s.exists(r)||(r=this.createPrim(\"path\",t.id),this.appendChildPrim(r,t.visProp.layer),t.rendNode=r),r.setAttributeNS(null,\"stroke\",t.visProp.strokecolor),r.setAttributeNS(null,\"stroke-opacity\",t.visProp.strokeopacity),r.setAttributeNS(null,\"stroke-width\",t.visProp.strokewidth),this.updatePathPrim(r,a,t.board)},displayCopyright:function(t,e){var i,r=this.createPrim(\"text\",\"licenseText\");r.setAttributeNS(null,\"x\",\"20px\"),r.setAttributeNS(null,\"y\",2+e+\"px\"),r.setAttributeNS(null,\"style\",\"font-family:Arial,Helvetica,sans-serif; font-size:\"+e+\"px; fill:#356AA0; opacity:0.3;\"),i=this.container.ownerDocument.createTextNode(t),r.appendChild(i),this.appendChildPrim(r,0)},drawInternalText:function(t){var e=this.createPrim(\"text\",t.id);return e.setAttributeNS(null,\"class\",t.visProp.cssclass),t.rendNodeText=this.container.ownerDocument.createTextNode(\"\"),e.appendChild(t.rendNodeText),this.appendChildPrim(e,t.visProp.layer),e},updateInternalText:function(t){var e,i=t.plaintext;isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||(e=t.coords.scrCoords[1],t.visPropOld.left!==t.visProp.anchorx+e&&(t.rendNode.setAttributeNS(null,\"x\",e+\"px\"),\"left\"===t.visProp.anchorx?t.rendNode.setAttributeNS(null,\"text-anchor\",\"start\"):\"right\"===t.visProp.anchorx?t.rendNode.setAttributeNS(null,\"text-anchor\",\"end\"):\"middle\"===t.visProp.anchorx&&t.rendNode.setAttributeNS(null,\"text-anchor\",\"middle\"),t.visPropOld.left=t.visProp.anchorx+e),e=t.coords.scrCoords[2],t.visPropOld.top!==t.visProp.anchory+e&&(t.rendNode.setAttributeNS(null,\"y\",e+.5*this.vOffsetText+\"px\"),\"bottom\"===t.visProp.anchory?t.rendNode.setAttributeNS(null,\"dominant-baseline\",\"text-after-edge\"):\"top\"===t.visProp.anchory?t.rendNode.setAttributeNS(null,\"dominant-baseline\",\"text-before-edge\"):\"middle\"===t.visProp.anchory&&t.rendNode.setAttributeNS(null,\"dominant-baseline\",\"middle\"),t.visPropOld.top=t.visProp.anchory+e)),t.htmlStr!==i&&(t.rendNodeText.data=i,t.htmlStr=i),this.transformImage(t,t.transformations)},updateInternalTextStyle:function(t,e,i){this.setObjectFillColor(t,e,i)},drawImage:function(t){var e=this.createPrim(\"image\",t.id);e.setAttributeNS(null,\"preserveAspectRatio\",\"none\"),this.appendChildPrim(e,t.visProp.layer),t.rendNode=e,this.updateImage(t)},transformImage:function(t,e){var i,r,s=t.rendNode,o=\"\",n=e.length;n>0&&(r=this.joinTransforms(t,e),i=[r[1][1],r[2][1],r[1][2],r[2][2],r[1][0],r[2][0]].join(\",\"),o+=\" matrix(\"+i+\") \",s.setAttributeNS(null,\"transform\",o))},updateImageURL:function(t){var e=s.evaluate(t.url);t.rendNode.setAttributeNS(this.xlinkNamespace,\"xlink:href\",e)},updateImageStyle:function(t,e){var i=e?t.visProp.highlightcssclass:t.visProp.cssclass;t.rendNode.setAttributeNS(null,\"class\",i)},appendChildPrim:function(t,i){return s.exists(i)?i>=e.layer.numlayers&&(i=e.layer.numlayers-1):i=0,this.layer[i].appendChild(t),t},createPrim:function(t,e){var i=this.container.ownerDocument.createElementNS(this.svgNamespace,t);return i.setAttributeNS(null,\"id\",this.container.id+\"_\"+e),i.style.position=\"absolute\",\"path\"===t&&(i.setAttributeNS(null,\"stroke-linecap\",\"butt\"),i.setAttributeNS(null,\"stroke-linejoin\",\"round\")),i},remove:function(t){s.exists(t)&&s.exists(t.parentNode)&&t.parentNode.removeChild(t)},makeArrows:function(t){var e;(t.visPropOld.firstarrow!==t.visProp.firstarrow||t.visPropOld.lastarrow!==t.visProp.lastarrow)&&(t.visProp.firstarrow?(e=t.rendNodeTriangleStart,s.exists(e)?this.defs.appendChild(e):(e=this._createArrowHead(t,\"End\"),this.defs.appendChild(e),t.rendNodeTriangleStart=e,t.rendNode.setAttributeNS(null,\"marker-start\",\"url(#\"+this.container.id+\"_\"+t.id+\"TriangleEnd)\"))):(e=t.rendNodeTriangleStart,s.exists(e)&&this.remove(e)),t.visProp.lastarrow?(e=t.rendNodeTriangleEnd,s.exists(e)?this.defs.appendChild(e):(e=this._createArrowHead(t,\"Start\"),this.defs.appendChild(e),t.rendNodeTriangleEnd=e,t.rendNode.setAttributeNS(null,\"marker-end\",\"url(#\"+this.container.id+\"_\"+t.id+\"TriangleStart)\"))):(e=t.rendNodeTriangleEnd,s.exists(e)&&this.remove(e)),t.visPropOld.firstarrow=t.visProp.firstarrow,t.visPropOld.lastarrow=t.visProp.lastarrow)},updateEllipsePrim:function(t,e,i,r,s){var o=1e6;e=Math.abs(e)<o?e:o*e/Math.abs(e),i=Math.abs(i)<o?i:o*i/Math.abs(i),r=Math.abs(r)<o?r:o*r/Math.abs(r),s=Math.abs(s)<o?s:o*s/Math.abs(s),t.setAttributeNS(null,\"cx\",e),t.setAttributeNS(null,\"cy\",i),t.setAttributeNS(null,\"rx\",Math.abs(r)),t.setAttributeNS(null,\"ry\",Math.abs(s))},updateLinePrim:function(t,e,i,r,s){var o=1e6;isNaN(e+i+r+s)||(e=Math.abs(e)<o?e:o*e/Math.abs(e),i=Math.abs(i)<o?i:o*i/Math.abs(i),r=Math.abs(r)<o?r:o*r/Math.abs(r),s=Math.abs(s)<o?s:o*s/Math.abs(s),t.setAttributeNS(null,\"x1\",e),t.setAttributeNS(null,\"y1\",i),t.setAttributeNS(null,\"x2\",r),t.setAttributeNS(null,\"y2\",s))},updatePathPrim:function(t,e){\"\"===e&&(e=\"M 0 0\"),t.setAttributeNS(null,\"d\",e)},updatePathStringPoint:function(t,e,i){var r=\"\",s=t.coords.scrCoords,o=.5*e*Math.sqrt(3),n=.5*e;return\"x\"===i?r=\" M \"+(s[1]-e)+\" \"+(s[2]-e)+\" L \"+(s[1]+e)+\" \"+(s[2]+e)+\" M \"+(s[1]+e)+\" \"+(s[2]-e)+\" L \"+(s[1]-e)+\" \"+(s[2]+e):\"+\"===i?r=\" M \"+(s[1]-e)+\" \"+s[2]+\" L \"+(s[1]+e)+\" \"+s[2]+\" M \"+s[1]+\" \"+(s[2]-e)+\" L \"+s[1]+\" \"+(s[2]+e):\"<>\"===i?r=\" M \"+(s[1]-e)+\" \"+s[2]+\" L \"+s[1]+\" \"+(s[2]+e)+\" L \"+(s[1]+e)+\" \"+s[2]+\" L \"+s[1]+\" \"+(s[2]-e)+\" Z \":\"^\"===i?r=\" M \"+s[1]+\" \"+(s[2]-e)+\" L \"+(s[1]-o)+\" \"+(s[2]+n)+\" L \"+(s[1]+o)+\" \"+(s[2]+n)+\" Z \":\"v\"===i?r=\" M \"+s[1]+\" \"+(s[2]+e)+\" L \"+(s[1]-o)+\" \"+(s[2]-n)+\" L \"+(s[1]+o)+\" \"+(s[2]-n)+\" Z \":\">\"===i?r=\" M \"+(s[1]+e)+\" \"+s[2]+\" L \"+(s[1]-n)+\" \"+(s[2]-o)+\" L \"+(s[1]-n)+\" \"+(s[2]+o)+\" Z \":\"<\"===i&&(r=\" M \"+(s[1]-e)+\" \"+s[2]+\" L \"+(s[1]+n)+\" \"+(s[2]-o)+\" L \"+(s[1]+n)+\" \"+(s[2]+o)+\" Z \"),r},updatePathStringPrim:function(t){var e,i,r,s=\" M \",o=\" L \",n=\" C \",h=s,l=5e3,c=\"\",d=\"plot\"!==t.visProp.curvetype;if(t.numberPoints<=0)return\"\";if(r=Math.min(t.points.length,t.numberPoints),1===t.bezierDegree)for(d&&t.board.options.curve.RDPsmoothing&&(t.points=a.RamerDouglasPeuker(t.points,.5)),e=0;r>e;e++)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?h=s:(i[1]=Math.max(Math.min(i[1],l),-l),i[2]=Math.max(Math.min(i[2],l),-l),c+=h+i[1]+\" \"+i[2],h=o);else if(3===t.bezierDegree)for(e=0;r>e;)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?h=s:(c+=h+i[1]+\" \"+i[2],h===n&&(e+=1,i=t.points[e].scrCoords,c+=\" \"+i[1]+\" \"+i[2],e+=1,i=t.points[e].scrCoords,c+=\" \"+i[1]+\" \"+i[2]),h=n),e+=1;return c},updatePathStringBezierPrim:function(t){var e,i,r,s,o,n,h,l=\" M \",c=\" C \",d=l,u=5e3,p=\"\",f=t.visProp.strokewidth,m=\"plot\"!==t.visProp.curvetype;if(t.numberPoints<=0)return\"\";for(m&&t.board.options.curve.RDPsmoothing&&(t.points=a.RamerDouglasPeuker(t.points,.5)),h=Math.min(t.points.length,t.numberPoints),i=1;3>i;i++)for(d=l,e=0;h>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?d=l:(s[1]=Math.max(Math.min(s[1],u),-u),s[2]=Math.max(Math.min(s[2],u),-u),d===l?p+=d+s[1]+\" \"+s[2]:(r=2*i,p+=[d,o+.333*(s[1]-o)+f*(r*Math.random()-i),\" \",n+.333*(s[2]-n)+f*(r*Math.random()-i),\" \",o+.666*(s[1]-o)+f*(r*Math.random()-i),\" \",n+.666*(s[2]-n)+f*(r*Math.random()-i),\" \",s[1],\" \",s[2]].join(\"\")),d=c,o=s[1],n=s[2]);return p},updatePolygonPrim:function(t,e){var i,r,s=\"\",o=e.vertices.length;for(t.setAttributeNS(null,\"stroke\",\"none\"),i=0;o-1>i;i++){if(!e.vertices[i].isReal)return t.setAttributeNS(null,\"points\",\"\"),void 0;r=e.vertices[i].coords.scrCoords,s=s+r[1]+\",\"+r[2],o-2>i&&(s+=\" \")}-1===s.indexOf(\"NaN\")&&t.setAttributeNS(null,\"points\",s)},updateRectPrim:function(t,e,i,r,s){t.setAttributeNS(null,\"x\",e),t.setAttributeNS(null,\"y\",i),t.setAttributeNS(null,\"width\",r),t.setAttributeNS(null,\"height\",s)},setPropertyPrim:function(t,e,i){\"stroked\"!==e&&t.setAttributeNS(null,e,i)},show:function(t){var e;t&&t.rendNode&&(e=t.rendNode,e.setAttributeNS(null,\"display\",\"inline\"),e.style.visibility=\"inherit\")},hide:function(t){var e;t&&t.rendNode&&(e=t.rendNode,e.setAttributeNS(null,\"display\",\"none\"),e.style.visibility=\"hidden\")},setBuffering:function(t,e){t.rendNode.setAttribute(\"buffered-rendering\",e)},setDashStyle:function(t){var e=t.visProp.dash,i=t.rendNode;t.visProp.dash>0?i.setAttributeNS(null,\"stroke-dasharray\",this.dashArray[e-1]):i.hasAttributeNS(null,\"stroke-dasharray\")&&i.removeAttributeNS(null,\"stroke-dasharray\")},setGradient:function(t){var e,i,r,o,n,a,h,l,c,d=t.rendNode;i=s.evaluate(t.visProp.fillopacity),i=i>0?i:0,e=s.evaluate(t.visProp.fillcolor),\"linear\"===t.visProp.gradient?(r=this.createPrim(\"linearGradient\",t.id+\"_gradient\"),a=\"0%\",h=\"100%\",l=\"0%\",c=\"0%\",r.setAttributeNS(null,\"x1\",a),r.setAttributeNS(null,\"x2\",h),r.setAttributeNS(null,\"y1\",l),r.setAttributeNS(null,\"y2\",c),o=this.createPrim(\"stop\",t.id+\"_gradient1\"),o.setAttributeNS(null,\"offset\",\"0%\"),o.setAttributeNS(null,\"style\",\"stop-color:\"+e+\";stop-opacity:\"+i),n=this.createPrim(\"stop\",t.id+\"_gradient2\"),n.setAttributeNS(null,\"offset\",\"100%\"),n.setAttributeNS(null,\"style\",\"stop-color:\"+t.visProp.gradientsecondcolor+\";stop-opacity:\"+t.visProp.gradientsecondopacity),r.appendChild(o),r.appendChild(n),this.defs.appendChild(r),d.setAttributeNS(null,\"style\",\"fill:url(#\"+this.container.id+\"_\"+t.id+\"_gradient)\"),t.gradNode1=o,t.gradNode2=n):\"radial\"===t.visProp.gradient?(r=this.createPrim(\"radialGradient\",t.id+\"_gradient\"),r.setAttributeNS(null,\"cx\",\"50%\"),r.setAttributeNS(null,\"cy\",\"50%\"),r.setAttributeNS(null,\"r\",\"50%\"),r.setAttributeNS(null,\"fx\",100*t.visProp.gradientpositionx+\"%\"),r.setAttributeNS(null,\"fy\",100*t.visProp.gradientpositiony+\"%\"),o=this.createPrim(\"stop\",t.id+\"_gradient1\"),o.setAttributeNS(null,\"offset\",\"0%\"),o.setAttributeNS(null,\"style\",\"stop-color:\"+t.visProp.gradientsecondcolor+\";stop-opacity:\"+t.visProp.gradientsecondopacity),n=this.createPrim(\"stop\",t.id+\"_gradient2\"),n.setAttributeNS(null,\"offset\",\"100%\"),n.setAttributeNS(null,\"style\",\"stop-color:\"+e+\";stop-opacity:\"+i),r.appendChild(o),r.appendChild(n),this.defs.appendChild(r),d.setAttributeNS(null,\"style\",\"fill:url(#\"+this.container.id+\"_\"+t.id+\"_gradient)\"),t.gradNode1=o,t.gradNode2=n):d.removeAttributeNS(null,\"style\")\n},updateGradient:function(t){var e,i,r=t.gradNode1,o=t.gradNode2;s.exists(r)&&s.exists(o)&&(i=s.evaluate(t.visProp.fillopacity),i=i>0?i:0,e=s.evaluate(t.visProp.fillcolor),\"linear\"===t.visProp.gradient?(r.setAttributeNS(null,\"style\",\"stop-color:\"+e+\";stop-opacity:\"+i),o.setAttributeNS(null,\"style\",\"stop-color:\"+t.visProp.gradientsecondcolor+\";stop-opacity:\"+t.visProp.gradientsecondopacity)):\"radial\"===t.visProp.gradient&&(r.setAttributeNS(null,\"style\",\"stop-color:\"+t.visProp.gradientsecondcolor+\";stop-opacity:\"+t.visProp.gradientsecondopacity),o.setAttributeNS(null,\"style\",\"stop-color:\"+e+\";stop-opacity:\"+i)))},setObjectFillColor:function(e,i,r){var o,a,h,l,c=s.evaluate(i),d=s.evaluate(r);d=d>0?d:0,(e.visPropOld.fillcolor!==c||e.visPropOld.fillopacity!==d)&&(s.exists(c)&&c!==!1&&(9!==c.length?(a=c,l=d):(h=n.rgba2rgbo(c),a=h[0],l=d*h[1]),o=e.rendNode,\"none\"!==a?o.setAttributeNS(null,\"fill\",a):l=0,e.type===t.OBJECT_TYPE_IMAGE?o.setAttributeNS(null,\"opacity\",l):o.setAttributeNS(null,\"fill-opacity\",l),s.exists(e.visProp.gradient)&&this.updateGradient(e)),e.visPropOld.fillcolor=c,e.visPropOld.fillopacity=d)},setObjectStrokeColor:function(t,e,i){var o,a,h,l,c=s.evaluate(e),d=s.evaluate(i);d=d>0?d:0,(t.visPropOld.strokecolor!==c||t.visPropOld.strokeopacity!==d)&&(s.exists(c)&&c!==!1&&(9!==c.length?(o=c,h=d):(a=n.rgba2rgbo(c),o=a[0],h=d*a[1]),l=t.rendNode,t.type===r.OBJECT_TYPE_TEXT?\"html\"===t.visProp.display?(l.style.color=o,l.style.opacity=h):(l.setAttributeNS(null,\"style\",\"fill:\"+o),l.setAttributeNS(null,\"style\",\"fill-opacity:\"+h)):(l.setAttributeNS(null,\"stroke\",o),l.setAttributeNS(null,\"stroke-opacity\",h)),t.type===r.OBJECT_TYPE_ARROW?this._setArrowAtts(t.rendNodeTriangle,o,h,t.visProp.strokewidth):(t.elementClass===r.OBJECT_CLASS_CURVE||t.elementClass===r.OBJECT_CLASS_LINE)&&(t.visProp.firstarrow&&this._setArrowAtts(t.rendNodeTriangleStart,o,h,t.visProp.strokewidth),t.visProp.lastarrow&&this._setArrowAtts(t.rendNodeTriangleEnd,o,h,t.visProp.strokewidth))),t.visPropOld.strokecolor=c,t.visPropOld.strokeopacity=d)},setObjectStrokeWidth:function(t,e){var i,o=s.evaluate(e);isNaN(o)||t.visPropOld.strokewidth===o||(i=t.rendNode,this.setPropertyPrim(i,\"stroked\",\"true\"),s.exists(o)&&(this.setPropertyPrim(i,\"stroke-width\",o+\"px\"),t.type===r.OBJECT_TYPE_ARROW?this._setArrowAtts(t.rendNodeTriangle,t.visProp.strokecolor,t.visProp.strokeopacity,o):(t.elementClass===r.OBJECT_CLASS_CURVE||t.elementClass===r.OBJECT_CLASS_LINE)&&(t.visProp.firstarrow&&this._setArrowAtts(t.rendNodeTriangleStart,t.visProp.strokecolor,t.visProp.strokeopacity,o),t.visProp.lastarrow&&this._setArrowAtts(t.rendNodeTriangleEnd,t.visProp.strokecolor,t.visProp.strokeopacity,o))),t.visPropOld.strokewidth=o)},setShadow:function(t){t.visPropOld.shadow!==t.visProp.shadow&&(s.exists(t.rendNode)&&(t.visProp.shadow?t.rendNode.setAttributeNS(null,\"filter\",\"url(#\"+this.container.id+\"_\"+\"f1)\"):t.rendNode.removeAttributeNS(null,\"filter\")),t.visPropOld.shadow=t.visProp.shadow)},suspendRedraw:function(){},unsuspendRedraw:function(){},resize:function(t,e){this.svgRoot.style.width=parseFloat(t)+\"px\",this.svgRoot.style.height=parseFloat(e)+\"px\"},createTouchpoints:function(t){var e,i,r,s;for(this.touchpoints=[],e=0;t>e;e++)i=\"touchpoint1_\"+e,s=this.createPrim(\"path\",i),this.appendChildPrim(s,19),s.setAttributeNS(null,\"d\",\"M 0 0\"),this.touchpoints.push(s),this.setPropertyPrim(s,\"stroked\",\"true\"),this.setPropertyPrim(s,\"stroke-width\",\"1px\"),s.setAttributeNS(null,\"stroke\",\"#000000\"),s.setAttributeNS(null,\"stroke-opacity\",1),s.setAttributeNS(null,\"display\",\"none\"),r=\"touchpoint2_\"+e,s=this.createPrim(\"ellipse\",r),this.appendChildPrim(s,19),this.updateEllipsePrim(s,0,0,0,0),this.touchpoints.push(s),this.setPropertyPrim(s,\"stroked\",\"true\"),this.setPropertyPrim(s,\"stroke-width\",\"1px\"),s.setAttributeNS(null,\"stroke\",\"#000000\"),s.setAttributeNS(null,\"stroke-opacity\",1),s.setAttributeNS(null,\"fill\",\"#ffffff\"),s.setAttributeNS(null,\"fill-opacity\",0),s.setAttributeNS(null,\"display\",\"none\")},showTouchpoint:function(t){this.touchpoints&&t>=0&&2*t<this.touchpoints.length&&(this.touchpoints[2*t].setAttributeNS(null,\"display\",\"inline\"),this.touchpoints[2*t+1].setAttributeNS(null,\"display\",\"inline\"))},hideTouchpoint:function(t){this.touchpoints&&t>=0&&2*t<this.touchpoints.length&&(this.touchpoints[2*t].setAttributeNS(null,\"display\",\"none\"),this.touchpoints[2*t+1].setAttributeNS(null,\"display\",\"none\"))},updateTouchpoint:function(t,e){var i,r,s=37;this.touchpoints&&t>=0&&2*t<this.touchpoints.length&&(i=e[0],r=e[1],this.touchpoints[2*t].setAttributeNS(null,\"d\",\"M \"+(i-s)+\" \"+r+\" \"+\"L \"+(i+s)+\" \"+r+\" \"+\"M \"+i+\" \"+(r-s)+\" \"+\"L \"+i+\" \"+(r+s)),this.updateEllipsePrim(this.touchpoints[2*t+1],e[0],e[1],25,25))}}),t.SVGRenderer}),define(\"renderer/vml\",[\"jxg\",\"renderer/abstract\",\"base/constants\",\"utils/type\",\"utils/color\",\"math/math\",\"math/numerics\"],function(t,e,i,r,s,o,n){return t.VMLRenderer=function(e){this.type=\"vml\",this.container=e,this.container.style.overflow=\"hidden\",\"\"===this.container.style.position&&(this.container.style.position=\"relative\"),this.container.onselectstart=function(){return!1},this.resolution=10,r.exists(t.vmlStylesheet)||(e.ownerDocument.namespaces.add(\"jxgvml\",\"urn:schemas-microsoft-com:vml\"),t.vmlStylesheet=this.container.ownerDocument.createStyleSheet(),t.vmlStylesheet.addRule(\".jxgvml\",\"behavior:url(#default#VML)\"));try{e.ownerDocument.namespaces.jxgvml||e.ownerDocument.namespaces.add(\"jxgvml\",\"urn:schemas-microsoft-com:vml\"),this.createNode=function(t){return e.ownerDocument.createElement(\"<jxgvml:\"+t+' class=\"jxgvml\">')}}catch(i){this.createNode=function(t){return e.ownerDocument.createElement(\"<\"+t+' xmlns=\"urn:schemas-microsoft.com:vml\" class=\"jxgvml\">')}}this.dashArray=[\"Solid\",\"1 1\",\"ShortDash\",\"Dash\",\"LongDash\",\"ShortDashDot\",\"LongDashDot\"]},t.VMLRenderer.prototype=new e,t.extend(t.VMLRenderer.prototype,{_setAttr:function(e,i,r,s){try{8===this.container.ownerDocument.documentMode?e[i]=r:e.setAttribute(i,r,s)}catch(o){t.debug(\"_setAttr: \"+i+\" \"+r+\"<br>\\n\")}},updateTicks:function(t){var e,i,s,o,n,a=this.resolution,h=[];for(i=t.ticks.length,e=0;i>e;e++)s=t.ticks[e],o=s[0],n=s[1],\"number\"==typeof o[0]&&\"number\"==typeof o[1]&&h.push(\" m \"+Math.round(a*o[0])+\", \"+Math.round(a*n[0])+\" l \"+Math.round(a*o[1])+\", \"+Math.round(a*n[1])+\" \");r.exists(t.rendNode)||(t.rendNode=this.createPrim(\"path\",t.id),this.appendChildPrim(t.rendNode,t.visProp.layer)),this._setAttr(t.rendNode,\"stroked\",\"true\"),this._setAttr(t.rendNode,\"strokecolor\",t.visProp.strokecolor,1),this._setAttr(t.rendNode,\"strokeweight\",t.visProp.strokewidth),this._setAttr(t.rendNodeStroke,\"opacity\",100*t.visProp.strokeopacity+\"%\"),this.updatePathPrim(t.rendNode,h,t.board)},displayCopyright:function(t,e){var i,r;i=this.createNode(\"textbox\"),i.style.position=\"absolute\",this._setAttr(i,\"id\",this.container.id+\"_\"+\"licenseText\"),i.style.left=20,i.style.top=2,i.style.fontSize=e,i.style.color=\"#356AA0\",i.style.fontFamily=\"Arial,Helvetica,sans-serif\",this._setAttr(i,\"opacity\",\"30%\"),i.style.filter=\"alpha(opacity = 30)\",r=this.container.ownerDocument.createTextNode(t),i.appendChild(r),this.appendChildPrim(i,0)},drawInternalText:function(t){var e;return e=this.createNode(\"textbox\"),e.style.position=\"absolute\",t.rendNodeText=this.container.ownerDocument.createTextNode(\"\"),e.appendChild(t.rendNodeText),this.appendChildPrim(e,9),e},updateInternalText:function(t){var e,i=t.plaintext;isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])||(e=\"right\"===t.visProp.anchorx?Math.floor(t.board.canvasWidth-t.coords.scrCoords[1]):\"middle\"===t.visProp.anchorx?Math.floor(t.coords.scrCoords[1]-.5*t.size[0]):Math.floor(t.coords.scrCoords[1]),t.visPropOld.left!==t.visProp.anchorx+e&&(\"right\"===t.visProp.anchorx?(t.rendNode.style.right=e+\"px\",t.rendNode.style.left=\"auto\"):(t.rendNode.style.left=e+\"px\",t.rendNode.style.right=\"auto\"),t.visPropOld.left=t.visProp.anchorx+e),e=\"top\"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]+this.vOffsetText):\"middle\"===t.visProp.anchory?Math.floor(t.coords.scrCoords[2]-.5*t.size[1]+this.vOffsetText):Math.floor(t.board.canvasHeight-t.coords.scrCoords[2]-this.vOffsetText),t.visPropOld.top!==t.visProp.anchory+e&&(\"bottom\"===t.visProp.anchory?(t.rendNode.style.bottom=e+\"px\",t.rendNode.style.top=\"auto\"):(t.rendNode.style.top=e+\"px\",t.rendNode.style.bottom=\"auto\"),t.visPropOld.top=t.visProp.anchory+e)),t.htmlStr!==i&&(t.rendNodeText.data=i,t.htmlStr=i),this.transformImage(t,t.transformations)},drawImage:function(t){var e;e=this.container.ownerDocument.createElement(\"img\"),e.style.position=\"absolute\",this._setAttr(e,\"id\",this.container.id+\"_\"+t.id),this.container.appendChild(e),this.appendChildPrim(e,t.visProp.layer),e.style.filter=\"progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand')\",t.rendNode=e,this.updateImage(t)},transformImage:function(t,e){var i,r,s,n,a,h,l,c=t.rendNode,d=[],u=e.length;if(u>0){for(l=t.rendNode.style.filter.toString(),l.match(/DXImageTransform/)||(c.style.filter=\"progid:DXImageTransform.Microsoft.Matrix(M11='1.0', sizingMethod='auto expand') \"+l),i=this.joinTransforms(t,e),d[0]=o.matVecMult(i,t.coords.scrCoords),d[0][1]/=d[0][0],d[0][2]/=d[0][0],d[1]=o.matVecMult(i,[1,t.coords.scrCoords[1]+t.size[0],t.coords.scrCoords[2]]),d[1][1]/=d[1][0],d[1][2]/=d[1][0],d[2]=o.matVecMult(i,[1,t.coords.scrCoords[1]+t.size[0],t.coords.scrCoords[2]-t.size[1]]),d[2][1]/=d[2][0],d[2][2]/=d[2][0],d[3]=o.matVecMult(i,[1,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1]]),d[3][1]/=d[3][0],d[3][2]/=d[3][0],r=d[0][1],n=d[0][1],s=d[0][2],a=d[0][2],h=1;4>h;h++)r=Math.max(r,d[h][1]),n=Math.min(n,d[h][1]),s=Math.max(s,d[h][2]),a=Math.min(a,d[h][2]);c.style.left=Math.floor(n)+\"px\",c.style.top=Math.floor(a)+\"px\",c.filters.item(0).M11=i[1][1],c.filters.item(0).M12=i[1][2],c.filters.item(0).M21=i[2][1],c.filters.item(0).M22=i[2][2]}},updateImageURL:function(t){var e=r.evaluate(t.url);this._setAttr(t.rendNode,\"src\",e)},appendChildPrim:function(t,e){return r.exists(e)||(e=0),t.style.zIndex=e,this.container.appendChild(t),t},appendNodesToElement:function(t,e){(\"shape\"===e||\"path\"===e||\"polygon\"===e)&&(t.rendNodePath=this.getElementById(t.id+\"_path\")),t.rendNodeFill=this.getElementById(t.id+\"_fill\"),t.rendNodeStroke=this.getElementById(t.id+\"_stroke\"),t.rendNodeShadow=this.getElementById(t.id+\"_shadow\"),t.rendNode=this.getElementById(t.id)},createPrim:function(t,e){var i,r,s=this.createNode(\"fill\"),o=this.createNode(\"stroke\"),n=this.createNode(\"shadow\");return this._setAttr(s,\"id\",this.container.id+\"_\"+e+\"_fill\"),this._setAttr(o,\"id\",this.container.id+\"_\"+e+\"_stroke\"),this._setAttr(n,\"id\",this.container.id+\"_\"+e+\"_shadow\"),\"circle\"===t||\"ellipse\"===t?(i=this.createNode(\"oval\"),i.appendChild(s),i.appendChild(o),i.appendChild(n)):\"polygon\"===t||\"path\"===t||\"shape\"===t||\"line\"===t?(i=this.createNode(\"shape\"),i.appendChild(s),i.appendChild(o),i.appendChild(n),r=this.createNode(\"path\"),this._setAttr(r,\"id\",this.container.id+\"_\"+e+\"_path\"),i.appendChild(r)):(i=this.createNode(t),i.appendChild(s),i.appendChild(o),i.appendChild(n)),i.style.position=\"absolute\",i.style.left=\"0px\",i.style.top=\"0px\",this._setAttr(i,\"id\",this.container.id+\"_\"+e),i},remove:function(t){r.exists(t)&&t.removeNode(!0)},makeArrows:function(t){var e;(t.visPropOld.firstarrow!==t.visProp.firstarrow||t.visPropOld.lastarrow!==t.visProp.lastarrow)&&(t.visProp.firstarrow?(e=t.rendNodeStroke,this._setAttr(e,\"startarrow\",\"block\"),this._setAttr(e,\"startarrowlength\",\"long\")):(e=t.rendNodeStroke,r.exists(e)&&this._setAttr(e,\"startarrow\",\"none\")),t.visProp.lastarrow?(e=t.rendNodeStroke,this._setAttr(e,\"id\",this.container.id+\"_\"+t.id+\"stroke\"),this._setAttr(e,\"endarrow\",\"block\"),this._setAttr(e,\"endarrowlength\",\"long\")):(e=t.rendNodeStroke,r.exists(e)&&this._setAttr(e,\"endarrow\",\"none\")),t.visPropOld.firstarrow=t.visProp.firstarrow,t.visPropOld.lastarrow=t.visProp.lastarrow)},updateEllipsePrim:function(t,e,i,r,s){t.style.left=Math.floor(e-r)+\"px\",t.style.top=Math.floor(i-s)+\"px\",t.style.width=Math.floor(2*Math.abs(r))+\"px\",t.style.height=Math.floor(2*Math.abs(s))+\"px\"},updateLinePrim:function(t,e,i,r,s,o){var n,a=this.resolution;isNaN(e+i+r+s)||(n=[\"m \",Math.floor(a*e),\", \",Math.floor(a*i),\" l \",Math.floor(a*r),\", \",Math.floor(a*s)],this.updatePathPrim(t,n,o))},updatePathPrim:function(t,e,i){var r=i.canvasWidth,s=i.canvasHeight;e.length<=0&&(e=[\"m 0,0\"]),t.style.width=r,t.style.height=s,this._setAttr(t,\"coordsize\",[Math.floor(this.resolution*r),Math.floor(this.resolution*s)].join(\",\")),this._setAttr(t,\"path\",e.join(\"\"))},updatePathStringPoint:function(t,e,i){var r=[],s=Math.round,o=t.coords.scrCoords,n=.5*e*Math.sqrt(3),a=.5*e,h=this.resolution;return\"x\"===i?r.push([\" m \",s(h*(o[1]-e)),\", \",s(h*(o[2]-e)),\" l \",s(h*(o[1]+e)),\", \",s(h*(o[2]+e)),\" m \",s(h*(o[1]+e)),\", \",s(h*(o[2]-e)),\" l \",s(h*(o[1]-e)),\", \",s(h*(o[2]+e))].join(\"\")):\"+\"===i?r.push([\" m \",s(h*(o[1]-e)),\", \",s(h*o[2]),\" l \",s(h*(o[1]+e)),\", \",s(h*o[2]),\" m \",s(h*o[1]),\", \",s(h*(o[2]-e)),\" l \",s(h*o[1]),\", \",s(h*(o[2]+e))].join(\"\")):\"<>\"===i?r.push([\" m \",s(h*(o[1]-e)),\", \",s(h*o[2]),\" l \",s(h*o[1]),\", \",s(h*(o[2]+e)),\" l \",s(h*(o[1]+e)),\", \",s(h*o[2]),\" l \",s(h*o[1]),\", \",s(h*(o[2]-e)),\" x e \"].join(\"\")):\"^\"===i?r.push([\" m \",s(h*o[1]),\", \",s(h*(o[2]-e)),\" l \",s(h*(o[1]-n)),\", \",s(h*(o[2]+a)),\" l \",s(h*(o[1]+n)),\", \",s(h*(o[2]+a)),\" x e \"].join(\"\")):\"v\"===i?r.push([\" m \",s(h*o[1]),\", \",s(h*(o[2]+e)),\" l \",s(h*(o[1]-n)),\", \",s(h*(o[2]-a)),\" l \",s(h*(o[1]+n)),\", \",s(h*(o[2]-a)),\" x e \"].join(\"\")):\">\"===i?r.push([\" m \",s(h*(o[1]+e)),\", \",s(h*o[2]),\" l \",s(h*(o[1]-a)),\", \",s(h*(o[2]-n)),\" l \",s(h*(o[1]-a)),\", \",s(h*(o[2]+n)),\" l \",s(h*(o[1]+e)),\", \",s(h*o[2])].join(\"\")):\"<\"===i&&r.push([\" m \",s(h*(o[1]-e)),\", \",s(h*o[2]),\" l \",s(h*(o[1]+a)),\", \",s(h*(o[2]-n)),\" l \",s(h*(o[1]+a)),\", \",s(h*(o[2]+n)),\" x e \"].join(\"\")),r},updatePathStringPrim:function(t){var e,i,r=[],s=this.resolution,o=Math.round,a=\" m \",h=\" l \",l=\" c \",c=a,d=\"plot\"!==t.visProp.curvetype,u=Math.min(t.numberPoints,8192);if(t.numberPoints<=0)return\"\";if(u=Math.min(u,t.points.length),1===t.bezierDegree)for(d&&t.board.options.curve.RDPsmoothing&&(t.points=n.RamerDouglasPeuker(t.points,1)),e=0;u>e;e++)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?c=a:(i[1]>2e4?i[1]=2e4:i[1]<-2e4&&(i[1]=-2e4),i[2]>2e4?i[2]=2e4:i[2]<-2e4&&(i[2]=-2e4),r.push([c,o(s*i[1]),\", \",o(s*i[2])].join(\"\")),c=h);else if(3===t.bezierDegree)for(e=0;u>e;)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?c=a:(r.push([c,o(s*i[1]),\", \",o(s*i[2])].join(\"\")),c===l&&(e+=1,i=t.points[e].scrCoords,r.push([\" \",o(s*i[1]),\", \",o(s*i[2])].join(\"\")),e+=1,i=t.points[e].scrCoords,r.push([\" \",o(s*i[1]),\", \",o(s*i[2])].join(\"\"))),c=l),e+=1;return r.push(\" e\"),r},updatePathStringBezierPrim:function(t){var e,i,r,s,o,a,h=[],l=t.visProp.strokewidth,c=this.resolution,d=Math.round,u=\" m \",p=\" c \",f=u,m=\"plot\"!==t.visProp.curvetype,b=Math.min(t.numberPoints,8192);if(t.numberPoints<=0)return\"\";for(m&&t.board.options.curve.RDPsmoothing&&(t.points=n.RamerDouglasPeuker(t.points,1)),b=Math.min(b,t.points.length),i=1;3>i;i++)for(f=u,e=0;b>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?f=u:(s[1]>2e4?s[1]=2e4:s[1]<-2e4&&(s[1]=-2e4),s[2]>2e4?s[2]=2e4:s[2]<-2e4&&(s[2]=-2e4),f===u?h.push([f,d(c*s[1]),\" \",d(c*s[2])].join(\"\")):(r=2*i,h.push([f,d(c*(o+.333*(s[1]-o)+l*(r*Math.random()-i))),\" \",d(c*(a+.333*(s[2]-a)+l*(r*Math.random()-i))),\" \",d(c*(o+.666*(s[1]-o)+l*(r*Math.random()-i))),\" \",d(c*(a+.666*(s[2]-a)+l*(r*Math.random()-i))),\" \",d(c*s[1]),\" \",d(c*s[2])].join(\"\"))),f=p,o=s[1],a=s[2]);return h.push(\" e\"),h},updatePolygonPrim:function(t,e){var i,r,s=e.vertices.length,o=this.resolution,n=[];if(this._setAttr(t,\"stroked\",\"false\"),r=e.vertices[0].coords.scrCoords,!isNaN(r[1]+r[2])){for(n.push([\"m \",Math.floor(o*r[1]),\",\",Math.floor(o*r[2]),\" l \"].join(\"\")),i=1;s-1>i;i++){if(!e.vertices[i].isReal)return this.updatePathPrim(t,\"\",e.board),void 0;if(r=e.vertices[i].coords.scrCoords,isNaN(r[1]+r[2]))return;n.push(Math.floor(o*r[1])+\",\"+Math.floor(o*r[2])),s-2>i&&n.push(\", \")}n.push(\" x e\"),this.updatePathPrim(t,n,e.board)}},updateRectPrim:function(t,e,i,r,s){t.style.left=Math.floor(e)+\"px\",t.style.top=Math.floor(i)+\"px\",r>=0&&(t.style.width=r+\"px\"),s>=0&&(t.style.height=s+\"px\")},setPropertyPrim:function(t,e,i){var s,o=\"\";switch(e){case\"stroke\":o=\"strokecolor\";break;case\"stroke-width\":o=\"strokeweight\";break;case\"stroke-dasharray\":o=\"dashstyle\"}\"\"!==o&&(s=r.evaluate(i),this._setAttr(t,o,s))},show:function(t){t&&t.rendNode&&(t.rendNode.style.visibility=\"inherit\")},hide:function(t){t&&t.rendNode&&(t.rendNode.style.visibility=\"hidden\")},setDashStyle:function(t,e){var i;e.dash>=0&&(i=t.rendNodeStroke,this._setAttr(i,\"dashstyle\",this.dashArray[e.dash]))},setGradient:function(t){var e=t.rendNodeFill;\"linear\"===t.visProp.gradient?(this._setAttr(e,\"type\",\"gradient\"),this._setAttr(e,\"color2\",t.visProp.gradientsecondcolor),this._setAttr(e,\"opacity2\",t.visProp.gradientsecondopacity),this._setAttr(e,\"angle\",t.visProp.gradientangle)):\"radial\"===t.visProp.gradient?(this._setAttr(e,\"type\",\"gradientradial\"),this._setAttr(e,\"color2\",t.visProp.gradientsecondcolor),this._setAttr(e,\"opacity2\",t.visProp.gradientsecondopacity),this._setAttr(e,\"focusposition\",100*t.visProp.gradientpositionx+\"%,\"+100*t.visProp.gradientpositiony+\"%\"),this._setAttr(e,\"focussize\",\"0,0\")):this._setAttr(e,\"type\",\"solid\")},setObjectFillColor:function(t,e,o){var n,a,h,l,c=r.evaluate(e),d=r.evaluate(o);t.rendNode,d=d>0?d:0,(t.visPropOld.fillcolor!==c||t.visPropOld.fillopacity!==d)&&(r.exists(c)&&c!==!1&&(9!==c.length?(n=c,h=d):(a=s.rgba2rgbo(c),n=a[0],h=d*a[1]),\"none\"===n||n===!1?this._setAttr(t.rendNode,\"filled\",\"false\"):(this._setAttr(t.rendNode,\"filled\",\"true\"),this._setAttr(t.rendNode,\"fillcolor\",n),r.exists(h)&&t.rendNodeFill&&this._setAttr(t.rendNodeFill,\"opacity\",100*h+\"%\")),t.type===i.OBJECT_TYPE_IMAGE&&(l=t.rendNode.style.filter.toString(),l.match(/alpha/)?t.rendNode.style.filter=l.replace(/alpha\\(opacity *= *[0-9\\.]+\\)/,\"alpha(opacity = \"+100*h+\")\"):t.rendNode.style.filter+=\" alpha(opacity = \"+100*h+\")\")),t.visPropOld.fillcolor=c,t.visPropOld.fillopacity=d)},setObjectStrokeColor:function(t,e,s){var o,n,a,h,l=r.evaluate(e),c=r.evaluate(s),d=t.rendNode;c=c>0?c:0,(t.visPropOld.strokecolor!==l||t.visPropOld.strokeopacity!==c)&&(r.exists(l)&&l!==!1&&(9!==l.length?(o=l,a=c):(n=e.rgba2rgbo(l),o=n[0],a=c*n[1]),t.type===i.OBJECT_TYPE_TEXT?(a=Math.round(100*a),d.style.filter=\" alpha(opacity = \"+a+\")\",d.style.color=o):(o!==!1&&(this._setAttr(d,\"stroked\",\"true\"),this._setAttr(d,\"strokecolor\",o)),h=t.rendNodeStroke,r.exists(a)&&t.type!==i.OBJECT_TYPE_IMAGE&&this._setAttr(h,\"opacity\",100*a+\"%\"))),t.visPropOld.strokecolor=l,t.visPropOld.strokeopacity=c)},setObjectStrokeWidth:function(t,e){var i,s=r.evaluate(e);isNaN(s)||t.visPropOld.strokewidth===s||(i=t.rendNode,this.setPropertyPrim(i,\"stroked\",\"true\"),r.exists(s)&&(this.setPropertyPrim(i,\"stroke-width\",s),0===s&&r.exists(t.rendNodeStroke)&&this._setAttr(i,\"stroked\",\"false\")),t.visPropOld.strokewidth=s)},setShadow:function(t){var e=t.rendNodeShadow;e&&t.visPropOld.shadow!==t.visProp.shadow&&(t.visProp.shadow?(this._setAttr(e,\"On\",\"True\"),this._setAttr(e,\"Offset\",\"3pt,3pt\"),this._setAttr(e,\"Opacity\",\"60%\"),this._setAttr(e,\"Color\",\"#aaaaaa\")):this._setAttr(e,\"On\",\"False\"),t.visPropOld.shadow=t.visProp.shadow)},suspendRedraw:function(){this.container.style.display=\"none\"},unsuspendRedraw:function(){this.container.style.display=\"\"}}),t.VMLRenderer}),define(\"renderer/canvas\",[\"jxg\",\"renderer/abstract\",\"base/constants\",\"utils/env\",\"utils/type\",\"utils/uuid\",\"utils/color\",\"base/coords\",\"math/math\",\"math/geometry\",\"math/numerics\"],function(t,e,i,r,s,o,n,a,h,l,c){return t.CanvasRenderer=function(t,e){this.type=\"canvas\",this.canvasRoot=null,this.suspendHandle=null,this.canvasId=o.genUUID(),this.canvasNamespace=null,r.isBrowser?(this.container=t,this.container.style.MozUserSelect=\"none\",this.container.style.overflow=\"hidden\",\"\"===this.container.style.position&&(this.container.style.position=\"relative\"),this.container.innerHTML=['<canvas id=\"',this.canvasId,'\" width=\"',e.width,'px\" height=\"',e.height,'px\"><',\"/canvas>\"].join(\"\"),this.canvasRoot=this.container.ownerDocument.getElementById(this.canvasId),this.context=this.canvasRoot.getContext(\"2d\")):r.isNode()&&(this.canvasId=\"object\"==typeof module?module.require(\"canvas\"):require(\"canvas\"),this.canvasRoot=new this.canvasId(500,500),this.context=this.canvasRoot.getContext(\"2d\")),this.dashArray=[[2,2],[5,5],[10,10],[20,20],[20,10,10,10],[20,5,10,5]]},t.CanvasRenderer.prototype=new e,t.extend(t.CanvasRenderer.prototype,{_drawFilledPolygon:function(t){var e,i=t.length,r=this.context;if(i>0){for(r.beginPath(),r.moveTo(t[0][0],t[0][1]),e=0;i>e;e++)e>0&&r.lineTo(t[e][0],t[e][1]);r.lineTo(t[0][0],t[0][1]),r.fill()}},_fill:function(t){var e=this.context;e.save(),this._setColor(t,\"fill\")&&e.fill(),e.restore()},_rotatePoint:function(t,e,i){return[e*Math.cos(t)-i*Math.sin(t),e*Math.sin(t)+i*Math.cos(t)]},_rotateShape:function(t,e){var i,r=[],s=t.length;if(0>=s)return t;for(i=0;s>i;i++)r.push(this._rotatePoint(e,t[i][0],t[i][1]));return r},_setColor:function(t,e,i){var r,o,a,h,l,c,d=!0,u=!1,p=t.visProp;return e=e||\"stroke\",i=i||e,s.exists(t.board)&&s.exists(t.board.highlightedObjects)||(u=!0),r=!u&&s.exists(t.board.highlightedObjects[t.id])?\"highlight\":\"\",o=s.evaluate(p[r+e+\"color\"]),\"none\"!==o&&o!==!1?(l=s.evaluate(p[r+e+\"opacity\"]),l=l>0?l:0,9!==o.length?(h=o,c=l):(a=n.rgba2rgbo(o),h=a[0],c=l*a[1]),this.context.globalAlpha=c,this.context[i+\"Style\"]=h):d=!1,\"stroke\"!==e||isNaN(parseFloat(p.strokewidth))||(this.context.lineWidth=parseFloat(p.strokewidth)),d},_stroke:function(t){var e=this.context;e.save(),t.visProp.dash>0?e.setLineDash&&e.setLineDash(this.dashArray[t.visProp.dash]):this.context.lineDashArray=[],this._setColor(t,\"stroke\")&&e.stroke(),e.restore()},_translateShape:function(t,e,i){var r,s=[],o=t.length;if(0>=o)return t;for(r=0;o>r;r++)s.push([t[r][0]+e,t[r][1]+i]);return s},drawPoint:function(t){var e=t.visProp.face,i=t.visProp.size,r=t.coords.scrCoords,s=.5*i*Math.sqrt(3),o=.5*i,n=parseFloat(t.visProp.strokewidth)/2,a=this.context;if(t.visProp.visible)switch(e){case\"cross\":case\"x\":a.beginPath(),a.moveTo(r[1]-i,r[2]-i),a.lineTo(r[1]+i,r[2]+i),a.moveTo(r[1]+i,r[2]-i),a.lineTo(r[1]-i,r[2]+i),a.closePath(),this._stroke(t);break;case\"circle\":case\"o\":a.beginPath(),a.arc(r[1],r[2],i+1+n,0,2*Math.PI,!1),a.closePath(),this._fill(t),this._stroke(t);break;case\"square\":case\"[]\":if(0>=i)break;a.save(),this._setColor(t,\"stroke\",\"fill\")&&a.fillRect(r[1]-i-n,r[2]-i-n,2*i+3*n,2*i+3*n),a.restore(),a.save(),this._setColor(t,\"fill\"),a.fillRect(r[1]-i+n,r[2]-i+n,2*i-n,2*i-n),a.restore();break;case\"plus\":case\"+\":a.beginPath(),a.moveTo(r[1]-i,r[2]),a.lineTo(r[1]+i,r[2]),a.moveTo(r[1],r[2]-i),a.lineTo(r[1],r[2]+i),a.closePath(),this._stroke(t);break;case\"diamond\":case\"<>\":a.beginPath(),a.moveTo(r[1]-i,r[2]),a.lineTo(r[1],r[2]+i),a.lineTo(r[1]+i,r[2]),a.lineTo(r[1],r[2]-i),a.closePath(),this._fill(t),this._stroke(t);break;case\"triangleup\":case\"a\":case\"^\":a.beginPath(),a.moveTo(r[1],r[2]-i),a.lineTo(r[1]-s,r[2]+o),a.lineTo(r[1]+s,r[2]+o),a.closePath(),this._fill(t),this._stroke(t);break;case\"triangledown\":case\"v\":a.beginPath(),a.moveTo(r[1],r[2]+i),a.lineTo(r[1]-s,r[2]-o),a.lineTo(r[1]+s,r[2]-o),a.closePath(),this._fill(t),this._stroke(t);break;case\"triangleleft\":case\"<\":a.beginPath(),a.moveTo(r[1]-i,r[2]),a.lineTo(r[1]+o,r[2]-s),a.lineTo(r[1]+o,r[2]+s),a.closePath(),this.fill(t),this._stroke(t);break;case\"triangleright\":case\">\":a.beginPath(),a.moveTo(r[1]+i,r[2]),a.lineTo(r[1]-o,r[2]-s),a.lineTo(r[1]-o,r[2]+s),a.closePath(),this._fill(t),this._stroke(t)}},updatePoint:function(t){this.drawPoint(t)},drawLine:function(t){var e,r,s,o,n,c,d=new a(i.COORDS_BY_USER,t.point1.coords.usrCoords,t.board),u=new a(i.COORDS_BY_USER,t.point2.coords.usrCoords,t.board),p=null;t.visProp.visible&&((t.visProp.firstarrow||t.visProp.lastarrow)&&(p=-4),l.calcStraight(t,d,u,p),s=o=n=c=0,e=Math.max(3*parseInt(t.visProp.strokewidth,10),10),t.visProp.lastarrow&&(r=d.distance(i.COORDS_BY_SCREEN,u),r>h.eps&&(n=(u.scrCoords[1]-d.scrCoords[1])*e/r,c=(u.scrCoords[2]-d.scrCoords[2])*e/r)),t.visProp.firstarrow&&(r=d.distance(i.COORDS_BY_SCREEN,u),r>h.eps&&(s=(u.scrCoords[1]-d.scrCoords[1])*e/r,o=(u.scrCoords[2]-d.scrCoords[2])*e/r)),this.context.beginPath(),this.context.moveTo(d.scrCoords[1]+s,d.scrCoords[2]+o),this.context.lineTo(u.scrCoords[1]-n,u.scrCoords[2]-c),this._stroke(t),this.makeArrows(t,d,u))},updateLine:function(t){this.drawLine(t)},drawTicks:function(){},updateTicks:function(t){var e,i,r,s,o=t.ticks.length,n=this.context;for(n.beginPath(),e=0;o>e;e++)i=t.ticks[e],r=i[0],s=i[1],n.moveTo(r[0],s[0]),n.lineTo(r[1],s[1]);for(e=0;o>e;e++)i=t.ticks[e].scrCoords,t.ticks[e].major&&(t.board.needsFullUpdate||t.needsRegularUpdate)&&t.labels[e]&&t.labels[e].visProp.visible&&this.updateText(t.labels[e]);this._stroke(t)},drawCurve:function(t){t.visProp.handdrawing?this.updatePathStringBezierPrim(t):this.updatePathStringPrim(t)},updateCurve:function(t){this.drawCurve(t)},drawEllipse:function(t){var e=t.center.coords.scrCoords[1],i=t.center.coords.scrCoords[2],r=t.board.unitX,s=t.board.unitY,o=2*t.Radius(),n=2*t.Radius(),a=o*r,h=n*s,l=e-a/2,c=i-h/2,d=.5522848*(a/2),u=.5522848*(h/2),p=l+a,f=c+h,m=l+a/2,b=c+h/2,g=this.context;o>0&&n>0&&!isNaN(e+i)&&(g.beginPath(),g.moveTo(l,b),g.bezierCurveTo(l,b-u,m-d,c,m,c),g.bezierCurveTo(m+d,c,p,b-u,p,b),g.bezierCurveTo(p,b+u,m+d,f,m,f),g.bezierCurveTo(m-d,f,l,b+u,l,b),g.closePath(),this._fill(t),this._stroke(t))},updateEllipse:function(t){return this.drawEllipse(t)},displayCopyright:function(t,e){var i=this.context;i.save(),i.font=e+\"px Arial\",i.fillStyle=\"#aaa\",i.lineWidth=.5,i.fillText(t,10,2+e),i.restore()},drawInternalText:function(t){var e,i=this.context;return i.save(),this._setColor(t,\"stroke\",\"fill\")&&!isNaN(t.coords.scrCoords[1]+t.coords.scrCoords[2])&&(t.visProp.fontsize&&(\"function\"==typeof t.visProp.fontsize?(e=t.visProp.fontsize(),i.font=(e>0?e:0)+\"px Arial\"):i.font=t.visProp.fontsize+\"px Arial\"),this.transformImage(t,t.transformations),\"left\"===t.visProp.anchorx?i.textAlign=\"left\":\"right\"===t.visProp.anchorx?i.textAlign=\"right\":\"middle\"===t.visProp.anchorx&&(i.textAlign=\"center\"),\"bottom\"===t.visProp.anchory?i.textBaseline=\"bottom\":\"top\"===t.visProp.anchory?i.textBaseline=\"top\":\"middle\"===t.visProp.anchory&&(i.textBaseline=\"middle\"),i.fillText(t.plaintext,t.coords.scrCoords[1],t.coords.scrCoords[2])),i.restore(),null},updateInternalText:function(t){this.drawInternalText(t)},setObjectStrokeColor:function(t,e,r){var o,a,h,l,c=s.evaluate(e),d=s.evaluate(r);d=d>0?d:0,(t.visPropOld.strokecolor!==c||t.visPropOld.strokeopacity!==d)&&(s.exists(c)&&c!==!1&&(9!==c.length?(o=c,h=d):(a=n.rgba2rgbo(c),o=a[0],h=d*a[1]),l=t.rendNode,t.type===i.OBJECT_TYPE_TEXT&&\"html\"===t.visProp.display&&(l.style.color=o,l.style.opacity=h)),t.visPropOld.strokecolor=c,t.visPropOld.strokeopacity=d)},drawImage:function(t){t.rendNode=new Image,t._src=\"\",this.updateImage(t)},updateImage:function(t){var e=this.context,i=s.evaluate(t.visProp.fillopacity),r=s.bind(function(){t.imgIsLoaded=!0,t.size[0]<=0||t.size[1]<=0||(e.save(),e.globalAlpha=i,this.transformImage(t,t.transformations),e.drawImage(t.rendNode,t.coords.scrCoords[1],t.coords.scrCoords[2]-t.size[1],t.size[0],t.size[1]),e.restore())},this);this.updateImageURL(t)?t.rendNode.onload=r:t.imgIsLoaded&&r()},transformImage:function(t,e){var i,r=e.length,s=this.context;r>0&&(i=this.joinTransforms(t,e),Math.abs(c.det(i))>=h.eps&&s.transform(i[1][1],i[2][1],i[1][2],i[2][2],i[1][0],i[2][0]))},updateImageURL:function(t){var e;return e=s.evaluate(t.url),t._src!==e?(t.imgIsLoaded=!1,t.rendNode.src=e,t._src=e,!0):!1},remove:function(t){s.exists(t)&&s.exists(t.parentNode)&&t.parentNode.removeChild(t)},makeArrows:function(t,e,r){var s,o,n,a,h,l=Math.max(3*t.visProp.strokewidth,10),c=[[-l,.5*-l],[0,0],[-l,.5*l]],d=[[l,.5*-l],[0,0],[l,.5*l]],u=this.context;if(\"none\"!==t.visProp.strokecolor&&(t.visProp.lastarrow||t.visProp.firstarrow)){if(t.elementClass!==i.OBJECT_CLASS_LINE)return;s=e.scrCoords[1],o=e.scrCoords[2],n=r.scrCoords[1],a=r.scrCoords[2],u.save(),this._setColor(t,\"stroke\",\"fill\")&&(h=Math.atan2(a-o,n-s),t.visProp.lastarrow&&this._drawFilledPolygon(this._translateShape(this._rotateShape(c,h),n,a)),t.visProp.firstarrow&&this._drawFilledPolygon(this._translateShape(this._rotateShape(d,h),s,o))),u.restore()}},updatePathStringPrim:function(t){var e,i,r,s,o,n=\"M\",a=\"L\",h=\"C\",l=n,d=5e3,u=\"plot\"!==t.visProp.curvetype,p=this.context;if(!(t.numberPoints<=0)){if(o=Math.min(t.points.length,t.numberPoints),p.beginPath(),1===t.bezierDegree)for(u&&t.board.options.curve.RDPsmoothing&&(t.points=c.RamerDouglasPeuker(t.points,.5)),e=0;o>e;e++)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?l=n:(i[1]>d?i[1]=d:i[1]<-d&&(i[1]=-d),i[2]>d?i[2]=d:i[2]<-d&&(i[2]=-d),l===n?p.moveTo(i[1],i[2]):p.lineTo(i[1],i[2]),l=a);else if(3===t.bezierDegree)for(e=0;o>e;)i=t.points[e].scrCoords,isNaN(i[1])||isNaN(i[2])?l=n:(l===n?p.moveTo(i[1],i[2]):(e+=1,r=t.points[e].scrCoords,e+=1,s=t.points[e].scrCoords,p.bezierCurveTo(i[1],i[2],r[1],r[2],s[1],s[2])),l=h),e+=1;this._fill(t),this._stroke(t)}},updatePathStringBezierPrim:function(t){var e,i,r,s,o,n,a,h=\"M\",l=\"C\",d=h,u=5e3,p=t.visProp.strokewidth,f=\"plot\"!==t.visProp.curvetype,m=this.context;if(!(t.numberPoints<=0)){for(f&&t.board.options.curve.RDPsmoothing&&(t.points=c.RamerDouglasPeuker(t.points,.5)),a=Math.min(t.points.length,t.numberPoints),m.beginPath(),i=1;3>i;i++)for(d=h,e=0;a>e;e++)s=t.points[e].scrCoords,isNaN(s[1])||isNaN(s[2])?d=h:(s[1]>u?s[1]=u:s[1]<-u&&(s[1]=-u),s[2]>u?s[2]=u:s[2]<-u&&(s[2]=-u),d===h?m.moveTo(s[1],s[2]):(r=2*i,m.bezierCurveTo(o+.333*(s[1]-o)+p*(r*Math.random()-i),n+.333*(s[2]-n)+p*(r*Math.random()-i),o+.666*(s[1]-o)+p*(r*Math.random()-i),n+.666*(s[2]-n)+p*(r*Math.random()-i),s[1],s[2])),d=l,o=s[1],n=s[2]);this._fill(t),this._stroke(t)}},updatePolygonPrim:function(t,e){var i,r,s,o=e.vertices.length,n=this.context,a=!0;if(!(0>=o)&&e.visProp.visible){for(n.beginPath(),r=0;!e.vertices[r].isReal&&o-1>r;)r++,a=!1;for(i=e.vertices[r].coords.scrCoords,n.moveTo(i[1],i[2]),s=r;o-1>s;s++)e.vertices[s].isReal||(a=!1),i=e.vertices[s].coords.scrCoords,n.lineTo(i[1],i[2]);n.closePath(),a&&this._fill(e)}},show:function(t){s.exists(t.rendNode)&&(t.rendNode.style.visibility=\"inherit\")},hide:function(t){s.exists(t.rendNode)&&(t.rendNode.style.visibility=\"hidden\")},setGradient:function(t){var e,i;i=s.evaluate(t.visProp.fillopacity),i=i>0?i:0,e=s.evaluate(t.visProp.fillcolor)},setShadow:function(t){t.visPropOld.shadow!==t.visProp.shadow&&(t.visPropOld.shadow=t.visProp.shadow)},highlight:function(t){return t.type===i.OBJECT_TYPE_TEXT&&\"html\"===t.visProp.display?this.updateTextStyle(t,!0):(t.board.prepareUpdate(),t.board.renderer.suspendRedraw(t.board),t.board.updateRenderer(),t.board.renderer.unsuspendRedraw()),this},noHighlight:function(t){return t.type===i.OBJECT_TYPE_TEXT&&\"html\"===t.visProp.display?this.updateTextStyle(t,!1):(t.board.prepareUpdate(),t.board.renderer.suspendRedraw(t.board),t.board.updateRenderer(),t.board.renderer.unsuspendRedraw()),this},suspendRedraw:function(e){this.context.save(),this.context.clearRect(0,0,this.canvasRoot.width,this.canvasRoot.height),e&&e.showCopyright&&this.displayCopyright(t.licenseText,12)},unsuspendRedraw:function(){this.context.restore()},resize:function(t,e){this.container?(this.canvasRoot.style.width=parseFloat(t)+\"px\",this.canvasRoot.style.height=parseFloat(e)+\"px\",this.canvasRoot.setAttribute(\"width\",parseFloat(t)+\"px\"),this.canvasRoot.setAttribute(\"height\",parseFloat(e)+\"px\")):(this.canvasRoot.width=parseFloat(t),this.canvasRoot.height=parseFloat(e))},removeToInsertLater:function(){return function(){}}}),t.CanvasRenderer}),define(\"jsxgraph\",[\"jxg\",\"utils/env\",\"utils/type\",\"base/board\",\"reader/file\",\"options\",\"renderer/svg\",\"renderer/vml\",\"renderer/canvas\",\"renderer/no\"],function(t,e,i,r,s,o,n,a,h,l){return t.JSXGraph={rendererType:function(){return o.renderer=\"no\",e.supportsVML()&&(o.renderer=\"vml\",document.onmousemove=function(){var t;\nreturn document.body&&(t=document.body.scrollLeft,t+=document.body.scrollTop),t}),e.supportsCanvas()&&(o.renderer=\"canvas\"),e.supportsSVG()&&(o.renderer=\"svg\"),e.isNode()&&e.supportsCanvas()&&(o.renderer=\"canvas\"),(e.isNode()||\"no\"===o.renderer)&&(o.text.display=\"internal\",o.infobox.display=\"internal\"),o.renderer}(),initRenderer:function(t,e,i){var r,s;if(i=i||document,\"object\"==typeof i&&null!==t)for(r=i.getElementById(t);r.firstChild;)r.removeChild(r.firstChild);else r=t;return s=\"svg\"===o.renderer?new n(r,e):\"vml\"===o.renderer?new a(r):\"canvas\"===o.renderer?new h(r,e):new l},initBoard:function(s,n){var a,h,l,c,d,u,p,f,m,b,g,v;return n=n||{},b=i.copyAttributes(n,o,\"board\"),b.zoom=i.copyAttributes(b,o,\"board\",\"zoom\"),b.pan=i.copyAttributes(b,o,\"board\",\"pan\"),f=e.getDimensions(s,b.document),b.unitx||b.unity?(a=i.def(b.originx,150),h=i.def(b.originy,150),l=i.def(b.unitx,50),c=i.def(b.unity,50)):(m=b.boundingbox,u=parseInt(f.width,10),p=parseInt(f.height,10),b.keepaspectratio?(l=u/(m[2]-m[0]),c=p/(m[1]-m[3]),Math.abs(l)<Math.abs(c)?c=Math.abs(l)*c/Math.abs(c):l=Math.abs(c)*l/Math.abs(l)):(l=u/(m[2]-m[0]),c=p/(m[1]-m[3])),a=-l*m[0],h=c*m[1]),d=this.initRenderer(s,f,b.document),v=new r(s,d,\"\",[a,h],b.zoomfactor*b.zoomx,b.zoomfactor*b.zoomy,l,c,f.width,f.height,b),t.boards[v.id]=v,t.boards[v.id]=v,v.resizeContainer(f.width,f.height,!0),v.suspendUpdate(),v.initInfobox(),b.axis&&(g=\"object\"==typeof b.axis?b.axis:{ticks:{drawZero:!0}},v.defaultAxes={},v.defaultAxes.x=v.create(\"axis\",[[0,0],[1,0]],g),v.defaultAxes.y=v.create(\"axis\",[[0,0],[0,1]],g)),b.grid&&v.create(\"grid\",[],\"object\"==typeof b.grid?b.grid:{}),v.renderer.drawZoomBar(v),v.unsuspendUpdate(),v},loadBoardFromFile:function(n,a,h,l,c){var d,u,p,f;return l=l||{},d=i.copyAttributes(l,o,\"board\"),d.zoom=i.copyAttributes(l,o,\"board\",\"zoom\"),d.pan=i.copyAttributes(l,o,\"board\",\"pan\"),f=e.getDimensions(n,d.document),u=this.initRenderer(n,f,d.document),p=new r(n,u,\"\",[150,150],1,1,50,50,f.width,f.height,d),p.initInfobox(),p.resizeContainer(f.width,f.height,!0),s.parseFileContent(a,p,h,!0,c),p.renderer.drawZoomBar(p),t.boards[p.id]=p,p},loadBoardFromString:function(n,a,h,l,c){var d,u,p,f;return l=l||{},d=i.copyAttributes(l,o,\"board\"),d.zoom=i.copyAttributes(l,o,\"board\",\"zoom\"),d.pan=i.copyAttributes(l,o,\"board\",\"pan\"),p=e.getDimensions(n,d.document),u=this.initRenderer(n,p,d.document),f=new r(n,u,\"\",[150,150],1,1,50,50,p.width,p.height,d),f.initInfobox(),f.resizeContainer(p.width,p.height,!0),s.parseString(a,f,h,!0,c),f.renderer.drawZoomBar(f),t.boards[f.id]=f,f},freeBoard:function(e){var i;\"string\"==typeof e&&(e=t.boards[e]),e.removeEventHandlers(),e.suspendUpdate();for(i in e.objects)e.objects.hasOwnProperty(i)&&e.objects[i].remove();for(;e.containerObj.firstChild;)e.containerObj.removeChild(e.containerObj.firstChild);for(i in e.objects)e.objects.hasOwnProperty(i)&&delete e.objects[i];delete e.renderer,e.jc.creator.clearCache(),delete e.jc,delete t.boards[e.id]},registerElement:function(e,i){t.registerElement(e,i)},unregisterElement:function(){throw new Error(\"Unimplemented\")}},e.isBrowser&&\"object\"==typeof window&&\"object\"==typeof document&&e.addEvent(window,\"load\",function(){var e,r,s,o,n,a,h,l,c,d,u,p,f=document.getElementsByTagName(\"script\"),m=function(e,i,r){var s=t.JSXGraph.initBoard(n,{boundingbox:r,keepaspectratio:!0,grid:u,axis:d,showReload:!0});if(i.toLowerCase().indexOf(\"script\")>-1)s.construct(e);else try{s.jc.parse(e)}catch(o){t.debug(o)}return s},b=function(e,i,r,s){return function(){var o;t.JSXGraph.freeBoard(e),o=m(i,r,s),o.reload=b(o,i,r,s)}};for(r=0;r<f.length;r++)if(e=f[r].getAttribute(\"type\",!1),i.exists(e)&&(\"text/jessiescript\"===e.toLowerCase()||\"jessiescript\"===e.toLowerCase()||\"text/jessiecode\"===e.toLowerCase()||\"jessiecode\"===e.toLowerCase())){if(h=f[r].getAttribute(\"width\",!1)||\"500px\",l=f[r].getAttribute(\"height\",!1)||\"500px\",c=f[r].getAttribute(\"boundingbox\",!1)||\"-5, 5, 5, -5\",n=f[r].getAttribute(\"container\",!1),c=c.split(\",\"),4!==c.length)c=[-5,5,5,-5];else for(s=0;s<c.length;s++)c[s]=parseFloat(c[s]);if(d=i.str2Bool(f[r].getAttribute(\"axis\",!1)||\"false\"),u=i.str2Bool(f[r].getAttribute(\"grid\",!1)||\"false\"),i.exists(n))o=document.getElementById(n);else{n=\"jessiescript_autgen_jxg_\"+r,o=document.createElement(\"div\"),o.setAttribute(\"id\",n),o.setAttribute(\"style\",\"width:\"+h+\"; height:\"+l+\"; float:left\"),o.setAttribute(\"class\",\"jxgbox\");try{document.body.insertBefore(o,f[r])}catch(g){\"object\"==typeof jQuery&&jQuery(o).insertBefore(f[r])}}document.getElementById(n)?(p=f[r].innerHTML,p=p.replace(/<!\\[CDATA\\[/g,\"\").replace(/\\]\\]>/g,\"\"),f[r].innerHTML=p,a=m(p,e,c),a.reload=b(a,p,e,c)):t.debug(\"JSXGraph: Apparently the div injection failed. Can't create a board, sorry.\")}},window),t.JSXGraph}),define(\"base/group\",[\"jxg\",\"base/constants\",\"base/element\",\"math/math\",\"utils/type\"],function(t,e,i,r,s){return t.Group=function(t,i,r,o){var n,a,h,l;for(this.board=t,this.objects={},n=this.board.numObjects,this.board.numObjects+=1,this.id=\"\"!==i&&s.exists(i)?i:this.board.id+\"Group\"+n,this.board.groups[this.id]=this,this.type=e.OBJECT_TYPE_POINT,this.elementClass=e.OBJECT_CLASS_POINT,this.name=\"\"!==r&&s.exists(r)?r:\"group_\"+this.board.generateName(this),delete this.type,this.coords={},a=s.isArray(o)?o:Array.prototype.slice.call(arguments,3),h=0;h<a.length;h++)l=this.board.select(a[h]),l.visProp.fixed||l.type!==e.OBJECT_TYPE_POINT&&l.type!==e.OBJECT_TYPE_GLIDER||(0!==l.group.length?this.addGroup(l.group[l.group.length-1]):this.addPoint(l));this.methodMap={ungroup:\"ungroup\",add:\"addPoint\",addPoint:\"addPoint\",addPoints:\"addPoints\",addGroup:\"addGroup\",remove:\"removePoint\",removePoint:\"removePoint\",setAttribute:\"setAttribute\",setProperty:\"setAttribute\"}},t.extend(t.Group.prototype,{ungroup:function(){var t;for(t in this.objects)this.objects.hasOwnProperty(t)&&(s.isArray(this.objects[t].point.group)&&this.objects[t].point.group[this.objects[t].point.group.length-1]===this&&this.objects[t].point.group.pop(),this.removePoint(this.objects[t].point))},update:function(t){var i,o,n,a,h=null;for(i in this.objects)if(this.objects.hasOwnProperty(i)&&(h=this.objects[i].point,h.coords.distance(e.COORDS_BY_USER,this.coords[i])>r.eps)){o=[h.coords.usrCoords[1]-this.coords[h.id].usrCoords[1],h.coords.usrCoords[2]-this.coords[h.id].usrCoords[2]],n=h;break}if(s.exists(n)){for(i in this.objects)this.objects.hasOwnProperty(i)&&(s.exists(this.board.objects[i])?(h=this.objects[i].point,h.id!==n.id&&h.coords.setCoordinates(e.COORDS_BY_USER,[this.coords[i].usrCoords[1]+o[0],this.coords[i].usrCoords[2]+o[1]])):delete this.objects[i],this.coords[h.id]={usrCoords:[h.coords.usrCoords[0],h.coords.usrCoords[1],h.coords.usrCoords[2]]});for(i in this.objects)if(this.objects.hasOwnProperty(i))for(a in this.objects[i].descendants)this.objects[i].descendants.hasOwnProperty(a)&&(this.objects[i].descendants.needsUpdate=this.objects[i].descendants.needsRegularUpdate||this.board.needsFullUpdate);this.board.updateElements(t)}return this},addPoint:function(t){this.objects[t.id]={point:t},this.coords[t.id]={usrCoords:[t.coords.usrCoords[0],t.coords.usrCoords[1],t.coords.usrCoords[2]]}},addPoints:function(t){var e;for(e=0;e<t.length;e++)this.addPoint(t[e])},addGroup:function(t){var e;for(e in t.objects)t.objects.hasOwnProperty(e)&&this.addPoint(t.objects[e].point)},removePoint:function(t){delete this.objects[t.id]},setProperty:t.shortcut(t.Group.prototype,\"setAttribute\"),setAttribute:function(){var t;for(t in this.objects)this.objects.hasOwnProperty(t)&&this.objects[t].point.setAttribute.apply(this.objects[t].point,arguments)}}),t.createGroup=function(e,i,r){var s,o=new t.Group(e,r.id,r.name,i);for(o.elType=\"group\",o.parents=[],s=0;s<i.length;s++)o.parents.push(i[s].id);return o},t.registerElement(\"group\",t.createGroup),{Group:t.Group,createGroup:t.createGroup}}),define(\"element/conic\",[\"jxg\",\"base/constants\",\"base/coords\",\"math/math\",\"math/numerics\",\"math/geometry\",\"utils/type\",\"base/point\",\"base/curve\"],function(t,e,i,r,s,o,n){return t.createEllipse=function(t,r,s){var o,a,h,l,c,d,u,p=[],f=n.copyAttributes(s,t.options,\"conic\",\"foci\"),m=n.copyAttributes(s,t.options,\"conic\");for(d=0;2>d;d++)if(r[d].length>1)p[d]=t.create(\"point\",r[d],f);else if(n.isPoint(r[d]))p[d]=t.select(r[d]);else if(\"function\"==typeof r[d]&&r[d]().elementClass===e.OBJECT_CLASS_POINT)p[d]=r[d]();else{if(!n.isString(r[d]))throw new Error(\"JSXGraph: Can't create Ellipse with parent types '\"+typeof r[0]+\"' and '\"+typeof r[1]+\"'.\"+\"\\nPossible parent types: [point,point,point], [point,point,number|function]\");p[d]=t.select(r[d])}if(n.isNumber(r[2]))c=n.createFunction(r[2],t);else if(\"function\"==typeof r[2]&&n.isNumber(r[2]()))c=r[2];else{if(n.isPoint(r[2]))l=t.select(r[2]);else if(r[2].length>1)l=t.create(\"point\",r[2],f);else if(\"function\"==typeof r[2]&&r[2]().elementClass===e.OBJECT_CLASS_POINT)l=r[2]();else{if(!n.isString(r[2]))throw new Error(\"JSXGraph: Can't create Ellipse with parent types '\"+typeof r[0]+\"' and '\"+typeof r[1]+\"' and '\"+typeof r[2]+\"'.\"+\"\\nPossible parent types: [point,point,point], [point,point,number|function]\");l=t.select(r[2])}c=function(){return l.Dist(p[0])+l.Dist(p[1])}}for(n.exists(r[4])||(r[4]=2*Math.PI),n.exists(r[3])||(r[3]=0),h=t.create(\"point\",[function(){return.5*(p[0].X()+p[1].X())},function(){return.5*(p[0].Y()+p[1].Y())}],f),a=t.create(\"curve\",[function(){return 0},function(){return 0},r[3],r[4]],m),a.majorAxis=c,u=a.hasPoint,o=function(t,e){var i,r,s,o,n,h,l,d,u;e||(i=c(),r=i*i,s=p[0].X(),o=p[0].Y(),n=p[1].X(),h=p[1].Y(),l=s-n,d=o-h,u=(r-s*s-o*o+n*n+h*h)/(2*i),a.quadraticform=[[u*u-n*n-h*h,u*l/i+n,u*d/i+h],[u*l/i+n,l*l/r-1,l*d/r],[u*d/i+h,l*d/r,d*d/r-1]])},a.X=function(t,e){var i=c(),r=p[1].Dist(p[0]),s=.5*(r*r-i*i)/(r*Math.cos(t)-i),n=Math.atan2(p[1].Y()-p[0].Y(),p[1].X()-p[0].X());return e||o(t,e),p[0].X()+Math.cos(n+t)*s},a.Y=function(t){var e=c(),i=p[1].Dist(p[0]),r=.5*(i*i-e*e)/(i*Math.cos(t)-e),s=Math.atan2(p[1].Y()-p[0].Y(),p[1].X()-p[0].X());return p[0].Y()+Math.sin(s+t)*r},a.midpoint=h,a.type=e.OBJECT_TYPE_CONIC,a.hasPoint=function(t,r){var s,o,n,a,h;return this.visProp.hasinnerpoints?(s=p[0].coords,o=p[1].coords,n=this.majorAxis(),a=new i(e.COORDS_BY_SCREEN,[t,r],this.board),h=a.distance(e.COORDS_BY_USER,s)+a.distance(e.COORDS_BY_USER,o),n>=h):u.apply(this,arguments)},h.addChild(a),d=0;2>d;d++)n.isPoint(p[d])&&p[d].addChild(a);for(n.isPoint(l)&&l.addChild(a),a.parents=[],d=0;d<r.length;d++)r[d].id&&a.parents.push(r[d].id);return a},t.createHyperbola=function(t,i,r){var s,o,a,h,l,c,d=[],u=n.copyAttributes(r,t.options,\"conic\",\"foci\"),p=n.copyAttributes(r,t.options,\"conic\");for(c=0;2>c;c++)if(i[c].length>1)d[c]=t.create(\"point\",i[c],u);else if(n.isPoint(i[c]))d[c]=t.select(i[c]);else if(\"function\"==typeof i[c]&&i[c]().elementClass===e.OBJECT_CLASS_POINT)d[c]=i[c]();else{if(!n.isString(i[c]))throw new Error(\"JSXGraph: Can't create Hyperbola with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,point,point], [point,point,number|function]\");d[c]=t.select(i[c])}if(n.isNumber(i[2]))l=n.createFunction(i[2],t);else if(\"function\"==typeof i[2]&&n.isNumber(i[2]()))l=i[2];else{if(n.isPoint(i[2]))h=t.select(i[2]);else if(i[2].length>1)h=t.create(\"point\",i[2],u);else if(\"function\"==typeof i[2]&&i[2]().elementClass===e.OBJECT_CLASS_POINT)h=i[2]();else{if(!n.isString(i[2]))throw new Error(\"JSXGraph: Can't create Hyperbola with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"' and '\"+typeof i[2]+\"'.\"+\"\\nPossible parent types: [point,point,point], [point,point,number|function]\");h=t.select(i[2])}l=function(){return h.Dist(d[0])-h.Dist(d[1])}}for(n.exists(i[4])||(i[4]=1.0001*Math.PI),n.exists(i[3])||(i[3]=-1.0001*Math.PI),a=t.create(\"point\",[function(){return.5*(d[0].X()+d[1].X())},function(){return.5*(d[0].Y()+d[1].Y())}],u),o=t.create(\"curve\",[function(){return 0},function(){return 0},i[3],i[4]],p),o.majorAxis=l,s=function(t,e){var i,r,s,n,a,h,c,u,p;e||(i=l(),r=i*i,s=d[0].X(),n=d[0].Y(),a=d[1].X(),h=d[1].Y(),c=s-a,u=n-h,p=(r-s*s-n*n+a*a+h*h)/(2*i),o.quadraticform=[[p*p-a*a-h*h,p*c/i+a,p*u/i+h],[p*c/i+a,c*c/r-1,c*u/r],[p*u/i+h,c*u/r,u*u/r-1]])},o.X=function(t,e){var i=this.majorAxis(),r=d[1].Dist(d[0]),o=.5*(r*r-i*i)/(r*Math.cos(t)+i),n=Math.atan2(d[1].Y()-d[0].Y(),d[1].X()-d[0].X());return e||s(t,e),d[0].X()+Math.cos(n+t)*o},o.Y=function(t){var e=this.majorAxis(),i=d[1].Dist(d[0]),r=.5*(i*i-e*e)/(i*Math.cos(t)+e),s=Math.atan2(d[1].Y()-d[0].Y(),d[1].X()-d[0].X());return d[0].Y()+Math.sin(s+t)*r},o.midpoint=a,o.type=e.OBJECT_TYPE_CONIC,a.addChild(o),c=0;2>c;c++)n.isPoint(d[c])&&d[c].addChild(o);for(n.isPoint(h)&&h.addChild(o),o.parents=[],c=0;c<i.length;c++)i[c].id&&o.parents.push(i[c].id);return o},t.createParabola=function(t,i,s){var a,h,l,c,d=i[0],u=i[1],p=n.copyAttributes(s,t.options,\"conic\",\"foci\"),f=n.copyAttributes(s,t.options,\"conic\");if(i[0].length>1)d=t.create(\"point\",i[0],p);else if(n.isPoint(i[0]))d=t.select(i[0]);else if(\"function\"==typeof i[0]&&i[0]().elementClass===e.OBJECT_CLASS_POINT)d=i[0]();else{if(!n.isString(i[0]))throw new Error(\"JSXGraph: Can't create Parabola with parent types '\"+typeof i[0]+\"' and '\"+typeof i[1]+\"'.\"+\"\\nPossible parent types: [point,line]\");d=t.select(i[0])}for(n.exists(i[3])||(i[3]=10),n.exists(i[2])||(i[2]=-10),l=t.create(\"point\",[function(){var e=[0,u.stdform[1],u.stdform[2]];return e=r.crossProduct(e,d.coords.usrCoords),o.meetLineLine(e,u.stdform,0,t).usrCoords}],p),h=t.create(\"curve\",[function(){return 0},function(){return 0},i[2],i[3]],f),a=function(t,e){var i,r,s,o,n,a;e||(i=u.stdform[1],r=u.stdform[2],s=u.stdform[0],o=i*i+r*r,n=d.X(),a=d.Y(),h.quadraticform=[[s*s-o*(n*n+a*a),s*i+o*n,s*r+o*a],[s*i+o*n,-r*r,i*r],[s*r+o*a,i*r,-i*i]])},h.X=function(t,e){var i,r,s=u.getAngle(),n=o.distPointLine(d.coords.usrCoords,u.stdform),h=u.point1.coords.usrCoords,l=u.point2.coords.usrCoords,c=d.coords.usrCoords;return r=(l[1]-h[1])*(c[2]-h[2])-(l[2]-h[2])*(c[1]-h[1])>=0?1:-1,i=r*n/(1-Math.sin(t)),e||a(t,e),d.X()+Math.cos(t+s)*i},h.Y=function(t){var e,i,r=u.getAngle(),s=o.distPointLine(d.coords.usrCoords,u.stdform),n=u.point1.coords.usrCoords,a=u.point2.coords.usrCoords,h=d.coords.usrCoords;return i=(a[1]-n[1])*(h[2]-n[2])-(a[2]-n[2])*(h[1]-n[1])>=0?1:-1,e=i*s/(1-Math.sin(t)),d.Y()+Math.sin(t+r)*e},h.type=e.OBJECT_TYPE_CONIC,l.addChild(h),n.isPoint(d)&&d.addChild(h),u.addChild(h),h.parents=[],c=0;c<i.length;c++)i[c].id&&h.parents.push(i[c].id);return h},t.createConic=function(i,o,a){var h,l,c,d,u,p,f,m,b,g,v,C,y,P,_=[[1,0,0],[0,1,0],[0,0,1]],S=[[1,0,0],[0,1,0],[0,0,1]],E=[],O=[],w=n.copyAttributes(a,i.options,\"conic\",\"foci\"),T=n.copyAttributes(a,i.options,\"conic\");if(5===o.length)P=!0;else{if(6!==o.length)throw new Error(\"JSXGraph: Can't create generic Conic with \"+o.length+\" parameters.\");P=!1}if(P)for(C=0;5>C;C++)if(o[C].length>1)E[C]=i.create(\"point\",o[C],w);else if(n.isPoint(o[C]))E[C]=i.select(o[C]);else if(\"function\"==typeof o[C]&&o[C]().elementClass===e.OBJECT_CLASS_POINT)E[C]=o[C]();else{if(!n.isString(o[C]))throw new Error(\"JSXGraph: Can't create Conic section with parent types '\"+typeof o[C]+\"'.\"+\"\\nPossible parent types: [point,point,point,point,point], [a00,a11,a22,a01,a02,a12]\");E[C]=i.select(o[C])}else y=[[0,0,0],[0,0,0],[0,0,0]],y[0][0]=n.isFunction(o[2])?function(){return o[2]()}:function(){return o[2]},y[0][1]=n.isFunction(o[4])?function(){return o[4]()}:function(){return o[4]},y[0][2]=n.isFunction(o[5])?function(){return o[5]()}:function(){return o[5]},y[1][1]=n.isFunction(o[0])?function(){return o[0]()}:function(){return o[0]},y[1][2]=n.isFunction(o[3])?function(){return o[3]()}:function(){return o[3]},y[2][2]=n.isFunction(o[1])?function(){return o[1]()}:function(){return o[1]};if(u=function(t){var e,i;for(e=0;3>e;e++)for(i=e;3>i;i++)t[e][i]+=t[i][e];for(e=0;3>e;e++)for(i=0;e>i;i++)t[e][i]=t[i][e];return t},d=function(t,e){var i,r,s=[[0,0,0],[0,0,0],[0,0,0]];for(i=0;3>i;i++)for(r=0;3>r;r++)s[i][r]=t[i]*e[r];return u(s)},c=function(t,e,i){var s,o,n,a,h,l=[[0,0,0],[0,0,0],[0,0,0]];for(h=r.matVecMult(e,i),n=r.innerProduct(i,h),h=r.matVecMult(t,i),a=r.innerProduct(i,h),s=0;3>s;s++)for(o=0;3>o;o++)l[s][o]=n*t[s][o]-a*e[s][o];return l},l=i.create(\"curve\",[function(){return 0},function(){return 0},0,2*Math.PI],T),h=function(e,i){var o,n,a,h;if(!i){if(P){for(o=0;5>o;o++)O[o]=E[o].coords.usrCoords;g=d(r.crossProduct(O[0],O[1]),r.crossProduct(O[2],O[3])),v=d(r.crossProduct(O[0],O[2]),r.crossProduct(O[1],O[3])),S=c(g,v,O[4])}else for(o=0;3>o;o++)for(n=o;3>n;n++)S[o][n]=y[o][n](),n>o&&(S[n][o]=S[o][n]);for(l.quadraticform=S,p=s.Jacobi(S),p[0][0][0]<0&&(p[0][0][0]*=-1,p[0][1][1]*=-1,p[0][2][2]*=-1),o=0;3>o;o++){for(a=0,n=0;3>n;n++)a+=p[1][n][o]*p[1][n][o];a=Math.sqrt(a)}_=p[1],b=Math.sqrt(Math.abs(p[0][0][0])),f=Math.sqrt(Math.abs(p[0][1][1])),m=Math.sqrt(Math.abs(p[0][2][2]))}return p[0][1][1]<=0&&p[0][2][2]<=0?h=r.matVecMult(_,[1/b,Math.cos(e)/f,Math.sin(e)/m]):p[0][1][1]<=0&&p[0][2][2]>0?h=r.matVecMult(_,[Math.cos(e)/b,1/f,Math.sin(e)/m]):p[0][2][2]<0&&(h=r.matVecMult(_,[Math.sin(e)/b,Math.cos(e)/f,1/m])),t.exists(h)?(h[1]/=h[0],h[2]/=h[0],h[0]=1):h=[1,0/0,0/0],h},l.X=function(t,e){return h(t,e)[1]},l.Y=function(t,e){return h(t,e)[2]},l.midpoint=i.create(\"point\",[function(){var t=l.quadraticform;return[t[1][1]*t[2][2]-t[1][2]*t[1][2],t[1][2]*t[0][2]-t[2][2]*t[0][1],t[0][1]*t[1][2]-t[1][1]*t[0][2]]}],w),l.type=e.OBJECT_TYPE_CONIC,P){for(C=0;5>C;C++)n.isPoint(E[C])&&E[C].addChild(l);for(l.parents=[],C=0;C<o.length;C++)o[C].id&&l.parents.push(o[C].id)}return l.addChild(l.midpoint),l},t.registerElement(\"ellipse\",t.createEllipse),t.registerElement(\"hyperbola\",t.createHyperbola),t.registerElement(\"parabola\",t.createParabola),t.registerElement(\"conic\",t.createConic),{createEllipse:t.createEllipse,createHyperbola:t.createHyperbola,createParabola:t.createParabola,createConic:t.createConic}}),define(\"base/polygon\",[\"jxg\",\"base/constants\",\"base/coords\",\"math/statistics\",\"utils/type\",\"base/element\",\"base/line\",\"base/transformation\"],function(t,e,i,r,s,o){return t.Polygon=function(i,r,o){this.constructor(i,o,e.OBJECT_TYPE_POLYGON,e.OBJECT_CLASS_AREA);var n,a,h,l,c,d=s.copyAttributes(o,i.options,\"polygon\",\"borders\");for(this.withLines=o.withlines,this.attr_line=d,this.vertices=[],n=0;n<r.length;n++)a=this.board.select(r[n]),this.vertices[n]=a;if(this.vertices[this.vertices.length-1]!==this.vertices[0]&&this.vertices.push(this.vertices[0]),this.borders=[],this.withLines)for(l=this.vertices.length-1,c=0;l>c;c++)n=(c+1)%l,d.id=d.ids&&d.ids[n],d.name=d.names&&d.names[n],d.strokecolor=s.isArray(d.colors)&&d.colors[n%d.colors.length]||d.strokecolor,d.visible=s.exists(o.borders.visible)?o.borders.visible:o.visible,d.strokecolor===!1&&(d.strokecolor=\"none\"),h=i.create(\"segment\",[this.vertices[n],this.vertices[n+1]],d),h.dump=!1,this.borders[n]=h,h.parentPolygon=this;for(this.id=this.board.setId(this,\"Py\"),n=0;n<this.vertices.length-1;n++)a=this.board.select(this.vertices[n]),a.addChild(this);this.board.renderer.drawPolygon(this),this.board.finalizeAdding(this),this.elType=\"polygon\",this.createLabel(),this.methodMap=t.deepCopy(this.methodMap,{borders:\"borders\",vertices:\"vertices\",A:\"Area\",Area:\"Area\",addPoints:\"addPoints\",insertPoints:\"insertPoints\",removePoints:\"removePoints\"})},t.Polygon.prototype=new o,t.extend(t.Polygon.prototype,{hasPoint:function(t,e){var i,r,s,o=!1;if(this.visProp.hasinnerpoints)for(s=this.vertices.length,i=0,r=s-2;s-1>i;r=i++)this.vertices[i].coords.scrCoords[2]>e!=this.vertices[r].coords.scrCoords[2]>e&&t<(this.vertices[r].coords.scrCoords[1]-this.vertices[i].coords.scrCoords[1])*(e-this.vertices[i].coords.scrCoords[2])/(this.vertices[r].coords.scrCoords[2]-this.vertices[i].coords.scrCoords[2])+this.vertices[i].coords.scrCoords[1]&&(o=!o);else for(s=this.borders.length,i=0;s>i;i++)if(this.borders[i].hasPoint(t,e)){o=!0;break}return o},updateRenderer:function(){this.needsUpdate&&this.visProp.visible&&(this.board.renderer.updatePolygon(this),this.needsUpdate=!1),this.hasLabel&&this.label.visProp.visible&&(this.label.update(),this.board.renderer.updateText(this.label))},getTextAnchor:function(){var t,r=this.vertices[0].X(),s=this.vertices[0].Y(),o=r,n=s;for(t=0;t<this.vertices.length;t++)this.vertices[t].X()<r&&(r=this.vertices[t].X()),this.vertices[t].X()>o&&(o=this.vertices[t].X()),this.vertices[t].Y()>s&&(s=this.vertices[t].Y()),this.vertices[t].Y()<n&&(n=this.vertices[t].Y());return new i(e.COORDS_BY_USER,[.5*(r+o),.5*(s+n)],this.board)},getLabelAnchor:t.shortcut(t.Polygon.prototype,\"getTextAnchor\"),cloneToBackground:function(){var t,e={};return e.id=this.id+\"T\"+this.numTraces,this.numTraces++,e.vertices=this.vertices,e.visProp=s.deepCopy(this.visProp,this.visProp.traceattributes,!0),e.visProp.layer=this.board.options.layer.trace,e.board=this.board,s.clearVisPropOld(e),t=this.board.renderer.enhancedRendering,this.board.renderer.enhancedRendering=!0,this.board.renderer.drawPolygon(e),this.board.renderer.enhancedRendering=t,this.traces[e.id]=e.rendNode,this},hideElement:function(t){var e;if(this.visProp.visible=!1,this.board.renderer.hide(this),!t)for(e=0;e<this.borders.length;e++)this.borders[e].hideElement();this.hasLabel&&s.exists(this.label)&&(this.label.hiddenByParent=!0,this.label.visProp.visible&&this.board.renderer.hide(this.label))},showElement:function(t){var e;if(this.visProp.visible=!0,this.board.renderer.show(this),!t)for(e=0;e<this.borders.length;e++)this.borders[e].showElement(),this.borders[e].updateRenderer();s.exists(this.label)&&this.hasLabel&&this.label.hiddenByParent&&(this.label.hiddenByParent=!1,this.label.visProp.visible||this.label.showElement().updateRenderer())},Area:function(){var t,e=0;for(t=0;t<this.vertices.length-1;t++)e+=this.vertices[t].X()*this.vertices[t+1].Y()-this.vertices[t+1].X()*this.vertices[t].Y();return e/=2,Math.abs(e)},remove:function(){var t;for(t=0;t<this.borders.length;t++)this.board.removeObject(this.borders[t]);o.prototype.remove.call(this)},findPoint:function(t){var e;if(!s.isPoint(t))return-1;for(e=0;e<this.vertices.length;e++)if(this.vertices[e].id===t.id)return e;return-1},addPoints:function(){var t=Array.prototype.slice.call(arguments);return this.insertPoints.apply(this,[this.vertices.length-2].concat(t))},insertPoints:function(t){var e,i,r=[];if(0===arguments.length)return this;if(0>t||t>this.vertices.length-2)return this;for(e=1;e<arguments.length;e++)s.isPoint(arguments[e])&&r.push(arguments[e]);if(i=this.vertices.slice(0,t+1).concat(r),this.vertices=i.concat(this.vertices.slice(t+1)),this.withLines){for(i=this.borders.slice(0,t),this.board.removeObject(this.borders[t]),e=0;e<r.length;e++)i.push(this.board.create(\"segment\",[this.vertices[t+e],this.vertices[t+e+1]],this.attr_line));i.push(this.board.create(\"segment\",[this.vertices[t+r.length],this.vertices[t+r.length+1]],this.attr_line)),this.borders=i.concat(this.borders.slice(t))}return this.board.update(),this},removePoints:function(){var t,e,i,r=[],o=[],n=[],a=[];for(this.vertices=this.vertices.slice(0,this.vertices.length-1),t=0;t<arguments.length;t++)s.isPoint(arguments[t])&&(i=this.findPoint(arguments[t])),s.isNumber(i)&&i>-1&&i<this.vertices.length&&-1===s.indexOf(n,i)&&n.push(i);for(n=n.sort(),r=this.vertices.slice(),o=this.borders.slice(),this.withLines&&a.push([n[n.length-1]]),t=n.length-1;t>-1;t--)r[n[t]]=-1,this.withLines&&n[t]-1>n[t-1]&&(a[a.length-1][1]=n[t],a.push([n[t-1]]));for(this.withLines&&(a[a.length-1][1]=n[0]),this.vertices=[],t=0;t<r.length;t++)s.isPoint(r[t])&&this.vertices.push(r[t]);if(this.vertices[this.vertices.length-1].id!==this.vertices[0].id&&this.vertices.push(this.vertices[0]),this.withLines){for(t=0;t<a.length;t++){for(e=a[t][1]-1;e<a[t][0]+1;e++)0>e?(e=0,this.board.removeObject(this.borders[o.length-1]),o[o.length-1]=-1):e>o.length-1&&(e=o.length-1),this.board.removeObject(this.borders[e]),o[e]=-1;0!==a[t][1]&&a[t][0]!==r.length-1&&(o[a[t][0]-1]=this.board.create(\"segment\",[r[Math.max(a[t][1]-1,0)],r[Math.min(a[t][0]+1,this.vertices.length-1)]],this.attr_line))}for(this.borders=[],t=0;t<o.length;t++)-1!==o[t]&&this.borders.push(o[t]);(5===a[0][1]||0===a[a.length-1][1])&&this.borders.push(this.board.create(\"segment\",[this.vertices[0],this.vertices[this.vertices.length-2]],this.attr_line))}return this.board.update(),this},getParents:function(){var t,e=[];for(t=0;t<this.vertices.length;t++)e.push(this.vertices[t].id);return e},getAttributes:function(){var t,e=o.prototype.getAttributes.call(this);if(this.withLines)for(e.lines=e.lines||{},e.lines.ids=[],e.lines.colors=[],t=0;t<this.borders.length;t++)e.lines.ids.push(this.borders[t].id),e.lines.colors.push(this.borders[t].visProp.strokecolor);return e},snapToGrid:function(){var t;for(t=0;t<this.vertices.length;t++)this.vertices[t].snapToGrid()},setPositionDirectly:function(t,e,s){var o,n,a,h,l=new i(t,e,this.board),c=new i(t,s,this.board);for(h=this.vertices.length-1,a=0;h>a;a++)if(!this.vertices[a].draggable())return this;return o=r.subtract(l.usrCoords,c.usrCoords),n=this.board.create(\"transform\",o.slice(1),{type:\"translate\"}),n.applyOnce(this.vertices.slice(0,-1)),this}}),t.createPolygon=function(e,i,r){var o,n,a=s.copyAttributes(r,e.options,\"polygon\");for(n=0;n<i.length;n++)if(i[n]=e.select(i[n]),!s.isPoint(i[n]))throw new Error(\"JSXGraph: Can't create polygon with parent types other than 'point'.\");return o=new t.Polygon(e,i,a),o.isDraggable=!0,o},t.createRegularPolygon=function(t,i,r){var o,n,a,h,l,c,d,u=[];if(s.isNumber(i[i.length-1])&&3!==i.length)throw new Error(\"JSXGraph: A regular polygon needs two points and a number as input.\");if(l=i.length,a=i[l-1],!s.isNumber(a)&&!s.isPoint(t.select(a))||3>a)throw new Error(\"JSXGraph: The third parameter has to be number greater than 2 or a point.\");for(s.isPoint(t.select(a))?(a=l,c=!0):(l--,c=!1),n=0;l>n;n++)if(i[n]=t.select(i[n]),!s.isPoint(i[n]))throw new Error(\"JSXGraph: Can't create regular polygon if the first two parameters aren't points.\");for(u[0]=i[0],u[1]=i[1],d=s.copyAttributes(r,t.options,\"polygon\",\"vertices\"),n=2;a>n;n++)h=t.create(\"transform\",[Math.PI*(2-(a-2)/a),u[n-1]],{type:\"rotate\"}),c?(u[n]=i[n],u[n].addTransform(i[n-2],h)):(s.isArray(d.ids)&&d.ids.length>=a-2&&(d.id=d.ids[n-2]),u[n]=t.create(\"point\",[u[n-2],h],d),u[n].type=e.OBJECT_TYPE_CAS,u[n].isDraggable=!0,u[n].visProp.fixed=!1);return d=s.copyAttributes(r,t.options,\"polygon\"),o=t.create(\"polygon\",u,d),o.elType=\"regularpolygon\",o},t.registerElement(\"polygon\",t.createPolygon),t.registerElement(\"regularpolygon\",t.createRegularPolygon),{Polygon:t.Polygon,createPolygon:t.createPolygon,createRegularPolygon:t.createRegularPolygon}}),define(\"element/arc\",[\"jxg\",\"math/geometry\",\"math/math\",\"base/coords\",\"base/circle\",\"utils/type\",\"base/constants\",\"base/curve\",\"element/composition\"],function(t,e,i,r,s,o,n){return t.createArc=function(a,h,l){var c,d,u;if(h.length<3||h[0].elementClass!==n.OBJECT_CLASS_POINT||h[1].elementClass!==n.OBJECT_CLASS_POINT||h[2].elementClass!==n.OBJECT_CLASS_POINT||h[3]&&h[3].elementClass!==n.OBJECT_CLASS_POINT)throw new Error(\"JSXGraph: Can't create Arc with parent types '\"+typeof h[0]+\"' and '\"+typeof h[1]+\"' and '\"+typeof h[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\");for(d=o.copyAttributes(l,a.options,\"arc\"),c=a.create(\"curve\",[[0],[0]],d),c.elType=\"arc\",c.parents=[],u=0;u<h.length;u++)h[u].id&&c.parents.push(h[u].id);return c.type=n.OBJECT_TYPE_ARC,c.center=a.select(h[0]),c.radiuspoint=a.select(h[1]),c.point2=c.radiuspoint,c.anglepoint=a.select(h[2]),c.point3=c.anglepoint,c.center.addChild(c),c.radiuspoint.addChild(c),c.anglepoint.addChild(c),c.useDirection=d.usedirection,c.updateDataArray=function(){var t,i,r,s,o,n,a=1,l=this.radiuspoint,c=this.center,d=this.anglepoint;i=e.rad(l,c,d),(\"minor\"===this.visProp.type&&i>Math.PI||\"major\"===this.visProp.type&&i<Math.PI)&&(a=-1),this.useDirection&&(s=h[1].coords.usrCoords,o=h[3].coords.usrCoords,n=h[2].coords.usrCoords,r=(s[1]-n[1])*(s[2]-o[2])-(s[2]-n[2])*(s[1]-o[1]),0>r?(this.radiuspoint=h[1],this.anglepoint=h[2]):(this.radiuspoint=h[2],this.anglepoint=h[1])),l=l.coords.usrCoords,c=c.coords.usrCoords,d=d.coords.usrCoords,t=e.bezierArc(l,c,d,!1,a),this.dataX=t[0],this.dataY=t[1],this.bezierDegree=3,this.updateStdform(),this.updateQuadraticform()},c.Radius=function(){return this.radiuspoint.Dist(this.center)},c.getRadius=function(){return this.Radius()},c.Value=function(){return this.Radius()*e.rad(this.radiuspoint,this.center,this.anglepoint)},c.hasPoint=function(t,s){var o,a,h,l,c,d,u,p,f=this.board.options.precision.hasPoint/this.board.unitX,m=this.Radius();return a=new r(n.COORDS_BY_SCREEN,[t,s],this.board),this.transformations.length>0&&(this.updateTransformMatrix(),u=i.inverse(this.transformMat),p=i.matVecMult(u,a.usrCoords),a=new r(n.COORDS_BY_USER,p,this.board)),o=this.center.coords.distance(n.COORDS_BY_USER,a),h=Math.abs(o-m)<f,h&&(l=e.rad(this.radiuspoint,this.center,a.usrCoords.slice(1)),c=0,d=e.rad(this.radiuspoint,this.center,this.anglepoint),(\"minor\"===this.visProp.type&&d>Math.PI||\"major\"===this.visProp.type&&d<Math.PI)&&(c=d,d=2*Math.PI),(c>l||l>d)&&(h=!1)),h},c.hasPointSector=function(t,i){var s,o,a,h=new r(n.COORDS_BY_SCREEN,[t,i],this.board),l=this.Radius(),c=this.center.coords.distance(n.COORDS_BY_USER,h),d=l>c;return d&&(s=e.rad(this.radiuspoint,this.center,h.usrCoords.slice(1)),o=0,a=e.rad(this.radiuspoint,this.center,this.anglepoint),(\"minor\"===this.visProp.type&&a>Math.PI||\"major\"===this.visProp.type&&a<Math.PI)&&(o=a,a=2*Math.PI),(o>s||s>a)&&(d=!1)),d},c.getTextAnchor=function(){return this.center.coords},c.getLabelAnchor=function(){var t,i,s,a,h=e.rad(this.radiuspoint,this.center,this.anglepoint),l=10/this.board.unitX,c=10/this.board.unitY,d=this.point2.coords.usrCoords,u=this.center.coords.usrCoords,p=d[1]-u[1],f=d[2]-u[2];return o.exists(this.label)&&(this.label.relativeCoords=new r(n.COORDS_BY_SCREEN,[0,0],this.board)),(\"minor\"===this.visProp.type&&h>Math.PI||\"major\"===this.visProp.type&&h<Math.PI)&&(h=-(2*Math.PI-h)),t=new r(n.COORDS_BY_USER,[u[1]+Math.cos(.5*h)*p-Math.sin(.5*h)*f,u[2]+Math.sin(.5*h)*p+Math.cos(.5*h)*f],this.board),i=t.usrCoords[1]-u[1],s=t.usrCoords[2]-u[2],a=Math.sqrt(i*i+s*s),i=i*(a+l)/a,s=s*(a+c)/a,new r(n.COORDS_BY_USER,[u[1]+i,u[2]+s],this.board)},c.updateQuadraticform=s.Circle.prototype.updateQuadraticform,c.updateStdform=s.Circle.prototype.updateStdform,c.methodMap=t.deepCopy(c.methodMap,{getRadius:\"getRadius\",radius:\"Radius\",center:\"center\",radiuspoint:\"radiuspoint\",anglepoint:\"anglepoint\"}),c.prepareUpdate().update(),c},t.registerElement(\"arc\",t.createArc),t.createSemicircle=function(t,e,i){var r,s,n;if(!o.isPoint(e[0])||!o.isPoint(e[1]))throw new Error(\"JSXGraph: Can't create Semicircle with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"'.\"+\"\\nPossible parent types: [point,point]\");return n=o.copyAttributes(i,t.options,\"semicircle\",\"midpoint\"),s=t.create(\"midpoint\",[e[0],e[1]],n),s.dump=!1,n=o.copyAttributes(i,t.options,\"semicircle\"),r=t.create(\"arc\",[s,e[1],e[0]],n),r.elType=\"semicircle\",r.parents=[e[0].id,e[1].id],r.subs={midpoint:s},r.midpoint=r.center=s,r},t.registerElement(\"semicircle\",t.createSemicircle),t.createCircumcircleArc=function(t,e,i){var r,s,n;if(!(o.isPoint(e[0])&&o.isPoint(e[1])&&o.isPoint(e[2])))throw new Error(\"JSXGraph: create Circumcircle Arc with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"' and '\"+typeof e[2]+\"'.\"+\"\\nPossible parent types: [point,point,point]\");return n=o.copyAttributes(i,t.options,\"circumcirclearc\",\"center\"),s=t.create(\"circumcenter\",[e[0],e[1],e[2]],n),s.dump=!1,n=o.copyAttributes(i,t.options,\"circumcirclearc\"),n.usedirection=!0,r=t.create(\"arc\",[s,e[0],e[2],e[1]],n),r.elType=\"circumcirclearc\",r.parents=[e[0].id,e[1].id,e[2].id],r.subs={center:s},r.center=s,r},t.registerElement(\"circumcirclearc\",t.createCircumcircleArc),t.createMinorArc=function(e,i,r){return r.type=\"minor\",t.createArc(e,i,r)},t.registerElement(\"minorarc\",t.createMinorArc),t.createMajorArc=function(e,i,r){return r.type=\"major\",t.createArc(e,i,r)},t.registerElement(\"majorarc\",t.createMajorArc),{createArc:t.createArc,createSemicircle:t.createSemicircle,createCircumcircleArc:t.createCircumcircleArc,createMinorArc:t.createMinorArc,createMajorArc:t.createMajorArc}\n}),define(\"element/sector\",[\"jxg\",\"math/geometry\",\"math/math\",\"math/statistics\",\"base/coords\",\"base/constants\",\"utils/type\",\"base/point\",\"base/curve\",\"base/transformation\",\"element/composition\"],function(t,e,i,r,s,o,n){return t.createSector=function(a,h,l){var c,d,u,p,f,m=\"invalid\",b=[\"center\",\"radiuspoint\",\"anglepoint\"];if(n.isPoint(h[0])&&n.isPoint(h[1])&&n.isPoint(h[2])?m=\"3points\":h[0].elementClass===o.OBJECT_CLASS_LINE&&h[1].elementClass===o.OBJECT_CLASS_LINE&&(n.isArray(h[2])||n.isNumber(h[2]))&&(n.isArray(h[3])||n.isNumber(h[3]))&&(n.isNumber(h[4])||n.isFunction(h[4]))&&(m=\"2lines\"),\"invalid\"===m)try{for(d=0;d<h.length;d++)n.isPoint(h[d])||(u=n.copyAttributes(l,a.options,\"sector\",b[d]),h[d]=a.create(\"point\",h[d],u));m=\"3points\"}catch(g){throw new Error(\"JSXGraph: Can't create Sector with parent types '\"+typeof h[0]+\"' and '\"+typeof h[1]+\"' and '\"+typeof h[2]+\"'.\")}return u=n.copyAttributes(l,a.options,\"sector\"),c=a.create(\"curve\",[[0],[0]],u),c.type=o.OBJECT_TYPE_SECTOR,c.elType=\"sector\",\"2lines\"===m?(c.Radius=function(){return n.evaluate(h[4])},c.line1=a.select(h[0]),c.line2=a.select(h[1]),c.line1.addChild(c),c.line2.addChild(c),c.parents=[h[0].id,h[1].id],c.point1={visProp:{}},c.point2={visProp:{}},c.point3={visProp:{}},p=e.meetLineLine(c.line1.stdform,c.line2.stdform,0,a),n.isArray(h[2])?(2===h[2].length&&(h[2]=[1].concat(h[2])),f=[0,c.line1.stdform[1],c.line1.stdform[2]],f=i.crossProduct(f,h[2]),f=e.meetLineLine(f,c.line1.stdform,0,a),f=r.subtract(f.usrCoords,p.usrCoords),c.direction1=i.innerProduct(f,[0,c.line1.stdform[2],-c.line1.stdform[1]],3)>=0?1:-1):c.direction1=h[2]>=0?1:-1,n.isArray(h[3])?(2===h[3].length&&(h[3]=[1].concat(h[3])),f=[0,c.line2.stdform[1],c.line2.stdform[2]],f=i.crossProduct(f,h[3]),f=e.meetLineLine(f,c.line2.stdform,0,a),f=r.subtract(f.usrCoords,p.usrCoords),c.direction2=i.innerProduct(f,[0,c.line2.stdform[2],-c.line2.stdform[1]],3)>=0?1:-1):c.direction2=h[3]>=0?1:-1,c.updateDataArray=function(){var t,n,a,h,l,d,u;return n=this.line1,a=this.line2,l=i.crossProduct(n.stdform,a.stdform),l[1]/=l[0],l[2]/=l[0],l[0]/=l[0],t=this.direction1*this.Radius(),h=r.add(l,[0,t*n.stdform[2],-t*n.stdform[1]]),t=this.direction2*this.Radius(),d=r.add(l,[0,t*a.stdform[2],-t*a.stdform[1]]),this.point2.coords=new s(o.COORDS_BY_USER,h,c.board),this.point1.coords=new s(o.COORDS_BY_USER,l,c.board),this.point3.coords=new s(o.COORDS_BY_USER,d,c.board),Math.abs(h[0])<i.eps||Math.abs(l[0])<i.eps||Math.abs(d[0])<i.eps?(this.dataX=[0/0],this.dataY=[0/0],void 0):(u=e.bezierArc(h,l,d,!0,1),this.dataX=u[0],this.dataY=u[1],this.bezierDegree=3,void 0)},c.methodMap=t.deepCopy(c.methodMap,{radius:\"getRadius\",getRadius:\"getRadius\",setRadius:\"setRadius\"}),c.prepareUpdate().update()):\"3points\"===m&&(c.point1=a.select(h[0]),c.point2=a.select(h[1]),c.point3=a.select(h[2]),c.point1.addChild(c),c.point2.addChild(c),c.point3.addChild(c),c.useDirection=l.usedirection,c.parents=[h[0].id,h[1].id,h[2].id],n.exists(h[3])&&(c.point4=a.select(h[3]),c.point4.addChild(c)),c.methodMap=t.deepCopy(c.methodMap,{center:\"center\",radiuspoint:\"radiuspoint\",anglepoint:\"anglepoint\",radius:\"getRadius\",getRadius:\"getRadius\",setRadius:\"setRadius\"}),c.updateDataArray=function(){var t,i,r,s,o,a=this.point2,h=this.point1,l=this.point3;return a.isReal&&h.isReal&&l.isReal?(this.useDirection&&n.exists(this.point4)&&(r=this.point2.coords.usrCoords,s=this.point4.coords.usrCoords,o=this.point3.coords.usrCoords,i=(r[1]-o[1])*(r[2]-s[2])-(r[2]-o[2])*(r[1]-s[1]),i>=0&&(l=this.point2,a=this.point3)),a=a.coords.usrCoords,h=h.coords.usrCoords,l=l.coords.usrCoords,t=e.bezierArc(a,h,l,!0,1),this.dataX=t[0],this.dataY=t[1],this.bezierDegree=3,void 0):(this.dataX=[0/0],this.dataY=[0/0],void 0)},c.Radius=function(){return this.point2.Dist(this.point1)}),c.center=c.point1,c.radiuspoint=c.point2,c.anglepoint=c.point3,c.hasPointCurve=function(t,i){var r,n,a,h=this.board.options.precision.hasPoint/this.board.unitX,l=new s(o.COORDS_BY_SCREEN,[t,i],this.board),c=this.Radius(),d=this.center.coords.distance(o.COORDS_BY_USER,l),u=Math.abs(d-c)<h;return u&&(r=e.rad(this.point2,this.center,l.usrCoords.slice(1)),n=0,a=e.rad(this.point2,this.center,this.point3),(n>r||r>a)&&(u=!1)),u},c.hasPointSector=function(t,i){var r,n=new s(o.COORDS_BY_SCREEN,[t,i],this.board),a=this.Radius(),h=this.point1.coords.distance(o.COORDS_BY_USER,n),l=a>h;return l&&(r=e.rad(this.point2,this.point1,n.usrCoords.slice(1)),r>e.rad(this.point2,this.point1,this.point3)&&(l=!1)),l},c.hasPoint=function(t,e){return this.visProp.highlightonsector?this.hasPointSector(t,e):this.hasPointCurve(t,e)},c.getTextAnchor=function(){return this.point1.coords},c.getLabelAnchor=function(){var t,i,r,a,h=e.rad(this.point2,this.point1,this.point3),l=13/this.board.unitX,c=13/this.board.unitY,d=this.point2.coords.usrCoords,u=this.point1.coords.usrCoords,p=d[1]-u[1],f=d[2]-u[2];return n.exists(this.label)&&(this.label.relativeCoords=new s(o.COORDS_BY_SCREEN,[0,0],this.board)),t=new s(o.COORDS_BY_USER,[u[1]+Math.cos(.5*h)*p-Math.sin(.5*h)*f,u[2]+Math.sin(.5*h)*p+Math.cos(.5*h)*f],this.board),i=t.usrCoords[1]-u[1],r=t.usrCoords[2]-u[2],a=Math.sqrt(i*i+r*r),i=i*(a+l)/a,r=r*(a+c)/a,new s(o.COORDS_BY_USER,[u[1]+i,u[2]+r],this.board)},c.setRadius=function(t){c.Radius=function(){return n.evaluate(t)}},c.getRadius=function(){return this.Radius()},c.prepareUpdate().update(),c},t.registerElement(\"sector\",t.createSector),t.createCircumcircleSector=function(t,e,i){var r,s,o;if(!(n.isPoint(e[0])&&n.isPoint(e[1])&&n.isPoint(e[2])))throw new Error(\"JSXGraph: Can't create circumcircle sector with parent types '\"+typeof e[0]+\"' and '\"+typeof e[1]+\"' and '\"+typeof e[2]+\"'.\");return o=n.copyAttributes(i,t.options,\"circumcirclesector\",\"center\"),s=t.create(\"circumcenter\",[e[0],e[1],e[2]],o),s.dump=!1,o=n.copyAttributes(i,t.options,\"circumcirclesector\"),r=t.create(\"sector\",[s,e[0],e[2],e[1]],o),r.elType=\"circumcirclesector\",r.parents=[e[0].id,e[1].id,e[2].id],r.center=s,r.subs={center:s},r},t.registerElement(\"circumcirclesector\",t.createCircumcircleSector),t.createAngle=function(t,r,a){var h,l,c,d,u,p,f=\"invalid\";if(n.isPoint(r[0])&&n.isPoint(r[1])&&n.isPoint(r[2])?f=\"3points\":r[0].elementClass===o.OBJECT_CLASS_LINE&&r[1].elementClass===o.OBJECT_CLASS_LINE&&(n.isArray(r[2])||n.isNumber(r[2]))&&(n.isArray(r[3])||n.isNumber(r[3]))&&(f=\"2lines\"),\"invalid\"===f)throw new Error(\"JSXGraph: Can't create angle with parent types '\"+typeof r[0]+\"' and '\"+typeof r[1]+\"' and '\"+typeof r[2]+\"'.\");if(d=n.copyAttributes(a,t.options,\"angle\"),c=d.name,n.exists(c)&&\"\"!==c||(c=t.generateName({type:o.OBJECT_TYPE_ANGLE}),d.name=c),l=n.exists(d.radius)?d.radius:0,\"2lines\"===f?(h=t.create(\"sector\",[r[0],r[1],r[2],r[3],l],d),h.updateDataArraySector=h.updateDataArray,h.setAngle=function(){},h.free=function(){}):(h=t.create(\"sector\",[r[1],r[0],r[2]],d),h.point=h.point2=h.radiuspoint=r[0],h.pointsquare=h.point3=h.anglepoint=r[2],h.Radius=function(){return n.evaluate(l)},h.updateDataArraySector=function(){var t,i=this.point2,r=this.point1,s=this.point3,o=this.Radius(),n=r.Dist(i);i=i.coords.usrCoords,r=r.coords.usrCoords,s=s.coords.usrCoords,i=[1,r[1]+(i[1]-r[1])*o/n,r[2]+(i[2]-r[2])*o/n],s=[1,r[1]+(s[1]-r[1])*o/n,r[2]+(s[2]-r[2])*o/n],t=e.bezierArc(i,r,s,!0,1),this.dataX=t[0],this.dataY=t[1],this.bezierDegree=3},h.setAngle=function(t){var e,i=this.anglepoint,r=this.radiuspoint;return i.draggable()&&(e=this.board.create(\"transform\",[t,this.center],{type:\"rotate\"}),i.addTransform(r,e),i.isDraggable=!1,i.parents=[r]),this},h.free=function(){var t=this.anglepoint;return t.transformations.length>0&&(t.transformations.pop(),t.isDraggable=!0,t.parents=[]),this}),h.elType=\"angle\",h.type=o.OBJECT_TYPE_ANGLE,h.parents=[r[0].id,r[1].id,r[2].id],h.subs={},h.updateDataArraySquare=function(){var t,r,s,o,n,a,h,l,c=this.Radius();\"2lines\"===f&&this.updateDataArraySector(),t=this.point2,r=this.point1,s=this.point3,t=t.coords.usrCoords,r=r.coords.usrCoords,s=s.coords.usrCoords,o=e.distance(t,r,3),n=e.distance(s,r,3),t=[1,r[1]+(t[1]-r[1])*c/o,r[2]+(t[2]-r[2])*c/o],s=[1,r[1]+(s[1]-r[1])*c/n,r[2]+(s[2]-r[2])*c/n],a=i.crossProduct(s,r),h=[-t[1]*a[1]-t[2]*a[2],t[0]*a[1],t[0]*a[2]],a=i.crossProduct(t,r),l=[-s[1]*a[1]-s[2]*a[2],s[0]*a[1],s[0]*a[2]],a=i.crossProduct(h,l),a[1]/=a[0],a[2]/=a[0],this.dataX=[r[1],t[1],a[1],s[1],r[1]],this.dataY=[r[2],t[2],a[2],s[2],r[2]],this.bezierDegree=1},h.updateDataArrayNone=function(){this.dataX=[0/0],this.dataY=[0/0],this.bezierDegree=1},h.updateDataArray=function(){var t=this.visProp.type,i=e.trueAngle(this.point2,this.point1,this.point3);Math.abs(i-90)<this.visProp.orthosensitivity&&(t=this.visProp.orthotype),\"none\"===t?this.updateDataArrayNone():\"square\"===t?this.updateDataArraySquare():\"sector\"===t?this.updateDataArraySector():\"sectordot\"===t&&(this.updateDataArraySector(),this.dot.visProp.visible||this.dot.setAttribute({visible:!0})),(!this.visProp.visible||\"sectordot\"!==t&&this.dot.visProp.visible)&&this.dot.setAttribute({visible:!1})},u=n.copyAttributes(a,t.options,\"angle\",\"dot\"),h.dot=t.create(\"point\",[function(){var t,r,s,o,a,l,c,d;return n.exists(h.dot)&&!h.dot.visProp.visible?[0,0]:(t=h.point2.coords.usrCoords,r=h.point1.coords.usrCoords,s=h.Radius(),o=e.distance(t,r,3),a=.5*e.rad(h.point2,h.point1,h.point3),l=Math.cos(a),c=Math.sin(a),t=[1,r[1]+(t[1]-r[1])*s/o,r[2]+(t[2]-r[2])*s/o],d=[[1,0,0],[r[1]-.5*r[1]*l+.5*r[2]*c,.5*l,.5*-c],[r[2]-.5*r[1]*c-.5*r[2]*l,.5*c,.5*l]],i.matVecMult(d,t))}],u),h.dot.dump=!1,h.subs.dot=h.dot,\"2lines\"===f)for(p=0;2>p;p++)t.select(r[p]).addChild(h.dot);else for(p=0;3>p;p++)t.select(r[p]).addChild(h.dot);return h.getLabelAnchor=function(){var t,r,a,l,c,d,u,p,f,m=12,b=12;return n.exists(this.label)&&(this.label.relativeCoords=new s(o.COORDS_BY_SCREEN,[0,0],this.board)),n.exists(this.label.visProp.fontSize)&&(m=this.label.visProp.fontSize,b=this.label.visProp.fontSize),m/=this.board.unitX,b/=this.board.unitY,r=h.point2.coords.usrCoords,a=h.point1.coords.usrCoords,l=h.Radius(),c=e.distance(r,a,3),d=.5*e.rad(h.point2,h.point1,h.point3),u=Math.cos(d),p=Math.sin(d),r=[1,a[1]+(r[1]-a[1])*l/c,a[2]+(r[2]-a[2])*l/c],f=[[1,0,0],[a[1]-.5*a[1]*u+.5*a[2]*p,.5*u,.5*-p],[a[2]-.5*a[1]*p-.5*a[2]*u,.5*p,.5*u]],t=i.matVecMult(f,r),t[1]/=t[0],t[2]/=t[0],t[0]/=t[0],c=e.distance(t,a,3),t=[t[0],a[1]+(t[1]-a[1])*(l+m)/c,a[2]+(t[2]-a[2])*(l+m)/c],new s(o.COORDS_BY_USER,t,this.board)},h.Value=function(){return e.rad(this.point2,this.point1,this.point3)},h.methodMap=n.deepCopy(h.methodMap,{Value:\"Value\",setAngle:\"setAngle\",free:\"free\"}),h},t.registerElement(\"angle\",t.createAngle),{createSector:t.createSector,createCircumcircleSector:t.createCircumcircleSector,createAngle:t.createAngle}}),define(\"element/locus\",[\"jxg\",\"math/symbolic\",\"utils/type\",\"base/constants\",\"base/curve\"],function(t,e,i,r){return t.createLocus=function(t,s,o){var n,a;if(!i.isArray(s)||1!==s.length||s[0].elementClass!==r.OBJECT_CLASS_POINT)throw new Error(\"JSXGraph: Can't create locus with parent of type other than point.\\nPossible parent types: [point]\");return a=s[0],n=t.create(\"curve\",[[null],[null]],o),n.dontCallServer=!1,n.elType=\"locus\",n.parents=[a.id],n.updateDataArray=function(){var i,r,s;n.board.mode>0||(i=e.generatePolynomials(t,a,!0).join(\"|\"),i!==n.spe&&(n.spe=i,r=function(t,e,i,r){n.dataX=t,n.dataY=e,n.eq=i,n.ctime=r,n.generatePolynomial=function(t){return function(e){var i,r=\"(\"+e.symbolic.x+\")\",s=\"(\"+e.symbolic.y+\")\",o=[];for(i=0;i<t.length;i++)o[i]=t[i].replace(/\\*\\*/g,\"^\").replace(/x/g,r).replace(/y/g,s);return o}}(i)},s=e.geometricLocusByGroebnerBase(t,a,r),r(s.datax,s.datay,s.polynomial,s.exectime)))},n},t.registerElement(\"locus\",t.createLocus),{createLocus:t.createLocus}}),define(\"base/image\",[\"jxg\",\"base/constants\",\"base/coords\",\"base/element\",\"math/math\",\"math/statistics\",\"utils/type\"],function(t,e,i,r,s,o,n){return t.Image=function(r,s,o,a,h){this.constructor(r,h,e.OBJECT_TYPE_IMAGE,e.OBJECT_CLASS_OTHER),this.initialCoords=new i(e.COORDS_BY_USER,o,this.board),n.isFunction(o[0])||n.isFunction(o[1])||(this.isDraggable=!0),this.X=n.createFunction(o[0],this.board,\"\"),this.Y=n.createFunction(o[1],this.board,\"\"),this.Z=n.createFunction(1,this.board,\"\"),this.W=n.createFunction(a[0],this.board,\"\"),this.H=n.createFunction(a[1],this.board,\"\"),this.coords=new i(e.COORDS_BY_USER,[this.X(),this.Y()],this.board),this.usrSize=[this.W(),this.H()],this.size=[Math.abs(this.usrSize[0]*r.unitX),Math.abs(this.usrSize[1]*r.unitY)],this.url=s,this.elType=\"image\",this.span=[[this.Z(),this.X(),this.Y()],[this.Z(),this.W(),0],[this.Z(),0,this.H()]],this.parent=r.select(h.anchor),this.id=this.board.setId(this,\"Im\"),this.board.renderer.drawImage(this),this.visProp.visible||this.board.renderer.hide(this),this.methodMap=t.deepCopy(this.methodMap,{addTransformation:\"addTransform\",trans:\"addTransform\"})},t.Image.prototype=new r,t.extend(t.Image.prototype,{hasPoint:function(t,r){var o,n,a,h,l,c,d,u=this.transformations.length;return 0===u?(o=t-this.coords.scrCoords[1],n=this.coords.scrCoords[2]-r,a=this.board.options.precision.hasPoint,o>=-a&&o-this.size[0]<=a&&n>=-a&&n-this.size[1]<=a):(h=new i(e.COORDS_BY_SCREEN,[t,r],this.board),h=h.usrCoords,l=[h[0]-this.span[0][0],h[1]-this.span[0][1],h[2]-this.span[0][2]],d=s.innerProduct,c=d(l,this.span[1]),c>=0&&c<=d(this.span[1],this.span[1])&&(c=d(l,this.span[2]),c>=0&&c<=d(this.span[2],this.span[2]))?!0:!1)},update:function(){return this.needsUpdate&&(this.visProp.frozen||this.updateCoords(),this.usrSize=[this.W(),this.H()],this.size=[Math.abs(this.usrSize[0]*this.board.unitX),Math.abs(this.usrSize[1]*this.board.unitY)],this.updateTransform(),this.updateSpan()),this},updateRenderer:function(){return this.needsUpdate&&(this.board.renderer.updateImage(this),this.needsUpdate=!1),this},updateTransform:function(){var t,e=this.transformations.length;if(e>0)for(t=0;e>t;t++)this.transformations[t].update();return this},updateCoords:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.X(),this.Y()])},updateSize:function(){this.coords.setCoordinates(e.COORDS_BY_USER,[this.W(),this.H()])},updateSpan:function(){var t,e,i=this.transformations.length,r=[];if(0===i)this.span=[[this.Z(),this.X(),this.Y()],[this.Z(),this.W(),0],[this.Z(),0,this.H()]];else{for(r[0]=[this.Z(),this.X(),this.Y()],r[1]=[this.Z(),this.X()+this.W(),this.Y()],r[2]=[this.Z(),this.X(),this.Y()+this.H()],t=0;i>t;t++)for(e=0;3>e;e++)r[e]=s.matVecMult(this.transformations[t].matrix,r[e]);for(e=0;3>e;e++)r[e][1]/=r[e][0],r[e][2]/=r[e][0],r[e][0]/=r[e][0];for(e=1;3>e;e++)r[e][0]-=r[0][0],r[e][1]-=r[0][1],r[e][2]-=r[0][2];this.span=r}return this},addTransform:function(t){var e;if(n.isArray(t))for(e=0;e<t.length;e++)this.transformations.push(t[e]);else this.transformations.push(t)},setPositionDirectly:function(t,r,s){var a,h=new i(t,r,this.board),l=new i(t,s,this.board),c=[this.Z(),this.X(),this.Y()];return a=o.subtract(h.usrCoords,l.usrCoords),this.X=n.createFunction(c[1]+a[1],this.board,\"\"),this.Y=n.createFunction(c[2]+a[2],this.board,\"\"),this.visProp.snaptogrid&&(this.coords.setCoordinates(e.COORDS_BY_USER,h.usrCoords),this.snapToGrid(),this.X=n.createFunction(this.coords.usrCoords[1],this.board,\"\"),this.Y=n.createFunction(this.coords.usrCoords[2],this.board,\"\")),this},snapToGrid:function(){return this.handleSnapToGrid()}}),t.createImage=function(e,i,r){var s,o;return s=n.copyAttributes(r,e.options,\"image\"),o=new t.Image(e,i[0],i[1],i[2],s),0!==n.evaluate(s.rotate)&&o.addRotation(n.evaluate(s.rotate)),o},t.registerElement(\"image\",t.createImage),{Image:t.Image,createImage:t.createImage}}),define(\"element/slider\",[\"jxg\",\"math/math\",\"base/constants\",\"utils/type\",\"base/point\",\"base/group\",\"base/line\",\"base/ticks\",\"base/text\"],function(t,e,i,r,s){return t.createSlider=function(t,o,n){var a,h,l,c,d,u,p,f,m,b,g,v,C,y,P,_,S,E,O,w,T;return a=o[0],h=o[1],l=o[2][0],c=o[2][1],d=o[2][2],u=d-l,w=r.copyAttributes(n,t.options,\"slider\"),E=w.withticks,S=w.withlabel,O=w.snapwidth,T=w.precision,w=r.copyAttributes(n,t.options,\"slider\",\"point1\"),p=t.create(\"point\",a,w),w=r.copyAttributes(n,t.options,\"slider\",\"point2\"),f=t.create(\"point\",h,w),t.create(\"group\",[p,f]),w=r.copyAttributes(n,t.options,\"slider\",\"baseline\"),m=t.create(\"segment\",[p,f],w),m.updateStdform(),E&&(w=r.copyAttributes(n,t.options,\"slider\",\"ticks\"),b=2,g=t.create(\"ticks\",[m,f.Dist(p)/b,function(t){var r=p.Dist(f),s=p.coords.distance(i.COORDS_BY_USER,t);return r<e.eps?0:s/r*u+l}],w)),v=a[0]+(h[0]-a[0])*(c-l)/(d-l),C=a[1]+(h[1]-a[1])*(c-l)/(d-l),w=r.copyAttributes(n,t.options,\"slider\"),w.withLabel=!1,y=t.create(\"glider\",[v,C,m],w),y.setAttribute({snapwidth:O}),w=r.copyAttributes(n,t.options,\"slider\",\"highline\"),P=t.create(\"segment\",[p,y],w),y.Value=function(){var t=this._smax-this._smin;return-1===y.visProp.snapwidth?this.position*t+this._smin:Math.round((this.position*t+this._smin)/this.visProp.snapwidth)*this.visProp.snapwidth},y.methodMap=r.deepCopy(y.methodMap,{Value:\"Value\",smax:\"_smax\",smin:\"_smin\"}),y._smax=d,y._smin=l,S&&(w=r.copyAttributes(n,t.options,\"slider\",\"label\"),_=t.create(\"text\",[function(){return.05*(f.X()-p.X())+f.X()},function(){return.05*(f.Y()-p.Y())+f.Y()},function(){var t;return t=y.name&&\"\"!==y.name?y.name+\" = \":\"\",t+y.Value().toFixed(T)}],w),y.label=_,y.visProp.withlabel=!0,y.hasLabel=!0),y.point1=p,y.point2=f,y.baseline=m,y.highline=P,E&&(y.ticks=g),y.remove=function(){S&&t.removeObject(_),t.removeObject(P),t.removeObject(m),t.removeObject(f),t.removeObject(p),s.Point.prototype.remove.call(y)},p.dump=!1,f.dump=!1,m.dump=!1,P.dump=!1,y.elType=\"slider\",y.parents=o,y.subs={point1:p,point2:f,baseLine:m,highLine:P},E&&(g.dump=!1,y.subs.ticks=g),y},t.registerElement(\"slider\",t.createSlider),{createSlider:t.createSlider}}),define(\"element/measure\",[\"jxg\",\"utils/type\",\"base/element\",\"base/point\",\"base/line\",\"base/ticks\"],function(t,e,i){return t.createTapemeasure=function(r,s,o){var n,a,h,l,c,d,u,p,f,m,b;return n=s[0],a=s[1],h=e.copyAttributes(o,r.options,\"tapemeasure\"),l=h.withticks,c=h.withlabel,d=h.precision,h=e.copyAttributes(o,r.options,\"tapemeasure\",\"point1\"),p=r.create(\"point\",n,h),h=e.copyAttributes(o,r.options,\"tapemeasure\",\"point2\"),f=r.create(\"point\",a,h),h=e.copyAttributes(o,r.options,\"tapemeasure\"),c&&(h.withlabel=!0),u=r.create(\"segment\",[p,f],h),c&&(m=o.name&&\"\"!==o.name?o.name+\" = \":\"\",u.label.setText(function(){return m+p.Dist(f).toFixed(d)})),l&&(h=e.copyAttributes(o,r.options,\"tapemeasure\",\"ticks\"),b=r.create(\"ticks\",[u,.1],h)),u.remove=function(){l&&u.removeTicks(b),r.removeObject(f),r.removeObject(p),i.prototype.remove.call(this)},u.Value=function(){return p.Dist(f)},p.dump=!1,f.dump=!1,u.elType=\"tapemeasure\",u.parents=s,u.subs={point1:p,point2:f},l&&(b.dump=!1),u.methodMap=t.deepCopy(u.methodMap,{Value:\"Value\"}),u},t.registerElement(\"tapemeasure\",t.createTapemeasure),{createTapemeasure:t.createTapemeasure}}),define(\"parser/datasource\",[\"jxg\",\"utils/type\"],function(t,e){return t.DataSource=function(){return this.data=[],this.columnHeaders=[],this.rowHeaders=[],this},t.extend(t.DataSource.prototype,{loadFromArray:function(t,i,r){var s,o,n;if(e.isArray(i)&&(this.columnHeaders=i,i=!1),e.isArray(r)&&(this.rowHeaders=r,r=!1),this.data=[],i&&(this.columnHeaders=[]),r&&(this.rowHeaders=[]),e.exists(t)){for(this.data=[],s=0;s<t.length;s++)for(this.data[s]=[],o=0;o<t[s].length;o++)n=t[s][o],this.data[s][o]=parseFloat(n).toString()===n?parseFloat(n):\"-\"!==n?n:0/0;if(i&&(this.columnHeaders=this.data[0].slice(1),this.data=this.data.slice(1)),r)for(this.rowHeaders=[],s=0;s<this.data.length;s++)this.rowHeaders.push(this.data[s][0]),this.data[s]=this.data[s].slice(1)}return this},loadFromTable:function(t,i,r){var s,o,n,a,h;if(e.isArray(i)&&(this.columnHeaders=i,i=!1),e.isArray(r)&&(this.rowHeaders=r,r=!1),this.data=[],i&&(this.columnHeaders=[]),r&&(this.rowHeaders=[]),t=document.getElementById(t),e.exists(t)){for(s=t.getElementsByTagName(\"tr\"),this.data=[],o=0;o<s.length;o++)for(a=s[o].getElementsByTagName(\"td\"),this.data[o]=[],n=0;n<a.length;n++)h=a[n].innerHTML,this.data[o][n]=parseFloat(h).toString()===h?parseFloat(h):\"-\"!==h?h:0/0;if(i&&(this.columnHeaders=this.data[0].slice(1),this.data=this.data.slice(1)),r)for(this.rowHeaders=[],o=0;o<this.data.length;o++)this.rowHeaders.push(this.data[o][0]),this.data[o]=this.data[o].slice(1)}return this},addColumn:function(){throw new Error(\"not implemented\")},addRow:function(){throw new Error(\"not implemented\")},getColumn:function(t){var e,i=[];if(\"string\"==typeof t)for(e=0;e<this.columnHeaders.length;e++)if(t===this.columnHeaders[e]){t=e;break}for(e=0;e<this.data.length;e++)this.data[e].length>t&&(i[e]=parseFloat(this.data[e][t]));return i},getRow:function(t){var e,i;if(\"string\"==typeof t)for(i=0;i<this.rowHeaders.length;i++)if(t===this.rowHeaders[i]){t=i;break}for(e=[],i=0;i<this.data[t].length;i++)e[i]=this.data[t][i];return e}}),t.DataSource}),define(\"base/chart\",[\"jxg\",\"math/numerics\",\"math/statistics\",\"base/constants\",\"base/coords\",\"base/element\",\"parser/datasource\",\"utils/color\",\"utils/type\",\"utils/env\",\"base/curve\",\"base/point\",\"base/text\",\"base/polygon\",\"element/sector\",\"base/transformation\",\"base/line\",\"base/circle\"],function(t,e,i,r,s,o,n,a,h,l){return t.Chart=function(t,e,i){this.constructor(t,i);var r,s,o,n,a,l;if(!h.isArray(e)||0===e.length)throw new Error(\"JSXGraph: Can't create a chart without data\");if(this.elements=[],h.isNumber(e[0]))for(s=e,r=[],o=0;o<s.length;o++)r[o]=o+1;else if(1===e.length&&h.isArray(e[0]))for(s=e[0],r=[],l=h.evaluate(s).length,o=0;l>o;o++)r[o]=o+1;else 2===e.length&&(l=Math.min(e[0].length,e[1].length),r=e[0].slice(0,l),s=e[1].slice(0,l));if(h.isArray(s)&&0===s.length)throw new Error(\"JSXGraph: Can't create charts without data.\");for(a=i.chartstyle.replace(/ /g,\"\").split(\",\"),o=0;o<a.length;o++){switch(a[o]){case\"bar\":n=this.drawBar(t,r,s,i);break;case\"line\":n=this.drawLine(t,r,s,i);break;case\"fit\":n=this.drawFit(t,r,s,i);break;case\"spline\":n=this.drawSpline(t,r,s,i);break;case\"pie\":n=this.drawPie(t,s,i);break;case\"point\":n=this.drawPoints(t,r,s,i);break;case\"radar\":n=this.drawRadar(t,e,i)}this.elements.push(n)}return this.id=this.board.setId(this,\"Chart\"),this.elements},t.Chart.prototype=new o,t.extend(t.Chart.prototype,{drawLine:function(t,e,i,r){return r.fillcolor=\"none\",r.highlightfillcolor=\"none\",t.create(\"curve\",[e,i],r)},drawSpline:function(t,e,i,r){return r.fillColor=\"none\",r.highlightfillcolor=\"none\",t.create(\"spline\",[e,i],r)},drawFit:function(t,i,r,s){var o=s.degree;return o=Math.max(parseInt(o,10),1)||1,s.fillcolor=\"none\",s.highlightfillcolor=\"none\",t.create(\"functiongraph\",[e.regressionPolynomial(o,i,r)],s)},drawBar:function(t,e,i,r){var s,o,n,a,l,c,d,u,p,f,m,b,g=[],v=[],C=function(t,i){return function(){return e[t]()-i*c}},y={fixed:!0,withLabel:!1,visible:!1,name:\"\"};if(h.exists(r.fillopacity)||(r.fillopacity=.6),r&&r.width)c=r.width;else{if(e.length<=1)c=1;else for(c=e[1]-e[0],s=1;s<e.length-1;s++)c=e[s+1]-e[s]<c?e[s+1]-e[s]:c;c*=.8}for(n=r.fillcolor,b=h.copyAttributes(r,t.options,\"chart\",\"label\"),a=parseFloat(b.fontsize),s=0;s<e.length;s++)h.isFunction(e[s])?(d=C(s,-.5),u=C(s,0),p=C(s,.5)):(d=e[s]-.5*c,u=e[s],p=e[s]+.5*c),f=i[s],\"horizontal\"===r.dir?(v[0]=t.create(\"point\",[0,d],y),v[1]=t.create(\"point\",[f,d],y),v[2]=t.create(\"point\",[f,p],y),v[3]=t.create(\"point\",[0,p],y),h.exists(r.labels)&&h.exists(r.labels[s])&&(o=r.labels[s].toString().length,o=2*o*a/t.unitX,f>=0?f+=.5*a/t.unitX:f-=a*o/t.unitX,u-=.2*a/t.unitY,l=t.create(\"text\",[f,u,r.labels[s]].toString(),b))):(v[0]=t.create(\"point\",[d,0],y),v[1]=t.create(\"point\",[d,f],y),v[2]=t.create(\"point\",[p,f],y),v[3]=t.create(\"point\",[p,0],y),h.exists(r.labels)&&h.exists(r.labels[s])&&(o=r.labels[s].toString().length,o=.6*o*a/t.unitX,f>=0?f+=.5*a/t.unitY:f-=a/t.unitY,l=t.create(\"text\",[u-.5*o,f,r.labels[s].toString()],b))),r.withlines=!1,h.isArray(r.colors)&&(m=r.colors,r.fillcolor=m[s%m.length]),g[s]=t.create(\"polygon\",v,r),h.exists(r.labels)&&h.exists(r.labels[s])&&(g[s].text=l);return g},drawPoints:function(t,e,i,r){var s,o=[],n=r.infoboxarray;for(r.fixed=!0,r.name=\"\",s=0;s<e.length;s++)r.infoboxtext=n?n[s%n.length]:!1,o[s]=t.create(\"point\",[e[s],i[s]],r);return o},drawPie:function(t,e,o){var n,a,l=[],c=[],d=(i.sum(e),o.colors),u=o.highlightcolors,p=o.labels,f=o.radius||4,m=f,b=o.center||[0,0],g=b[0],v=b[1],C=function(t,i,r){return function(){var s,o,n,a=0;for(o=0;t>=o;o++)a+=parseFloat(h.evaluate(e[o]));for(s=a,o=t+1;o<e.length;o++)s+=parseFloat(h.evaluate(e[o]));return n=0!==s?2*Math.PI*a/s:0,m()*Math[i](n)+r}},y=function(t,e){var i=-this.point1.coords.usrCoords[1]+this.point2.coords.usrCoords[1],o=-this.point1.coords.usrCoords[2]+this.point2.coords.usrCoords[2];h.exists(this.label)&&(this.label.rendNode.style.fontSize=e*this.label.visProp.fontsize+\"px\",this.label.prepareUpdate().update().updateRenderer()),this.point2.coords=new s(r.COORDS_BY_USER,[this.point1.coords.usrCoords[1]+i*t,this.point1.coords.usrCoords[2]+o*t],this.board),this.prepareUpdate().update().updateRenderer()},P=function(){this.highlighted||(this.highlighted=!0,this.board.highlightedObjects[this.id]=this,this.board.renderer.highlight(this),y.call(this,1.1,2))},_=function(){this.highlighted&&(this.highlighted=!1,this.board.renderer.noHighlight(this),y.call(this,.9090909,1))},S={fixed:!0,withLabel:!1,visible:!1,name:\"\"};if(!h.isArray(p))for(p=[],n=0;n<e.length;n++)p[n]=\"\";for(h.isFunction(f)||(m=function(){return f}),o.highlightonsector=o.highlightonsector||!1,o.straightfirst=!1,o.straightlast=!1,a=t.create(\"point\",[g,v],S),l[0]=t.create(\"point\",[function(){return m()+g},function(){return v}],S),n=0;n<e.length;n++)l[n+1]=t.create(\"point\",[C(n,\"cos\",g),C(n,\"sin\",v)],S),o.name=p[n],o.withlabel=\"\"!==o.name,o.fillcolor=d&&d[n%d.length],o.labelcolor=d&&d[n%d.length],o.highlightfillcolor=u&&u[n%u.length],c[n]=t.create(\"sector\",[a,l[n],l[n+1]],o),o.highlightonsector&&(c[n].hasPoint=c[n].hasPointSector),o.highlightbysize&&(c[n].highlight=P,c[n].noHighlight=_);return{sectors:c,points:l,midpoint:a}},drawRadar:function(e,i,o){var n,a,l,c,d,u,p,f,m,b,g,v,C,y,P,_,S,E,O,w,T,x,A,M,N,k,R,L,B,Y,j,D,I,X,J,U,G,F,z,$,H,V,q,W,Z,Q=i.length,K=function(){var t,e,i,o,n=this.visProp.label.offset.slice(0);return t=this.point1.X(),e=this.point2.X(),i=this.point1.Y(),o=this.point2.Y(),t>e&&(n[0]=-n[0]),i>o&&(n[1]=-n[1]),this.setLabelRelativeCoords(n),new s(r.COORDS_BY_USER,[this.point2.X(),this.point2.Y()],this.board)},te=function(t,i){var r,s,o;return r=e.create(\"transform\",[-(P[i]-C[i]),0],{type:\"translate\"}),s=e.create(\"transform\",[w/(_[i]+y[i]-(P[i]-C[i])),1],{type:\"scale\"}),r.melt(s),o=e.create(\"transform\",[t],{type:\"rotate\"}),r.melt(o),r};if(0>=Q)return t.debug(\"No data\"),void 0;if(l=o.paramarray,!h.exists(l))return t.debug(\"Need paramArray attribute\"),void 0;if(c=l.length,1>=c)return t.debug(\"Need more than 1 param\"),void 0;for(n=0;Q>n;n++)if(c!==i[n].length)return t.debug(\"Use data length equal to number of params (\"+i[n].length+\" != \"+c+\")\"),void 0;for(d=[],u=[],a=0;c>a;a++)d[a]=i[0][a],u[a]=d[a];for(n=1;Q>n;n++)for(a=0;c>a;a++)i[n][a]>d[a]&&(d[a]=i[n][a]),i[n][a]<u[a]&&(u[a]=i[n][a]);for(p=[],f=[],n=0;Q>n;n++)p[n]=\"\",f[n]=[];for(m=[],b=[],g=o.startshiftratio||0,v=o.endshiftratio||0,n=0;c>n;n++)m[n]=(d[n]-u[n])*g,b[n]=(d[n]-u[n])*v;if(C=o.startshiftarray||m,y=o.endshiftarray||b,P=o.startarray||u,h.exists(o.start))for(n=0;c>n;n++)P[n]=o.start;if(_=o.endarray||d,h.exists(o.end))for(n=0;c>n;n++)_[n]=o.end;if(C.length!==c)return t.debug(\"Start shifts length is not equal to number of parameters\"),void 0;if(y.length!==c)return t.debug(\"End shifts length is not equal to number of parameters\"),void 0;if(P.length!==c)return t.debug(\"Starts length is not equal to number of parameters\"),void 0;if(_.length!==c)return t.debug(\"Ends length is not equal to number of parameters\"),void 0;for(S=o.labelarray||p,E=o.colors,O=o.highlightcolors,w=o.radius||10,W=o.strokewidth||1,h.exists(o.highlightonsector)||(o.highlightonsector=!1),T={name:o.name,id:o.id,strokewidth:W,polystrokewidth:o.polystrokewidth||W,strokecolor:o.strokecolor||\"black\",straightfirst:!1,straightlast:!1,fillcolor:o.fillColor||\"#FFFF88\",fillopacity:o.fillOpacity||.4,highlightfillcolor:o.highlightFillColor||\"#FF7400\",highlightstrokecolor:o.highlightStrokeColor||\"black\",gradient:o.gradient||\"none\"},x=o.center||[0,0],A=x[0],M=x[1],N=e.create(\"point\",[A,M],{name:\"\",fixed:!0,withlabel:!1,visible:!1}),k=Math.PI/2-Math.PI/c,k=o.startangle||0,R=k,L=[],B=[],n=0;c>n;n++)for(R+=2*Math.PI/c,j=w*Math.cos(R)+A,D=w*Math.sin(R)+M,L[n]=e.create(\"point\",[j,D],{name:\"\",fixed:!0,withlabel:!1,visible:!1}),B[n]=e.create(\"line\",[N,L[n]],{name:l[n],strokeColor:T.strokecolor,strokeWidth:T.strokewidth,strokeOpacity:1,straightFirst:!1,straightLast:!1,withLabel:!0,highlightStrokeColor:T.highlightstrokecolor}),B[n].getLabelAnchor=K,Y=te(R,n),a=0;a<i.length;a++)Z=i[a][n],f[a][n]=e.create(\"point\",[Z,0],{name:\"\",fixed:!0,withlabel:!1,visible:!1}),f[a][n].addTransform(f[a][n],Y);for(I=[],n=0;Q>n;n++)for(T.labelcolor=E&&E[n%E.length],T.strokecolor=E&&E[n%E.length],T.fillcolor=E&&E[n%E.length],I[n]=e.create(\"polygon\",f[n],{withLines:!0,withLabel:!1,fillColor:T.fillcolor,fillOpacity:T.fillopacity,highlightFillColor:T.highlightfillcolor}),a=0;c>a;a++)I[n].borders[a].setAttribute(\"strokecolor:\"+E[n%E.length]),I[n].borders[a].setAttribute(\"strokewidth:\"+T.polystrokewidth);switch(X=o.legendposition||\"none\"){case\"right\":U=o.legendleftoffset||2,G=o.legendtopoffset||1,this.legend=e.create(\"legend\",[A+w+U,M+w-G],{labels:S,colors:E});break;case\"none\":break;default:t.debug(\"Unknown legend position\")}if(J=[],o.showcircles){for(F=[],n=0;6>n;n++)F[n]=20*n;if(F[0]=\"0\",z=o.circlelabelarray||F,$=z.length,2>$)return t.debug(\"Too less circles\"),void 0;for(H=[],V=k+Math.PI/c,Y=te(V,0),T.fillcolor=\"none\",T.highlightfillcolor=\"none\",T.strokecolor=o.strokecolor||\"black\",T.strokewidth=o.circlestrokewidth||.5,T.layer=0,q=(_[0]-P[0])/($-1),n=0;$>n;n++)H[n]=e.create(\"point\",[P[0]+n*q,0],{name:z[n],size:0,fixed:!0,withLabel:!0,visible:!0}),H[n].addTransform(H[n],Y),J[n]=e.create(\"circle\",[N,H[n]],T)}return this.rendNode=I[0].rendNode,{circles:J,lines:B,points:f,midpoint:N,polygons:I}},updateRenderer:function(){return this},update:function(){return this.needsUpdate&&this.updateDataArray(),this},updateDataArray:function(){}}),t.createChart=function(e,i,r){var s,o,c,d,u,p,f,m,b,g,v,C,y,P,_,S,E=[],O=l.isBrowser?e.document.getElementById(i[0]):null;if(1===i.length&&\"string\"==typeof i[0]){if(h.exists(O)){if(b=h.copyAttributes(r,e.options,\"chart\"),O=(new n).loadFromTable(i[0],b.withheaders,b.withheaders),s=O.data,u=O.columnHeaders,o=O.rowHeaders,g=b.width,v=b.name,C=b.strokecolor,y=b.fillcolor,P=b.highlightstrokecolor,_=b.highlightfillcolor,e.suspendUpdate(),S=s.length,m=[],b.rows&&h.isArray(b.rows)){for(c=0;S>c;c++)for(d=0;d<b.rows.length;d++)if(b.rows[d]===c||b.withheaders&&b.rows[d]===o[c]){m.push(s[c]);break}}else m=s;for(S=m.length,c=0;S>c;c++){if(f=[],b.chartstyle&&-1!==b.chartstyle.indexOf(\"bar\")){for(p=g?g:.8,f.push(1-p/2+(c+.5)*p/S),d=1;d<m[c].length;d++)f.push(f[d-1]+1);b.width=p/S}v&&v.length===S?b.name=v[c]:b.withheaders&&(b.name=u[c]),b.strokecolor=C&&C.length===S?C[c]:a.hsv2rgb(360*((c+1)/S),.9,.6),b.fillcolor=y&&y.length===S?y[c]:a.hsv2rgb(360*((c+1)/S),.9,1),b.highlightstrokecolor=P&&P.length===S?P[c]:a.hsv2rgb(360*((c+1)/S),.9,1),b.highlightfillcolor=_&&_.length===S?_[c]:a.hsv2rgb(360*((c+1)/S),.9,.6),b.chartstyle&&-1!==b.chartstyle.indexOf(\"bar\")?E.push(new t.Chart(e,[f,m[c]],b)):E.push(new t.Chart(e,[m[c]],b))}e.unsuspendUpdate()}return E}return b=h.copyAttributes(r,e.options,\"chart\"),new t.Chart(e,i,b)},t.registerElement(\"chart\",t.createChart),t.Legend=function(t,e,i){var o;if(this.constructor(),o=h.copyAttributes(i,t.options,\"legend\"),this.board=t,this.coords=new s(r.COORDS_BY_USER,e,this.board),this.myAtts={},this.label_array=o.labelarray||o.labels,this.color_array=o.colorarray||o.colors,this.lines=[],this.myAtts.strokewidth=o.strokewidth||5,this.myAtts.straightfirst=!1,this.myAtts.straightlast=!1,this.myAtts.withlabel=!0,this.myAtts.fixed=!0,this.style=o.legendstyle||o.style,\"vertical\"!==this.style)throw new Error(\"JSXGraph: Unknown legend style: \"+this.style);\nthis.drawVerticalLegend(t,o)},t.Legend.prototype=new o,t.Legend.prototype.drawVerticalLegend=function(t,e){var i,o=e.linelength||1,n=(e.rowheight||20)/this.board.unitY,a=function(){return this.setLabelRelativeCoords(this.visProp.label.offset),new s(r.COORDS_BY_USER,[this.point2.X(),this.point2.Y()],this.board)};for(i=0;i<this.label_array.length;i++)this.myAtts.strokecolor=this.color_array[i],this.myAtts.highlightstrokecolor=this.color_array[i],this.myAtts.name=this.label_array[i],this.myAtts.label={offset:[10,0],strokeColor:this.color_array[i],strokeWidth:this.myAtts.strokewidth},this.lines[i]=t.create(\"line\",[[this.coords.usrCoords[1],this.coords.usrCoords[2]-i*n],[this.coords.usrCoords[1]+o,this.coords.usrCoords[2]-i*n]],this.myAtts),this.lines[i].getLabelAnchor=a},t.createLegend=function(e,i,r){var s=[0,0];return h.exists(i)&&2===i.length&&(s=i),new t.Legend(e,s,r)},t.registerElement(\"legend\",t.createLegend),{Chart:t.Chart,Legend:t.Legend,createChart:t.createChart,createLegend:t.createLegend}}),define(\"base/turtle\",[\"jxg\",\"base/constants\",\"base/element\",\"utils/type\",\"base/curve\",\"base/point\",\"base/line\",\"base/transformation\"],function(t,e,i,r){return t.Turtle=function(t,i,s){var o,n,a;return this.constructor(t,s,e.OBJECT_TYPE_TURTLE,e.OBJECT_CLASS_OTHER),this.turtleIsHidden=!1,this.board=t,this.visProp.curveType=\"plot\",this._attributes=r.copyAttributes(this.visProp,t.options,\"turtle\"),delete this._attributes.id,o=0,n=0,a=90,0!==i.length&&(3===i.length?(o=i[0],n=i[1],a=i[2]):2===i.length?r.isArray(i[0])?(o=i[0][0],n=i[0][1],a=i[1]):(o=i[0],n=i[1]):(o=i[0][0],n=i[0][1])),this.init(o,n,a),this.methodMap=r.deepCopy(this.methodMap,{forward:\"forward\",fd:\"forward\",back:\"back\",bk:\"back\",right:\"right\",rt:\"right\",left:\"left\",lt:\"left\",penUp:\"penUp\",pu:\"penUp\",penDown:\"penDown\",pd:\"penDown\",clearScreen:\"clearScreen\",cs:\"clearScreen\",clean:\"clean\",setPos:\"setPos\",home:\"home\",hideTurtle:\"hideTurtle\",ht:\"hideTurtle\",showTurtle:\"showTurtle\",st:\"showTurtle\",penSize:\"setPenSize\",penColor:\"setPenColor\",pushTurtle:\"pushTurtle\",push:\"pushTurtle\",popTurtle:\"popTurtle\",pop:\"popTurtle\",lookTo:\"lookTo\",pos:\"pos\",moveTo:\"moveTo\",X:\"X\",Y:\"Y\"}),this},t.Turtle.prototype=new i,t.extend(t.Turtle.prototype,{init:function(t,e,i){var r={fixed:!0,name:\"\",visible:!1,withLabel:!1};this.arrowLen=20/Math.sqrt(this.board.unitX*this.board.unitX+this.board.unitY*this.board.unitY),this.pos=[t,e],this.isPenDown=!0,this.dir=90,this.stack=[],this.objects=[],this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.turtle=this.board.create(\"point\",this.pos,r),this.objects.push(this.turtle),this.turtle2=this.board.create(\"point\",[this.pos[0],this.pos[1]+this.arrowLen],r),this.objects.push(this.turtle2),this.visProp.arrow.lastArrow=!0,this.visProp.arrow.straightFirst=!1,this.visProp.arrow.straightLast=!1,this.arrow=this.board.create(\"line\",[this.turtle,this.turtle2],this.visProp.arrow),this.objects.push(this.arrow),this.right(90-i),this.board.update()},forward:function(t){if(0===t)return this;var e,i=t*Math.cos(this.dir*Math.PI/180),r=t*Math.sin(this.dir*Math.PI/180);return this.turtleIsHidden||(e=this.board.create(\"transform\",[i,r],{type:\"translate\"}),e.applyOnce(this.turtle),e.applyOnce(this.turtle2)),this.isPenDown&&this.curve.dataX.length>=8192&&(this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve)),this.pos[0]+=i,this.pos[1]+=r,this.isPenDown&&(this.curve.dataX.push(this.pos[0]),this.curve.dataY.push(this.pos[1])),this.board.update(),this},back:function(t){return this.forward(-t)},right:function(t){if(this.dir-=t,this.dir%=360,!this.turtleIsHidden){var e=this.board.create(\"transform\",[-t*Math.PI/180,this.turtle],{type:\"rotate\"});e.applyOnce(this.turtle2)}return this.board.update(),this},left:function(t){return this.right(-t)},penUp:function(){return this.isPenDown=!1,this},penDown:function(){return this.isPenDown=!0,this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this},clean:function(){var t,i;for(t=0;t<this.objects.length;t++)i=this.objects[t],i.type===e.OBJECT_TYPE_CURVE&&(this.board.removeObject(i),this.objects.splice(t,1));return this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.board.update(),this},clearScreen:function(){var t,e,i=this.objects.length;for(t=0;i>t;t++)e=this.objects[t],this.board.removeObject(e);return this.init(0,0,90),this},setPos:function(t,i){var s;return this.pos=r.isArray(t)?t:[t,i],this.turtleIsHidden||(this.turtle.setPositionDirectly(e.COORDS_BY_USER,[t,i]),this.turtle2.setPositionDirectly(e.COORDS_BY_USER,[t,i+this.arrowLen]),s=this.board.create(\"transform\",[-(this.dir-90)*Math.PI/180,this.turtle],{type:\"rotate\"}),s.applyOnce(this.turtle2)),this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve),this.board.update(),this},setPenSize:function(t){return this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this.copyAttr(\"strokeWidth\",t)),this.objects.push(this.curve),this},setPenColor:function(t){return this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this.copyAttr(\"strokeColor\",t)),this.objects.push(this.curve),this},setHighlightPenColor:function(t){return this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this.copyAttr(\"highlightStrokeColor\",t)),this.objects.push(this.curve),this},setAttribute:function(t){var i,s,o,n=this.objects.length;for(i=0;n>i;i++)s=this.objects[i],s.type===e.OBJECT_TYPE_CURVE&&s.setAttribute(t);return o=this.visProp.id,this.visProp=r.deepCopy(this.curve.visProp),this.visProp.id=o,this._attributes=r.deepCopy(this.visProp),delete this._attributes.id,this},copyAttr:function(t,e){return this._attributes[t.toLowerCase()]=e,this._attributes},showTurtle:function(){return this.turtleIsHidden=!1,this.arrow.setAttribute({visible:!0}),this.visProp.arrow.visible=!1,this.setPos(this.pos[0],this.pos[1]),this.board.update(),this},hideTurtle:function(){return this.turtleIsHidden=!0,this.arrow.setAttribute({visible:!1}),this.visProp.arrow.visible=!1,this.board.update(),this},home:function(){return this.pos=[0,0],this.setPos(this.pos[0],this.pos[1]),this},pushTurtle:function(){return this.stack.push([this.pos[0],this.pos[1],this.dir]),this},popTurtle:function(){var t=this.stack.pop();return this.pos[0]=t[0],this.pos[1]=t[1],this.dir=t[2],this.setPos(this.pos[0],this.pos[1]),this},lookTo:function(t){var e,i,s,o,n;return r.isArray(t)?(e=this.pos[0],i=this.pos[1],s=t[0],o=t[1],n=Math.atan2(o-i,s-e),this.right(this.dir-180*n/Math.PI)):r.isNumber(t)&&this.right(this.dir-t),this},moveTo:function(t){var e,i,s;return r.isArray(t)&&(e=t[0]-this.pos[0],i=t[1]-this.pos[1],this.turtleIsHidden||(s=this.board.create(\"transform\",[e,i],{type:\"translate\"}),s.applyOnce(this.turtle),s.applyOnce(this.turtle2)),this.isPenDown&&this.curve.dataX.length>=8192&&(this.curve=this.board.create(\"curve\",[[this.pos[0]],[this.pos[1]]],this._attributes),this.objects.push(this.curve)),this.pos[0]=t[0],this.pos[1]=t[1],this.isPenDown&&(this.curve.dataX.push(this.pos[0]),this.curve.dataY.push(this.pos[1])),this.board.update()),this},fd:function(t){return this.forward(t)},bk:function(t){return this.back(t)},lt:function(t){return this.left(t)},rt:function(t){return this.right(t)},pu:function(){return this.penUp()},pd:function(){return this.penDown()},ht:function(){return this.hideTurtle()},st:function(){return this.showTurtle()},cs:function(){return this.clearScreen()},push:function(){return this.pushTurtle()},pop:function(){return this.popTurtle()},evalAt:function(t,i){var r,s,o,n,a=this.objects.length;for(r=0,s=0;a>r;r++)if(o=this.objects[r],o.elementClass===e.OBJECT_CLASS_CURVE){if(t>=s&&t<s+o.numberPoints)return n=t-s,o[i](n);s+=o.numberPoints}return this[i]()},X:function(t){return r.exists(t)?this.evalAt(t,\"X\"):this.pos[0]},Y:function(t){return r.exists(t)?this.evalAt(t,\"Y\"):this.pos[1]},Z:function(){return 1},minX:function(){return 0},maxX:function(){var t,i,r=this.objects.length,s=0;for(t=0;r>t;t++)i=this.objects[t],i.elementClass===e.OBJECT_CLASS_CURVE&&(s+=this.objects[t].numberPoints);return s},hasPoint:function(t,i){var r,s;for(r=0;r<this.objects.length;r++)if(s=this.objects[r],s.type===e.OBJECT_TYPE_CURVE&&s.hasPoint(t,i))return!0;return!1}}),t.createTurtle=function(e,i,s){var o;return i=i||[],o=r.copyAttributes(s,e.options,\"turtle\"),new t.Turtle(e,i,o)},t.registerElement(\"turtle\",t.createTurtle),{Turtle:t.Turtle,createTurtle:t.createTurtle}}),define(\"utils/dump\",[\"jxg\",\"utils/type\"],function(t,e){return t.Dump={addMarkers:function(t,i,r){var s,o,n;e.isArray(i)||(i=[i]),e.isArray(r)||(r=[r]),o=Math.min(i.length,r.length),i.length=o,r.length=o;for(s in t.objects)if(t.objects.hasOwnProperty(s))for(n=0;o>n;n++)t.objects[s][i[n]]=r[n]},deleteMarkers:function(t,i){var r,s,o;e.isArray(i)||(i=[i]),s=i.length,i.length=s;for(r in t.objects)if(t.objects.hasOwnProperty(r))for(o=0;s>o;o++)delete t.objects[r][i[o]]},str:function(t){return\"string\"==typeof t&&\"function\"!==t.substr(0,7)&&(t=\"'\"+t+\"'\"),t},minimizeObject:function(t){var i,r,s,o={},n=e.deepCopy(t),a=[];for(s=1;s<arguments.length;s++)a.push(arguments[s]);for(s=a.length;s>0;s--)o=e.deepCopy(o,a[s-1],!0);for(i in o)o.hasOwnProperty(i)&&(r=i.toLowerCase(),\"object\"!=typeof o[i]&&o[i]===n[r]&&delete n[r]);return n},prepareAttributes:function(e,i){var r,s;r=this.minimizeObject(i.getAttributes(),t.Options[i.elType]);for(s in i.subs)i.subs.hasOwnProperty(s)&&(r[s]=this.minimizeObject(i.subs[s].getAttributes(),t.Options[i.elType][s],t.Options[i.subs[s].elType]),r[s].id=i.subs[s].id,r[s].name=i.subs[s].name);return r.id=i.id,r.name=i.name,r},dump:function(t){var e,i,r,s,o=[],n=[],a=[],h=t.objectsList.length;for(this.addMarkers(t,\"dumped\",!1),n.push({obj:\"$board\",method:\"setBoundingBox\",params:[t.getBoundingBox(),!0]}),e=0;h>e;e++)if(i=t.objectsList[e],r={},!i.dumped&&i.dump){for(r.type=i.getType(),r.parents=i.getParents(),\"point\"===r.type&&1===r.parents[0]&&(r.parents=r.parents.slice(1)),s=0;s<r.parents.length;s++)\"string\"==typeof r.parents[s]&&(r.parents[s]=\"'\"+r.parents[s]+\"'\");r.attributes=this.prepareAttributes(t,i),\"glider\"===r.type&&i.onPolygon&&o.push({obj:i.id,prop:\"onPolygon\",val:!0}),a.push(r)}return this.deleteMarkers(t,\"dumped\"),{elements:a,props:o,methods:n}},arrayToParamStr:function(t,e){var i,r=[];for(i=0;i<t.length;i++)r.push(e.call(this,t[i]));return r.join(\", \")},toJSAN:function(t){var i,r,s;switch(typeof t){case\"object\":if(t){if(r=[],e.isArray(t)){for(i=0;i<t.length;i++)r.push(this.toJSAN(t[i]));return\"[\"+r.join(\",\")+\"]\"}for(s in t)t.hasOwnProperty(s)&&r.push(s+\": \"+this.toJSAN(t[s]));return\"<<\"+r.join(\", \")+\">> \"}return\"null\";case\"string\":return\"'\"+t.replace(/([\"'])/g,\"\\\\$1\")+\"'\";case\"number\":case\"boolean\":return t.toString();case\"null\":return\"null\"}},toJessie:function(t){var e,i,r=this.dump(t),s=[];for(i=r.elements,e=0;e<i.length;e++)i[e].attributes.name.length>0&&s.push(\"// \"+i[e].attributes.name),s.push(\"s\"+e+\" = \"+i[e].type+\"(\"+i[e].parents.join(\", \")+\") \"+this.toJSAN(i[e].attributes).replace(/\\n/,\"\\\\n\")+\";\"),s.push(\"\");for(e=0;e<r.methods.length;e++)s.push(r.methods[e].obj+\".\"+r.methods[e].method+\"(\"+this.arrayToParamStr(r.methods[e].params,this.toJSAN)+\");\"),s.push(\"\");for(e=0;e<r.props.length;e++)s.push(r.props[e].obj+\".\"+r.props[e].prop+\" = \"+this.toJSAN(r.props[e].val)+\";\"),s.push(\"\");return s.join(\"\\n\")},toJavaScript:function(t){var i,r,s=this.dump(t),o=[];for(r=s.elements,i=0;i<r.length;i++)o.push('board.create(\"'+r[i].type+'\", ['+r[i].parents.join(\", \")+\"], \"+e.toJSON(r[i].attributes)+\");\");for(i=0;i<s.methods.length;i++)o.push(s.methods[i].obj+\".\"+s.methods[i].method+\"(\"+this.arrayToParamStr(s.methods[i].params,e.toJSON)+\");\"),o.push(\"\");for(i=0;i<s.props.length;i++)o.push(s.props[i].obj+\".\"+s.props[i].prop+\" = \"+e.toJSON(s.props[i].val)+\";\"),o.push(\"\");return o.join(\"\\n\")}},t.Dump}),define(\"element/slopetriangle\",[\"jxg\",\"options\",\"utils/type\",\"base/constants\",\"base/line\",\"base/polygon\",\"base/point\",\"base/element\"],function(t,e,i,r,s,o){var n={removeSlopeTriangle:function(){o.Polygon.prototype.remove.call(this),this.board.removeObject(this.toppoint),this.board.removeObject(this.glider),this.board.removeObject(this.baseline),this.board.removeObject(this.basepoint),this.board.removeObject(this.label)},Value:function(){return this.tangent.getSlope()}};return t.createSlopeTriangle=function(e,s,o){var a,h,l,c,d,u,p,f,m;if(1===s.length&&s[0].type===r.OBJECT_TYPE_TANGENT)h=s[0],l=h.glider;else{if(2!==s.length||s[0].elementClass!==r.OBJECT_CLASS_LINE||s[1].elementClass!==r.OBJECT_CLASS_POINT)throw new Error(\"JSXGraph: Can't create slope triangle with parent types '\"+typeof s[0]+\"'.\");h=s[0],l=s[1]}return m=i.copyAttributes(o,e.options,\"slopetriangle\",\"basepoint\"),p=e.create(\"point\",[function(){return[l.X()+1,l.Y()]}],m),m=i.copyAttributes(o,e.options,\"slopetriangle\",\"baseline\"),u=e.create(\"line\",[l,p],m),m=i.copyAttributes(o,e.options,\"slopetriangle\",\"glider\"),c=e.create(\"glider\",[l.X()+1,l.Y(),u],m),m=i.copyAttributes(o,e.options,\"slopetriangle\",\"toppoint\"),d=e.create(\"point\",[function(){return[c.X(),c.Y()+(c.X()-l.X())*h.getSlope()]}],m),m=i.copyAttributes(o,e.options,\"slopetriangle\"),a=e.create(\"polygon\",[l,c,d],m),a.Value=n.Value,a.tangent=h,m=i.copyAttributes(o,e.options,\"slopetriangle\",\"label\"),f=e.create(\"text\",[function(){return c.X()+.1},function(){return.5*(c.Y()+d.Y())},function(){return\"\"}],m),f._setText(function(){return a.Value().toFixed(f.visProp.digits)}),f.prepareUpdate().update().updateRenderer(),a.glider=c,a.basepoint=p,a.baseline=u,a.toppoint=d,a.label=f,a.methodMap=t.deepCopy(a.methodMap,{tangent:\"tangent\",glider:\"glider\",basepoint:\"basepoint\",baseline:\"baseline\",toppoint:\"toppoint\",label:\"label\",Value:\"Value\",V:\"Value\"}),a.remove=n.removeSlopeTriangle,a},t.registerElement(\"slopetriangle\",t.createSlopeTriangle),{createSlopeTriangle:t.createSlopeTriangle}}),define(\"../build/core.deps.js\",[\"jxg\",\"utils/env\",\"base/constants\",\"utils/type\",\"utils/xml\",\"utils/event\",\"utils/expect\",\"math/math\",\"math/qdt\",\"math/numerics\",\"math/statistics\",\"math/symbolic\",\"math/geometry\",\"math/poly\",\"math/complex\",\"renderer/abstract\",\"renderer/no\",\"reader/file\",\"parser/geonext\",\"base/board\",\"options\",\"jsxgraph\",\"base/element\",\"base/coords\",\"base/point\",\"base/line\",\"base/group\",\"base/circle\",\"element/conic\",\"base/polygon\",\"base/curve\",\"element/arc\",\"element/sector\",\"base/composition\",\"element/composition\",\"element/locus\",\"base/text\",\"base/image\",\"element/slider\",\"element/measure\",\"base/chart\",\"base/transformation\",\"base/turtle\",\"utils/color\",\"base/ticks\",\"utils/zip\",\"utils/base64\",\"utils/uuid\",\"utils/encoding\",\"server/server\",\"parser/datasource\",\"parser/jessiecode\",\"utils/dump\",\"renderer/svg\",\"renderer/vml\",\"renderer/canvas\",\"renderer/no\",\"element/slopetriangle\"],function(t,e){return e.isBrowser?window.JXG=t:e.isNode()&&\"object\"==typeof module?module.exports=t:e.isWebWorker()&&(self.JXG=t),t}),module.exports=require(\"../build/core.deps.js\")}();"
},
"$:/plugins/kpe/jsxgraph/jsxgraph.css": {
"type": "text/css",
"title": "$:/plugins/kpe/jsxgraph/jsxgraph.css",
"tags": "[[$:/tags/stylesheet]]",
"text": "/*\n Copyright 2008-2013\n Matthias Ehmann,\n Michael Gerhaeuser,\n Carsten Miller,\n Bianca Valentin,\n Alfred Wassermann,\n Peter Wilfahrt\n\n This file is part of JSXGraph.\n\n JSXGraph is free software dual licensed under the GNU LGPL or MIT License.\n\n You can redistribute it and/or modify it under the terms of the\n\n * GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version\n OR\n * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT\n\n JSXGraph is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License and\n the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>\n and <http://opensource.org/licenses/MIT/>.\n */\n\n.jxgbox {\n /* for IE 7 */\n position: relative;\n overflow: hidden;\n background-color: #ffffff;\n border-style: solid;\n border-width: 1px;\n border-color: #356AA0;\n border-radius: 10px;\n -webkit-border-radius: 10px;\n -ms-touch-action: none;\n}\n\n.JXGtext {\n /* May produce artefacts in IE. Solution: setting a color explicitly. */\n background-color: transparent;\n font-family: Arial, Helvetica, Geneva, sans-serif;\n padding: 0;\n margin: 0;\n}\n\n.JXGinfobox {\n border-style: none;\n border-width: 1px;\n border-color: black;\n}\n\n.JXGimage {\n opacity: 1.0;\n}\n\n.JXGimageHighlight {\n opacity: 0.6;\n}\n\n"
}
}
}
{
"tiddlers": {
"$:/core/modules/widgets/edit-text-codemirror.js": {
"text": "/*\\\ntitle: $:/core/modules/widgets/edit-text-codemirror.js\ntype: application/javascript\nmodule-type: widget\n\nExtend the edit-text widget to use CodeMirror\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar CODEMIRROR_OPTIONS = \"$:/config/CodeMirror\", configOptions;\n/*\ne.g. to allow vim key bindings\n {\n\t\"require\": [\n\t\t\"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js\",\n\t\t\"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js\",\n\t\t\"$:/plugins/tiddlywiki/codemirror/keymap/vim.js\"\n\t],\n\t\"configuration\": {\n\t\t\t\"keyMap\": \"vim\",\n\t\t\t\"showCursorWhenSelecting\": true\n\t}\n}\n*/\n\nvar EditTextWidget = require(\"$:/core/modules/widgets/edit-text.js\")[\"edit-text\"];\n\nif($tw.browser) {\n\twindow.CodeMirror = require(\"$:/plugins/tiddlywiki/codemirror/lib/codemirror.js\");\n\n\tconfigOptions = $tw.wiki.getTiddlerData(CODEMIRROR_OPTIONS,{});\n\n\tif(configOptions) {\n\t\tif(configOptions[\"require\"]) {\n\t\t\t\tif($tw.utils.isArray(configOptions[\"require\"])) {\n\t\t\t\t\tfor (var index=0; index < configOptions[\"require\"].length; index++) {\n\t\t\t\t\t\trequire(configOptions[\"require\"][index]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\trequire(configOptions[\"require\"]);\n\t\t\t\t}\n\t\t}\n\t\tEditTextWidget.configuration = configOptions[\"configuration\"];\n\t}\n}\n\n/*\nThe edit-text widget calls this method just after inserting its dom nodes\n*/\nEditTextWidget.prototype.postRender = function() {\n\tvar self = this,\n\t\tcm, config, cv, cm_opts = {\n\t\t\tlineWrapping: true,\n\t\t\tlineNumbers: true\n\t\t},\n\t\ttid = this.wiki.getTiddler(this.editTitle);\n\tif(tid && tid.fields.type) {\n\t\tcm_opts.mode = tid.fields.type\n\t};\n\n\tif($tw.browser && window.CodeMirror && this.editTag === \"textarea\") {\n\t\tif(EditTextWidget.configuration) {\n\t\t\tfor (cv in EditTextWidget.configuration) { cm_opts[cv] = EditTextWidget.configuration[cv]; }\n\t\t}\n\t\tcm = window.CodeMirror.fromTextArea(this.domNodes[0], cm_opts);\n\t\tcm.on(\"change\",function() {\n\t\t\tself.saveChanges(cm.getValue());\n\t\t});\n\t} else {\n\t\tcm = undefined;\n\t}\n\tthis.codemirrorInstance = cm;\n};\n\nEditTextWidget.prototype.updateEditor = function(text) {\n\t// Replace the edit value if the tiddler we're editing has changed\n\tif(this.codemirrorInstance) {\n\t\tif(!this.codemirrorInstance.hasFocus()) {\n\t\t\tthis.codemirrorInstance.setValue(text);\n\t\t}\n\t} else {\n\t\tthis.updateEditorDomNode(this.getEditInfo().value);\n\t}\n};\n\n})();\n",
"title": "$:/core/modules/widgets/edit-text-codemirror.js",
"type": "application/javascript",
"module-type": "widget"
},
"$:/plugins/tiddlywiki/codemirror/instructions": {
"title": "$:/plugins/tiddlywiki/codemirror/instructions",
"text": "! Configuration\n\n* You can configure the CodeMirror plugin by creating a tiddler called [[$:/config/CodeMirror]] containing a JSON configuration object.\n* The configuration tiddler needs to be `type: application/json`, to take effect.\n\nFor example:\n\n```\n{\n \"require\": [\n \"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js\",\n \"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js\",\n \"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js\",\n \"$:/plugins/tiddlywiki/codemirror/keymap/vim.js\",\n \"$:/plugins/tiddlywiki/codemirror/keymap/emacs.js\"\n ],\n \"configuration\": {\n \"keyMap\": \"vim\",\n \"showCursorWhenSelecting\": true\n }\n}\n```\n"
},
"$:/plugins/tiddlywiki/codemirror/lib/codemirror.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/lib/codemirror.js",
"module-type": "library",
"text": "// 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(mod) {\n if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n module.exports = mod();\n else if (typeof define == \"function\" && define.amd) // AMD\n return define([], mod);\n else // Plain browser env\n this.CodeMirror = mod();\n})(function() {\n \"use strict\";\n\n // BROWSER SNIFFING\n\n // Kludges for bugs and behavior differences that can't be feature\n // detected are enabled based on userAgent etc sniffing.\n\n var gecko = /gecko\\/\\d/i.test(navigator.userAgent);\n // ie_uptoN means Internet Explorer version N or lower\n var ie_upto10 = /MSIE \\d/.test(navigator.userAgent);\n var ie_upto7 = ie_upto10 && (document.documentMode == null || document.documentMode < 8);\n var ie_upto8 = ie_upto10 && (document.documentMode == null || document.documentMode < 9);\n var ie_upto9 = ie_upto10 && (document.documentMode == null || document.documentMode < 10);\n var ie_11up = /Trident\\/([7-9]|\\d{2,})\\./.test(navigator.userAgent);\n var ie = ie_upto10 || ie_11up;\n var webkit = /WebKit\\//.test(navigator.userAgent);\n var qtwebkit = webkit && /Qt\\/\\d+\\.\\d+/.test(navigator.userAgent);\n var chrome = /Chrome\\//.test(navigator.userAgent);\n var presto = /Opera\\//.test(navigator.userAgent);\n var safari = /Apple Computer/.test(navigator.vendor);\n var khtml = /KHTML\\//.test(navigator.userAgent);\n var mac_geMountainLion = /Mac OS X 1\\d\\D([8-9]|\\d\\d)\\D/.test(navigator.userAgent);\n var phantom = /PhantomJS/.test(navigator.userAgent);\n\n var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\\/\\w+/.test(navigator.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(navigator.userAgent);\n var mac = ios || /Mac/.test(navigator.platform);\n var windows = /win/i.test(navigator.platform);\n\n var presto_version = presto && navigator.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_upto8);\n\n // Optimize some code when these features are not used.\n var sawReadOnlySpans = false, sawCollapsedSpans = false;\n\n // EDITOR CONSTRUCTOR\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 if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);\n\n this.options = options = options || {};\n // Determine effective options based on given values and defaults.\n copyObj(defaults, options, false);\n setGuttersForLineNumbers(options);\n\n var doc = options.value;\n if (typeof doc == \"string\") doc = new Doc(doc, options.mode);\n this.doc = doc;\n\n var display = this.display = new Display(place, doc);\n display.wrapper.CodeMirror = this;\n updateGutters(this);\n themeChanged(this);\n if (options.lineWrapping)\n this.display.wrapper.className += \" CodeMirror-wrap\";\n if (options.autofocus && !mobile) focusInput(this);\n\n this.state = {\n keyMaps: [], // stores maps added by addKeyMap\n overlays: [], // highlighting overlays, as added by addOverlay\n modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info\n overwrite: false, focused: false,\n suppressEdits: false, // used to disable editing during key handlers when in readOnly mode\n pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput\n draggingText: false,\n highlight: new Delayed() // stores highlight worker timeout\n };\n\n // Override magic textarea content restore that IE sometimes does\n // on our hidden textarea on reload\n if (ie_upto10) setTimeout(bind(resetInput, this, true), 20);\n\n registerEventHandlers(this);\n ensureGlobalHandlers();\n\n var cm = this;\n runInOp(this, function() {\n cm.curOp.forceUpdate = true;\n attachDoc(cm, doc);\n\n if ((options.autofocus && !mobile) || activeElt() == display.input)\n setTimeout(bind(onFocus, cm), 20);\n else\n onBlur(cm);\n\n for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))\n optionHandlers[opt](cm, options[opt], Init);\n for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);\n });\n }\n\n // DISPLAY CONSTRUCTOR\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) {\n var d = this;\n\n // The semihidden textarea that is focused when the editor is\n // focused, and receives input.\n var input = d.input = elt(\"textarea\", null, null, \"position: absolute; padding: 0; width: 1px; height: 1em; outline: none\");\n // The textarea is kept positioned near the cursor to prevent the\n // fact that it'll be scrolled into view on input from scrolling\n // our fake cursor out of view. On webkit, when wrap=off, paste is\n // very slow. So make the area wide instead.\n if (webkit) input.style.width = \"1000px\";\n else input.setAttribute(\"wrap\", \"off\");\n // If border: 0; -- iOS fails to open keyboard (issue #1287)\n if (ios) input.style.border = \"1px solid black\";\n input.setAttribute(\"autocorrect\", \"off\"); input.setAttribute(\"autocapitalize\", \"off\"); input.setAttribute(\"spellcheck\", \"false\");\n\n // Wraps and hides input textarea\n d.inputDiv = elt(\"div\", [input], null, \"overflow: hidden; position: relative; width: 3px; height: 0px;\");\n // The fake scrollbar elements.\n d.scrollbarH = elt(\"div\", [elt(\"div\", null, null, \"height: 100%; min-height: 1px\")], \"CodeMirror-hscrollbar\");\n d.scrollbarV = elt(\"div\", [elt(\"div\", null, null, \"min-width: 1px\")], \"CodeMirror-vscrollbar\");\n // Covers bottom-right square when both scrollbars are present.\n d.scrollbarFiller = elt(\"div\", null, \"CodeMirror-scrollbar-filler\");\n // Covers bottom of gutter when coverGutterNextToScrollbar is on\n // and h scrollbar is present.\n d.gutterFiller = elt(\"div\", null, \"CodeMirror-gutter-filler\");\n // Will contain the actual code, positioned to cover the viewport.\n d.lineDiv = elt(\"div\", null, \"CodeMirror-code\");\n // Elements are added to these to represent selection and cursors.\n d.selectionDiv = elt(\"div\", null, null, \"position: relative; z-index: 1\");\n d.cursorDiv = elt(\"div\", null, \"CodeMirror-cursors\");\n // A visibility: hidden element used to find the size of things.\n d.measure = elt(\"div\", null, \"CodeMirror-measure\");\n // When lines outside of the viewport are measured, they are drawn in this.\n d.lineMeasure = elt(\"div\", null, \"CodeMirror-measure\");\n // Wraps everything that needs to exist inside the vertically-padded coordinate system\n d.lineSpace = elt(\"div\", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],\n null, \"position: relative; outline: none\");\n // Moved around its parent to cover visible view.\n d.mover = elt(\"div\", [elt(\"div\", [d.lineSpace], \"CodeMirror-lines\")], null, \"position: relative\");\n // Set to the height of the document, allowing scrolling.\n d.sizer = elt(\"div\", [d.mover], \"CodeMirror-sizer\");\n // Behavior of elts with overflow: auto and padding is\n // inconsistent across browsers. This is used to ensure the\n // scrollable area is big enough.\n d.heightForcer = elt(\"div\", null, null, \"position: absolute; height: \" + scrollerCutOff + \"px; width: 1px;\");\n // Will contain the gutters, if any.\n d.gutters = elt(\"div\", null, \"CodeMirror-gutters\");\n d.lineGutter = null;\n // Actual scrollable element.\n d.scroller = elt(\"div\", [d.sizer, d.heightForcer, d.gutters], \"CodeMirror-scroll\");\n d.scroller.setAttribute(\"tabIndex\", \"-1\");\n // The element in which the editor lives.\n d.wrapper = elt(\"div\", [d.inputDiv, d.scrollbarH, d.scrollbarV,\n d.scrollbarFiller, d.gutterFiller, d.scroller], \"CodeMirror\");\n\n // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)\n if (ie_upto7) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }\n // Needed to hide big blue blinking cursor on Mobile Safari\n if (ios) input.style.width = \"0px\";\n if (!webkit) d.scroller.draggable = true;\n // Needed to handle Tab key in KHTML\n if (khtml) { d.inputDiv.style.height = \"1px\"; d.inputDiv.style.position = \"absolute\"; }\n // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).\n if (ie_upto7) d.scrollbarH.style.minHeight = d.scrollbarV.style.minWidth = \"18px\";\n\n if (place.appendChild) place.appendChild(d.wrapper);\n else place(d.wrapper);\n\n // Current rendered range (may be bigger than the view window).\n d.viewFrom = d.viewTo = doc.first;\n // Information about the rendered lines.\n d.view = [];\n // Holds info about a single rendered line when it was rendered\n // for measurement, while not in view.\n d.externalMeasured = null;\n // Empty space (in pixels) above the view\n d.viewOffset = 0;\n d.lastSizeC = 0;\n d.updateLineNumbers = null;\n\n // Used to only resize the line number gutter when necessary (when\n // the amount of lines crosses a boundary that makes its width change)\n d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;\n // See readInput and resetInput\n d.prevInput = \"\";\n // Set to true when a non-horizontal-scrolling line widget is\n // added. As an optimization, line widget aligning is skipped when\n // this is false.\n d.alignWidgets = false;\n // Flag that indicates whether we expect input to appear real soon\n // now (after some event like 'keypress' or 'input') and are\n // polling intensively.\n d.pollingFast = false;\n // Self-resetting timeout for the poller\n d.poll = new Delayed();\n\n d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;\n\n // Tracks when resetInput has punted to just putting a short\n // string into the textarea instead of the full selection.\n d.inaccurateSelection = false;\n\n // Tracks the maximum line length so that the horizontal scrollbar\n // can be kept static when scrolling.\n d.maxLine = null;\n d.maxLineLength = 0;\n d.maxLineChanged = false;\n\n // Used for measuring wheel scrolling granularity\n d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;\n\n // True when shift is held down.\n d.shift = false;\n\n // Used to track whether anything happened since the context menu\n // was opened.\n d.selForContextMenu = null;\n }\n\n // STATE UPDATES\n\n // Used to get the editor into a consistent state again when options change.\n\n function loadMode(cm) {\n cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);\n resetModeState(cm);\n }\n\n function resetModeState(cm) {\n cm.doc.iter(function(line) {\n if (line.stateAfter) line.stateAfter = null;\n if (line.styles) line.styles = null;\n });\n cm.doc.frontier = cm.doc.first;\n startWorker(cm, 100);\n cm.state.modeGen++;\n if (cm.curOp) regChange(cm);\n }\n\n function wrappingChanged(cm) {\n if (cm.options.lineWrapping) {\n addClass(cm.display.wrapper, \"CodeMirror-wrap\");\n cm.display.sizer.style.minWidth = \"\";\n } else {\n rmClass(cm.display.wrapper, \"CodeMirror-wrap\");\n findMaxLine(cm);\n }\n estimateLineHeights(cm);\n regChange(cm);\n clearCaches(cm);\n setTimeout(function(){updateScrollbars(cm);}, 100);\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 var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;\n var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);\n return function(line) {\n if (lineIsHidden(cm.doc, line)) return 0;\n\n var widgetsHeight = 0;\n if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {\n if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;\n }\n\n if (wrapping)\n return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;\n else\n return widgetsHeight + th;\n };\n }\n\n function estimateLineHeights(cm) {\n var doc = cm.doc, est = estimateHeight(cm);\n doc.iter(function(line) {\n var estHeight = est(line);\n if (estHeight != line.height) updateLineHeight(line, estHeight);\n });\n }\n\n function keyMapChanged(cm) {\n var map = keyMap[cm.options.keyMap], style = map.style;\n cm.display.wrapper.className = cm.display.wrapper.className.replace(/\\s*cm-keymap-\\S+/g, \"\") +\n (style ? \" cm-keymap-\" + style : \"\");\n }\n\n function themeChanged(cm) {\n cm.display.wrapper.className = cm.display.wrapper.className.replace(/\\s*cm-s-\\S+/g, \"\") +\n cm.options.theme.replace(/(^|\\s)\\s*/g, \" cm-s-\");\n clearCaches(cm);\n }\n\n function guttersChanged(cm) {\n updateGutters(cm);\n regChange(cm);\n setTimeout(function(){alignHorizontally(cm);}, 20);\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 var gutters = cm.display.gutters, specs = cm.options.gutters;\n removeChildren(gutters);\n for (var i = 0; i < specs.length; ++i) {\n var gutterClass = specs[i];\n var gElt = gutters.appendChild(elt(\"div\", null, \"CodeMirror-gutter \" + gutterClass));\n if (gutterClass == \"CodeMirror-linenumbers\") {\n cm.display.lineGutter = gElt;\n gElt.style.width = (cm.display.lineNumWidth || 1) + \"px\";\n }\n }\n gutters.style.display = i ? \"\" : \"none\";\n updateGutterSpace(cm);\n }\n\n function updateGutterSpace(cm) {\n var width = cm.display.gutters.offsetWidth;\n cm.display.sizer.style.marginLeft = width + \"px\";\n cm.display.scrollbarH.style.left = cm.options.fixedGutter ? width + \"px\" : 0;\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 if (line.height == 0) return 0;\n var len = line.text.length, merged, cur = line;\n while (merged = collapsedSpanAtStart(cur)) {\n var found = merged.find(0, true);\n cur = found.from.line;\n len += found.from.ch - found.to.ch;\n }\n cur = line;\n while (merged = collapsedSpanAtEnd(cur)) {\n var found = merged.find(0, true);\n len -= cur.text.length - found.from.ch;\n cur = found.to.line;\n len += cur.text.length - found.to.ch;\n }\n return len;\n }\n\n // Find the longest line in the document.\n function findMaxLine(cm) {\n var d = cm.display, doc = cm.doc;\n d.maxLine = getLine(doc, doc.first);\n d.maxLineLength = lineLength(d.maxLine);\n d.maxLineChanged = true;\n doc.iter(function(line) {\n var len = lineLength(line);\n if (len > d.maxLineLength) {\n d.maxLineLength = len;\n d.maxLine = line;\n }\n });\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 var found = indexOf(options.gutters, \"CodeMirror-linenumbers\");\n if (found == -1 && options.lineNumbers) {\n options.gutters = options.gutters.concat([\"CodeMirror-linenumbers\"]);\n } else if (found > -1 && !options.lineNumbers) {\n options.gutters = options.gutters.slice(0);\n options.gutters.splice(found, 1);\n }\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 var scroll = cm.display.scroller;\n return {\n clientHeight: scroll.clientHeight,\n barHeight: cm.display.scrollbarV.clientHeight,\n scrollWidth: scroll.scrollWidth, clientWidth: scroll.clientWidth,\n barWidth: cm.display.scrollbarH.clientWidth,\n docHeight: Math.round(cm.doc.height + paddingVert(cm.display))\n };\n }\n\n // Re-synchronize the fake scrollbars with the actual size of the\n // content.\n function updateScrollbars(cm, measure) {\n if (!measure) measure = measureForScrollbars(cm);\n var d = cm.display;\n var scrollHeight = measure.docHeight + scrollerCutOff;\n var needsH = measure.scrollWidth > measure.clientWidth;\n var needsV = scrollHeight > measure.clientHeight;\n if (needsV) {\n d.scrollbarV.style.display = \"block\";\n d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + \"px\" : \"0\";\n // A bug in IE8 can cause this value to be negative, so guard it.\n d.scrollbarV.firstChild.style.height =\n Math.max(0, scrollHeight - measure.clientHeight + (measure.barHeight || d.scrollbarV.clientHeight)) + \"px\";\n } else {\n d.scrollbarV.style.display = \"\";\n d.scrollbarV.firstChild.style.height = \"0\";\n }\n if (needsH) {\n d.scrollbarH.style.display = \"block\";\n d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + \"px\" : \"0\";\n d.scrollbarH.firstChild.style.width =\n (measure.scrollWidth - measure.clientWidth + (measure.barWidth || d.scrollbarH.clientWidth)) + \"px\";\n } else {\n d.scrollbarH.style.display = \"\";\n d.scrollbarH.firstChild.style.width = \"0\";\n }\n if (needsH && needsV) {\n d.scrollbarFiller.style.display = \"block\";\n d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + \"px\";\n } else d.scrollbarFiller.style.display = \"\";\n if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {\n d.gutterFiller.style.display = \"block\";\n d.gutterFiller.style.height = scrollbarWidth(d.measure) + \"px\";\n d.gutterFiller.style.width = d.gutters.offsetWidth + \"px\";\n } else d.gutterFiller.style.display = \"\";\n\n if (!cm.state.checkedOverlayScrollbar && measure.clientHeight > 0) {\n if (scrollbarWidth(d.measure) === 0) {\n var w = mac && !mac_geMountainLion ? \"12px\" : \"18px\";\n d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = w;\n var barMouseDown = function(e) {\n if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)\n operation(cm, onMouseDown)(e);\n };\n on(d.scrollbarV, \"mousedown\", barMouseDown);\n on(d.scrollbarH, \"mousedown\", barMouseDown);\n }\n cm.state.checkedOverlayScrollbar = true;\n }\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 var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop;\n top = Math.floor(top - paddingTop(display));\n var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight;\n\n var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);\n // Ensure is a {from: {line, ch}, to: {line, ch}} object, and\n // forces those lines into the viewport (if possible).\n if (viewPort && viewPort.ensure) {\n var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line;\n if (ensureFrom < from)\n return {from: ensureFrom,\n to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)};\n if (Math.min(ensureTo, doc.lastLine()) >= to)\n return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight),\n to: ensureTo};\n }\n return {from: from, to: to};\n }\n\n // LINE NUMBERS\n\n // Re-align line numbers and gutter marks to compensate for\n // horizontal scrolling.\n function alignHorizontally(cm) {\n var display = cm.display, view = display.view;\n if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;\n var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;\n var gutterW = display.gutters.offsetWidth, left = comp + \"px\";\n for (var i = 0; i < view.length; i++) if (!view[i].hidden) {\n if (cm.options.fixedGutter && view[i].gutter)\n view[i].gutter.style.left = left;\n var align = view[i].alignable;\n if (align) for (var j = 0; j < align.length; j++)\n align[j].style.left = left;\n }\n if (cm.options.fixedGutter)\n 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 if (!cm.options.lineNumbers) return false;\n var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;\n if (last.length != display.lineNumChars) {\n var test = display.measure.appendChild(elt(\"div\", [elt(\"div\", last)],\n \"CodeMirror-linenumber CodeMirror-gutter-elt\"));\n var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;\n display.lineGutter.style.width = \"\";\n display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);\n display.lineNumWidth = display.lineNumInnerWidth + padding;\n display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;\n display.lineGutter.style.width = display.lineNumWidth + \"px\";\n updateGutterSpace(cm);\n return true;\n }\n return false;\n }\n\n function lineNumberFor(options, i) {\n return String(options.lineNumberFormatter(i + options.firstLineNumber));\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 return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;\n }\n\n // DISPLAY DRAWING\n\n // Updates the display, selection, and scrollbars, using the\n // information in display.view to find out which nodes are no longer\n // up-to-date. Tries to bail out early when no changes are needed,\n // unless forced is true.\n // Returns true if an actual update happened, false otherwise.\n function updateDisplay(cm, viewPort, forced) {\n var oldFrom = cm.display.viewFrom, oldTo = cm.display.viewTo, updated;\n var visible = visibleLines(cm.display, cm.doc, viewPort);\n for (var first = true;; first = false) {\n var oldWidth = cm.display.scroller.clientWidth;\n if (!updateDisplayInner(cm, visible, forced)) break;\n updated = true;\n\n // If the max line changed since it was last measured, measure it,\n // and ensure the document's width matches it.\n if (cm.display.maxLineChanged && !cm.options.lineWrapping)\n adjustContentWidth(cm);\n\n var barMeasure = measureForScrollbars(cm);\n updateSelection(cm);\n setDocumentHeight(cm, barMeasure);\n updateScrollbars(cm, barMeasure);\n if (webkit && cm.options.lineWrapping)\n checkForWebkitWidthBug(cm, barMeasure); // (Issue #2420)\n if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {\n forced = true;\n continue;\n }\n forced = false;\n\n // Clip forced viewport to actual scrollable area.\n if (viewPort && viewPort.top != null)\n viewPort = {top: Math.min(barMeasure.docHeight - scrollerCutOff - barMeasure.clientHeight, viewPort.top)};\n // Updated line heights might result in the drawn area not\n // actually covering the viewport. Keep looping until it does.\n visible = visibleLines(cm.display, cm.doc, viewPort);\n if (visible.from >= cm.display.viewFrom && visible.to <= cm.display.viewTo)\n break;\n }\n\n cm.display.updateLineNumbers = null;\n if (updated) {\n signalLater(cm, \"update\", cm);\n if (cm.display.viewFrom != oldFrom || cm.display.viewTo != oldTo)\n signalLater(cm, \"viewportChange\", cm, cm.display.viewFrom, cm.display.viewTo);\n }\n return updated;\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 updateDisplayInner(cm, visible, forced) {\n var display = cm.display, doc = cm.doc;\n if (!display.wrapper.offsetWidth) {\n resetView(cm);\n return;\n }\n\n // Bail out if the visible area is already rendered and nothing changed.\n if (!forced && visible.from >= display.viewFrom && visible.to <= display.viewTo &&\n countDirtyView(cm) == 0)\n return;\n\n if (maybeUpdateLineNumberWidth(cm))\n resetView(cm);\n var dims = getDimensions(cm);\n\n // Compute a suitable new viewport (from & to)\n var end = doc.first + doc.size;\n var from = Math.max(visible.from - cm.options.viewportMargin, doc.first);\n var to = Math.min(end, visible.to + cm.options.viewportMargin);\n if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);\n if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);\n if (sawCollapsedSpans) {\n from = visualLineNo(cm.doc, from);\n to = visualLineEndNo(cm.doc, to);\n }\n\n var different = from != display.viewFrom || to != display.viewTo ||\n display.lastSizeC != display.wrapper.clientHeight;\n adjustView(cm, from, to);\n\n display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));\n // Position the mover div to align with the current scroll position\n cm.display.mover.style.top = display.viewOffset + \"px\";\n\n var toUpdate = countDirtyView(cm);\n if (!different && toUpdate == 0 && !forced) return;\n\n // For big changes, we hide the enclosing element during the\n // update, since that speeds up the operations on most browsers.\n var focused = activeElt();\n if (toUpdate > 4) display.lineDiv.style.display = \"none\";\n patchDisplay(cm, display.updateLineNumbers, dims);\n if (toUpdate > 4) display.lineDiv.style.display = \"\";\n // There might have been a widget with a focused element that got\n // hidden or updated, if so re-focus it.\n if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();\n\n // Prevent selection and cursors from interfering with the scroll\n // width.\n removeChildren(display.cursorDiv);\n removeChildren(display.selectionDiv);\n\n if (different) {\n display.lastSizeC = display.wrapper.clientHeight;\n startWorker(cm, 400);\n }\n\n updateHeightsInViewport(cm);\n\n return true;\n }\n\n function adjustContentWidth(cm) {\n var display = cm.display;\n var width = measureChar(cm, display.maxLine, display.maxLine.text.length).left;\n display.maxLineChanged = false;\n var minWidth = Math.max(0, width + 3);\n var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + minWidth + scrollerCutOff - display.scroller.clientWidth);\n display.sizer.style.minWidth = minWidth + \"px\";\n if (maxScrollLeft < cm.doc.scrollLeft)\n setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true);\n }\n\n function setDocumentHeight(cm, measure) {\n cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = measure.docHeight + \"px\";\n cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + \"px\";\n }\n\n\n function checkForWebkitWidthBug(cm, measure) {\n // Work around Webkit bug where it sometimes reserves space for a\n // non-existing phantom scrollbar in the scroller (Issue #2420)\n if (cm.display.sizer.offsetWidth + cm.display.gutters.offsetWidth < cm.display.scroller.clientWidth - 1) {\n cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = \"0px\";\n cm.display.gutters.style.height = measure.docHeight + \"px\";\n }\n }\n\n // Read the actual heights of the rendered lines, and update their\n // stored heights to match.\n function updateHeightsInViewport(cm) {\n var display = cm.display;\n var prevBottom = display.lineDiv.offsetTop;\n for (var i = 0; i < display.view.length; i++) {\n var cur = display.view[i], height;\n if (cur.hidden) continue;\n if (ie_upto7) {\n var bot = cur.node.offsetTop + cur.node.offsetHeight;\n height = bot - prevBottom;\n prevBottom = bot;\n } else {\n var box = cur.node.getBoundingClientRect();\n height = box.bottom - box.top;\n }\n var diff = cur.line.height - height;\n if (height < 2) height = textHeight(display);\n if (diff > .001 || diff < -.001) {\n updateLineHeight(cur.line, height);\n updateWidgetHeight(cur.line);\n if (cur.rest) for (var j = 0; j < cur.rest.length; j++)\n updateWidgetHeight(cur.rest[j]);\n }\n }\n }\n\n // Read and store the height of line widgets associated with the\n // given line.\n function updateWidgetHeight(line) {\n if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)\n line.widgets[i].height = line.widgets[i].node.offsetHeight;\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 var d = cm.display, left = {}, width = {};\n for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {\n left[cm.options.gutters[i]] = n.offsetLeft;\n width[cm.options.gutters[i]] = n.offsetWidth;\n }\n return {fixedPos: compensateForHScroll(d),\n gutterTotalWidth: d.gutters.offsetWidth,\n gutterLeft: left,\n gutterWidth: width,\n wrapperWidth: d.wrapper.clientWidth};\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 var display = cm.display, lineNumbers = cm.options.lineNumbers;\n var container = display.lineDiv, cur = container.firstChild;\n\n function rm(node) {\n var next = node.nextSibling;\n // Works around a throw-scroll bug in OS X Webkit\n if (webkit && mac && cm.display.currentWheelTarget == node)\n node.style.display = \"none\";\n else\n node.parentNode.removeChild(node);\n return next;\n }\n\n var view = display.view, lineN = display.viewFrom;\n // Loop over the elements in the view, syncing cur (the DOM nodes\n // in display.lineDiv) with the view as we go.\n for (var i = 0; i < view.length; i++) {\n var lineView = view[i];\n if (lineView.hidden) {\n } else if (!lineView.node) { // Not drawn yet\n var node = buildLineElement(cm, lineView, lineN, dims);\n container.insertBefore(node, cur);\n } else { // Already drawn\n while (cur != lineView.node) cur = rm(cur);\n var updateNumber = lineNumbers && updateNumbersFrom != null &&\n updateNumbersFrom <= lineN && lineView.lineNumber;\n if (lineView.changes) {\n if (indexOf(lineView.changes, \"gutter\") > -1) updateNumber = false;\n updateLineForChanges(cm, lineView, lineN, dims);\n }\n if (updateNumber) {\n removeChildren(lineView.lineNumber);\n lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));\n }\n cur = lineView.node.nextSibling;\n }\n lineN += lineView.size;\n }\n while (cur) cur = rm(cur);\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 for (var j = 0; j < lineView.changes.length; j++) {\n var type = lineView.changes[j];\n if (type == \"text\") updateLineText(cm, lineView);\n else if (type == \"gutter\") updateLineGutter(cm, lineView, lineN, dims);\n else if (type == \"class\") updateLineClasses(lineView);\n else if (type == \"widget\") updateLineWidgets(lineView, dims);\n }\n lineView.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 if (lineView.node == lineView.text) {\n lineView.node = elt(\"div\", null, null, \"position: relative\");\n if (lineView.text.parentNode)\n lineView.text.parentNode.replaceChild(lineView.node, lineView.text);\n lineView.node.appendChild(lineView.text);\n if (ie_upto7) lineView.node.style.zIndex = 2;\n }\n return lineView.node;\n }\n\n function updateLineBackground(lineView) {\n var cls = lineView.bgClass ? lineView.bgClass + \" \" + (lineView.line.bgClass || \"\") : lineView.line.bgClass;\n if (cls) cls += \" CodeMirror-linebackground\";\n if (lineView.background) {\n if (cls) lineView.background.className = cls;\n else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }\n } else if (cls) {\n var wrap = ensureLineWrapped(lineView);\n lineView.background = wrap.insertBefore(elt(\"div\", null, cls), wrap.firstChild);\n }\n }\n\n // Wrapper around buildLineContent which will reuse the structure\n // in display.externalMeasured when possible.\n function getLineContent(cm, lineView) {\n var ext = cm.display.externalMeasured;\n if (ext && ext.line == lineView.line) {\n cm.display.externalMeasured = null;\n lineView.measure = ext.measure;\n return ext.built;\n }\n return 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 var cls = lineView.text.className;\n var built = getLineContent(cm, lineView);\n if (lineView.text == lineView.node) lineView.node = built.pre;\n lineView.text.parentNode.replaceChild(built.pre, lineView.text);\n lineView.text = built.pre;\n if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {\n lineView.bgClass = built.bgClass;\n lineView.textClass = built.textClass;\n updateLineClasses(lineView);\n } else if (cls) {\n lineView.text.className = cls;\n }\n }\n\n function updateLineClasses(lineView) {\n updateLineBackground(lineView);\n if (lineView.line.wrapClass)\n ensureLineWrapped(lineView).className = lineView.line.wrapClass;\n else if (lineView.node != lineView.text)\n lineView.node.className = \"\";\n var textClass = lineView.textClass ? lineView.textClass + \" \" + (lineView.line.textClass || \"\") : lineView.line.textClass;\n lineView.text.className = textClass || \"\";\n }\n\n function updateLineGutter(cm, lineView, lineN, dims) {\n if (lineView.gutter) {\n lineView.node.removeChild(lineView.gutter);\n lineView.gutter = null;\n }\n var markers = lineView.line.gutterMarkers;\n if (cm.options.lineNumbers || markers) {\n var wrap = ensureLineWrapped(lineView);\n var gutterWrap = lineView.gutter =\n wrap.insertBefore(elt(\"div\", null, \"CodeMirror-gutter-wrapper\", \"position: absolute; left: \" +\n (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + \"px\"),\n lineView.text);\n if (cm.options.lineNumbers && (!markers || !markers[\"CodeMirror-linenumbers\"]))\n lineView.lineNumber = gutterWrap.appendChild(\n elt(\"div\", lineNumberFor(cm.options, lineN),\n \"CodeMirror-linenumber CodeMirror-gutter-elt\",\n \"left: \" + dims.gutterLeft[\"CodeMirror-linenumbers\"] + \"px; width: \"\n + cm.display.lineNumInnerWidth + \"px\"));\n if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {\n var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];\n if (found)\n gutterWrap.appendChild(elt(\"div\", [found], \"CodeMirror-gutter-elt\", \"left: \" +\n dims.gutterLeft[id] + \"px; width: \" + dims.gutterWidth[id] + \"px\"));\n }\n }\n }\n\n function updateLineWidgets(lineView, dims) {\n if (lineView.alignable) lineView.alignable = null;\n for (var node = lineView.node.firstChild, next; node; node = next) {\n var next = node.nextSibling;\n if (node.className == \"CodeMirror-linewidget\")\n lineView.node.removeChild(node);\n }\n insertLineWidgets(lineView, dims);\n }\n\n // Build a line's DOM representation from scratch\n function buildLineElement(cm, lineView, lineN, dims) {\n var built = getLineContent(cm, lineView);\n lineView.text = lineView.node = built.pre;\n if (built.bgClass) lineView.bgClass = built.bgClass;\n if (built.textClass) lineView.textClass = built.textClass;\n\n updateLineClasses(lineView);\n updateLineGutter(cm, lineView, lineN, dims);\n insertLineWidgets(lineView, dims);\n return 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(lineView, dims) {\n insertLineWidgetsFor(lineView.line, lineView, dims, true);\n if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)\n insertLineWidgetsFor(lineView.rest[i], lineView, dims, false);\n }\n\n function insertLineWidgetsFor(line, lineView, dims, allowAbove) {\n if (!line.widgets) return;\n var wrap = ensureLineWrapped(lineView);\n for (var i = 0, ws = line.widgets; i < ws.length; ++i) {\n var widget = ws[i], node = elt(\"div\", [widget.node], \"CodeMirror-linewidget\");\n if (!widget.handleMouseEvents) node.ignoreEvents = true;\n positionLineWidget(widget, node, lineView, dims);\n if (allowAbove && widget.above)\n wrap.insertBefore(node, lineView.gutter || lineView.text);\n else\n wrap.appendChild(node);\n signalLater(widget, \"redraw\");\n }\n }\n\n function positionLineWidget(widget, node, lineView, dims) {\n if (widget.noHScroll) {\n (lineView.alignable || (lineView.alignable = [])).push(node);\n var width = dims.wrapperWidth;\n node.style.left = dims.fixedPos + \"px\";\n if (!widget.coverGutter) {\n width -= dims.gutterTotalWidth;\n node.style.paddingLeft = dims.gutterTotalWidth + \"px\";\n }\n node.style.width = width + \"px\";\n }\n if (widget.coverGutter) {\n node.style.zIndex = 5;\n node.style.position = \"relative\";\n if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + \"px\";\n }\n }\n\n // POSITION OBJECT\n\n // A Pos instance represents a position within the text.\n var Pos = CodeMirror.Pos = function(line, ch) {\n if (!(this instanceof Pos)) return new Pos(line, ch);\n this.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 var cmp = CodeMirror.cmpPos = function(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 // SELECTION / CURSOR\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 this.ranges = ranges;\n this.primIndex = primIndex;\n }\n\n Selection.prototype = {\n primary: function() { return this.ranges[this.primIndex]; },\n equals: function(other) {\n if (other == this) return true;\n if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;\n for (var i = 0; i < this.ranges.length; i++) {\n var here = this.ranges[i], there = other.ranges[i];\n if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;\n }\n return true;\n },\n deepCopy: function() {\n for (var out = [], i = 0; i < this.ranges.length; i++)\n out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));\n return new Selection(out, this.primIndex);\n },\n somethingSelected: function() {\n for (var i = 0; i < this.ranges.length; i++)\n if (!this.ranges[i].empty()) return true;\n return false;\n },\n contains: function(pos, end) {\n if (!end) end = pos;\n for (var i = 0; i < this.ranges.length; i++) {\n var range = this.ranges[i];\n if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)\n return i;\n }\n return -1;\n }\n };\n\n function Range(anchor, head) {\n this.anchor = anchor; this.head = head;\n }\n\n Range.prototype = {\n from: function() { return minPos(this.anchor, this.head); },\n to: function() { return maxPos(this.anchor, this.head); },\n empty: function() {\n return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;\n }\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 var prim = ranges[primIndex];\n ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });\n primIndex = indexOf(ranges, prim);\n for (var i = 1; i < ranges.length; i++) {\n var cur = ranges[i], prev = ranges[i - 1];\n if (cmp(prev.to(), cur.from()) >= 0) {\n var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());\n var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;\n if (i <= primIndex) --primIndex;\n ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));\n }\n }\n return new Selection(ranges, primIndex);\n }\n\n function simpleSelection(anchor, head) {\n return new Selection([new Range(anchor, head || anchor)], 0);\n }\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 if (pos.line < doc.first) return Pos(doc.first, 0);\n var last = doc.first + doc.size - 1;\n if (pos.line > last) return Pos(last, getLine(doc, last).text.length);\n return clipToLen(pos, getLine(doc, pos.line).text.length);\n }\n function clipToLen(pos, linelen) {\n var ch = pos.ch;\n if (ch == null || ch > linelen) return Pos(pos.line, linelen);\n else if (ch < 0) return Pos(pos.line, 0);\n else return pos;\n }\n function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}\n function clipPosArray(doc, array) {\n for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);\n return out;\n }\n\n // SELECTION UPDATES\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 if (doc.cm && doc.cm.display.shift || doc.extend) {\n var anchor = range.anchor;\n if (other) {\n var posBefore = cmp(head, anchor) < 0;\n if (posBefore != (cmp(other, anchor) < 0)) {\n anchor = head;\n head = other;\n } else if (posBefore != (cmp(head, other) < 0)) {\n head = other;\n }\n }\n return new Range(anchor, head);\n } else {\n return new Range(other || head, head);\n }\n }\n\n // Extend the primary selection range, discard the rest.\n function extendSelection(doc, head, other, options) {\n setSelection(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 for (var out = [], i = 0; i < doc.sel.ranges.length; i++)\n out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);\n var newSel = normalizeSelection(out, doc.sel.primIndex);\n setSelection(doc, newSel, options);\n }\n\n // Updates a single range in the selection.\n function replaceOneSelection(doc, i, range, options) {\n var ranges = doc.sel.ranges.slice(0);\n ranges[i] = range;\n setSelection(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 setSelection(doc, simpleSelection(anchor, head), options);\n }\n\n // Give beforeSelectionChange handlers a change to influence a\n // selection update.\n function filterSelectionChange(doc, sel) {\n var obj = {\n ranges: sel.ranges,\n update: function(ranges) {\n this.ranges = [];\n for (var i = 0; i < ranges.length; i++)\n this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),\n clipPos(doc, ranges[i].head));\n }\n };\n signal(doc, \"beforeSelectionChange\", doc, obj);\n if (doc.cm) signal(doc.cm, \"beforeSelectionChange\", doc.cm, obj);\n if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);\n else return sel;\n }\n\n function setSelectionReplaceHistory(doc, sel, options) {\n var done = doc.history.done, last = lst(done);\n if (last && last.ranges) {\n done[done.length - 1] = sel;\n setSelectionNoUndo(doc, sel, options);\n } else {\n setSelection(doc, sel, options);\n }\n }\n\n // Set a new selection.\n function setSelection(doc, sel, options) {\n setSelectionNoUndo(doc, sel, options);\n addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);\n }\n\n function setSelectionNoUndo(doc, sel, options) {\n if (hasHandler(doc, \"beforeSelectionChange\") || doc.cm && hasHandler(doc.cm, \"beforeSelectionChange\"))\n sel = filterSelectionChange(doc, sel);\n\n var bias = cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1;\n setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));\n\n if (!(options && options.scroll === false) && doc.cm)\n ensureCursorVisible(doc.cm);\n }\n\n function setSelectionInner(doc, sel) {\n if (sel.equals(doc.sel)) return;\n\n doc.sel = sel;\n\n if (doc.cm) {\n doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;\n signalCursorActivity(doc.cm);\n }\n signalLater(doc, \"cursorActivity\", doc);\n }\n\n // Verify that the selection does not partially select any atomic\n // marked ranges.\n function reCheckSelection(doc) {\n setSelectionInner(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 var out;\n for (var i = 0; i < sel.ranges.length; i++) {\n var range = sel.ranges[i];\n var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);\n var newHead = skipAtomic(doc, range.head, bias, mayClear);\n if (out || newAnchor != range.anchor || newHead != range.head) {\n if (!out) out = sel.ranges.slice(0, i);\n out[i] = new Range(newAnchor, newHead);\n }\n }\n return out ? normalizeSelection(out, sel.primIndex) : sel;\n }\n\n // Ensure a given position is not inside an atomic range.\n function skipAtomic(doc, pos, bias, mayClear) {\n var flipped = false, curPos = pos;\n var dir = bias || 1;\n doc.cantEdit = false;\n search: for (;;) {\n var line = getLine(doc, curPos.line);\n if (line.markedSpans) {\n for (var i = 0; i < line.markedSpans.length; ++i) {\n var sp = line.markedSpans[i], m = sp.marker;\n if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&\n (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {\n if (mayClear) {\n signal(m, \"beforeCursorEnter\");\n if (m.explicitlyCleared) {\n if (!line.markedSpans) break;\n else {--i; continue;}\n }\n }\n if (!m.atomic) continue;\n var newPos = m.find(dir < 0 ? -1 : 1);\n if (cmp(newPos, curPos) == 0) {\n newPos.ch += dir;\n if (newPos.ch < 0) {\n if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));\n else newPos = null;\n } else if (newPos.ch > line.text.length) {\n if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);\n else newPos = null;\n }\n if (!newPos) {\n if (flipped) {\n // Driven in a corner -- no valid cursor position found at all\n // -- try again *with* clearing, if we didn't already\n if (!mayClear) return skipAtomic(doc, pos, bias, true);\n // Otherwise, turn off editing until further notice, and return the start of the doc\n doc.cantEdit = true;\n return Pos(doc.first, 0);\n }\n flipped = true; newPos = pos; dir = -dir;\n }\n }\n curPos = newPos;\n continue search;\n }\n }\n }\n return curPos;\n }\n }\n\n // SELECTION DRAWING\n\n // Redraw the selection and/or cursor\n function updateSelection(cm) {\n var display = cm.display, doc = cm.doc;\n var curFragment = document.createDocumentFragment();\n var selFragment = document.createDocumentFragment();\n\n for (var i = 0; i < doc.sel.ranges.length; i++) {\n var range = doc.sel.ranges[i];\n var collapsed = range.empty();\n if (collapsed || cm.options.showCursorWhenSelecting)\n drawSelectionCursor(cm, range, curFragment);\n if (!collapsed)\n drawSelectionRange(cm, range, selFragment);\n }\n\n // Move the hidden textarea near the cursor to prevent scrolling artifacts\n if (cm.options.moveInputWithCursor) {\n var headPos = cursorCoords(cm, doc.sel.primary().head, \"div\");\n var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();\n var top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,\n headPos.top + lineOff.top - wrapOff.top));\n var left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,\n headPos.left + lineOff.left - wrapOff.left));\n display.inputDiv.style.top = top + \"px\";\n display.inputDiv.style.left = left + \"px\";\n }\n\n removeChildrenAndAdd(display.cursorDiv, curFragment);\n removeChildrenAndAdd(display.selectionDiv, selFragment);\n }\n\n // Draws a cursor for the given range\n function drawSelectionCursor(cm, range, output) {\n var pos = cursorCoords(cm, range.head, \"div\");\n\n var cursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor\"));\n cursor.style.left = pos.left + \"px\";\n cursor.style.top = pos.top + \"px\";\n cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + \"px\";\n\n if (pos.other) {\n // Secondary cursor, shown when on a 'jump' in bi-directional text\n var otherCursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor CodeMirror-secondarycursor\"));\n otherCursor.style.display = \"\";\n otherCursor.style.left = pos.other.left + \"px\";\n otherCursor.style.top = pos.other.top + \"px\";\n otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + \"px\";\n }\n }\n\n // Draws the given range as a highlighted selection\n function drawSelectionRange(cm, range, output) {\n var display = cm.display, doc = cm.doc;\n var fragment = document.createDocumentFragment();\n var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right;\n\n function add(left, top, width, bottom) {\n if (top < 0) top = 0;\n top = Math.round(top);\n bottom = Math.round(bottom);\n fragment.appendChild(elt(\"div\", null, \"CodeMirror-selected\", \"position: absolute; left: \" + left +\n \"px; top: \" + top + \"px; width: \" + (width == null ? rightSide - left : width) +\n \"px; height: \" + (bottom - top) + \"px\"));\n }\n\n function drawForLine(line, fromArg, toArg) {\n var lineObj = getLine(doc, line);\n var lineLen = lineObj.text.length;\n var start, end;\n function coords(ch, bias) {\n return charCoords(cm, Pos(line, ch), \"div\", lineObj, bias);\n }\n\n iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {\n var leftPos = coords(from, \"left\"), rightPos, left, right;\n if (from == to) {\n rightPos = leftPos;\n left = right = leftPos.left;\n } else {\n rightPos = coords(to - 1, \"right\");\n if (dir == \"rtl\") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }\n left = leftPos.left;\n right = rightPos.right;\n }\n if (fromArg == null && from == 0) left = leftSide;\n if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part\n add(left, leftPos.top, null, leftPos.bottom);\n left = leftSide;\n if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);\n }\n if (toArg == null && to == lineLen) right = rightSide;\n if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)\n start = leftPos;\n if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)\n end = rightPos;\n if (left < leftSide + 1) left = leftSide;\n add(left, rightPos.top, right - left, rightPos.bottom);\n });\n return {start: start, end: end};\n }\n\n var sFrom = range.from(), sTo = range.to();\n if (sFrom.line == sTo.line) {\n drawForLine(sFrom.line, sFrom.ch, sTo.ch);\n } else {\n var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);\n var singleVLine = visualLine(fromLine) == visualLine(toLine);\n var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;\n var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;\n if (singleVLine) {\n if (leftEnd.top < rightStart.top - 2) {\n add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);\n add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);\n } else {\n add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);\n }\n }\n if (leftEnd.bottom < rightStart.top)\n add(leftSide, leftEnd.bottom, null, rightStart.top);\n }\n\n output.appendChild(fragment);\n }\n\n // Cursor-blinking\n function restartBlink(cm) {\n if (!cm.state.focused) return;\n var display = cm.display;\n clearInterval(display.blinker);\n var on = true;\n display.cursorDiv.style.visibility = \"\";\n if (cm.options.cursorBlinkRate > 0)\n display.blinker = setInterval(function() {\n display.cursorDiv.style.visibility = (on = !on) ? \"\" : \"hidden\";\n }, cm.options.cursorBlinkRate);\n }\n\n // HIGHLIGHT WORKER\n\n function startWorker(cm, time) {\n if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)\n cm.state.highlight.set(time, bind(highlightWorker, cm));\n }\n\n function highlightWorker(cm) {\n var doc = cm.doc;\n if (doc.frontier < doc.first) doc.frontier = doc.first;\n if (doc.frontier >= cm.display.viewTo) return;\n var end = +new Date + cm.options.workTime;\n var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));\n\n runInOp(cm, function() {\n doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {\n if (doc.frontier >= cm.display.viewFrom) { // Visible\n var oldStyles = line.styles;\n var highlighted = highlightLine(cm, line, state, true);\n line.styles = highlighted.styles;\n if (highlighted.classes) line.styleClasses = highlighted.classes;\n else if (line.styleClasses) line.styleClasses = null;\n var ischange = !oldStyles || oldStyles.length != line.styles.length;\n for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];\n if (ischange) regLineChange(cm, doc.frontier, \"text\");\n line.stateAfter = copyState(doc.mode, state);\n } else {\n processLine(cm, line.text, state);\n line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;\n }\n ++doc.frontier;\n if (+new Date > end) {\n startWorker(cm, cm.options.workDelay);\n return true;\n }\n });\n });\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 var minindent, minline, doc = cm.doc;\n var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);\n for (var search = n; search > lim; --search) {\n if (search <= doc.first) return doc.first;\n var line = getLine(doc, search - 1);\n if (line.stateAfter && (!precise || search <= doc.frontier)) return search;\n var indented = countColumn(line.text, null, cm.options.tabSize);\n if (minline == null || minindent > indented) {\n minline = search - 1;\n minindent = indented;\n }\n }\n return minline;\n }\n\n function getStateBefore(cm, n, precise) {\n var doc = cm.doc, display = cm.display;\n if (!doc.mode.startState) return true;\n var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;\n if (!state) state = startState(doc.mode);\n else state = copyState(doc.mode, state);\n doc.iter(pos, n, function(line) {\n processLine(cm, line.text, state);\n var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;\n line.stateAfter = save ? copyState(doc.mode, state) : null;\n ++pos;\n });\n if (precise) doc.frontier = pos;\n return state;\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 if (display.cachedPaddingH) return display.cachedPaddingH;\n var e = removeChildrenAndAdd(display.measure, elt(\"pre\", \"x\"));\n var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;\n var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};\n if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;\n return data;\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 var wrapping = cm.options.lineWrapping;\n var curWidth = wrapping && cm.display.scroller.clientWidth;\n if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {\n var heights = lineView.measure.heights = [];\n if (wrapping) {\n lineView.measure.width = curWidth;\n var rects = lineView.text.firstChild.getClientRects();\n for (var i = 0; i < rects.length - 1; i++) {\n var cur = rects[i], next = rects[i + 1];\n if (Math.abs(cur.bottom - next.bottom) > 2)\n heights.push((cur.bottom + next.top) / 2 - rect.top);\n }\n }\n heights.push(rect.bottom - rect.top);\n }\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 if (lineView.line == line)\n return {map: lineView.measure.map, cache: lineView.measure.cache};\n for (var i = 0; i < lineView.rest.length; i++)\n if (lineView.rest[i] == line)\n return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};\n for (var i = 0; i < lineView.rest.length; i++)\n if (lineNo(lineView.rest[i]) > lineN)\n return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], 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 line = visualLine(line);\n var lineN = lineNo(line);\n var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);\n view.lineN = lineN;\n var built = view.built = buildLineContent(cm, view);\n view.text = built.pre;\n removeChildrenAndAdd(cm.display.lineMeasure, built.pre);\n return 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 return 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 if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n return cm.display.view[findViewIndex(cm, lineN)];\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n 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 var lineN = lineNo(line);\n var view = findViewForLine(cm, lineN);\n if (view && !view.text)\n view = null;\n else if (view && view.changes)\n updateLineForChanges(cm, view, lineN, getDimensions(cm));\n if (!view)\n view = updateExternalMeasurement(cm, line);\n\n var info = mapFromLineView(view, line, lineN);\n return {\n line: line, view: view, rect: null,\n map: info.map, cache: info.cache, before: info.before,\n hasHeights: false\n };\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) {\n if (prepared.before) ch = -1;\n var key = ch + (bias || \"\"), found;\n if (prepared.cache.hasOwnProperty(key)) {\n found = prepared.cache[key];\n } else {\n if (!prepared.rect)\n prepared.rect = prepared.view.text.getBoundingClientRect();\n if (!prepared.hasHeights) {\n ensureLineHeights(cm, prepared.view, prepared.rect);\n prepared.hasHeights = true;\n }\n found = measureCharInner(cm, prepared, ch, bias);\n if (!found.bogus) prepared.cache[key] = found;\n }\n return {left: found.left, right: found.right, top: found.top, bottom: found.bottom};\n }\n\n var nullRect = {left: 0, right: 0, top: 0, bottom: 0};\n\n function measureCharInner(cm, prepared, ch, bias) {\n var map = prepared.map;\n\n var node, start, end, collapse;\n // First, search the line map for the text node corresponding to,\n // or closest to, the target character.\n for (var i = 0; i < map.length; i += 3) {\n var mStart = map[i], mEnd = map[i + 1];\n if (ch < mStart) {\n start = 0; end = 1;\n collapse = \"left\";\n } else if (ch < mEnd) {\n start = ch - mStart;\n end = start + 1;\n } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {\n end = mEnd - mStart;\n start = end - 1;\n if (ch >= mEnd) collapse = \"right\";\n }\n if (start != null) {\n node = map[i + 2];\n if (mStart == mEnd && bias == (node.insertLeft ? \"left\" : \"right\"))\n collapse = bias;\n if (bias == \"left\" && start == 0)\n while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {\n node = map[(i -= 3) + 2];\n collapse = \"left\";\n }\n if (bias == \"right\" && start == mEnd - mStart)\n while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {\n node = map[(i += 3) + 2];\n collapse = \"right\";\n }\n break;\n }\n }\n\n var rect;\n if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.\n while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start;\n while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end;\n if (ie_upto8 && start == 0 && end == mEnd - mStart) {\n rect = node.parentNode.getBoundingClientRect();\n } else if (ie && cm.options.lineWrapping) {\n var rects = range(node, start, end).getClientRects();\n if (rects.length)\n rect = rects[bias == \"right\" ? rects.length - 1 : 0];\n else\n rect = nullRect;\n } else {\n rect = range(node, start, end).getBoundingClientRect() || nullRect;\n }\n } else { // If it is a widget, simply get the box for the whole widget.\n if (start > 0) collapse = bias = \"right\";\n var rects;\n if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)\n rect = rects[bias == \"right\" ? rects.length - 1 : 0];\n else\n rect = node.getBoundingClientRect();\n }\n if (ie_upto8 && !start && (!rect || !rect.left && !rect.right)) {\n var rSpan = node.parentNode.getClientRects()[0];\n if (rSpan)\n rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};\n else\n rect = nullRect;\n }\n\n var top, bot = (rect.bottom + rect.top) / 2 - prepared.rect.top;\n var heights = prepared.view.measure.heights;\n for (var i = 0; i < heights.length - 1; i++)\n if (bot < heights[i]) break;\n top = i ? heights[i - 1] : 0; bot = heights[i];\n var result = {left: (collapse == \"right\" ? rect.right : rect.left) - prepared.rect.left,\n right: (collapse == \"left\" ? rect.left : rect.right) - prepared.rect.left,\n top: top, bottom: bot};\n if (!rect.left && !rect.right) result.bogus = true;\n return result;\n }\n\n function clearLineMeasurementCacheFor(lineView) {\n if (lineView.measure) {\n lineView.measure.cache = {};\n lineView.measure.heights = null;\n if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)\n lineView.measure.caches[i] = {};\n }\n }\n\n function clearLineMeasurementCache(cm) {\n cm.display.externalMeasure = null;\n removeChildren(cm.display.lineMeasure);\n for (var i = 0; i < cm.display.view.length; i++)\n clearLineMeasurementCacheFor(cm.display.view[i]);\n }\n\n function clearCaches(cm) {\n clearLineMeasurementCache(cm);\n cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;\n if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;\n cm.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), or \"page\".\n function intoCoordSystem(cm, lineObj, rect, context) {\n if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {\n var size = widgetHeight(lineObj.widgets[i]);\n rect.top += size; rect.bottom += size;\n }\n if (context == \"line\") return rect;\n if (!context) context = \"local\";\n var yOff = heightAtLine(lineObj);\n if (context == \"local\") yOff += paddingTop(cm.display);\n else yOff -= cm.display.viewOffset;\n if (context == \"page\" || context == \"window\") {\n var lOff = cm.display.lineSpace.getBoundingClientRect();\n yOff += lOff.top + (context == \"window\" ? 0 : pageScrollY());\n var xOff = lOff.left + (context == \"window\" ? 0 : pageScrollX());\n rect.left += xOff; rect.right += xOff;\n }\n rect.top += yOff; rect.bottom += yOff;\n return 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 if (context == \"div\") return coords;\n var left = coords.left, top = coords.top;\n // First move into \"page\" coordinate system\n if (context == \"page\") {\n left -= pageScrollX();\n top -= pageScrollY();\n } else if (context == \"local\" || !context) {\n var localBox = cm.display.sizer.getBoundingClientRect();\n left += localBox.left;\n top += localBox.top;\n }\n\n var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();\n return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};\n }\n\n function charCoords(cm, pos, context, lineObj, bias) {\n if (!lineObj) lineObj = getLine(cm.doc, pos.line);\n return 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) {\n lineObj = lineObj || getLine(cm.doc, pos.line);\n if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);\n function get(ch, right) {\n var m = measureCharPrepared(cm, preparedMeasure, ch, right ? \"right\" : \"left\");\n if (right) m.left = m.right; else m.right = m.left;\n return intoCoordSystem(cm, lineObj, m, context);\n }\n function getBidi(ch, partPos) {\n var part = order[partPos], right = part.level % 2;\n if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {\n part = order[--partPos];\n ch = bidiRight(part) - (part.level % 2 ? 0 : 1);\n right = true;\n } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {\n part = order[++partPos];\n ch = bidiLeft(part) - part.level % 2;\n right = false;\n }\n if (right && ch == part.to && ch > part.from) return get(ch - 1);\n return get(ch, right);\n }\n var order = getOrder(lineObj), ch = pos.ch;\n if (!order) return get(ch);\n var partPos = getBidiPartAt(order, ch);\n var val = getBidi(ch, partPos);\n if (bidiOther != null) val.other = getBidi(ch, bidiOther);\n return 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 var left = 0, pos = clipPos(cm.doc, pos);\n if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;\n var lineObj = getLine(cm.doc, pos.line);\n var top = heightAtLine(lineObj) + paddingTop(cm.display);\n return {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 var pos = Pos(line, ch);\n pos.xRel = xRel;\n if (outside) pos.outside = true;\n return 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 var doc = cm.doc;\n y += cm.display.viewOffset;\n if (y < 0) return PosWithInfo(doc.first, 0, true, -1);\n var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;\n if (lineN > last)\n return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);\n if (x < 0) x = 0;\n\n var lineObj = getLine(doc, lineN);\n for (;;) {\n var found = coordsCharInner(cm, lineObj, lineN, x, y);\n var merged = collapsedSpanAtEnd(lineObj);\n var mergedPos = merged && merged.find(0, true);\n if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))\n lineN = lineNo(lineObj = mergedPos.to.line);\n else\n return found;\n }\n }\n\n function coordsCharInner(cm, lineObj, lineNo, x, y) {\n var innerOff = y - heightAtLine(lineObj);\n var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;\n var preparedMeasure = prepareMeasureForLine(cm, lineObj);\n\n function getX(ch) {\n var sp = cursorCoords(cm, Pos(lineNo, ch), \"line\", lineObj, preparedMeasure);\n wrongLine = true;\n if (innerOff > sp.bottom) return sp.left - adjust;\n else if (innerOff < sp.top) return sp.left + adjust;\n else wrongLine = false;\n return sp.left;\n }\n\n var bidi = getOrder(lineObj), dist = lineObj.text.length;\n var from = lineLeft(lineObj), to = lineRight(lineObj);\n var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;\n\n if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);\n // Do a binary search between these bounds.\n for (;;) {\n if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {\n var ch = x < fromX || x - fromX <= toX - x ? from : to;\n var xDiff = x - (ch == from ? fromX : toX);\n while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;\n var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,\n xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);\n return pos;\n }\n var step = Math.ceil(dist / 2), middle = from + step;\n if (bidi) {\n middle = from;\n for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);\n }\n var middleX = getX(middle);\n if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}\n else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}\n }\n }\n\n var measureText;\n // Compute the default text height.\n function textHeight(display) {\n if (display.cachedTextHeight != null) return display.cachedTextHeight;\n if (measureText == null) {\n measureText = elt(\"pre\");\n // Measure a bunch of lines, for browsers that compute\n // fractional heights.\n for (var i = 0; i < 49; ++i) {\n measureText.appendChild(document.createTextNode(\"x\"));\n measureText.appendChild(elt(\"br\"));\n }\n measureText.appendChild(document.createTextNode(\"x\"));\n }\n removeChildrenAndAdd(display.measure, measureText);\n var height = measureText.offsetHeight / 50;\n if (height > 3) display.cachedTextHeight = height;\n removeChildren(display.measure);\n return height || 1;\n }\n\n // Compute the default character width.\n function charWidth(display) {\n if (display.cachedCharWidth != null) return display.cachedCharWidth;\n var anchor = elt(\"span\", \"xxxxxxxxxx\");\n var pre = elt(\"pre\", [anchor]);\n removeChildrenAndAdd(display.measure, pre);\n var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;\n if (width > 2) display.cachedCharWidth = width;\n return width || 10;\n }\n\n // OPERATIONS\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 cm.curOp = {\n viewChanged: false, // Flag that indicates that lines might need to be redrawn\n startHeight: cm.doc.height, // Used to detect need to update scrollbar\n forceUpdate: false, // Used to force a redraw\n updateInput: null, // Whether to reset the input textarea\n typing: false, // Whether this reset should be careful to leave existing text (for compositing)\n changeObjs: null, // Accumulated changes, for firing change events\n cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on\n selectionChanged: false, // Whether the selection needs to be redrawn\n updateMaxLine: false, // Set when the widest line needs to be determined anew\n scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet\n scrollToPos: null, // Used to scroll to a specific position\n id: ++nextOpId // Unique ID\n };\n if (!delayedCallbackDepth++) delayedCallbacks = [];\n }\n\n // Finish an operation, updating the display and signalling delayed events\n function endOperation(cm) {\n var op = cm.curOp, doc = cm.doc, display = cm.display;\n cm.curOp = null;\n\n if (op.updateMaxLine) findMaxLine(cm);\n\n // If it looks like an update might be needed, call updateDisplay\n if (op.viewChanged || op.forceUpdate || op.scrollTop != null ||\n op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||\n op.scrollToPos.to.line >= display.viewTo) ||\n display.maxLineChanged && cm.options.lineWrapping) {\n var updated = updateDisplay(cm, {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);\n if (cm.display.scroller.offsetHeight) cm.doc.scrollTop = cm.display.scroller.scrollTop;\n }\n // If no update was run, but the selection changed, redraw that.\n if (!updated && op.selectionChanged) updateSelection(cm);\n if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm);\n\n // Propagate the scroll position to the actual DOM scroller\n if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) {\n var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));\n display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;\n }\n if (op.scrollLeft != null && display.scroller.scrollLeft != op.scrollLeft) {\n var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));\n display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;\n alignHorizontally(cm);\n }\n // If we need to scroll a specific position into view, do so.\n if (op.scrollToPos) {\n var coords = scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from),\n clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin);\n if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);\n }\n\n if (op.selectionChanged) restartBlink(cm);\n\n if (cm.state.focused && op.updateInput)\n resetInput(cm, op.typing);\n\n // Fire events for markers that are hidden/unidden by editing or\n // undoing\n var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;\n if (hidden) for (var i = 0; i < hidden.length; ++i)\n if (!hidden[i].lines.length) signal(hidden[i], \"hide\");\n if (unhidden) for (var i = 0; i < unhidden.length; ++i)\n if (unhidden[i].lines.length) signal(unhidden[i], \"unhide\");\n\n var delayed;\n if (!--delayedCallbackDepth) {\n delayed = delayedCallbacks;\n delayedCallbacks = null;\n }\n // Fire change events, and delayed event handlers\n if (op.changeObjs)\n signal(cm, \"changes\", cm, op.changeObjs);\n if (delayed) for (var i = 0; i < delayed.length; ++i) delayed[i]();\n if (op.cursorActivityHandlers)\n for (var i = 0; i < op.cursorActivityHandlers.length; i++)\n op.cursorActivityHandlers[i](cm);\n }\n\n // Run the given function in an operation\n function runInOp(cm, f) {\n if (cm.curOp) return f();\n startOperation(cm);\n try { return f(); }\n finally { endOperation(cm); }\n }\n // Wraps a function in an operation. Returns the wrapped function.\n function operation(cm, f) {\n return function() {\n if (cm.curOp) return f.apply(cm, arguments);\n startOperation(cm);\n try { return f.apply(cm, arguments); }\n finally { endOperation(cm); }\n };\n }\n // Used to add methods to editor and doc instances, wrapping them in\n // operations.\n function methodOp(f) {\n return function() {\n if (this.curOp) return f.apply(this, arguments);\n startOperation(this);\n try { return f.apply(this, arguments); }\n finally { endOperation(this); }\n };\n }\n function docMethodOp(f) {\n return function() {\n var cm = this.cm;\n if (!cm || cm.curOp) return f.apply(this, arguments);\n startOperation(cm);\n try { return f.apply(this, arguments); }\n finally { endOperation(cm); }\n };\n }\n\n // VIEW TRACKING\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 // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }\n\n // Create a range of LineView objects for the given lines.\n function buildViewArray(cm, from, to) {\n var array = [], nextPos;\n for (var pos = from; pos < to; pos = nextPos) {\n var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);\n nextPos = pos + view.size;\n array.push(view);\n }\n return array;\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 if (from == null) from = cm.doc.first;\n if (to == null) to = cm.doc.first + cm.doc.size;\n if (!lendiff) lendiff = 0;\n\n var display = cm.display;\n if (lendiff && to < display.viewTo &&\n (display.updateLineNumbers == null || display.updateLineNumbers > from))\n display.updateLineNumbers = from;\n\n cm.curOp.viewChanged = true;\n\n if (from >= display.viewTo) { // Change after\n if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)\n resetView(cm);\n } else if (to <= display.viewFrom) { // Change before\n if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {\n resetView(cm);\n } else {\n display.viewFrom += lendiff;\n display.viewTo += lendiff;\n }\n } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap\n resetView(cm);\n } else if (from <= display.viewFrom) { // Top overlap\n var cut = viewCuttingPoint(cm, to, to + lendiff, 1);\n if (cut) {\n display.view = display.view.slice(cut.index);\n display.viewFrom = cut.lineN;\n display.viewTo += lendiff;\n } else {\n resetView(cm);\n }\n } else if (to >= display.viewTo) { // Bottom overlap\n var cut = viewCuttingPoint(cm, from, from, -1);\n if (cut) {\n display.view = display.view.slice(0, cut.index);\n display.viewTo = cut.lineN;\n } else {\n resetView(cm);\n }\n } else { // Gap in the middle\n var cutTop = viewCuttingPoint(cm, from, from, -1);\n var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);\n if (cutTop && cutBot) {\n display.view = display.view.slice(0, cutTop.index)\n .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))\n .concat(display.view.slice(cutBot.index));\n display.viewTo += lendiff;\n } else {\n resetView(cm);\n }\n }\n\n var ext = display.externalMeasured;\n if (ext) {\n if (to < ext.lineN)\n ext.lineN += lendiff;\n else if (from < ext.lineN + ext.size)\n display.externalMeasured = null;\n }\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 cm.curOp.viewChanged = true;\n var display = cm.display, ext = cm.display.externalMeasured;\n if (ext && line >= ext.lineN && line < ext.lineN + ext.size)\n display.externalMeasured = null;\n\n if (line < display.viewFrom || line >= display.viewTo) return;\n var lineView = display.view[findViewIndex(cm, line)];\n if (lineView.node == null) return;\n var arr = lineView.changes || (lineView.changes = []);\n if (indexOf(arr, type) == -1) arr.push(type);\n }\n\n // Clear the view.\n function resetView(cm) {\n cm.display.viewFrom = cm.display.viewTo = cm.doc.first;\n cm.display.view = [];\n cm.display.viewOffset = 0;\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 if (n >= cm.display.viewTo) return null;\n n -= cm.display.viewFrom;\n if (n < 0) return null;\n var view = cm.display.view;\n for (var i = 0; i < view.length; i++) {\n n -= view[i].size;\n if (n < 0) return i;\n }\n }\n\n function viewCuttingPoint(cm, oldN, newN, dir) {\n var index = findViewIndex(cm, oldN), diff, view = cm.display.view;\n if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)\n return {index: index, lineN: newN};\n for (var i = 0, n = cm.display.viewFrom; i < index; i++)\n n += view[i].size;\n if (n != oldN) {\n if (dir > 0) {\n if (index == view.length - 1) return null;\n diff = (n + view[index].size) - oldN;\n index++;\n } else {\n diff = n - oldN;\n }\n oldN += diff; newN += diff;\n }\n while (visualLineNo(cm.doc, newN) != newN) {\n if (index == (dir < 0 ? 0 : view.length - 1)) return null;\n newN += dir * view[index - (dir < 0 ? 1 : 0)].size;\n index += dir;\n }\n return {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 var display = cm.display, view = display.view;\n if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {\n display.view = buildViewArray(cm, from, to);\n display.viewFrom = from;\n } else {\n if (display.viewFrom > from)\n display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);\n else if (display.viewFrom < from)\n display.view = display.view.slice(findViewIndex(cm, from));\n display.viewFrom = from;\n if (display.viewTo < to)\n display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));\n else if (display.viewTo > to)\n display.view = display.view.slice(0, findViewIndex(cm, to));\n }\n display.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 var view = cm.display.view, dirty = 0;\n for (var i = 0; i < view.length; i++) {\n var lineView = view[i];\n if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;\n }\n return dirty;\n }\n\n // INPUT HANDLING\n\n // Poll for input changes, using the normal rate of polling. This\n // runs as long as the editor is focused.\n function slowPoll(cm) {\n if (cm.display.pollingFast) return;\n cm.display.poll.set(cm.options.pollInterval, function() {\n readInput(cm);\n if (cm.state.focused) slowPoll(cm);\n });\n }\n\n // When an event has just come in that is likely to add or change\n // something in the input textarea, we poll faster, to ensure that\n // the change appears on the screen quickly.\n function fastPoll(cm) {\n var missed = false;\n cm.display.pollingFast = true;\n function p() {\n var changed = readInput(cm);\n if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}\n else {cm.display.pollingFast = false; slowPoll(cm);}\n }\n cm.display.poll.set(20, p);\n }\n\n // Read input from the textarea, and update the document to match.\n // When something is selected, it is present in the textarea, and\n // selected (unless it is huge, in which case a placeholder is\n // used). When nothing is selected, the cursor sits after previously\n // seen text (can be empty), which is stored in prevInput (we must\n // not reset the textarea when typing, because that breaks IME).\n function readInput(cm) {\n var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc;\n // Since this is called a *lot*, try to bail out as cheaply as\n // possible when it is clear that nothing happened. hasSelection\n // will be the case when there is a lot of text in the textarea,\n // in which case reading its value would be expensive.\n if (!cm.state.focused || (hasSelection(input) && !prevInput) || isReadOnly(cm) || cm.options.disableInput)\n return false;\n // See paste handler for more on the fakedLastChar kludge\n if (cm.state.pasteIncoming && cm.state.fakedLastChar) {\n input.value = input.value.substring(0, input.value.length - 1);\n cm.state.fakedLastChar = false;\n }\n var text = input.value;\n // If nothing changed, bail.\n if (text == prevInput && !cm.somethingSelected()) return false;\n // Work around nonsensical selection resetting in IE9/10\n if (ie && !ie_upto8 && cm.display.inputHasSelection === text) {\n resetInput(cm);\n return false;\n }\n\n var withOp = !cm.curOp;\n if (withOp) startOperation(cm);\n cm.display.shift = false;\n\n if (text.charCodeAt(0) == 0x200b && doc.sel == cm.display.selForContextMenu && !prevInput)\n prevInput = \"\\u200b\";\n // Find the part of the input that is actually new\n var same = 0, l = Math.min(prevInput.length, text.length);\n while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;\n var inserted = text.slice(same), textLines = splitLines(inserted);\n\n // When pasing N lines into N selections, insert one line per selection\n var multiPaste = cm.state.pasteIncoming && textLines.length > 1 && doc.sel.ranges.length == textLines.length;\n\n // Normal behavior is to insert the new text into every selection\n for (var i = doc.sel.ranges.length - 1; i >= 0; i--) {\n var range = doc.sel.ranges[i];\n var from = range.from(), to = range.to();\n // Handle deletion\n if (same < prevInput.length)\n from = Pos(from.line, from.ch - (prevInput.length - same));\n // Handle overwrite\n else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming)\n to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));\n var updateInput = cm.curOp.updateInput;\n var changeEvent = {from: from, to: to, text: multiPaste ? [textLines[i]] : textLines,\n origin: cm.state.pasteIncoming ? \"paste\" : cm.state.cutIncoming ? \"cut\" : \"+input\"};\n makeChange(cm.doc, changeEvent);\n signalLater(cm, \"inputRead\", cm, changeEvent);\n // When an 'electric' character is inserted, immediately trigger a reindent\n if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&\n cm.options.smartIndent && range.head.ch < 100 &&\n (!i || doc.sel.ranges[i - 1].head.line != range.head.line)) {\n var mode = cm.getModeAt(range.head);\n if (mode.electricChars) {\n for (var j = 0; j < mode.electricChars.length; j++)\n if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {\n indentLine(cm, range.head.line, \"smart\");\n break;\n }\n } else if (mode.electricInput) {\n var end = changeEnd(changeEvent);\n if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))\n indentLine(cm, range.head.line, \"smart\");\n }\n }\n }\n ensureCursorVisible(cm);\n cm.curOp.updateInput = updateInput;\n cm.curOp.typing = true;\n\n // Don't leave long text in the textarea, since it makes further polling slow\n if (text.length > 1000 || text.indexOf(\"\\n\") > -1) input.value = cm.display.prevInput = \"\";\n else cm.display.prevInput = text;\n if (withOp) endOperation(cm);\n cm.state.pasteIncoming = cm.state.cutIncoming = false;\n return true;\n }\n\n // Reset the input to correspond to the selection (or to be empty,\n // when not typing and nothing is selected)\n function resetInput(cm, typing) {\n var minimal, selected, doc = cm.doc;\n if (cm.somethingSelected()) {\n cm.display.prevInput = \"\";\n var range = doc.sel.primary();\n minimal = hasCopyEvent &&\n (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);\n var content = minimal ? \"-\" : selected || cm.getSelection();\n cm.display.input.value = content;\n if (cm.state.focused) selectInput(cm.display.input);\n if (ie && !ie_upto8) cm.display.inputHasSelection = content;\n } else if (!typing) {\n cm.display.prevInput = cm.display.input.value = \"\";\n if (ie && !ie_upto8) cm.display.inputHasSelection = null;\n }\n cm.display.inaccurateSelection = minimal;\n }\n\n function focusInput(cm) {\n if (cm.options.readOnly != \"nocursor\" && (!mobile || activeElt() != cm.display.input))\n cm.display.input.focus();\n }\n\n function ensureFocus(cm) {\n if (!cm.state.focused) { focusInput(cm); onFocus(cm); }\n }\n\n function isReadOnly(cm) {\n return cm.options.readOnly || cm.doc.cantEdit;\n }\n\n // EVENT HANDLERS\n\n // Attach the necessary event handlers when initializing the editor\n function registerEventHandlers(cm) {\n var d = cm.display;\n on(d.scroller, \"mousedown\", operation(cm, onMouseDown));\n // Older IE's will not fire a second mousedown for a double click\n if (ie_upto10)\n on(d.scroller, \"dblclick\", operation(cm, function(e) {\n if (signalDOMEvent(cm, e)) return;\n var pos = posFromMouse(cm, e);\n if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;\n e_preventDefault(e);\n var word = findWordAt(cm, pos);\n extendSelection(cm.doc, word.anchor, word.head);\n }));\n else\n on(d.scroller, \"dblclick\", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });\n // Prevent normal selection in the editor (we handle our own)\n on(d.lineSpace, \"selectstart\", function(e) {\n if (!eventInWidget(d, e)) e_preventDefault(e);\n });\n // Some browsers fire contextmenu *after* opening the menu, at\n // which point we can't mess with it anymore. Context menu is\n // handled in onMouseDown for these browsers.\n if (!captureRightClick) on(d.scroller, \"contextmenu\", function(e) {onContextMenu(cm, e);});\n\n // Sync scrolling between fake scrollbars and real scrollable\n // area, ensure viewport is updated when scrolling.\n on(d.scroller, \"scroll\", function() {\n if (d.scroller.clientHeight) {\n setScrollTop(cm, d.scroller.scrollTop);\n setScrollLeft(cm, d.scroller.scrollLeft, true);\n signal(cm, \"scroll\", cm);\n }\n });\n on(d.scrollbarV, \"scroll\", function() {\n if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);\n });\n on(d.scrollbarH, \"scroll\", function() {\n if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);\n });\n\n // Listen to wheel events in order to try and update the viewport on time.\n on(d.scroller, \"mousewheel\", function(e){onScrollWheel(cm, e);});\n on(d.scroller, \"DOMMouseScroll\", function(e){onScrollWheel(cm, e);});\n\n // Prevent clicks in the scrollbars from killing focus\n function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }\n on(d.scrollbarH, \"mousedown\", reFocus);\n on(d.scrollbarV, \"mousedown\", reFocus);\n // Prevent wrapper from ever scrolling\n on(d.wrapper, \"scroll\", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });\n\n on(d.input, \"keyup\", operation(cm, onKeyUp));\n on(d.input, \"input\", function() {\n if (ie && !ie_upto8 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;\n fastPoll(cm);\n });\n on(d.input, \"keydown\", operation(cm, onKeyDown));\n on(d.input, \"keypress\", operation(cm, onKeyPress));\n on(d.input, \"focus\", bind(onFocus, cm));\n on(d.input, \"blur\", bind(onBlur, cm));\n\n function drag_(e) {\n if (!signalDOMEvent(cm, e)) e_stop(e);\n }\n if (cm.options.dragDrop) {\n on(d.scroller, \"dragstart\", function(e){onDragStart(cm, e);});\n on(d.scroller, \"dragenter\", drag_);\n on(d.scroller, \"dragover\", drag_);\n on(d.scroller, \"drop\", operation(cm, onDrop));\n }\n on(d.scroller, \"paste\", function(e) {\n if (eventInWidget(d, e)) return;\n cm.state.pasteIncoming = true;\n focusInput(cm);\n fastPoll(cm);\n });\n on(d.input, \"paste\", function() {\n // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206\n // Add a char to the end of textarea before paste occur so that\n // selection doesn't span to the end of textarea.\n if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {\n var start = d.input.selectionStart, end = d.input.selectionEnd;\n d.input.value += \"$\";\n d.input.selectionStart = start;\n d.input.selectionEnd = end;\n cm.state.fakedLastChar = true;\n }\n cm.state.pasteIncoming = true;\n fastPoll(cm);\n });\n\n function prepareCopyCut(e) {\n if (cm.somethingSelected()) {\n if (d.inaccurateSelection) {\n d.prevInput = \"\";\n d.inaccurateSelection = false;\n d.input.value = cm.getSelection();\n selectInput(d.input);\n }\n } else {\n var text = \"\", ranges = [];\n for (var i = 0; i < cm.doc.sel.ranges.length; i++) {\n var line = cm.doc.sel.ranges[i].head.line;\n var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};\n ranges.push(lineRange);\n text += cm.getRange(lineRange.anchor, lineRange.head);\n }\n if (e.type == \"cut\") {\n cm.setSelections(ranges, null, sel_dontScroll);\n } else {\n d.prevInput = \"\";\n d.input.value = text;\n selectInput(d.input);\n }\n }\n if (e.type == \"cut\") cm.state.cutIncoming = true;\n }\n on(d.input, \"cut\", prepareCopyCut);\n on(d.input, \"copy\", prepareCopyCut);\n\n // Needed to handle Tab key in KHTML\n if (khtml) on(d.sizer, \"mouseup\", function() {\n if (activeElt() == d.input) d.input.blur();\n focusInput(cm);\n });\n }\n\n // Called when the window resizes\n function onResize(cm) {\n // Might be a text scaling operation, clear size caches.\n var d = cm.display;\n d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;\n cm.setSize();\n }\n\n // MOUSE EVENTS\n\n // Return true when the given mouse event happened in a widget\n function eventInWidget(display, e) {\n for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {\n if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;\n }\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 var display = cm.display;\n if (!liberal) {\n var target = e_target(e);\n if (target == display.scrollbarH || target == display.scrollbarV ||\n target == display.scrollbarFiller || target == display.gutterFiller) return null;\n }\n var x, y, space = display.lineSpace.getBoundingClientRect();\n // Fails unpredictably on IE[67] when mouse is dragged around quickly.\n try { x = e.clientX - space.left; y = e.clientY - space.top; }\n catch (e) { return null; }\n var coords = coordsChar(cm, x, y), line;\n if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {\n var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;\n coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));\n }\n return coords;\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 if (signalDOMEvent(this, e)) return;\n var cm = this, display = cm.display;\n display.shift = e.shiftKey;\n\n if (eventInWidget(display, e)) {\n if (!webkit) {\n // Briefly turn off draggability, to allow widgets to do\n // normal dragging things.\n display.scroller.draggable = false;\n setTimeout(function(){display.scroller.draggable = true;}, 100);\n }\n return;\n }\n if (clickInGutter(cm, e)) return;\n var start = posFromMouse(cm, e);\n window.focus();\n\n switch (e_button(e)) {\n case 1:\n if (start)\n leftButtonDown(cm, e, start);\n else if (e_target(e) == display.scroller)\n e_preventDefault(e);\n break;\n case 2:\n if (webkit) cm.state.lastMiddleDown = +new Date;\n if (start) extendSelection(cm.doc, start);\n setTimeout(bind(focusInput, cm), 20);\n e_preventDefault(e);\n break;\n case 3:\n if (captureRightClick) onContextMenu(cm, e);\n break;\n }\n }\n\n var lastClick, lastDoubleClick;\n function leftButtonDown(cm, e, start) {\n setTimeout(bind(ensureFocus, cm), 0);\n\n var now = +new Date, type;\n if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {\n type = \"triple\";\n } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {\n type = \"double\";\n lastDoubleClick = {time: now, pos: start};\n } else {\n type = \"single\";\n lastClick = {time: now, pos: start};\n }\n\n var sel = cm.doc.sel, addNew = mac ? e.metaKey : e.ctrlKey;\n if (cm.options.dragDrop && dragAndDrop && !addNew && !isReadOnly(cm) &&\n type == \"single\" && sel.contains(start) > -1 && sel.somethingSelected())\n leftButtonStartDrag(cm, e, start);\n else\n leftButtonSelect(cm, e, start, type, addNew);\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) {\n var display = cm.display;\n var dragEnd = operation(cm, function(e2) {\n if (webkit) display.scroller.draggable = false;\n cm.state.draggingText = false;\n off(document, \"mouseup\", dragEnd);\n off(display.scroller, \"drop\", dragEnd);\n if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {\n e_preventDefault(e2);\n extendSelection(cm.doc, start);\n focusInput(cm);\n // Work around unexplainable focus problem in IE9 (#2127)\n if (ie_upto10 && !ie_upto8)\n setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);\n }\n });\n // Let the drag handler handle this.\n if (webkit) display.scroller.draggable = true;\n cm.state.draggingText = dragEnd;\n // IE's approach to draggable\n if (display.scroller.dragDrop) display.scroller.dragDrop();\n on(document, \"mouseup\", dragEnd);\n on(display.scroller, \"drop\", dragEnd);\n }\n\n // Normal selection, as opposed to text dragging.\n function leftButtonSelect(cm, e, start, type, addNew) {\n var display = cm.display, doc = cm.doc;\n e_preventDefault(e);\n\n var ourRange, ourIndex, startSel = doc.sel;\n if (addNew && !e.shiftKey) {\n ourIndex = doc.sel.contains(start);\n if (ourIndex > -1)\n ourRange = doc.sel.ranges[ourIndex];\n else\n ourRange = new Range(start, start);\n } else {\n ourRange = doc.sel.primary();\n }\n\n if (e.altKey) {\n type = \"rect\";\n if (!addNew) ourRange = new Range(start, start);\n start = posFromMouse(cm, e, true, true);\n ourIndex = -1;\n } else if (type == \"double\") {\n var word = findWordAt(cm, start);\n if (cm.display.shift || doc.extend)\n ourRange = extendRange(doc, ourRange, word.anchor, word.head);\n else\n ourRange = word;\n } else if (type == \"triple\") {\n var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));\n if (cm.display.shift || doc.extend)\n ourRange = extendRange(doc, ourRange, line.anchor, line.head);\n else\n ourRange = line;\n } else {\n ourRange = extendRange(doc, ourRange, start);\n }\n\n if (!addNew) {\n ourIndex = 0;\n setSelection(doc, new Selection([ourRange], 0), sel_mouse);\n startSel = doc.sel;\n } else if (ourIndex > -1) {\n replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);\n } else {\n ourIndex = doc.sel.ranges.length;\n setSelection(doc, normalizeSelection(doc.sel.ranges.concat([ourRange]), ourIndex),\n {scroll: false, origin: \"*mouse\"});\n }\n\n var lastPos = start;\n function extendTo(pos) {\n if (cmp(lastPos, pos) == 0) return;\n lastPos = pos;\n\n if (type == \"rect\") {\n var ranges = [], tabSize = cm.options.tabSize;\n var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);\n var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);\n var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);\n for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));\n line <= end; line++) {\n var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);\n if (left == right)\n ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));\n else if (text.length > leftPos)\n ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));\n }\n if (!ranges.length) ranges.push(new Range(start, start));\n setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),\n {origin: \"*mouse\", scroll: false});\n cm.scrollIntoView(pos);\n } else {\n var oldRange = ourRange;\n var anchor = oldRange.anchor, head = pos;\n if (type != \"single\") {\n if (type == \"double\")\n var range = findWordAt(cm, pos);\n else\n var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));\n if (cmp(range.anchor, anchor) > 0) {\n head = range.head;\n anchor = minPos(oldRange.from(), range.anchor);\n } else {\n head = range.anchor;\n anchor = maxPos(oldRange.to(), range.head);\n }\n }\n var ranges = startSel.ranges.slice(0);\n ranges[ourIndex] = new Range(clipPos(doc, anchor), head);\n setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);\n }\n }\n\n var editorSize = display.wrapper.getBoundingClientRect();\n // Used to ensure timeout re-tries don't fire when another extend\n // happened in the meantime (clearTimeout isn't reliable -- at\n // least on Chrome, the timeouts still happen even when cleared,\n // if the clear happens after their scheduled firing time).\n var counter = 0;\n\n function extend(e) {\n var curCount = ++counter;\n var cur = posFromMouse(cm, e, true, type == \"rect\");\n if (!cur) return;\n if (cmp(cur, lastPos) != 0) {\n ensureFocus(cm);\n extendTo(cur);\n var visible = visibleLines(display, doc);\n if (cur.line >= visible.to || cur.line < visible.from)\n setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);\n } else {\n var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;\n if (outside) setTimeout(operation(cm, function() {\n if (counter != curCount) return;\n display.scroller.scrollTop += outside;\n extend(e);\n }), 50);\n }\n }\n\n function done(e) {\n counter = Infinity;\n e_preventDefault(e);\n focusInput(cm);\n off(document, \"mousemove\", move);\n off(document, \"mouseup\", up);\n doc.history.lastSelOrigin = null;\n }\n\n var move = operation(cm, function(e) {\n if ((ie && !ie_upto9) ? !e.buttons : !e_button(e)) done(e);\n else extend(e);\n });\n var up = operation(cm, done);\n on(document, \"mousemove\", move);\n on(document, \"mouseup\", up);\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, signalfn) {\n try { var mX = e.clientX, mY = e.clientY; }\n catch(e) { return false; }\n if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;\n if (prevent) e_preventDefault(e);\n\n var display = cm.display;\n var lineBox = display.lineDiv.getBoundingClientRect();\n\n if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);\n mY -= lineBox.top - display.viewOffset;\n\n for (var i = 0; i < cm.options.gutters.length; ++i) {\n var g = display.gutters.childNodes[i];\n if (g && g.getBoundingClientRect().right >= mX) {\n var line = lineAtHeight(cm.doc, mY);\n var gutter = cm.options.gutters[i];\n signalfn(cm, type, cm, line, gutter, e);\n return e_defaultPrevented(e);\n }\n }\n }\n\n function clickInGutter(cm, e) {\n return gutterEvent(cm, e, \"gutterClick\", true, signalLater);\n }\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 var cm = this;\n if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))\n return;\n e_preventDefault(e);\n if (ie) lastDrop = +new Date;\n var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;\n if (!pos || isReadOnly(cm)) return;\n // Might be a file drop, in which case we simply extract the text\n // and insert it.\n if (files && files.length && window.FileReader && window.File) {\n var n = files.length, text = Array(n), read = 0;\n var loadFile = function(file, i) {\n var reader = new FileReader;\n reader.onload = operation(cm, function() {\n text[i] = reader.result;\n if (++read == n) {\n pos = clipPos(cm.doc, pos);\n var change = {from: pos, to: pos, text: splitLines(text.join(\"\\n\")), origin: \"paste\"};\n makeChange(cm.doc, change);\n setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));\n }\n });\n reader.readAsText(file);\n };\n for (var i = 0; i < n; ++i) loadFile(files[i], i);\n } else { // Normal drop\n // Don't do a replace if the drop happened inside of the selected text.\n if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {\n cm.state.draggingText(e);\n // Ensure the editor is re-focused\n setTimeout(bind(focusInput, cm), 20);\n return;\n }\n try {\n var text = e.dataTransfer.getData(\"Text\");\n if (text) {\n var selected = cm.state.draggingText && cm.listSelections();\n setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));\n if (selected) for (var i = 0; i < selected.length; ++i)\n replaceRange(cm.doc, \"\", selected[i].anchor, selected[i].head, \"drag\");\n cm.replaceSelection(text, \"around\", \"paste\");\n focusInput(cm);\n }\n }\n catch(e){}\n }\n }\n\n function onDragStart(cm, e) {\n if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }\n if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;\n\n e.dataTransfer.setData(\"Text\", cm.getSelection());\n\n // Use dummy image instead of default browsers image.\n // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.\n if (e.dataTransfer.setDragImage && !safari) {\n var img = elt(\"img\", null, null, \"position: fixed; left: 0; top: 0;\");\n img.src = \"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\";\n if (presto) {\n img.width = img.height = 1;\n cm.display.wrapper.appendChild(img);\n // Force a relayout, or Opera won't use our image for some obscure reason\n img._top = img.offsetTop;\n }\n e.dataTransfer.setDragImage(img, 0, 0);\n if (presto) img.parentNode.removeChild(img);\n }\n }\n\n // SCROLL EVENTS\n\n // Sync the scrollable area and scrollbars, ensure the viewport\n // covers the visible area.\n function setScrollTop(cm, val) {\n if (Math.abs(cm.doc.scrollTop - val) < 2) return;\n cm.doc.scrollTop = val;\n if (!gecko) updateDisplay(cm, {top: val});\n if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;\n if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;\n if (gecko) updateDisplay(cm);\n startWorker(cm, 100);\n }\n // Sync scroller and scrollbar, ensure the gutter elements are\n // aligned.\n function setScrollLeft(cm, val, isScroller) {\n if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;\n val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);\n cm.doc.scrollLeft = val;\n alignHorizontally(cm);\n if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;\n if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = 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, 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 onScrollWheel(cm, e) {\n var dx = e.wheelDeltaX, dy = e.wheelDeltaY;\n if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;\n if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;\n else if (dy == null) dy = e.wheelDelta;\n\n var display = cm.display, scroll = display.scroller;\n // Quit if there's nothing to scroll here\n if (!(dx && scroll.scrollWidth > scroll.clientWidth ||\n dy && scroll.scrollHeight > scroll.clientHeight)) return;\n\n // Webkit browsers on OS X abort momentum scrolls when the target\n // of the scroll event is removed from the scrollable element.\n // This hack (see related code in patchDisplay) makes sure the\n // element is kept around.\n if (dy && mac && webkit) {\n outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {\n for (var i = 0; i < view.length; i++) {\n if (view[i].node == cur) {\n cm.display.currentWheelTarget = cur;\n break outer;\n }\n }\n }\n }\n\n // On some browsers, horizontal scrolling will cause redraws to\n // happen before the gutter has been realigned, causing it to\n // wriggle around in a most unseemly way. When we have an\n // estimated pixels/delta value, we just handle horizontal\n // scrolling entirely here. It'll be slightly off from native, but\n // better than glitching out.\n if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {\n if (dy)\n setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));\n setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));\n e_preventDefault(e);\n display.wheelStartX = null; // Abort measurement, if in progress\n return;\n }\n\n // 'Project' the visible viewport to cover the area that is being\n // scrolled into view (if we know enough to estimate it).\n if (dy && wheelPixelsPerUnit != null) {\n var pixels = dy * wheelPixelsPerUnit;\n var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;\n if (pixels < 0) top = Math.max(0, top + pixels - 50);\n else bot = Math.min(cm.doc.height, bot + pixels + 50);\n updateDisplay(cm, {top: top, bottom: bot});\n }\n\n if (wheelSamples < 20) {\n if (display.wheelStartX == null) {\n display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;\n display.wheelDX = dx; display.wheelDY = dy;\n setTimeout(function() {\n if (display.wheelStartX == null) return;\n var movedX = scroll.scrollLeft - display.wheelStartX;\n var movedY = scroll.scrollTop - display.wheelStartY;\n var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||\n (movedX && display.wheelDX && movedX / display.wheelDX);\n display.wheelStartX = display.wheelStartY = null;\n if (!sample) return;\n wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);\n ++wheelSamples;\n }, 200);\n } else {\n display.wheelDX += dx; display.wheelDY += dy;\n }\n }\n }\n\n // KEY EVENTS\n\n // Run a handler that was bound to a key.\n function doHandleBinding(cm, bound, dropShift) {\n if (typeof bound == \"string\") {\n bound = commands[bound];\n if (!bound) return false;\n }\n // Ensure previous input has been read, so that the handler sees a\n // consistent view of the document\n if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;\n var prevShift = cm.display.shift, done = false;\n try {\n if (isReadOnly(cm)) cm.state.suppressEdits = true;\n if (dropShift) cm.display.shift = false;\n done = bound(cm) != Pass;\n } finally {\n cm.display.shift = prevShift;\n cm.state.suppressEdits = false;\n }\n return done;\n }\n\n // Collect the currently active keymaps.\n function allKeyMaps(cm) {\n var maps = cm.state.keyMaps.slice(0);\n if (cm.options.extraKeys) maps.push(cm.options.extraKeys);\n maps.push(cm.options.keyMap);\n return maps;\n }\n\n var maybeTransition;\n // Handle a key from the keydown event.\n function handleKeyBinding(cm, e) {\n // Handle automatic keymap transitions\n var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;\n clearTimeout(maybeTransition);\n if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {\n if (getKeyMap(cm.options.keyMap) == startMap) {\n cm.options.keyMap = (next.call ? next.call(null, cm) : next);\n keyMapChanged(cm);\n }\n }, 50);\n\n var name = keyName(e, true), handled = false;\n if (!name) return false;\n var keymaps = allKeyMaps(cm);\n\n if (e.shiftKey) {\n // First try to resolve full name (including 'Shift-'). Failing\n // that, see if there is a cursor-motion command (starting with\n // 'go') bound to the keyname without 'Shift-'.\n handled = lookupKey(\"Shift-\" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})\n || lookupKey(name, keymaps, function(b) {\n if (typeof b == \"string\" ? /^go[A-Z]/.test(b) : b.motion)\n return doHandleBinding(cm, b);\n });\n } else {\n handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });\n }\n\n if (handled) {\n e_preventDefault(e);\n restartBlink(cm);\n signalLater(cm, \"keyHandled\", cm, name, e);\n }\n return handled;\n }\n\n // Handle a key from the keypress event\n function handleCharBinding(cm, e, ch) {\n var handled = lookupKey(\"'\" + ch + \"'\", allKeyMaps(cm),\n function(b) { return doHandleBinding(cm, b, true); });\n if (handled) {\n e_preventDefault(e);\n restartBlink(cm);\n signalLater(cm, \"keyHandled\", cm, \"'\" + ch + \"'\", e);\n }\n return handled;\n }\n\n var lastStoppedKey = null;\n function onKeyDown(e) {\n var cm = this;\n ensureFocus(cm);\n if (signalDOMEvent(cm, e)) return;\n // IE does strange things with escape.\n if (ie_upto10 && e.keyCode == 27) e.returnValue = false;\n var code = e.keyCode;\n cm.display.shift = code == 16 || e.shiftKey;\n var handled = handleKeyBinding(cm, e);\n if (presto) {\n lastStoppedKey = handled ? code : null;\n // Opera has no cut event... we try to at least catch the key combo\n if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))\n cm.replaceSelection(\"\", null, \"cut\");\n }\n\n // Turn mouse into crosshair when Alt is held on Mac.\n if (code == 18 && !/\\bCodeMirror-crosshair\\b/.test(cm.display.lineDiv.className))\n showCrossHair(cm);\n }\n\n function showCrossHair(cm) {\n var lineDiv = cm.display.lineDiv;\n addClass(lineDiv, \"CodeMirror-crosshair\");\n\n function up(e) {\n if (e.keyCode == 18 || !e.altKey) {\n rmClass(lineDiv, \"CodeMirror-crosshair\");\n off(document, \"keyup\", up);\n off(document, \"mouseover\", up);\n }\n }\n on(document, \"keyup\", up);\n on(document, \"mouseover\", up);\n }\n\n function onKeyUp(e) {\n if (signalDOMEvent(this, e)) return;\n if (e.keyCode == 16) this.doc.sel.shift = false;\n }\n\n function onKeyPress(e) {\n var cm = this;\n if (signalDOMEvent(cm, e)) return;\n var keyCode = e.keyCode, charCode = e.charCode;\n if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}\n if (((presto && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;\n var ch = String.fromCharCode(charCode == null ? keyCode : charCode);\n if (handleCharBinding(cm, e, ch)) return;\n if (ie && !ie_upto8) cm.display.inputHasSelection = null;\n fastPoll(cm);\n }\n\n // FOCUS/BLUR EVENTS\n\n function onFocus(cm) {\n if (cm.options.readOnly == \"nocursor\") return;\n if (!cm.state.focused) {\n signal(cm, \"focus\", cm);\n cm.state.focused = true;\n addClass(cm.display.wrapper, \"CodeMirror-focused\");\n // The prevInput test prevents this from firing when a context\n // menu is closed (since the resetInput would kill the\n // select-all detection hack)\n if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {\n resetInput(cm);\n if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730\n }\n }\n slowPoll(cm);\n restartBlink(cm);\n }\n function onBlur(cm) {\n if (cm.state.focused) {\n signal(cm, \"blur\", cm);\n cm.state.focused = false;\n rmClass(cm.display.wrapper, \"CodeMirror-focused\");\n }\n clearInterval(cm.display.blinker);\n setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);\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 if (signalDOMEvent(cm, e, \"contextmenu\")) return;\n var display = cm.display;\n if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;\n\n var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;\n if (!pos || presto) return; // Opera is difficult.\n\n // Reset the current text selection only if the click is done outside of the selection\n // and 'resetSelectionOnContextMenu' option is true.\n var reset = cm.options.resetSelectionOnContextMenu;\n if (reset && cm.doc.sel.contains(pos) == -1)\n operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);\n\n var oldCSS = display.input.style.cssText;\n display.inputDiv.style.position = \"absolute\";\n display.input.style.cssText = \"position: fixed; width: 30px; height: 30px; top: \" + (e.clientY - 5) +\n \"px; left: \" + (e.clientX - 5) + \"px; z-index: 1000; background: \" +\n (ie ? \"rgba(255, 255, 255, .05)\" : \"transparent\") +\n \"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);\";\n focusInput(cm);\n resetInput(cm);\n // Adds \"Select all\" to context menu in FF\n if (!cm.somethingSelected()) display.input.value = display.prevInput = \" \";\n display.selForContextMenu = cm.doc.sel;\n clearTimeout(display.detectingSelectAll);\n\n // Select-all will be greyed out if there's nothing to select, so\n // this adds a zero-width space so that we can later check whether\n // it got selected.\n function prepareSelectAllHack() {\n if (display.input.selectionStart != null) {\n var selected = cm.somethingSelected();\n var extval = display.input.value = \"\\u200b\" + (selected ? display.input.value : \"\");\n display.prevInput = selected ? \"\" : \"\\u200b\";\n display.input.selectionStart = 1; display.input.selectionEnd = extval.length;\n }\n }\n function rehide() {\n display.inputDiv.style.position = \"relative\";\n display.input.style.cssText = oldCSS;\n if (ie_upto8) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;\n slowPoll(cm);\n\n // Try to detect the user choosing select-all\n if (display.input.selectionStart != null) {\n if (!ie || ie_upto8) prepareSelectAllHack();\n var i = 0, poll = function() {\n if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0)\n operation(cm, commands.selectAll)(cm);\n else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);\n else resetInput(cm);\n };\n display.detectingSelectAll = setTimeout(poll, 200);\n }\n }\n\n if (ie && !ie_upto8) prepareSelectAllHack();\n if (captureRightClick) {\n e_stop(e);\n var mouseup = function() {\n off(window, \"mouseup\", mouseup);\n setTimeout(rehide, 20);\n };\n on(window, \"mouseup\", mouseup);\n } else {\n setTimeout(rehide, 50);\n }\n }\n\n function contextMenuInGutter(cm, e) {\n if (!hasHandler(cm, \"gutterContextMenu\")) return false;\n return gutterEvent(cm, e, \"gutterContextMenu\", false, signal);\n }\n\n // UPDATING\n\n // Compute the position of the end of a change (its 'to' property\n // refers to the pre-change end).\n var changeEnd = CodeMirror.changeEnd = function(change) {\n if (!change.text) return change.to;\n return Pos(change.from.line + change.text.length - 1,\n 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 if (cmp(pos, change.from) < 0) return pos;\n if (cmp(pos, change.to) <= 0) return changeEnd(change);\n\n var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;\n if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;\n return Pos(line, ch);\n }\n\n function computeSelAfterChange(doc, change) {\n var out = [];\n for (var i = 0; i < doc.sel.ranges.length; i++) {\n var range = doc.sel.ranges[i];\n out.push(new Range(adjustForChange(range.anchor, change),\n adjustForChange(range.head, change)));\n }\n return normalizeSelection(out, doc.sel.primIndex);\n }\n\n function offsetPos(pos, old, nw) {\n if (pos.line == old.line)\n return Pos(nw.line, pos.ch - old.ch + nw.ch);\n else\n 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 var out = [];\n var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;\n for (var i = 0; i < changes.length; i++) {\n var change = changes[i];\n var from = offsetPos(change.from, oldPrev, newPrev);\n var to = offsetPos(changeEnd(change), oldPrev, newPrev);\n oldPrev = change.to;\n newPrev = to;\n if (hint == \"around\") {\n var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;\n out[i] = new Range(inv ? to : from, inv ? from : to);\n } else {\n out[i] = new Range(from, from);\n }\n }\n return new Selection(out, doc.sel.primIndex);\n }\n\n // Allow \"beforeChange\" event handlers to influence a change\n function filterChange(doc, change, update) {\n var obj = {\n canceled: false,\n from: change.from,\n to: change.to,\n text: change.text,\n origin: change.origin,\n cancel: function() { this.canceled = true; }\n };\n if (update) obj.update = function(from, to, text, origin) {\n if (from) this.from = clipPos(doc, from);\n if (to) this.to = clipPos(doc, to);\n if (text) this.text = text;\n if (origin !== undefined) this.origin = origin;\n };\n signal(doc, \"beforeChange\", doc, obj);\n if (doc.cm) signal(doc.cm, \"beforeChange\", doc.cm, obj);\n\n if (obj.canceled) return null;\n return {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 if (doc.cm) {\n if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);\n if (doc.cm.state.suppressEdits) return;\n }\n\n if (hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\")) {\n change = filterChange(doc, change, true);\n if (!change) return;\n }\n\n // Possibly split or suppress the update based on the presence\n // of read-only spans in its range.\n var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);\n if (split) {\n for (var i = split.length - 1; i >= 0; --i)\n makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [\"\"] : change.text});\n } else {\n makeChangeInner(doc, change);\n }\n }\n\n function makeChangeInner(doc, change) {\n if (change.text.length == 1 && change.text[0] == \"\" && cmp(change.from, change.to) == 0) return;\n var selAfter = computeSelAfterChange(doc, change);\n addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);\n\n makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));\n var rebased = [];\n\n linkedDocs(doc, function(doc, sharedHist) {\n if (!sharedHist && indexOf(rebased, doc.history) == -1) {\n rebaseHist(doc.history, change);\n rebased.push(doc.history);\n }\n makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));\n });\n }\n\n // Revert a change stored in a document's history.\n function makeChangeFromHistory(doc, type, allowSelectionOnly) {\n if (doc.cm && doc.cm.state.suppressEdits) return;\n\n var hist = doc.history, event, selAfter = doc.sel;\n var source = type == \"undo\" ? hist.done : hist.undone, dest = type == \"undo\" ? hist.undone : hist.done;\n\n // Verify that there is a useable event (so that ctrl-z won't\n // needlessly clear selection events)\n for (var i = 0; i < source.length; i++) {\n event = source[i];\n if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)\n break;\n }\n if (i == source.length) return;\n hist.lastOrigin = hist.lastSelOrigin = null;\n\n for (;;) {\n event = source.pop();\n if (event.ranges) {\n pushSelectionToHistory(event, dest);\n if (allowSelectionOnly && !event.equals(doc.sel)) {\n setSelection(doc, event, {clearRedo: false});\n return;\n }\n selAfter = event;\n }\n else break;\n }\n\n // Build up a reverse change object to add to the opposite history\n // stack (redo when undoing, and vice versa).\n var antiChanges = [];\n pushSelectionToHistory(selAfter, dest);\n dest.push({changes: antiChanges, generation: hist.generation});\n hist.generation = event.generation || ++hist.maxGeneration;\n\n var filter = hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\");\n\n for (var i = event.changes.length - 1; i >= 0; --i) {\n var change = event.changes[i];\n change.origin = type;\n if (filter && !filterChange(doc, change, false)) {\n source.length = 0;\n return;\n }\n\n antiChanges.push(historyChangeFromChange(doc, change));\n\n var after = i ? computeSelAfterChange(doc, change, null) : lst(source);\n makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));\n if (!i && doc.cm) doc.cm.scrollIntoView(change);\n var rebased = [];\n\n // Propagate to the linked documents\n linkedDocs(doc, function(doc, sharedHist) {\n if (!sharedHist && indexOf(rebased, doc.history) == -1) {\n rebaseHist(doc.history, change);\n rebased.push(doc.history);\n }\n makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));\n });\n }\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 if (distance == 0) return;\n doc.first += distance;\n doc.sel = new Selection(map(doc.sel.ranges, function(range) {\n return new Range(Pos(range.anchor.line + distance, range.anchor.ch),\n Pos(range.head.line + distance, range.head.ch));\n }), doc.sel.primIndex);\n if (doc.cm) {\n regChange(doc.cm, doc.first, doc.first - distance, distance);\n for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)\n regLineChange(doc.cm, l, \"gutter\");\n }\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 if (doc.cm && !doc.cm.curOp)\n return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);\n\n if (change.to.line < doc.first) {\n shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));\n return;\n }\n if (change.from.line > doc.lastLine()) return;\n\n // Clip the change to the size of this doc\n if (change.from.line < doc.first) {\n var shift = change.text.length - 1 - (doc.first - change.from.line);\n shiftDoc(doc, shift);\n change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),\n text: [lst(change.text)], origin: change.origin};\n }\n var last = doc.lastLine();\n if (change.to.line > last) {\n change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),\n text: [change.text[0]], origin: change.origin};\n }\n\n change.removed = getBetween(doc, change.from, change.to);\n\n if (!selAfter) selAfter = computeSelAfterChange(doc, change, null);\n if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);\n else updateDoc(doc, change, spans);\n setSelectionNoUndo(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 var doc = cm.doc, display = cm.display, from = change.from, to = change.to;\n\n var recomputeMaxLength = false, checkWidthStart = from.line;\n if (!cm.options.lineWrapping) {\n checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));\n doc.iter(checkWidthStart, to.line + 1, function(line) {\n if (line == display.maxLine) {\n recomputeMaxLength = true;\n return true;\n }\n });\n }\n\n if (doc.sel.contains(change.from, change.to) > -1)\n signalCursorActivity(cm);\n\n updateDoc(doc, change, spans, estimateHeight(cm));\n\n if (!cm.options.lineWrapping) {\n doc.iter(checkWidthStart, from.line + change.text.length, function(line) {\n var len = lineLength(line);\n if (len > display.maxLineLength) {\n display.maxLine = line;\n display.maxLineLength = len;\n display.maxLineChanged = true;\n recomputeMaxLength = false;\n }\n });\n if (recomputeMaxLength) cm.curOp.updateMaxLine = true;\n }\n\n // Adjust frontier, schedule worker\n doc.frontier = Math.min(doc.frontier, from.line);\n startWorker(cm, 400);\n\n var lendiff = change.text.length - (to.line - from.line) - 1;\n // Remember that these lines changed, for updating the display\n if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))\n regLineChange(cm, from.line, \"text\");\n else\n regChange(cm, from.line, to.line + 1, lendiff);\n\n var changesHandler = hasHandler(cm, \"changes\"), changeHandler = hasHandler(cm, \"change\");\n if (changeHandler || changesHandler) {\n var obj = {\n from: from, to: to,\n text: change.text,\n removed: change.removed,\n origin: change.origin\n };\n if (changeHandler) signalLater(cm, \"change\", cm, obj);\n if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);\n }\n cm.display.selForContextMenu = null;\n }\n\n function replaceRange(doc, code, from, to, origin) {\n if (!to) to = from;\n if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }\n if (typeof code == \"string\") code = splitLines(code);\n makeChange(doc, {from: from, to: to, text: code, origin: origin});\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 var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;\n if (coords.top + box.top < 0) doScroll = true;\n else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;\n if (doScroll != null && !phantom) {\n var scrollNode = elt(\"div\", \"\\u200b\", null, \"position: absolute; top: \" +\n (coords.top - display.viewOffset - paddingTop(cm.display)) + \"px; height: \" +\n (coords.bottom - coords.top + scrollerCutOff) + \"px; left: \" +\n coords.left + \"px; width: 2px;\");\n cm.display.lineSpace.appendChild(scrollNode);\n scrollNode.scrollIntoView(doScroll);\n cm.display.lineSpace.removeChild(scrollNode);\n }\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 if (margin == null) margin = 0;\n for (;;) {\n var changed = false, coords = cursorCoords(cm, pos);\n var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);\n var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),\n Math.min(coords.top, endCoords.top) - margin,\n Math.max(coords.left, endCoords.left),\n Math.max(coords.bottom, endCoords.bottom) + margin);\n var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;\n if (scrollPos.scrollTop != null) {\n setScrollTop(cm, scrollPos.scrollTop);\n if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;\n }\n if (scrollPos.scrollLeft != null) {\n setScrollLeft(cm, scrollPos.scrollLeft);\n if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;\n }\n if (!changed) return coords;\n }\n }\n\n // Scroll a given set of coordinates into view (immediately).\n function scrollIntoView(cm, x1, y1, x2, y2) {\n var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);\n if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);\n if (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 var display = cm.display, snapMargin = textHeight(cm.display);\n if (y1 < 0) y1 = 0;\n var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;\n var screen = display.scroller.clientHeight - scrollerCutOff, result = {};\n var docBottom = cm.doc.height + paddingVert(display);\n var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;\n if (y1 < screentop) {\n result.scrollTop = atTop ? 0 : y1;\n } else if (y2 > screentop + screen) {\n var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);\n if (newTop != screentop) result.scrollTop = newTop;\n }\n\n var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;\n var screenw = display.scroller.clientWidth - scrollerCutOff;\n x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;\n var gutterw = display.gutters.offsetWidth;\n var atLeft = x1 < gutterw + 10;\n if (x1 < screenleft + gutterw || atLeft) {\n if (atLeft) x1 = 0;\n result.scrollLeft = Math.max(0, x1 - 10 - gutterw);\n } else if (x2 > screenw + screenleft - 3) {\n result.scrollLeft = x2 + 10 - screenw;\n }\n return 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 if (left != null || top != null) resolveScrollToPos(cm);\n if (left != null)\n cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;\n if (top != null)\n 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 resolveScrollToPos(cm);\n var cur = cm.getCursor(), from = cur, to = cur;\n if (!cm.options.lineWrapping) {\n from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;\n to = Pos(cur.line, cur.ch + 1);\n }\n cm.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 var range = cm.curOp.scrollToPos;\n if (range) {\n cm.curOp.scrollToPos = null;\n var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);\n var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),\n Math.min(from.top, to.top) - range.margin,\n Math.max(from.right, to.right),\n Math.max(from.bottom, to.bottom) + range.margin);\n cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);\n }\n }\n\n // API UTILITIES\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 var doc = cm.doc, state;\n if (how == null) how = \"add\";\n if (how == \"smart\") {\n // Fall back to \"prev\" when the mode doesn't have an indentation\n // method.\n if (!cm.doc.mode.indent) how = \"prev\";\n else state = getStateBefore(cm, n);\n }\n\n var tabSize = cm.options.tabSize;\n var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);\n if (line.stateAfter) line.stateAfter = null;\n var curSpaceString = line.text.match(/^\\s*/)[0], indentation;\n if (!aggressive && !/\\S/.test(line.text)) {\n indentation = 0;\n how = \"not\";\n } else if (how == \"smart\") {\n indentation = cm.doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);\n if (indentation == Pass) {\n if (!aggressive) return;\n how = \"prev\";\n }\n }\n if (how == \"prev\") {\n if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);\n else indentation = 0;\n } else if (how == \"add\") {\n indentation = curSpace + cm.options.indentUnit;\n } else if (how == \"subtract\") {\n indentation = curSpace - cm.options.indentUnit;\n } else if (typeof how == \"number\") {\n indentation = curSpace + how;\n }\n indentation = Math.max(0, indentation);\n\n var indentString = \"\", pos = 0;\n if (cm.options.indentWithTabs)\n for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += \"\\t\";}\n if (pos < indentation) indentString += spaceStr(indentation - pos);\n\n if (indentString != curSpaceString) {\n replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), \"+input\");\n } else {\n // Ensure that, if the cursor was in the whitespace at the start\n // of the line, it is moved to the end of that space.\n for (var i = 0; i < doc.sel.ranges.length; i++) {\n var range = doc.sel.ranges[i];\n if (range.head.line == n && range.head.ch < curSpaceString.length) {\n var pos = Pos(n, curSpaceString.length);\n replaceOneSelection(doc, i, new Range(pos, pos));\n break;\n }\n }\n }\n line.stateAfter = null;\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(cm, handle, changeType, op) {\n var no = handle, line = handle, doc = cm.doc;\n if (typeof handle == \"number\") line = getLine(doc, clipLine(doc, handle));\n else no = lineNo(handle);\n if (no == null) return null;\n if (op(line, no)) regLineChange(cm, no, changeType);\n return line;\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 var ranges = cm.doc.sel.ranges, kill = [];\n // Build up a set of ranges to kill first, merging overlapping\n // ranges.\n for (var i = 0; i < ranges.length; i++) {\n var toKill = compute(ranges[i]);\n while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {\n var replaced = kill.pop();\n if (cmp(replaced.from, toKill.from) < 0) {\n toKill.from = replaced.from;\n break;\n }\n }\n kill.push(toKill);\n }\n // Next, remove those actual ranges.\n runInOp(cm, function() {\n for (var i = kill.length - 1; i >= 0; i--)\n replaceRange(cm.doc, \"\", kill[i].from, kill[i].to, \"+delete\");\n ensureCursorVisible(cm);\n });\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 var line = pos.line, ch = pos.ch, origDir = dir;\n var lineObj = getLine(doc, line);\n var possible = true;\n function findNextLine() {\n var l = line + dir;\n if (l < doc.first || l >= doc.first + doc.size) return (possible = false);\n line = l;\n return lineObj = getLine(doc, l);\n }\n function moveOnce(boundToLine) {\n var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);\n if (next == null) {\n if (!boundToLine && findNextLine()) {\n if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);\n else ch = dir < 0 ? lineObj.text.length : 0;\n } else return (possible = false);\n } else ch = next;\n return true;\n }\n\n if (unit == \"char\") moveOnce();\n else if (unit == \"column\") moveOnce(true);\n else if (unit == \"word\" || unit == \"group\") {\n var sawType = null, group = unit == \"group\";\n var helper = doc.cm && doc.cm.getHelper(pos, \"wordChars\");\n for (var first = true;; first = false) {\n if (dir < 0 && !moveOnce(!first)) break;\n var cur = lineObj.text.charAt(ch) || \"\\n\";\n var type = isWordChar(cur, helper) ? \"w\"\n : group && cur == \"\\n\" ? \"n\"\n : !group || /\\s/.test(cur) ? null\n : \"p\";\n if (group && !first && !type) type = \"s\";\n if (sawType && sawType != type) {\n if (dir < 0) {dir = 1; moveOnce();}\n break;\n }\n\n if (type) sawType = type;\n if (dir > 0 && !moveOnce(!first)) break;\n }\n }\n var result = skipAtomic(doc, Pos(line, ch), origDir, true);\n if (!possible) result.hitSide = true;\n return 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 var doc = cm.doc, x = pos.left, y;\n if (unit == \"page\") {\n var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);\n y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));\n } else if (unit == \"line\") {\n y = dir > 0 ? pos.bottom + 3 : pos.top - 3;\n }\n for (;;) {\n var target = coordsChar(cm, x, y);\n if (!target.outside) break;\n if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }\n y += dir * 5;\n }\n return target;\n }\n\n // Find the word at the given position (as returned by coordsChar).\n function findWordAt(cm, pos) {\n var doc = cm.doc, line = getLine(doc, pos.line).text;\n var start = pos.ch, end = pos.ch;\n if (line) {\n var helper = cm.getHelper(pos, \"wordChars\");\n if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;\n var startChar = line.charAt(start);\n var check = isWordChar(startChar, helper)\n ? function(ch) { return isWordChar(ch, helper); }\n : /\\s/.test(startChar) ? function(ch) {return /\\s/.test(ch);}\n : function(ch) {return !/\\s/.test(ch) && !isWordChar(ch);};\n while (start > 0 && check(line.charAt(start - 1))) --start;\n while (end < line.length && check(line.charAt(end))) ++end;\n }\n return new Range(Pos(pos.line, start), Pos(pos.line, end));\n }\n\n // EDITOR METHODS\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 CodeMirror.prototype = {\n constructor: CodeMirror,\n focus: function(){window.focus(); focusInput(this); fastPoll(this);},\n\n setOption: function(option, value) {\n var options = this.options, old = options[option];\n if (options[option] == value && option != \"mode\") return;\n options[option] = value;\n if (optionHandlers.hasOwnProperty(option))\n operation(this, optionHandlers[option])(this, value, old);\n },\n\n getOption: function(option) {return this.options[option];},\n getDoc: function() {return this.doc;},\n\n addKeyMap: function(map, bottom) {\n this.state.keyMaps[bottom ? \"push\" : \"unshift\"](map);\n },\n removeKeyMap: function(map) {\n var maps = this.state.keyMaps;\n for (var i = 0; i < maps.length; ++i)\n if (maps[i] == map || (typeof maps[i] != \"string\" && maps[i].name == map)) {\n maps.splice(i, 1);\n return true;\n }\n },\n\n addOverlay: methodOp(function(spec, options) {\n var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);\n if (mode.startState) throw new Error(\"Overlays may not be stateful.\");\n this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});\n this.state.modeGen++;\n regChange(this);\n }),\n removeOverlay: methodOp(function(spec) {\n var overlays = this.state.overlays;\n for (var i = 0; i < overlays.length; ++i) {\n var cur = overlays[i].modeSpec;\n if (cur == spec || typeof spec == \"string\" && cur.name == spec) {\n overlays.splice(i, 1);\n this.state.modeGen++;\n regChange(this);\n return;\n }\n }\n }),\n\n indentLine: methodOp(function(n, dir, aggressive) {\n if (typeof dir != \"string\" && typeof dir != \"number\") {\n if (dir == null) dir = this.options.smartIndent ? \"smart\" : \"prev\";\n else dir = dir ? \"add\" : \"subtract\";\n }\n if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);\n }),\n indentSelection: methodOp(function(how) {\n var ranges = this.doc.sel.ranges, end = -1;\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n if (!range.empty()) {\n var start = Math.max(end, range.from().line);\n var to = range.to();\n end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;\n for (var j = start; j < end; ++j)\n indentLine(this, j, how);\n } else if (range.head.line > end) {\n indentLine(this, range.head.line, how, true);\n end = range.head.line;\n if (i == this.doc.sel.primIndex) ensureCursorVisible(this);\n }\n }\n }),\n\n // Fetch the parser token for a given character. Useful for hacks\n // that want to inspect the mode state (say, for completion).\n getTokenAt: function(pos, precise) {\n var doc = this.doc;\n pos = clipPos(doc, pos);\n var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode;\n var line = getLine(doc, pos.line);\n var stream = new StringStream(line.text, this.options.tabSize);\n while (stream.pos < pos.ch && !stream.eol()) {\n stream.start = stream.pos;\n var style = readToken(mode, stream, state);\n }\n return {start: stream.start,\n end: stream.pos,\n string: stream.current(),\n type: style || null,\n state: state};\n },\n\n getTokenTypeAt: function(pos) {\n pos = clipPos(this.doc, pos);\n var styles = getLineStyles(this, getLine(this.doc, pos.line));\n var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;\n var type;\n if (ch == 0) type = styles[2];\n else for (;;) {\n var mid = (before + after) >> 1;\n if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;\n else if (styles[mid * 2 + 1] < ch) before = mid + 1;\n else { type = styles[mid * 2 + 2]; break; }\n }\n var cut = type ? type.indexOf(\"cm-overlay \") : -1;\n return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);\n },\n\n getModeAt: function(pos) {\n var mode = this.doc.mode;\n if (!mode.innerMode) return mode;\n return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;\n },\n\n getHelper: function(pos, type) {\n return this.getHelpers(pos, type)[0];\n },\n\n getHelpers: function(pos, type) {\n var found = [];\n if (!helpers.hasOwnProperty(type)) return helpers;\n var help = helpers[type], mode = this.getModeAt(pos);\n if (typeof mode[type] == \"string\") {\n if (help[mode[type]]) found.push(help[mode[type]]);\n } else if (mode[type]) {\n for (var i = 0; i < mode[type].length; i++) {\n var val = help[mode[type][i]];\n if (val) found.push(val);\n }\n } else if (mode.helperType && help[mode.helperType]) {\n found.push(help[mode.helperType]);\n } else if (help[mode.name]) {\n found.push(help[mode.name]);\n }\n for (var i = 0; i < help._global.length; i++) {\n var cur = help._global[i];\n if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)\n found.push(cur.val);\n }\n return found;\n },\n\n getStateAfter: function(line, precise) {\n var doc = this.doc;\n line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);\n return getStateBefore(this, line + 1, precise);\n },\n\n cursorCoords: function(start, mode) {\n var pos, range = this.doc.sel.primary();\n if (start == null) pos = range.head;\n else if (typeof start == \"object\") pos = clipPos(this.doc, start);\n else pos = start ? range.from() : range.to();\n return cursorCoords(this, pos, mode || \"page\");\n },\n\n charCoords: function(pos, mode) {\n return charCoords(this, clipPos(this.doc, pos), mode || \"page\");\n },\n\n coordsChar: function(coords, mode) {\n coords = fromCoordSystem(this, coords, mode || \"page\");\n return coordsChar(this, coords.left, coords.top);\n },\n\n lineAtHeight: function(height, mode) {\n height = fromCoordSystem(this, {top: height, left: 0}, mode || \"page\").top;\n return lineAtHeight(this.doc, height + this.display.viewOffset);\n },\n heightAtLine: function(line, mode) {\n var end = false, last = this.doc.first + this.doc.size - 1;\n if (line < this.doc.first) line = this.doc.first;\n else if (line > last) { line = last; end = true; }\n var lineObj = getLine(this.doc, line);\n return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || \"page\").top +\n (end ? this.doc.height - heightAtLine(lineObj) : 0);\n },\n\n defaultTextHeight: function() { return textHeight(this.display); },\n defaultCharWidth: function() { return charWidth(this.display); },\n\n setGutterMarker: methodOp(function(line, gutterID, value) {\n return changeLine(this, line, \"gutter\", function(line) {\n var markers = line.gutterMarkers || (line.gutterMarkers = {});\n markers[gutterID] = value;\n if (!value && isEmpty(markers)) line.gutterMarkers = null;\n return true;\n });\n }),\n\n clearGutter: methodOp(function(gutterID) {\n var cm = this, doc = cm.doc, i = doc.first;\n doc.iter(function(line) {\n if (line.gutterMarkers && line.gutterMarkers[gutterID]) {\n line.gutterMarkers[gutterID] = null;\n regLineChange(cm, i, \"gutter\");\n if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;\n }\n ++i;\n });\n }),\n\n addLineClass: methodOp(function(handle, where, cls) {\n return changeLine(this, handle, \"class\", function(line) {\n var prop = where == \"text\" ? \"textClass\" : where == \"background\" ? \"bgClass\" : \"wrapClass\";\n if (!line[prop]) line[prop] = cls;\n else if (new RegExp(\"(?:^|\\\\s)\" + cls + \"(?:$|\\\\s)\").test(line[prop])) return false;\n else line[prop] += \" \" + cls;\n return true;\n });\n }),\n\n removeLineClass: methodOp(function(handle, where, cls) {\n return changeLine(this, handle, \"class\", function(line) {\n var prop = where == \"text\" ? \"textClass\" : where == \"background\" ? \"bgClass\" : \"wrapClass\";\n var cur = line[prop];\n if (!cur) return false;\n else if (cls == null) line[prop] = null;\n else {\n var found = cur.match(new RegExp(\"(?:^|\\\\s+)\" + cls + \"(?:$|\\\\s+)\"));\n if (!found) return false;\n var end = found.index + found[0].length;\n line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? \"\" : \" \") + cur.slice(end) || null;\n }\n return true;\n });\n }),\n\n addLineWidget: methodOp(function(handle, node, options) {\n return addLineWidget(this, handle, node, options);\n }),\n\n removeLineWidget: function(widget) { widget.clear(); },\n\n lineInfo: function(line) {\n if (typeof line == \"number\") {\n if (!isLine(this.doc, line)) return null;\n var n = line;\n line = getLine(this.doc, line);\n if (!line) return null;\n } else {\n var n = lineNo(line);\n if (n == null) return null;\n }\n return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,\n textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,\n widgets: line.widgets};\n },\n\n getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},\n\n addWidget: function(pos, node, scroll, vert, horiz) {\n var display = this.display;\n pos = cursorCoords(this, clipPos(this.doc, pos));\n var top = pos.bottom, left = pos.left;\n node.style.position = \"absolute\";\n display.sizer.appendChild(node);\n if (vert == \"over\") {\n top = pos.top;\n } else if (vert == \"above\" || vert == \"near\") {\n var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),\n hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);\n // Default to positioning above (if specified and possible); otherwise default to positioning below\n if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)\n top = pos.top - node.offsetHeight;\n else if (pos.bottom + node.offsetHeight <= vspace)\n top = pos.bottom;\n if (left + node.offsetWidth > hspace)\n left = hspace - node.offsetWidth;\n }\n node.style.top = top + \"px\";\n node.style.left = node.style.right = \"\";\n if (horiz == \"right\") {\n left = display.sizer.clientWidth - node.offsetWidth;\n node.style.right = \"0px\";\n } else {\n if (horiz == \"left\") left = 0;\n else if (horiz == \"middle\") left = (display.sizer.clientWidth - node.offsetWidth) / 2;\n node.style.left = left + \"px\";\n }\n if (scroll)\n scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);\n },\n\n triggerOnKeyDown: methodOp(onKeyDown),\n triggerOnKeyPress: methodOp(onKeyPress),\n triggerOnKeyUp: methodOp(onKeyUp),\n\n execCommand: function(cmd) {\n if (commands.hasOwnProperty(cmd))\n return commands[cmd](this);\n },\n\n findPosH: function(from, amount, unit, visually) {\n var dir = 1;\n if (amount < 0) { dir = -1; amount = -amount; }\n for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {\n cur = findPosH(this.doc, cur, dir, unit, visually);\n if (cur.hitSide) break;\n }\n return cur;\n },\n\n moveH: methodOp(function(dir, unit) {\n var cm = this;\n cm.extendSelectionsBy(function(range) {\n if (cm.display.shift || cm.doc.extend || range.empty())\n return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);\n else\n return dir < 0 ? range.from() : range.to();\n }, sel_move);\n }),\n\n deleteH: methodOp(function(dir, unit) {\n var sel = this.doc.sel, doc = this.doc;\n if (sel.somethingSelected())\n doc.replaceSelection(\"\", null, \"+delete\");\n else\n deleteNearSelection(this, function(range) {\n var other = findPosH(doc, range.head, dir, unit, false);\n return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};\n });\n }),\n\n findPosV: function(from, amount, unit, goalColumn) {\n var dir = 1, x = goalColumn;\n if (amount < 0) { dir = -1; amount = -amount; }\n for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {\n var coords = cursorCoords(this, cur, \"div\");\n if (x == null) x = coords.left;\n else coords.left = x;\n cur = findPosV(this, coords, dir, unit);\n if (cur.hitSide) break;\n }\n return cur;\n },\n\n moveV: methodOp(function(dir, unit) {\n var cm = this, doc = this.doc, goals = [];\n var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();\n doc.extendSelectionsBy(function(range) {\n if (collapse)\n return dir < 0 ? range.from() : range.to();\n var headPos = cursorCoords(cm, range.head, \"div\");\n if (range.goalColumn != null) headPos.left = range.goalColumn;\n goals.push(headPos.left);\n var pos = findPosV(cm, headPos, dir, unit);\n if (unit == \"page\" && range == doc.sel.primary())\n addToScrollPos(cm, null, charCoords(cm, pos, \"div\").top - headPos.top);\n return pos;\n }, sel_move);\n if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)\n doc.sel.ranges[i].goalColumn = goals[i];\n }),\n\n toggleOverwrite: function(value) {\n if (value != null && value == this.state.overwrite) return;\n if (this.state.overwrite = !this.state.overwrite)\n addClass(this.display.cursorDiv, \"CodeMirror-overwrite\");\n else\n rmClass(this.display.cursorDiv, \"CodeMirror-overwrite\");\n\n signal(this, \"overwriteToggle\", this, this.state.overwrite);\n },\n hasFocus: function() { return activeElt() == this.display.input; },\n\n scrollTo: methodOp(function(x, y) {\n if (x != null || y != null) resolveScrollToPos(this);\n if (x != null) this.curOp.scrollLeft = x;\n if (y != null) this.curOp.scrollTop = y;\n }),\n getScrollInfo: function() {\n var scroller = this.display.scroller, co = scrollerCutOff;\n return {left: scroller.scrollLeft, top: scroller.scrollTop,\n height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,\n clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};\n },\n\n scrollIntoView: methodOp(function(range, margin) {\n if (range == null) {\n range = {from: this.doc.sel.primary().head, to: null};\n if (margin == null) margin = this.options.cursorScrollMargin;\n } else if (typeof range == \"number\") {\n range = {from: Pos(range, 0), to: null};\n } else if (range.from == null) {\n range = {from: range, to: null};\n }\n if (!range.to) range.to = range.from;\n range.margin = margin || 0;\n\n if (range.from.line != null) {\n resolveScrollToPos(this);\n this.curOp.scrollToPos = range;\n } else {\n var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),\n Math.min(range.from.top, range.to.top) - range.margin,\n Math.max(range.from.right, range.to.right),\n Math.max(range.from.bottom, range.to.bottom) + range.margin);\n this.scrollTo(sPos.scrollLeft, sPos.scrollTop);\n }\n }),\n\n setSize: methodOp(function(width, height) {\n function interpret(val) {\n return typeof val == \"number\" || /^\\d+$/.test(String(val)) ? val + \"px\" : val;\n }\n if (width != null) this.display.wrapper.style.width = interpret(width);\n if (height != null) this.display.wrapper.style.height = interpret(height);\n if (this.options.lineWrapping) clearLineMeasurementCache(this);\n this.curOp.forceUpdate = true;\n signal(this, \"refresh\", this);\n }),\n\n operation: function(f){return runInOp(this, f);},\n\n refresh: methodOp(function() {\n var oldHeight = this.display.cachedTextHeight;\n regChange(this);\n this.curOp.forceUpdate = true;\n clearCaches(this);\n this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);\n updateGutterSpace(this);\n if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)\n estimateLineHeights(this);\n signal(this, \"refresh\", this);\n }),\n\n swapDoc: methodOp(function(doc) {\n var old = this.doc;\n old.cm = null;\n attachDoc(this, doc);\n clearCaches(this);\n resetInput(this);\n this.scrollTo(doc.scrollLeft, doc.scrollTop);\n signalLater(this, \"swapDoc\", this, old);\n return old;\n }),\n\n getInputField: function(){return this.display.input;},\n getWrapperElement: function(){return this.display.wrapper;},\n getScrollerElement: function(){return this.display.scroller;},\n getGutterElement: function(){return this.display.gutters;}\n };\n eventMixin(CodeMirror);\n\n // OPTION DEFAULTS\n\n // The default configuration options.\n var defaults = CodeMirror.defaults = {};\n // Functions to run when options are changed.\n var optionHandlers = CodeMirror.optionHandlers = {};\n\n function option(name, deflt, handle, notOnInit) {\n CodeMirror.defaults[name] = deflt;\n if (handle) optionHandlers[name] =\n notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;\n }\n\n // Passed to option handlers when there is no old value.\n var Init = CodeMirror.Init = {toString: function(){return \"CodeMirror.Init\";}};\n\n // These two are, on init, called from the constructor because they\n // have to be initialized before the editor can start at all.\n option(\"value\", \"\", function(cm, val) {\n cm.setValue(val);\n }, true);\n option(\"mode\", null, function(cm, val) {\n cm.doc.modeOption = val;\n loadMode(cm);\n }, true);\n\n option(\"indentUnit\", 2, loadMode, true);\n option(\"indentWithTabs\", false);\n option(\"smartIndent\", true);\n option(\"tabSize\", 4, function(cm) {\n resetModeState(cm);\n clearCaches(cm);\n regChange(cm);\n }, true);\n option(\"specialChars\", /[\\t\\u0000-\\u0019\\u00ad\\u200b\\u2028\\u2029\\ufeff]/g, function(cm, val) {\n cm.options.specialChars = new RegExp(val.source + (val.test(\"\\t\") ? \"\" : \"|\\t\"), \"g\");\n cm.refresh();\n }, true);\n option(\"specialCharPlaceholder\", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);\n option(\"electricChars\", true);\n option(\"rtlMoveVisually\", !windows);\n option(\"wholeLineUpdateBefore\", true);\n\n option(\"theme\", \"default\", function(cm) {\n themeChanged(cm);\n guttersChanged(cm);\n }, true);\n option(\"keyMap\", \"default\", keyMapChanged);\n option(\"extraKeys\", null);\n\n option(\"lineWrapping\", false, wrappingChanged, true);\n option(\"gutters\", [], function(cm) {\n setGuttersForLineNumbers(cm.options);\n guttersChanged(cm);\n }, true);\n option(\"fixedGutter\", true, function(cm, val) {\n cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + \"px\" : \"0\";\n cm.refresh();\n }, true);\n option(\"coverGutterNextToScrollbar\", false, updateScrollbars, true);\n option(\"lineNumbers\", false, function(cm) {\n setGuttersForLineNumbers(cm.options);\n guttersChanged(cm);\n }, true);\n option(\"firstLineNumber\", 1, guttersChanged, true);\n option(\"lineNumberFormatter\", function(integer) {return integer;}, guttersChanged, true);\n option(\"showCursorWhenSelecting\", false, updateSelection, true);\n\n option(\"resetSelectionOnContextMenu\", true);\n\n option(\"readOnly\", false, function(cm, val) {\n if (val == \"nocursor\") {\n onBlur(cm);\n cm.display.input.blur();\n cm.display.disabled = true;\n } else {\n cm.display.disabled = false;\n if (!val) resetInput(cm);\n }\n });\n option(\"disableInput\", false, function(cm, val) {if (!val) resetInput(cm);}, true);\n option(\"dragDrop\", true);\n\n option(\"cursorBlinkRate\", 530);\n option(\"cursorScrollMargin\", 0);\n option(\"cursorHeight\", 1);\n option(\"workTime\", 100);\n option(\"workDelay\", 100);\n option(\"flattenSpans\", true, resetModeState, true);\n option(\"addModeClass\", false, resetModeState, true);\n option(\"pollInterval\", 100);\n option(\"undoDepth\", 200, function(cm, val){cm.doc.history.undoDepth = val;});\n option(\"historyEventDelay\", 1250);\n option(\"viewportMargin\", 10, function(cm){cm.refresh();}, true);\n option(\"maxHighlightLength\", 10000, resetModeState, true);\n option(\"moveInputWithCursor\", true, function(cm, val) {\n if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;\n });\n\n option(\"tabindex\", null, function(cm, val) {\n cm.display.input.tabIndex = val || \"\";\n });\n option(\"autofocus\", null);\n\n // MODE DEFINITION AND QUERYING\n\n // Known modes, by name and by MIME\n var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};\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 if (!CodeMirror.defaults.mode && name != \"null\") CodeMirror.defaults.mode = name;\n if (arguments.length > 2) {\n mode.dependencies = [];\n for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);\n }\n modes[name] = mode;\n };\n\n CodeMirror.defineMIME = function(mime, spec) {\n mimeModes[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 CodeMirror.resolveMode = function(spec) {\n if (typeof spec == \"string\" && mimeModes.hasOwnProperty(spec)) {\n spec = mimeModes[spec];\n } else if (spec && typeof spec.name == \"string\" && mimeModes.hasOwnProperty(spec.name)) {\n var found = mimeModes[spec.name];\n if (typeof found == \"string\") found = {name: found};\n spec = createObj(found, spec);\n spec.name = found.name;\n } else if (typeof spec == \"string\" && /^[\\w\\-]+\\/[\\w\\-]+\\+xml$/.test(spec)) {\n return CodeMirror.resolveMode(\"application/xml\");\n }\n if (typeof spec == \"string\") return {name: spec};\n else return spec || {name: \"null\"};\n };\n\n // Given a mode spec (anything that resolveMode accepts), find and\n // initialize an actual mode object.\n CodeMirror.getMode = function(options, spec) {\n var spec = CodeMirror.resolveMode(spec);\n var mfactory = modes[spec.name];\n if (!mfactory) return CodeMirror.getMode(options, \"text/plain\");\n var modeObj = mfactory(options, spec);\n if (modeExtensions.hasOwnProperty(spec.name)) {\n var exts = modeExtensions[spec.name];\n for (var prop in exts) {\n if (!exts.hasOwnProperty(prop)) continue;\n if (modeObj.hasOwnProperty(prop)) modeObj[\"_\" + prop] = modeObj[prop];\n modeObj[prop] = exts[prop];\n }\n }\n modeObj.name = spec.name;\n if (spec.helperType) modeObj.helperType = spec.helperType;\n if (spec.modeProps) for (var prop in spec.modeProps)\n modeObj[prop] = spec.modeProps[prop];\n\n return modeObj;\n };\n\n // Minimal default mode.\n CodeMirror.defineMode(\"null\", function() {\n return {token: function(stream) {stream.skipToEnd();}};\n });\n CodeMirror.defineMIME(\"text/plain\", \"null\");\n\n // This can be used to attach properties to mode objects from\n // outside the actual mode definition.\n var modeExtensions = CodeMirror.modeExtensions = {};\n CodeMirror.extendMode = function(mode, properties) {\n var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});\n copyObj(properties, exts);\n };\n\n // EXTENSIONS\n\n CodeMirror.defineExtension = function(name, func) {\n CodeMirror.prototype[name] = func;\n };\n CodeMirror.defineDocExtension = function(name, func) {\n Doc.prototype[name] = func;\n };\n CodeMirror.defineOption = option;\n\n var initHooks = [];\n CodeMirror.defineInitHook = function(f) {initHooks.push(f);};\n\n var helpers = CodeMirror.helpers = {};\n CodeMirror.registerHelper = function(type, name, value) {\n if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};\n helpers[type][name] = value;\n };\n CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {\n CodeMirror.registerHelper(type, name, value);\n helpers[type]._global.push({pred: predicate, val: value});\n };\n\n // MODE STATE HANDLING\n\n // Utility functions for working with state. Exported because nested\n // modes need to do this for their inner modes.\n\n var copyState = CodeMirror.copyState = function(mode, state) {\n if (state === true) return state;\n if (mode.copyState) return mode.copyState(state);\n var nstate = {};\n for (var n in state) {\n var val = state[n];\n if (val instanceof Array) val = val.concat([]);\n nstate[n] = val;\n }\n return nstate;\n };\n\n var startState = CodeMirror.startState = function(mode, a1, a2) {\n return mode.startState ? mode.startState(a1, a2) : true;\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 CodeMirror.innerMode = function(mode, state) {\n while (mode.innerMode) {\n var info = mode.innerMode(state);\n if (!info || info.mode == mode) break;\n state = info.state;\n mode = info.mode;\n }\n return info || {mode: mode, state: state};\n };\n\n // STANDARD COMMANDS\n\n // Commands are parameter-less actions that can be performed on an\n // editor, mostly used for keybindings.\n var commands = CodeMirror.commands = {\n selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},\n singleSelection: function(cm) {\n cm.setSelection(cm.getCursor(\"anchor\"), cm.getCursor(\"head\"), sel_dontScroll);\n },\n killLine: function(cm) {\n deleteNearSelection(cm, function(range) {\n if (range.empty()) {\n var len = getLine(cm.doc, range.head.line).text.length;\n if (range.head.ch == len && range.head.line < cm.lastLine())\n return {from: range.head, to: Pos(range.head.line + 1, 0)};\n else\n return {from: range.head, to: Pos(range.head.line, len)};\n } else {\n return {from: range.from(), to: range.to()};\n }\n });\n },\n deleteLine: function(cm) {\n deleteNearSelection(cm, function(range) {\n return {from: Pos(range.from().line, 0),\n to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};\n });\n },\n delLineLeft: function(cm) {\n deleteNearSelection(cm, function(range) {\n return {from: Pos(range.from().line, 0), to: range.from()};\n });\n },\n undo: function(cm) {cm.undo();},\n redo: function(cm) {cm.redo();},\n undoSelection: function(cm) {cm.undoSelection();},\n redoSelection: function(cm) {cm.redoSelection();},\n goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},\n goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},\n goLineStart: function(cm) {\n cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, sel_move);\n },\n goLineStartSmart: function(cm) {\n cm.extendSelectionsBy(function(range) {\n var start = lineStart(cm, range.head.line);\n var line = cm.getLineHandle(start.line);\n var order = getOrder(line);\n if (!order || order[0].level == 0) {\n var firstNonWS = Math.max(0, line.text.search(/\\S/));\n var inWS = range.head.line == start.line && range.head.ch <= firstNonWS && range.head.ch;\n return Pos(start.line, inWS ? 0 : firstNonWS);\n }\n return start;\n }, sel_move);\n },\n goLineEnd: function(cm) {\n cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, sel_move);\n },\n goLineRight: function(cm) {\n cm.extendSelectionsBy(function(range) {\n var top = cm.charCoords(range.head, \"div\").top + 5;\n return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, \"div\");\n }, sel_move);\n },\n goLineLeft: function(cm) {\n cm.extendSelectionsBy(function(range) {\n var top = cm.charCoords(range.head, \"div\").top + 5;\n return cm.coordsChar({left: 0, top: top}, \"div\");\n }, sel_move);\n },\n goLineUp: function(cm) {cm.moveV(-1, \"line\");},\n goLineDown: function(cm) {cm.moveV(1, \"line\");},\n goPageUp: function(cm) {cm.moveV(-1, \"page\");},\n goPageDown: function(cm) {cm.moveV(1, \"page\");},\n goCharLeft: function(cm) {cm.moveH(-1, \"char\");},\n goCharRight: function(cm) {cm.moveH(1, \"char\");},\n goColumnLeft: function(cm) {cm.moveH(-1, \"column\");},\n goColumnRight: function(cm) {cm.moveH(1, \"column\");},\n goWordLeft: function(cm) {cm.moveH(-1, \"word\");},\n goGroupRight: function(cm) {cm.moveH(1, \"group\");},\n goGroupLeft: function(cm) {cm.moveH(-1, \"group\");},\n goWordRight: function(cm) {cm.moveH(1, \"word\");},\n delCharBefore: function(cm) {cm.deleteH(-1, \"char\");},\n delCharAfter: function(cm) {cm.deleteH(1, \"char\");},\n delWordBefore: function(cm) {cm.deleteH(-1, \"word\");},\n delWordAfter: function(cm) {cm.deleteH(1, \"word\");},\n delGroupBefore: function(cm) {cm.deleteH(-1, \"group\");},\n delGroupAfter: function(cm) {cm.deleteH(1, \"group\");},\n indentAuto: function(cm) {cm.indentSelection(\"smart\");},\n indentMore: function(cm) {cm.indentSelection(\"add\");},\n indentLess: function(cm) {cm.indentSelection(\"subtract\");},\n insertTab: function(cm) {cm.replaceSelection(\"\\t\");},\n insertSoftTab: function(cm) {\n var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;\n for (var i = 0; i < ranges.length; i++) {\n var pos = ranges[i].from();\n var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);\n spaces.push(new Array(tabSize - col % tabSize + 1).join(\" \"));\n }\n cm.replaceSelections(spaces);\n },\n defaultTab: function(cm) {\n if (cm.somethingSelected()) cm.indentSelection(\"add\");\n else cm.execCommand(\"insertTab\");\n },\n transposeChars: function(cm) {\n runInOp(cm, function() {\n var ranges = cm.listSelections(), newSel = [];\n for (var i = 0; i < ranges.length; i++) {\n var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;\n if (line) {\n if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);\n if (cur.ch > 0) {\n cur = new Pos(cur.line, cur.ch + 1);\n cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),\n Pos(cur.line, cur.ch - 2), cur, \"+transpose\");\n } else if (cur.line > cm.doc.first) {\n var prev = getLine(cm.doc, cur.line - 1).text;\n if (prev)\n cm.replaceRange(line.charAt(0) + \"\\n\" + prev.charAt(prev.length - 1),\n Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), \"+transpose\");\n }\n }\n newSel.push(new Range(cur, cur));\n }\n cm.setSelections(newSel);\n });\n },\n newlineAndIndent: function(cm) {\n runInOp(cm, function() {\n var len = cm.listSelections().length;\n for (var i = 0; i < len; i++) {\n var range = cm.listSelections()[i];\n cm.replaceRange(\"\\n\", range.anchor, range.head, \"+input\");\n cm.indentLine(range.from().line + 1, null, true);\n ensureCursorVisible(cm);\n }\n });\n },\n toggleOverwrite: function(cm) {cm.toggleOverwrite();}\n };\n\n // STANDARD KEYMAPS\n\n var keyMap = CodeMirror.keyMap = {};\n keyMap.basic = {\n \"Left\": \"goCharLeft\", \"Right\": \"goCharRight\", \"Up\": \"goLineUp\", \"Down\": \"goLineDown\",\n \"End\": \"goLineEnd\", \"Home\": \"goLineStartSmart\", \"PageUp\": \"goPageUp\", \"PageDown\": \"goPageDown\",\n \"Delete\": \"delCharAfter\", \"Backspace\": \"delCharBefore\", \"Shift-Backspace\": \"delCharBefore\",\n \"Tab\": \"defaultTab\", \"Shift-Tab\": \"indentAuto\",\n \"Enter\": \"newlineAndIndent\", \"Insert\": \"toggleOverwrite\",\n \"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 \"Ctrl-A\": \"selectAll\", \"Ctrl-D\": \"deleteLine\", \"Ctrl-Z\": \"undo\", \"Shift-Ctrl-Z\": \"redo\", \"Ctrl-Y\": \"redo\",\n \"Ctrl-Home\": \"goDocStart\", \"Ctrl-Up\": \"goDocStart\", \"Ctrl-End\": \"goDocEnd\", \"Ctrl-Down\": \"goDocEnd\",\n \"Ctrl-Left\": \"goGroupLeft\", \"Ctrl-Right\": \"goGroupRight\", \"Alt-Left\": \"goLineStart\", \"Alt-Right\": \"goLineEnd\",\n \"Ctrl-Backspace\": \"delGroupBefore\", \"Ctrl-Delete\": \"delGroupAfter\", \"Ctrl-S\": \"save\", \"Ctrl-F\": \"find\",\n \"Ctrl-G\": \"findNext\", \"Shift-Ctrl-G\": \"findPrev\", \"Shift-Ctrl-F\": \"replace\", \"Shift-Ctrl-R\": \"replaceAll\",\n \"Ctrl-[\": \"indentLess\", \"Ctrl-]\": \"indentMore\",\n \"Ctrl-U\": \"undoSelection\", \"Shift-Ctrl-U\": \"redoSelection\", \"Alt-U\": \"redoSelection\",\n fallthrough: \"basic\"\n };\n keyMap.macDefault = {\n \"Cmd-A\": \"selectAll\", \"Cmd-D\": \"deleteLine\", \"Cmd-Z\": \"undo\", \"Shift-Cmd-Z\": \"redo\", \"Cmd-Y\": \"redo\",\n \"Cmd-Up\": \"goDocStart\", \"Cmd-End\": \"goDocEnd\", \"Cmd-Down\": \"goDocEnd\", \"Alt-Left\": \"goGroupLeft\",\n \"Alt-Right\": \"goGroupRight\", \"Cmd-Left\": \"goLineStart\", \"Cmd-Right\": \"goLineEnd\", \"Alt-Backspace\": \"delGroupBefore\",\n \"Ctrl-Alt-Backspace\": \"delGroupAfter\", \"Alt-Delete\": \"delGroupAfter\", \"Cmd-S\": \"save\", \"Cmd-F\": \"find\",\n \"Cmd-G\": \"findNext\", \"Shift-Cmd-G\": \"findPrev\", \"Cmd-Alt-F\": \"replace\", \"Shift-Cmd-Alt-F\": \"replaceAll\",\n \"Cmd-[\": \"indentLess\", \"Cmd-]\": \"indentMore\", \"Cmd-Backspace\": \"delLineLeft\",\n \"Cmd-U\": \"undoSelection\", \"Shift-Cmd-U\": \"redoSelection\",\n fallthrough: [\"basic\", \"emacsy\"]\n };\n // Very basic readline/emacs-style bindings, which are standard on Mac.\n keyMap.emacsy = {\n \"Ctrl-F\": \"goCharRight\", \"Ctrl-B\": \"goCharLeft\", \"Ctrl-P\": \"goLineUp\", \"Ctrl-N\": \"goLineDown\",\n \"Alt-F\": \"goWordRight\", \"Alt-B\": \"goWordLeft\", \"Ctrl-A\": \"goLineStart\", \"Ctrl-E\": \"goLineEnd\",\n \"Ctrl-V\": \"goPageDown\", \"Shift-Ctrl-V\": \"goPageUp\", \"Ctrl-D\": \"delCharAfter\", \"Ctrl-H\": \"delCharBefore\",\n \"Alt-D\": \"delWordAfter\", \"Alt-Backspace\": \"delWordBefore\", \"Ctrl-K\": \"killLine\", \"Ctrl-T\": \"transposeChars\"\n };\n keyMap[\"default\"] = mac ? keyMap.macDefault : keyMap.pcDefault;\n\n // KEYMAP DISPATCH\n\n function getKeyMap(val) {\n if (typeof val == \"string\") return keyMap[val];\n else return val;\n }\n\n // Given an array of keymaps and a key name, call handle on any\n // bindings found, until that returns a truthy value, at which point\n // we consider the key handled. Implements things like binding a key\n // to false stopping further handling and keymap fallthrough.\n var lookupKey = CodeMirror.lookupKey = function(name, maps, handle) {\n function lookup(map) {\n map = getKeyMap(map);\n var found = map[name];\n if (found === false) return \"stop\";\n if (found != null && handle(found)) return true;\n if (map.nofallthrough) return \"stop\";\n\n var fallthrough = map.fallthrough;\n if (fallthrough == null) return false;\n if (Object.prototype.toString.call(fallthrough) != \"[object Array]\")\n return lookup(fallthrough);\n for (var i = 0; i < fallthrough.length; ++i) {\n var done = lookup(fallthrough[i]);\n if (done) return done;\n }\n return false;\n }\n\n for (var i = 0; i < maps.length; ++i) {\n var done = lookup(maps[i]);\n if (done) return done != \"stop\";\n }\n };\n\n // Modifier key presses don't count as 'real' key presses for the\n // purpose of keymap fallthrough.\n var isModifierKey = CodeMirror.isModifierKey = function(event) {\n var name = keyNames[event.keyCode];\n return 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 var keyName = CodeMirror.keyName = function(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) return false;\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) return false;\n if (event.altKey) name = \"Alt-\" + name;\n if (flipCtrlCmd ? event.metaKey : event.ctrlKey) name = \"Ctrl-\" + name;\n if (flipCtrlCmd ? event.ctrlKey : event.metaKey) name = \"Cmd-\" + name;\n if (!noShift && event.shiftKey) name = \"Shift-\" + name;\n return name;\n };\n\n // FROMTEXTAREA\n\n CodeMirror.fromTextArea = function(textarea, options) {\n if (!options) options = {};\n options.value = textarea.value;\n if (!options.tabindex && textarea.tabindex)\n options.tabindex = textarea.tabindex;\n if (!options.placeholder && textarea.placeholder)\n options.placeholder = textarea.placeholder;\n // Set autofocus to true if this textarea is focused, or if it has\n // autofocus and no other element is focused.\n if (options.autofocus == null) {\n var hasFocus = activeElt();\n options.autofocus = hasFocus == textarea ||\n textarea.getAttribute(\"autofocus\") != null && hasFocus == document.body;\n }\n\n function save() {textarea.value = cm.getValue();}\n if (textarea.form) {\n on(textarea.form, \"submit\", save);\n // Deplorable hack to make the submit method do the right thing.\n if (!options.leaveSubmitMethodAlone) {\n var form = textarea.form, realSubmit = form.submit;\n try {\n var wrappedSubmit = form.submit = function() {\n save();\n form.submit = realSubmit;\n form.submit();\n form.submit = wrappedSubmit;\n };\n } catch(e) {}\n }\n }\n\n textarea.style.display = \"none\";\n var cm = CodeMirror(function(node) {\n textarea.parentNode.insertBefore(node, textarea.nextSibling);\n }, options);\n cm.save = save;\n cm.getTextArea = function() { return textarea; };\n cm.toTextArea = function() {\n save();\n textarea.parentNode.removeChild(cm.getWrapperElement());\n textarea.style.display = \"\";\n if (textarea.form) {\n off(textarea.form, \"submit\", save);\n if (typeof textarea.form.submit == \"function\")\n textarea.form.submit = realSubmit;\n }\n };\n return cm;\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 = CodeMirror.StringStream = function(string, tabSize) {\n this.pos = this.start = 0;\n this.string = string;\n this.tabSize = tabSize || 8;\n this.lastColumnPos = this.lastColumnValue = 0;\n this.lineStart = 0;\n };\n\n StringStream.prototype = {\n eol: function() {return this.pos >= this.string.length;},\n sol: function() {return this.pos == this.lineStart;},\n peek: function() {return this.string.charAt(this.pos) || undefined;},\n next: function() {\n if (this.pos < this.string.length)\n return this.string.charAt(this.pos++);\n },\n eat: function(match) {\n var ch = this.string.charAt(this.pos);\n if (typeof match == \"string\") var ok = ch == match;\n else var ok = ch && (match.test ? match.test(ch) : match(ch));\n if (ok) {++this.pos; return ch;}\n },\n eatWhile: function(match) {\n var start = this.pos;\n while (this.eat(match)){}\n return this.pos > start;\n },\n eatSpace: function() {\n var start = this.pos;\n while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;\n return this.pos > start;\n },\n skipToEnd: function() {this.pos = this.string.length;},\n skipTo: function(ch) {\n var found = this.string.indexOf(ch, this.pos);\n if (found > -1) {this.pos = found; return true;}\n },\n backUp: function(n) {this.pos -= n;},\n column: function() {\n if (this.lastColumnPos < this.start) {\n this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);\n this.lastColumnPos = this.start;\n }\n return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);\n },\n indentation: function() {\n return countColumn(this.string, null, this.tabSize) -\n (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);\n },\n match: function(pattern, consume, caseInsensitive) {\n if (typeof pattern == \"string\") {\n var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};\n var substr = this.string.substr(this.pos, pattern.length);\n if (cased(substr) == cased(pattern)) {\n if (consume !== false) this.pos += pattern.length;\n return true;\n }\n } else {\n var match = this.string.slice(this.pos).match(pattern);\n if (match && match.index > 0) return null;\n if (match && consume !== false) this.pos += match[0].length;\n return match;\n }\n },\n current: function(){return this.string.slice(this.start, this.pos);},\n hideFirstChars: function(n, inner) {\n this.lineStart += n;\n try { return inner(); }\n finally { this.lineStart -= n; }\n }\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 var TextMarker = CodeMirror.TextMarker = function(doc, type) {\n this.lines = [];\n this.type = type;\n this.doc = doc;\n };\n eventMixin(TextMarker);\n\n // Clear the marker.\n TextMarker.prototype.clear = function() {\n if (this.explicitlyCleared) return;\n var cm = this.doc.cm, withOp = cm && !cm.curOp;\n if (withOp) startOperation(cm);\n if (hasHandler(this, \"clear\")) {\n var found = this.find();\n if (found) signalLater(this, \"clear\", found.from, found.to);\n }\n var min = null, max = null;\n for (var i = 0; i < this.lines.length; ++i) {\n var line = this.lines[i];\n var span = getMarkedSpanFor(line.markedSpans, this);\n if (cm && !this.collapsed) regLineChange(cm, lineNo(line), \"text\");\n else if (cm) {\n if (span.to != null) max = lineNo(line);\n if (span.from != null) min = lineNo(line);\n }\n line.markedSpans = removeMarkedSpan(line.markedSpans, span);\n if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)\n updateLineHeight(line, textHeight(cm.display));\n }\n if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {\n var visual = visualLine(this.lines[i]), len = lineLength(visual);\n if (len > cm.display.maxLineLength) {\n cm.display.maxLine = visual;\n cm.display.maxLineLength = len;\n cm.display.maxLineChanged = true;\n }\n }\n\n if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);\n this.lines.length = 0;\n this.explicitlyCleared = true;\n if (this.atomic && this.doc.cantEdit) {\n this.doc.cantEdit = false;\n if (cm) reCheckSelection(cm.doc);\n }\n if (cm) signalLater(cm, \"markerCleared\", cm, this);\n if (withOp) endOperation(cm);\n if (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 if (side == null && this.type == \"bookmark\") side = 1;\n var from, to;\n for (var i = 0; i < this.lines.length; ++i) {\n var line = this.lines[i];\n var span = getMarkedSpanFor(line.markedSpans, this);\n if (span.from != null) {\n from = Pos(lineObj ? line : lineNo(line), span.from);\n if (side == -1) return from;\n }\n if (span.to != null) {\n to = Pos(lineObj ? line : lineNo(line), span.to);\n if (side == 1) return to;\n }\n }\n return 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 var pos = this.find(-1, true), widget = this, cm = this.doc.cm;\n if (!pos || !cm) return;\n runInOp(cm, function() {\n var line = pos.line, lineN = lineNo(pos.line);\n var view = findViewForLine(cm, lineN);\n if (view) {\n clearLineMeasurementCacheFor(view);\n cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;\n }\n cm.curOp.updateMaxLine = true;\n if (!lineIsHidden(widget.doc, line) && widget.height != null) {\n var oldHeight = widget.height;\n widget.height = null;\n var dHeight = widgetHeight(widget) - oldHeight;\n if (dHeight)\n updateLineHeight(line, line.height + dHeight);\n }\n });\n };\n\n TextMarker.prototype.attachLine = function(line) {\n if (!this.lines.length && this.doc.cm) {\n var op = this.doc.cm.curOp;\n if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)\n (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);\n }\n this.lines.push(line);\n };\n TextMarker.prototype.detachLine = function(line) {\n this.lines.splice(indexOf(this.lines, line), 1);\n if (!this.lines.length && this.doc.cm) {\n var op = this.doc.cm.curOp;\n (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);\n }\n };\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 // Create a marker, wire it up to the right lines, and\n function markText(doc, from, to, options, type) {\n // Shared markers (across linked documents) are handled separately\n // (markTextShared will call out to this again, once per\n // document).\n if (options && options.shared) return markTextShared(doc, from, to, options, type);\n // Ensure we are in an operation.\n if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);\n\n var marker = new TextMarker(doc, type), diff = cmp(from, to);\n if (options) copyObj(options, marker, false);\n // Don't connect empty markers unless clearWhenEmpty is false\n if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)\n return marker;\n if (marker.replacedWith) {\n // Showing up as a widget implies collapsed (widget replaces text)\n marker.collapsed = true;\n marker.widgetNode = elt(\"span\", [marker.replacedWith], \"CodeMirror-widget\");\n if (!options.handleMouseEvents) marker.widgetNode.ignoreEvents = true;\n if (options.insertLeft) marker.widgetNode.insertLeft = true;\n }\n if (marker.collapsed) {\n if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||\n from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))\n throw new Error(\"Inserting collapsed marker partially overlapping an existing one\");\n sawCollapsedSpans = true;\n }\n\n if (marker.addToHistory)\n addChangeToHistory(doc, {from: from, to: to, origin: \"markText\"}, doc.sel, NaN);\n\n var curLine = from.line, cm = doc.cm, updateMaxLine;\n doc.iter(curLine, to.line + 1, function(line) {\n if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)\n updateMaxLine = true;\n if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);\n addMarkedSpan(line, new MarkedSpan(marker,\n curLine == from.line ? from.ch : null,\n curLine == to.line ? to.ch : null));\n ++curLine;\n });\n // lineIsHidden depends on the presence of the spans, so needs a second pass\n if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {\n if (lineIsHidden(doc, line)) updateLineHeight(line, 0);\n });\n\n if (marker.clearOnEnter) on(marker, \"beforeCursorEnter\", function() { marker.clear(); });\n\n if (marker.readOnly) {\n sawReadOnlySpans = true;\n if (doc.history.done.length || doc.history.undone.length)\n doc.clearHistory();\n }\n if (marker.collapsed) {\n marker.id = ++nextMarkerId;\n marker.atomic = true;\n }\n if (cm) {\n // Sync editor state\n if (updateMaxLine) cm.curOp.updateMaxLine = true;\n if (marker.collapsed)\n regChange(cm, from.line, to.line + 1);\n else if (marker.className || marker.title || marker.startStyle || marker.endStyle)\n for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, \"text\");\n if (marker.atomic) reCheckSelection(cm.doc);\n signalLater(cm, \"markerAdded\", cm, marker);\n }\n return 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 var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {\n this.markers = markers;\n this.primary = primary;\n for (var i = 0; i < markers.length; ++i)\n markers[i].parent = this;\n };\n eventMixin(SharedTextMarker);\n\n SharedTextMarker.prototype.clear = function() {\n if (this.explicitlyCleared) return;\n this.explicitlyCleared = true;\n for (var i = 0; i < this.markers.length; ++i)\n this.markers[i].clear();\n signalLater(this, \"clear\");\n };\n SharedTextMarker.prototype.find = function(side, lineObj) {\n return this.primary.find(side, lineObj);\n };\n\n function markTextShared(doc, from, to, options, type) {\n options = copyObj(options);\n options.shared = false;\n var markers = [markText(doc, from, to, options, type)], primary = markers[0];\n var widget = options.widgetNode;\n linkedDocs(doc, function(doc) {\n if (widget) options.widgetNode = widget.cloneNode(true);\n markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));\n for (var i = 0; i < doc.linked.length; ++i)\n if (doc.linked[i].isParent) return;\n primary = lst(markers);\n });\n return new SharedTextMarker(markers, primary);\n }\n\n function findSharedMarkers(doc) {\n return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),\n function(m) { return m.parent; });\n }\n\n function copySharedMarkers(doc, markers) {\n for (var i = 0; i < markers.length; i++) {\n var marker = markers[i], pos = marker.find();\n var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);\n if (cmp(mFrom, mTo)) {\n var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);\n marker.markers.push(subMark);\n subMark.parent = marker;\n }\n }\n }\n\n function detachSharedMarkers(markers) {\n for (var i = 0; i < markers.length; i++) {\n var marker = markers[i], linked = [marker.primary.doc];;\n linkedDocs(marker.primary.doc, function(d) { linked.push(d); });\n for (var j = 0; j < marker.markers.length; j++) {\n var subMarker = marker.markers[j];\n if (indexOf(linked, subMarker.doc) == -1) {\n subMarker.parent = null;\n marker.markers.splice(j--, 1);\n }\n }\n }\n }\n\n // TEXTMARKER SPANS\n\n function MarkedSpan(marker, from, to) {\n this.marker = marker;\n this.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 if (spans) for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if (span.marker == marker) return span;\n }\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 for (var r, i = 0; i < spans.length; ++i)\n if (spans[i] != span) (r || (r = [])).push(spans[i]);\n return r;\n }\n // Add a span to a line.\n function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.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 if (old) for (var i = 0, nw; i < old.length; ++i) {\n var span = old[i], marker = span.marker;\n var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);\n if (startsBefore || span.from == startCh && marker.type == \"bookmark\" && (!isInsert || !span.marker.insertLeft)) {\n var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);\n (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));\n }\n }\n return nw;\n }\n function markedSpansAfter(old, endCh, isInsert) {\n if (old) for (var i = 0, nw; i < old.length; ++i) {\n var span = old[i], marker = span.marker;\n var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);\n if (endsAfter || span.from == endCh && marker.type == \"bookmark\" && (!isInsert || span.marker.insertLeft)) {\n var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);\n (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,\n span.to == null ? null : span.to - endCh));\n }\n }\n return 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 var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;\n var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;\n if (!oldFirst && !oldLast) return null;\n\n var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;\n // Get the spans that 'stick out' on both sides\n var first = markedSpansBefore(oldFirst, startCh, isInsert);\n var last = markedSpansAfter(oldLast, endCh, isInsert);\n\n // Next, merge those two ends\n var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);\n if (first) {\n // Fix up .to properties of first\n for (var i = 0; i < first.length; ++i) {\n var span = first[i];\n if (span.to == null) {\n var found = getMarkedSpanFor(last, span.marker);\n if (!found) span.to = startCh;\n else if (sameLine) span.to = found.to == null ? null : found.to + offset;\n }\n }\n }\n if (last) {\n // Fix up .from in last (or move them into first in case of sameLine)\n for (var i = 0; i < last.length; ++i) {\n var span = last[i];\n if (span.to != null) span.to += offset;\n if (span.from == null) {\n var found = getMarkedSpanFor(first, span.marker);\n if (!found) {\n span.from = offset;\n if (sameLine) (first || (first = [])).push(span);\n }\n } else {\n span.from += offset;\n if (sameLine) (first || (first = [])).push(span);\n }\n }\n }\n // Make sure we didn't create any zero-length spans\n if (first) first = clearEmptySpans(first);\n if (last && last != first) last = clearEmptySpans(last);\n\n var newMarkers = [first];\n if (!sameLine) {\n // Fill gap with whole-line-spans\n var gap = change.text.length - 2, gapMarkers;\n if (gap > 0 && first)\n for (var i = 0; i < first.length; ++i)\n if (first[i].to == null)\n (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));\n for (var i = 0; i < gap; ++i)\n newMarkers.push(gapMarkers);\n newMarkers.push(last);\n }\n return newMarkers;\n }\n\n // Remove spans that are empty and don't have a clearWhenEmpty\n // option of false.\n function clearEmptySpans(spans) {\n for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)\n spans.splice(i--, 1);\n }\n if (!spans.length) return null;\n return spans;\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 var old = getOldSpans(doc, change);\n var stretched = stretchSpansOverChange(doc, change);\n if (!old) return stretched;\n if (!stretched) return old;\n\n for (var i = 0; i < old.length; ++i) {\n var oldCur = old[i], stretchCur = stretched[i];\n if (oldCur && stretchCur) {\n spans: for (var j = 0; j < stretchCur.length; ++j) {\n var span = stretchCur[j];\n for (var k = 0; k < oldCur.length; ++k)\n if (oldCur[k].marker == span.marker) continue spans;\n oldCur.push(span);\n }\n } else if (stretchCur) {\n old[i] = stretchCur;\n }\n }\n return old;\n }\n\n // Used to 'clip' out readOnly ranges when making a change.\n function removeReadOnlyRanges(doc, from, to) {\n var markers = null;\n doc.iter(from.line, to.line + 1, function(line) {\n if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {\n var mark = line.markedSpans[i].marker;\n if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))\n (markers || (markers = [])).push(mark);\n }\n });\n if (!markers) return null;\n var parts = [{from: from, to: to}];\n for (var i = 0; i < markers.length; ++i) {\n var mk = markers[i], m = mk.find(0);\n for (var j = 0; j < parts.length; ++j) {\n var p = parts[j];\n if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;\n var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);\n if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)\n newParts.push({from: p.from, to: m.from});\n if (dto > 0 || !mk.inclusiveRight && !dto)\n newParts.push({from: m.to, to: p.to});\n parts.splice.apply(parts, newParts);\n j += newParts.length - 1;\n }\n }\n return parts;\n }\n\n // Connect or disconnect spans from a line.\n function detachMarkedSpans(line) {\n var spans = line.markedSpans;\n if (!spans) return;\n for (var i = 0; i < spans.length; ++i)\n spans[i].marker.detachLine(line);\n line.markedSpans = null;\n }\n function attachMarkedSpans(line, spans) {\n if (!spans) return;\n for (var i = 0; i < spans.length; ++i)\n spans[i].marker.attachLine(line);\n line.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 var lenDiff = a.lines.length - b.lines.length;\n if (lenDiff != 0) return lenDiff;\n var aPos = a.find(), bPos = b.find();\n var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);\n if (fromCmp) return -fromCmp;\n var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);\n if (toCmp) return toCmp;\n return 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 var sps = sawCollapsedSpans && line.markedSpans, found;\n if (sps) for (var sp, i = 0; i < sps.length; ++i) {\n sp = sps[i];\n if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&\n (!found || compareCollapsedMarkers(found, sp.marker) < 0))\n found = sp.marker;\n }\n return 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 var line = getLine(doc, lineNo);\n var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) for (var i = 0; i < sps.length; ++i) {\n var sp = sps[i];\n if (!sp.marker.collapsed) continue;\n var found = sp.marker.find(0);\n var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);\n var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);\n if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;\n if (fromCmp <= 0 && (cmp(found.to, from) || extraRight(sp.marker) - extraLeft(marker)) > 0 ||\n fromCmp >= 0 && (cmp(found.from, to) || extraLeft(sp.marker) - extraRight(marker)) < 0)\n return true;\n }\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 var merged;\n while (merged = collapsedSpanAtStart(line))\n line = merged.find(-1, true).line;\n return 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 var merged, lines;\n while (merged = collapsedSpanAtEnd(line)) {\n line = merged.find(1, true).line;\n (lines || (lines = [])).push(line);\n }\n return 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 var line = getLine(doc, lineN), vis = visualLine(line);\n if (line == vis) return lineN;\n return lineNo(vis);\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 if (lineN > doc.lastLine()) return lineN;\n var line = getLine(doc, lineN), merged;\n if (!lineIsHidden(doc, line)) return lineN;\n while (merged = collapsedSpanAtEnd(line))\n line = merged.find(1, true).line;\n return 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 var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) for (var sp, i = 0; i < sps.length; ++i) {\n sp = sps[i];\n if (!sp.marker.collapsed) continue;\n if (sp.from == null) return true;\n if (sp.marker.widgetNode) continue;\n if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))\n return true;\n }\n }\n function lineIsHiddenInner(doc, line, span) {\n if (span.to == null) {\n var end = span.marker.find(1, true);\n return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));\n }\n if (span.marker.inclusiveRight && span.to == line.text.length)\n return true;\n for (var sp, i = 0; i < line.markedSpans.length; ++i) {\n sp = line.markedSpans[i];\n if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&\n (sp.to == null || sp.to != span.from) &&\n (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&\n lineIsHiddenInner(doc, line, sp)) return true;\n }\n }\n\n // LINE WIDGETS\n\n // Line widgets are block elements displayed above or below a line.\n\n var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {\n if (options) for (var opt in options) if (options.hasOwnProperty(opt))\n this[opt] = options[opt];\n this.cm = cm;\n this.node = node;\n };\n eventMixin(LineWidget);\n\n function adjustScrollWhenAboveVisible(cm, line, diff) {\n if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))\n addToScrollPos(cm, null, diff);\n }\n\n LineWidget.prototype.clear = function() {\n var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);\n if (no == null || !ws) return;\n for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);\n if (!ws.length) line.widgets = null;\n var height = widgetHeight(this);\n runInOp(cm, function() {\n adjustScrollWhenAboveVisible(cm, line, -height);\n regLineChange(cm, no, \"widget\");\n updateLineHeight(line, Math.max(0, line.height - height));\n });\n };\n LineWidget.prototype.changed = function() {\n var oldH = this.height, cm = this.cm, line = this.line;\n this.height = null;\n var diff = widgetHeight(this) - oldH;\n if (!diff) return;\n runInOp(cm, function() {\n cm.curOp.forceUpdate = true;\n adjustScrollWhenAboveVisible(cm, line, diff);\n updateLineHeight(line, line.height + diff);\n });\n };\n\n function widgetHeight(widget) {\n if (widget.height != null) return widget.height;\n if (!contains(document.body, widget.node))\n removeChildrenAndAdd(widget.cm.display.measure, elt(\"div\", [widget.node], null, \"position: relative\"));\n return widget.height = widget.node.offsetHeight;\n }\n\n function addLineWidget(cm, handle, node, options) {\n var widget = new LineWidget(cm, node, options);\n if (widget.noHScroll) cm.display.alignWidgets = true;\n changeLine(cm, handle, \"widget\", function(line) {\n var widgets = line.widgets || (line.widgets = []);\n if (widget.insertAt == null) widgets.push(widget);\n else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);\n widget.line = line;\n if (!lineIsHidden(cm.doc, line)) {\n var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;\n updateLineHeight(line, line.height + widgetHeight(widget));\n if (aboveVisible) addToScrollPos(cm, null, widget.height);\n cm.curOp.forceUpdate = true;\n }\n return true;\n });\n return widget;\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 var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {\n this.text = text;\n attachMarkedSpans(this, markedSpans);\n this.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 line.text = text;\n if (line.stateAfter) line.stateAfter = null;\n if (line.styles) line.styles = null;\n if (line.order != null) line.order = null;\n detachMarkedSpans(line);\n attachMarkedSpans(line, markedSpans);\n var estHeight = estimateHeight ? estimateHeight(line) : 1;\n if (estHeight != line.height) updateLineHeight(line, estHeight);\n }\n\n // Detach a line from the document tree and its markers.\n function cleanUpLine(line) {\n line.parent = null;\n detachMarkedSpans(line);\n }\n\n function extractLineClasses(type, output) {\n if (type) for (;;) {\n var lineClass = type.match(/(?:^|\\s+)line-(background-)?(\\S+)/);\n if (!lineClass) break;\n type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);\n var prop = lineClass[1] ? \"bgClass\" : \"textClass\";\n if (output[prop] == null)\n output[prop] = lineClass[2];\n else if (!(new RegExp(\"(?:^|\\s)\" + lineClass[2] + \"(?:$|\\s)\")).test(output[prop]))\n output[prop] += \" \" + lineClass[2];\n }\n return type;\n }\n\n function callBlankLine(mode, state) {\n if (mode.blankLine) return mode.blankLine(state);\n if (!mode.innerMode) return;\n var inner = CodeMirror.innerMode(mode, state);\n if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);\n }\n\n function readToken(mode, stream, state) {\n for (var i = 0; i < 10; i++) {\n var style = mode.token(stream, state);\n if (stream.pos > stream.start) return style;\n }\n throw new Error(\"Mode \" + mode.name + \" failed to advance stream.\");\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 var flattenSpans = mode.flattenSpans;\n if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;\n var curStart = 0, curStyle = null;\n var stream = new StringStream(text, cm.options.tabSize), style;\n if (text == \"\") extractLineClasses(callBlankLine(mode, state), lineClasses);\n while (!stream.eol()) {\n if (stream.pos > cm.options.maxHighlightLength) {\n flattenSpans = false;\n if (forceToEnd) processLine(cm, text, state, stream.pos);\n stream.pos = text.length;\n style = null;\n } else {\n style = extractLineClasses(readToken(mode, stream, state), lineClasses);\n }\n if (cm.options.addModeClass) {\n var mName = CodeMirror.innerMode(mode, state).mode.name;\n if (mName) style = \"m-\" + (style ? mName + \" \" + style : mName);\n }\n if (!flattenSpans || curStyle != style) {\n if (curStart < stream.start) f(stream.start, curStyle);\n curStart = stream.start; curStyle = style;\n }\n stream.start = stream.pos;\n }\n while (curStart < stream.pos) {\n // Webkit seems to refuse to render text nodes longer than 57444 characters\n var pos = Math.min(stream.pos, curStart + 50000);\n f(pos, curStyle);\n curStart = pos;\n }\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 // A styles array always starts with a number identifying the\n // mode/overlays that it is based on (for easy invalidation).\n var st = [cm.state.modeGen], lineClasses = {};\n // Compute the base array of styles\n runMode(cm, line.text, cm.doc.mode, state, function(end, style) {\n st.push(end, style);\n }, lineClasses, forceToEnd);\n\n // Run overlays, adjust style array.\n for (var o = 0; o < cm.state.overlays.length; ++o) {\n var overlay = cm.state.overlays[o], i = 1, at = 0;\n runMode(cm, line.text, overlay.mode, true, function(end, style) {\n var start = i;\n // Ensure there's a token end at the current position, and that i points at it\n while (at < end) {\n var i_end = st[i];\n if (i_end > end)\n st.splice(i, 1, end, st[i+1], i_end);\n i += 2;\n at = Math.min(end, i_end);\n }\n if (!style) return;\n if (overlay.opaque) {\n st.splice(start, i - start, end, \"cm-overlay \" + style);\n i = start + 2;\n } else {\n for (; start < i; start += 2) {\n var cur = st[start+1];\n st[start+1] = (cur ? cur + \" \" : \"\") + \"cm-overlay \" + style;\n }\n }\n }, lineClasses);\n }\n\n return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};\n }\n\n function getLineStyles(cm, line) {\n if (!line.styles || line.styles[0] != cm.state.modeGen) {\n var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));\n line.styles = result.styles;\n if (result.classes) line.styleClasses = result.classes;\n else if (line.styleClasses) line.styleClasses = null;\n }\n return line.styles;\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 var mode = cm.doc.mode;\n var stream = new StringStream(text, cm.options.tabSize);\n stream.start = stream.pos = startAt || 0;\n if (text == \"\") callBlankLine(mode, state);\n while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {\n readToken(mode, stream, state);\n stream.start = stream.pos;\n }\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 = {}, styleToClassCacheWithMode = {};\n function interpretTokenStyle(style, options) {\n if (!style || /^\\s*$/.test(style)) return null;\n var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;\n return cache[style] ||\n (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 // The padding-right forces the element to have a 'border', which\n // is needed on Webkit to be able to get line-level bounding\n // rectangles for it (in measureChar).\n var content = elt(\"span\", null, null, webkit ? \"padding-right: .1px\" : null);\n var builder = {pre: elt(\"pre\", [content]), content: content, col: 0, pos: 0, cm: cm};\n lineView.measure = {};\n\n // Iterate over the logical lines that make up this visual line.\n for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {\n var line = i ? lineView.rest[i - 1] : lineView.line, order;\n builder.pos = 0;\n builder.addToken = buildToken;\n // Optionally wire in some hacks into the token-rendering\n // algorithm, to deal with browser quirks.\n if ((ie || webkit) && cm.getOption(\"lineWrapping\"))\n builder.addToken = buildTokenSplitSpaces(builder.addToken);\n if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))\n builder.addToken = buildTokenBadBidi(builder.addToken, order);\n builder.map = [];\n insertLineContent(line, builder, getLineStyles(cm, line));\n if (line.styleClasses) {\n if (line.styleClasses.bgClass)\n builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || \"\");\n if (line.styleClasses.textClass)\n builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || \"\");\n }\n\n // Ensure at least a single node is present, for measuring.\n if (builder.map.length == 0)\n builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));\n\n // Store the map and a cache object for the current logical line\n if (i == 0) {\n lineView.measure.map = builder.map;\n lineView.measure.cache = {};\n } else {\n (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);\n (lineView.measure.caches || (lineView.measure.caches = [])).push({});\n }\n }\n\n signal(cm, \"renderLine\", cm, lineView.line, builder.pre);\n return builder;\n }\n\n function defaultSpecialCharPlaceholder(ch) {\n var token = elt(\"span\", \"\\u2022\", \"cm-invalidchar\");\n token.title = \"\\\\u\" + ch.charCodeAt(0).toString(16);\n return 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) {\n if (!text) return;\n var special = builder.cm.options.specialChars, mustWrap = false;\n if (!special.test(text)) {\n builder.col += text.length;\n var content = document.createTextNode(text);\n builder.map.push(builder.pos, builder.pos + text.length, content);\n if (ie_upto8) mustWrap = true;\n builder.pos += text.length;\n } else {\n var content = document.createDocumentFragment(), pos = 0;\n while (true) {\n special.lastIndex = pos;\n var m = special.exec(text);\n var skipped = m ? m.index - pos : text.length - pos;\n if (skipped) {\n var txt = document.createTextNode(text.slice(pos, pos + skipped));\n if (ie_upto8) content.appendChild(elt(\"span\", [txt]));\n else content.appendChild(txt);\n builder.map.push(builder.pos, builder.pos + skipped, txt);\n builder.col += skipped;\n builder.pos += skipped;\n }\n if (!m) break;\n pos += skipped + 1;\n if (m[0] == \"\\t\") {\n var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;\n var txt = content.appendChild(elt(\"span\", spaceStr(tabWidth), \"cm-tab\"));\n builder.col += tabWidth;\n } else {\n var txt = builder.cm.options.specialCharPlaceholder(m[0]);\n if (ie_upto8) content.appendChild(elt(\"span\", [txt]));\n else content.appendChild(txt);\n builder.col += 1;\n }\n builder.map.push(builder.pos, builder.pos + 1, txt);\n builder.pos++;\n }\n }\n if (style || startStyle || endStyle || mustWrap) {\n var fullStyle = style || \"\";\n if (startStyle) fullStyle += startStyle;\n if (endStyle) fullStyle += endStyle;\n var token = elt(\"span\", [content], fullStyle);\n if (title) token.title = title;\n return builder.content.appendChild(token);\n }\n builder.content.appendChild(content);\n }\n\n function buildTokenSplitSpaces(inner) {\n function split(old) {\n var out = \" \";\n for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? \" \" : \"\\u00a0\";\n out += \" \";\n return out;\n }\n return function(builder, text, style, startStyle, endStyle, title) {\n inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);\n };\n }\n\n // Work around nonsense dimensions being reported for stretches of\n // right-to-left text.\n function buildTokenBadBidi(inner, order) {\n return function(builder, text, style, startStyle, endStyle, title) {\n style = style ? style + \" cm-force-border\" : \"cm-force-border\";\n var start = builder.pos, end = start + text.length;\n for (;;) {\n // Find the part that overlaps with the start of this text\n for (var i = 0; i < order.length; i++) {\n var part = order[i];\n if (part.to > start && part.from <= start) break;\n }\n if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title);\n inner(builder, text.slice(0, part.to - start), style, startStyle, null, title);\n startStyle = null;\n text = text.slice(part.to - start);\n start = part.to;\n }\n };\n }\n\n function buildCollapsedSpan(builder, size, marker, ignoreWidget) {\n var widget = !ignoreWidget && marker.widgetNode;\n if (widget) {\n builder.map.push(builder.pos, builder.pos + size, widget);\n builder.content.appendChild(widget);\n }\n builder.pos += size;\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 var spans = line.markedSpans, allText = line.text, at = 0;\n if (!spans) {\n for (var i = 1; i < styles.length; i+=2)\n builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));\n return;\n }\n\n var len = allText.length, pos = 0, i = 1, text = \"\", style;\n var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;\n for (;;) {\n if (nextChange == pos) { // Update current marker set\n spanStyle = spanEndStyle = spanStartStyle = title = \"\";\n collapsed = null; nextChange = Infinity;\n var foundBookmarks = [];\n for (var j = 0; j < spans.length; ++j) {\n var sp = spans[j], m = sp.marker;\n if (sp.from <= pos && (sp.to == null || sp.to > pos)) {\n if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = \"\"; }\n if (m.className) spanStyle += \" \" + m.className;\n if (m.startStyle && sp.from == pos) spanStartStyle += \" \" + m.startStyle;\n if (m.endStyle && sp.to == nextChange) spanEndStyle += \" \" + m.endStyle;\n if (m.title && !title) title = m.title;\n if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))\n collapsed = sp;\n } else if (sp.from > pos && nextChange > sp.from) {\n nextChange = sp.from;\n }\n if (m.type == \"bookmark\" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);\n }\n if (collapsed && (collapsed.from || 0) == pos) {\n buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,\n collapsed.marker, collapsed.from == null);\n if (collapsed.to == null) return;\n }\n if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)\n buildCollapsedSpan(builder, 0, foundBookmarks[j]);\n }\n if (pos >= len) break;\n\n var upto = Math.min(len, nextChange);\n while (true) {\n if (text) {\n var end = pos + text.length;\n if (!collapsed) {\n var tokenText = end > upto ? text.slice(0, upto - pos) : text;\n builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,\n spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : \"\", title);\n }\n if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}\n pos = end;\n spanStartStyle = \"\";\n }\n text = allText.slice(at, at = styles[i++]);\n style = interpretTokenStyle(styles[i++], builder.cm.options);\n }\n }\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 return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == \"\" &&\n (!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 function spansFor(n) {return markedSpans ? markedSpans[n] : null;}\n function update(line, text, spans) {\n updateLine(line, text, spans, estimateHeight);\n signalLater(line, \"change\", line, change);\n }\n\n var from = change.from, to = change.to, text = change.text;\n var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);\n var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;\n\n // Adjust the line structure\n if (isWholeLineUpdate(doc, change)) {\n // This is a whole-line replace. Treated specially to make\n // sure line objects move the way they are supposed to.\n for (var i = 0, added = []; i < text.length - 1; ++i)\n added.push(new Line(text[i], spansFor(i), estimateHeight));\n update(lastLine, lastLine.text, lastSpans);\n if (nlines) doc.remove(from.line, nlines);\n if (added.length) doc.insert(from.line, added);\n } else if (firstLine == lastLine) {\n if (text.length == 1) {\n update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);\n } else {\n for (var added = [], i = 1; i < text.length - 1; ++i)\n added.push(new Line(text[i], spansFor(i), estimateHeight));\n added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));\n doc.insert(from.line + 1, added);\n }\n } else if (text.length == 1) {\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));\n doc.remove(from.line + 1, nlines);\n } else {\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));\n update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);\n for (var i = 1, added = []; i < text.length - 1; ++i)\n added.push(new Line(text[i], spansFor(i), estimateHeight));\n if (nlines > 1) doc.remove(from.line + 1, nlines - 1);\n doc.insert(from.line + 1, added);\n }\n\n signalLater(doc, \"change\", doc, change);\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 this.lines = lines;\n this.parent = null;\n for (var i = 0, height = 0; i < lines.length; ++i) {\n lines[i].parent = this;\n height += lines[i].height;\n }\n this.height = height;\n }\n\n LeafChunk.prototype = {\n chunkSize: function() { return this.lines.length; },\n // Remove the n lines at offset 'at'.\n removeInner: function(at, n) {\n for (var i = at, e = at + n; i < e; ++i) {\n var line = this.lines[i];\n this.height -= line.height;\n cleanUpLine(line);\n signalLater(line, \"delete\");\n }\n this.lines.splice(at, n);\n },\n // Helper used to collapse a small branch into a single leaf.\n collapse: function(lines) {\n lines.push.apply(lines, this.lines);\n },\n // Insert the given array of lines at offset 'at', count them as\n // having the given height.\n insertInner: function(at, lines, height) {\n this.height += height;\n this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));\n for (var i = 0; i < lines.length; ++i) lines[i].parent = this;\n },\n // Used to iterate over a part of the tree.\n iterN: function(at, n, op) {\n for (var e = at + n; at < e; ++at)\n if (op(this.lines[at])) return true;\n }\n };\n\n function BranchChunk(children) {\n this.children = children;\n var size = 0, height = 0;\n for (var i = 0; i < children.length; ++i) {\n var ch = children[i];\n size += ch.chunkSize(); height += ch.height;\n ch.parent = this;\n }\n this.size = size;\n this.height = height;\n this.parent = null;\n }\n\n BranchChunk.prototype = {\n chunkSize: function() { return this.size; },\n removeInner: function(at, n) {\n this.size -= n;\n for (var i = 0; i < this.children.length; ++i) {\n var child = this.children[i], sz = child.chunkSize();\n if (at < sz) {\n var rm = Math.min(n, sz - at), oldHeight = child.height;\n child.removeInner(at, rm);\n this.height -= oldHeight - child.height;\n if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }\n if ((n -= rm) == 0) break;\n at = 0;\n } else at -= sz;\n }\n // If the result is smaller than 25 lines, ensure that it is a\n // single leaf node.\n if (this.size - n < 25 &&\n (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {\n var lines = [];\n this.collapse(lines);\n this.children = [new LeafChunk(lines)];\n this.children[0].parent = this;\n }\n },\n collapse: function(lines) {\n for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);\n },\n insertInner: function(at, lines, height) {\n this.size += lines.length;\n this.height += height;\n for (var i = 0; i < this.children.length; ++i) {\n var child = this.children[i], sz = child.chunkSize();\n if (at <= sz) {\n child.insertInner(at, lines, height);\n if (child.lines && child.lines.length > 50) {\n while (child.lines.length > 50) {\n var spilled = child.lines.splice(child.lines.length - 25, 25);\n var newleaf = new LeafChunk(spilled);\n child.height -= newleaf.height;\n this.children.splice(i + 1, 0, newleaf);\n newleaf.parent = this;\n }\n this.maybeSpill();\n }\n break;\n }\n at -= sz;\n }\n },\n // When a node has grown, check whether it should be split.\n maybeSpill: function() {\n if (this.children.length <= 10) return;\n var me = this;\n do {\n var spilled = me.children.splice(me.children.length - 5, 5);\n var sibling = new BranchChunk(spilled);\n if (!me.parent) { // Become the parent node\n var copy = new BranchChunk(me.children);\n copy.parent = me;\n me.children = [copy, sibling];\n me = copy;\n } else {\n me.size -= sibling.size;\n me.height -= sibling.height;\n var myIndex = indexOf(me.parent.children, me);\n me.parent.children.splice(myIndex + 1, 0, sibling);\n }\n sibling.parent = me.parent;\n } while (me.children.length > 10);\n me.parent.maybeSpill();\n },\n iterN: function(at, n, op) {\n for (var i = 0; i < this.children.length; ++i) {\n var child = this.children[i], sz = child.chunkSize();\n if (at < sz) {\n var used = Math.min(n, sz - at);\n if (child.iterN(at, used, op)) return true;\n if ((n -= used) == 0) break;\n at = 0;\n } else at -= sz;\n }\n }\n };\n\n var nextDocId = 0;\n var Doc = CodeMirror.Doc = function(text, mode, firstLine) {\n if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);\n if (firstLine == null) firstLine = 0;\n\n BranchChunk.call(this, [new LeafChunk([new Line(\"\", null)])]);\n this.first = firstLine;\n this.scrollTop = this.scrollLeft = 0;\n this.cantEdit = false;\n this.cleanGeneration = 1;\n this.frontier = firstLine;\n var start = Pos(firstLine, 0);\n this.sel = simpleSelection(start);\n this.history = new History(null);\n this.id = ++nextDocId;\n this.modeOption = mode;\n\n if (typeof text == \"string\") text = splitLines(text);\n updateDoc(this, {from: start, to: start, text: text});\n setSelection(this, simpleSelection(start), sel_dontScroll);\n };\n\n Doc.prototype = createObj(BranchChunk.prototype, {\n constructor: Doc,\n // Iterate over the document. Supports two forms -- with only one\n // argument, it calls that for each line in the document. With\n // three, it iterates over the range given by the first two (with\n // the second being non-inclusive).\n iter: function(from, to, op) {\n if (op) this.iterN(from - this.first, to - from, op);\n else this.iterN(this.first, this.first + this.size, from);\n },\n\n // Non-public interface for adding and removing lines.\n insert: function(at, lines) {\n var height = 0;\n for (var i = 0; i < lines.length; ++i) height += lines[i].height;\n this.insertInner(at - this.first, lines, height);\n },\n remove: function(at, n) { this.removeInner(at - this.first, n); },\n\n // From here, the methods are part of the public interface. Most\n // are also available from CodeMirror (editor) instances.\n\n getValue: function(lineSep) {\n var lines = getLines(this, this.first, this.first + this.size);\n if (lineSep === false) return lines;\n return lines.join(lineSep || \"\\n\");\n },\n setValue: docMethodOp(function(code) {\n var top = Pos(this.first, 0), last = this.first + this.size - 1;\n makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),\n text: splitLines(code), origin: \"setValue\"}, true);\n setSelection(this, simpleSelection(top));\n }),\n replaceRange: function(code, from, to, origin) {\n from = clipPos(this, from);\n to = to ? clipPos(this, to) : from;\n replaceRange(this, code, from, to, origin);\n },\n getRange: function(from, to, lineSep) {\n var lines = getBetween(this, clipPos(this, from), clipPos(this, to));\n if (lineSep === false) return lines;\n return lines.join(lineSep || \"\\n\");\n },\n\n getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},\n\n getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},\n getLineNumber: function(line) {return lineNo(line);},\n\n getLineHandleVisualStart: function(line) {\n if (typeof line == \"number\") line = getLine(this, line);\n return visualLine(line);\n },\n\n lineCount: function() {return this.size;},\n firstLine: function() {return this.first;},\n lastLine: function() {return this.first + this.size - 1;},\n\n clipPos: function(pos) {return clipPos(this, pos);},\n\n getCursor: function(start) {\n var range = this.sel.primary(), pos;\n if (start == null || start == \"head\") pos = range.head;\n else if (start == \"anchor\") pos = range.anchor;\n else if (start == \"end\" || start == \"to\" || start === false) pos = range.to();\n else pos = range.from();\n return pos;\n },\n listSelections: function() { return this.sel.ranges; },\n somethingSelected: function() {return this.sel.somethingSelected();},\n\n setCursor: docMethodOp(function(line, ch, options) {\n setSimpleSelection(this, clipPos(this, typeof line == \"number\" ? Pos(line, ch || 0) : line), null, options);\n }),\n setSelection: docMethodOp(function(anchor, head, options) {\n setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);\n }),\n extendSelection: docMethodOp(function(head, other, options) {\n extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);\n }),\n extendSelections: docMethodOp(function(heads, options) {\n extendSelections(this, clipPosArray(this, heads, options));\n }),\n extendSelectionsBy: docMethodOp(function(f, options) {\n extendSelections(this, map(this.sel.ranges, f), options);\n }),\n setSelections: docMethodOp(function(ranges, primary, options) {\n if (!ranges.length) return;\n for (var i = 0, out = []; i < ranges.length; i++)\n out[i] = new Range(clipPos(this, ranges[i].anchor),\n clipPos(this, ranges[i].head));\n if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);\n setSelection(this, normalizeSelection(out, primary), options);\n }),\n addSelection: docMethodOp(function(anchor, head, options) {\n var ranges = this.sel.ranges.slice(0);\n ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));\n setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);\n }),\n\n getSelection: function(lineSep) {\n var ranges = this.sel.ranges, lines;\n for (var i = 0; i < ranges.length; i++) {\n var sel = getBetween(this, ranges[i].from(), ranges[i].to());\n lines = lines ? lines.concat(sel) : sel;\n }\n if (lineSep === false) return lines;\n else return lines.join(lineSep || \"\\n\");\n },\n getSelections: function(lineSep) {\n var parts = [], ranges = this.sel.ranges;\n for (var i = 0; i < ranges.length; i++) {\n var sel = getBetween(this, ranges[i].from(), ranges[i].to());\n if (lineSep !== false) sel = sel.join(lineSep || \"\\n\");\n parts[i] = sel;\n }\n return parts;\n },\n replaceSelection: function(code, collapse, origin) {\n var dup = [];\n for (var i = 0; i < this.sel.ranges.length; i++)\n dup[i] = code;\n this.replaceSelections(dup, collapse, origin || \"+input\");\n },\n replaceSelections: docMethodOp(function(code, collapse, origin) {\n var changes = [], sel = this.sel;\n for (var i = 0; i < sel.ranges.length; i++) {\n var range = sel.ranges[i];\n changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};\n }\n var newSel = collapse && collapse != \"end\" && computeReplacedSel(this, changes, collapse);\n for (var i = changes.length - 1; i >= 0; i--)\n makeChange(this, changes[i]);\n if (newSel) setSelectionReplaceHistory(this, newSel);\n else if (this.cm) ensureCursorVisible(this.cm);\n }),\n undo: docMethodOp(function() {makeChangeFromHistory(this, \"undo\");}),\n redo: docMethodOp(function() {makeChangeFromHistory(this, \"redo\");}),\n undoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"undo\", true);}),\n redoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"redo\", true);}),\n\n setExtending: function(val) {this.extend = val;},\n getExtending: function() {return this.extend;},\n\n historySize: function() {\n var hist = this.history, done = 0, undone = 0;\n for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;\n for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;\n return {undo: done, redo: undone};\n },\n clearHistory: function() {this.history = new History(this.history.maxGeneration);},\n\n markClean: function() {\n this.cleanGeneration = this.changeGeneration(true);\n },\n changeGeneration: function(forceSplit) {\n if (forceSplit)\n this.history.lastOp = this.history.lastOrigin = null;\n return this.history.generation;\n },\n isClean: function (gen) {\n return this.history.generation == (gen || this.cleanGeneration);\n },\n\n getHistory: function() {\n return {done: copyHistoryArray(this.history.done),\n undone: copyHistoryArray(this.history.undone)};\n },\n setHistory: function(histData) {\n var hist = this.history = new History(this.history.maxGeneration);\n hist.done = copyHistoryArray(histData.done.slice(0), null, true);\n hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);\n },\n\n markText: function(from, to, options) {\n return markText(this, clipPos(this, from), clipPos(this, to), options, \"range\");\n },\n setBookmark: function(pos, options) {\n var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),\n insertLeft: options && options.insertLeft,\n clearWhenEmpty: false, shared: options && options.shared};\n pos = clipPos(this, pos);\n return markText(this, pos, pos, realOpts, \"bookmark\");\n },\n findMarksAt: function(pos) {\n pos = clipPos(this, pos);\n var markers = [], spans = getLine(this, pos.line).markedSpans;\n if (spans) for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if ((span.from == null || span.from <= pos.ch) &&\n (span.to == null || span.to >= pos.ch))\n markers.push(span.marker.parent || span.marker);\n }\n return markers;\n },\n findMarks: function(from, to, filter) {\n from = clipPos(this, from); to = clipPos(this, to);\n var found = [], lineNo = from.line;\n this.iter(from.line, to.line + 1, function(line) {\n var spans = line.markedSpans;\n if (spans) for (var i = 0; i < spans.length; i++) {\n var span = spans[i];\n if (!(lineNo == from.line && from.ch > span.to ||\n span.from == null && lineNo != from.line||\n lineNo == to.line && span.from > to.ch) &&\n (!filter || filter(span.marker)))\n found.push(span.marker.parent || span.marker);\n }\n ++lineNo;\n });\n return found;\n },\n getAllMarks: function() {\n var markers = [];\n this.iter(function(line) {\n var sps = line.markedSpans;\n if (sps) for (var i = 0; i < sps.length; ++i)\n if (sps[i].from != null) markers.push(sps[i].marker);\n });\n return markers;\n },\n\n posFromIndex: function(off) {\n var ch, lineNo = this.first;\n this.iter(function(line) {\n var sz = line.text.length + 1;\n if (sz > off) { ch = off; return true; }\n off -= sz;\n ++lineNo;\n });\n return clipPos(this, Pos(lineNo, ch));\n },\n indexFromPos: function (coords) {\n coords = clipPos(this, coords);\n var index = coords.ch;\n if (coords.line < this.first || coords.ch < 0) return 0;\n this.iter(this.first, coords.line, function (line) {\n index += line.text.length + 1;\n });\n return index;\n },\n\n copy: function(copyHistory) {\n var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);\n doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;\n doc.sel = this.sel;\n doc.extend = false;\n if (copyHistory) {\n doc.history.undoDepth = this.history.undoDepth;\n doc.setHistory(this.getHistory());\n }\n return doc;\n },\n\n linkedDoc: function(options) {\n if (!options) options = {};\n var from = this.first, to = this.first + this.size;\n if (options.from != null && options.from > from) from = options.from;\n if (options.to != null && options.to < to) to = options.to;\n var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);\n if (options.sharedHist) copy.history = this.history;\n (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});\n copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];\n copySharedMarkers(copy, findSharedMarkers(this));\n return copy;\n },\n unlinkDoc: function(other) {\n if (other instanceof CodeMirror) other = other.doc;\n if (this.linked) for (var i = 0; i < this.linked.length; ++i) {\n var link = this.linked[i];\n if (link.doc != other) continue;\n this.linked.splice(i, 1);\n other.unlinkDoc(this);\n detachSharedMarkers(findSharedMarkers(this));\n break;\n }\n // If the histories were shared, split them again\n if (other.history == this.history) {\n var splitIds = [other.id];\n linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);\n other.history = new History(null);\n other.history.done = copyHistoryArray(this.history.done, splitIds);\n other.history.undone = copyHistoryArray(this.history.undone, splitIds);\n }\n },\n iterLinkedDocs: function(f) {linkedDocs(this, f);},\n\n getMode: function() {return this.mode;},\n getEditor: function() {return this.cm;}\n });\n\n // Public alias.\n Doc.prototype.eachLine = Doc.prototype.iter;\n\n // Set up methods on CodeMirror's prototype to redirect to the editor's document.\n var dontDelegate = \"iter insert remove copy getEditor\".split(\" \");\n for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)\n CodeMirror.prototype[prop] = (function(method) {\n return function() {return method.apply(this.doc, arguments);};\n })(Doc.prototype[prop]);\n\n eventMixin(Doc);\n\n // Call f for all linked documents.\n function linkedDocs(doc, f, sharedHistOnly) {\n function propagate(doc, skip, sharedHist) {\n if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {\n var rel = doc.linked[i];\n if (rel.doc == skip) continue;\n var shared = sharedHist && rel.sharedHist;\n if (sharedHistOnly && !shared) continue;\n f(rel.doc, shared);\n propagate(rel.doc, doc, shared);\n }\n }\n propagate(doc, null, true);\n }\n\n // Attach a document to an editor.\n function attachDoc(cm, doc) {\n if (doc.cm) throw new Error(\"This document is already in use.\");\n cm.doc = doc;\n doc.cm = cm;\n estimateLineHeights(cm);\n loadMode(cm);\n if (!cm.options.lineWrapping) findMaxLine(cm);\n cm.options.mode = doc.modeOption;\n regChange(cm);\n }\n\n // LINE UTILITIES\n\n // Find the line object corresponding to the given line number.\n function getLine(doc, n) {\n n -= doc.first;\n if (n < 0 || n >= doc.size) throw new Error(\"There is no line \" + (n + doc.first) + \" in the document.\");\n for (var chunk = doc; !chunk.lines;) {\n for (var i = 0;; ++i) {\n var child = chunk.children[i], sz = child.chunkSize();\n if (n < sz) { chunk = child; break; }\n n -= sz;\n }\n }\n return 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 var out = [], n = start.line;\n doc.iter(start.line, end.line + 1, function(line) {\n var text = line.text;\n if (n == end.line) text = text.slice(0, end.ch);\n if (n == start.line) text = text.slice(start.ch);\n out.push(text);\n ++n;\n });\n return out;\n }\n // Get the lines between from and to, as array of strings.\n function getLines(doc, from, to) {\n var out = [];\n doc.iter(from, to, function(line) { out.push(line.text); });\n return 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 var diff = height - line.height;\n if (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 if (line.parent == null) return null;\n var cur = line.parent, no = indexOf(cur.lines, line);\n for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {\n for (var i = 0;; ++i) {\n if (chunk.children[i] == cur) break;\n no += chunk.children[i].chunkSize();\n }\n }\n return 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 var n = chunk.first;\n outer: do {\n for (var i = 0; i < chunk.children.length; ++i) {\n var child = chunk.children[i], ch = child.height;\n if (h < ch) { chunk = child; continue outer; }\n h -= ch;\n n += child.chunkSize();\n }\n return n;\n } while (!chunk.lines);\n for (var i = 0; i < chunk.lines.length; ++i) {\n var line = chunk.lines[i], lh = line.height;\n if (h < lh) break;\n h -= lh;\n }\n return n + i;\n }\n\n\n // Find the height above the given line.\n function heightAtLine(lineObj) {\n lineObj = visualLine(lineObj);\n\n var h = 0, chunk = lineObj.parent;\n for (var i = 0; i < chunk.lines.length; ++i) {\n var line = chunk.lines[i];\n if (line == lineObj) break;\n else h += line.height;\n }\n for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {\n for (var i = 0; i < p.children.length; ++i) {\n var cur = p.children[i];\n if (cur == chunk) break;\n else h += cur.height;\n }\n }\n return h;\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 var order = line.order;\n if (order == null) order = line.order = bidiOrdering(line.text);\n return order;\n }\n\n // HISTORY\n\n function History(startGen) {\n // Arrays of change events and selections. Doing something adds an\n // event to done and clears undo. Undoing moves events from done\n // to undone, redoing moves them in the other direction.\n this.done = []; this.undone = [];\n this.undoDepth = Infinity;\n // Used to track when changes can be merged into a single undo\n // event\n this.lastModTime = this.lastSelTime = 0;\n this.lastOp = null;\n this.lastOrigin = this.lastSelOrigin = null;\n // Used by the isClean() method\n this.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 var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};\n attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);\n linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);\n return 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 while (array.length) {\n var last = lst(array);\n if (last.ranges) array.pop();\n else break;\n }\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 if (force) {\n clearSelectionEvents(hist.done);\n return lst(hist.done);\n } else if (hist.done.length && !lst(hist.done).ranges) {\n return lst(hist.done);\n } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {\n hist.done.pop();\n return lst(hist.done);\n }\n }\n\n // Register a change in the history. Merges changes that are within\n // a single operation, ore are close together with an origin that\n // allows merging (starting with \"+\") into a single event.\n function addChangeToHistory(doc, change, selAfter, opId) {\n var hist = doc.history;\n hist.undone.length = 0;\n var time = +new Date, cur;\n\n if ((hist.lastOp == opId ||\n hist.lastOrigin == change.origin && change.origin &&\n ((change.origin.charAt(0) == \"+\" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||\n change.origin.charAt(0) == \"*\")) &&\n (cur = lastChangeEvent(hist, hist.lastOp == opId))) {\n // Merge this change into the last event\n var last = lst(cur.changes);\n if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {\n // Optimized case for simple insertion -- don't want to add\n // new changesets for every character typed\n last.to = changeEnd(change);\n } else {\n // Add new sub-event\n cur.changes.push(historyChangeFromChange(doc, change));\n }\n } else {\n // Can not be merged, start a new event.\n var before = lst(hist.done);\n if (!before || !before.ranges)\n pushSelectionToHistory(doc.sel, hist.done);\n cur = {changes: [historyChangeFromChange(doc, change)],\n generation: hist.generation};\n hist.done.push(cur);\n while (hist.done.length > hist.undoDepth) {\n hist.done.shift();\n if (!hist.done[0].ranges) hist.done.shift();\n }\n }\n hist.done.push(selAfter);\n hist.generation = ++hist.maxGeneration;\n hist.lastModTime = hist.lastSelTime = time;\n hist.lastOp = opId;\n hist.lastOrigin = hist.lastSelOrigin = change.origin;\n\n if (!last) signal(doc, \"historyAdded\");\n }\n\n function selectionEventCanBeMerged(doc, origin, prev, sel) {\n var ch = origin.charAt(0);\n return ch == \"*\" ||\n ch == \"+\" &&\n prev.ranges.length == sel.ranges.length &&\n prev.somethingSelected() == sel.somethingSelected() &&\n 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 var hist = doc.history, origin = options && options.origin;\n\n // A new event is started when the previous origin does not match\n // the current, or the origins don't allow matching. Origins\n // starting with * are always merged, those starting with + are\n // merged when similar and close together in time.\n if (opId == hist.lastOp ||\n (origin && hist.lastSelOrigin == origin &&\n (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||\n selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))\n hist.done[hist.done.length - 1] = sel;\n else\n pushSelectionToHistory(sel, hist.done);\n\n hist.lastSelTime = +new Date;\n hist.lastSelOrigin = origin;\n hist.lastOp = opId;\n if (options && options.clearRedo !== false)\n clearSelectionEvents(hist.undone);\n }\n\n function pushSelectionToHistory(sel, dest) {\n var top = lst(dest);\n if (!(top && top.ranges && top.equals(sel)))\n dest.push(sel);\n }\n\n // Used to store marked span information in the history.\n function attachLocalSpans(doc, change, from, to) {\n var existing = change[\"spans_\" + doc.id], n = 0;\n doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {\n if (line.markedSpans)\n (existing || (existing = change[\"spans_\" + doc.id] = {}))[n] = line.markedSpans;\n ++n;\n });\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 if (!spans) return null;\n for (var i = 0, out; i < spans.length; ++i) {\n if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }\n else if (out) out.push(spans[i]);\n }\n return !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 var found = change[\"spans_\" + doc.id];\n if (!found) return null;\n for (var i = 0, nw = []; i < change.text.length; ++i)\n nw.push(removeClearedSpans(found[i]));\n return nw;\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 for (var i = 0, copy = []; i < events.length; ++i) {\n var event = events[i];\n if (event.ranges) {\n copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);\n continue;\n }\n var changes = event.changes, newChanges = [];\n copy.push({changes: newChanges});\n for (var j = 0; j < changes.length; ++j) {\n var change = changes[j], m;\n newChanges.push({from: change.from, to: change.to, text: change.text});\n if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\\d+)$/)) {\n if (indexOf(newGroup, Number(m[1])) > -1) {\n lst(newChanges)[prop] = change[prop];\n delete change[prop];\n }\n }\n }\n }\n return copy;\n }\n\n // Rebasing/resetting history to deal with externally-sourced changes\n\n function rebaseHistSelSingle(pos, from, to, diff) {\n if (to < pos.line) {\n pos.line += diff;\n } else if (from < pos.line) {\n pos.line = from;\n pos.ch = 0;\n }\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 for (var i = 0; i < array.length; ++i) {\n var sub = array[i], ok = true;\n if (sub.ranges) {\n if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }\n for (var j = 0; j < sub.ranges.length; j++) {\n rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);\n rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);\n }\n continue;\n }\n for (var j = 0; j < sub.changes.length; ++j) {\n var cur = sub.changes[j];\n if (to < cur.from.line) {\n cur.from = Pos(cur.from.line + diff, cur.from.ch);\n cur.to = Pos(cur.to.line + diff, cur.to.ch);\n } else if (from <= cur.to.line) {\n ok = false;\n break;\n }\n }\n if (!ok) {\n array.splice(0, i + 1);\n i = 0;\n }\n }\n }\n\n function rebaseHist(hist, change) {\n var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;\n rebaseHistArray(hist.done, from, to, diff);\n rebaseHistArray(hist.undone, from, to, diff);\n }\n\n // EVENT UTILITIES\n\n // Due to the fact that we still support jurassic IE versions, some\n // compatibility wrappers are needed.\n\n var e_preventDefault = CodeMirror.e_preventDefault = function(e) {\n if (e.preventDefault) e.preventDefault();\n else e.returnValue = false;\n };\n var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {\n if (e.stopPropagation) e.stopPropagation();\n else e.cancelBubble = true;\n };\n function e_defaultPrevented(e) {\n return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;\n }\n var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};\n\n function e_target(e) {return e.target || e.srcElement;}\n function e_button(e) {\n var b = e.which;\n if (b == null) {\n if (e.button & 1) b = 1;\n else if (e.button & 2) b = 3;\n else if (e.button & 4) b = 2;\n }\n if (mac && e.ctrlKey && b == 1) b = 3;\n return b;\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 = CodeMirror.on = function(emitter, type, f) {\n if (emitter.addEventListener)\n emitter.addEventListener(type, f, false);\n else if (emitter.attachEvent)\n emitter.attachEvent(\"on\" + type, f);\n else {\n var map = emitter._handlers || (emitter._handlers = {});\n var arr = map[type] || (map[type] = []);\n arr.push(f);\n }\n };\n\n var off = CodeMirror.off = function(emitter, type, f) {\n if (emitter.removeEventListener)\n emitter.removeEventListener(type, f, false);\n else if (emitter.detachEvent)\n emitter.detachEvent(\"on\" + type, f);\n else {\n var arr = emitter._handlers && emitter._handlers[type];\n if (!arr) return;\n for (var i = 0; i < arr.length; ++i)\n if (arr[i] == f) { arr.splice(i, 1); break; }\n }\n };\n\n var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {\n var arr = emitter._handlers && emitter._handlers[type];\n if (!arr) return;\n var args = Array.prototype.slice.call(arguments, 2);\n for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);\n };\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 var delayedCallbacks, delayedCallbackDepth = 0;\n function signalLater(emitter, type /*, values...*/) {\n var arr = emitter._handlers && emitter._handlers[type];\n if (!arr) return;\n var args = Array.prototype.slice.call(arguments, 2);\n if (!delayedCallbacks) {\n ++delayedCallbackDepth;\n delayedCallbacks = [];\n setTimeout(fireDelayed, 0);\n }\n function bnd(f) {return function(){f.apply(null, args);};};\n for (var i = 0; i < arr.length; ++i)\n delayedCallbacks.push(bnd(arr[i]));\n }\n\n function fireDelayed() {\n --delayedCallbackDepth;\n var delayed = delayedCallbacks;\n delayedCallbacks = null;\n for (var i = 0; i < delayed.length; ++i) delayed[i]();\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 signal(cm, override || e.type, cm, e);\n return e_defaultPrevented(e) || e.codemirrorIgnore;\n }\n\n function signalCursorActivity(cm) {\n var arr = cm._handlers && cm._handlers.cursorActivity;\n if (!arr) return;\n var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);\n for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)\n set.push(arr[i]);\n }\n\n function hasHandler(emitter, type) {\n var arr = emitter._handlers && emitter._handlers[type];\n return arr && arr.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 ctor.prototype.on = function(type, f) {on(this, type, f);};\n ctor.prototype.off = function(type, f) {off(this, type, f);};\n }\n\n // MISC UTILITIES\n\n // Number of pixels added to scroller and sizer to hide scrollbar\n var scrollerCutOff = 30;\n\n // Returned or thrown by various protocols to signal 'I'm not\n // handling this'.\n var Pass = CodeMirror.Pass = {toString: function(){return \"CodeMirror.Pass\";}};\n\n // Reused option objects for setSelection & friends\n var sel_dontScroll = {scroll: false}, sel_mouse = {origin: \"*mouse\"}, sel_move = {origin: \"+move\"};\n\n function Delayed() {this.id = null;}\n Delayed.prototype.set = function(ms, f) {\n clearTimeout(this.id);\n this.id = setTimeout(f, ms);\n };\n\n // Counts the column offset in a string, taking tabs into account.\n // Used mostly to find indentation.\n var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {\n if (end == null) {\n end = string.search(/[^\\s\\u00a0]/);\n if (end == -1) end = string.length;\n }\n for (var i = startIndex || 0, n = startValue || 0;;) {\n var nextTab = string.indexOf(\"\\t\", i);\n if (nextTab < 0 || nextTab >= end)\n return n + (end - i);\n n += nextTab - i;\n n += tabSize - (n % tabSize);\n i = nextTab + 1;\n }\n };\n\n // The inverse of countColumn -- find the offset that corresponds to\n // a particular column.\n function findColumn(string, goal, tabSize) {\n for (var pos = 0, col = 0;;) {\n var nextTab = string.indexOf(\"\\t\", pos);\n if (nextTab == -1) nextTab = string.length;\n var skipped = nextTab - pos;\n if (nextTab == string.length || col + skipped >= goal)\n return pos + Math.min(skipped, goal - col);\n col += nextTab - pos;\n col += tabSize - (col % tabSize);\n pos = nextTab + 1;\n if (col >= goal) return pos;\n }\n }\n\n var spaceStrs = [\"\"];\n function spaceStr(n) {\n while (spaceStrs.length <= n)\n spaceStrs.push(lst(spaceStrs) + \" \");\n return spaceStrs[n];\n }\n\n function lst(arr) { return arr[arr.length-1]; }\n\n var selectInput = function(node) { node.select(); };\n if (ios) // Mobile Safari apparently has a bug where select() is broken.\n selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };\n else if (ie) // Suppress mysterious IE10 errors\n selectInput = function(node) { try { node.select(); } catch(_e) {} };\n\n function indexOf(array, elt) {\n for (var i = 0; i < array.length; ++i)\n if (array[i] == elt) return i;\n return -1;\n }\n if ([].indexOf) indexOf = function(array, elt) { return array.indexOf(elt); };\n function map(array, f) {\n var out = [];\n for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);\n return out;\n }\n if ([].map) map = function(array, f) { return array.map(f); };\n\n function createObj(base, props) {\n var inst;\n if (Object.create) {\n inst = Object.create(base);\n } else {\n var ctor = function() {};\n ctor.prototype = base;\n inst = new ctor();\n }\n if (props) copyObj(props, inst);\n return inst;\n };\n\n function copyObj(obj, target, overwrite) {\n if (!target) target = {};\n for (var prop in obj)\n if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))\n target[prop] = obj[prop];\n return target;\n }\n\n function bind(f) {\n var args = Array.prototype.slice.call(arguments, 1);\n return function(){return f.apply(null, args);};\n }\n\n var nonASCIISingleCaseWordChar = /[\\u00df\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\n var isWordCharBasic = CodeMirror.isWordChar = function(ch) {\n return /\\w/.test(ch) || ch > \"\\x80\" &&\n (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));\n };\n function isWordChar(ch, helper) {\n if (!helper) return isWordCharBasic(ch);\n if (helper.source.indexOf(\"\\\\w\") > -1 && isWordCharBasic(ch)) return true;\n return helper.test(ch);\n }\n\n function isEmpty(obj) {\n for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;\n return 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 // DOM UTILITIES\n\n function elt(tag, content, className, style) {\n var e = document.createElement(tag);\n if (className) e.className = className;\n if (style) e.style.cssText = style;\n if (typeof content == \"string\") e.appendChild(document.createTextNode(content));\n else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);\n return e;\n }\n\n var range;\n if (document.createRange) range = function(node, start, end) {\n var r = document.createRange();\n r.setEnd(node, end);\n r.setStart(node, start);\n return r;\n };\n else range = function(node, start, end) {\n var r = document.body.createTextRange();\n r.moveToElementText(node.parentNode);\n r.collapse(true);\n r.moveEnd(\"character\", end);\n r.moveStart(\"character\", start);\n return r;\n };\n\n function removeChildren(e) {\n for (var count = e.childNodes.length; count > 0; --count)\n e.removeChild(e.firstChild);\n return e;\n }\n\n function removeChildrenAndAdd(parent, e) {\n return removeChildren(parent).appendChild(e);\n }\n\n function contains(parent, child) {\n if (parent.contains)\n return parent.contains(child);\n while (child = child.parentNode)\n if (child == parent) return true;\n }\n\n function activeElt() { return document.activeElement; }\n // Older versions of IE throws unspecified error when touching\n // document.activeElement in some cases (during loading, in iframe)\n if (ie_upto10) activeElt = function() {\n try { return document.activeElement; }\n catch(e) { return document.body; }\n };\n\n function classTest(cls) { return new RegExp(\"\\\\b\" + cls + \"\\\\b\\\\s*\"); }\n function rmClass(node, cls) {\n var test = classTest(cls);\n if (test.test(node.className)) node.className = node.className.replace(test, \"\");\n }\n function addClass(node, cls) {\n if (!classTest(cls).test(node.className)) node.className += \" \" + cls;\n }\n function joinClasses(a, b) {\n var as = a.split(\" \");\n for (var i = 0; i < as.length; i++)\n if (as[i] && !classTest(as[i]).test(b)) b += \" \" + as[i];\n return b;\n }\n\n // WINDOW-WIDE EVENTS\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 if (!document.body.getElementsByClassName) return;\n var byClass = document.body.getElementsByClassName(\"CodeMirror\");\n for (var i = 0; i < byClass.length; i++) {\n var cm = byClass[i].CodeMirror;\n if (cm) f(cm);\n }\n }\n\n var globalsRegistered = false;\n function ensureGlobalHandlers() {\n if (globalsRegistered) return;\n registerGlobalHandlers();\n globalsRegistered = true;\n }\n function registerGlobalHandlers() {\n // When the window resizes, we need to refresh active editors.\n var resizeTimer;\n on(window, \"resize\", function() {\n if (resizeTimer == null) resizeTimer = setTimeout(function() {\n resizeTimer = null;\n knownScrollbarWidth = null;\n forEachCodeMirror(onResize);\n }, 100);\n });\n // When the window loses focus, we want to show the editor as blurred\n on(window, \"blur\", function() {\n forEachCodeMirror(onBlur);\n });\n }\n\n // FEATURE DETECTION\n\n // Detect drag-and-drop\n var dragAndDrop = function() {\n // There is *some* kind of drag-and-drop support in IE6-8, but I\n // couldn't get it to work yet.\n if (ie_upto8) return false;\n var div = elt('div');\n return \"draggable\" in div || \"dragDrop\" in div;\n }();\n\n var knownScrollbarWidth;\n function scrollbarWidth(measure) {\n if (knownScrollbarWidth != null) return knownScrollbarWidth;\n var test = elt(\"div\", null, null, \"width: 50px; height: 50px; overflow-x: scroll\");\n removeChildrenAndAdd(measure, test);\n if (test.offsetWidth)\n knownScrollbarWidth = test.offsetHeight - test.clientHeight;\n return knownScrollbarWidth || 0;\n }\n\n var zwspSupported;\n function zeroWidthElement(measure) {\n if (zwspSupported == null) {\n var test = elt(\"span\", \"\\u200b\");\n removeChildrenAndAdd(measure, elt(\"span\", [test, document.createTextNode(\"x\")]));\n if (measure.firstChild.offsetHeight != 0)\n zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_upto7;\n }\n if (zwspSupported) return elt(\"span\", \"\\u200b\");\n else return elt(\"span\", \"\\u00a0\", null, \"display: inline-block; width: 1px; margin-right: -1px\");\n }\n\n // Feature-detect IE's crummy client rect reporting for bidi text\n var badBidiRects;\n function hasBadBidiRects(measure) {\n if (badBidiRects != null) return badBidiRects;\n var txt = removeChildrenAndAdd(measure, document.createTextNode(\"A\\u062eA\"));\n var r0 = range(txt, 0, 1).getBoundingClientRect();\n if (r0.left == r0.right) return false;\n var r1 = range(txt, 1, 2).getBoundingClientRect();\n return 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 splitLines = CodeMirror.splitLines = \"\\n\\nb\".split(/\\n/).length != 3 ? function(string) {\n var pos = 0, result = [], l = string.length;\n while (pos <= l) {\n var nl = string.indexOf(\"\\n\", pos);\n if (nl == -1) nl = string.length;\n var line = string.slice(pos, string.charAt(nl - 1) == \"\\r\" ? nl - 1 : nl);\n var rt = line.indexOf(\"\\r\");\n if (rt != -1) {\n result.push(line.slice(0, rt));\n pos += rt + 1;\n } else {\n result.push(line);\n pos = nl + 1;\n }\n }\n return result;\n } : function(string){return string.split(/\\r\\n?|\\n/);};\n\n var hasSelection = window.getSelection ? function(te) {\n try { return te.selectionStart != te.selectionEnd; }\n catch(e) { return false; }\n } : function(te) {\n try {var range = te.ownerDocument.selection.createRange();}\n catch(e) {}\n if (!range || range.parentElement() != te) return false;\n return range.compareEndPoints(\"StartToEnd\", range) != 0;\n };\n\n var hasCopyEvent = (function() {\n var e = elt(\"div\");\n if (\"oncopy\" in e) return true;\n e.setAttribute(\"oncopy\", \"return;\");\n return typeof e.oncopy == \"function\";\n })();\n\n // KEY NAMES\n\n var keyNames = {3: \"Enter\", 8: \"Backspace\", 9: \"Tab\", 13: \"Enter\", 16: \"Shift\", 17: \"Ctrl\", 18: \"Alt\",\n 19: \"Pause\", 20: \"CapsLock\", 27: \"Esc\", 32: \"Space\", 33: \"PageUp\", 34: \"PageDown\", 35: \"End\",\n 36: \"Home\", 37: \"Left\", 38: \"Up\", 39: \"Right\", 40: \"Down\", 44: \"PrintScrn\", 45: \"Insert\",\n 46: \"Delete\", 59: \";\", 61: \"=\", 91: \"Mod\", 92: \"Mod\", 93: \"Mod\", 107: \"=\", 109: \"-\", 127: \"Delete\",\n 173: \"-\", 186: \";\", 187: \"=\", 188: \",\", 189: \"-\", 190: \".\", 191: \"/\", 192: \"`\", 219: \"[\", 220: \"\\\\\",\n 221: \"]\", 222: \"'\", 63232: \"Up\", 63233: \"Down\", 63234: \"Left\", 63235: \"Right\", 63272: \"Delete\",\n 63273: \"Home\", 63275: \"End\", 63276: \"PageUp\", 63277: \"PageDown\", 63302: \"Insert\"};\n CodeMirror.keyNames = keyNames;\n (function() {\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 = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);\n // Function keys\n for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = \"F\" + i;\n })();\n\n // BIDI HELPERS\n\n function iterateBidiSections(order, from, to, f) {\n if (!order) return f(from, to, \"ltr\");\n var found = false;\n for (var i = 0; i < order.length; ++i) {\n var part = order[i];\n if (part.from < to && part.to > from || from == to && part.to == from) {\n f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? \"rtl\" : \"ltr\");\n found = true;\n }\n }\n if (!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 var order = getOrder(line);\n if (!order) return line.text.length;\n return bidiRight(lst(order));\n }\n\n function lineStart(cm, lineN) {\n var line = getLine(cm.doc, lineN);\n var visual = visualLine(line);\n if (visual != line) lineN = lineNo(visual);\n var order = getOrder(visual);\n var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);\n return Pos(lineN, ch);\n }\n function lineEnd(cm, lineN) {\n var merged, line = getLine(cm.doc, lineN);\n while (merged = collapsedSpanAtEnd(line)) {\n line = merged.find(1, true).line;\n lineN = null;\n }\n var order = getOrder(line);\n var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);\n return Pos(lineN == null ? lineNo(line) : lineN, ch);\n }\n\n function compareBidiLevel(order, a, b) {\n var linedir = order[0].level;\n if (a == linedir) return true;\n if (b == linedir) return false;\n return a < b;\n }\n var bidiOther;\n function getBidiPartAt(order, pos) {\n bidiOther = null;\n for (var i = 0, found; i < order.length; ++i) {\n var cur = order[i];\n if (cur.from < pos && cur.to > pos) return i;\n if ((cur.from == pos || cur.to == pos)) {\n if (found == null) {\n found = i;\n } else if (compareBidiLevel(order, cur.level, order[found].level)) {\n if (cur.from != cur.to) bidiOther = found;\n return i;\n } else {\n if (cur.from != cur.to) bidiOther = i;\n return found;\n }\n }\n }\n return found;\n }\n\n function moveInLine(line, pos, dir, byUnit) {\n if (!byUnit) return pos + dir;\n do pos += dir;\n while (pos > 0 && isExtendingChar(line.text.charAt(pos)));\n return 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 var bidi = getOrder(line);\n if (!bidi) return moveLogically(line, start, dir, byUnit);\n var pos = getBidiPartAt(bidi, start), part = bidi[pos];\n var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);\n\n for (;;) {\n if (target > part.from && target < part.to) return target;\n if (target == part.from || target == part.to) {\n if (getBidiPartAt(bidi, target) == pos) return target;\n part = bidi[pos += dir];\n return (dir > 0) == part.level % 2 ? part.to : part.from;\n } else {\n part = bidi[pos += dir];\n if (!part) return null;\n if ((dir > 0) == part.level % 2)\n target = moveInLine(line, part.to, -1, byUnit);\n else\n target = moveInLine(line, part.from, 1, byUnit);\n }\n }\n }\n\n function moveLogically(line, start, dir, byUnit) {\n var target = start + dir;\n if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;\n return 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 // Character types for codepoints 0 to 0xff\n var lowTypes = \"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN\";\n // Character types for codepoints 0x600 to 0x6ff\n var arabicTypes = \"rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm\";\n function charType(code) {\n if (code <= 0xf7) return lowTypes.charAt(code);\n else if (0x590 <= code && code <= 0x5f4) return \"R\";\n else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);\n else if (0x6ee <= code && code <= 0x8ac) return \"r\";\n else if (0x2000 <= code && code <= 0x200b) return \"w\";\n else if (code == 0x200c) return \"b\";\n else return \"L\";\n }\n\n var bidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;\n var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;\n // Browsers seem to always treat the boundaries of block elements as being L.\n var outerType = \"L\";\n\n function BidiSpan(level, from, to) {\n this.level = level;\n this.from = from; this.to = to;\n }\n\n return function(str) {\n if (!bidiRE.test(str)) return false;\n var len = str.length, types = [];\n for (var i = 0, type; i < len; ++i)\n types.push(type = charType(str.charCodeAt(i)));\n\n // W1. Examine each non-spacing mark (NSM) in the level run, and\n // change the type of the NSM to the type of the previous\n // character. If the NSM is at the start of the level run, it will\n // get the type of sor.\n for (var i = 0, prev = outerType; i < len; ++i) {\n var type = types[i];\n if (type == \"m\") types[i] = prev;\n else prev = type;\n }\n\n // W2. Search backwards from each instance of a European number\n // until the first strong type (R, L, AL, or sor) is found. If an\n // AL is found, change the type of the European number to Arabic\n // number.\n // W3. Change all ALs to R.\n for (var i = 0, cur = outerType; i < len; ++i) {\n var type = types[i];\n if (type == \"1\" && cur == \"r\") types[i] = \"n\";\n else if (isStrong.test(type)) { cur = type; if (type == \"r\") types[i] = \"R\"; }\n }\n\n // W4. A single European separator between two European numbers\n // changes to a European number. A single common separator between\n // two numbers of the same type changes to that type.\n for (var i = 1, prev = types[0]; i < len - 1; ++i) {\n var type = types[i];\n if (type == \"+\" && prev == \"1\" && types[i+1] == \"1\") types[i] = \"1\";\n else if (type == \",\" && prev == types[i+1] &&\n (prev == \"1\" || prev == \"n\")) types[i] = prev;\n prev = type;\n }\n\n // W5. A sequence of European terminators adjacent to European\n // numbers changes to all European numbers.\n // W6. Otherwise, separators and terminators change to Other\n // Neutral.\n for (var i = 0; i < len; ++i) {\n var type = types[i];\n if (type == \",\") types[i] = \"N\";\n else if (type == \"%\") {\n for (var end = i + 1; end < len && types[end] == \"%\"; ++end) {}\n var replace = (i && types[i-1] == \"!\") || (end < len && types[end] == \"1\") ? \"1\" : \"N\";\n for (var j = i; j < end; ++j) types[j] = replace;\n i = end - 1;\n }\n }\n\n // W7. Search backwards from each instance of a European number\n // until the first strong type (R, L, or sor) is found. If an L is\n // found, then change the type of the European number to L.\n for (var i = 0, cur = outerType; i < len; ++i) {\n var type = types[i];\n if (cur == \"L\" && type == \"1\") types[i] = \"L\";\n else if (isStrong.test(type)) cur = type;\n }\n\n // N1. A sequence of neutrals takes the direction of the\n // surrounding strong text if the text on both sides has the same\n // direction. European and Arabic numbers act as if they were R in\n // terms of their influence on neutrals. Start-of-level-run (sor)\n // and end-of-level-run (eor) are used at level run boundaries.\n // N2. Any remaining neutrals take the embedding direction.\n for (var i = 0; i < len; ++i) {\n if (isNeutral.test(types[i])) {\n for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}\n var before = (i ? types[i-1] : outerType) == \"L\";\n var after = (end < len ? types[end] : outerType) == \"L\";\n var replace = before || after ? \"L\" : \"R\";\n for (var j = i; j < end; ++j) types[j] = replace;\n i = end - 1;\n }\n }\n\n // Here we depart from the documented algorithm, in order to avoid\n // building up an actual levels array. Since there are only three\n // levels (0, 1, 2) in an implementation that doesn't take\n // explicit embedding into account, we can build up the order on\n // the fly, without following the level-based algorithm.\n var order = [], m;\n for (var i = 0; i < len;) {\n if (countsAsLeft.test(types[i])) {\n var start = i;\n for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}\n order.push(new BidiSpan(0, start, i));\n } else {\n var pos = i, at = order.length;\n for (++i; i < len && types[i] != \"L\"; ++i) {}\n for (var j = pos; j < i;) {\n if (countsAsNum.test(types[j])) {\n if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));\n var nstart = j;\n for (++j; j < i && countsAsNum.test(types[j]); ++j) {}\n order.splice(at, 0, new BidiSpan(2, nstart, j));\n pos = j;\n } else ++j;\n }\n if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));\n }\n }\n if (order[0].level == 1 && (m = str.match(/^\\s+/))) {\n order[0].from = m[0].length;\n order.unshift(new BidiSpan(0, 0, m[0].length));\n }\n if (lst(order).level == 1 && (m = str.match(/\\s+$/))) {\n lst(order).to -= m[0].length;\n order.push(new BidiSpan(0, len - m[0].length, len));\n }\n if (order[0].level != lst(order).level)\n order.push(new BidiSpan(order[0].level, len, len));\n\n return order;\n };\n })();\n\n // THE END\n\n CodeMirror.version = \"4.1.1\";\n\n return CodeMirror;\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/lib/codemirror.css": {
"type": "text/css",
"title": "$:/plugins/tiddlywiki/codemirror/lib/codemirror.css",
"tags": "[[$:/tags/stylesheet]]",
"text": "/* BASICS */\n\n.CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-family: monospace;\n height: 300px;\n}\n.CodeMirror-scroll {\n /* Set scrolling behaviour here */\n overflow: auto;\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 -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n/* CURSOR */\n\n.CodeMirror div.CodeMirror-cursor {\n border-left: 1px solid black;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n}\n.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {\n width: auto;\n border: 0;\n background: #7e7;\n}\n/* Can style cursor different in overwrite (non-insert) mode */\ndiv.CodeMirror-overwrite div.CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; }\n\n.CodeMirror-ruler {\n border-left: 1px solid #ccc;\n position: absolute;\n}\n\n/* DEFAULT THEME */\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 {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-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\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\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}\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 line-height: 1;\n position: relative;\n overflow: hidden;\n background: white;\n color: black;\n}\n\n.CodeMirror-scroll {\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 -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n.CodeMirror-sizer {\n position: relative;\n border-right: 30px solid transparent;\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n before actuall 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 padding-bottom: 30px;\n z-index: 3;\n}\n.CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n padding-bottom: 30px;\n margin-bottom: -32px;\n display: inline-block;\n /* Hack to make IE7 behave */\n *zoom:1;\n *display:inline;\n}\n.CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n}\n\n.CodeMirror-lines {\n cursor: text;\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}\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 overflow: auto;\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-wrap .CodeMirror-scroll {\n overflow-x: hidden;\n}\n\n.CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n}\n.CodeMirror-measure pre { position: static; }\n\n.CodeMirror div.CodeMirror-cursor {\n position: absolute;\n border-right: none;\n width: 0;\n}\n\ndiv.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n z-index: 1;\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\n.cm-searching {\n background: #ffa;\n background: rgba(255, 255, 0, .4);\n}\n\n/* IE7 hack to prevent it from returning funny offsetTops on the spans */\n.CodeMirror span { *vertical-align: text-bottom; }\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"
},
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.css": {
"type": "text/css",
"title": "$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.css",
"tags": "[[$:/tags/stylesheet]]",
"text": ".CodeMirror-dialog {\n position: absolute;\n left: 0; right: 0;\n background: white;\n z-index: 15;\n padding: .1em .8em;\n overflow: hidden;\n color: #333;\n}\n\n.CodeMirror-dialog-top {\n border-bottom: 1px solid #eee;\n top: 0;\n}\n\n.CodeMirror-dialog-bottom {\n border-top: 1px solid #eee;\n bottom: 0;\n}\n\n.CodeMirror-dialog input {\n border: none;\n outline: none;\n background: transparent;\n width: 20em;\n color: inherit;\n font-family: monospace;\n}\n\n.CodeMirror-dialog button {\n font-size: 70%;\n}\n"
},
"$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js",
"module-type": "library",
"text": "// Open simple dialogs on top of an editor. Relies on dialog.css.\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 function dialogDiv(cm, template, bottom) {\n var wrap = cm.getWrapperElement();\n var dialog;\n dialog = wrap.appendChild(document.createElement(\"div\"));\n if (bottom) {\n dialog.className = \"CodeMirror-dialog CodeMirror-dialog-bottom\";\n } else {\n dialog.className = \"CodeMirror-dialog CodeMirror-dialog-top\";\n }\n if (typeof template == \"string\") {\n dialog.innerHTML = template;\n } else { // Assuming it's a detached DOM element.\n dialog.appendChild(template);\n }\n return dialog;\n }\n\n function closeNotification(cm, newVal) {\n if (cm.state.currentNotificationClose)\n cm.state.currentNotificationClose();\n cm.state.currentNotificationClose = newVal;\n }\n\n CodeMirror.defineExtension(\"openDialog\", function(template, callback, options) {\n closeNotification(this, null);\n var dialog = dialogDiv(this, template, options && options.bottom);\n var closed = false, me = this;\n function close() {\n if (closed) return;\n closed = true;\n dialog.parentNode.removeChild(dialog);\n }\n var inp = dialog.getElementsByTagName(\"input\")[0], button;\n if (inp) {\n if (options && options.value) inp.value = options.value;\n CodeMirror.on(inp, \"keydown\", function(e) {\n if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }\n if (e.keyCode == 13 || e.keyCode == 27) {\n inp.blur();\n CodeMirror.e_stop(e);\n close();\n me.focus();\n if (e.keyCode == 13) callback(inp.value);\n }\n });\n if (options && options.onKeyUp) {\n CodeMirror.on(inp, \"keyup\", function(e) {options.onKeyUp(e, inp.value, close);});\n }\n if (options && options.value) inp.value = options.value;\n inp.focus();\n CodeMirror.on(inp, \"blur\", close);\n } else if (button = dialog.getElementsByTagName(\"button\")[0]) {\n CodeMirror.on(button, \"click\", function() {\n close();\n me.focus();\n });\n button.focus();\n CodeMirror.on(button, \"blur\", close);\n }\n return close;\n });\n\n CodeMirror.defineExtension(\"openConfirm\", function(template, callbacks, options) {\n closeNotification(this, null);\n var dialog = dialogDiv(this, template, options && options.bottom);\n var buttons = dialog.getElementsByTagName(\"button\");\n var closed = false, me = this, blurring = 1;\n function close() {\n if (closed) return;\n closed = true;\n dialog.parentNode.removeChild(dialog);\n me.focus();\n }\n buttons[0].focus();\n for (var i = 0; i < buttons.length; ++i) {\n var b = buttons[i];\n (function(callback) {\n CodeMirror.on(b, \"click\", function(e) {\n CodeMirror.e_preventDefault(e);\n close();\n if (callback) callback(me);\n });\n })(callbacks[i]);\n CodeMirror.on(b, \"blur\", function() {\n --blurring;\n setTimeout(function() { if (blurring <= 0) close(); }, 200);\n });\n CodeMirror.on(b, \"focus\", function() { ++blurring; });\n }\n });\n\n /*\n * openNotification\n * Opens a notification, that can be closed with an optional timer\n * (default 5000ms timer) and always closes on click.\n *\n * If a notification is opened while another is opened, it will close the\n * currently opened one and open the new one immediately.\n */\n CodeMirror.defineExtension(\"openNotification\", function(template, options) {\n closeNotification(this, close);\n var dialog = dialogDiv(this, template, options && options.bottom);\n var duration = options && (options.duration === undefined ? 5000 : options.duration);\n var closed = false, doneTimer;\n\n function close() {\n if (closed) return;\n closed = true;\n clearTimeout(doneTimer);\n dialog.parentNode.removeChild(dialog);\n }\n\n CodeMirror.on(dialog, 'click', function(e) {\n CodeMirror.e_preventDefault(e);\n close();\n });\n if (duration)\n doneTimer = setTimeout(close, options.duration);\n });\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js",
"module-type": "library",
"text": "(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 var ie_lt8 = /MSIE \\d/.test(navigator.userAgent) &&\n (document.documentMode == null || document.documentMode < 8);\n\n var Pos = CodeMirror.Pos;\n\n var matching = {\"(\": \")>\", \")\": \"(<\", \"[\": \"]>\", \"]\": \"[<\", \"{\": \"}>\", \"}\": \"{<\"};\n\n function findMatchingBracket(cm, where, strict, config) {\n var line = cm.getLineHandle(where.line), pos = where.ch - 1;\n var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];\n if (!match) return null;\n var dir = match.charAt(1) == \">\" ? 1 : -1;\n if (strict && (dir > 0) != (pos == where.ch)) return null;\n var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));\n\n var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);\n if (found == null) return null;\n return {from: Pos(where.line, pos), to: found && found.pos,\n match: found && found.ch == match.charAt(0), forward: dir > 0};\n }\n\n // bracketRegex is used to specify which type of bracket to scan\n // should be a regexp, e.g. /[[\\]]/\n //\n // Note: If \"where\" is on an open bracket, then this bracket is ignored.\n //\n // Returns false when no bracket was found, null when it reached\n // maxScanLines and gave up\n function scanForBracket(cm, where, dir, style, config) {\n var maxScanLen = (config && config.maxScanLineLength) || 10000;\n var maxScanLines = (config && config.maxScanLines) || 1000;\n\n var stack = [];\n var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\\]]/;\n var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)\n : Math.max(cm.firstLine() - 1, where.line - maxScanLines);\n for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {\n var line = cm.getLine(lineNo);\n if (!line) continue;\n var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;\n if (line.length > maxScanLen) continue;\n if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);\n for (; pos != end; pos += dir) {\n var ch = line.charAt(pos);\n if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {\n var match = matching[ch];\n if ((match.charAt(1) == \">\") == (dir > 0)) stack.push(ch);\n else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};\n else stack.pop();\n }\n }\n }\n return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;\n }\n\n function matchBrackets(cm, autoclear, config) {\n // Disable brace matching in long lines, since it'll cause hugely slow updates\n var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;\n var marks = [], ranges = cm.listSelections();\n for (var i = 0; i < ranges.length; i++) {\n var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);\n if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {\n var style = match.match ? \"CodeMirror-matchingbracket\" : \"CodeMirror-nonmatchingbracket\";\n marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));\n if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)\n marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));\n }\n }\n\n if (marks.length) {\n // Kludge to work around the IE bug from issue #1193, where text\n // input stops going to the textare whever this fires.\n if (ie_lt8 && cm.state.focused) cm.display.input.focus();\n\n var clear = function() {\n cm.operation(function() {\n for (var i = 0; i < marks.length; i++) marks[i].clear();\n });\n };\n if (autoclear) setTimeout(clear, 800);\n else return clear;\n }\n }\n\n var currentlyHighlighted = null;\n function doMatchBrackets(cm) {\n cm.operation(function() {\n if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}\n currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);\n });\n }\n\n CodeMirror.defineOption(\"matchBrackets\", false, function(cm, val, old) {\n if (old && old != CodeMirror.Init)\n cm.off(\"cursorActivity\", doMatchBrackets);\n if (val) {\n cm.state.matchBrackets = typeof val == \"object\" ? val : {};\n cm.on(\"cursorActivity\", doMatchBrackets);\n }\n });\n\n CodeMirror.defineExtension(\"matchBrackets\", function() {matchBrackets(this, true);});\n CodeMirror.defineExtension(\"findMatchingBracket\", function(pos, strict, config){\n return findMatchingBracket(this, pos, strict, config);\n });\n CodeMirror.defineExtension(\"scanForBracket\", function(pos, dir, style, config){\n return scanForBracket(this, pos, dir, style, config);\n });\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js",
"module-type": "library",
"text": "(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 var Pos = CodeMirror.Pos;\n\n function SearchCursor(doc, query, pos, caseFold) {\n this.atOccurrence = false; this.doc = doc;\n if (caseFold == null && typeof query == \"string\") caseFold = false;\n\n pos = pos ? doc.clipPos(pos) : Pos(0, 0);\n this.pos = {from: pos, to: pos};\n\n // The matches method is filled in based on the type of query.\n // It takes a position and a direction, and returns an object\n // describing the next occurrence of the query, or null if no\n // more matches were found.\n if (typeof query != \"string\") { // Regexp match\n if (!query.global) query = new RegExp(query.source, query.ignoreCase ? \"ig\" : \"g\");\n this.matches = function(reverse, pos) {\n if (reverse) {\n query.lastIndex = 0;\n var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;\n for (;;) {\n query.lastIndex = cutOff;\n var newMatch = query.exec(line);\n if (!newMatch) break;\n match = newMatch;\n start = match.index;\n cutOff = match.index + (match[0].length || 1);\n if (cutOff == line.length) break;\n }\n var matchLen = (match && match[0].length) || 0;\n if (!matchLen) {\n if (start == 0 && line.length == 0) {match = undefined;}\n else if (start != doc.getLine(pos.line).length) {\n matchLen++;\n }\n }\n } else {\n query.lastIndex = pos.ch;\n var line = doc.getLine(pos.line), match = query.exec(line);\n var matchLen = (match && match[0].length) || 0;\n var start = match && match.index;\n if (start + matchLen != line.length && !matchLen) matchLen = 1;\n }\n if (match && matchLen)\n return {from: Pos(pos.line, start),\n to: Pos(pos.line, start + matchLen),\n match: match};\n };\n } else { // String query\n var origQuery = query;\n if (caseFold) query = query.toLowerCase();\n var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};\n var target = query.split(\"\\n\");\n // Different methods for single-line and multi-line queries\n if (target.length == 1) {\n if (!query.length) {\n // Empty string would match anything and never progress, so\n // we define it to match nothing instead.\n this.matches = function() {};\n } else {\n this.matches = function(reverse, pos) {\n if (reverse) {\n var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);\n var match = line.lastIndexOf(query);\n if (match > -1) {\n match = adjustPos(orig, line, match);\n return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};\n }\n } else {\n var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);\n var match = line.indexOf(query);\n if (match > -1) {\n match = adjustPos(orig, line, match) + pos.ch;\n return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};\n }\n }\n };\n }\n } else {\n var origTarget = origQuery.split(\"\\n\");\n this.matches = function(reverse, pos) {\n var last = target.length - 1;\n if (reverse) {\n if (pos.line - (target.length - 1) < doc.firstLine()) return;\n if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;\n var to = Pos(pos.line, origTarget[last].length);\n for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)\n if (target[i] != fold(doc.getLine(ln))) return;\n var line = doc.getLine(ln), cut = line.length - origTarget[0].length;\n if (fold(line.slice(cut)) != target[0]) return;\n return {from: Pos(ln, cut), to: to};\n } else {\n if (pos.line + (target.length - 1) > doc.lastLine()) return;\n var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;\n if (fold(line.slice(cut)) != target[0]) return;\n var from = Pos(pos.line, cut);\n for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)\n if (target[i] != fold(doc.getLine(ln))) return;\n if (doc.getLine(ln).slice(0, origTarget[last].length) != target[last]) return;\n return {from: from, to: Pos(ln, origTarget[last].length)};\n }\n };\n }\n }\n }\n\n SearchCursor.prototype = {\n findNext: function() {return this.find(false);},\n findPrevious: function() {return this.find(true);},\n\n find: function(reverse) {\n var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);\n function savePosAndFail(line) {\n var pos = Pos(line, 0);\n self.pos = {from: pos, to: pos};\n self.atOccurrence = false;\n return false;\n }\n\n for (;;) {\n if (this.pos = this.matches(reverse, pos)) {\n this.atOccurrence = true;\n return this.pos.match || true;\n }\n if (reverse) {\n if (!pos.line) return savePosAndFail(0);\n pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);\n }\n else {\n var maxLine = this.doc.lineCount();\n if (pos.line == maxLine - 1) return savePosAndFail(maxLine);\n pos = Pos(pos.line + 1, 0);\n }\n }\n },\n\n from: function() {if (this.atOccurrence) return this.pos.from;},\n to: function() {if (this.atOccurrence) return this.pos.to;},\n\n replace: function(newText) {\n if (!this.atOccurrence) return;\n var lines = CodeMirror.splitLines(newText);\n this.doc.replaceRange(lines, this.pos.from, this.pos.to);\n this.pos.to = Pos(this.pos.from.line + lines.length - 1,\n lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));\n }\n };\n\n // Maps a position in a case-folded line back to a position in the original line\n // (compensating for codepoints increasing in number during folding)\n function adjustPos(orig, folded, pos) {\n if (orig.length == folded.length) return pos;\n for (var pos1 = Math.min(pos, orig.length);;) {\n var len1 = orig.slice(0, pos1).toLowerCase().length;\n if (len1 < pos) ++pos1;\n else if (len1 > pos) --pos1;\n else return pos1;\n }\n }\n\n CodeMirror.defineExtension(\"getSearchCursor\", function(query, pos, caseFold) {\n return new SearchCursor(this.doc, query, pos, caseFold);\n });\n CodeMirror.defineDocExtension(\"getSearchCursor\", function(query, pos, caseFold) {\n return new SearchCursor(this, query, pos, caseFold);\n });\n\n CodeMirror.defineExtension(\"selectMatches\", function(query, caseFold) {\n var ranges = [], next;\n var cur = this.getSearchCursor(query, this.getCursor(\"from\"), caseFold);\n while (next = cur.findNext()) {\n if (CodeMirror.cmpPos(cur.to(), this.getCursor(\"to\")) > 0) break;\n ranges.push({anchor: cur.from(), head: cur.to()});\n }\n if (ranges.length)\n this.setSelections(ranges, 0);\n });\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js",
"module-type": "library",
"text": "// TODO actually recognize syntax of TypeScript constructs\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(\"javascript\", function(config, parserConfig) {\n var indentUnit = config.indentUnit;\n var statementIndent = parserConfig.statementIndent;\n var jsonldMode = parserConfig.jsonld;\n var jsonMode = parserConfig.json || jsonldMode;\n var isTS = parserConfig.typescript;\n\n // Tokenizer\n\n var keywords = function(){\n function kw(type) {return {type: type, style: \"keyword\"};}\n var A = kw(\"keyword a\"), B = kw(\"keyword b\"), C = kw(\"keyword c\");\n var operator = kw(\"operator\"), atom = {type: \"atom\", style: \"atom\"};\n\n var jsKeywords = {\n \"if\": kw(\"if\"), \"while\": A, \"with\": A, \"else\": B, \"do\": B, \"try\": B, \"finally\": B,\n \"return\": C, \"break\": C, \"continue\": C, \"new\": C, \"delete\": C, \"throw\": C, \"debugger\": C,\n \"var\": kw(\"var\"), \"const\": kw(\"var\"), \"let\": kw(\"var\"),\n \"function\": kw(\"function\"), \"catch\": kw(\"catch\"),\n \"for\": kw(\"for\"), \"switch\": kw(\"switch\"), \"case\": kw(\"case\"), \"default\": kw(\"default\"),\n \"in\": operator, \"typeof\": operator, \"instanceof\": operator,\n \"true\": atom, \"false\": atom, \"null\": atom, \"undefined\": atom, \"NaN\": atom, \"Infinity\": atom,\n \"this\": kw(\"this\"), \"module\": kw(\"module\"), \"class\": kw(\"class\"), \"super\": kw(\"atom\"),\n \"yield\": C, \"export\": kw(\"export\"), \"import\": kw(\"import\"), \"extends\": C\n };\n\n // Extend the 'normal' keywords with the TypeScript language extensions\n if (isTS) {\n var type = {type: \"variable\", style: \"variable-3\"};\n var tsKeywords = {\n // object-like things\n \"interface\": kw(\"interface\"),\n \"extends\": kw(\"extends\"),\n \"constructor\": kw(\"constructor\"),\n\n // scope modifiers\n \"public\": kw(\"public\"),\n \"private\": kw(\"private\"),\n \"protected\": kw(\"protected\"),\n \"static\": kw(\"static\"),\n\n // types\n \"string\": type, \"number\": type, \"bool\": type, \"any\": type\n };\n\n for (var attr in tsKeywords) {\n jsKeywords[attr] = tsKeywords[attr];\n }\n }\n\n return jsKeywords;\n }();\n\n var isOperatorChar = /[+\\-*&%=<>!?|~^]/;\n var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)\"/;\n\n function readRegexp(stream) {\n var escaped = false, next, inSet = false;\n while ((next = stream.next()) != null) {\n if (!escaped) {\n if (next == \"/\" && !inSet) return;\n if (next == \"[\") inSet = true;\n else if (inSet && next == \"]\") inSet = false;\n }\n escaped = !escaped && next == \"\\\\\";\n }\n }\n\n // Used as scratch variables to communicate multiple values without\n // consing up tons of objects.\n var type, content;\n function ret(tp, style, cont) {\n type = tp; content = cont;\n return style;\n }\n function tokenBase(stream, state) {\n var ch = stream.next();\n if (ch == '\"' || ch == \"'\") {\n state.tokenize = tokenString(ch);\n return state.tokenize(stream, state);\n } else if (ch == \".\" && stream.match(/^\\d+(?:[eE][+\\-]?\\d+)?/)) {\n return ret(\"number\", \"number\");\n } else if (ch == \".\" && stream.match(\"..\")) {\n return ret(\"spread\", \"meta\");\n } else if (/[\\[\\]{}\\(\\),;\\:\\.]/.test(ch)) {\n return ret(ch);\n } else if (ch == \"=\" && stream.eat(\">\")) {\n return ret(\"=>\", \"operator\");\n } else if (ch == \"0\" && stream.eat(/x/i)) {\n stream.eatWhile(/[\\da-f]/i);\n return ret(\"number\", \"number\");\n } else if (/\\d/.test(ch)) {\n stream.match(/^\\d*(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/);\n return ret(\"number\", \"number\");\n } else if (ch == \"/\") {\n if (stream.eat(\"*\")) {\n state.tokenize = tokenComment;\n return tokenComment(stream, state);\n } else if (stream.eat(\"/\")) {\n stream.skipToEnd();\n return ret(\"comment\", \"comment\");\n } else if (state.lastType == \"operator\" || state.lastType == \"keyword c\" ||\n state.lastType == \"sof\" || /^[\\[{}\\(,;:]$/.test(state.lastType)) {\n readRegexp(stream);\n stream.eatWhile(/[gimy]/); // 'y' is \"sticky\" option in Mozilla\n return ret(\"regexp\", \"string-2\");\n } else {\n stream.eatWhile(isOperatorChar);\n return ret(\"operator\", \"operator\", stream.current());\n }\n } else if (ch == \"`\") {\n state.tokenize = tokenQuasi;\n return tokenQuasi(stream, state);\n } else if (ch == \"#\") {\n stream.skipToEnd();\n return ret(\"error\", \"error\");\n } else if (isOperatorChar.test(ch)) {\n stream.eatWhile(isOperatorChar);\n return ret(\"operator\", \"operator\", stream.current());\n } else {\n stream.eatWhile(/[\\w\\$_]/);\n var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];\n return (known && state.lastType != \".\") ? ret(known.type, known.style, word) :\n ret(\"variable\", \"variable\", word);\n }\n }\n\n function tokenString(quote) {\n return function(stream, state) {\n var escaped = false, next;\n if (jsonldMode && stream.peek() == \"@\" && stream.match(isJsonldKeyword)){\n state.tokenize = tokenBase;\n return ret(\"jsonld-keyword\", \"meta\");\n }\n while ((next = stream.next()) != null) {\n if (next == quote && !escaped) break;\n escaped = !escaped && next == \"\\\\\";\n }\n if (!escaped) state.tokenize = tokenBase;\n return ret(\"string\", \"string\");\n };\n }\n\n function tokenComment(stream, state) {\n var maybeEnd = false, ch;\n while (ch = stream.next()) {\n if (ch == \"/\" && maybeEnd) {\n state.tokenize = tokenBase;\n break;\n }\n maybeEnd = (ch == \"*\");\n }\n return ret(\"comment\", \"comment\");\n }\n\n function tokenQuasi(stream, state) {\n var escaped = false, next;\n while ((next = stream.next()) != null) {\n if (!escaped && (next == \"`\" || next == \"$\" && stream.eat(\"{\"))) {\n state.tokenize = tokenBase;\n break;\n }\n escaped = !escaped && next == \"\\\\\";\n }\n return ret(\"quasi\", \"string-2\", stream.current());\n }\n\n var brackets = \"([{}])\";\n // This is a crude lookahead trick to try and notice that we're\n // parsing the argument patterns for a fat-arrow function before we\n // actually hit the arrow token. It only works if the arrow is on\n // the same line as the arguments and there's no strange noise\n // (comments) in between. Fallback is to only notice when we hit the\n // arrow, and not declare the arguments as locals for the arrow\n // body.\n function findFatArrow(stream, state) {\n if (state.fatArrowAt) state.fatArrowAt = null;\n var arrow = stream.string.indexOf(\"=>\", stream.start);\n if (arrow < 0) return;\n\n var depth = 0, sawSomething = false;\n for (var pos = arrow - 1; pos >= 0; --pos) {\n var ch = stream.string.charAt(pos);\n var bracket = brackets.indexOf(ch);\n if (bracket >= 0 && bracket < 3) {\n if (!depth) { ++pos; break; }\n if (--depth == 0) break;\n } else if (bracket >= 3 && bracket < 6) {\n ++depth;\n } else if (/[$\\w]/.test(ch)) {\n sawSomething = true;\n } else if (sawSomething && !depth) {\n ++pos;\n break;\n }\n }\n if (sawSomething && !depth) state.fatArrowAt = pos;\n }\n\n // Parser\n\n var atomicTypes = {\"atom\": true, \"number\": true, \"variable\": true, \"string\": true, \"regexp\": true, \"this\": true, \"jsonld-keyword\": true};\n\n function JSLexical(indented, column, type, align, prev, info) {\n this.indented = indented;\n this.column = column;\n this.type = type;\n this.prev = prev;\n this.info = info;\n if (align != null) this.align = align;\n }\n\n function inScope(state, varname) {\n for (var v = state.localVars; v; v = v.next)\n if (v.name == varname) return true;\n for (var cx = state.context; cx; cx = cx.prev) {\n for (var v = cx.vars; v; v = v.next)\n if (v.name == varname) return true;\n }\n }\n\n function parseJS(state, style, type, content, stream) {\n var cc = state.cc;\n // Communicate our context to the combinators.\n // (Less wasteful than consing up a hundred closures on every call.)\n cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;\n\n if (!state.lexical.hasOwnProperty(\"align\"))\n state.lexical.align = true;\n\n while(true) {\n var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;\n if (combinator(type, content)) {\n while(cc.length && cc[cc.length - 1].lex)\n cc.pop()();\n if (cx.marked) return cx.marked;\n if (type == \"variable\" && inScope(state, content)) return \"variable-2\";\n return style;\n }\n }\n }\n\n // Combinator utils\n\n var cx = {state: null, column: null, marked: null, cc: null};\n function pass() {\n for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);\n }\n function cont() {\n pass.apply(null, arguments);\n return true;\n }\n function register(varname) {\n function inList(list) {\n for (var v = list; v; v = v.next)\n if (v.name == varname) return true;\n return false;\n }\n var state = cx.state;\n if (state.context) {\n cx.marked = \"def\";\n if (inList(state.localVars)) return;\n state.localVars = {name: varname, next: state.localVars};\n } else {\n if (inList(state.globalVars)) return;\n if (parserConfig.globalVars)\n state.globalVars = {name: varname, next: state.globalVars};\n }\n }\n\n // Combinators\n\n var defaultVars = {name: \"this\", next: {name: \"arguments\"}};\n function pushcontext() {\n cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};\n cx.state.localVars = defaultVars;\n }\n function popcontext() {\n cx.state.localVars = cx.state.context.vars;\n cx.state.context = cx.state.context.prev;\n }\n function pushlex(type, info) {\n var result = function() {\n var state = cx.state, indent = state.indented;\n if (state.lexical.type == \"stat\") indent = state.lexical.indented;\n state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);\n };\n result.lex = true;\n return result;\n }\n function poplex() {\n var state = cx.state;\n if (state.lexical.prev) {\n if (state.lexical.type == \")\")\n state.indented = state.lexical.indented;\n state.lexical = state.lexical.prev;\n }\n }\n poplex.lex = true;\n\n function expect(wanted) {\n function exp(type) {\n if (type == wanted) return cont();\n else if (wanted == \";\") return pass();\n else return cont(exp);\n };\n return exp;\n }\n\n function statement(type, value) {\n if (type == \"var\") return cont(pushlex(\"vardef\", value.length), vardef, expect(\";\"), poplex);\n if (type == \"keyword a\") return cont(pushlex(\"form\"), expression, statement, poplex);\n if (type == \"keyword b\") return cont(pushlex(\"form\"), statement, poplex);\n if (type == \"{\") return cont(pushlex(\"}\"), block, poplex);\n if (type == \";\") return cont();\n if (type == \"if\") {\n if (cx.state.lexical.info == \"else\" && cx.state.cc[cx.state.cc.length - 1] == poplex)\n cx.state.cc.pop()();\n return cont(pushlex(\"form\"), expression, statement, poplex, maybeelse);\n }\n if (type == \"function\") return cont(functiondef);\n if (type == \"for\") return cont(pushlex(\"form\"), forspec, statement, poplex);\n if (type == \"variable\") return cont(pushlex(\"stat\"), maybelabel);\n if (type == \"switch\") return cont(pushlex(\"form\"), expression, pushlex(\"}\", \"switch\"), expect(\"{\"),\n block, poplex, poplex);\n if (type == \"case\") return cont(expression, expect(\":\"));\n if (type == \"default\") return cont(expect(\":\"));\n if (type == \"catch\") return cont(pushlex(\"form\"), pushcontext, expect(\"(\"), funarg, expect(\")\"),\n statement, poplex, popcontext);\n if (type == \"module\") return cont(pushlex(\"form\"), pushcontext, afterModule, popcontext, poplex);\n if (type == \"class\") return cont(pushlex(\"form\"), className, objlit, poplex);\n if (type == \"export\") return cont(pushlex(\"form\"), afterExport, poplex);\n if (type == \"import\") return cont(pushlex(\"form\"), afterImport, poplex);\n return pass(pushlex(\"stat\"), expression, expect(\";\"), poplex);\n }\n function expression(type) {\n return expressionInner(type, false);\n }\n function expressionNoComma(type) {\n return expressionInner(type, true);\n }\n function expressionInner(type, noComma) {\n if (cx.state.fatArrowAt == cx.stream.start) {\n var body = noComma ? arrowBodyNoComma : arrowBody;\n if (type == \"(\") return cont(pushcontext, pushlex(\")\"), commasep(pattern, \")\"), poplex, expect(\"=>\"), body, popcontext);\n else if (type == \"variable\") return pass(pushcontext, pattern, expect(\"=>\"), body, popcontext);\n }\n\n var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;\n if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);\n if (type == \"function\") return cont(functiondef, maybeop);\n if (type == \"keyword c\") return cont(noComma ? maybeexpressionNoComma : maybeexpression);\n if (type == \"(\") return cont(pushlex(\")\"), maybeexpression, comprehension, expect(\")\"), poplex, maybeop);\n if (type == \"operator\" || type == \"spread\") return cont(noComma ? expressionNoComma : expression);\n if (type == \"[\") return cont(pushlex(\"]\"), arrayLiteral, poplex, maybeop);\n if (type == \"{\") return contCommasep(objprop, \"}\", null, maybeop);\n if (type == \"quasi\") { return pass(quasi, maybeop); }\n return cont();\n }\n function maybeexpression(type) {\n if (type.match(/[;\\}\\)\\],]/)) return pass();\n return pass(expression);\n }\n function maybeexpressionNoComma(type) {\n if (type.match(/[;\\}\\)\\],]/)) return pass();\n return pass(expressionNoComma);\n }\n\n function maybeoperatorComma(type, value) {\n if (type == \",\") return cont(expression);\n return maybeoperatorNoComma(type, value, false);\n }\n function maybeoperatorNoComma(type, value, noComma) {\n var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;\n var expr = noComma == false ? expression : expressionNoComma;\n if (value == \"=>\") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);\n if (type == \"operator\") {\n if (/\\+\\+|--/.test(value)) return cont(me);\n if (value == \"?\") return cont(expression, expect(\":\"), expr);\n return cont(expr);\n }\n if (type == \"quasi\") { return pass(quasi, me); }\n if (type == \";\") return;\n if (type == \"(\") return contCommasep(expressionNoComma, \")\", \"call\", me);\n if (type == \".\") return cont(property, me);\n if (type == \"[\") return cont(pushlex(\"]\"), maybeexpression, expect(\"]\"), poplex, me);\n }\n function quasi(type, value) {\n if (type != \"quasi\") return pass();\n if (value.slice(value.length - 2) != \"${\") return cont(quasi);\n return cont(expression, continueQuasi);\n }\n function continueQuasi(type) {\n if (type == \"}\") {\n cx.marked = \"string-2\";\n cx.state.tokenize = tokenQuasi;\n return cont(quasi);\n }\n }\n function arrowBody(type) {\n findFatArrow(cx.stream, cx.state);\n if (type == \"{\") return pass(statement);\n return pass(expression);\n }\n function arrowBodyNoComma(type) {\n findFatArrow(cx.stream, cx.state);\n if (type == \"{\") return pass(statement);\n return pass(expressionNoComma);\n }\n function maybelabel(type) {\n if (type == \":\") return cont(poplex, statement);\n return pass(maybeoperatorComma, expect(\";\"), poplex);\n }\n function property(type) {\n if (type == \"variable\") {cx.marked = \"property\"; return cont();}\n }\n function objprop(type, value) {\n if (type == \"variable\") {\n cx.marked = \"property\";\n if (value == \"get\" || value == \"set\") return cont(getterSetter);\n } else if (type == \"number\" || type == \"string\") {\n cx.marked = jsonldMode ? \"property\" : (type + \" property\");\n } else if (type == \"[\") {\n return cont(expression, expect(\"]\"), afterprop);\n }\n if (atomicTypes.hasOwnProperty(type)) return cont(afterprop);\n }\n function getterSetter(type) {\n if (type != \"variable\") return pass(afterprop);\n cx.marked = \"property\";\n return cont(functiondef);\n }\n function afterprop(type) {\n if (type == \":\") return cont(expressionNoComma);\n if (type == \"(\") return pass(functiondef);\n }\n function commasep(what, end) {\n function proceed(type) {\n if (type == \",\") {\n var lex = cx.state.lexical;\n if (lex.info == \"call\") lex.pos = (lex.pos || 0) + 1;\n return cont(what, proceed);\n }\n if (type == end) return cont();\n return cont(expect(end));\n }\n return function(type) {\n if (type == end) return cont();\n return pass(what, proceed);\n };\n }\n function contCommasep(what, end, info) {\n for (var i = 3; i < arguments.length; i++)\n cx.cc.push(arguments[i]);\n return cont(pushlex(end, info), commasep(what, end), poplex);\n }\n function block(type) {\n if (type == \"}\") return cont();\n return pass(statement, block);\n }\n function maybetype(type) {\n if (isTS && type == \":\") return cont(typedef);\n }\n function typedef(type) {\n if (type == \"variable\"){cx.marked = \"variable-3\"; return cont();}\n }\n function vardef() {\n return pass(pattern, maybetype, maybeAssign, vardefCont);\n }\n function pattern(type, value) {\n if (type == \"variable\") { register(value); return cont(); }\n if (type == \"[\") return contCommasep(pattern, \"]\");\n if (type == \"{\") return contCommasep(proppattern, \"}\");\n }\n function proppattern(type, value) {\n if (type == \"variable\" && !cx.stream.match(/^\\s*:/, false)) {\n register(value);\n return cont(maybeAssign);\n }\n if (type == \"variable\") cx.marked = \"property\";\n return cont(expect(\":\"), pattern, maybeAssign);\n }\n function maybeAssign(_type, value) {\n if (value == \"=\") return cont(expressionNoComma);\n }\n function vardefCont(type) {\n if (type == \",\") return cont(vardef);\n }\n function maybeelse(type, value) {\n if (type == \"keyword b\" && value == \"else\") return cont(pushlex(\"form\", \"else\"), statement, poplex);\n }\n function forspec(type) {\n if (type == \"(\") return cont(pushlex(\")\"), forspec1, expect(\")\"), poplex);\n }\n function forspec1(type) {\n if (type == \"var\") return cont(vardef, expect(\";\"), forspec2);\n if (type == \";\") return cont(forspec2);\n if (type == \"variable\") return cont(formaybeinof);\n return pass(expression, expect(\";\"), forspec2);\n }\n function formaybeinof(_type, value) {\n if (value == \"in\" || value == \"of\") { cx.marked = \"keyword\"; return cont(expression); }\n return cont(maybeoperatorComma, forspec2);\n }\n function forspec2(type, value) {\n if (type == \";\") return cont(forspec3);\n if (value == \"in\" || value == \"of\") { cx.marked = \"keyword\"; return cont(expression); }\n return pass(expression, expect(\";\"), forspec3);\n }\n function forspec3(type) {\n if (type != \")\") cont(expression);\n }\n function functiondef(type, value) {\n if (value == \"*\") {cx.marked = \"keyword\"; return cont(functiondef);}\n if (type == \"variable\") {register(value); return cont(functiondef);}\n if (type == \"(\") return cont(pushcontext, pushlex(\")\"), commasep(funarg, \")\"), poplex, statement, popcontext);\n }\n function funarg(type) {\n if (type == \"spread\") return cont(funarg);\n return pass(pattern, maybetype);\n }\n function className(type, value) {\n if (type == \"variable\") {register(value); return cont(classNameAfter);}\n }\n function classNameAfter(_type, value) {\n if (value == \"extends\") return cont(expression);\n }\n function objlit(type) {\n if (type == \"{\") return contCommasep(objprop, \"}\");\n }\n function afterModule(type, value) {\n if (type == \"string\") return cont(statement);\n if (type == \"variable\") { register(value); return cont(maybeFrom); }\n }\n function afterExport(_type, value) {\n if (value == \"*\") { cx.marked = \"keyword\"; return cont(maybeFrom, expect(\";\")); }\n if (value == \"default\") { cx.marked = \"keyword\"; return cont(expression, expect(\";\")); }\n return pass(statement);\n }\n function afterImport(type) {\n if (type == \"string\") return cont();\n return pass(importSpec, maybeFrom);\n }\n function importSpec(type, value) {\n if (type == \"{\") return contCommasep(importSpec, \"}\");\n if (type == \"variable\") register(value);\n return cont();\n }\n function maybeFrom(_type, value) {\n if (value == \"from\") { cx.marked = \"keyword\"; return cont(expression); }\n }\n function arrayLiteral(type) {\n if (type == \"]\") return cont();\n return pass(expressionNoComma, maybeArrayComprehension);\n }\n function maybeArrayComprehension(type) {\n if (type == \"for\") return pass(comprehension, expect(\"]\"));\n if (type == \",\") return cont(commasep(expressionNoComma, \"]\"));\n return pass(commasep(expressionNoComma, \"]\"));\n }\n function comprehension(type) {\n if (type == \"for\") return cont(forspec, comprehension);\n if (type == \"if\") return cont(expression, comprehension);\n }\n\n // Interface\n\n return {\n startState: function(basecolumn) {\n var state = {\n tokenize: tokenBase,\n lastType: \"sof\",\n cc: [],\n lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, \"block\", false),\n localVars: parserConfig.localVars,\n context: parserConfig.localVars && {vars: parserConfig.localVars},\n indented: 0\n };\n if (parserConfig.globalVars && typeof parserConfig.globalVars == \"object\")\n state.globalVars = parserConfig.globalVars;\n return state;\n },\n\n token: function(stream, state) {\n if (stream.sol()) {\n if (!state.lexical.hasOwnProperty(\"align\"))\n state.lexical.align = false;\n state.indented = stream.indentation();\n findFatArrow(stream, state);\n }\n if (state.tokenize != tokenComment && stream.eatSpace()) return null;\n var style = state.tokenize(stream, state);\n if (type == \"comment\") return style;\n state.lastType = type == \"operator\" && (content == \"++\" || content == \"--\") ? \"incdec\" : type;\n return parseJS(state, style, type, content, stream);\n },\n\n indent: function(state, textAfter) {\n if (state.tokenize == tokenComment) return CodeMirror.Pass;\n if (state.tokenize != tokenBase) return 0;\n var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;\n // Kludge to prevent 'maybelse' from blocking lexical scope pops\n if (!/^\\s*else\\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {\n var c = state.cc[i];\n if (c == poplex) lexical = lexical.prev;\n else if (c != maybeelse) break;\n }\n if (lexical.type == \"stat\" && firstChar == \"}\") lexical = lexical.prev;\n if (statementIndent && lexical.type == \")\" && lexical.prev.type == \"stat\")\n lexical = lexical.prev;\n var type = lexical.type, closing = firstChar == type;\n\n if (type == \"vardef\") return lexical.indented + (state.lastType == \"operator\" || state.lastType == \",\" ? lexical.info + 1 : 0);\n else if (type == \"form\" && firstChar == \"{\") return lexical.indented;\n else if (type == \"form\") return lexical.indented + indentUnit;\n else if (type == \"stat\")\n return lexical.indented + (state.lastType == \"operator\" || state.lastType == \",\" ? statementIndent || indentUnit : 0);\n else if (lexical.info == \"switch\" && !closing && parserConfig.doubleIndentSwitch != false)\n return lexical.indented + (/^(?:case|default)\\b/.test(textAfter) ? indentUnit : 2 * indentUnit);\n else if (lexical.align) return lexical.column + (closing ? 0 : 1);\n else return lexical.indented + (closing ? 0 : indentUnit);\n },\n\n electricChars: \":{}\",\n blockCommentStart: jsonMode ? null : \"/*\",\n blockCommentEnd: jsonMode ? null : \"*/\",\n lineComment: jsonMode ? null : \"//\",\n fold: \"brace\",\n\n helperType: jsonMode ? \"json\" : \"javascript\",\n jsonldMode: jsonldMode,\n jsonMode: jsonMode\n };\n});\n\nCodeMirror.registerHelper(\"wordChars\", \"javascript\", /[\\\\w$]/);\n\nCodeMirror.defineMIME(\"text/javascript\", \"javascript\");\nCodeMirror.defineMIME(\"text/ecmascript\", \"javascript\");\nCodeMirror.defineMIME(\"application/javascript\", \"javascript\");\nCodeMirror.defineMIME(\"application/ecmascript\", \"javascript\");\nCodeMirror.defineMIME(\"application/json\", {name: \"javascript\", json: true});\nCodeMirror.defineMIME(\"application/x-json\", {name: \"javascript\", json: true});\nCodeMirror.defineMIME(\"application/ld+json\", {name: \"javascript\", jsonld: true});\nCodeMirror.defineMIME(\"text/typescript\", { name: \"javascript\", typescript: true });\nCodeMirror.defineMIME(\"application/typescript\", { name: \"javascript\", typescript: true });\n\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/keymap/vim.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/keymap/vim.js",
"module-type": "library",
"text": "/**\n * Supported keybindings:\n *\n * Motion:\n * h, j, k, l\n * gj, gk\n * e, E, w, W, b, B, ge, gE\n * f<character>, F<character>, t<character>, T<character>\n * $, ^, 0, -, +, _\n * gg, G\n * %\n * '<character>, `<character>\n *\n * Operator:\n * d, y, c\n * dd, yy, cc\n * g~, g~g~\n * >, <, >>, <<\n *\n * Operator-Motion:\n * x, X, D, Y, C, ~\n *\n * Action:\n * a, i, s, A, I, S, o, O\n * zz, z., z<CR>, zt, zb, z-\n * J\n * u, Ctrl-r\n * m<character>\n * r<character>\n *\n * Modes:\n * ESC - leave insert mode, visual mode, and clear input state.\n * Ctrl-[, Ctrl-c - same as ESC.\n *\n * Registers: unnamed, -, a-z, A-Z, 0-9\n * (Does not respect the special case for number registers when delete\n * operator is made with these commands: %, (, ), , /, ?, n, N, {, } )\n * TODO: Implement the remaining registers.\n * Marks: a-z, A-Z, and 0-9\n * TODO: Implement the remaining special marks. They have more complex\n * behavior.\n *\n * Events:\n * 'vim-mode-change' - raised on the editor anytime the current mode changes,\n * Event object: {mode: \"visual\", subMode: \"linewise\"}\n *\n * Code structure:\n * 1. Default keymap\n * 2. Variable declarations and short basic helpers\n * 3. Instance (External API) implementation\n * 4. Internal state tracking objects (input state, counter) implementation\n * and instanstiation\n * 5. Key handler (the main command dispatcher) implementation\n * 6. Motion, operator, and action implementations\n * 7. Helper functions for the key handler, motions, operators, and actions\n * 8. Set up Vim to work as a keymap for CodeMirror.\n */\n\n(function(mod) {\n if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n mod(require(\"../lib/codemirror\"), require(\"../addon/search/searchcursor\"), require(\"../addon/dialog/dialog\"), require(\"../addon/edit/matchbrackets.js\"));\n else if (typeof define == \"function\" && define.amd) // AMD\n define([\"../lib/codemirror\", \"../addon/search/searchcursor\", \"../addon/dialog/dialog\", \"../addon/edit/matchbrackets\"], mod);\n else // Plain browser env\n mod(CodeMirror);\n})(function(CodeMirror) {\n 'use strict';\n\n var defaultKeymap = [\n // Key to key mapping. This goes first to make it possible to override\n // existing mappings.\n { keys: ['<Left>'], type: 'keyToKey', toKeys: ['h'] },\n { keys: ['<Right>'], type: 'keyToKey', toKeys: ['l'] },\n { keys: ['<Up>'], type: 'keyToKey', toKeys: ['k'] },\n { keys: ['<Down>'], type: 'keyToKey', toKeys: ['j'] },\n { keys: ['<Space>'], type: 'keyToKey', toKeys: ['l'] },\n { keys: ['<BS>'], type: 'keyToKey', toKeys: ['h'] },\n { keys: ['<C-Space>'], type: 'keyToKey', toKeys: ['W'] },\n { keys: ['<C-BS>'], type: 'keyToKey', toKeys: ['B'] },\n { keys: ['<S-Space>'], type: 'keyToKey', toKeys: ['w'] },\n { keys: ['<S-BS>'], type: 'keyToKey', toKeys: ['b'] },\n { keys: ['<C-n>'], type: 'keyToKey', toKeys: ['j'] },\n { keys: ['<C-p>'], type: 'keyToKey', toKeys: ['k'] },\n { keys: ['<C-[>'], type: 'keyToKey', toKeys: ['<Esc>'] },\n { keys: ['<C-c>'], type: 'keyToKey', toKeys: ['<Esc>'] },\n { keys: ['s'], type: 'keyToKey', toKeys: ['c', 'l'], context: 'normal' },\n { keys: ['s'], type: 'keyToKey', toKeys: ['x', 'i'], context: 'visual'},\n { keys: ['S'], type: 'keyToKey', toKeys: ['c', 'c'], context: 'normal' },\n { keys: ['S'], type: 'keyToKey', toKeys: ['d', 'c', 'c'], context: 'visual' },\n { keys: ['<Home>'], type: 'keyToKey', toKeys: ['0'] },\n { keys: ['<End>'], type: 'keyToKey', toKeys: ['$'] },\n { keys: ['<PageUp>'], type: 'keyToKey', toKeys: ['<C-b>'] },\n { keys: ['<PageDown>'], type: 'keyToKey', toKeys: ['<C-f>'] },\n { keys: ['<CR>'], type: 'keyToKey', toKeys: ['j', '^'], context: 'normal' },\n // Motions\n { keys: ['H'], type: 'motion',\n motion: 'moveToTopLine',\n motionArgs: { linewise: true, toJumplist: true }},\n { keys: ['M'], type: 'motion',\n motion: 'moveToMiddleLine',\n motionArgs: { linewise: true, toJumplist: true }},\n { keys: ['L'], type: 'motion',\n motion: 'moveToBottomLine',\n motionArgs: { linewise: true, toJumplist: true }},\n { keys: ['h'], type: 'motion',\n motion: 'moveByCharacters',\n motionArgs: { forward: false }},\n { keys: ['l'], type: 'motion',\n motion: 'moveByCharacters',\n motionArgs: { forward: true }},\n { keys: ['j'], type: 'motion',\n motion: 'moveByLines',\n motionArgs: { forward: true, linewise: true }},\n { keys: ['k'], type: 'motion',\n motion: 'moveByLines',\n motionArgs: { forward: false, linewise: true }},\n { keys: ['g','j'], type: 'motion',\n motion: 'moveByDisplayLines',\n motionArgs: { forward: true }},\n { keys: ['g','k'], type: 'motion',\n motion: 'moveByDisplayLines',\n motionArgs: { forward: false }},\n { keys: ['w'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: true, wordEnd: false }},\n { keys: ['W'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: true, wordEnd: false, bigWord: true }},\n { keys: ['e'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: true, wordEnd: true, inclusive: true }},\n { keys: ['E'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: true, wordEnd: true, bigWord: true,\n inclusive: true }},\n { keys: ['b'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: false, wordEnd: false }},\n { keys: ['B'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: false, wordEnd: false, bigWord: true }},\n { keys: ['g', 'e'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: false, wordEnd: true, inclusive: true }},\n { keys: ['g', 'E'], type: 'motion',\n motion: 'moveByWords',\n motionArgs: { forward: false, wordEnd: true, bigWord: true,\n inclusive: true }},\n { keys: ['{'], type: 'motion', motion: 'moveByParagraph',\n motionArgs: { forward: false, toJumplist: true }},\n { keys: ['}'], type: 'motion', motion: 'moveByParagraph',\n motionArgs: { forward: true, toJumplist: true }},\n { keys: ['<C-f>'], type: 'motion',\n motion: 'moveByPage', motionArgs: { forward: true }},\n { keys: ['<C-b>'], type: 'motion',\n motion: 'moveByPage', motionArgs: { forward: false }},\n { keys: ['<C-d>'], type: 'motion',\n motion: 'moveByScroll',\n motionArgs: { forward: true, explicitRepeat: true }},\n { keys: ['<C-u>'], type: 'motion',\n motion: 'moveByScroll',\n motionArgs: { forward: false, explicitRepeat: true }},\n { keys: ['g', 'g'], type: 'motion',\n motion: 'moveToLineOrEdgeOfDocument',\n motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }},\n { keys: ['G'], type: 'motion',\n motion: 'moveToLineOrEdgeOfDocument',\n motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }},\n { keys: ['0'], type: 'motion', motion: 'moveToStartOfLine' },\n { keys: ['^'], type: 'motion',\n motion: 'moveToFirstNonWhiteSpaceCharacter' },\n { keys: ['+'], type: 'motion',\n motion: 'moveByLines',\n motionArgs: { forward: true, toFirstChar:true }},\n { keys: ['-'], type: 'motion',\n motion: 'moveByLines',\n motionArgs: { forward: false, toFirstChar:true }},\n { keys: ['_'], type: 'motion',\n motion: 'moveByLines',\n motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }},\n { keys: ['$'], type: 'motion',\n motion: 'moveToEol',\n motionArgs: { inclusive: true }},\n { keys: ['%'], type: 'motion',\n motion: 'moveToMatchedSymbol',\n motionArgs: { inclusive: true, toJumplist: true }},\n { keys: ['f', 'character'], type: 'motion',\n motion: 'moveToCharacter',\n motionArgs: { forward: true , inclusive: true }},\n { keys: ['F', 'character'], type: 'motion',\n motion: 'moveToCharacter',\n motionArgs: { forward: false }},\n { keys: ['t', 'character'], type: 'motion',\n motion: 'moveTillCharacter',\n motionArgs: { forward: true, inclusive: true }},\n { keys: ['T', 'character'], type: 'motion',\n motion: 'moveTillCharacter',\n motionArgs: { forward: false }},\n { keys: [';'], type: 'motion', motion: 'repeatLastCharacterSearch',\n motionArgs: { forward: true }},\n { keys: [','], type: 'motion', motion: 'repeatLastCharacterSearch',\n motionArgs: { forward: false }},\n { keys: ['\\'', 'character'], type: 'motion', motion: 'goToMark',\n motionArgs: {toJumplist: true, linewise: true}},\n { keys: ['`', 'character'], type: 'motion', motion: 'goToMark',\n motionArgs: {toJumplist: true}},\n { keys: [']', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } },\n { keys: ['[', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } },\n { keys: [']', '\\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } },\n { keys: ['[', '\\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } },\n // the next two aren't motions but must come before more general motion declarations\n { keys: [']', 'p'], type: 'action', action: 'paste', isEdit: true,\n actionArgs: { after: true, isEdit: true, matchIndent: true}},\n { keys: ['[', 'p'], type: 'action', action: 'paste', isEdit: true,\n actionArgs: { after: false, isEdit: true, matchIndent: true}},\n { keys: [']', 'character'], type: 'motion',\n motion: 'moveToSymbol',\n motionArgs: { forward: true, toJumplist: true}},\n { keys: ['[', 'character'], type: 'motion',\n motion: 'moveToSymbol',\n motionArgs: { forward: false, toJumplist: true}},\n { keys: ['|'], type: 'motion',\n motion: 'moveToColumn',\n motionArgs: { }},\n { keys: ['o'], type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: { },context:'visual'},\n // Operators\n { keys: ['d'], type: 'operator', operator: 'delete' },\n { keys: ['y'], type: 'operator', operator: 'yank' },\n { keys: ['c'], type: 'operator', operator: 'change' },\n { keys: ['>'], type: 'operator', operator: 'indent',\n operatorArgs: { indentRight: true }},\n { keys: ['<'], type: 'operator', operator: 'indent',\n operatorArgs: { indentRight: false }},\n { keys: ['g', '~'], type: 'operator', operator: 'swapcase' },\n { keys: ['n'], type: 'motion', motion: 'findNext',\n motionArgs: { forward: true, toJumplist: true }},\n { keys: ['N'], type: 'motion', motion: 'findNext',\n motionArgs: { forward: false, toJumplist: true }},\n // Operator-Motion dual commands\n { keys: ['x'], type: 'operatorMotion', operator: 'delete',\n motion: 'moveByCharacters', motionArgs: { forward: true },\n operatorMotionArgs: { visualLine: false }},\n { keys: ['X'], type: 'operatorMotion', operator: 'delete',\n motion: 'moveByCharacters', motionArgs: { forward: false },\n operatorMotionArgs: { visualLine: true }},\n { keys: ['D'], type: 'operatorMotion', operator: 'delete',\n motion: 'moveToEol', motionArgs: { inclusive: true },\n operatorMotionArgs: { visualLine: true }},\n { keys: ['Y'], type: 'operatorMotion', operator: 'yank',\n motion: 'moveToEol', motionArgs: { inclusive: true },\n operatorMotionArgs: { visualLine: true }},\n { keys: ['C'], type: 'operatorMotion',\n operator: 'change',\n motion: 'moveToEol', motionArgs: { inclusive: true },\n operatorMotionArgs: { visualLine: true }},\n { keys: ['~'], type: 'operatorMotion',\n operator: 'swapcase', operatorArgs: { shouldMoveCursor: true },\n motion: 'moveByCharacters', motionArgs: { forward: true }},\n // Actions\n { keys: ['<C-i>'], type: 'action', action: 'jumpListWalk',\n actionArgs: { forward: true }},\n { keys: ['<C-o>'], type: 'action', action: 'jumpListWalk',\n actionArgs: { forward: false }},\n { keys: ['<C-e>'], type: 'action',\n action: 'scroll',\n actionArgs: { forward: true, linewise: true }},\n { keys: ['<C-y>'], type: 'action',\n action: 'scroll',\n actionArgs: { forward: false, linewise: true }},\n { keys: ['a'], type: 'action', action: 'enterInsertMode', isEdit: true,\n actionArgs: { insertAt: 'charAfter' }},\n { keys: ['A'], type: 'action', action: 'enterInsertMode', isEdit: true,\n actionArgs: { insertAt: 'eol' }},\n { keys: ['i'], type: 'action', action: 'enterInsertMode', isEdit: true,\n actionArgs: { insertAt: 'inplace' }},\n { keys: ['I'], type: 'action', action: 'enterInsertMode', isEdit: true,\n actionArgs: { insertAt: 'firstNonBlank' }},\n { keys: ['o'], type: 'action', action: 'newLineAndEnterInsertMode',\n isEdit: true, interlaceInsertRepeat: true,\n actionArgs: { after: true }},\n { keys: ['O'], type: 'action', action: 'newLineAndEnterInsertMode',\n isEdit: true, interlaceInsertRepeat: true,\n actionArgs: { after: false }},\n { keys: ['v'], type: 'action', action: 'toggleVisualMode' },\n { keys: ['V'], type: 'action', action: 'toggleVisualMode',\n actionArgs: { linewise: true }},\n { keys: ['g', 'v'], type: 'action', action: 'reselectLastSelection' },\n { keys: ['J'], type: 'action', action: 'joinLines', isEdit: true },\n { keys: ['p'], type: 'action', action: 'paste', isEdit: true,\n actionArgs: { after: true, isEdit: true }},\n { keys: ['P'], type: 'action', action: 'paste', isEdit: true,\n actionArgs: { after: false, isEdit: true }},\n { keys: ['r', 'character'], type: 'action', action: 'replace', isEdit: true },\n { keys: ['@', 'character'], type: 'action', action: 'replayMacro' },\n { keys: ['q', 'character'], type: 'action', action: 'enterMacroRecordMode' },\n // Handle Replace-mode as a special case of insert mode.\n { keys: ['R'], type: 'action', action: 'enterInsertMode', isEdit: true,\n actionArgs: { replace: true }},\n { keys: ['u'], type: 'action', action: 'undo' },\n { keys: ['u'], type: 'action', action: 'changeCase', actionArgs: {toLower: true}, context: 'visual', isEdit: true },\n { keys: ['U'],type: 'action', action: 'changeCase', actionArgs: {toLower: false}, context: 'visual', isEdit: true },\n { keys: ['<C-r>'], type: 'action', action: 'redo' },\n { keys: ['m', 'character'], type: 'action', action: 'setMark' },\n { keys: ['\"', 'character'], type: 'action', action: 'setRegister' },\n { keys: ['z', 'z'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'center' }},\n { keys: ['z', '.'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'center' },\n motion: 'moveToFirstNonWhiteSpaceCharacter' },\n { keys: ['z', 't'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'top' }},\n { keys: ['z', '<CR>'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'top' },\n motion: 'moveToFirstNonWhiteSpaceCharacter' },\n { keys: ['z', '-'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'bottom' }},\n { keys: ['z', 'b'], type: 'action', action: 'scrollToCursor',\n actionArgs: { position: 'bottom' },\n motion: 'moveToFirstNonWhiteSpaceCharacter' },\n { keys: ['.'], type: 'action', action: 'repeatLastEdit' },\n { keys: ['<C-a>'], type: 'action', action: 'incrementNumberToken',\n isEdit: true,\n actionArgs: {increase: true, backtrack: false}},\n { keys: ['<C-x>'], type: 'action', action: 'incrementNumberToken',\n isEdit: true,\n actionArgs: {increase: false, backtrack: false}},\n // Text object motions\n { keys: ['a', 'character'], type: 'motion',\n motion: 'textObjectManipulation' },\n { keys: ['i', 'character'], type: 'motion',\n motion: 'textObjectManipulation',\n motionArgs: { textObjectInner: true }},\n // Search\n { keys: ['/'], type: 'search',\n searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }},\n { keys: ['?'], type: 'search',\n searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }},\n { keys: ['*'], type: 'search',\n searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }},\n { keys: ['#'], type: 'search',\n searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }},\n { keys: ['g', '*'], type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }},\n { keys: ['g', '#'], type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }},\n // Ex command\n { keys: [':'], type: 'ex' }\n ];\n\n var Pos = CodeMirror.Pos;\n\n var Vim = function() {\n CodeMirror.defineOption('vimMode', false, function(cm, val) {\n if (val) {\n cm.setOption('keyMap', 'vim');\n cm.setOption('disableInput', true);\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"normal\"});\n cm.on('beforeSelectionChange', beforeSelectionChange);\n cm.on('cursorActivity', onCursorActivity);\n maybeInitVimState(cm);\n CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm));\n } else if (cm.state.vim) {\n cm.setOption('keyMap', 'default');\n cm.setOption('disableInput', false);\n cm.off('beforeSelectionChange', beforeSelectionChange);\n cm.off('cursorActivity', onCursorActivity);\n CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm));\n cm.state.vim = null;\n }\n });\n function beforeSelectionChange(cm, obj) {\n var vim = cm.state.vim;\n if (vim.insertMode || vim.exMode) return;\n\n var head = obj.ranges[0].head;\n var anchor = obj.ranges[0].anchor;\n if (head.ch && head.ch == cm.doc.getLine(head.line).length) {\n var pos = Pos(head.line, head.ch - 1);\n obj.update([{anchor: cursorEqual(head, anchor) ? pos : anchor,\n head: pos}]);\n }\n }\n function getOnPasteFn(cm) {\n var vim = cm.state.vim;\n if (!vim.onPasteFn) {\n vim.onPasteFn = function() {\n if (!vim.insertMode) {\n cm.setCursor(offsetCursor(cm.getCursor(), 0, 1));\n actions.enterInsertMode(cm, {}, vim);\n }\n };\n }\n return vim.onPasteFn;\n }\n\n var numberRegex = /[\\d]/;\n var wordRegexp = [(/\\w/), (/[^\\w\\s]/)], bigWordRegexp = [(/\\S/)];\n function makeKeyRange(start, size) {\n var keys = [];\n for (var i = start; i < start + size; i++) {\n keys.push(String.fromCharCode(i));\n }\n return keys;\n }\n var upperCaseAlphabet = makeKeyRange(65, 26);\n var lowerCaseAlphabet = makeKeyRange(97, 26);\n var numbers = makeKeyRange(48, 10);\n var specialSymbols = '~`!@#$%^&*()_-+=[{}]\\\\|/?.,<>:;\"\\''.split('');\n var specialKeys = ['Left', 'Right', 'Up', 'Down', 'Space', 'Backspace',\n 'Esc', 'Home', 'End', 'PageUp', 'PageDown', 'Enter'];\n var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']);\n var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '\"', '.', ':']);\n\n function isLine(cm, line) {\n return line >= cm.firstLine() && line <= cm.lastLine();\n }\n function isLowerCase(k) {\n return (/^[a-z]$/).test(k);\n }\n function isMatchableSymbol(k) {\n return '()[]{}'.indexOf(k) != -1;\n }\n function isNumber(k) {\n return numberRegex.test(k);\n }\n function isUpperCase(k) {\n return (/^[A-Z]$/).test(k);\n }\n function isWhiteSpaceString(k) {\n return (/^\\s*$/).test(k);\n }\n function inArray(val, arr) {\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] == val) {\n return true;\n }\n }\n return false;\n }\n\n var options = {};\n function defineOption(name, defaultValue, type) {\n if (defaultValue === undefined) { throw Error('defaultValue is required'); }\n if (!type) { type = 'string'; }\n options[name] = {\n type: type,\n defaultValue: defaultValue\n };\n setOption(name, defaultValue);\n }\n\n function setOption(name, value) {\n var option = options[name];\n if (!option) {\n throw Error('Unknown option: ' + name);\n }\n if (option.type == 'boolean') {\n if (value && value !== true) {\n throw Error('Invalid argument: ' + name + '=' + value);\n } else if (value !== false) {\n // Boolean options are set to true if value is not defined.\n value = true;\n }\n }\n option.value = option.type == 'boolean' ? !!value : value;\n }\n\n function getOption(name) {\n var option = options[name];\n if (!option) {\n throw Error('Unknown option: ' + name);\n }\n return option.value;\n }\n\n var createCircularJumpList = function() {\n var size = 100;\n var pointer = -1;\n var head = 0;\n var tail = 0;\n var buffer = new Array(size);\n function add(cm, oldCur, newCur) {\n var current = pointer % size;\n var curMark = buffer[current];\n function useNextSlot(cursor) {\n var next = ++pointer % size;\n var trashMark = buffer[next];\n if (trashMark) {\n trashMark.clear();\n }\n buffer[next] = cm.setBookmark(cursor);\n }\n if (curMark) {\n var markPos = curMark.find();\n // avoid recording redundant cursor position\n if (markPos && !cursorEqual(markPos, oldCur)) {\n useNextSlot(oldCur);\n }\n } else {\n useNextSlot(oldCur);\n }\n useNextSlot(newCur);\n head = pointer;\n tail = pointer - size + 1;\n if (tail < 0) {\n tail = 0;\n }\n }\n function move(cm, offset) {\n pointer += offset;\n if (pointer > head) {\n pointer = head;\n } else if (pointer < tail) {\n pointer = tail;\n }\n var mark = buffer[(size + pointer) % size];\n // skip marks that are temporarily removed from text buffer\n if (mark && !mark.find()) {\n var inc = offset > 0 ? 1 : -1;\n var newCur;\n var oldCur = cm.getCursor();\n do {\n pointer += inc;\n mark = buffer[(size + pointer) % size];\n // skip marks that are the same as current position\n if (mark &&\n (newCur = mark.find()) &&\n !cursorEqual(oldCur, newCur)) {\n break;\n }\n } while (pointer < head && pointer > tail);\n }\n return mark;\n }\n return {\n cachedCursor: undefined, //used for # and * jumps\n add: add,\n move: move\n };\n };\n\n // Returns an object to track the changes associated insert mode. It\n // clones the object that is passed in, or creates an empty object one if\n // none is provided.\n var createInsertModeChanges = function(c) {\n if (c) {\n // Copy construction\n return {\n changes: c.changes,\n expectCursorActivityForChange: c.expectCursorActivityForChange\n };\n }\n return {\n // Change list\n changes: [],\n // Set to true on change, false on cursorActivity.\n expectCursorActivityForChange: false\n };\n };\n\n function MacroModeState() {\n this.latestRegister = undefined;\n this.isPlaying = false;\n this.isRecording = false;\n this.replaySearchQueries = [];\n this.onRecordingDone = undefined;\n this.lastInsertModeChanges = createInsertModeChanges();\n }\n MacroModeState.prototype = {\n exitMacroRecordMode: function() {\n var macroModeState = vimGlobalState.macroModeState;\n macroModeState.onRecordingDone(); // close dialog\n macroModeState.onRecordingDone = undefined;\n macroModeState.isRecording = false;\n },\n enterMacroRecordMode: function(cm, registerName) {\n var register =\n vimGlobalState.registerController.getRegister(registerName);\n if (register) {\n register.clear();\n this.latestRegister = registerName;\n this.onRecordingDone = cm.openDialog(\n '(recording)['+registerName+']', null, {bottom:true});\n this.isRecording = true;\n }\n }\n };\n\n function maybeInitVimState(cm) {\n if (!cm.state.vim) {\n // Store instance state in the CodeMirror object.\n cm.state.vim = {\n inputState: new InputState(),\n // Vim's input state that triggered the last edit, used to repeat\n // motions and operators with '.'.\n lastEditInputState: undefined,\n // Vim's action command before the last edit, used to repeat actions\n // with '.' and insert mode repeat.\n lastEditActionCommand: undefined,\n // When using jk for navigation, if you move from a longer line to a\n // shorter line, the cursor may clip to the end of the shorter line.\n // If j is pressed again and cursor goes to the next line, the\n // cursor should go back to its horizontal position on the longer\n // line if it can. This is to keep track of the horizontal position.\n lastHPos: -1,\n // Doing the same with screen-position for gj/gk\n lastHSPos: -1,\n // The last motion command run. Cleared if a non-motion command gets\n // executed in between.\n lastMotion: null,\n marks: {},\n insertMode: false,\n // Repeat count for changes made in insert mode, triggered by key\n // sequences like 3,i. Only exists when insertMode is true.\n insertModeRepeat: undefined,\n visualMode: false,\n // If we are in visual line mode. No effect if visualMode is false.\n visualLine: false,\n lastSelection: null\n };\n }\n return cm.state.vim;\n }\n var vimGlobalState;\n function resetVimGlobalState() {\n vimGlobalState = {\n // The current search query.\n searchQuery: null,\n // Whether we are searching backwards.\n searchIsReversed: false,\n // Replace part of the last substituted pattern\n lastSubstituteReplacePart: undefined,\n jumpList: createCircularJumpList(),\n macroModeState: new MacroModeState,\n // Recording latest f, t, F or T motion command.\n lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},\n registerController: new RegisterController({})\n };\n for (var optionName in options) {\n var option = options[optionName];\n option.value = option.defaultValue;\n }\n }\n\n var vimApi= {\n buildKeyMap: function() {\n // TODO: Convert keymap into dictionary format for fast lookup.\n },\n // Testing hook, though it might be useful to expose the register\n // controller anyways.\n getRegisterController: function() {\n return vimGlobalState.registerController;\n },\n // Testing hook.\n resetVimGlobalState_: resetVimGlobalState,\n\n // Testing hook.\n getVimGlobalState_: function() {\n return vimGlobalState;\n },\n\n // Testing hook.\n maybeInitVimState_: maybeInitVimState,\n\n InsertModeKey: InsertModeKey,\n map: function(lhs, rhs, ctx) {\n // Add user defined key bindings.\n exCommandDispatcher.map(lhs, rhs, ctx);\n },\n setOption: setOption,\n getOption: getOption,\n defineOption: defineOption,\n defineEx: function(name, prefix, func){\n if (name.indexOf(prefix) !== 0) {\n throw new Error('(Vim.defineEx) \"'+prefix+'\" is not a prefix of \"'+name+'\", command not registered');\n }\n exCommands[name]=func;\n exCommandDispatcher.commandMap_[prefix]={name:name, shortName:prefix, type:'api'};\n },\n // This is the outermost function called by CodeMirror, after keys have\n // been mapped to their Vim equivalents.\n handleKey: function(cm, key) {\n var command;\n var vim = maybeInitVimState(cm);\n var macroModeState = vimGlobalState.macroModeState;\n if (macroModeState.isRecording) {\n if (key == 'q') {\n macroModeState.exitMacroRecordMode();\n vim.inputState = new InputState();\n return;\n }\n }\n if (key == '<Esc>') {\n // Clear input state and get back to normal mode.\n vim.inputState = new InputState();\n if (vim.visualMode) {\n exitVisualMode(cm);\n }\n return;\n }\n // Enter visual mode when the mouse selects text.\n if (!vim.visualMode &&\n !cursorEqual(cm.getCursor('head'), cm.getCursor('anchor'))) {\n vim.visualMode = true;\n vim.visualLine = false;\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"visual\"});\n cm.on('mousedown', exitVisualMode);\n }\n if (key != '0' || (key == '0' && vim.inputState.getRepeat() === 0)) {\n // Have to special case 0 since it's both a motion and a number.\n command = commandDispatcher.matchCommand(key, defaultKeymap, vim);\n }\n if (!command) {\n if (isNumber(key)) {\n // Increment count unless count is 0 and key is 0.\n vim.inputState.pushRepeatDigit(key);\n }\n if (macroModeState.isRecording) {\n logKey(macroModeState, key);\n }\n return;\n }\n if (command.type == 'keyToKey') {\n // TODO: prevent infinite recursion.\n for (var i = 0; i < command.toKeys.length; i++) {\n this.handleKey(cm, command.toKeys[i]);\n }\n } else {\n if (macroModeState.isRecording) {\n logKey(macroModeState, key);\n }\n commandDispatcher.processCommand(cm, vim, command);\n }\n },\n handleEx: function(cm, input) {\n exCommandDispatcher.processCommand(cm, input);\n }\n };\n\n // Represents the current input state.\n function InputState() {\n this.prefixRepeat = [];\n this.motionRepeat = [];\n\n this.operator = null;\n this.operatorArgs = null;\n this.motion = null;\n this.motionArgs = null;\n this.keyBuffer = []; // For matching multi-key commands.\n this.registerName = null; // Defaults to the unnamed register.\n }\n InputState.prototype.pushRepeatDigit = function(n) {\n if (!this.operator) {\n this.prefixRepeat = this.prefixRepeat.concat(n);\n } else {\n this.motionRepeat = this.motionRepeat.concat(n);\n }\n };\n InputState.prototype.getRepeat = function() {\n var repeat = 0;\n if (this.prefixRepeat.length > 0 || this.motionRepeat.length > 0) {\n repeat = 1;\n if (this.prefixRepeat.length > 0) {\n repeat *= parseInt(this.prefixRepeat.join(''), 10);\n }\n if (this.motionRepeat.length > 0) {\n repeat *= parseInt(this.motionRepeat.join(''), 10);\n }\n }\n return repeat;\n };\n\n /*\n * Register stores information about copy and paste registers. Besides\n * text, a register must store whether it is linewise (i.e., when it is\n * pasted, should it insert itself into a new line, or should the text be\n * inserted at the cursor position.)\n */\n function Register(text, linewise) {\n this.clear();\n this.keyBuffer = [text || ''];\n this.insertModeChanges = [];\n this.searchQueries = [];\n this.linewise = !!linewise;\n }\n Register.prototype = {\n setText: function(text, linewise) {\n this.keyBuffer = [text || ''];\n this.linewise = !!linewise;\n },\n pushText: function(text, linewise) {\n // if this register has ever been set to linewise, use linewise.\n if (linewise) {\n if (!this.linewise) {\n this.keyBuffer.push('\\n');\n }\n this.linewise = true;\n }\n this.keyBuffer.push(text);\n },\n pushInsertModeChanges: function(changes) {\n this.insertModeChanges.push(createInsertModeChanges(changes));\n },\n pushSearchQuery: function(query) {\n this.searchQueries.push(query);\n },\n clear: function() {\n this.keyBuffer = [];\n this.insertModeChanges = [];\n this.searchQueries = [];\n this.linewise = false;\n },\n toString: function() {\n return this.keyBuffer.join('');\n }\n };\n\n /*\n * vim registers allow you to keep many independent copy and paste buffers.\n * See http://usevim.com/2012/04/13/registers/ for an introduction.\n *\n * RegisterController keeps the state of all the registers. An initial\n * state may be passed in. The unnamed register '\"' will always be\n * overridden.\n */\n function RegisterController(registers) {\n this.registers = registers;\n this.unnamedRegister = registers['\"'] = new Register();\n registers['.'] = new Register();\n registers[':'] = new Register();\n }\n RegisterController.prototype = {\n pushText: function(registerName, operator, text, linewise) {\n if (linewise && text.charAt(0) == '\\n') {\n text = text.slice(1) + '\\n';\n }\n if (linewise && text.charAt(text.length - 1) !== '\\n'){\n text += '\\n';\n }\n // Lowercase and uppercase registers refer to the same register.\n // Uppercase just means append.\n var register = this.isValidRegister(registerName) ?\n this.getRegister(registerName) : null;\n // if no register/an invalid register was specified, things go to the\n // default registers\n if (!register) {\n switch (operator) {\n case 'yank':\n // The 0 register contains the text from the most recent yank.\n this.registers['0'] = new Register(text, linewise);\n break;\n case 'delete':\n case 'change':\n if (text.indexOf('\\n') == -1) {\n // Delete less than 1 line. Update the small delete register.\n this.registers['-'] = new Register(text, linewise);\n } else {\n // Shift down the contents of the numbered registers and put the\n // deleted text into register 1.\n this.shiftNumericRegisters_();\n this.registers['1'] = new Register(text, linewise);\n }\n break;\n }\n // Make sure the unnamed register is set to what just happened\n this.unnamedRegister.setText(text, linewise);\n return;\n }\n\n // If we've gotten to this point, we've actually specified a register\n var append = isUpperCase(registerName);\n if (append) {\n register.pushText(text, linewise);\n } else {\n register.setText(text, linewise);\n }\n // The unnamed register always has the same value as the last used\n // register.\n this.unnamedRegister.setText(register.toString(), linewise);\n },\n // Gets the register named @name. If one of @name doesn't already exist,\n // create it. If @name is invalid, return the unnamedRegister.\n getRegister: function(name) {\n if (!this.isValidRegister(name)) {\n return this.unnamedRegister;\n }\n name = name.toLowerCase();\n if (!this.registers[name]) {\n this.registers[name] = new Register();\n }\n return this.registers[name];\n },\n isValidRegister: function(name) {\n return name && inArray(name, validRegisters);\n },\n shiftNumericRegisters_: function() {\n for (var i = 9; i >= 2; i--) {\n this.registers[i] = this.getRegister('' + (i - 1));\n }\n }\n };\n\n var commandDispatcher = {\n matchCommand: function(key, keyMap, vim) {\n var inputState = vim.inputState;\n var keys = inputState.keyBuffer.concat(key);\n var matchedCommands = [];\n var selectedCharacter;\n for (var i = 0; i < keyMap.length; i++) {\n var command = keyMap[i];\n if (matchKeysPartial(keys, command.keys)) {\n if (inputState.operator && command.type == 'action') {\n // Ignore matched action commands after an operator. Operators\n // only operate on motions. This check is really for text\n // objects since aW, a[ etcs conflicts with a.\n continue;\n }\n // Match commands that take <character> as an argument.\n if (command.keys[keys.length - 1] == 'character') {\n selectedCharacter = keys[keys.length - 1];\n if (selectedCharacter.length>1){\n switch(selectedCharacter){\n case '<CR>':\n selectedCharacter='\\n';\n break;\n case '<Space>':\n selectedCharacter=' ';\n break;\n default:\n continue;\n }\n }\n }\n // Add the command to the list of matched commands. Choose the best\n // command later.\n matchedCommands.push(command);\n }\n }\n\n // Returns the command if it is a full match, or null if not.\n function getFullyMatchedCommandOrNull(command) {\n if (keys.length < command.keys.length) {\n // Matches part of a multi-key command. Buffer and wait for next\n // stroke.\n inputState.keyBuffer.push(key);\n return null;\n } else {\n if (command.keys[keys.length - 1] == 'character') {\n inputState.selectedCharacter = selectedCharacter;\n }\n // Clear the buffer since a full match was found.\n inputState.keyBuffer = [];\n return command;\n }\n }\n\n if (!matchedCommands.length) {\n // Clear the buffer since there were no matches.\n inputState.keyBuffer = [];\n return null;\n } else if (matchedCommands.length == 1) {\n return getFullyMatchedCommandOrNull(matchedCommands[0]);\n } else {\n // Find the best match in the list of matchedCommands.\n var context = vim.visualMode ? 'visual' : 'normal';\n var bestMatch; // Default to first in the list.\n for (var i = 0; i < matchedCommands.length; i++) {\n var current = matchedCommands[i];\n if (current.context == context) {\n bestMatch = current;\n break;\n } else if (!bestMatch && !current.context) {\n // Only set an imperfect match to best match if no best match is\n // set and the imperfect match is not restricted to another\n // context.\n bestMatch = current;\n }\n }\n return getFullyMatchedCommandOrNull(bestMatch);\n }\n },\n processCommand: function(cm, vim, command) {\n vim.inputState.repeatOverride = command.repeatOverride;\n switch (command.type) {\n case 'motion':\n this.processMotion(cm, vim, command);\n break;\n case 'operator':\n this.processOperator(cm, vim, command);\n break;\n case 'operatorMotion':\n this.processOperatorMotion(cm, vim, command);\n break;\n case 'action':\n this.processAction(cm, vim, command);\n break;\n case 'search':\n this.processSearch(cm, vim, command);\n break;\n case 'ex':\n case 'keyToEx':\n this.processEx(cm, vim, command);\n break;\n default:\n break;\n }\n },\n processMotion: function(cm, vim, command) {\n vim.inputState.motion = command.motion;\n vim.inputState.motionArgs = copyArgs(command.motionArgs);\n this.evalInput(cm, vim);\n },\n processOperator: function(cm, vim, command) {\n var inputState = vim.inputState;\n if (inputState.operator) {\n if (inputState.operator == command.operator) {\n // Typing an operator twice like 'dd' makes the operator operate\n // linewise\n inputState.motion = 'expandToLine';\n inputState.motionArgs = { linewise: true };\n this.evalInput(cm, vim);\n return;\n } else {\n // 2 different operators in a row doesn't make sense.\n vim.inputState = new InputState();\n }\n }\n inputState.operator = command.operator;\n inputState.operatorArgs = copyArgs(command.operatorArgs);\n if (vim.visualMode) {\n // Operating on a selection in visual mode. We don't need a motion.\n this.evalInput(cm, vim);\n }\n },\n processOperatorMotion: function(cm, vim, command) {\n var visualMode = vim.visualMode;\n var operatorMotionArgs = copyArgs(command.operatorMotionArgs);\n if (operatorMotionArgs) {\n // Operator motions may have special behavior in visual mode.\n if (visualMode && operatorMotionArgs.visualLine) {\n vim.visualLine = true;\n }\n }\n this.processOperator(cm, vim, command);\n if (!visualMode) {\n this.processMotion(cm, vim, command);\n }\n },\n processAction: function(cm, vim, command) {\n var inputState = vim.inputState;\n var repeat = inputState.getRepeat();\n var repeatIsExplicit = !!repeat;\n var actionArgs = copyArgs(command.actionArgs) || {};\n if (inputState.selectedCharacter) {\n actionArgs.selectedCharacter = inputState.selectedCharacter;\n }\n // Actions may or may not have motions and operators. Do these first.\n if (command.operator) {\n this.processOperator(cm, vim, command);\n }\n if (command.motion) {\n this.processMotion(cm, vim, command);\n }\n if (command.motion || command.operator) {\n this.evalInput(cm, vim);\n }\n actionArgs.repeat = repeat || 1;\n actionArgs.repeatIsExplicit = repeatIsExplicit;\n actionArgs.registerName = inputState.registerName;\n vim.inputState = new InputState();\n vim.lastMotion = null;\n if (command.isEdit) {\n this.recordLastEdit(vim, inputState, command);\n }\n actions[command.action](cm, actionArgs, vim);\n },\n processSearch: function(cm, vim, command) {\n if (!cm.getSearchCursor) {\n // Search depends on SearchCursor.\n return;\n }\n var forward = command.searchArgs.forward;\n var wholeWordOnly = command.searchArgs.wholeWordOnly;\n getSearchState(cm).setReversed(!forward);\n var promptPrefix = (forward) ? '/' : '?';\n var originalQuery = getSearchState(cm).getQuery();\n var originalScrollPos = cm.getScrollInfo();\n function handleQuery(query, ignoreCase, smartCase) {\n try {\n updateSearchQuery(cm, query, ignoreCase, smartCase);\n } catch (e) {\n showConfirm(cm, 'Invalid regex: ' + query);\n return;\n }\n commandDispatcher.processMotion(cm, vim, {\n type: 'motion',\n motion: 'findNext',\n motionArgs: { forward: true, toJumplist: command.searchArgs.toJumplist }\n });\n }\n function onPromptClose(query) {\n cm.scrollTo(originalScrollPos.left, originalScrollPos.top);\n handleQuery(query, true /** ignoreCase */, true /** smartCase */);\n var macroModeState = vimGlobalState.macroModeState;\n if (macroModeState.isRecording) {\n logSearchQuery(macroModeState, query);\n }\n }\n function onPromptKeyUp(_e, query) {\n var parsedQuery;\n try {\n parsedQuery = updateSearchQuery(cm, query,\n true /** ignoreCase */, true /** smartCase */);\n } catch (e) {\n // Swallow bad regexes for incremental search.\n }\n if (parsedQuery) {\n cm.scrollIntoView(findNext(cm, !forward, parsedQuery), 30);\n } else {\n clearSearchHighlight(cm);\n cm.scrollTo(originalScrollPos.left, originalScrollPos.top);\n }\n }\n function onPromptKeyDown(e, _query, close) {\n var keyName = CodeMirror.keyName(e);\n if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[') {\n updateSearchQuery(cm, originalQuery);\n clearSearchHighlight(cm);\n cm.scrollTo(originalScrollPos.left, originalScrollPos.top);\n\n CodeMirror.e_stop(e);\n close();\n cm.focus();\n }\n }\n switch (command.searchArgs.querySrc) {\n case 'prompt':\n var macroModeState = vimGlobalState.macroModeState;\n if (macroModeState.isPlaying) {\n var query = macroModeState.replaySearchQueries.shift();\n handleQuery(query, true /** ignoreCase */, false /** smartCase */);\n } else {\n showPrompt(cm, {\n onClose: onPromptClose,\n prefix: promptPrefix,\n desc: searchPromptDesc,\n onKeyUp: onPromptKeyUp,\n onKeyDown: onPromptKeyDown\n });\n }\n break;\n case 'wordUnderCursor':\n var word = expandWordUnderCursor(cm, false /** inclusive */,\n true /** forward */, false /** bigWord */,\n true /** noSymbol */);\n var isKeyword = true;\n if (!word) {\n word = expandWordUnderCursor(cm, false /** inclusive */,\n true /** forward */, false /** bigWord */,\n false /** noSymbol */);\n isKeyword = false;\n }\n if (!word) {\n return;\n }\n var query = cm.getLine(word.start.line).substring(word.start.ch,\n word.end.ch);\n if (isKeyword && wholeWordOnly) {\n query = '\\\\b' + query + '\\\\b';\n } else {\n query = escapeRegex(query);\n }\n\n // cachedCursor is used to save the old position of the cursor\n // when * or # causes vim to seek for the nearest word and shift\n // the cursor before entering the motion.\n vimGlobalState.jumpList.cachedCursor = cm.getCursor();\n cm.setCursor(word.start);\n\n handleQuery(query, true /** ignoreCase */, false /** smartCase */);\n break;\n }\n },\n processEx: function(cm, vim, command) {\n function onPromptClose(input) {\n // Give the prompt some time to close so that if processCommand shows\n // an error, the elements don't overlap.\n exCommandDispatcher.processCommand(cm, input);\n }\n function onPromptKeyDown(e, _input, close) {\n var keyName = CodeMirror.keyName(e);\n if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[') {\n CodeMirror.e_stop(e);\n close();\n cm.focus();\n }\n }\n if (command.type == 'keyToEx') {\n // Handle user defined Ex to Ex mappings\n exCommandDispatcher.processCommand(cm, command.exArgs.input);\n } else {\n if (vim.visualMode) {\n showPrompt(cm, { onClose: onPromptClose, prefix: ':', value: '\\'<,\\'>',\n onKeyDown: onPromptKeyDown});\n } else {\n showPrompt(cm, { onClose: onPromptClose, prefix: ':',\n onKeyDown: onPromptKeyDown});\n }\n }\n },\n evalInput: function(cm, vim) {\n // If the motion comand is set, execute both the operator and motion.\n // Otherwise return.\n var inputState = vim.inputState;\n var motion = inputState.motion;\n var motionArgs = inputState.motionArgs || {};\n var operator = inputState.operator;\n var operatorArgs = inputState.operatorArgs || {};\n var registerName = inputState.registerName;\n var selectionEnd = copyCursor(cm.getCursor('head'));\n var selectionStart = copyCursor(cm.getCursor('anchor'));\n // The difference between cur and selection cursors are that cur is\n // being operated on and ignores that there is a selection.\n var curStart = copyCursor(selectionEnd);\n var curOriginal = copyCursor(curStart);\n var curEnd;\n var repeat;\n if (operator) {\n this.recordLastEdit(vim, inputState);\n }\n if (inputState.repeatOverride !== undefined) {\n // If repeatOverride is specified, that takes precedence over the\n // input state's repeat. Used by Ex mode and can be user defined.\n repeat = inputState.repeatOverride;\n } else {\n repeat = inputState.getRepeat();\n }\n if (repeat > 0 && motionArgs.explicitRepeat) {\n motionArgs.repeatIsExplicit = true;\n } else if (motionArgs.noRepeat ||\n (!motionArgs.explicitRepeat && repeat === 0)) {\n repeat = 1;\n motionArgs.repeatIsExplicit = false;\n }\n if (inputState.selectedCharacter) {\n // If there is a character input, stick it in all of the arg arrays.\n motionArgs.selectedCharacter = operatorArgs.selectedCharacter =\n inputState.selectedCharacter;\n }\n motionArgs.repeat = repeat;\n vim.inputState = new InputState();\n if (motion) {\n var motionResult = motions[motion](cm, motionArgs, vim);\n vim.lastMotion = motions[motion];\n if (!motionResult) {\n return;\n }\n if (motionArgs.toJumplist) {\n var jumpList = vimGlobalState.jumpList;\n // if the current motion is # or *, use cachedCursor\n var cachedCursor = jumpList.cachedCursor;\n if (cachedCursor) {\n recordJumpPosition(cm, cachedCursor, motionResult);\n delete jumpList.cachedCursor;\n } else {\n recordJumpPosition(cm, curOriginal, motionResult);\n }\n }\n if (motionResult instanceof Array) {\n curStart = motionResult[0];\n curEnd = motionResult[1];\n } else {\n curEnd = motionResult;\n }\n // TODO: Handle null returns from motion commands better.\n if (!curEnd) {\n curEnd = Pos(curStart.line, curStart.ch);\n }\n if (vim.visualMode) {\n // Check if the selection crossed over itself. Will need to shift\n // the start point if that happened.\n if (cursorIsBefore(selectionStart, selectionEnd) &&\n (cursorEqual(selectionStart, curEnd) ||\n cursorIsBefore(curEnd, selectionStart))) {\n // The end of the selection has moved from after the start to\n // before the start. We will shift the start right by 1.\n selectionStart.ch += 1;\n } else if (cursorIsBefore(selectionEnd, selectionStart) &&\n (cursorEqual(selectionStart, curEnd) ||\n cursorIsBefore(selectionStart, curEnd))) {\n // The opposite happened. We will shift the start left by 1.\n selectionStart.ch -= 1;\n }\n selectionEnd = curEnd;\n selectionStart = (motionResult instanceof Array) ? curStart : selectionStart;\n if (vim.visualLine) {\n if (cursorIsBefore(selectionStart, selectionEnd)) {\n selectionStart.ch = 0;\n\n var lastLine = cm.lastLine();\n if (selectionEnd.line > lastLine) {\n selectionEnd.line = lastLine;\n }\n selectionEnd.ch = lineLength(cm, selectionEnd.line);\n } else {\n selectionEnd.ch = 0;\n selectionStart.ch = lineLength(cm, selectionStart.line);\n }\n }\n cm.setSelection(selectionStart, selectionEnd);\n updateMark(cm, vim, '<',\n cursorIsBefore(selectionStart, selectionEnd) ? selectionStart\n : selectionEnd);\n updateMark(cm, vim, '>',\n cursorIsBefore(selectionStart, selectionEnd) ? selectionEnd\n : selectionStart);\n } else if (!operator) {\n curEnd = clipCursorToContent(cm, curEnd);\n cm.setCursor(curEnd.line, curEnd.ch);\n }\n }\n\n if (operator) {\n var inverted = false;\n vim.lastMotion = null;\n operatorArgs.repeat = repeat; // Indent in visual mode needs this.\n if (vim.visualMode) {\n curStart = selectionStart;\n curEnd = selectionEnd;\n motionArgs.inclusive = true;\n }\n // Swap start and end if motion was backward.\n if (curEnd && cursorIsBefore(curEnd, curStart)) {\n var tmp = curStart;\n curStart = curEnd;\n curEnd = tmp;\n inverted = true;\n } else if (!curEnd) {\n curEnd = copyCursor(curStart);\n }\n if (motionArgs.inclusive && !(vim.visualMode && inverted)) {\n // Move the selection end one to the right to include the last\n // character.\n curEnd.ch++;\n }\n if (operatorArgs.selOffset) {\n // Replaying a visual mode operation\n curEnd.line = curStart.line + operatorArgs.selOffset.line;\n if (operatorArgs.selOffset.line) {curEnd.ch = operatorArgs.selOffset.ch; }\n else { curEnd.ch = curStart.ch + operatorArgs.selOffset.ch; }\n } else if (vim.visualMode) {\n var selOffset = Pos();\n selOffset.line = curEnd.line - curStart.line;\n if (selOffset.line) { selOffset.ch = curEnd.ch; }\n else { selOffset.ch = curEnd.ch - curStart.ch; }\n operatorArgs.selOffset = selOffset;\n }\n var linewise = motionArgs.linewise ||\n (vim.visualMode && vim.visualLine) ||\n operatorArgs.linewise;\n if (linewise) {\n // Expand selection to entire line.\n expandSelectionToLine(cm, curStart, curEnd);\n } else if (motionArgs.forward) {\n // Clip to trailing newlines only if the motion goes forward.\n clipToLine(cm, curStart, curEnd);\n }\n operatorArgs.registerName = registerName;\n // Keep track of linewise as it affects how paste and change behave.\n operatorArgs.linewise = linewise;\n operators[operator](cm, operatorArgs, vim, curStart,\n curEnd, curOriginal);\n if (vim.visualMode) {\n exitVisualMode(cm);\n }\n }\n },\n recordLastEdit: function(vim, inputState, actionCommand) {\n var macroModeState = vimGlobalState.macroModeState;\n if (macroModeState.isPlaying) { return; }\n vim.lastEditInputState = inputState;\n vim.lastEditActionCommand = actionCommand;\n macroModeState.lastInsertModeChanges.changes = [];\n macroModeState.lastInsertModeChanges.expectCursorActivityForChange = false;\n }\n };\n\n /**\n * typedef {Object{line:number,ch:number}} Cursor An object containing the\n * position of the cursor.\n */\n // All of the functions below return Cursor objects.\n var motions = {\n moveToTopLine: function(cm, motionArgs) {\n var line = getUserVisibleLines(cm).top + motionArgs.repeat -1;\n return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));\n },\n moveToMiddleLine: function(cm) {\n var range = getUserVisibleLines(cm);\n var line = Math.floor((range.top + range.bottom) * 0.5);\n return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));\n },\n moveToBottomLine: function(cm, motionArgs) {\n var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1;\n return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));\n },\n expandToLine: function(cm, motionArgs) {\n // Expands forward to end of line, and then to next line if repeat is\n // >1. Does not handle backward motion!\n var cur = cm.getCursor();\n return Pos(cur.line + motionArgs.repeat - 1, Infinity);\n },\n findNext: function(cm, motionArgs) {\n var state = getSearchState(cm);\n var query = state.getQuery();\n if (!query) {\n return;\n }\n var prev = !motionArgs.forward;\n // If search is initiated with ? instead of /, negate direction.\n prev = (state.isReversed()) ? !prev : prev;\n highlightSearchMatches(cm, query);\n return findNext(cm, prev/** prev */, query, motionArgs.repeat);\n },\n goToMark: function(cm, motionArgs, vim) {\n var mark = vim.marks[motionArgs.selectedCharacter];\n if (mark) {\n var pos = mark.find();\n return motionArgs.linewise ? { line: pos.line, ch: findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line)) } : pos;\n }\n return null;\n },\n moveToOtherHighlightedEnd: function(cm) {\n var curEnd = copyCursor(cm.getCursor('head'));\n var curStart = copyCursor(cm.getCursor('anchor'));\n if (cursorIsBefore(curStart, curEnd)) {\n curEnd.ch += 1;\n } else if (cursorIsBefore(curEnd, curStart)) {\n curStart.ch -= 1;\n }\n return ([curEnd,curStart]);\n },\n jumpToMark: function(cm, motionArgs, vim) {\n var best = cm.getCursor();\n for (var i = 0; i < motionArgs.repeat; i++) {\n var cursor = best;\n for (var key in vim.marks) {\n if (!isLowerCase(key)) {\n continue;\n }\n var mark = vim.marks[key].find();\n var isWrongDirection = (motionArgs.forward) ?\n cursorIsBefore(mark, cursor) : cursorIsBefore(cursor, mark);\n\n if (isWrongDirection) {\n continue;\n }\n if (motionArgs.linewise && (mark.line == cursor.line)) {\n continue;\n }\n\n var equal = cursorEqual(cursor, best);\n var between = (motionArgs.forward) ?\n cusrorIsBetween(cursor, mark, best) :\n cusrorIsBetween(best, mark, cursor);\n\n if (equal || between) {\n best = mark;\n }\n }\n }\n\n if (motionArgs.linewise) {\n // Vim places the cursor on the first non-whitespace character of\n // the line if there is one, else it places the cursor at the end\n // of the line, regardless of whether a mark was found.\n best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line)));\n }\n return best;\n },\n moveByCharacters: function(cm, motionArgs) {\n var cur = cm.getCursor();\n var repeat = motionArgs.repeat;\n var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat;\n return Pos(cur.line, ch);\n },\n moveByLines: function(cm, motionArgs, vim) {\n var cur = cm.getCursor();\n var endCh = cur.ch;\n // Depending what our last motion was, we may want to do different\n // things. If our last motion was moving vertically, we want to\n // preserve the HPos from our last horizontal move. If our last motion\n // was going to the end of a line, moving vertically we should go to\n // the end of the line, etc.\n switch (vim.lastMotion) {\n case this.moveByLines:\n case this.moveByDisplayLines:\n case this.moveByScroll:\n case this.moveToColumn:\n case this.moveToEol:\n endCh = vim.lastHPos;\n break;\n default:\n vim.lastHPos = endCh;\n }\n var repeat = motionArgs.repeat+(motionArgs.repeatOffset||0);\n var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;\n var first = cm.firstLine();\n var last = cm.lastLine();\n // Vim cancels linewise motions that start on an edge and move beyond\n // that edge. It does not cancel motions that do not start on an edge.\n if ((line < first && cur.line == first) ||\n (line > last && cur.line == last)) {\n return;\n }\n if (motionArgs.toFirstChar){\n endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));\n vim.lastHPos = endCh;\n }\n vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left;\n return Pos(line, endCh);\n },\n moveByDisplayLines: function(cm, motionArgs, vim) {\n var cur = cm.getCursor();\n switch (vim.lastMotion) {\n case this.moveByDisplayLines:\n case this.moveByScroll:\n case this.moveByLines:\n case this.moveToColumn:\n case this.moveToEol:\n break;\n default:\n vim.lastHSPos = cm.charCoords(cur,'div').left;\n }\n var repeat = motionArgs.repeat;\n var res=cm.findPosV(cur,(motionArgs.forward ? repeat : -repeat),'line',vim.lastHSPos);\n if (res.hitSide) {\n if (motionArgs.forward) {\n var lastCharCoords = cm.charCoords(res, 'div');\n var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos };\n var res = cm.coordsChar(goalCoords, 'div');\n } else {\n var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div');\n resCoords.left = vim.lastHSPos;\n res = cm.coordsChar(resCoords, 'div');\n }\n }\n vim.lastHPos = res.ch;\n return res;\n },\n moveByPage: function(cm, motionArgs) {\n // CodeMirror only exposes functions that move the cursor page down, so\n // doing this bad hack to move the cursor and move it back. evalInput\n // will move the cursor to where it should be in the end.\n var curStart = cm.getCursor();\n var repeat = motionArgs.repeat;\n return cm.findPosV(curStart, (motionArgs.forward ? repeat : -repeat), 'page');\n },\n moveByParagraph: function(cm, motionArgs) {\n var line = cm.getCursor().line;\n var repeat = motionArgs.repeat;\n var inc = motionArgs.forward ? 1 : -1;\n for (var i = 0; i < repeat; i++) {\n if ((!motionArgs.forward && line === cm.firstLine() ) ||\n (motionArgs.forward && line == cm.lastLine())) {\n break;\n }\n line += inc;\n while (line !== cm.firstLine() && line != cm.lastLine() && cm.getLine(line)) {\n line += inc;\n }\n }\n return Pos(line, 0);\n },\n moveByScroll: function(cm, motionArgs, vim) {\n var scrollbox = cm.getScrollInfo();\n var curEnd = null;\n var repeat = motionArgs.repeat;\n if (!repeat) {\n repeat = scrollbox.clientHeight / (2 * cm.defaultTextHeight());\n }\n var orig = cm.charCoords(cm.getCursor(), 'local');\n motionArgs.repeat = repeat;\n var curEnd = motions.moveByDisplayLines(cm, motionArgs, vim);\n if (!curEnd) {\n return null;\n }\n var dest = cm.charCoords(curEnd, 'local');\n cm.scrollTo(null, scrollbox.top + dest.top - orig.top);\n return curEnd;\n },\n moveByWords: function(cm, motionArgs) {\n return moveToWord(cm, motionArgs.repeat, !!motionArgs.forward,\n !!motionArgs.wordEnd, !!motionArgs.bigWord);\n },\n moveTillCharacter: function(cm, motionArgs) {\n var repeat = motionArgs.repeat;\n var curEnd = moveToCharacter(cm, repeat, motionArgs.forward,\n motionArgs.selectedCharacter);\n var increment = motionArgs.forward ? -1 : 1;\n recordLastCharacterSearch(increment, motionArgs);\n if (!curEnd) return null;\n curEnd.ch += increment;\n return curEnd;\n },\n moveToCharacter: function(cm, motionArgs) {\n var repeat = motionArgs.repeat;\n recordLastCharacterSearch(0, motionArgs);\n return moveToCharacter(cm, repeat, motionArgs.forward,\n motionArgs.selectedCharacter) || cm.getCursor();\n },\n moveToSymbol: function(cm, motionArgs) {\n var repeat = motionArgs.repeat;\n return findSymbol(cm, repeat, motionArgs.forward,\n motionArgs.selectedCharacter) || cm.getCursor();\n },\n moveToColumn: function(cm, motionArgs, vim) {\n var repeat = motionArgs.repeat;\n // repeat is equivalent to which column we want to move to!\n vim.lastHPos = repeat - 1;\n vim.lastHSPos = cm.charCoords(cm.getCursor(),'div').left;\n return moveToColumn(cm, repeat);\n },\n moveToEol: function(cm, motionArgs, vim) {\n var cur = cm.getCursor();\n vim.lastHPos = Infinity;\n var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity);\n var end=cm.clipPos(retval);\n end.ch--;\n vim.lastHSPos = cm.charCoords(end,'div').left;\n return retval;\n },\n moveToFirstNonWhiteSpaceCharacter: function(cm) {\n // Go to the start of the line where the text begins, or the end for\n // whitespace-only lines\n var cursor = cm.getCursor();\n return Pos(cursor.line,\n findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line)));\n },\n moveToMatchedSymbol: function(cm) {\n var cursor = cm.getCursor();\n var line = cursor.line;\n var ch = cursor.ch;\n var lineText = cm.getLine(line);\n var symbol;\n do {\n symbol = lineText.charAt(ch++);\n if (symbol && isMatchableSymbol(symbol)) {\n var style = cm.getTokenTypeAt(Pos(line, ch));\n if (style !== \"string\" && style !== \"comment\") {\n break;\n }\n }\n } while (symbol);\n if (symbol) {\n var matched = cm.findMatchingBracket(Pos(line, ch));\n return matched.to;\n } else {\n return cursor;\n }\n },\n moveToStartOfLine: function(cm) {\n var cursor = cm.getCursor();\n return Pos(cursor.line, 0);\n },\n moveToLineOrEdgeOfDocument: function(cm, motionArgs) {\n var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine();\n if (motionArgs.repeatIsExplicit) {\n lineNum = motionArgs.repeat - cm.getOption('firstLineNumber');\n }\n return Pos(lineNum,\n findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum)));\n },\n textObjectManipulation: function(cm, motionArgs) {\n // TODO: lots of possible exceptions that can be thrown here. Try da(\n // outside of a () block.\n\n // TODO: adding <> >< to this map doesn't work, presumably because\n // they're operators\n var mirroredPairs = {'(': ')', ')': '(',\n '{': '}', '}': '{',\n '[': ']', ']': '['};\n var selfPaired = {'\\'': true, '\"': true};\n\n var character = motionArgs.selectedCharacter;\n // 'b' refers to '()' block.\n // 'B' refers to '{}' block.\n if (character == 'b') {\n character = '(';\n } else if (character == 'B') {\n character = '{';\n }\n\n // Inclusive is the difference between a and i\n // TODO: Instead of using the additional text object map to perform text\n // object operations, merge the map into the defaultKeyMap and use\n // motionArgs to define behavior. Define separate entries for 'aw',\n // 'iw', 'a[', 'i[', etc.\n var inclusive = !motionArgs.textObjectInner;\n\n var tmp;\n if (mirroredPairs[character]) {\n tmp = selectCompanionObject(cm, character, inclusive);\n } else if (selfPaired[character]) {\n tmp = findBeginningAndEnd(cm, character, inclusive);\n } else if (character === 'W') {\n tmp = expandWordUnderCursor(cm, inclusive, true /** forward */,\n true /** bigWord */);\n } else if (character === 'w') {\n tmp = expandWordUnderCursor(cm, inclusive, true /** forward */,\n false /** bigWord */);\n } else {\n // No text object defined for this, don't move.\n return null;\n }\n\n return [tmp.start, tmp.end];\n },\n\n repeatLastCharacterSearch: function(cm, motionArgs) {\n var lastSearch = vimGlobalState.lastChararacterSearch;\n var repeat = motionArgs.repeat;\n var forward = motionArgs.forward === lastSearch.forward;\n var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1);\n cm.moveH(-increment, 'char');\n motionArgs.inclusive = forward ? true : false;\n var curEnd = moveToCharacter(cm, repeat, forward, lastSearch.selectedCharacter);\n if (!curEnd) {\n cm.moveH(increment, 'char');\n return cm.getCursor();\n }\n curEnd.ch += increment;\n return curEnd;\n }\n };\n\n var operators = {\n change: function(cm, operatorArgs, _vim, curStart, curEnd) {\n vimGlobalState.registerController.pushText(\n operatorArgs.registerName, 'change', cm.getRange(curStart, curEnd),\n operatorArgs.linewise);\n if (operatorArgs.linewise) {\n // Push the next line back down, if there is a next line.\n var replacement = curEnd.line > cm.lastLine() ? '' : '\\n';\n cm.replaceRange(replacement, curStart, curEnd);\n cm.indentLine(curStart.line, 'smart');\n // null ch so setCursor moves to end of line.\n curStart.ch = null;\n } else {\n // Exclude trailing whitespace if the range is not all whitespace.\n var text = cm.getRange(curStart, curEnd);\n if (!isWhiteSpaceString(text)) {\n var match = (/\\s+$/).exec(text);\n if (match) {\n curEnd = offsetCursor(curEnd, 0, - match[0].length);\n }\n }\n cm.replaceRange('', curStart, curEnd);\n }\n actions.enterInsertMode(cm, {}, cm.state.vim);\n cm.setCursor(curStart);\n },\n // delete is a javascript keyword.\n 'delete': function(cm, operatorArgs, _vim, curStart, curEnd) {\n // If the ending line is past the last line, inclusive, instead of\n // including the trailing \\n, include the \\n before the starting line\n if (operatorArgs.linewise &&\n curEnd.line > cm.lastLine() && curStart.line > cm.firstLine()) {\n curStart.line--;\n curStart.ch = lineLength(cm, curStart.line);\n }\n vimGlobalState.registerController.pushText(\n operatorArgs.registerName, 'delete', cm.getRange(curStart, curEnd),\n operatorArgs.linewise);\n cm.replaceRange('', curStart, curEnd);\n if (operatorArgs.linewise) {\n cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm));\n } else {\n cm.setCursor(curStart);\n }\n },\n indent: function(cm, operatorArgs, vim, curStart, curEnd) {\n var startLine = curStart.line;\n var endLine = curEnd.line;\n // In visual mode, n> shifts the selection right n times, instead of\n // shifting n lines right once.\n var repeat = (vim.visualMode) ? operatorArgs.repeat : 1;\n if (operatorArgs.linewise) {\n // The only way to delete a newline is to delete until the start of\n // the next line, so in linewise mode evalInput will include the next\n // line. We don't want this in indent, so we go back a line.\n endLine--;\n }\n for (var i = startLine; i <= endLine; i++) {\n for (var j = 0; j < repeat; j++) {\n cm.indentLine(i, operatorArgs.indentRight);\n }\n }\n cm.setCursor(curStart);\n cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm));\n },\n swapcase: function(cm, operatorArgs, _vim, curStart, curEnd, curOriginal) {\n var toSwap = cm.getRange(curStart, curEnd);\n var swapped = '';\n for (var i = 0; i < toSwap.length; i++) {\n var character = toSwap.charAt(i);\n swapped += isUpperCase(character) ? character.toLowerCase() :\n character.toUpperCase();\n }\n cm.replaceRange(swapped, curStart, curEnd);\n if (!operatorArgs.shouldMoveCursor) {\n cm.setCursor(curOriginal);\n }\n },\n yank: function(cm, operatorArgs, _vim, curStart, curEnd, curOriginal) {\n vimGlobalState.registerController.pushText(\n operatorArgs.registerName, 'yank',\n cm.getRange(curStart, curEnd), operatorArgs.linewise);\n cm.setCursor(curOriginal);\n }\n };\n\n var actions = {\n jumpListWalk: function(cm, actionArgs, vim) {\n if (vim.visualMode) {\n return;\n }\n var repeat = actionArgs.repeat;\n var forward = actionArgs.forward;\n var jumpList = vimGlobalState.jumpList;\n\n var mark = jumpList.move(cm, forward ? repeat : -repeat);\n var markPos = mark ? mark.find() : undefined;\n markPos = markPos ? markPos : cm.getCursor();\n cm.setCursor(markPos);\n },\n scroll: function(cm, actionArgs, vim) {\n if (vim.visualMode) {\n return;\n }\n var repeat = actionArgs.repeat || 1;\n var lineHeight = cm.defaultTextHeight();\n var top = cm.getScrollInfo().top;\n var delta = lineHeight * repeat;\n var newPos = actionArgs.forward ? top + delta : top - delta;\n var cursor = copyCursor(cm.getCursor());\n var cursorCoords = cm.charCoords(cursor, 'local');\n if (actionArgs.forward) {\n if (newPos > cursorCoords.top) {\n cursor.line += (newPos - cursorCoords.top) / lineHeight;\n cursor.line = Math.ceil(cursor.line);\n cm.setCursor(cursor);\n cursorCoords = cm.charCoords(cursor, 'local');\n cm.scrollTo(null, cursorCoords.top);\n } else {\n // Cursor stays within bounds. Just reposition the scroll window.\n cm.scrollTo(null, newPos);\n }\n } else {\n var newBottom = newPos + cm.getScrollInfo().clientHeight;\n if (newBottom < cursorCoords.bottom) {\n cursor.line -= (cursorCoords.bottom - newBottom) / lineHeight;\n cursor.line = Math.floor(cursor.line);\n cm.setCursor(cursor);\n cursorCoords = cm.charCoords(cursor, 'local');\n cm.scrollTo(\n null, cursorCoords.bottom - cm.getScrollInfo().clientHeight);\n } else {\n // Cursor stays within bounds. Just reposition the scroll window.\n cm.scrollTo(null, newPos);\n }\n }\n },\n scrollToCursor: function(cm, actionArgs) {\n var lineNum = cm.getCursor().line;\n var charCoords = cm.charCoords(Pos(lineNum, 0), 'local');\n var height = cm.getScrollInfo().clientHeight;\n var y = charCoords.top;\n var lineHeight = charCoords.bottom - y;\n switch (actionArgs.position) {\n case 'center': y = y - (height / 2) + lineHeight;\n break;\n case 'bottom': y = y - height + lineHeight*1.4;\n break;\n case 'top': y = y + lineHeight*0.4;\n break;\n }\n cm.scrollTo(null, y);\n },\n replayMacro: function(cm, actionArgs, vim) {\n var registerName = actionArgs.selectedCharacter;\n var repeat = actionArgs.repeat;\n var macroModeState = vimGlobalState.macroModeState;\n if (registerName == '@') {\n registerName = macroModeState.latestRegister;\n }\n while(repeat--){\n executeMacroRegister(cm, vim, macroModeState, registerName);\n }\n },\n enterMacroRecordMode: function(cm, actionArgs) {\n var macroModeState = vimGlobalState.macroModeState;\n var registerName = actionArgs.selectedCharacter;\n macroModeState.enterMacroRecordMode(cm, registerName);\n },\n enterInsertMode: function(cm, actionArgs, vim) {\n if (cm.getOption('readOnly')) { return; }\n vim.insertMode = true;\n vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1;\n var insertAt = (actionArgs) ? actionArgs.insertAt : null;\n if (insertAt == 'eol') {\n var cursor = cm.getCursor();\n cursor = Pos(cursor.line, lineLength(cm, cursor.line));\n cm.setCursor(cursor);\n } else if (insertAt == 'charAfter') {\n cm.setCursor(offsetCursor(cm.getCursor(), 0, 1));\n } else if (insertAt == 'firstNonBlank') {\n cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm));\n }\n cm.setOption('keyMap', 'vim-insert');\n cm.setOption('disableInput', false);\n if (actionArgs && actionArgs.replace) {\n // Handle Replace-mode as a special case of insert mode.\n cm.toggleOverwrite(true);\n cm.setOption('keyMap', 'vim-replace');\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"replace\"});\n } else {\n cm.setOption('keyMap', 'vim-insert');\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"insert\"});\n }\n if (!vimGlobalState.macroModeState.isPlaying) {\n // Only record if not replaying.\n cm.on('change', onChange);\n CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);\n }\n },\n toggleVisualMode: function(cm, actionArgs, vim) {\n var repeat = actionArgs.repeat;\n var curStart = cm.getCursor();\n var curEnd;\n // TODO: The repeat should actually select number of characters/lines\n // equal to the repeat times the size of the previous visual\n // operation.\n if (!vim.visualMode) {\n cm.on('mousedown', exitVisualMode);\n vim.visualMode = true;\n vim.visualLine = !!actionArgs.linewise;\n if (vim.visualLine) {\n curStart.ch = 0;\n curEnd = clipCursorToContent(\n cm, Pos(curStart.line + repeat - 1, lineLength(cm, curStart.line)),\n true /** includeLineBreak */);\n } else {\n curEnd = clipCursorToContent(\n cm, Pos(curStart.line, curStart.ch + repeat),\n true /** includeLineBreak */);\n }\n // Make the initial selection.\n if (!actionArgs.repeatIsExplicit && !vim.visualLine) {\n // This is a strange case. Here the implicit repeat is 1. The\n // following commands lets the cursor hover over the 1 character\n // selection.\n cm.setCursor(curEnd);\n cm.setSelection(curEnd, curStart);\n } else {\n cm.setSelection(curStart, curEnd);\n }\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"visual\", subMode: vim.visualLine ? \"linewise\" : \"\"});\n } else {\n curStart = cm.getCursor('anchor');\n curEnd = cm.getCursor('head');\n if (!vim.visualLine && actionArgs.linewise) {\n // Shift-V pressed in characterwise visual mode. Switch to linewise\n // visual mode instead of exiting visual mode.\n vim.visualLine = true;\n curStart.ch = cursorIsBefore(curStart, curEnd) ? 0 :\n lineLength(cm, curStart.line);\n curEnd.ch = cursorIsBefore(curStart, curEnd) ?\n lineLength(cm, curEnd.line) : 0;\n cm.setSelection(curStart, curEnd);\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"visual\", subMode: \"linewise\"});\n } else if (vim.visualLine && !actionArgs.linewise) {\n // v pressed in linewise visual mode. Switch to characterwise visual\n // mode instead of exiting visual mode.\n vim.visualLine = false;\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"visual\"});\n } else {\n exitVisualMode(cm);\n }\n }\n updateMark(cm, vim, '<', cursorIsBefore(curStart, curEnd) ? curStart\n : curEnd);\n updateMark(cm, vim, '>', cursorIsBefore(curStart, curEnd) ? curEnd\n : curStart);\n },\n reselectLastSelection: function(cm, _actionArgs, vim) {\n if (vim.lastSelection) {\n var lastSelection = vim.lastSelection;\n cm.setSelection(lastSelection.curStart, lastSelection.curEnd);\n if (lastSelection.visualLine) {\n vim.visualMode = true;\n vim.visualLine = true;\n }\n else {\n vim.visualMode = true;\n vim.visualLine = false;\n }\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"visual\", subMode: vim.visualLine ? \"linewise\" : \"\"});\n }\n },\n joinLines: function(cm, actionArgs, vim) {\n var curStart, curEnd;\n if (vim.visualMode) {\n curStart = cm.getCursor('anchor');\n curEnd = cm.getCursor('head');\n curEnd.ch = lineLength(cm, curEnd.line) - 1;\n } else {\n // Repeat is the number of lines to join. Minimum 2 lines.\n var repeat = Math.max(actionArgs.repeat, 2);\n curStart = cm.getCursor();\n curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1,\n Infinity));\n }\n var finalCh = 0;\n cm.operation(function() {\n for (var i = curStart.line; i < curEnd.line; i++) {\n finalCh = lineLength(cm, curStart.line);\n var tmp = Pos(curStart.line + 1,\n lineLength(cm, curStart.line + 1));\n var text = cm.getRange(curStart, tmp);\n text = text.replace(/\\n\\s*/g, ' ');\n cm.replaceRange(text, curStart, tmp);\n }\n var curFinalPos = Pos(curStart.line, finalCh);\n cm.setCursor(curFinalPos);\n });\n },\n newLineAndEnterInsertMode: function(cm, actionArgs, vim) {\n vim.insertMode = true;\n var insertAt = copyCursor(cm.getCursor());\n if (insertAt.line === cm.firstLine() && !actionArgs.after) {\n // Special case for inserting newline before start of document.\n cm.replaceRange('\\n', Pos(cm.firstLine(), 0));\n cm.setCursor(cm.firstLine(), 0);\n } else {\n insertAt.line = (actionArgs.after) ? insertAt.line :\n insertAt.line - 1;\n insertAt.ch = lineLength(cm, insertAt.line);\n cm.setCursor(insertAt);\n var newlineFn = CodeMirror.commands.newlineAndIndentContinueComment ||\n CodeMirror.commands.newlineAndIndent;\n newlineFn(cm);\n }\n this.enterInsertMode(cm, { repeat: actionArgs.repeat }, vim);\n },\n paste: function(cm, actionArgs) {\n var cur = copyCursor(cm.getCursor());\n var register = vimGlobalState.registerController.getRegister(\n actionArgs.registerName);\n var text = register.toString();\n if (!text) {\n return;\n }\n if (actionArgs.matchIndent) {\n // length that considers tabs and cm.options.tabSize\n var whitespaceLength = function(str) {\n var tabs = (str.split(\"\\t\").length - 1);\n var spaces = (str.split(\" \").length - 1);\n return tabs * cm.options.tabSize + spaces * 1;\n };\n var currentLine = cm.getLine(cm.getCursor().line);\n var indent = whitespaceLength(currentLine.match(/^\\s*/)[0]);\n // chomp last newline b/c don't want it to match /^\\s*/gm\n var chompedText = text.replace(/\\n$/, '');\n var wasChomped = text !== chompedText;\n var firstIndent = whitespaceLength(text.match(/^\\s*/)[0]);\n var text = chompedText.replace(/^\\s*/gm, function(wspace) {\n var newIndent = indent + (whitespaceLength(wspace) - firstIndent);\n if (newIndent < 0) {\n return \"\";\n }\n else if (cm.options.indentWithTabs) {\n var quotient = Math.floor(newIndent / cm.options.tabSize);\n return Array(quotient + 1).join('\\t');\n }\n else {\n return Array(newIndent + 1).join(' ');\n }\n });\n text += wasChomped ? \"\\n\" : \"\";\n }\n if (actionArgs.repeat > 1) {\n var text = Array(actionArgs.repeat + 1).join(text);\n }\n var linewise = register.linewise;\n if (linewise) {\n if (actionArgs.after) {\n // Move the newline at the end to the start instead, and paste just\n // before the newline character of the line we are on right now.\n text = '\\n' + text.slice(0, text.length - 1);\n cur.ch = lineLength(cm, cur.line);\n } else {\n cur.ch = 0;\n }\n } else {\n cur.ch += actionArgs.after ? 1 : 0;\n }\n cm.replaceRange(text, cur);\n // Now fine tune the cursor to where we want it.\n var curPosFinal;\n var idx;\n if (linewise && actionArgs.after) {\n curPosFinal = Pos(\n cur.line + 1,\n findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1)));\n } else if (linewise && !actionArgs.after) {\n curPosFinal = Pos(\n cur.line,\n findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));\n } else if (!linewise && actionArgs.after) {\n idx = cm.indexFromPos(cur);\n curPosFinal = cm.posFromIndex(idx + text.length - 1);\n } else {\n idx = cm.indexFromPos(cur);\n curPosFinal = cm.posFromIndex(idx + text.length);\n }\n cm.setCursor(curPosFinal);\n },\n undo: function(cm, actionArgs) {\n cm.operation(function() {\n repeatFn(cm, CodeMirror.commands.undo, actionArgs.repeat)();\n cm.setCursor(cm.getCursor('anchor'));\n });\n },\n redo: function(cm, actionArgs) {\n repeatFn(cm, CodeMirror.commands.redo, actionArgs.repeat)();\n },\n setRegister: function(_cm, actionArgs, vim) {\n vim.inputState.registerName = actionArgs.selectedCharacter;\n },\n setMark: function(cm, actionArgs, vim) {\n var markName = actionArgs.selectedCharacter;\n updateMark(cm, vim, markName, cm.getCursor());\n },\n replace: function(cm, actionArgs, vim) {\n var replaceWith = actionArgs.selectedCharacter;\n var curStart = cm.getCursor();\n var replaceTo;\n var curEnd;\n if (vim.visualMode){\n curStart=cm.getCursor('start');\n curEnd=cm.getCursor('end');\n // workaround to catch the character under the cursor\n // existing workaround doesn't cover actions\n curEnd=cm.clipPos(Pos(curEnd.line, curEnd.ch+1));\n }else{\n var line = cm.getLine(curStart.line);\n replaceTo = curStart.ch + actionArgs.repeat;\n if (replaceTo > line.length) {\n replaceTo=line.length;\n }\n curEnd = Pos(curStart.line, replaceTo);\n }\n if (replaceWith=='\\n'){\n if (!vim.visualMode) cm.replaceRange('', curStart, curEnd);\n // special case, where vim help says to replace by just one line-break\n (CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm);\n }else {\n var replaceWithStr=cm.getRange(curStart, curEnd);\n //replace all characters in range by selected, but keep linebreaks\n replaceWithStr=replaceWithStr.replace(/[^\\n]/g,replaceWith);\n cm.replaceRange(replaceWithStr, curStart, curEnd);\n if (vim.visualMode){\n cm.setCursor(curStart);\n exitVisualMode(cm);\n }else{\n cm.setCursor(offsetCursor(curEnd, 0, -1));\n }\n }\n },\n incrementNumberToken: function(cm, actionArgs) {\n var cur = cm.getCursor();\n var lineStr = cm.getLine(cur.line);\n var re = /-?\\d+/g;\n var match;\n var start;\n var end;\n var numberStr;\n var token;\n while ((match = re.exec(lineStr)) !== null) {\n token = match[0];\n start = match.index;\n end = start + token.length;\n if (cur.ch < end)break;\n }\n if (!actionArgs.backtrack && (end <= cur.ch))return;\n if (token) {\n var increment = actionArgs.increase ? 1 : -1;\n var number = parseInt(token) + (increment * actionArgs.repeat);\n var from = Pos(cur.line, start);\n var to = Pos(cur.line, end);\n numberStr = number.toString();\n cm.replaceRange(numberStr, from, to);\n } else {\n return;\n }\n cm.setCursor(Pos(cur.line, start + numberStr.length - 1));\n },\n repeatLastEdit: function(cm, actionArgs, vim) {\n var lastEditInputState = vim.lastEditInputState;\n if (!lastEditInputState) { return; }\n var repeat = actionArgs.repeat;\n if (repeat && actionArgs.repeatIsExplicit) {\n vim.lastEditInputState.repeatOverride = repeat;\n } else {\n repeat = vim.lastEditInputState.repeatOverride || repeat;\n }\n repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */);\n },\n changeCase: function(cm, actionArgs, vim) {\n var selectedAreaRange = getSelectedAreaRange(cm, vim);\n var selectionStart = selectedAreaRange[0];\n var selectionEnd = selectedAreaRange[1];\n var toLower = actionArgs.toLower;\n if (cursorIsBefore(selectionEnd, selectionStart)) {\n var tmp = selectionStart;\n selectionStart = selectionEnd;\n selectionEnd = tmp;\n } else {\n selectionEnd = cm.clipPos(Pos(selectionEnd.line, selectionEnd.ch+1));\n }\n var text = cm.getRange(selectionStart, selectionEnd);\n cm.replaceRange(toLower ? text.toLowerCase() : text.toUpperCase(), selectionStart, selectionEnd);\n cm.setCursor(selectionStart);\n }\n };\n\n /*\n * Below are miscellaneous utility functions used by vim.js\n */\n\n /**\n * Clips cursor to ensure that line is within the buffer's range\n * If includeLineBreak is true, then allow cur.ch == lineLength.\n */\n function clipCursorToContent(cm, cur, includeLineBreak) {\n var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() );\n var maxCh = lineLength(cm, line) - 1;\n maxCh = (includeLineBreak) ? maxCh + 1 : maxCh;\n var ch = Math.min(Math.max(0, cur.ch), maxCh);\n return Pos(line, ch);\n }\n function copyArgs(args) {\n var ret = {};\n for (var prop in args) {\n if (args.hasOwnProperty(prop)) {\n ret[prop] = args[prop];\n }\n }\n return ret;\n }\n function offsetCursor(cur, offsetLine, offsetCh) {\n return Pos(cur.line + offsetLine, cur.ch + offsetCh);\n }\n function matchKeysPartial(pressed, mapped) {\n for (var i = 0; i < pressed.length; i++) {\n // 'character' means any character. For mark, register commads, etc.\n if (pressed[i] != mapped[i] && mapped[i] != 'character') {\n return false;\n }\n }\n return true;\n }\n function repeatFn(cm, fn, repeat) {\n return function() {\n for (var i = 0; i < repeat; i++) {\n fn(cm);\n }\n };\n }\n function copyCursor(cur) {\n return Pos(cur.line, cur.ch);\n }\n function cursorEqual(cur1, cur2) {\n return cur1.ch == cur2.ch && cur1.line == cur2.line;\n }\n function cursorIsBefore(cur1, cur2) {\n if (cur1.line < cur2.line) {\n return true;\n }\n if (cur1.line == cur2.line && cur1.ch < cur2.ch) {\n return true;\n }\n return false;\n }\n function cusrorIsBetween(cur1, cur2, cur3) {\n // returns true if cur2 is between cur1 and cur3.\n var cur1before2 = cursorIsBefore(cur1, cur2);\n var cur2before3 = cursorIsBefore(cur2, cur3);\n return cur1before2 && cur2before3;\n }\n function lineLength(cm, lineNum) {\n return cm.getLine(lineNum).length;\n }\n function reverse(s){\n return s.split('').reverse().join('');\n }\n function trim(s) {\n if (s.trim) {\n return s.trim();\n }\n return s.replace(/^\\s+|\\s+$/g, '');\n }\n function escapeRegex(s) {\n return s.replace(/([.?*+$\\[\\]\\/\\\\(){}|\\-])/g, '\\\\$1');\n }\n function getSelectedAreaRange(cm, vim) {\n var selectionStart = cm.getCursor('anchor');\n var selectionEnd = cm.getCursor('head');\n var lastSelection = vim.lastSelection;\n if (!vim.visualMode) {\n var line = lastSelection.curEnd.line - lastSelection.curStart.line;\n var ch = line ? lastSelection.curEnd.ch : lastSelection.curEnd.ch - lastSelection.curStart.ch;\n selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch};\n if (lastSelection.visualLine) {\n return [{line: selectionStart.line, ch: 0}, {line: selectionEnd.line, ch: lineLength(cm, selectionEnd.line)}];\n }\n } else {\n exitVisualMode(cm);\n }\n return [selectionStart, selectionEnd];\n }\n\n function exitVisualMode(cm) {\n cm.off('mousedown', exitVisualMode);\n var vim = cm.state.vim;\n // can't use selection state here because yank has already reset its cursor\n vim.lastSelection = {'curStart': vim.marks['<'].find(),\n 'curEnd': vim.marks['>'].find(), 'visualMode': vim.visualMode,\n 'visualLine': vim.visualLine};\n vim.visualMode = false;\n vim.visualLine = false;\n var selectionStart = cm.getCursor('anchor');\n var selectionEnd = cm.getCursor('head');\n if (!cursorEqual(selectionStart, selectionEnd)) {\n // Clear the selection and set the cursor only if the selection has not\n // already been cleared. Otherwise we risk moving the cursor somewhere\n // it's not supposed to be.\n cm.setCursor(clipCursorToContent(cm, selectionEnd));\n }\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"normal\"});\n }\n\n // Remove any trailing newlines from the selection. For\n // example, with the caret at the start of the last word on the line,\n // 'dw' should word, but not the newline, while 'w' should advance the\n // caret to the first character of the next line.\n function clipToLine(cm, curStart, curEnd) {\n var selection = cm.getRange(curStart, curEnd);\n // Only clip if the selection ends with trailing newline + whitespace\n if (/\\n\\s*$/.test(selection)) {\n var lines = selection.split('\\n');\n // We know this is all whitepsace.\n lines.pop();\n\n // Cases:\n // 1. Last word is an empty line - do not clip the trailing '\\n'\n // 2. Last word is not an empty line - clip the trailing '\\n'\n var line;\n // Find the line containing the last word, and clip all whitespace up\n // to it.\n for (var line = lines.pop(); lines.length > 0 && line && isWhiteSpaceString(line); line = lines.pop()) {\n curEnd.line--;\n curEnd.ch = 0;\n }\n // If the last word is not an empty line, clip an additional newline\n if (line) {\n curEnd.line--;\n curEnd.ch = lineLength(cm, curEnd.line);\n } else {\n curEnd.ch = 0;\n }\n }\n }\n\n // Expand the selection to line ends.\n function expandSelectionToLine(_cm, curStart, curEnd) {\n curStart.ch = 0;\n curEnd.ch = 0;\n curEnd.line++;\n }\n\n function findFirstNonWhiteSpaceCharacter(text) {\n if (!text) {\n return 0;\n }\n var firstNonWS = text.search(/\\S/);\n return firstNonWS == -1 ? text.length : firstNonWS;\n }\n\n function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) {\n var cur = cm.getCursor();\n var line = cm.getLine(cur.line);\n var idx = cur.ch;\n\n // Seek to first word or non-whitespace character, depending on if\n // noSymbol is true.\n var textAfterIdx = line.substring(idx);\n var firstMatchedChar;\n if (noSymbol) {\n firstMatchedChar = textAfterIdx.search(/\\w/);\n } else {\n firstMatchedChar = textAfterIdx.search(/\\S/);\n }\n if (firstMatchedChar == -1) {\n return null;\n }\n idx += firstMatchedChar;\n textAfterIdx = line.substring(idx);\n var textBeforeIdx = line.substring(0, idx);\n\n var matchRegex;\n // Greedy matchers for the \"word\" we are trying to expand.\n if (bigWord) {\n matchRegex = /^\\S+/;\n } else {\n if ((/\\w/).test(line.charAt(idx))) {\n matchRegex = /^\\w+/;\n } else {\n matchRegex = /^[^\\w\\s]+/;\n }\n }\n\n var wordAfterRegex = matchRegex.exec(textAfterIdx);\n var wordStart = idx;\n var wordEnd = idx + wordAfterRegex[0].length;\n // TODO: Find a better way to do this. It will be slow on very long lines.\n var revTextBeforeIdx = reverse(textBeforeIdx);\n var wordBeforeRegex = matchRegex.exec(revTextBeforeIdx);\n if (wordBeforeRegex) {\n wordStart -= wordBeforeRegex[0].length;\n }\n\n if (inclusive) {\n // If present, trim all whitespace after word.\n // Otherwise, trim all whitespace before word.\n var textAfterWordEnd = line.substring(wordEnd);\n var whitespacesAfterWord = textAfterWordEnd.match(/^\\s*/)[0].length;\n if (whitespacesAfterWord > 0) {\n wordEnd += whitespacesAfterWord;\n } else {\n var revTrim = revTextBeforeIdx.length - wordStart;\n var textBeforeWordStart = revTextBeforeIdx.substring(revTrim);\n var whitespacesBeforeWord = textBeforeWordStart.match(/^\\s*/)[0].length;\n wordStart -= whitespacesBeforeWord;\n }\n }\n\n return { start: Pos(cur.line, wordStart),\n end: Pos(cur.line, wordEnd) };\n }\n\n function recordJumpPosition(cm, oldCur, newCur) {\n if (!cursorEqual(oldCur, newCur)) {\n vimGlobalState.jumpList.add(cm, oldCur, newCur);\n }\n }\n\n function recordLastCharacterSearch(increment, args) {\n vimGlobalState.lastChararacterSearch.increment = increment;\n vimGlobalState.lastChararacterSearch.forward = args.forward;\n vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter;\n }\n\n var symbolToMode = {\n '(': 'bracket', ')': 'bracket', '{': 'bracket', '}': 'bracket',\n '[': 'section', ']': 'section',\n '*': 'comment', '/': 'comment',\n 'm': 'method', 'M': 'method',\n '#': 'preprocess'\n };\n var findSymbolModes = {\n bracket: {\n isComplete: function(state) {\n if (state.nextCh === state.symb) {\n state.depth++;\n if (state.depth >= 1)return true;\n } else if (state.nextCh === state.reverseSymb) {\n state.depth--;\n }\n return false;\n }\n },\n section: {\n init: function(state) {\n state.curMoveThrough = true;\n state.symb = (state.forward ? ']' : '[') === state.symb ? '{' : '}';\n },\n isComplete: function(state) {\n return state.index === 0 && state.nextCh === state.symb;\n }\n },\n comment: {\n isComplete: function(state) {\n var found = state.lastCh === '*' && state.nextCh === '/';\n state.lastCh = state.nextCh;\n return found;\n }\n },\n // TODO: The original Vim implementation only operates on level 1 and 2.\n // The current implementation doesn't check for code block level and\n // therefore it operates on any levels.\n method: {\n init: function(state) {\n state.symb = (state.symb === 'm' ? '{' : '}');\n state.reverseSymb = state.symb === '{' ? '}' : '{';\n },\n isComplete: function(state) {\n if (state.nextCh === state.symb)return true;\n return false;\n }\n },\n preprocess: {\n init: function(state) {\n state.index = 0;\n },\n isComplete: function(state) {\n if (state.nextCh === '#') {\n var token = state.lineText.match(/#(\\w+)/)[1];\n if (token === 'endif') {\n if (state.forward && state.depth === 0) {\n return true;\n }\n state.depth++;\n } else if (token === 'if') {\n if (!state.forward && state.depth === 0) {\n return true;\n }\n state.depth--;\n }\n if (token === 'else' && state.depth === 0)return true;\n }\n return false;\n }\n }\n };\n function findSymbol(cm, repeat, forward, symb) {\n var cur = copyCursor(cm.getCursor());\n var increment = forward ? 1 : -1;\n var endLine = forward ? cm.lineCount() : -1;\n var curCh = cur.ch;\n var line = cur.line;\n var lineText = cm.getLine(line);\n var state = {\n lineText: lineText,\n nextCh: lineText.charAt(curCh),\n lastCh: null,\n index: curCh,\n symb: symb,\n reverseSymb: (forward ? { ')': '(', '}': '{' } : { '(': ')', '{': '}' })[symb],\n forward: forward,\n depth: 0,\n curMoveThrough: false\n };\n var mode = symbolToMode[symb];\n if (!mode)return cur;\n var init = findSymbolModes[mode].init;\n var isComplete = findSymbolModes[mode].isComplete;\n if (init) { init(state); }\n while (line !== endLine && repeat) {\n state.index += increment;\n state.nextCh = state.lineText.charAt(state.index);\n if (!state.nextCh) {\n line += increment;\n state.lineText = cm.getLine(line) || '';\n if (increment > 0) {\n state.index = 0;\n } else {\n var lineLen = state.lineText.length;\n state.index = (lineLen > 0) ? (lineLen-1) : 0;\n }\n state.nextCh = state.lineText.charAt(state.index);\n }\n if (isComplete(state)) {\n cur.line = line;\n cur.ch = state.index;\n repeat--;\n }\n }\n if (state.nextCh || state.curMoveThrough) {\n return Pos(line, state.index);\n }\n return cur;\n }\n\n /*\n * Returns the boundaries of the next word. If the cursor in the middle of\n * the word, then returns the boundaries of the current word, starting at\n * the cursor. If the cursor is at the start/end of a word, and we are going\n * forward/backward, respectively, find the boundaries of the next word.\n *\n * @param {CodeMirror} cm CodeMirror object.\n * @param {Cursor} cur The cursor position.\n * @param {boolean} forward True to search forward. False to search\n * backward.\n * @param {boolean} bigWord True if punctuation count as part of the word.\n * False if only [a-zA-Z0-9] characters count as part of the word.\n * @param {boolean} emptyLineIsWord True if empty lines should be treated\n * as words.\n * @return {Object{from:number, to:number, line: number}} The boundaries of\n * the word, or null if there are no more words.\n */\n function findWord(cm, cur, forward, bigWord, emptyLineIsWord) {\n var lineNum = cur.line;\n var pos = cur.ch;\n var line = cm.getLine(lineNum);\n var dir = forward ? 1 : -1;\n var regexps = bigWord ? bigWordRegexp : wordRegexp;\n\n if (emptyLineIsWord && line == '') {\n lineNum += dir;\n line = cm.getLine(lineNum);\n if (!isLine(cm, lineNum)) {\n return null;\n }\n pos = (forward) ? 0 : line.length;\n }\n\n while (true) {\n if (emptyLineIsWord && line == '') {\n return { from: 0, to: 0, line: lineNum };\n }\n var stop = (dir > 0) ? line.length : -1;\n var wordStart = stop, wordEnd = stop;\n // Find bounds of next word.\n while (pos != stop) {\n var foundWord = false;\n for (var i = 0; i < regexps.length && !foundWord; ++i) {\n if (regexps[i].test(line.charAt(pos))) {\n wordStart = pos;\n // Advance to end of word.\n while (pos != stop && regexps[i].test(line.charAt(pos))) {\n pos += dir;\n }\n wordEnd = pos;\n foundWord = wordStart != wordEnd;\n if (wordStart == cur.ch && lineNum == cur.line &&\n wordEnd == wordStart + dir) {\n // We started at the end of a word. Find the next one.\n continue;\n } else {\n return {\n from: Math.min(wordStart, wordEnd + 1),\n to: Math.max(wordStart, wordEnd),\n line: lineNum };\n }\n }\n }\n if (!foundWord) {\n pos += dir;\n }\n }\n // Advance to next/prev line.\n lineNum += dir;\n if (!isLine(cm, lineNum)) {\n return null;\n }\n line = cm.getLine(lineNum);\n pos = (dir > 0) ? 0 : line.length;\n }\n // Should never get here.\n throw new Error('The impossible happened.');\n }\n\n /**\n * @param {CodeMirror} cm CodeMirror object.\n * @param {int} repeat Number of words to move past.\n * @param {boolean} forward True to search forward. False to search\n * backward.\n * @param {boolean} wordEnd True to move to end of word. False to move to\n * beginning of word.\n * @param {boolean} bigWord True if punctuation count as part of the word.\n * False if only alphabet characters count as part of the word.\n * @return {Cursor} The position the cursor should move to.\n */\n function moveToWord(cm, repeat, forward, wordEnd, bigWord) {\n var cur = cm.getCursor();\n var curStart = copyCursor(cur);\n var words = [];\n if (forward && !wordEnd || !forward && wordEnd) {\n repeat++;\n }\n // For 'e', empty lines are not considered words, go figure.\n var emptyLineIsWord = !(forward && wordEnd);\n for (var i = 0; i < repeat; i++) {\n var word = findWord(cm, cur, forward, bigWord, emptyLineIsWord);\n if (!word) {\n var eodCh = lineLength(cm, cm.lastLine());\n words.push(forward\n ? {line: cm.lastLine(), from: eodCh, to: eodCh}\n : {line: 0, from: 0, to: 0});\n break;\n }\n words.push(word);\n cur = Pos(word.line, forward ? (word.to - 1) : word.from);\n }\n var shortCircuit = words.length != repeat;\n var firstWord = words[0];\n var lastWord = words.pop();\n if (forward && !wordEnd) {\n // w\n if (!shortCircuit && (firstWord.from != curStart.ch || firstWord.line != curStart.line)) {\n // We did not start in the middle of a word. Discard the extra word at the end.\n lastWord = words.pop();\n }\n return Pos(lastWord.line, lastWord.from);\n } else if (forward && wordEnd) {\n return Pos(lastWord.line, lastWord.to - 1);\n } else if (!forward && wordEnd) {\n // ge\n if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) {\n // We did not start in the middle of a word. Discard the extra word at the end.\n lastWord = words.pop();\n }\n return Pos(lastWord.line, lastWord.to);\n } else {\n // b\n return Pos(lastWord.line, lastWord.from);\n }\n }\n\n function moveToCharacter(cm, repeat, forward, character) {\n var cur = cm.getCursor();\n var start = cur.ch;\n var idx;\n for (var i = 0; i < repeat; i ++) {\n var line = cm.getLine(cur.line);\n idx = charIdxInLine(start, line, character, forward, true);\n if (idx == -1) {\n return null;\n }\n start = idx;\n }\n return Pos(cm.getCursor().line, idx);\n }\n\n function moveToColumn(cm, repeat) {\n // repeat is always >= 1, so repeat - 1 always corresponds\n // to the column we want to go to.\n var line = cm.getCursor().line;\n return clipCursorToContent(cm, Pos(line, repeat - 1));\n }\n\n function updateMark(cm, vim, markName, pos) {\n if (!inArray(markName, validMarks)) {\n return;\n }\n if (vim.marks[markName]) {\n vim.marks[markName].clear();\n }\n vim.marks[markName] = cm.setBookmark(pos);\n }\n\n function charIdxInLine(start, line, character, forward, includeChar) {\n // Search for char in line.\n // motion_options: {forward, includeChar}\n // If includeChar = true, include it too.\n // If forward = true, search forward, else search backwards.\n // If char is not found on this line, do nothing\n var idx;\n if (forward) {\n idx = line.indexOf(character, start + 1);\n if (idx != -1 && !includeChar) {\n idx -= 1;\n }\n } else {\n idx = line.lastIndexOf(character, start - 1);\n if (idx != -1 && !includeChar) {\n idx += 1;\n }\n }\n return idx;\n }\n\n // TODO: perhaps this finagling of start and end positions belonds\n // in codmirror/replaceRange?\n function selectCompanionObject(cm, symb, inclusive) {\n var cur = cm.getCursor(), start, end;\n\n var bracketRegexp = ({\n '(': /[()]/, ')': /[()]/,\n '[': /[[\\]]/, ']': /[[\\]]/,\n '{': /[{}]/, '}': /[{}]/})[symb];\n var openSym = ({\n '(': '(', ')': '(',\n '[': '[', ']': '[',\n '{': '{', '}': '{'})[symb];\n var curChar = cm.getLine(cur.line).charAt(cur.ch);\n // Due to the behavior of scanForBracket, we need to add an offset if the\n // cursor is on a matching open bracket.\n var offset = curChar === openSym ? 1 : 0;\n\n start = cm.scanForBracket(Pos(cur.line, cur.ch + offset), -1, null, {'bracketRegex': bracketRegexp});\n end = cm.scanForBracket(Pos(cur.line, cur.ch + offset), 1, null, {'bracketRegex': bracketRegexp});\n\n if (!start || !end) {\n return { start: cur, end: cur };\n }\n\n start = start.pos;\n end = end.pos;\n\n if ((start.line == end.line && start.ch > end.ch)\n || (start.line > end.line)) {\n var tmp = start;\n start = end;\n end = tmp;\n }\n\n if (inclusive) {\n end.ch += 1;\n } else {\n start.ch += 1;\n }\n\n return { start: start, end: end };\n }\n\n // Takes in a symbol and a cursor and tries to simulate text objects that\n // have identical opening and closing symbols\n // TODO support across multiple lines\n function findBeginningAndEnd(cm, symb, inclusive) {\n var cur = copyCursor(cm.getCursor());\n var line = cm.getLine(cur.line);\n var chars = line.split('');\n var start, end, i, len;\n var firstIndex = chars.indexOf(symb);\n\n // the decision tree is to always look backwards for the beginning first,\n // but if the cursor is in front of the first instance of the symb,\n // then move the cursor forward\n if (cur.ch < firstIndex) {\n cur.ch = firstIndex;\n // Why is this line even here???\n // cm.setCursor(cur.line, firstIndex+1);\n }\n // otherwise if the cursor is currently on the closing symbol\n else if (firstIndex < cur.ch && chars[cur.ch] == symb) {\n end = cur.ch; // assign end to the current cursor\n --cur.ch; // make sure to look backwards\n }\n\n // if we're currently on the symbol, we've got a start\n if (chars[cur.ch] == symb && !end) {\n start = cur.ch + 1; // assign start to ahead of the cursor\n } else {\n // go backwards to find the start\n for (i = cur.ch; i > -1 && !start; i--) {\n if (chars[i] == symb) {\n start = i + 1;\n }\n }\n }\n\n // look forwards for the end symbol\n if (start && !end) {\n for (i = start, len = chars.length; i < len && !end; i++) {\n if (chars[i] == symb) {\n end = i;\n }\n }\n }\n\n // nothing found\n if (!start || !end) {\n return { start: cur, end: cur };\n }\n\n // include the symbols\n if (inclusive) {\n --start; ++end;\n }\n\n return {\n start: Pos(cur.line, start),\n end: Pos(cur.line, end)\n };\n }\n\n // Search functions\n defineOption('pcre', true, 'boolean');\n function SearchState() {}\n SearchState.prototype = {\n getQuery: function() {\n return vimGlobalState.query;\n },\n setQuery: function(query) {\n vimGlobalState.query = query;\n },\n getOverlay: function() {\n return this.searchOverlay;\n },\n setOverlay: function(overlay) {\n this.searchOverlay = overlay;\n },\n isReversed: function() {\n return vimGlobalState.isReversed;\n },\n setReversed: function(reversed) {\n vimGlobalState.isReversed = reversed;\n }\n };\n function getSearchState(cm) {\n var vim = cm.state.vim;\n return vim.searchState_ || (vim.searchState_ = new SearchState());\n }\n function dialog(cm, template, shortText, onClose, options) {\n if (cm.openDialog) {\n cm.openDialog(template, onClose, { bottom: true, value: options.value,\n onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp });\n }\n else {\n onClose(prompt(shortText, ''));\n }\n }\n\n function findUnescapedSlashes(str) {\n var escapeNextChar = false;\n var slashes = [];\n for (var i = 0; i < str.length; i++) {\n var c = str.charAt(i);\n if (!escapeNextChar && c == '/') {\n slashes.push(i);\n }\n escapeNextChar = !escapeNextChar && (c == '\\\\');\n }\n return slashes;\n }\n\n // Translates a search string from ex (vim) syntax into javascript form.\n function translateRegex(str) {\n // When these match, add a '\\' if unescaped or remove one if escaped.\n var specials = '|(){';\n // Remove, but never add, a '\\' for these.\n var unescape = '}';\n var escapeNextChar = false;\n var out = [];\n for (var i = -1; i < str.length; i++) {\n var c = str.charAt(i) || '';\n var n = str.charAt(i+1) || '';\n var specialComesNext = (n && specials.indexOf(n) != -1);\n if (escapeNextChar) {\n if (c !== '\\\\' || !specialComesNext) {\n out.push(c);\n }\n escapeNextChar = false;\n } else {\n if (c === '\\\\') {\n escapeNextChar = true;\n // Treat the unescape list as special for removing, but not adding '\\'.\n if (n && unescape.indexOf(n) != -1) {\n specialComesNext = true;\n }\n // Not passing this test means removing a '\\'.\n if (!specialComesNext || n === '\\\\') {\n out.push(c);\n }\n } else {\n out.push(c);\n if (specialComesNext && n !== '\\\\') {\n out.push('\\\\');\n }\n }\n }\n }\n return out.join('');\n }\n\n // Translates the replace part of a search and replace from ex (vim) syntax into\n // javascript form. Similar to translateRegex, but additionally fixes back references\n // (translates '\\[0..9]' to '$[0..9]') and follows different rules for escaping '$'.\n function translateRegexReplace(str) {\n var escapeNextChar = false;\n var out = [];\n for (var i = -1; i < str.length; i++) {\n var c = str.charAt(i) || '';\n var n = str.charAt(i+1) || '';\n if (escapeNextChar) {\n // At any point in the loop, escapeNextChar is true if the previous\n // character was a '\\' and was not escaped.\n out.push(c);\n escapeNextChar = false;\n } else {\n if (c === '\\\\') {\n escapeNextChar = true;\n if ((isNumber(n) || n === '$')) {\n out.push('$');\n } else if (n !== '/' && n !== '\\\\') {\n out.push('\\\\');\n }\n } else {\n if (c === '$') {\n out.push('$');\n }\n out.push(c);\n if (n === '/') {\n out.push('\\\\');\n }\n }\n }\n }\n return out.join('');\n }\n\n // Unescape \\ and / in the replace part, for PCRE mode.\n function unescapeRegexReplace(str) {\n var stream = new CodeMirror.StringStream(str);\n var output = [];\n while (!stream.eol()) {\n // Search for \\.\n while (stream.peek() && stream.peek() != '\\\\') {\n output.push(stream.next());\n }\n if (stream.match('\\\\/', true)) {\n // \\/ => /\n output.push('/');\n } else if (stream.match('\\\\\\\\', true)) {\n // \\\\ => \\\n output.push('\\\\');\n } else {\n // Don't change anything\n output.push(stream.next());\n }\n }\n return output.join('');\n }\n\n /**\n * Extract the regular expression from the query and return a Regexp object.\n * Returns null if the query is blank.\n * If ignoreCase is passed in, the Regexp object will have the 'i' flag set.\n * If smartCase is passed in, and the query contains upper case letters,\n * then ignoreCase is overridden, and the 'i' flag will not be set.\n * If the query contains the /i in the flag part of the regular expression,\n * then both ignoreCase and smartCase are ignored, and 'i' will be passed\n * through to the Regex object.\n */\n function parseQuery(query, ignoreCase, smartCase) {\n // Check if the query is already a regex.\n if (query instanceof RegExp) { return query; }\n // First try to extract regex + flags from the input. If no flags found,\n // extract just the regex. IE does not accept flags directly defined in\n // the regex string in the form /regex/flags\n var slashes = findUnescapedSlashes(query);\n var regexPart;\n var forceIgnoreCase;\n if (!slashes.length) {\n // Query looks like 'regexp'\n regexPart = query;\n } else {\n // Query looks like 'regexp/...'\n regexPart = query.substring(0, slashes[0]);\n var flagsPart = query.substring(slashes[0]);\n forceIgnoreCase = (flagsPart.indexOf('i') != -1);\n }\n if (!regexPart) {\n return null;\n }\n if (!getOption('pcre')) {\n regexPart = translateRegex(regexPart);\n }\n if (smartCase) {\n ignoreCase = (/^[^A-Z]*$/).test(regexPart);\n }\n var regexp = new RegExp(regexPart,\n (ignoreCase || forceIgnoreCase) ? 'i' : undefined);\n return regexp;\n }\n function showConfirm(cm, text) {\n if (cm.openNotification) {\n cm.openNotification('<span style=\"color: red\">' + text + '</span>',\n {bottom: true, duration: 5000});\n } else {\n alert(text);\n }\n }\n function makePrompt(prefix, desc) {\n var raw = '';\n if (prefix) {\n raw += '<span style=\"font-family: monospace\">' + prefix + '</span>';\n }\n raw += '<input type=\"text\"/> ' +\n '<span style=\"color: #888\">';\n if (desc) {\n raw += '<span style=\"color: #888\">';\n raw += desc;\n raw += '</span>';\n }\n return raw;\n }\n var searchPromptDesc = '(Javascript regexp)';\n function showPrompt(cm, options) {\n var shortText = (options.prefix || '') + ' ' + (options.desc || '');\n var prompt = makePrompt(options.prefix, options.desc);\n dialog(cm, prompt, shortText, options.onClose, options);\n }\n function regexEqual(r1, r2) {\n if (r1 instanceof RegExp && r2 instanceof RegExp) {\n var props = ['global', 'multiline', 'ignoreCase', 'source'];\n for (var i = 0; i < props.length; i++) {\n var prop = props[i];\n if (r1[prop] !== r2[prop]) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n // Returns true if the query is valid.\n function updateSearchQuery(cm, rawQuery, ignoreCase, smartCase) {\n if (!rawQuery) {\n return;\n }\n var state = getSearchState(cm);\n var query = parseQuery(rawQuery, !!ignoreCase, !!smartCase);\n if (!query) {\n return;\n }\n highlightSearchMatches(cm, query);\n if (regexEqual(query, state.getQuery())) {\n return query;\n }\n state.setQuery(query);\n return query;\n }\n function searchOverlay(query) {\n if (query.source.charAt(0) == '^') {\n var matchSol = true;\n }\n return {\n token: function(stream) {\n if (matchSol && !stream.sol()) {\n stream.skipToEnd();\n return;\n }\n var match = stream.match(query, false);\n if (match) {\n if (match[0].length == 0) {\n // Matched empty string, skip to next.\n stream.next();\n return 'searching';\n }\n if (!stream.sol()) {\n // Backtrack 1 to match \\b\n stream.backUp(1);\n if (!query.exec(stream.next() + match[0])) {\n stream.next();\n return null;\n }\n }\n stream.match(query);\n return 'searching';\n }\n while (!stream.eol()) {\n stream.next();\n if (stream.match(query, false)) break;\n }\n },\n query: query\n };\n }\n function highlightSearchMatches(cm, query) {\n var overlay = getSearchState(cm).getOverlay();\n if (!overlay || query != overlay.query) {\n if (overlay) {\n cm.removeOverlay(overlay);\n }\n overlay = searchOverlay(query);\n cm.addOverlay(overlay);\n getSearchState(cm).setOverlay(overlay);\n }\n }\n function findNext(cm, prev, query, repeat) {\n if (repeat === undefined) { repeat = 1; }\n return cm.operation(function() {\n var pos = cm.getCursor();\n var cursor = cm.getSearchCursor(query, pos);\n for (var i = 0; i < repeat; i++) {\n var found = cursor.find(prev);\n if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); }\n if (!found) {\n // SearchCursor may have returned null because it hit EOF, wrap\n // around and try again.\n cursor = cm.getSearchCursor(query,\n (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) );\n if (!cursor.find(prev)) {\n return;\n }\n }\n }\n return cursor.from();\n });\n }\n function clearSearchHighlight(cm) {\n cm.removeOverlay(getSearchState(cm).getOverlay());\n getSearchState(cm).setOverlay(null);\n }\n /**\n * Check if pos is in the specified range, INCLUSIVE.\n * Range can be specified with 1 or 2 arguments.\n * If the first range argument is an array, treat it as an array of line\n * numbers. Match pos against any of the lines.\n * If the first range argument is a number,\n * if there is only 1 range argument, check if pos has the same line\n * number\n * if there are 2 range arguments, then check if pos is in between the two\n * range arguments.\n */\n function isInRange(pos, start, end) {\n if (typeof pos != 'number') {\n // Assume it is a cursor position. Get the line number.\n pos = pos.line;\n }\n if (start instanceof Array) {\n return inArray(pos, start);\n } else {\n if (end) {\n return (pos >= start && pos <= end);\n } else {\n return pos == start;\n }\n }\n }\n function getUserVisibleLines(cm) {\n var scrollInfo = cm.getScrollInfo();\n var occludeToleranceTop = 6;\n var occludeToleranceBottom = 10;\n var from = cm.coordsChar({left:0, top: occludeToleranceTop + scrollInfo.top}, 'local');\n var bottomY = scrollInfo.clientHeight - occludeToleranceBottom + scrollInfo.top;\n var to = cm.coordsChar({left:0, top: bottomY}, 'local');\n return {top: from.line, bottom: to.line};\n }\n\n // Ex command handling\n // Care must be taken when adding to the default Ex command map. For any\n // pair of commands that have a shared prefix, at least one of their\n // shortNames must not match the prefix of the other command.\n var defaultExCommandMap = [\n { name: 'map' },\n { name: 'nmap', shortName: 'nm' },\n { name: 'vmap', shortName: 'vm' },\n { name: 'unmap' },\n { name: 'write', shortName: 'w' },\n { name: 'undo', shortName: 'u' },\n { name: 'redo', shortName: 'red' },\n { name: 'set', shortName: 'set' },\n { name: 'sort', shortName: 'sor' },\n { name: 'substitute', shortName: 's' },\n { name: 'nohlsearch', shortName: 'noh' },\n { name: 'delmarks', shortName: 'delm' },\n { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true }\n ];\n Vim.ExCommandDispatcher = function() {\n this.buildCommandMap_();\n };\n Vim.ExCommandDispatcher.prototype = {\n processCommand: function(cm, input) {\n var vim = cm.state.vim;\n var commandHistoryRegister = vimGlobalState.registerController.getRegister(':');\n var previousCommand = commandHistoryRegister.toString();\n if (vim.visualMode) {\n exitVisualMode(cm);\n }\n var inputStream = new CodeMirror.StringStream(input);\n // update \": with the latest command whether valid or invalid\n commandHistoryRegister.setText(input);\n var params = {};\n params.input = input;\n try {\n this.parseInput_(cm, inputStream, params);\n } catch(e) {\n showConfirm(cm, e);\n throw e;\n }\n var commandName;\n if (!params.commandName) {\n // If only a line range is defined, move to the line.\n if (params.line !== undefined) {\n commandName = 'move';\n }\n } else {\n var command = this.matchCommand_(params.commandName);\n if (command) {\n commandName = command.name;\n if (command.excludeFromCommandHistory) {\n commandHistoryRegister.setText(previousCommand);\n }\n this.parseCommandArgs_(inputStream, params, command);\n if (command.type == 'exToKey') {\n // Handle Ex to Key mapping.\n for (var i = 0; i < command.toKeys.length; i++) {\n CodeMirror.Vim.handleKey(cm, command.toKeys[i]);\n }\n return;\n } else if (command.type == 'exToEx') {\n // Handle Ex to Ex mapping.\n this.processCommand(cm, command.toInput);\n return;\n }\n }\n }\n if (!commandName) {\n showConfirm(cm, 'Not an editor command \":' + input + '\"');\n return;\n }\n try {\n exCommands[commandName](cm, params);\n } catch(e) {\n showConfirm(cm, e);\n throw e;\n }\n },\n parseInput_: function(cm, inputStream, result) {\n inputStream.eatWhile(':');\n // Parse range.\n if (inputStream.eat('%')) {\n result.line = cm.firstLine();\n result.lineEnd = cm.lastLine();\n } else {\n result.line = this.parseLineSpec_(cm, inputStream);\n if (result.line !== undefined && inputStream.eat(',')) {\n result.lineEnd = this.parseLineSpec_(cm, inputStream);\n }\n }\n\n // Parse command name.\n var commandMatch = inputStream.match(/^(\\w+)/);\n if (commandMatch) {\n result.commandName = commandMatch[1];\n } else {\n result.commandName = inputStream.match(/.*/)[0];\n }\n\n return result;\n },\n parseLineSpec_: function(cm, inputStream) {\n var numberMatch = inputStream.match(/^(\\d+)/);\n if (numberMatch) {\n return parseInt(numberMatch[1], 10) - 1;\n }\n switch (inputStream.next()) {\n case '.':\n return cm.getCursor().line;\n case '$':\n return cm.lastLine();\n case '\\'':\n var mark = cm.state.vim.marks[inputStream.next()];\n if (mark && mark.find()) {\n return mark.find().line;\n }\n throw new Error('Mark not set');\n default:\n inputStream.backUp(1);\n return undefined;\n }\n },\n parseCommandArgs_: function(inputStream, params, command) {\n if (inputStream.eol()) {\n return;\n }\n params.argString = inputStream.match(/.*/)[0];\n // Parse command-line arguments\n var delim = command.argDelimiter || /\\s+/;\n var args = trim(params.argString).split(delim);\n if (args.length && args[0]) {\n params.args = args;\n }\n },\n matchCommand_: function(commandName) {\n // Return the command in the command map that matches the shortest\n // prefix of the passed in command name. The match is guaranteed to be\n // unambiguous if the defaultExCommandMap's shortNames are set up\n // correctly. (see @code{defaultExCommandMap}).\n for (var i = commandName.length; i > 0; i--) {\n var prefix = commandName.substring(0, i);\n if (this.commandMap_[prefix]) {\n var command = this.commandMap_[prefix];\n if (command.name.indexOf(commandName) === 0) {\n return command;\n }\n }\n }\n return null;\n },\n buildCommandMap_: function() {\n this.commandMap_ = {};\n for (var i = 0; i < defaultExCommandMap.length; i++) {\n var command = defaultExCommandMap[i];\n var key = command.shortName || command.name;\n this.commandMap_[key] = command;\n }\n },\n map: function(lhs, rhs, ctx) {\n if (lhs != ':' && lhs.charAt(0) == ':') {\n if (ctx) { throw Error('Mode not supported for ex mappings'); }\n var commandName = lhs.substring(1);\n if (rhs != ':' && rhs.charAt(0) == ':') {\n // Ex to Ex mapping\n this.commandMap_[commandName] = {\n name: commandName,\n type: 'exToEx',\n toInput: rhs.substring(1),\n user: true\n };\n } else {\n // Ex to key mapping\n this.commandMap_[commandName] = {\n name: commandName,\n type: 'exToKey',\n toKeys: parseKeyString(rhs),\n user: true\n };\n }\n } else {\n if (rhs != ':' && rhs.charAt(0) == ':') {\n // Key to Ex mapping.\n var mapping = {\n keys: parseKeyString(lhs),\n type: 'keyToEx',\n exArgs: { input: rhs.substring(1) },\n user: true};\n if (ctx) { mapping.context = ctx; }\n defaultKeymap.unshift(mapping);\n } else {\n // Key to key mapping\n var mapping = {\n keys: parseKeyString(lhs),\n type: 'keyToKey',\n toKeys: parseKeyString(rhs),\n user: true\n };\n if (ctx) { mapping.context = ctx; }\n defaultKeymap.unshift(mapping);\n }\n }\n },\n unmap: function(lhs, ctx) {\n var arrayEquals = function(a, b) {\n if (a === b) return true;\n if (a == null || b == null) return true;\n if (a.length != b.length) return false;\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n };\n if (lhs != ':' && lhs.charAt(0) == ':') {\n // Ex to Ex or Ex to key mapping\n if (ctx) { throw Error('Mode not supported for ex mappings'); }\n var commandName = lhs.substring(1);\n if (this.commandMap_[commandName] && this.commandMap_[commandName].user) {\n delete this.commandMap_[commandName];\n return;\n }\n } else {\n // Key to Ex or key to key mapping\n var keys = parseKeyString(lhs);\n for (var i = 0; i < defaultKeymap.length; i++) {\n if (arrayEquals(keys, defaultKeymap[i].keys)\n && defaultKeymap[i].context === ctx\n && defaultKeymap[i].user) {\n defaultKeymap.splice(i, 1);\n return;\n }\n }\n }\n throw Error('No such mapping.');\n }\n };\n\n // Converts a key string sequence of the form a<C-w>bd<Left> into Vim's\n // keymap representation.\n function parseKeyString(str) {\n var key, match;\n var keys = [];\n while (str) {\n match = (/<\\w+-.+?>|<\\w+>|./).exec(str);\n if (match === null)break;\n key = match[0];\n str = str.substring(match.index + key.length);\n keys.push(key);\n }\n return keys;\n }\n\n var exCommands = {\n map: function(cm, params, ctx) {\n var mapArgs = params.args;\n if (!mapArgs || mapArgs.length < 2) {\n if (cm) {\n showConfirm(cm, 'Invalid mapping: ' + params.input);\n }\n return;\n }\n exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx);\n },\n nmap: function(cm, params) { this.map(cm, params, 'normal'); },\n vmap: function(cm, params) { this.map(cm, params, 'visual'); },\n unmap: function(cm, params, ctx) {\n var mapArgs = params.args;\n if (!mapArgs || mapArgs.length < 1) {\n if (cm) {\n showConfirm(cm, 'No such mapping: ' + params.input);\n }\n return;\n }\n exCommandDispatcher.unmap(mapArgs[0], ctx);\n },\n move: function(cm, params) {\n commandDispatcher.processCommand(cm, cm.state.vim, {\n type: 'motion',\n motion: 'moveToLineOrEdgeOfDocument',\n motionArgs: { forward: false, explicitRepeat: true,\n linewise: true },\n repeatOverride: params.line+1});\n },\n set: function(cm, params) {\n var setArgs = params.args;\n if (!setArgs || setArgs.length < 1) {\n if (cm) {\n showConfirm(cm, 'Invalid mapping: ' + params.input);\n }\n return;\n }\n var expr = setArgs[0].split('=');\n var optionName = expr[0];\n var value = expr[1];\n var forceGet = false;\n\n if (optionName.charAt(optionName.length - 1) == '?') {\n // If post-fixed with ?, then the set is actually a get.\n if (value) { throw Error('Trailing characters: ' + params.argString); }\n optionName = optionName.substring(0, optionName.length - 1);\n forceGet = true;\n }\n if (value === undefined && optionName.substring(0, 2) == 'no') {\n // To set boolean options to false, the option name is prefixed with\n // 'no'.\n optionName = optionName.substring(2);\n value = false;\n }\n var optionIsBoolean = options[optionName] && options[optionName].type == 'boolean';\n if (optionIsBoolean && value == undefined) {\n // Calling set with a boolean option sets it to true.\n value = true;\n }\n if (!optionIsBoolean && !value || forceGet) {\n var oldValue = getOption(optionName);\n // If no value is provided, then we assume this is a get.\n if (oldValue === true || oldValue === false) {\n showConfirm(cm, ' ' + (oldValue ? '' : 'no') + optionName);\n } else {\n showConfirm(cm, ' ' + optionName + '=' + oldValue);\n }\n } else {\n setOption(optionName, value);\n }\n },\n registers: function(cm,params) {\n var regArgs = params.args;\n var registers = vimGlobalState.registerController.registers;\n var regInfo = '----------Registers----------<br><br>';\n if (!regArgs) {\n for (var registerName in registers) {\n var text = registers[registerName].toString();\n if (text.length) {\n regInfo += '\"' + registerName + ' ' + text + '<br>';\n }\n }\n } else {\n var registerName;\n regArgs = regArgs.join('');\n for (var i = 0; i < regArgs.length; i++) {\n registerName = regArgs.charAt(i);\n if (!vimGlobalState.registerController.isValidRegister(registerName)) {\n continue;\n }\n var register = registers[registerName] || new Register();\n regInfo += '\"' + registerName + ' ' + register.toString() + '<br>';\n }\n }\n showConfirm(cm, regInfo);\n },\n sort: function(cm, params) {\n var reverse, ignoreCase, unique, number;\n function parseArgs() {\n if (params.argString) {\n var args = new CodeMirror.StringStream(params.argString);\n if (args.eat('!')) { reverse = true; }\n if (args.eol()) { return; }\n if (!args.eatSpace()) { return 'Invalid arguments'; }\n var opts = args.match(/[a-z]+/);\n if (opts) {\n opts = opts[0];\n ignoreCase = opts.indexOf('i') != -1;\n unique = opts.indexOf('u') != -1;\n var decimal = opts.indexOf('d') != -1 && 1;\n var hex = opts.indexOf('x') != -1 && 1;\n var octal = opts.indexOf('o') != -1 && 1;\n if (decimal + hex + octal > 1) { return 'Invalid arguments'; }\n number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';\n }\n if (args.eatSpace() && args.match(/\\/.*\\//)) { 'patterns not supported'; }\n }\n }\n var err = parseArgs();\n if (err) {\n showConfirm(cm, err + ': ' + params.argString);\n return;\n }\n var lineStart = params.line || cm.firstLine();\n var lineEnd = params.lineEnd || params.line || cm.lastLine();\n if (lineStart == lineEnd) { return; }\n var curStart = Pos(lineStart, 0);\n var curEnd = Pos(lineEnd, lineLength(cm, lineEnd));\n var text = cm.getRange(curStart, curEnd).split('\\n');\n var numberRegex = (number == 'decimal') ? /(-?)([\\d]+)/ :\n (number == 'hex') ? /(-?)(?:0x)?([0-9a-f]+)/i :\n (number == 'octal') ? /([0-7]+)/ : null;\n var radix = (number == 'decimal') ? 10 : (number == 'hex') ? 16 : (number == 'octal') ? 8 : null;\n var numPart = [], textPart = [];\n if (number) {\n for (var i = 0; i < text.length; i++) {\n if (numberRegex.exec(text[i])) {\n numPart.push(text[i]);\n } else {\n textPart.push(text[i]);\n }\n }\n } else {\n textPart = text;\n }\n function compareFn(a, b) {\n if (reverse) { var tmp; tmp = a; a = b; b = tmp; }\n if (ignoreCase) { a = a.toLowerCase(); b = b.toLowerCase(); }\n var anum = number && numberRegex.exec(a);\n var bnum = number && numberRegex.exec(b);\n if (!anum) { return a < b ? -1 : 1; }\n anum = parseInt((anum[1] + anum[2]).toLowerCase(), radix);\n bnum = parseInt((bnum[1] + bnum[2]).toLowerCase(), radix);\n return anum - bnum;\n }\n numPart.sort(compareFn);\n textPart.sort(compareFn);\n text = (!reverse) ? textPart.concat(numPart) : numPart.concat(textPart);\n if (unique) { // Remove duplicate lines\n var textOld = text;\n var lastLine;\n text = [];\n for (var i = 0; i < textOld.length; i++) {\n if (textOld[i] != lastLine) {\n text.push(textOld[i]);\n }\n lastLine = textOld[i];\n }\n }\n cm.replaceRange(text.join('\\n'), curStart, curEnd);\n },\n substitute: function(cm, params) {\n if (!cm.getSearchCursor) {\n throw new Error('Search feature not available. Requires searchcursor.js or ' +\n 'any other getSearchCursor implementation.');\n }\n var argString = params.argString;\n var slashes = argString ? findUnescapedSlashes(argString) : [];\n var replacePart = '';\n if (slashes.length) {\n if (slashes[0] !== 0) {\n showConfirm(cm, 'Substitutions should be of the form ' +\n ':s/pattern/replace/');\n return;\n }\n var regexPart = argString.substring(slashes[0] + 1, slashes[1]);\n var flagsPart;\n var count;\n var confirm = false; // Whether to confirm each replace.\n if (slashes[1]) {\n replacePart = argString.substring(slashes[1] + 1, slashes[2]);\n if (getOption('pcre')) {\n replacePart = unescapeRegexReplace(replacePart);\n } else {\n replacePart = translateRegexReplace(replacePart);\n }\n vimGlobalState.lastSubstituteReplacePart = replacePart;\n }\n if (slashes[2]) {\n // After the 3rd slash, we can have flags followed by a space followed\n // by count.\n var trailing = argString.substring(slashes[2] + 1).split(' ');\n flagsPart = trailing[0];\n count = parseInt(trailing[1]);\n }\n if (flagsPart) {\n if (flagsPart.indexOf('c') != -1) {\n confirm = true;\n flagsPart.replace('c', '');\n }\n regexPart = regexPart + '/' + flagsPart;\n }\n }\n if (regexPart) {\n // If regex part is empty, then use the previous query. Otherwise use\n // the regex part as the new query.\n try {\n updateSearchQuery(cm, regexPart, true /** ignoreCase */,\n true /** smartCase */);\n } catch (e) {\n showConfirm(cm, 'Invalid regex: ' + regexPart);\n return;\n }\n }\n replacePart = replacePart || vimGlobalState.lastSubstituteReplacePart;\n if (replacePart === undefined) {\n showConfirm(cm, 'No previous substitute regular expression');\n return;\n }\n var state = getSearchState(cm);\n var query = state.getQuery();\n var lineStart = (params.line !== undefined) ? params.line : cm.getCursor().line;\n var lineEnd = params.lineEnd || lineStart;\n if (count) {\n lineStart = lineEnd;\n lineEnd = lineStart + count - 1;\n }\n var startPos = clipCursorToContent(cm, Pos(lineStart, 0));\n var cursor = cm.getSearchCursor(query, startPos);\n doReplace(cm, confirm, lineStart, lineEnd, cursor, query, replacePart);\n },\n redo: CodeMirror.commands.redo,\n undo: CodeMirror.commands.undo,\n write: function(cm) {\n if (CodeMirror.commands.save) {\n // If a save command is defined, call it.\n CodeMirror.commands.save(cm);\n } else {\n // Saves to text area if no save command is defined.\n cm.save();\n }\n },\n nohlsearch: function(cm) {\n clearSearchHighlight(cm);\n },\n delmarks: function(cm, params) {\n if (!params.argString || !trim(params.argString)) {\n showConfirm(cm, 'Argument required');\n return;\n }\n\n var state = cm.state.vim;\n var stream = new CodeMirror.StringStream(trim(params.argString));\n while (!stream.eol()) {\n stream.eatSpace();\n\n // Record the streams position at the beginning of the loop for use\n // in error messages.\n var count = stream.pos;\n\n if (!stream.match(/[a-zA-Z]/, false)) {\n showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));\n return;\n }\n\n var sym = stream.next();\n // Check if this symbol is part of a range\n if (stream.match('-', true)) {\n // This symbol is part of a range.\n\n // The range must terminate at an alphabetic character.\n if (!stream.match(/[a-zA-Z]/, false)) {\n showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));\n return;\n }\n\n var startMark = sym;\n var finishMark = stream.next();\n // The range must terminate at an alphabetic character which\n // shares the same case as the start of the range.\n if (isLowerCase(startMark) && isLowerCase(finishMark) ||\n isUpperCase(startMark) && isUpperCase(finishMark)) {\n var start = startMark.charCodeAt(0);\n var finish = finishMark.charCodeAt(0);\n if (start >= finish) {\n showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));\n return;\n }\n\n // Because marks are always ASCII values, and we have\n // determined that they are the same case, we can use\n // their char codes to iterate through the defined range.\n for (var j = 0; j <= finish - start; j++) {\n var mark = String.fromCharCode(start + j);\n delete state.marks[mark];\n }\n } else {\n showConfirm(cm, 'Invalid argument: ' + startMark + '-');\n return;\n }\n } else {\n // This symbol is a valid mark, and is not part of a range.\n delete state.marks[sym];\n }\n }\n }\n };\n\n var exCommandDispatcher = new Vim.ExCommandDispatcher();\n\n /**\n * @param {CodeMirror} cm CodeMirror instance we are in.\n * @param {boolean} confirm Whether to confirm each replace.\n * @param {Cursor} lineStart Line to start replacing from.\n * @param {Cursor} lineEnd Line to stop replacing at.\n * @param {RegExp} query Query for performing matches with.\n * @param {string} replaceWith Text to replace matches with. May contain $1,\n * $2, etc for replacing captured groups using Javascript replace.\n */\n function doReplace(cm, confirm, lineStart, lineEnd, searchCursor, query,\n replaceWith) {\n // Set up all the functions.\n cm.state.vim.exMode = true;\n var done = false;\n var lastPos = searchCursor.from();\n function replaceAll() {\n cm.operation(function() {\n while (!done) {\n replace();\n next();\n }\n stop();\n });\n }\n function replace() {\n var text = cm.getRange(searchCursor.from(), searchCursor.to());\n var newText = text.replace(query, replaceWith);\n searchCursor.replace(newText);\n }\n function next() {\n var found = searchCursor.findNext();\n if (!found) {\n done = true;\n } else if (isInRange(searchCursor.from(), lineStart, lineEnd)) {\n cm.scrollIntoView(searchCursor.from(), 30);\n cm.setSelection(searchCursor.from(), searchCursor.to());\n lastPos = searchCursor.from();\n done = false;\n } else {\n done = true;\n }\n }\n function stop(close) {\n if (close) { close(); }\n cm.focus();\n if (lastPos) {\n cm.setCursor(lastPos);\n var vim = cm.state.vim;\n vim.exMode = false;\n vim.lastHPos = vim.lastHSPos = lastPos.ch;\n }\n }\n function onPromptKeyDown(e, _value, close) {\n // Swallow all keys.\n CodeMirror.e_stop(e);\n var keyName = CodeMirror.keyName(e);\n switch (keyName) {\n case 'Y':\n replace(); next(); break;\n case 'N':\n next(); break;\n case 'A':\n cm.operation(replaceAll); break;\n case 'L':\n replace();\n // fall through and exit.\n case 'Q':\n case 'Esc':\n case 'Ctrl-C':\n case 'Ctrl-[':\n stop(close);\n break;\n }\n if (done) { stop(close); }\n }\n\n // Actually do replace.\n next();\n if (done) {\n showConfirm(cm, 'No matches for ' + query.source);\n return;\n }\n if (!confirm) {\n replaceAll();\n return;\n }\n showPrompt(cm, {\n prefix: 'replace with <strong>' + replaceWith + '</strong> (y/n/a/q/l)',\n onKeyDown: onPromptKeyDown\n });\n }\n\n // Register Vim with CodeMirror\n function buildVimKeyMap() {\n /**\n * Handle the raw key event from CodeMirror. Translate the\n * Shift + key modifier to the resulting letter, while preserving other\n * modifers.\n */\n function cmKeyToVimKey(key, modifier) {\n var vimKey = key;\n if (isUpperCase(vimKey) && modifier == 'Ctrl') {\n vimKey = vimKey.toLowerCase();\n }\n if (modifier) {\n // Vim will parse modifier+key combination as a single key.\n vimKey = modifier.charAt(0) + '-' + vimKey;\n }\n var specialKey = ({Enter:'CR',Backspace:'BS',Delete:'Del'})[vimKey];\n vimKey = specialKey ? specialKey : vimKey;\n vimKey = vimKey.length > 1 ? '<'+ vimKey + '>' : vimKey;\n return vimKey;\n }\n\n // Closure to bind CodeMirror, key, modifier.\n function keyMapper(vimKey) {\n return function(cm) {\n CodeMirror.Vim.handleKey(cm, vimKey);\n };\n }\n\n var cmToVimKeymap = {\n 'nofallthrough': true,\n 'style': 'fat-cursor'\n };\n function bindKeys(keys, modifier) {\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!modifier && key.length == 1) {\n // Wrap all keys without modifiers with '' to identify them by their\n // key characters instead of key identifiers.\n key = \"'\" + key + \"'\";\n }\n var vimKey = cmKeyToVimKey(keys[i], modifier);\n var cmKey = modifier ? modifier + '-' + key : key;\n cmToVimKeymap[cmKey] = keyMapper(vimKey);\n }\n }\n bindKeys(upperCaseAlphabet);\n bindKeys(lowerCaseAlphabet);\n bindKeys(upperCaseAlphabet, 'Ctrl');\n bindKeys(specialSymbols);\n bindKeys(specialSymbols, 'Ctrl');\n bindKeys(numbers);\n bindKeys(numbers, 'Ctrl');\n bindKeys(specialKeys);\n bindKeys(specialKeys, 'Ctrl');\n return cmToVimKeymap;\n }\n CodeMirror.keyMap.vim = buildVimKeyMap();\n\n function exitInsertMode(cm) {\n var vim = cm.state.vim;\n var macroModeState = vimGlobalState.macroModeState;\n var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.');\n var isPlaying = macroModeState.isPlaying;\n if (!isPlaying) {\n cm.off('change', onChange);\n CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);\n }\n if (!isPlaying && vim.insertModeRepeat > 1) {\n // Perform insert mode repeat for commands like 3,a and 3,o.\n repeatLastEdit(cm, vim, vim.insertModeRepeat - 1,\n true /** repeatForInsert */);\n vim.lastEditInputState.repeatOverride = vim.insertModeRepeat;\n }\n delete vim.insertModeRepeat;\n vim.insertMode = false;\n cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);\n cm.setOption('keyMap', 'vim');\n cm.setOption('disableInput', true);\n cm.toggleOverwrite(false); // exit replace mode if we were in it.\n // update the \". register before exiting insert mode\n insertModeChangeRegister.setText(macroModeState.lastInsertModeChanges.changes.join(''));\n CodeMirror.signal(cm, \"vim-mode-change\", {mode: \"normal\"});\n if (macroModeState.isRecording) {\n logInsertModeChange(macroModeState);\n }\n }\n\n CodeMirror.keyMap['vim-insert'] = {\n // TODO: override navigation keys so that Esc will cancel automatic\n // indentation from o, O, i_<CR>\n 'Esc': exitInsertMode,\n 'Ctrl-[': exitInsertMode,\n 'Ctrl-C': exitInsertMode,\n 'Ctrl-N': 'autocomplete',\n 'Ctrl-P': 'autocomplete',\n 'Enter': function(cm) {\n var fn = CodeMirror.commands.newlineAndIndentContinueComment ||\n CodeMirror.commands.newlineAndIndent;\n fn(cm);\n },\n fallthrough: ['default']\n };\n\n CodeMirror.keyMap['vim-replace'] = {\n 'Backspace': 'goCharLeft',\n fallthrough: ['vim-insert']\n };\n\n function executeMacroRegister(cm, vim, macroModeState, registerName) {\n var register = vimGlobalState.registerController.getRegister(registerName);\n var keyBuffer = register.keyBuffer;\n var imc = 0;\n macroModeState.isPlaying = true;\n macroModeState.replaySearchQueries = register.searchQueries.slice(0);\n for (var i = 0; i < keyBuffer.length; i++) {\n var text = keyBuffer[i];\n var match, key;\n while (text) {\n // Pull off one command key, which is either a single character\n // or a special sequence wrapped in '<' and '>', e.g. '<Space>'.\n match = (/<\\w+-.+?>|<\\w+>|./).exec(text);\n key = match[0];\n text = text.substring(match.index + key.length);\n CodeMirror.Vim.handleKey(cm, key);\n if (vim.insertMode) {\n repeatInsertModeChanges(\n cm, register.insertModeChanges[imc++].changes, 1);\n exitInsertMode(cm);\n }\n }\n };\n macroModeState.isPlaying = false;\n }\n\n function logKey(macroModeState, key) {\n if (macroModeState.isPlaying) { return; }\n var registerName = macroModeState.latestRegister;\n var register = vimGlobalState.registerController.getRegister(registerName);\n if (register) {\n register.pushText(key);\n }\n }\n\n function logInsertModeChange(macroModeState) {\n if (macroModeState.isPlaying) { return; }\n var registerName = macroModeState.latestRegister;\n var register = vimGlobalState.registerController.getRegister(registerName);\n if (register) {\n register.pushInsertModeChanges(macroModeState.lastInsertModeChanges);\n }\n }\n\n function logSearchQuery(macroModeState, query) {\n if (macroModeState.isPlaying) { return; }\n var registerName = macroModeState.latestRegister;\n var register = vimGlobalState.registerController.getRegister(registerName);\n if (register) {\n register.pushSearchQuery(query);\n }\n }\n\n /**\n * Listens for changes made in insert mode.\n * Should only be active in insert mode.\n */\n function onChange(_cm, changeObj) {\n var macroModeState = vimGlobalState.macroModeState;\n var lastChange = macroModeState.lastInsertModeChanges;\n if (!macroModeState.isPlaying) {\n while(changeObj) {\n lastChange.expectCursorActivityForChange = true;\n if (changeObj.origin == '+input' || changeObj.origin == 'paste'\n || changeObj.origin === undefined /* only in testing */) {\n var text = changeObj.text.join('\\n');\n lastChange.changes.push(text);\n }\n // Change objects may be chained with next.\n changeObj = changeObj.next;\n }\n }\n }\n\n /**\n * Listens for any kind of cursor activity on CodeMirror.\n */\n function onCursorActivity(cm) {\n var vim = cm.state.vim;\n if (vim.insertMode) {\n // Tracking cursor activity in insert mode (for macro support).\n var macroModeState = vimGlobalState.macroModeState;\n if (macroModeState.isPlaying) { return; }\n var lastChange = macroModeState.lastInsertModeChanges;\n if (lastChange.expectCursorActivityForChange) {\n lastChange.expectCursorActivityForChange = false;\n } else {\n // Cursor moved outside the context of an edit. Reset the change.\n lastChange.changes = [];\n }\n } else if (cm.doc.history.lastSelOrigin == '*mouse') {\n // Reset lastHPos if mouse click was done in normal mode.\n vim.lastHPos = cm.doc.getCursor().ch;\n }\n }\n\n /** Wrapper for special keys pressed in insert mode */\n function InsertModeKey(keyName) {\n this.keyName = keyName;\n }\n\n /**\n * Handles raw key down events from the text area.\n * - Should only be active in insert mode.\n * - For recording deletes in insert mode.\n */\n function onKeyEventTargetKeyDown(e) {\n var macroModeState = vimGlobalState.macroModeState;\n var lastChange = macroModeState.lastInsertModeChanges;\n var keyName = CodeMirror.keyName(e);\n function onKeyFound() {\n lastChange.changes.push(new InsertModeKey(keyName));\n return true;\n }\n if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) {\n CodeMirror.lookupKey(keyName, ['vim-insert'], onKeyFound);\n }\n }\n\n /**\n * Repeats the last edit, which includes exactly 1 command and at most 1\n * insert. Operator and motion commands are read from lastEditInputState,\n * while action commands are read from lastEditActionCommand.\n *\n * If repeatForInsert is true, then the function was called by\n * exitInsertMode to repeat the insert mode changes the user just made. The\n * corresponding enterInsertMode call was made with a count.\n */\n function repeatLastEdit(cm, vim, repeat, repeatForInsert) {\n var macroModeState = vimGlobalState.macroModeState;\n macroModeState.isPlaying = true;\n var isAction = !!vim.lastEditActionCommand;\n var cachedInputState = vim.inputState;\n function repeatCommand() {\n if (isAction) {\n commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand);\n } else {\n commandDispatcher.evalInput(cm, vim);\n }\n }\n function repeatInsert(repeat) {\n if (macroModeState.lastInsertModeChanges.changes.length > 0) {\n // For some reason, repeat cw in desktop VIM does not repeat\n // insert mode changes. Will conform to that behavior.\n repeat = !vim.lastEditActionCommand ? 1 : repeat;\n var changeObject = macroModeState.lastInsertModeChanges;\n // This isn't strictly necessary, but since lastInsertModeChanges is\n // supposed to be immutable during replay, this helps catch bugs.\n macroModeState.lastInsertModeChanges = {};\n repeatInsertModeChanges(cm, changeObject.changes, repeat);\n macroModeState.lastInsertModeChanges = changeObject;\n }\n }\n vim.inputState = vim.lastEditInputState;\n if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) {\n // o and O repeat have to be interlaced with insert repeats so that the\n // insertions appear on separate lines instead of the last line.\n for (var i = 0; i < repeat; i++) {\n repeatCommand();\n repeatInsert(1);\n }\n } else {\n if (!repeatForInsert) {\n // Hack to get the cursor to end up at the right place. If I is\n // repeated in insert mode repeat, cursor will be 1 insert\n // change set left of where it should be.\n repeatCommand();\n }\n repeatInsert(repeat);\n }\n vim.inputState = cachedInputState;\n if (vim.insertMode && !repeatForInsert) {\n // Don't exit insert mode twice. If repeatForInsert is set, then we\n // were called by an exitInsertMode call lower on the stack.\n exitInsertMode(cm);\n }\n macroModeState.isPlaying = false;\n };\n\n function repeatInsertModeChanges(cm, changes, repeat) {\n function keyHandler(binding) {\n if (typeof binding == 'string') {\n CodeMirror.commands[binding](cm);\n } else {\n binding(cm);\n }\n return true;\n }\n for (var i = 0; i < repeat; i++) {\n for (var j = 0; j < changes.length; j++) {\n var change = changes[j];\n if (change instanceof InsertModeKey) {\n CodeMirror.lookupKey(change.keyName, ['vim-insert'], keyHandler);\n } else {\n var cur = cm.getCursor();\n cm.replaceRange(change, cur, cur);\n }\n }\n }\n }\n\n resetVimGlobalState();\n return vimApi;\n };\n // Initialize Vim and make it available as an API.\n CodeMirror.Vim = Vim();\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/keymap/sublime.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/keymap/sublime.js",
"module-type": "library",
"text": "// A rough approximation of Sublime Text's keybindings\n// Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js\n\n(function(mod) {\n if (typeof exports == \"object\" && typeof module == \"object\") // CommonJS\n mod(require(\"../lib/codemirror\"), require(\"../addon/search/searchcursor\"), require(\"../addon/edit/matchbrackets\"));\n else if (typeof define == \"function\" && define.amd) // AMD\n define([\"../lib/codemirror\", \"../addon/search/searchcursor\", \"../addon/edit/matchbrackets\"], mod);\n else // Plain browser env\n mod(CodeMirror);\n})(function(CodeMirror) {\n \"use strict\";\n\n var map = CodeMirror.keyMap.sublime = {fallthrough: \"default\"};\n var cmds = CodeMirror.commands;\n var Pos = CodeMirror.Pos;\n var ctrl = CodeMirror.keyMap[\"default\"] == CodeMirror.keyMap.pcDefault ? \"Ctrl-\" : \"Cmd-\";\n\n // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.\n function findPosSubword(doc, start, dir) {\n if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));\n var line = doc.getLine(start.line);\n if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));\n var state = \"start\", type;\n for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {\n var next = line.charAt(dir < 0 ? pos - 1 : pos);\n var cat = next != \"_\" && CodeMirror.isWordChar(next) ? \"w\" : \"o\";\n if (cat == \"w\" && next.toUpperCase() == next) cat = \"W\";\n if (state == \"start\") {\n if (cat != \"o\") { state = \"in\"; type = cat; }\n } else if (state == \"in\") {\n if (type != cat) {\n if (type == \"w\" && cat == \"W\" && dir < 0) pos--;\n if (type == \"W\" && cat == \"w\" && dir > 0) { type = \"w\"; continue; }\n break;\n }\n }\n }\n return Pos(start.line, pos);\n }\n\n function moveSubword(cm, dir) {\n cm.extendSelectionsBy(function(range) {\n if (cm.display.shift || cm.doc.extend || range.empty())\n return findPosSubword(cm.doc, range.head, dir);\n else\n return dir < 0 ? range.from() : range.to();\n });\n }\n\n cmds[map[\"Alt-Left\"] = \"goSubwordLeft\"] = function(cm) { moveSubword(cm, -1); };\n cmds[map[\"Alt-Right\"] = \"goSubwordRight\"] = function(cm) { moveSubword(cm, 1); };\n\n cmds[map[ctrl + \"Up\"] = \"scrollLineUp\"] = function(cm) {\n var info = cm.getScrollInfo();\n if (!cm.somethingSelected()) {\n var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, \"local\");\n if (cm.getCursor().line >= visibleBottomLine)\n cm.execCommand(\"goLineUp\");\n }\n cm.scrollTo(null, info.top - cm.defaultTextHeight());\n };\n cmds[map[ctrl + \"Down\"] = \"scrollLineDown\"] = function(cm) {\n var info = cm.getScrollInfo();\n if (!cm.somethingSelected()) {\n var visibleTopLine = cm.lineAtHeight(info.top, \"local\")+1;\n if (cm.getCursor().line <= visibleTopLine)\n cm.execCommand(\"goLineDown\");\n }\n cm.scrollTo(null, info.top + cm.defaultTextHeight());\n };\n\n cmds[map[\"Shift-\" + ctrl + \"L\"] = \"splitSelectionByLine\"] = function(cm) {\n var ranges = cm.listSelections(), lineRanges = [];\n for (var i = 0; i < ranges.length; i++) {\n var from = ranges[i].from(), to = ranges[i].to();\n for (var line = from.line; line <= to.line; ++line)\n if (!(to.line > from.line && line == to.line && to.ch == 0))\n lineRanges.push({anchor: line == from.line ? from : Pos(line, 0),\n head: line == to.line ? to : Pos(line)});\n }\n cm.setSelections(lineRanges, 0);\n };\n\n map[\"Shift-Tab\"] = \"indentLess\";\n\n cmds[map[\"Esc\"] = \"singleSelectionTop\"] = function(cm) {\n var range = cm.listSelections()[0];\n cm.setSelection(range.anchor, range.head, {scroll: false});\n };\n\n cmds[map[ctrl + \"L\"] = \"selectLine\"] = function(cm) {\n var ranges = cm.listSelections(), extended = [];\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n extended.push({anchor: Pos(range.from().line, 0),\n head: Pos(range.to().line + 1, 0)});\n }\n cm.setSelections(extended);\n };\n\n map[\"Shift-\" + ctrl + \"K\"] = \"deleteLine\";\n\n function insertLine(cm, above) {\n cm.operation(function() {\n var len = cm.listSelections().length, newSelection = [], last = -1;\n for (var i = 0; i < len; i++) {\n var head = cm.listSelections()[i].head;\n if (head.line <= last) continue;\n var at = Pos(head.line + (above ? 0 : 1), 0);\n cm.replaceRange(\"\\n\", at, null, \"+insertLine\");\n cm.indentLine(at.line, null, true);\n newSelection.push({head: at, anchor: at});\n last = head.line + 1;\n }\n cm.setSelections(newSelection);\n });\n }\n\n cmds[map[ctrl + \"Enter\"] = \"insertLineAfter\"] = function(cm) { insertLine(cm, false); };\n\n cmds[map[\"Shift-\" + ctrl + \"Enter\"] = \"insertLineBefore\"] = function(cm) { insertLine(cm, true); };\n\n function wordAt(cm, pos) {\n var start = pos.ch, end = start, line = cm.getLine(pos.line);\n while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start;\n while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end;\n return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)};\n }\n\n cmds[map[ctrl + \"D\"] = \"selectNextOccurrence\"] = function(cm) {\n var from = cm.getCursor(\"from\"), to = cm.getCursor(\"to\");\n var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;\n if (CodeMirror.cmpPos(from, to) == 0) {\n var word = wordAt(cm, from);\n if (!word.word) return;\n cm.setSelection(word.from, word.to);\n fullWord = true;\n } else {\n var text = cm.getRange(from, to);\n var query = fullWord ? new RegExp(\"\\\\b\" + text + \"\\\\b\") : text;\n var cur = cm.getSearchCursor(query, to);\n if (cur.findNext()) {\n cm.addSelection(cur.from(), cur.to());\n } else {\n cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));\n if (cur.findNext())\n cm.addSelection(cur.from(), cur.to());\n }\n }\n if (fullWord)\n cm.state.sublimeFindFullWord = cm.doc.sel;\n };\n\n var mirror = \"(){}[]\";\n function selectBetweenBrackets(cm) {\n var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1);\n if (!opening) return;\n for (;;) {\n var closing = cm.scanForBracket(pos, 1);\n if (!closing) return;\n if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {\n cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false);\n return true;\n }\n pos = Pos(closing.pos.line, closing.pos.ch + 1);\n }\n }\n\n cmds[map[\"Shift-\" + ctrl + \"Space\"] = \"selectScope\"] = function(cm) {\n selectBetweenBrackets(cm) || cm.execCommand(\"selectAll\");\n };\n cmds[map[\"Shift-\" + ctrl + \"M\"] = \"selectBetweenBrackets\"] = function(cm) {\n if (!selectBetweenBrackets(cm)) return CodeMirror.Pass;\n };\n\n cmds[map[ctrl + \"M\"] = \"goToBracket\"] = function(cm) {\n cm.extendSelectionsBy(function(range) {\n var next = cm.scanForBracket(range.head, 1);\n if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos;\n var prev = cm.scanForBracket(range.head, -1);\n return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head;\n });\n };\n\n cmds[map[\"Shift-\" + ctrl + \"Up\"] = \"swapLineUp\"] = function(cm) {\n var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1;\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i], from = range.from().line - 1, to = range.to().line;\n if (from > at) linesToMove.push(from, to);\n else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;\n at = to;\n }\n cm.operation(function() {\n for (var i = 0; i < linesToMove.length; i += 2) {\n var from = linesToMove[i], to = linesToMove[i + 1];\n var line = cm.getLine(from);\n cm.replaceRange(\"\", Pos(from, 0), Pos(from + 1, 0), \"+swapLine\");\n if (to > cm.lastLine()) {\n cm.replaceRange(\"\\n\" + line, Pos(cm.lastLine()), null, \"+swapLine\");\n var sels = cm.listSelections(), last = sels[sels.length - 1];\n var head = last.head.line == to ? Pos(to - 1) : last.head;\n var anchor = last.anchor.line == to ? Pos(to - 1) : last.anchor;\n cm.setSelections(sels.slice(0, sels.length - 1).concat([{head: head, anchor: anchor}]));\n } else {\n cm.replaceRange(line + \"\\n\", Pos(to, 0), null, \"+swapLine\");\n }\n }\n cm.scrollIntoView();\n });\n };\n\n cmds[map[\"Shift-\" + ctrl + \"Down\"] = \"swapLineDown\"] = function(cm) {\n var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;\n for (var i = ranges.length - 1; i >= 0; i--) {\n var range = ranges[i], from = range.to().line + 1, to = range.from().line;\n if (from < at) linesToMove.push(from, to);\n else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;\n at = to;\n }\n cm.operation(function() {\n for (var i = linesToMove.length - 2; i >= 0; i -= 2) {\n var from = linesToMove[i], to = linesToMove[i + 1];\n var line = cm.getLine(from);\n if (from == cm.lastLine())\n cm.replaceRange(\"\", Pos(from - 1), Pos(from), \"+swapLine\");\n else\n cm.replaceRange(\"\", Pos(from, 0), Pos(from + 1, 0), \"+swapLine\");\n cm.replaceRange(line + \"\\n\", Pos(to, 0), null, \"+swapLine\");\n }\n cm.scrollIntoView();\n });\n };\n\n map[ctrl + \"/\"] = \"toggleComment\";\n\n cmds[map[ctrl + \"J\"] = \"joinLines\"] = function(cm) {\n var ranges = cm.listSelections(), joined = [];\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i], from = range.from();\n var start = from.line, end = range.to().line;\n while (i < ranges.length - 1 && ranges[i + 1].from().line == end)\n end = ranges[++i].to().line;\n joined.push({start: start, end: end, anchor: !range.empty() && from});\n }\n cm.operation(function() {\n var offset = 0, ranges = [];\n for (var i = 0; i < joined.length; i++) {\n var obj = joined[i];\n var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head;\n for (var line = obj.start; line <= obj.end; line++) {\n var actual = line - offset;\n if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);\n if (actual < cm.lastLine()) {\n cm.replaceRange(\" \", Pos(actual), Pos(actual + 1, /^\\s*/.exec(cm.getLine(actual + 1))[0].length));\n ++offset;\n }\n }\n ranges.push({anchor: anchor || head, head: head});\n }\n cm.setSelections(ranges, 0);\n });\n };\n\n cmds[map[\"Shift-\" + ctrl + \"D\"] = \"duplicateLine\"] = function(cm) {\n cm.operation(function() {\n var rangeCount = cm.listSelections().length;\n for (var i = 0; i < rangeCount; i++) {\n var range = cm.listSelections()[i];\n if (range.empty())\n cm.replaceRange(cm.getLine(range.head.line) + \"\\n\", Pos(range.head.line, 0));\n else\n cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());\n }\n cm.scrollIntoView();\n });\n };\n\n map[ctrl + \"T\"] = \"transposeChars\";\n\n function sortLines(cm, caseSensitive) {\n var ranges = cm.listSelections(), toSort = [], selected;\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n if (range.empty()) continue;\n var from = range.from().line, to = range.to().line;\n while (i < ranges.length - 1 && ranges[i + 1].from().line == to)\n to = range[++i].to().line;\n toSort.push(from, to);\n }\n if (toSort.length) selected = true;\n else toSort.push(cm.firstLine(), cm.lastLine());\n\n cm.operation(function() {\n var ranges = [];\n for (var i = 0; i < toSort.length; i += 2) {\n var from = toSort[i], to = toSort[i + 1];\n var start = Pos(from, 0), end = Pos(to);\n var lines = cm.getRange(start, end, false);\n if (caseSensitive)\n lines.sort();\n else\n lines.sort(function(a, b) {\n var au = a.toUpperCase(), bu = b.toUpperCase();\n if (au != bu) { a = au; b = bu; }\n return a < b ? -1 : a == b ? 0 : 1;\n });\n cm.replaceRange(lines, start, end);\n if (selected) ranges.push({anchor: start, head: end});\n }\n if (selected) cm.setSelections(ranges, 0);\n });\n }\n\n cmds[map[\"F9\"] = \"sortLines\"] = function(cm) { sortLines(cm, true); };\n cmds[map[ctrl + \"F9\"] = \"sortLinesInsensitive\"] = function(cm) { sortLines(cm, false); };\n\n cmds[map[\"F2\"] = \"nextBookmark\"] = function(cm) {\n var marks = cm.state.sublimeBookmarks;\n if (marks) while (marks.length) {\n var current = marks.shift();\n var found = current.find();\n if (found) {\n marks.push(current);\n return cm.setSelection(found.from, found.to);\n }\n }\n };\n\n cmds[map[\"Shift-F2\"] = \"prevBookmark\"] = function(cm) {\n var marks = cm.state.sublimeBookmarks;\n if (marks) while (marks.length) {\n marks.unshift(marks.pop());\n var found = marks[marks.length - 1].find();\n if (!found)\n marks.pop();\n else\n return cm.setSelection(found.from, found.to);\n }\n };\n\n cmds[map[ctrl + \"F2\"] = \"toggleBookmark\"] = function(cm) {\n var ranges = cm.listSelections();\n var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []);\n for (var i = 0; i < ranges.length; i++) {\n var from = ranges[i].from(), to = ranges[i].to();\n var found = cm.findMarks(from, to);\n for (var j = 0; j < found.length; j++) {\n if (found[j].sublimeBookmark) {\n found[j].clear();\n for (var k = 0; k < marks.length; k++)\n if (marks[k] == found[j])\n marks.splice(k--, 1);\n break;\n }\n }\n if (j == found.length)\n marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false}));\n }\n };\n\n cmds[map[\"Shift-\" + ctrl + \"F2\"] = \"clearBookmarks\"] = function(cm) {\n var marks = cm.state.sublimeBookmarks;\n if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear();\n marks.length = 0;\n };\n\n cmds[map[\"Alt-F2\"] = \"selectBookmarks\"] = function(cm) {\n var marks = cm.state.sublimeBookmarks, ranges = [];\n if (marks) for (var i = 0; i < marks.length; i++) {\n var found = marks[i].find();\n if (!found)\n marks.splice(i--, 0);\n else\n ranges.push({anchor: found.from, head: found.to});\n }\n if (ranges.length)\n cm.setSelections(ranges, 0);\n };\n\n map[\"Alt-Q\"] = \"wrapLines\";\n\n var mapK = CodeMirror.keyMap[\"sublime-Ctrl-K\"] = {auto: \"sublime\", nofallthrough: true};\n\n map[ctrl + \"K\"] = function(cm) {cm.setOption(\"keyMap\", \"sublime-Ctrl-K\");};\n\n function modifyWordOrSelection(cm, mod) {\n cm.operation(function() {\n var ranges = cm.listSelections(), indices = [], replacements = [];\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n if (range.empty()) { indices.push(i); replacements.push(\"\"); }\n else replacements.push(mod(cm.getRange(range.from(), range.to())));\n }\n cm.replaceSelections(replacements, \"around\", \"case\");\n for (var i = indices.length - 1, at; i >= 0; i--) {\n var range = ranges[indices[i]];\n if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;\n var word = wordAt(cm, range.head);\n at = word.from;\n cm.replaceRange(mod(word.word), word.from, word.to);\n }\n });\n }\n\n mapK[ctrl + \"Backspace\"] = \"delLineLeft\";\n\n cmds[mapK[ctrl + \"K\"] = \"delLineRight\"] = function(cm) {\n cm.operation(function() {\n var ranges = cm.listSelections();\n for (var i = ranges.length - 1; i >= 0; i--)\n cm.replaceRange(\"\", ranges[i].anchor, Pos(ranges[i].to().line), \"+delete\");\n cm.scrollIntoView();\n });\n };\n\n cmds[mapK[ctrl + \"U\"] = \"upcaseAtCursor\"] = function(cm) {\n modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); });\n };\n cmds[mapK[ctrl + \"L\"] = \"downcaseAtCursor\"] = function(cm) {\n modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); });\n };\n\n cmds[mapK[ctrl + \"Space\"] = \"setSublimeMark\"] = function(cm) {\n if (cm.state.sublimeMark) cm.state.sublimeMark.clear();\n cm.state.sublimeMark = cm.setBookmark(cm.getCursor());\n };\n cmds[mapK[ctrl + \"A\"] = \"selectToSublimeMark\"] = function(cm) {\n var found = cm.state.sublimeMark && cm.state.sublimeMark.find();\n if (found) cm.setSelection(cm.getCursor(), found);\n };\n cmds[mapK[ctrl + \"W\"] = \"deleteToSublimeMark\"] = function(cm) {\n var found = cm.state.sublimeMark && cm.state.sublimeMark.find();\n if (found) {\n var from = cm.getCursor(), to = found;\n if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }\n cm.state.sublimeKilled = cm.getRange(from, to);\n cm.replaceRange(\"\", from, to);\n }\n };\n cmds[mapK[ctrl + \"X\"] = \"swapWithSublimeMark\"] = function(cm) {\n var found = cm.state.sublimeMark && cm.state.sublimeMark.find();\n if (found) {\n cm.state.sublimeMark.clear();\n cm.state.sublimeMark = cm.setBookmark(cm.getCursor());\n cm.setCursor(found);\n }\n };\n cmds[mapK[ctrl + \"Y\"] = \"sublimeYank\"] = function(cm) {\n if (cm.state.sublimeKilled != null)\n cm.replaceSelection(cm.state.sublimeKilled, null, \"paste\");\n };\n\n mapK[ctrl + \"G\"] = \"clearBookmarks\";\n cmds[mapK[ctrl + \"C\"] = \"showInCenter\"] = function(cm) {\n var pos = cm.cursorCoords(null, \"local\");\n cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);\n };\n\n cmds[map[\"Shift-Alt-Up\"] = \"selectLinesUpward\"] = function(cm) {\n cm.operation(function() {\n var ranges = cm.listSelections();\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n if (range.head.line > cm.firstLine())\n cm.addSelection(Pos(range.head.line - 1, range.head.ch));\n }\n });\n };\n cmds[map[\"Shift-Alt-Down\"] = \"selectLinesDownward\"] = function(cm) {\n cm.operation(function() {\n var ranges = cm.listSelections();\n for (var i = 0; i < ranges.length; i++) {\n var range = ranges[i];\n if (range.head.line < cm.lastLine())\n cm.addSelection(Pos(range.head.line + 1, range.head.ch));\n }\n });\n };\n\n function findAndGoTo(cm, forward) {\n var from = cm.getCursor(\"from\"), to = cm.getCursor(\"to\");\n if (CodeMirror.cmpPos(from, to) == 0) {\n var word = wordAt(cm, from);\n if (!word.word) return;\n from = word.from;\n to = word.to;\n }\n\n var query = cm.getRange(from, to);\n var cur = cm.getSearchCursor(query, forward ? to : from);\n\n if (forward ? cur.findNext() : cur.findPrevious()) {\n cm.setSelection(cur.from(), cur.to());\n } else {\n cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0)\n : cm.clipPos(Pos(cm.lastLine())));\n if (forward ? cur.findNext() : cur.findPrevious())\n cm.setSelection(cur.from(), cur.to());\n else if (word)\n cm.setSelection(from, to);\n }\n };\n cmds[map[ctrl + \"F3\"] = \"findUnder\"] = function(cm) { findAndGoTo(cm, true); };\n cmds[map[\"Shift-\" + ctrl + \"F3\"] = \"findUnderPrevious\"] = function(cm) { findAndGoTo(cm,false); };\n\n map[\"Shift-\" + ctrl + \"[\"] = \"fold\";\n map[\"Shift-\" + ctrl + \"]\"] = \"unfold\";\n mapK[ctrl + \"0\"] = mapK[ctrl + \"j\"] = \"unfoldAll\";\n\n map[ctrl + \"I\"] = \"findIncremental\";\n map[\"Shift-\" + ctrl + \"I\"] = \"findIncrementalReverse\";\n map[ctrl + \"H\"] = \"replace\";\n map[\"F3\"] = \"findNext\";\n map[\"Shift-F3\"] = \"findPrev\";\n\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/keymap/emacs.js": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/keymap/emacs.js",
"module-type": "library",
"text": "(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 Pos = CodeMirror.Pos;\n function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }\n\n // Kill 'ring'\n\n var killRing = [];\n function addToRing(str) {\n killRing.push(str);\n if (killRing.length > 50) killRing.shift();\n }\n function growRingTop(str) {\n if (!killRing.length) return addToRing(str);\n killRing[killRing.length - 1] += str;\n }\n function getFromRing(n) { return killRing[killRing.length - (n ? Math.min(n, 1) : 1)] || \"\"; }\n function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }\n\n var lastKill = null;\n\n function kill(cm, from, to, mayGrow, text) {\n if (text == null) text = cm.getRange(from, to);\n\n if (mayGrow && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen))\n growRingTop(text);\n else\n addToRing(text);\n cm.replaceRange(\"\", from, to, \"+delete\");\n\n if (mayGrow) lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()};\n else lastKill = null;\n }\n\n // Boundaries of various units\n\n function byChar(cm, pos, dir) {\n return cm.findPosH(pos, dir, \"char\", true);\n }\n\n function byWord(cm, pos, dir) {\n return cm.findPosH(pos, dir, \"word\", true);\n }\n\n function byLine(cm, pos, dir) {\n return cm.findPosV(pos, dir, \"line\", cm.doc.sel.goalColumn);\n }\n\n function byPage(cm, pos, dir) {\n return cm.findPosV(pos, dir, \"page\", cm.doc.sel.goalColumn);\n }\n\n function byParagraph(cm, pos, dir) {\n var no = pos.line, line = cm.getLine(no);\n var sawText = /\\S/.test(dir < 0 ? line.slice(0, pos.ch) : line.slice(pos.ch));\n var fst = cm.firstLine(), lst = cm.lastLine();\n for (;;) {\n no += dir;\n if (no < fst || no > lst)\n return cm.clipPos(Pos(no - dir, dir < 0 ? 0 : null));\n line = cm.getLine(no);\n var hasText = /\\S/.test(line);\n if (hasText) sawText = true;\n else if (sawText) return Pos(no, 0);\n }\n }\n\n function bySentence(cm, pos, dir) {\n var line = pos.line, ch = pos.ch;\n var text = cm.getLine(pos.line), sawWord = false;\n for (;;) {\n var next = text.charAt(ch + (dir < 0 ? -1 : 0));\n if (!next) { // End/beginning of line reached\n if (line == (dir < 0 ? cm.firstLine() : cm.lastLine())) return Pos(line, ch);\n text = cm.getLine(line + dir);\n if (!/\\S/.test(text)) return Pos(line, ch);\n line += dir;\n ch = dir < 0 ? text.length : 0;\n continue;\n }\n if (sawWord && /[!?.]/.test(next)) return Pos(line, ch + (dir > 0 ? 1 : 0));\n if (!sawWord) sawWord = /\\w/.test(next);\n ch += dir;\n }\n }\n\n function byExpr(cm, pos, dir) {\n var wrap;\n if (cm.findMatchingBracket && (wrap = cm.findMatchingBracket(pos, true))\n && wrap.match && (wrap.forward ? 1 : -1) == dir)\n return dir > 0 ? Pos(wrap.to.line, wrap.to.ch + 1) : wrap.to;\n\n for (var first = true;; first = false) {\n var token = cm.getTokenAt(pos);\n var after = Pos(pos.line, dir < 0 ? token.start : token.end);\n if (first && dir > 0 && token.end == pos.ch || !/\\w/.test(token.string)) {\n var newPos = cm.findPosH(after, dir, \"char\");\n if (posEq(after, newPos)) return pos;\n else pos = newPos;\n } else {\n return after;\n }\n }\n }\n\n // Prefixes (only crudely supported)\n\n function getPrefix(cm, precise) {\n var digits = cm.state.emacsPrefix;\n if (!digits) return precise ? null : 1;\n clearPrefix(cm);\n return digits == \"-\" ? -1 : Number(digits);\n }\n\n function repeated(cmd) {\n var f = typeof cmd == \"string\" ? function(cm) { cm.execCommand(cmd); } : cmd;\n return function(cm) {\n var prefix = getPrefix(cm);\n f(cm);\n for (var i = 1; i < prefix; ++i) f(cm);\n };\n }\n\n function findEnd(cm, by, dir) {\n var pos = cm.getCursor(), prefix = getPrefix(cm);\n if (prefix < 0) { dir = -dir; prefix = -prefix; }\n for (var i = 0; i < prefix; ++i) {\n var newPos = by(cm, pos, dir);\n if (posEq(newPos, pos)) break;\n pos = newPos;\n }\n return pos;\n }\n\n function move(by, dir) {\n var f = function(cm) {\n cm.extendSelection(findEnd(cm, by, dir));\n };\n f.motion = true;\n return f;\n }\n\n function killTo(cm, by, dir) {\n kill(cm, cm.getCursor(), findEnd(cm, by, dir), true);\n }\n\n function addPrefix(cm, digit) {\n if (cm.state.emacsPrefix) {\n if (digit != \"-\") cm.state.emacsPrefix += digit;\n return;\n }\n // Not active yet\n cm.state.emacsPrefix = digit;\n cm.on(\"keyHandled\", maybeClearPrefix);\n cm.on(\"inputRead\", maybeDuplicateInput);\n }\n\n var prefixPreservingKeys = {\"Alt-G\": true, \"Ctrl-X\": true, \"Ctrl-Q\": true, \"Ctrl-U\": true};\n\n function maybeClearPrefix(cm, arg) {\n if (!cm.state.emacsPrefixMap && !prefixPreservingKeys.hasOwnProperty(arg))\n clearPrefix(cm);\n }\n\n function clearPrefix(cm) {\n cm.state.emacsPrefix = null;\n cm.off(\"keyHandled\", maybeClearPrefix);\n cm.off(\"inputRead\", maybeDuplicateInput);\n }\n\n function maybeDuplicateInput(cm, event) {\n var dup = getPrefix(cm);\n if (dup > 1 && event.origin == \"+input\") {\n var one = event.text.join(\"\\n\"), txt = \"\";\n for (var i = 1; i < dup; ++i) txt += one;\n cm.replaceSelection(txt);\n }\n }\n\n function addPrefixMap(cm) {\n cm.state.emacsPrefixMap = true;\n cm.addKeyMap(prefixMap);\n cm.on(\"keyHandled\", maybeRemovePrefixMap);\n cm.on(\"inputRead\", maybeRemovePrefixMap);\n }\n\n function maybeRemovePrefixMap(cm, arg) {\n if (typeof arg == \"string\" && (/^\\d$/.test(arg) || arg == \"Ctrl-U\")) return;\n cm.removeKeyMap(prefixMap);\n cm.state.emacsPrefixMap = false;\n cm.off(\"keyHandled\", maybeRemovePrefixMap);\n cm.off(\"inputRead\", maybeRemovePrefixMap);\n }\n\n // Utilities\n\n function setMark(cm) {\n cm.setCursor(cm.getCursor());\n cm.setExtending(!cm.getExtending());\n cm.on(\"change\", function() { cm.setExtending(false); });\n }\n\n function clearMark(cm) {\n cm.setExtending(false);\n cm.setCursor(cm.getCursor());\n }\n\n function getInput(cm, msg, f) {\n if (cm.openDialog)\n cm.openDialog(msg + \": <input type=\\\"text\\\" style=\\\"width: 10em\\\"/>\", f, {bottom: true});\n else\n f(prompt(msg, \"\"));\n }\n\n function operateOnWord(cm, op) {\n var start = cm.getCursor(), end = cm.findPosH(start, 1, \"word\");\n cm.replaceRange(op(cm.getRange(start, end)), start, end);\n cm.setCursor(end);\n }\n\n function toEnclosingExpr(cm) {\n var pos = cm.getCursor(), line = pos.line, ch = pos.ch;\n var stack = [];\n while (line >= cm.firstLine()) {\n var text = cm.getLine(line);\n for (var i = ch == null ? text.length : ch; i > 0;) {\n var ch = text.charAt(--i);\n if (ch == \")\")\n stack.push(\"(\");\n else if (ch == \"]\")\n stack.push(\"[\");\n else if (ch == \"}\")\n stack.push(\"{\");\n else if (/[\\(\\{\\[]/.test(ch) && (!stack.length || stack.pop() != ch))\n return cm.extendSelection(Pos(line, i));\n }\n --line; ch = null;\n }\n }\n\n function quit(cm) {\n cm.execCommand(\"clearSearch\");\n clearMark(cm);\n }\n\n // Actual keymap\n\n var keyMap = CodeMirror.keyMap.emacs = {\n \"Ctrl-W\": function(cm) {kill(cm, cm.getCursor(\"start\"), cm.getCursor(\"end\"));},\n \"Ctrl-K\": repeated(function(cm) {\n var start = cm.getCursor(), end = cm.clipPos(Pos(start.line));\n var text = cm.getRange(start, end);\n if (!/\\S/.test(text)) {\n text += \"\\n\";\n end = Pos(start.line + 1, 0);\n }\n kill(cm, start, end, true, text);\n }),\n \"Alt-W\": function(cm) {\n addToRing(cm.getSelection());\n clearMark(cm);\n },\n \"Ctrl-Y\": function(cm) {\n var start = cm.getCursor();\n cm.replaceRange(getFromRing(getPrefix(cm)), start, start, \"paste\");\n cm.setSelection(start, cm.getCursor());\n },\n \"Alt-Y\": function(cm) {cm.replaceSelection(popFromRing(), \"around\", \"paste\");},\n\n \"Ctrl-Space\": setMark, \"Ctrl-Shift-2\": setMark,\n\n \"Ctrl-F\": move(byChar, 1), \"Ctrl-B\": move(byChar, -1),\n \"Right\": move(byChar, 1), \"Left\": move(byChar, -1),\n \"Ctrl-D\": function(cm) { killTo(cm, byChar, 1); },\n \"Delete\": function(cm) { killTo(cm, byChar, 1); },\n \"Ctrl-H\": function(cm) { killTo(cm, byChar, -1); },\n \"Backspace\": function(cm) { killTo(cm, byChar, -1); },\n\n \"Alt-F\": move(byWord, 1), \"Alt-B\": move(byWord, -1),\n \"Alt-D\": function(cm) { killTo(cm, byWord, 1); },\n \"Alt-Backspace\": function(cm) { killTo(cm, byWord, -1); },\n\n \"Ctrl-N\": move(byLine, 1), \"Ctrl-P\": move(byLine, -1),\n \"Down\": move(byLine, 1), \"Up\": move(byLine, -1),\n \"Ctrl-A\": \"goLineStart\", \"Ctrl-E\": \"goLineEnd\",\n \"End\": \"goLineEnd\", \"Home\": \"goLineStart\",\n\n \"Alt-V\": move(byPage, -1), \"Ctrl-V\": move(byPage, 1),\n \"PageUp\": move(byPage, -1), \"PageDown\": move(byPage, 1),\n\n \"Ctrl-Up\": move(byParagraph, -1), \"Ctrl-Down\": move(byParagraph, 1),\n\n \"Alt-A\": move(bySentence, -1), \"Alt-E\": move(bySentence, 1),\n \"Alt-K\": function(cm) { killTo(cm, bySentence, 1); },\n\n \"Ctrl-Alt-K\": function(cm) { killTo(cm, byExpr, 1); },\n \"Ctrl-Alt-Backspace\": function(cm) { killTo(cm, byExpr, -1); },\n \"Ctrl-Alt-F\": move(byExpr, 1), \"Ctrl-Alt-B\": move(byExpr, -1),\n\n \"Shift-Ctrl-Alt-2\": function(cm) {\n cm.setSelection(findEnd(cm, byExpr, 1), cm.getCursor());\n },\n \"Ctrl-Alt-T\": function(cm) {\n var leftStart = byExpr(cm, cm.getCursor(), -1), leftEnd = byExpr(cm, leftStart, 1);\n var rightEnd = byExpr(cm, leftEnd, 1), rightStart = byExpr(cm, rightEnd, -1);\n cm.replaceRange(cm.getRange(rightStart, rightEnd) + cm.getRange(leftEnd, rightStart) +\n cm.getRange(leftStart, leftEnd), leftStart, rightEnd);\n },\n \"Ctrl-Alt-U\": repeated(toEnclosingExpr),\n\n \"Alt-Space\": function(cm) {\n var pos = cm.getCursor(), from = pos.ch, to = pos.ch, text = cm.getLine(pos.line);\n while (from && /\\s/.test(text.charAt(from - 1))) --from;\n while (to < text.length && /\\s/.test(text.charAt(to))) ++to;\n cm.replaceRange(\" \", Pos(pos.line, from), Pos(pos.line, to));\n },\n \"Ctrl-O\": repeated(function(cm) { cm.replaceSelection(\"\\n\", \"start\"); }),\n \"Ctrl-T\": repeated(function(cm) {\n cm.execCommand(\"transposeChars\");\n }),\n\n \"Alt-C\": repeated(function(cm) {\n operateOnWord(cm, function(w) {\n var letter = w.search(/\\w/);\n if (letter == -1) return w;\n return w.slice(0, letter) + w.charAt(letter).toUpperCase() + w.slice(letter + 1).toLowerCase();\n });\n }),\n \"Alt-U\": repeated(function(cm) {\n operateOnWord(cm, function(w) { return w.toUpperCase(); });\n }),\n \"Alt-L\": repeated(function(cm) {\n operateOnWord(cm, function(w) { return w.toLowerCase(); });\n }),\n\n \"Alt-;\": \"toggleComment\",\n\n \"Ctrl-/\": repeated(\"undo\"), \"Shift-Ctrl--\": repeated(\"undo\"),\n \"Ctrl-Z\": repeated(\"undo\"), \"Cmd-Z\": repeated(\"undo\"),\n \"Shift-Alt-,\": \"goDocStart\", \"Shift-Alt-.\": \"goDocEnd\",\n \"Ctrl-S\": \"findNext\", \"Ctrl-R\": \"findPrev\", \"Ctrl-G\": quit, \"Shift-Alt-5\": \"replace\",\n \"Alt-/\": \"autocomplete\",\n \"Ctrl-J\": \"newlineAndIndent\", \"Enter\": false, \"Tab\": \"indentAuto\",\n\n \"Alt-G\": function(cm) {cm.setOption(\"keyMap\", \"emacs-Alt-G\");},\n \"Ctrl-X\": function(cm) {cm.setOption(\"keyMap\", \"emacs-Ctrl-X\");},\n \"Ctrl-Q\": function(cm) {cm.setOption(\"keyMap\", \"emacs-Ctrl-Q\");},\n \"Ctrl-U\": addPrefixMap\n };\n\n CodeMirror.keyMap[\"emacs-Ctrl-X\"] = {\n \"Tab\": function(cm) {\n cm.indentSelection(getPrefix(cm, true) || cm.getOption(\"indentUnit\"));\n },\n \"Ctrl-X\": function(cm) {\n cm.setSelection(cm.getCursor(\"head\"), cm.getCursor(\"anchor\"));\n },\n\n \"Ctrl-S\": \"save\", \"Ctrl-W\": \"save\", \"S\": \"saveAll\", \"F\": \"open\", \"U\": repeated(\"undo\"), \"K\": \"close\",\n \"Delete\": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); },\n auto: \"emacs\", nofallthrough: true, disableInput: true\n };\n\n CodeMirror.keyMap[\"emacs-Alt-G\"] = {\n \"G\": function(cm) {\n var prefix = getPrefix(cm, true);\n if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1);\n\n getInput(cm, \"Goto line\", function(str) {\n var num;\n if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0)\n cm.setCursor(num - 1);\n });\n },\n auto: \"emacs\", nofallthrough: true, disableInput: true\n };\n\n CodeMirror.keyMap[\"emacs-Ctrl-Q\"] = {\n \"Tab\": repeated(\"insertTab\"),\n auto: \"emacs\", nofallthrough: true\n };\n\n var prefixMap = {\"Ctrl-G\": clearPrefix};\n function regPrefix(d) {\n prefixMap[d] = function(cm) { addPrefix(cm, d); };\n keyMap[\"Ctrl-\" + d] = function(cm) { addPrefix(cm, d); };\n prefixPreservingKeys[\"Ctrl-\" + d] = true;\n }\n for (var i = 0; i < 10; ++i) regPrefix(String(i));\n regPrefix(\"-\");\n});\n"
},
"$:/plugins/tiddlywiki/codemirror/styles": {
"title": "$:/plugins/tiddlywiki/codemirror/styles",
"tags": "[[$:/tags/stylesheet]]",
"text": "/* Make the editor resize to fit its content */\n\n.CodeMirror {\n\theight: auto;\n\tborder: 1px solid #ddd;\n\tline-height: 1.5;\n\tfont-family: \"Monaco\", monospace;\n}\n\n.CodeMirror-scroll {\n\toverflow-x: auto;\n\toverflow-y: hidden;\t\n}\n"
}
}
}