├── .gitignore ├── Icon.png ├── Icon.xcf ├── images ├── Demo0.1.0.png └── Demo0.2.0.png ├── .vscodeignore ├── src ├── deps │ └── js-sequence-diagrams │ │ ├── danielbd.woff │ │ ├── danielbd.woff2 │ │ ├── sequence-diagram-min.css │ │ ├── sequence-diagram.css │ │ ├── webfont.js │ │ ├── underscore-min.js │ │ ├── sequence-diagram-snap-min.js │ │ ├── sequence-diagram-snap.js │ │ └── snap.svg-min.js ├── logger.ts ├── utils.ts ├── extension.ts ├── contentscript.js ├── preview.ts └── previewContentProvider.ts ├── .vscode ├── settings.json ├── launch.json └── tasks.json ├── tsconfig.json ├── README.md ├── webpack.config.js ├── vsc-extension-quickstart.md ├── CHANGELOG.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | *.vsix 4 | dist -------------------------------------------------------------------------------- /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/Icon.png -------------------------------------------------------------------------------- /Icon.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/Icon.xcf -------------------------------------------------------------------------------- /images/Demo0.1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/images/Demo0.1.0.png -------------------------------------------------------------------------------- /images/Demo0.2.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/images/Demo0.2.0.png -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules 3 | out/ 4 | src/ 5 | tsconfig.json 6 | webpack.config.js 7 | vsc-extension-quickstart.md -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/danielbd.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/src/deps/js-sequence-diagrams/danielbd.woff -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/danielbd.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandarDev/vscode-sequence-diagrams/HEAD/src/deps/js-sequence-diagrams/danielbd.woff2 -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | } 9 | } -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/sequence-diagram-min.css: -------------------------------------------------------------------------------- 1 | /** js sequence diagrams 2 | * https://bramp.github.io/js-sequence-diagrams/ 3 | * (c) 2012-2017 Andrew Brampton (bramp.net) 4 | * Simplified BSD license. 5 | */ 6 | @font-face{font-family:'danielbd';src:url(danielbd.woff2) format('woff2'),url(danielbd.woff) format('woff');font-weight:normal;font-style:normal} -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "dist", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src" 11 | }, 12 | "exclude": [ 13 | "node_modules", 14 | ".vscode-test" 15 | ] 16 | } -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/sequence-diagram.css: -------------------------------------------------------------------------------- 1 | /** js sequence diagrams 2 | * https://bramp.github.io/js-sequence-diagrams/ 3 | * (c) 2012-2017 Andrew Brampton (bramp.net) 4 | * Simplified BSD license. 5 | */ 6 | @font-face { 7 | font-family: 'danielbd'; 8 | src: url('danielbd.woff2') format('woff2'), 9 | url('danielbd.woff') format('woff'); 10 | font-weight: normal; 11 | font-style: normal; 12 | } 13 | -------------------------------------------------------------------------------- /src/logger.ts: -------------------------------------------------------------------------------- 1 | export default class logger { 2 | static loggerPrefix: string = "vscode-sequence-diagrams: "; 3 | 4 | public static info(message?: any) { 5 | if (typeof message === 'string') 6 | console.log(logger.loggerPrefix + message); 7 | else console.log(logger.loggerPrefix, message); 8 | } 9 | 10 | public static warn(message?: any) { 11 | console.warn(logger.loggerPrefix + message); 12 | } 13 | 14 | public static error(message?: any) { 15 | console.error(logger.loggerPrefix + message); 16 | } 17 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false, 12 | "sourceMaps": true, 13 | "outFiles": [ "${workspaceRoot}/dist/**/*.js" ], 14 | "preLaunchTask": "npm" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | export function throttle(func, wait) { 2 | var timeout, context, args, result; 3 | var previous = 0; 4 | 5 | var later = function() { 6 | previous = new Date().getTime(); 7 | timeout = null; 8 | result = func.apply(context, args); 9 | if (!timeout) context = args = null; 10 | }; 11 | 12 | var throttled = function() { 13 | var now = new Date().getTime(); 14 | var remaining = wait - (now - previous); 15 | context = this; 16 | args = arguments; 17 | if (remaining <= 0 || remaining > wait) { 18 | if (timeout) { 19 | clearTimeout(timeout); 20 | timeout = null; 21 | } 22 | previous = now; 23 | result = func.apply(context, args); 24 | if (!timeout) context = args = null; 25 | } else if (!timeout) { 26 | timeout = setTimeout(later, remaining); 27 | } 28 | return result; 29 | }; 30 | 31 | return throttled; 32 | } -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | // The module 'vscode' contains the VS Code extensibility API 3 | // Import the module and reference it with the alias vscode in your code below 4 | import * as vscode from 'vscode'; 5 | import preview from './preview'; 6 | import logger from './logger'; 7 | 8 | var previewInstance: preview; 9 | 10 | export function activate(context: vscode.ExtensionContext) { 11 | logger.info("Active!") 12 | 13 | // Open the preview 14 | previewInstance = new preview(context); 15 | previewInstance.present(); 16 | 17 | // Register commands 18 | const disposableCommands = [ 19 | vscode.commands.registerCommand('extension.showsequencediagrampreview', () => { previewInstance.present(); }), 20 | ]; 21 | 22 | for (let disposableCommandIndex = 0; disposableCommandIndex < disposableCommands.length; disposableCommandIndex++) { 23 | context.subscriptions.push(disposableCommands[disposableCommandIndex]); 24 | } 25 | } 26 | 27 | // this method is called when your extension is deactivated 28 | export function deactivate() { 29 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls a custom npm script that compiles the extension. 10 | { 11 | "version": "0.1.0", 12 | 13 | // we want to run npm 14 | "command": "npm", 15 | 16 | // the command is a shell script 17 | "isShellCommand": true, 18 | 19 | // show the output window only if unrecognized errors occur. 20 | "showOutput": "silent", 21 | 22 | // we run the custom script "compile" as defined in package.json 23 | "args": ["run", "watch", "--loglevel", "silent"], 24 | 25 | // The tsc compiler is started in watching mode 26 | "isBackground": true, 27 | 28 | // use the standard tsc in watch mode problem matcher to find compile problems in the output. 29 | "problemMatcher": "$tsc-watch" 30 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VSCode Sequence Diagrams 2 | 3 | _vscode-sequence-diagrams_ 4 | 5 | ## How to 6 | 7 | When you open `.seqdiag` file in Visual Studio Code, preview tab will open automatically. 8 | 9 | If you wish to reopen the preview tab, press `CTRL+SHIFT+P` or `F1` to open Command Palette and execute `Show Sequence Diagram Preview` command. 10 | 11 | See [js-sequence-diagrams](https://bramp.github.io/js-sequence-diagrams/) for syntax details. 12 | 13 | ## Configuration 14 | 15 | | property | description | 16 | |----------------------------------|------------------------------------------| 17 | | `sequencediagrams.diagram.style` | The diagram style. Select between `hand` for hand drawn diagram or `simple` for diagram with simple straight lines. | 18 | | `sequencediagrams.preview.trigger` | Configure the preview refresh on every change or on file save. Select between `onChange` and `onSave`. | 19 | 20 | ## Publishing 21 | 22 | ### Building the extension package 23 | 24 | ```bash 25 | yarn install 26 | yarn vscode:prepublish 27 | ``` 28 | 29 | ### Publishing to store 30 | 31 | Install Visual Studio Code Extensions CLI 32 | 33 | ```bash 34 | npm install -g vsce 35 | ``` 36 | 37 | Login and publish the extension 38 | 39 | ```bash 40 | vsce publish -p 41 | ``` 42 | 43 | **Enjoy!** 44 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | //@ts-check 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | const CopyPlugin = require('copy-webpack-plugin'); 7 | 8 | /**@type {import('webpack').Configuration}*/ 9 | const config = { 10 | target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ 11 | 12 | entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ 13 | output: { 14 | // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ 15 | path: path.resolve(__dirname, 'dist'), 16 | filename: 'extension.js', 17 | libraryTarget: 'commonjs2', 18 | devtoolModuleFilenameTemplate: '../[resource-path]' 19 | }, 20 | devtool: 'source-map', 21 | externals: { 22 | vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ 23 | }, 24 | resolve: { 25 | // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader 26 | extensions: ['.ts', '.js'] 27 | }, 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.ts$/, 32 | exclude: /node_modules/, 33 | use: [ 34 | { 35 | loader: 'ts-loader' 36 | } 37 | ] 38 | } 39 | ] 40 | }, 41 | plugins: [ 42 | new CopyPlugin({ 43 | patterns: [ 44 | { from: 'src/deps', to: 'deps' }, 45 | { from: 'src/contentscript.js', to: 'contentscript.js' } 46 | ] 47 | }) 48 | ] 49 | }; 50 | module.exports = config; -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your first VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension 5 | * `package.json` - this is the manifest file in which you declare your extension and command. 6 | The sample plugin registers a command and defines its title and command name. With this information 7 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `src/extension.ts` - this is the main file where you will provide the implementation of your command. 9 | The file exports one function, `activate`, which is called the very first time your extension is 10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 11 | We pass the function containing the implementation of the command as the second parameter to 12 | `registerCommand`. 13 | 14 | ## Get up and running straight away 15 | * press `F5` to open a new window with your extension loaded 16 | * run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World` 17 | * set breakpoints in your code inside `src/extension.ts` to debug your extension 18 | * find output from your extension in the debug console 19 | 20 | ## Make changes 21 | * you can relaunch the extension from the debug toolbar after changing code in `src/extension.ts` 22 | * you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes 23 | 24 | ## Explore the API 25 | * you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts` 26 | 27 | ## Run tests 28 | * open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests` 29 | * press `F5` to run the tests in a new window with your extension loaded 30 | * see the output of the test result in the debug console 31 | * make changes to `test/extension.test.ts` or create new test files inside the `test` folder 32 | * by convention, the test runner will only consider files matching the name pattern `**.test.ts` 33 | * you can create folders inside the `test` folder to structure your tests any way you want -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "vscode-sequence-diagrams" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [0.4.7] - 2021-04-12 8 | 9 | - Updated npm packages for securty #30, #31 10 | 11 | ## [0.4.5] - 2021-04-12 12 | 13 | - Fix assetPath function for production package (Community PR [#32](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/32) by [Joe Burns](https://github.com/JoeMcB)) 14 | 15 | ## [0.4.4] - 2021-03-30 16 | 17 | ### Fixed 18 | 19 | - Allow loading of resources from workspace root and extension's install directory (Community PR [#29](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/29) by [Chris Havekost](https://github.com/chrishavekost)) 20 | 21 | ## [0.4.3] - 2021-01-23 22 | 23 | ### Fixed 24 | 25 | - Extension build errors (Community PR [#27](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/27) by [Joe Burns](https://github.com/JoeMcB)) 26 | 27 | ## [0.4.1] - 2020-10-22 28 | 29 | ### Fixed 30 | 31 | - Sequence rendering (Community PR [#24](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/24) 32 | 33 | ## [0.4.0] - 2020-02-08 34 | 35 | ### Added 36 | 37 | - Added UTF-8 support when exporting (Community PR [#17](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/17) 🚀) 38 | - Preview can now be updated on file save or on every change 39 | 40 | ### Fixed 41 | 42 | - Typo in settings description (Community PR [#15](https://github.com/AleksandarDev/vscode-sequence-diagrams/pull/15) 😎) 43 | 44 | ## [0.3.1] - 2018-09-16 45 | 46 | ### Fixed 47 | 48 | - Fixed exporting diagram multiple times would fail 49 | 50 | ## [0.3.0] - 2018-09-15 51 | 52 | ### Added 53 | 54 | - Added export to SVG 55 | - Added export to PNG 56 | - Added parsing error message is now showing in preview 57 | 58 | ## [0.2.1] - 2017-09-13 59 | 60 | ### Fixed 61 | 62 | - Fixed diagram preview is blank on Unix systems 63 | 64 | ## [0.2.0] - 2017-09-07 65 | 66 | ### Added 67 | 68 | - Added diagram style option to configuration 69 | 70 | ![v0.2.0 Perview Screenshot](images/Demo0.2.0.png) 71 | 72 | ## [0.1.0] - 2017-09-06 73 | 74 | ### Added 75 | 76 | - Added preview 77 | - Added command "Show Sequence Diagram Preview" 78 | - Added `.seqdiag` extensions support 79 | 80 | ![v0.1.0 Preview Screenshot](images/Demo0.1.0.png) 81 | -------------------------------------------------------------------------------- /src/contentscript.js: -------------------------------------------------------------------------------- 1 | const exportSvgLink = document.querySelector('.link-download-svg'); 2 | const exportPngLink = document.querySelector('.link-download-png'); 3 | 4 | function getDiagramSvgBase64() { 5 | var svg = document.getElementById('diagram').children[0]; 6 | var xml = new XMLSerializer().serializeToString(svg); 7 | return btoa(encodeURIComponent(xml).replace(/%([0-9A-F]{2})/g,(match, p1)=> { 8 | return String.fromCharCode('0x' + p1); 9 | })); 10 | } 11 | 12 | function disableExportButtons() { 13 | exportSvgLink.classList.add('disabled'); 14 | exportPngLink.classList.add('disabled'); 15 | } 16 | 17 | function enableExportButtons() { 18 | exportSvgLink.classList.remove('disabled'); 19 | exportPngLink.classList.remove('disabled'); 20 | } 21 | 22 | try { 23 | exportSvgLink.onclick = () => { 24 | if (exportSvgLink.classList.contains('disabled')) 25 | return; 26 | disableExportButtons(); 27 | const data = getDiagramSvgBase64(); 28 | if (window.vscode == null) 29 | window.vscode = acquireVsCodeApi(); 30 | window.vscode.postMessage({ 31 | command: 'export-svg', 32 | data: data 33 | }); 34 | }; 35 | 36 | exportPngLink.onclick = () => { 37 | if (exportPngLink.classList.contains('disabled')) 38 | return; 39 | disableExportButtons(); 40 | const data = getDiagramSvgBase64(); 41 | if (window.vscode == null) 42 | window.vscode = acquireVsCodeApi(); 43 | window.vscode.postMessage({ 44 | command: 'export-png', 45 | data: data 46 | }); 47 | }; 48 | 49 | // Handle the message inside the webview 50 | window.addEventListener('message', event => { 51 | if (event == null || 52 | event.data == null || 53 | event.data.command == null) { 54 | return; 55 | } 56 | 57 | switch(event.data.command) { 58 | case 'set-source': 59 | try { 60 | document.getElementById("diagram").innerHTML = null; 61 | Diagram.parse(event.data.source).drawSVG("diagram", { theme: window.diagramStyle }); 62 | } catch(error) { 63 | document.getElementById('diagram').innerHTML = "" + error + ""; 64 | } 65 | break; 66 | case 'export-done': 67 | enableExportButtons(); 68 | break; 69 | } 70 | }); 71 | } 72 | catch (error) { 73 | document.getElementById('diagram').innerHTML = "" + error + ""; 74 | } 75 | //# sourceMappingURL=contentscript.js.map -------------------------------------------------------------------------------- /src/preview.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import previewContentProvider from './previewContentProvider'; 3 | import logger from './logger'; 4 | 5 | export default class preview { 6 | private provider: previewContentProvider; 7 | private exContext: vscode.ExtensionContext; 8 | private previewTrigger: string; 9 | 10 | constructor(context: vscode.ExtensionContext) { 11 | this.exContext = context; 12 | 13 | this.checkRefreshDocument = this.checkRefreshDocument.bind(this) 14 | 15 | // Attach to events 16 | var disposeOnDidChangeTextDocument = vscode.workspace.onDidChangeTextDocument(this.checkRefreshDocument); 17 | var disposeOnDidChangeActiveTextEditor = vscode.window.onDidChangeActiveTextEditor(this.checkRefreshDocument); 18 | 19 | this.exContext.subscriptions.push(disposeOnDidChangeTextDocument); 20 | this.exContext.subscriptions.push(disposeOnDidChangeActiveTextEditor); 21 | 22 | // Retrieve settings 23 | this.previewTrigger = vscode.workspace.getConfiguration("sequencediagrams").get("preview.trigger", "onChange"); 24 | } 25 | 26 | public async present() { 27 | // Instantiate preview provider and assign scheme 28 | this.provider = new previewContentProvider(this.exContext); 29 | this.provider.diagramStyle = vscode.workspace.getConfiguration("sequencediagrams").get("diagram.style", "simple"); 30 | this.provider.present(); 31 | 32 | this.checkRefreshDocument(vscode.window.activeTextEditor); 33 | } 34 | 35 | private checkRefreshDocument(editor: vscode.TextEditor | vscode.TextDocumentChangeEvent) { 36 | // Ignore if changed editor's document isn't the active one 37 | // or document is not diagram document 38 | if (editor === undefined || 39 | vscode.window.activeTextEditor === undefined || 40 | editor.document == null || 41 | editor.document.isClosed || 42 | editor.document !== vscode.window.activeTextEditor.document || 43 | !preview.isDocumentDiagram(editor.document)) { 44 | 45 | logger.info("Check refresh document rejected."); 46 | return; 47 | } 48 | 49 | // Check if we onlt need to update preview on save 50 | if (this.previewTrigger === "onSave" && 51 | editor.document.isDirty) { 52 | 53 | logger.info("Check refresh document rejected - trigger configured to OnSave."); 54 | return; 55 | } 56 | 57 | logger.info("Check refresh document accepted."); 58 | 59 | this.provider.refreshDocument(editor.document); 60 | } 61 | 62 | private static isDocumentDiagram(doc: vscode.TextDocument) { 63 | return doc.languageId === "sequencediagram"; 64 | } 65 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-sequence-diagrams", 3 | "displayName": "VSCode Sequence Diagrams", 4 | "description": "Generates UML sequence diagrams from simple text", 5 | "version": "0.4.7", 6 | "publisher": "AleksandarDev", 7 | "keywords": [ 8 | "uml", 9 | "sequence", 10 | "diagram", 11 | "preview", 12 | "code" 13 | ], 14 | "icon": "Icon.png", 15 | "license": "MIT", 16 | "preview": true, 17 | "author": { 18 | "name": "Aleksandar Toplek", 19 | "url": "https://github.com/AleksandarDev" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/AleksandarDev/vscode-sequence-diagrams" 24 | }, 25 | "bugs": { 26 | "url": "https://github.com/AleksandarDev/vscode-sequence-diagrams/issues" 27 | }, 28 | "engines": { 29 | "vscode": "^1.34.0" 30 | }, 31 | "categories": [ 32 | "Other" 33 | ], 34 | "activationEvents": [ 35 | "onCommand:extension.showsequencediagrampreview", 36 | "onLanguage:sequencediagram" 37 | ], 38 | "main": "./dist/extension", 39 | "contributes": { 40 | "commands": [ 41 | { 42 | "command": "extension.showsequencediagrampreview", 43 | "title": "Show Sequence Diagram Preview" 44 | } 45 | ], 46 | "languages": [ 47 | { 48 | "id": "sequencediagram", 49 | "aliases": [ 50 | "Sequence Diagram" 51 | ], 52 | "extensions": [ 53 | ".seqdiag" 54 | ] 55 | } 56 | ], 57 | "configuration": { 58 | "title": "Sequence Diagram configuration", 59 | "type": "object", 60 | "properties": { 61 | "sequencediagrams.diagram.style": { 62 | "enum": [ 63 | "hand", 64 | "simple" 65 | ], 66 | "default": "hand", 67 | "description": "The diagram style. Select between `hand` for hand drawn diagram or `simple` for diagram with simple straight lines." 68 | }, 69 | "sequencediagrams.preview.trigger": { 70 | "enum": [ 71 | "onChange", 72 | "onSave" 73 | ], 74 | "default": "onChange", 75 | "description": "Configure the preview refresh on every change or on file save." 76 | } 77 | } 78 | } 79 | }, 80 | "scripts": { 81 | "vscode:prepublish": "webpack --mode production", 82 | "webpack": "webpack --mode development", 83 | "webpack-dev": "webpack --mode development --watch", 84 | "test-compile": "webpack --mode development" 85 | }, 86 | "devDependencies": { 87 | "@types/node": "^10.14.17", 88 | "@types/vscode": "^1.34.0", 89 | "copy-webpack-plugin": "^6.2.1", 90 | "ts-loader": "^8.0.6", 91 | "typescript": "^3.5.0", 92 | "webpack": "^5.2.0", 93 | "webpack-cli": "^4.1.0" 94 | }, 95 | "dependencies": { 96 | "@types/svg2png": "^4.1.0", 97 | "svg2png": "^4.1.1" 98 | } 99 | } -------------------------------------------------------------------------------- /src/previewContentProvider.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as svg2png from 'svg2png'; 3 | import * as utils from './utils'; 4 | import logger from './logger'; 5 | import { writeFileSync } from 'fs'; 6 | import * as path from 'path'; 7 | 8 | export default class previewContentProvider { 9 | public diagramStyle: string; 10 | private currentPanel: vscode.WebviewPanel; 11 | private previewDocument: vscode.TextDocument; 12 | private throttledRefreshDocument; 13 | private extensionPath: string; 14 | 15 | constructor(context: vscode.ExtensionContext) { 16 | this.extensionPath = context.extensionPath; 17 | 18 | this._receiveMessage = this._receiveMessage.bind(this); 19 | this._refreshDocument = this._refreshDocument.bind(this); 20 | this._getExportFileName = this._getExportFileName.bind(this); 21 | 22 | this.currentPanel = vscode.window.createWebviewPanel( 23 | 'sequence-diagram', 24 | 'Sequence Diagram', 25 | vscode.ViewColumn.Two, { 26 | enableScripts: true, 27 | enableCommandUris: false, 28 | localResourceRoots: [ 29 | vscode.Uri.joinPath(context.extensionUri, 'dist') 30 | ] 31 | }); 32 | 33 | // Handle messages from the webview 34 | this.currentPanel.webview.onDidReceiveMessage( 35 | this._receiveMessage, 36 | undefined, 37 | context.subscriptions); 38 | 39 | this.currentPanel.onDidDispose( 40 | () => { this.currentPanel = undefined; }, 41 | undefined, 42 | context.subscriptions); 43 | 44 | this.throttledRefreshDocument = utils.throttle(this._refreshDocument, 200); 45 | } 46 | 47 | private async _receiveMessage(message) { 48 | if (message == null || message.command == null) return; 49 | 50 | let extension; 51 | try { 52 | let exportFileName; 53 | switch (message.command) { 54 | case 'export-svg': 55 | extension = "svg"; 56 | exportFileName = this._getExportFileName(extension); 57 | writeFileSync(exportFileName, Buffer.from(message.data, 'base64').toString('binary')); 58 | break; 59 | case 'export-png': 60 | extension = "png"; 61 | exportFileName = this._getExportFileName(extension); 62 | const pngBuffer = await svg2png(Buffer.from(message.data, 'base64')); 63 | writeFileSync(exportFileName, pngBuffer); 64 | break; 65 | } 66 | vscode.window.showInformationMessage("Sequence Diagrams - " + extension.toUpperCase() + " saved to " + exportFileName); 67 | } catch(error) { 68 | logger.error(error); 69 | vscode.window.showErrorMessage("Sequence Diagrams - Failed to save " + extension.toUpperCase()); 70 | } 71 | 72 | this.currentPanel.webview.postMessage({ 73 | command: 'export-done', 74 | }); 75 | } 76 | 77 | private _getExportFileName(extension: string) : string { 78 | const fileName = this.previewDocument.fileName; 79 | const exportFileName = (fileName.substr(0, fileName.lastIndexOf('.')) || fileName) + "." + extension; 80 | return exportFileName; 81 | } 82 | 83 | public present() { 84 | this.setWebViewContent(); 85 | } 86 | 87 | public refreshDocument(previewDocument: vscode.TextDocument) { 88 | this.previewDocument = previewDocument; 89 | this.throttledRefreshDocument(); 90 | } 91 | 92 | private _refreshDocument() { 93 | this.currentPanel.webview.postMessage({ 94 | command: 'set-source', 95 | source: this.previewDocument.getText() 96 | }); 97 | } 98 | 99 | private setWebViewContent() { 100 | if (this.currentPanel == null) return; 101 | this.currentPanel.webview.html = this.createContent() 102 | } 103 | 104 | private createContent(): string { 105 | const svgStyle = ` 106 | body { margin: 0; } 107 | 108 | .status-panel { 109 | background-color: rgba(128, 128, 128, 0.1); 110 | padding: 4px; 111 | position: fixed; 112 | bottom: 0; 113 | left: 0; 114 | right: 0; 115 | text-align: right; 116 | } 117 | 118 | .export-btn { 119 | cursor: pointer; 120 | border: 1px solid #aaa; 121 | padding: 4px 8px; 122 | color: #333333; 123 | display: inline-block; 124 | } 125 | body.vscode-dark .export-btn { 126 | color: #dedede; 127 | } 128 | 129 | .export-btn.disabled { 130 | cursor: default; 131 | background-color: rgba(128, 128, 128, 0.1); 132 | color: #666666; 133 | } 134 | body.vscode-dark .export-btn.disabled { 135 | color: #aaaaaa; 136 | } 137 | 138 | body.vscode-dark svg line, svg path { 139 | stroke: #ababab; 140 | } 141 | 142 | body.vscode-dark svg .signal line, body.vscode-dark svg .signal path, 143 | body.vscode-dark svg .title rect, body.vscode-dark svg .title path, 144 | body.vscode-dark svg .actor rect, body.vscode-dark svg .actor path, 145 | body.vscode-dark svg .note rect, body.vscode-dark svg .note path { 146 | fill: none; 147 | stroke: #ababab; 148 | } 149 | 150 | body.vscode-dark svg .title text, 151 | body.vscode-dark svg .signal text, 152 | body.vscode-dark svg .note text, 153 | body.vscode-dark svg .actor text { 154 | fill: #dedede; 155 | }`; 156 | 157 | return ` 158 | 159 | 160 | 161 | 162 |
163 |
164 | 165 | 166 |
167 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | `; 177 | } 178 | 179 | private assetPath(resourcePath) { 180 | return this.currentPanel.webview.asWebviewUri( 181 | vscode.Uri.file( 182 | path.join(this.extensionPath, 'dist', resourcePath) 183 | ) 184 | ) 185 | } 186 | } -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/webfont.js: -------------------------------------------------------------------------------- 1 | /* Web Font Loader v1.6.6 - (c) Adobe Systems, Google. License: Apache 2.0 */ 2 | (function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return K}I.prototype.start=function(){this.s.serif=this.B.j.offsetWidth;this.s["sans-serif"]=this.C.j.offsetWidth;this.ea=p();M(this)};function N(a,b,c){for(var d in J)if(J.hasOwnProperty(d)&&b===a.s[J[d]]&&c===a.s[J[d]])return!0;return!1} 9 | function M(a){var b=a.v.j.offsetWidth,c=a.w.j.offsetWidth,d;(d=b===a.s.serif&&c===a.s["sans-serif"])||(d=L()&&N(a,b,c));d?p()-a.ea>=a.M?L()&&N(a,b,c)&&(null===a.T||a.T.hasOwnProperty(a.g.getName()))?O(a,a.O):O(a,a.ba):ha(a):O(a,a.O)}function ha(a){setTimeout(n(function(){M(this)},a),50)}function O(a,b){setTimeout(n(function(){this.v.remove();this.w.remove();this.B.remove();this.C.remove();b(this.g)},a),0)};function P(a,b,c){this.a=a;this.o=b;this.K=0;this.X=this.S=!1;this.M=c}P.prototype.$=function(a){var b=this.o;b.u&&t(b.h,[b.e.d(b.f,a.getName(),B(a).toString(),"active")],[b.e.d(b.f,a.getName(),B(a).toString(),"loading"),b.e.d(b.f,a.getName(),B(a).toString(),"inactive")]);C(b,"fontactive",a);this.X=!0;Q(this)}; 10 | P.prototype.aa=function(a){var b=this.o;if(b.u){var c=u(b.h,b.e.d(b.f,a.getName(),B(a).toString(),"active")),d=[],f=[b.e.d(b.f,a.getName(),B(a).toString(),"loading")];c||d.push(b.e.d(b.f,a.getName(),B(a).toString(),"inactive"));t(b.h,d,f)}C(b,"fontinactive",a);Q(this)};function Q(a){0==--a.K&&a.S&&(a.X?(a=a.o,a.u&&t(a.h,[a.e.d(a.f,"active")],[a.e.d(a.f,"loading"),a.e.d(a.f,"inactive")]),C(a,"active")):D(a.o))};function R(a){this.D=a;this.p=new fa;this.U=0;this.P=this.Q=!0}R.prototype.load=function(a){this.a=new r(this.D,a.context||this.D);this.Q=!1!==a.events;this.P=!1!==a.classes;ia(this,new da(this.a,a),a)}; 11 | function ja(a,b,c,d,f){var e=0==--a.U;(a.P||a.Q)&&setTimeout(function(){var a=f||null,l=d||null||{};if(0===c.length&&e)D(b.o);else{b.K+=c.length;e&&(b.S=e);var h,k=[];for(h=0;h=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); 6 | //# sourceMappingURL=underscore-min.map -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/sequence-diagram-snap-min.js: -------------------------------------------------------------------------------- 1 | /** js sequence diagrams 2.0.1 2 | * https://bramp.github.io/js-sequence-diagrams/ 3 | * (c) 2012-2017 Andrew Brampton (bramp.net) 4 | * @license Simplified BSD license. 5 | */ 6 | !function(){"use strict";function Diagram(){this.title=void 0,this.actors=[],this.signals=[]}function ParseError(message,hash){_.extend(this,hash),this.name="ParseError",this.message=message||""}function AssertException(message){this.message=message}function assert(exp,message){if(!exp)throw new AssertException(message)}function registerTheme(name,theme){Diagram.themes[name]=theme}function getCenterX(box){return box.x+box.width/2}function getCenterY(box){return box.y+box.height/2}function clamp(x,min,max){return xmax?max:x}function wobble(x1,y1,x2,y2){assert(_.all([x1,x2,y1,y2],_.isFinite),"x1,x2,y1,y2 must be numeric");var factor=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/25,r1=clamp(Math.random(),.2,.8),r2=clamp(Math.random(),.2,.8),xfactor=Math.random()>.5?factor:-factor,yfactor=Math.random()>.5?factor:-factor,p1={x:(x2-x1)*r1+x1+xfactor,y:(y2-y1)*r1+y1+yfactor},p2={x:(x2-x1)*r2+x1-xfactor,y:(y2-y1)*r2+y1-yfactor};return"C"+p1.x.toFixed(1)+","+p1.y.toFixed(1)+" "+p2.x.toFixed(1)+","+p2.y.toFixed(1)+" "+x2.toFixed(1)+","+y2.toFixed(1)}function handRect(x,y,w,h){return assert(_.all([x,y,w,h],_.isFinite),"x, y, w, h must be numeric"),"M"+x+","+y+wobble(x,y,x+w,y)+wobble(x+w,y,x+w,y+h)+wobble(x+w,y+h,x,y+h)+wobble(x,y+h,x,y)}function handLine(x1,y1,x2,y2){return assert(_.all([x1,x2,y1,y2],_.isFinite),"x1,x2,y1,y2 must be numeric"),"M"+x1.toFixed(1)+","+y1.toFixed(1)+wobble(x1,y1,x2,y2)}Diagram.prototype.getActor=function(alias,name){alias=alias.trim();var i,actors=this.actors;for(i in actors)if(actors[i].alias==alias)return actors[i];return i=actors.push(new Diagram.Actor(alias,name||alias,actors.length)),actors[i-1]},Diagram.prototype.getActorWithAlias=function(input){input=input.trim();var alias,name,s=/([\s\S]+) as (\S+)$/im.exec(input);return s?(name=s[1].trim(),alias=s[2].trim()):name=alias=input,this.getActor(alias,name)},Diagram.prototype.setTitle=function(title){this.title=title},Diagram.prototype.addSignal=function(signal){this.signals.push(signal)},Diagram.Actor=function(alias,name,index){this.alias=alias,this.name=name,this.index=index},Diagram.Signal=function(actorA,signaltype,actorB,message){this.type="Signal",this.actorA=actorA,this.actorB=actorB,this.linetype=3&signaltype,this.arrowtype=signaltype>>2&3,this.message=message},Diagram.Signal.prototype.isSelf=function(){return this.actorA.index==this.actorB.index},Diagram.Note=function(actor,placement,message){if(this.type="Note",this.actor=actor,this.placement=placement,this.message=message,this.hasManyActors()&&actor[0]==actor[1])throw new Error("Note should be over two different actors")},Diagram.Note.prototype.hasManyActors=function(){return _.isArray(this.actor)},Diagram.unescape=function(s){return s.trim().replace(/^"(.*)"$/m,"$1").replace(/\\n/gm,"\n")},Diagram.LINETYPE={SOLID:0,DOTTED:1},Diagram.ARROWTYPE={FILLED:0,OPEN:1},Diagram.PLACEMENT={LEFTOF:0,RIGHTOF:1,OVER:2},"function"!=typeof Object.getPrototypeOf&&("object"==typeof"test".__proto__?Object.getPrototypeOf=function(object){return object.__proto__}:Object.getPrototypeOf=function(object){return object.constructor.prototype});var parser=function(){function Parser(){this.yy={}}var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[5,8,9,13,15,24],$V1=[1,13],$V2=[1,17],$V3=[24,29,30],parser={trace:function(){},yy:{},symbols_:{error:2,start:3,document:4,EOF:5,line:6,statement:7,NL:8,participant:9,actor_alias:10,signal:11,note_statement:12,title:13,message:14,note:15,placement:16,actor:17,over:18,actor_pair:19,",":20,left_of:21,right_of:22,signaltype:23,ACTOR:24,linetype:25,arrowtype:26,LINE:27,DOTLINE:28,ARROW:29,OPENARROW:30,MESSAGE:31,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"NL",9:"participant",13:"title",15:"note",18:"over",20:",",21:"left_of",22:"right_of",24:"ACTOR",27:"LINE",28:"DOTLINE",29:"ARROW",30:"OPENARROW",31:"MESSAGE"},productions_:[0,[3,2],[4,0],[4,2],[6,1],[6,1],[7,2],[7,1],[7,1],[7,2],[12,4],[12,4],[19,1],[19,3],[16,1],[16,1],[11,4],[17,1],[10,1],[23,2],[23,1],[25,1],[25,1],[26,1],[26,1],[14,1]],performAction:function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:return yy.parser.yy;case 4:break;case 6:$$[$0];break;case 7:case 8:yy.parser.yy.addSignal($$[$0]);break;case 9:yy.parser.yy.setTitle($$[$0]);break;case 10:this.$=new Diagram.Note($$[$0-1],$$[$0-2],$$[$0]);break;case 11:this.$=new Diagram.Note($$[$0-1],Diagram.PLACEMENT.OVER,$$[$0]);break;case 12:case 20:this.$=$$[$0];break;case 13:this.$=[$$[$0-2],$$[$0]];break;case 14:this.$=Diagram.PLACEMENT.LEFTOF;break;case 15:this.$=Diagram.PLACEMENT.RIGHTOF;break;case 16:this.$=new Diagram.Signal($$[$0-3],$$[$0-2],$$[$0-1],$$[$0]);break;case 17:this.$=yy.parser.yy.getActor(Diagram.unescape($$[$0]));break;case 18:this.$=yy.parser.yy.getActorWithAlias(Diagram.unescape($$[$0]));break;case 19:this.$=$$[$0-1]|$$[$0]<<2;break;case 21:this.$=Diagram.LINETYPE.SOLID;break;case 22:this.$=Diagram.LINETYPE.DOTTED;break;case 23:this.$=Diagram.ARROWTYPE.FILLED;break;case 24:this.$=Diagram.ARROWTYPE.OPEN;break;case 25:this.$=Diagram.unescape($$[$0].substring(1))}},table:[o($V0,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],6:4,7:5,8:[1,6],9:[1,7],11:8,12:9,13:[1,10],15:[1,12],17:11,24:$V1},{1:[2,1]},o($V0,[2,3]),o($V0,[2,4]),o($V0,[2,5]),{10:14,24:[1,15]},o($V0,[2,7]),o($V0,[2,8]),{14:16,31:$V2},{23:18,25:19,27:[1,20],28:[1,21]},{16:22,18:[1,23],21:[1,24],22:[1,25]},o([20,27,28,31],[2,17]),o($V0,[2,6]),o($V0,[2,18]),o($V0,[2,9]),o($V0,[2,25]),{17:26,24:$V1},{24:[2,20],26:27,29:[1,28],30:[1,29]},o($V3,[2,21]),o($V3,[2,22]),{17:30,24:$V1},{17:32,19:31,24:$V1},{24:[2,14]},{24:[2,15]},{14:33,31:$V2},{24:[2,19]},{24:[2,23]},{24:[2,24]},{14:34,31:$V2},{14:35,31:$V2},{20:[1,36],31:[2,12]},o($V0,[2,16]),o($V0,[2,10]),o($V0,[2,11]),{17:37,24:$V1},{31:[2,13]}],defaultActions:{3:[2,1],24:[2,14],25:[2,15],27:[2,19],28:[2,23],29:[2,24],37:[2,13]},parseError:function(str,hash){if(!hash.recoverable)throw new Error(str);this.trace(str)},parse:function(input){function lex(){var token;return token=lexer.lex()||EOF,"number"!=typeof token&&(token=self.symbols_[token]||token),token}var self=this,stack=[0],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,recovering=0,TERROR=2,EOF=1,args=lstack.slice.call(arguments,1),lexer=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer,sharedState.yy.parser=this,"undefined"==typeof lexer.yylloc&&(lexer.yylloc={});var yyloc=lexer.yylloc;lstack.push(yyloc);var ranges=lexer.options&&lexer.options.ranges;"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var symbol,preErrorSymbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null!==symbol&&"undefined"!=typeof symbol||(symbol=lex()),action=table[state]&&table[state][symbol]),"undefined"==typeof action||!action.length||!action[0]){var errStr="";expected=[];for(p in table[state])this.terminals_[p]&&p>TERROR&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(symbol==EOF?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer.match,token:this.terminals_[symbol]||symbol,line:lexer.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer.yytext),lstack.push(lexer.yylloc),stack.push(action[1]),symbol=null,preErrorSymbol?(symbol=preErrorSymbol,preErrorSymbol=null):(yyleng=lexer.yyleng,yytext=lexer.yytext,yylineno=lexer.yylineno,yyloc=lexer.yylloc,recovering>0&&recovering--);break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args)),"undefined"!=typeof r)return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0}},lexer=function(){var lexer={EOF:1,parseError:function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},setInput:function(input,yy){return this.yy=yy||this.yy||{},this._input=input,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 ch=this._input[0];this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch;var lines=ch.match(/(?:\r\n?|\n).*/g);return lines?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},unput:function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=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),lines.length-1&&(this.yylineno-=lines.length-1);var r=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:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),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(n){this.unput(this.match.slice(n))},pastInput:function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},test_match:function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={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&&(backup.yylloc.range=this.yylloc.range.slice(0))),lines=match[0].match(/(?:\r\n?|\n).*/g),lines&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,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(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var token,match,tempMatch,index;this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;imatch[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(token=this.test_match(tempMatch,rules[i]),token!==!1)return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?(token=this.test_match(match,rules[index]),token!==!1&&token):""===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 r=this.next();return r?r:this.lex()},begin:function(condition){this.conditionStack.push(condition)},popState:function(){var n=this.conditionStack.length-1;return n>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(n){return n=this.conditionStack.length-1-Math.abs(n||0),n>=0?this.conditionStack[n]:"INITIAL"},pushState:function(condition){this.begin(condition)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:return 8;case 1:break;case 2:break;case 3:return 9;case 4:return 21;case 5:return 22;case 6:return 18;case 7:return 15;case 8:return 13;case 9:return 20;case 10:return 24;case 11:return 24;case 12:return 28;case 13:return 27;case 14:return 30;case 15:return 29;case 16:return 31;case 17:return 5;case 18:return"INVALID"}},rules:[/^(?:[\r\n]+)/i,/^(?:\s+)/i,/^(?:#[^\r\n]*)/i,/^(?:participant\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:,)/i,/^(?:[^\->:,\r\n"]+)/i,/^(?:"[^"]+")/i,/^(?:--)/i,/^(?:-)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:[^\r\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],inclusive:!0}}};return lexer}();return parser.lexer=lexer,Parser.prototype=parser,parser.Parser=Parser,new Parser}();"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(args){args[1]||(console.log("Usage: "+args[0]+" FILE"),process.exit(1));var source=require("fs").readFileSync(require("path").normalize(args[1]),"utf8");return exports.parser.parse(source)},"undefined"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1))),ParseError.prototype=new Error,Diagram.ParseError=ParseError,Diagram.parse=function(input){parser.yy=new Diagram,parser.yy.parseError=function(message,hash){throw new ParseError(message,hash)};var diagram=parser.parse(input);return delete diagram.parseError,diagram};var DIAGRAM_MARGIN=10,ACTOR_MARGIN=10,ACTOR_PADDING=10,SIGNAL_MARGIN=5,SIGNAL_PADDING=5,NOTE_MARGIN=10,NOTE_PADDING=5,NOTE_OVERLAP=15,TITLE_MARGIN=0,TITLE_PADDING=5,SELF_SIGNAL_WIDTH=20,PLACEMENT=Diagram.PLACEMENT,LINETYPE=Diagram.LINETYPE,ARROWTYPE=Diagram.ARROWTYPE,ALIGN_LEFT=0,ALIGN_CENTER=1;AssertException.prototype.toString=function(){return"AssertException: "+this.message},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Diagram.themes={};var BaseTheme=function(diagram,options){this.init(diagram,options)};if(_.extend(BaseTheme.prototype,{init:function(diagram,options){this.diagram=diagram,this.actorsHeight_=0,this.signalsHeight_=0,this.title_=void 0},setupPaper:function(container){},draw:function(container){this.setupPaper(container),this.layout();var titleHeight=this.title_?this.title_.height:0,y=DIAGRAM_MARGIN+titleHeight;this.drawTitle(),this.drawActors(y),this.drawSignals(y+this.actorsHeight_)},layout:function(){function actorEnsureDistance(a,b,d){assert(a=actors.length?(a=actors[a],a.paddingRight=Math.max(d,a.paddingRight)):(a=actors[a],a.distances[b]=Math.max(d,a.distances[b]?a.distances[b]:0))}var diagram=this.diagram,font=this.font_,actors=diagram.actors,signals=diagram.signals;if(diagram.width=0,diagram.height=0,diagram.title){var title=this.title_={},bb=this.textBBox(diagram.title,font);title.textBB=bb,title.message=diagram.title,title.width=bb.width+2*(TITLE_PADDING+TITLE_MARGIN),title.height=bb.height+2*(TITLE_PADDING+TITLE_MARGIN),title.x=DIAGRAM_MARGIN,title.y=DIAGRAM_MARGIN,diagram.width+=title.width,diagram.height+=title.height}_.each(actors,function(a){var bb=this.textBBox(a.name,font);a.textBB=bb,a.x=0,a.y=0,a.width=bb.width+2*(ACTOR_PADDING+ACTOR_MARGIN),a.height=bb.height+2*(ACTOR_PADDING+ACTOR_MARGIN),a.distances=[],a.paddingRight=0,this.actorsHeight_=Math.max(a.height,this.actorsHeight_)},this),_.each(signals,function(s){var a,b,bb=this.textBBox(s.message,font);s.textBB=bb,s.width=bb.width,s.height=bb.height;var extraWidth=0;if("Signal"==s.type)s.width+=2*(SIGNAL_MARGIN+SIGNAL_PADDING),s.height+=2*(SIGNAL_MARGIN+SIGNAL_PADDING),s.isSelf()?(a=s.actorA.index,b=a+1,s.width+=SELF_SIGNAL_WIDTH):(a=Math.min(s.actorA.index,s.actorB.index),b=Math.max(s.actorA.index,s.actorB.index));else{if("Note"!=s.type)throw new Error("Unhandled signal type:"+s.type);if(s.width+=2*(NOTE_MARGIN+NOTE_PADDING),s.height+=2*(NOTE_MARGIN+NOTE_PADDING),extraWidth=2*ACTOR_MARGIN,s.placement==PLACEMENT.LEFTOF)b=s.actor.index,a=b-1;else if(s.placement==PLACEMENT.RIGHTOF)a=s.actor.index,b=a+1;else if(s.placement==PLACEMENT.OVER&&s.hasManyActors())a=Math.min(s.actor[0].index,s.actor[1].index),b=Math.max(s.actor[0].index,s.actor[1].index),extraWidth=-(2*NOTE_PADDING+2*NOTE_OVERLAP);else if(s.placement==PLACEMENT.OVER)return a=s.actor.index,actorEnsureDistance(a-1,a,s.width/2),actorEnsureDistance(a,a+1,s.width/2),void(this.signalsHeight_+=s.height)}actorEnsureDistance(a,b,s.width+extraWidth),this.signalsHeight_+=s.height},this);var actorsX=0;return _.each(actors,function(a){a.x=Math.max(actorsX,a.x),_.each(a.distances,function(distance,b){"undefined"!=typeof distance&&(b=actors[b],distance=Math.max(distance,a.width/2,b.width/2),b.x=Math.max(b.x,a.x+a.width/2+distance-b.width/2))}),actorsX=a.x+a.width+a.paddingRight},this),diagram.width=Math.max(actorsX,diagram.width),diagram.width+=2*DIAGRAM_MARGIN,diagram.height+=2*DIAGRAM_MARGIN+2*this.actorsHeight_+this.signalsHeight_,this},textBBox:function(text,font){},drawTitle:function(){var title=this.title_;title&&this.drawTextBox(title,title.message,TITLE_MARGIN,TITLE_PADDING,this.font_,ALIGN_LEFT)},drawActors:function(offsetY){var y=offsetY;_.each(this.diagram.actors,function(a){this.drawActor(a,y,this.actorsHeight_),this.drawActor(a,y+this.actorsHeight_+this.signalsHeight_,this.actorsHeight_);var aX=getCenterX(a);this.drawLine(aX,y+this.actorsHeight_-ACTOR_MARGIN,aX,y+this.actorsHeight_+ACTOR_MARGIN+this.signalsHeight_)},this)},drawActor:function(actor,offsetY,height){actor.y=offsetY,actor.height=height,this.drawTextBox(actor,actor.name,ACTOR_MARGIN,ACTOR_PADDING,this.font_,ALIGN_CENTER)},drawSignals:function(offsetY){var y=offsetY;_.each(this.diagram.signals,function(s){"Signal"==s.type?s.isSelf()?this.drawSelfSignal(s,y):this.drawSignal(s,y):"Note"==s.type&&this.drawNote(s,y),y+=s.height},this)},drawSelfSignal:function(signal,offsetY){assert(signal.isSelf(),"signal must be a self signal");var textBB=signal.textBB,aX=getCenterX(signal.actorA),x=aX+SELF_SIGNAL_WIDTH+SIGNAL_PADDING,y=offsetY+SIGNAL_PADDING+signal.height/2+textBB.y;this.drawText(x,y,signal.message,this.font_,ALIGN_LEFT);var y1=offsetY+SIGNAL_MARGIN+SIGNAL_PADDING,y2=y1+signal.height-2*SIGNAL_MARGIN-SIGNAL_PADDING;this.drawLine(aX,y1,aX+SELF_SIGNAL_WIDTH,y1,signal.linetype),this.drawLine(aX+SELF_SIGNAL_WIDTH,y1,aX+SELF_SIGNAL_WIDTH,y2,signal.linetype),this.drawLine(aX+SELF_SIGNAL_WIDTH,y2,aX,y2,signal.linetype,signal.arrowtype)},drawSignal:function(signal,offsetY){var aX=getCenterX(signal.actorA),bX=getCenterX(signal.actorB),x=(bX-aX)/2+aX,y=offsetY+SIGNAL_MARGIN+2*SIGNAL_PADDING;this.drawText(x,y,signal.message,this.font_,ALIGN_CENTER),y=offsetY+signal.height-SIGNAL_MARGIN-SIGNAL_PADDING,this.drawLine(aX,y,bX,y,signal.linetype,signal.arrowtype)},drawNote:function(note,offsetY){note.y=offsetY;var actorA=note.hasManyActors()?note.actor[0]:note.actor,aX=getCenterX(actorA);switch(note.placement){case PLACEMENT.RIGHTOF:note.x=aX+ACTOR_MARGIN;break;case PLACEMENT.LEFTOF:note.x=aX-ACTOR_MARGIN-note.width;break;case PLACEMENT.OVER:if(note.hasManyActors()){var bX=getCenterX(note.actor[1]),overlap=NOTE_OVERLAP+NOTE_PADDING;note.x=Math.min(aX,bX)-overlap,note.width=Math.max(aX,bX)+overlap-note.x}else note.x=aX-note.width/2;break;default:throw new Error("Unhandled note placement: "+note.placement)}return this.drawTextBox(note,note.message,NOTE_MARGIN,NOTE_PADDING,this.font_,ALIGN_LEFT)},drawTextBox:function(box,text,margin,padding,font,align){var x=box.x+margin,y=box.y+margin,w=box.width-2*margin,h=box.height-2*margin;return this.drawRect(x,y,w,h),align==ALIGN_CENTER?(x=getCenterX(box),y=getCenterY(box)):(x+=padding,y+=padding),this.drawText(x,y,text,font,align)}}),"undefined"!=typeof Snap){var xmlns="http://www.w3.org/2000/svg",LINE={stroke:"#000000","stroke-width":2,fill:"none"},RECT={stroke:"#000000","stroke-width":2,fill:"#fff"},LOADED_FONTS={},SnapTheme=function(diagram,options,resume){_.defaults(options,{"css-class":"simple","font-size":16,"font-family":"Andale Mono, monospace"}),this.init(diagram,options,resume)};_.extend(SnapTheme.prototype,BaseTheme.prototype,{init:function(diagram,options,resume){BaseTheme.prototype.init.call(this,diagram),this.paper_=void 0,this.cssClass_=options["css-class"]||void 0,this.font_={"font-size":options["font-size"],"font-family":options["font-family"]};var a=this.arrowTypes_={};a[ARROWTYPE.FILLED]="Block",a[ARROWTYPE.OPEN]="Open";var l=this.lineTypes_={};l[LINETYPE.SOLID]="",l[LINETYPE.DOTTED]="6,2";var that=this;this.waitForFont(function(){resume(that)})},waitForFont:function(callback){var fontFamily=this.font_["font-family"];if("undefined"==typeof WebFont)throw new Error("WebFont is required (https://github.com/typekit/webfontloader).");return LOADED_FONTS[fontFamily]?void callback():void WebFont.load({custom:{families:[fontFamily]},classes:!1,active:function(){LOADED_FONTS[fontFamily]=!0,callback()},inactive:function(){LOADED_FONTS[fontFamily]=!0,callback()}})},addDescription:function(svg,description){var desc=document.createElementNS(xmlns,"desc");desc.appendChild(document.createTextNode(description)),svg.appendChild(desc)},setupPaper:function(container){var svg=document.createElementNS(xmlns,"svg");container.appendChild(svg),this.addDescription(svg,this.diagram.title||""),this.paper_=Snap(svg),this.paper_.addClass("sequence"),this.cssClass_&&this.paper_.addClass(this.cssClass_),this.beginGroup();var a=this.arrowMarkers_={},arrow=this.paper_.path("M 0 0 L 5 2.5 L 0 5 z");a[ARROWTYPE.FILLED]=arrow.marker(0,0,5,5,5,2.5).attr({id:"markerArrowBlock"}),arrow=this.paper_.path("M 9.6,8 1.92,16 0,13.7 5.76,8 0,2.286 1.92,0 9.6,8 z"),a[ARROWTYPE.OPEN]=arrow.marker(0,0,9.6,16,9.6,8).attr({markerWidth:"4",id:"markerArrowOpen"})},layout:function(){BaseTheme.prototype.layout.call(this),this.paper_.attr({width:this.diagram.width+"px",height:this.diagram.height+"px"})},textBBox:function(text,font){var t=this.createText(text,font),bb=t.getBBox();return t.remove(),bb},pushToStack:function(element){return this._stack.push(element),element},beginGroup:function(){this._stack=[]},finishGroup:function(){var g=this.paper_.group.apply(this.paper_,this._stack);return this.beginGroup(),g},createText:function(text,font){text=_.invoke(text.split("\n"),"trim");var t=this.paper_.text(0,0,text);return t.attr(font||{}),text.length>1&&t.selectAll("tspan:nth-child(n+2)").attr({dy:"1.2em",x:0}),t},drawLine:function(x1,y1,x2,y2,linetype,arrowhead){var line=this.paper_.line(x1,y1,x2,y2).attr(LINE);return void 0!==linetype&&line.attr("strokeDasharray",this.lineTypes_[linetype]),void 0!==arrowhead&&line.attr("markerEnd",this.arrowMarkers_[arrowhead]),this.pushToStack(line)},drawRect:function(x,y,w,h){var rect=this.paper_.rect(x,y,w,h).attr(RECT);return this.pushToStack(rect)},drawText:function(x,y,text,font,align){var t=this.createText(text,font),bb=t.getBBox();return align==ALIGN_CENTER&&(x-=bb.width/2,y-=bb.height/2),t.attr({x:x-bb.x,y:y-bb.y}),t.selectAll("tspan").attr({x:x}),this.pushToStack(t),t},drawTitle:function(){return this.beginGroup(),BaseTheme.prototype.drawTitle.call(this),this.finishGroup().addClass("title")},drawActor:function(actor,offsetY,height){return this.beginGroup(),BaseTheme.prototype.drawActor.call(this,actor,offsetY,height),this.finishGroup().addClass("actor")},drawSignal:function(signal,offsetY){return this.beginGroup(),BaseTheme.prototype.drawSignal.call(this,signal,offsetY),this.finishGroup().addClass("signal")},drawSelfSignal:function(signal,offsetY){return this.beginGroup(),BaseTheme.prototype.drawSelfSignal.call(this,signal,offsetY),this.finishGroup().addClass("signal")},drawNote:function(note,offsetY){return this.beginGroup(),BaseTheme.prototype.drawNote.call(this,note,offsetY),this.finishGroup().addClass("note")}});var SnapHandTheme=function(diagram,options,resume){_.defaults(options,{"css-class":"hand","font-size":16,"font-family":"danielbd"}),this.init(diagram,options,resume)};_.extend(SnapHandTheme.prototype,SnapTheme.prototype,{drawLine:function(x1,y1,x2,y2,linetype,arrowhead){var line=this.paper_.path(handLine(x1,y1,x2,y2)).attr(LINE);return void 0!==linetype&&line.attr("strokeDasharray",this.lineTypes_[linetype]),void 0!==arrowhead&&line.attr("markerEnd",this.arrowMarkers_[arrowhead]),this.pushToStack(line)},drawRect:function(x,y,w,h){var rect=this.paper_.path(handRect(x,y,w,h)).attr(RECT);return this.pushToStack(rect)}}),registerTheme("snapSimple",SnapTheme),registerTheme("snapHand",SnapHandTheme)}if("undefined"==typeof Raphael&&"undefined"==typeof Snap)throw new Error("Raphael or Snap.svg is required to be included.");if(_.isEmpty(Diagram.themes))throw new Error("No themes were registered. Please call registerTheme(...).");Diagram.themes.hand=Diagram.themes.snapHand||Diagram.themes.raphaelHand,Diagram.themes.simple=Diagram.themes.snapSimple||Diagram.themes.raphaelSimple,Diagram.prototype.drawSVG=function(container,options){var defaultOptions={theme:"hand"};if(options=_.defaults(options||{},defaultOptions),!(options.theme in Diagram.themes))throw new Error("Unsupported theme: "+options.theme);var div=_.isString(container)?document.getElementById(container):container;if(null===div||!div.tagName)throw new Error("Invalid container: "+container);var Theme=Diagram.themes[options.theme];new Theme(this,options,function(drawing){drawing.draw(div)})},"undefined"!=typeof jQuery&&!function($){$.fn.sequenceDiagram=function(options){return this.each(function(){var $this=$(this),diagram=Diagram.parse($this.text());$this.html(""),diagram.drawSVG(this,options)})}}(jQuery);var root="object"==typeof self&&self.self==self&&self||"object"==typeof global&&global.global==global&&global;"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=Diagram),exports.Diagram=Diagram):root.Diagram=Diagram}(); 7 | //# sourceMappingURL=sequence-diagram-snap.js -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/sequence-diagram-snap.js: -------------------------------------------------------------------------------- 1 | /** js sequence diagrams 2.0.1 2 | * https://bramp.github.io/js-sequence-diagrams/ 3 | * (c) 2012-2017 Andrew Brampton (bramp.net) 4 | * @license Simplified BSD license. 5 | */ 6 | (function() { 7 | 'use strict'; 8 | /*global Diagram */ 9 | 10 | // The following are included by preprocessor */ 11 | /** js sequence diagrams 12 | * https://bramp.github.io/js-sequence-diagrams/ 13 | * (c) 2012-2017 Andrew Brampton (bramp.net) 14 | * Simplified BSD license. 15 | */ 16 | /*global grammar _ */ 17 | 18 | function Diagram() { 19 | this.title = undefined; 20 | this.actors = []; 21 | this.signals = []; 22 | } 23 | /* 24 | * Return an existing actor with this alias, or creates a new one with alias and name. 25 | */ 26 | Diagram.prototype.getActor = function(alias, name) { 27 | alias = alias.trim(); 28 | 29 | var i; 30 | var actors = this.actors; 31 | for (i in actors) { 32 | if (actors[i].alias == alias) { 33 | return actors[i]; 34 | } 35 | } 36 | i = actors.push(new Diagram.Actor(alias, (name || alias), actors.length)); 37 | return actors[ i - 1 ]; 38 | }; 39 | 40 | /* 41 | * Parses the input as either a alias, or a "name as alias", and returns the corresponding actor. 42 | */ 43 | Diagram.prototype.getActorWithAlias = function(input) { 44 | input = input.trim(); 45 | 46 | // We are lazy and do some of the parsing in javascript :(. TODO move into the .jison file. 47 | var s = /([\s\S]+) as (\S+)$/im.exec(input); 48 | var alias; 49 | var name; 50 | if (s) { 51 | name = s[1].trim(); 52 | alias = s[2].trim(); 53 | } else { 54 | name = alias = input; 55 | } 56 | return this.getActor(alias, name); 57 | }; 58 | 59 | Diagram.prototype.setTitle = function(title) { 60 | this.title = title; 61 | }; 62 | 63 | Diagram.prototype.addSignal = function(signal) { 64 | this.signals.push(signal); 65 | }; 66 | 67 | Diagram.Actor = function(alias, name, index) { 68 | this.alias = alias; 69 | this.name = name; 70 | this.index = index; 71 | }; 72 | 73 | Diagram.Signal = function(actorA, signaltype, actorB, message) { 74 | this.type = 'Signal'; 75 | this.actorA = actorA; 76 | this.actorB = actorB; 77 | this.linetype = signaltype & 3; 78 | this.arrowtype = (signaltype >> 2) & 3; 79 | this.message = message; 80 | }; 81 | 82 | Diagram.Signal.prototype.isSelf = function() { 83 | return this.actorA.index == this.actorB.index; 84 | }; 85 | 86 | Diagram.Note = function(actor, placement, message) { 87 | this.type = 'Note'; 88 | this.actor = actor; 89 | this.placement = placement; 90 | this.message = message; 91 | 92 | if (this.hasManyActors() && actor[0] == actor[1]) { 93 | throw new Error('Note should be over two different actors'); 94 | } 95 | }; 96 | 97 | Diagram.Note.prototype.hasManyActors = function() { 98 | return _.isArray(this.actor); 99 | }; 100 | 101 | Diagram.unescape = function(s) { 102 | // Turn "\\n" into "\n" 103 | return s.trim().replace(/^"(.*)"$/m, '$1').replace(/\\n/gm, '\n'); 104 | }; 105 | 106 | Diagram.LINETYPE = { 107 | SOLID: 0, 108 | DOTTED: 1 109 | }; 110 | 111 | Diagram.ARROWTYPE = { 112 | FILLED: 0, 113 | OPEN: 1 114 | }; 115 | 116 | Diagram.PLACEMENT = { 117 | LEFTOF: 0, 118 | RIGHTOF: 1, 119 | OVER: 2 120 | }; 121 | 122 | // Some older browsers don't have getPrototypeOf, thus we polyfill it 123 | // https://github.com/bramp/js-sequence-diagrams/issues/57 124 | // https://github.com/zaach/jison/issues/194 125 | // Taken from http://ejohn.org/blog/objectgetprototypeof/ 126 | if (typeof Object.getPrototypeOf !== 'function') { 127 | /* jshint -W103 */ 128 | if (typeof 'test'.__proto__ === 'object') { 129 | Object.getPrototypeOf = function(object) { 130 | return object.__proto__; 131 | }; 132 | } else { 133 | Object.getPrototypeOf = function(object) { 134 | // May break if the constructor has been tampered with 135 | return object.constructor.prototype; 136 | }; 137 | } 138 | /* jshint +W103 */ 139 | } 140 | 141 | /** The following is included by preprocessor */ 142 | /* parser generated by jison 0.4.15 */ 143 | /* 144 | Returns a Parser object of the following structure: 145 | 146 | Parser: { 147 | yy: {} 148 | } 149 | 150 | Parser.prototype: { 151 | yy: {}, 152 | trace: function(), 153 | symbols_: {associative list: name ==> number}, 154 | terminals_: {associative list: number ==> name}, 155 | productions_: [...], 156 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), 157 | table: [...], 158 | defaultActions: {...}, 159 | parseError: function(str, hash), 160 | parse: function(input), 161 | 162 | lexer: { 163 | EOF: 1, 164 | parseError: function(str, hash), 165 | setInput: function(input), 166 | input: function(), 167 | unput: function(str), 168 | more: function(), 169 | less: function(n), 170 | pastInput: function(), 171 | upcomingInput: function(), 172 | showPosition: function(), 173 | test_match: function(regex_match_array, rule_index), 174 | next: function(), 175 | lex: function(), 176 | begin: function(condition), 177 | popState: function(), 178 | _currentRules: function(), 179 | topState: function(), 180 | pushState: function(condition), 181 | 182 | options: { 183 | ranges: boolean (optional: true ==> token location info will include a .range[] member) 184 | flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) 185 | backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) 186 | }, 187 | 188 | performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), 189 | rules: [...], 190 | conditions: {associative list: name ==> set}, 191 | } 192 | } 193 | 194 | 195 | token location info (@$, _$, etc.): { 196 | first_line: n, 197 | last_line: n, 198 | first_column: n, 199 | last_column: n, 200 | range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) 201 | } 202 | 203 | 204 | the parseError function receives a 'hash' object with these members for lexer and parser errors: { 205 | text: (matched text) 206 | token: (the produced terminal token, if any) 207 | line: (yylineno) 208 | } 209 | while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { 210 | loc: (yylloc) 211 | expected: (string describing the set of expected tokens) 212 | recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) 213 | } 214 | */ 215 | var parser = function() { 216 | function Parser() { 217 | this.yy = {}; 218 | } 219 | var o = function(k, v, o, l) { 220 | for (o = o || {}, l = k.length; l--; o[k[l]] = v) ; 221 | return o; 222 | }, $V0 = [ 5, 8, 9, 13, 15, 24 ], $V1 = [ 1, 13 ], $V2 = [ 1, 17 ], $V3 = [ 24, 29, 30 ], parser = { 223 | trace: function() {}, 224 | yy: {}, 225 | symbols_: { 226 | error: 2, 227 | start: 3, 228 | document: 4, 229 | EOF: 5, 230 | line: 6, 231 | statement: 7, 232 | NL: 8, 233 | participant: 9, 234 | actor_alias: 10, 235 | signal: 11, 236 | note_statement: 12, 237 | title: 13, 238 | message: 14, 239 | note: 15, 240 | placement: 16, 241 | actor: 17, 242 | over: 18, 243 | actor_pair: 19, 244 | ",": 20, 245 | left_of: 21, 246 | right_of: 22, 247 | signaltype: 23, 248 | ACTOR: 24, 249 | linetype: 25, 250 | arrowtype: 26, 251 | LINE: 27, 252 | DOTLINE: 28, 253 | ARROW: 29, 254 | OPENARROW: 30, 255 | MESSAGE: 31, 256 | $accept: 0, 257 | $end: 1 258 | }, 259 | terminals_: { 260 | 2: "error", 261 | 5: "EOF", 262 | 8: "NL", 263 | 9: "participant", 264 | 13: "title", 265 | 15: "note", 266 | 18: "over", 267 | 20: ",", 268 | 21: "left_of", 269 | 22: "right_of", 270 | 24: "ACTOR", 271 | 27: "LINE", 272 | 28: "DOTLINE", 273 | 29: "ARROW", 274 | 30: "OPENARROW", 275 | 31: "MESSAGE" 276 | }, 277 | productions_: [ 0, [ 3, 2 ], [ 4, 0 ], [ 4, 2 ], [ 6, 1 ], [ 6, 1 ], [ 7, 2 ], [ 7, 1 ], [ 7, 1 ], [ 7, 2 ], [ 12, 4 ], [ 12, 4 ], [ 19, 1 ], [ 19, 3 ], [ 16, 1 ], [ 16, 1 ], [ 11, 4 ], [ 17, 1 ], [ 10, 1 ], [ 23, 2 ], [ 23, 1 ], [ 25, 1 ], [ 25, 1 ], [ 26, 1 ], [ 26, 1 ], [ 14, 1 ] ], 278 | performAction: function(yytext, yyleng, yylineno, yy, yystate, $$, _$) { 279 | /* this == yyval */ 280 | var $0 = $$.length - 1; 281 | switch (yystate) { 282 | case 1: 283 | return yy.parser.yy; 284 | 285 | case 4: 286 | break; 287 | 288 | case 6: 289 | $$[$0]; 290 | break; 291 | 292 | case 7: 293 | case 8: 294 | yy.parser.yy.addSignal($$[$0]); 295 | break; 296 | 297 | case 9: 298 | yy.parser.yy.setTitle($$[$0]); 299 | break; 300 | 301 | case 10: 302 | this.$ = new Diagram.Note($$[$0 - 1], $$[$0 - 2], $$[$0]); 303 | break; 304 | 305 | case 11: 306 | this.$ = new Diagram.Note($$[$0 - 1], Diagram.PLACEMENT.OVER, $$[$0]); 307 | break; 308 | 309 | case 12: 310 | case 20: 311 | this.$ = $$[$0]; 312 | break; 313 | 314 | case 13: 315 | this.$ = [ $$[$0 - 2], $$[$0] ]; 316 | break; 317 | 318 | case 14: 319 | this.$ = Diagram.PLACEMENT.LEFTOF; 320 | break; 321 | 322 | case 15: 323 | this.$ = Diagram.PLACEMENT.RIGHTOF; 324 | break; 325 | 326 | case 16: 327 | this.$ = new Diagram.Signal($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0]); 328 | break; 329 | 330 | case 17: 331 | this.$ = yy.parser.yy.getActor(Diagram.unescape($$[$0])); 332 | break; 333 | 334 | case 18: 335 | this.$ = yy.parser.yy.getActorWithAlias(Diagram.unescape($$[$0])); 336 | break; 337 | 338 | case 19: 339 | this.$ = $$[$0 - 1] | $$[$0] << 2; 340 | break; 341 | 342 | case 21: 343 | this.$ = Diagram.LINETYPE.SOLID; 344 | break; 345 | 346 | case 22: 347 | this.$ = Diagram.LINETYPE.DOTTED; 348 | break; 349 | 350 | case 23: 351 | this.$ = Diagram.ARROWTYPE.FILLED; 352 | break; 353 | 354 | case 24: 355 | this.$ = Diagram.ARROWTYPE.OPEN; 356 | break; 357 | 358 | case 25: 359 | this.$ = Diagram.unescape($$[$0].substring(1)); 360 | } 361 | }, 362 | table: [ o($V0, [ 2, 2 ], { 363 | 3: 1, 364 | 4: 2 365 | }), { 366 | 1: [ 3 ] 367 | }, { 368 | 5: [ 1, 3 ], 369 | 6: 4, 370 | 7: 5, 371 | 8: [ 1, 6 ], 372 | 9: [ 1, 7 ], 373 | 11: 8, 374 | 12: 9, 375 | 13: [ 1, 10 ], 376 | 15: [ 1, 12 ], 377 | 17: 11, 378 | 24: $V1 379 | }, { 380 | 1: [ 2, 1 ] 381 | }, o($V0, [ 2, 3 ]), o($V0, [ 2, 4 ]), o($V0, [ 2, 5 ]), { 382 | 10: 14, 383 | 24: [ 1, 15 ] 384 | }, o($V0, [ 2, 7 ]), o($V0, [ 2, 8 ]), { 385 | 14: 16, 386 | 31: $V2 387 | }, { 388 | 23: 18, 389 | 25: 19, 390 | 27: [ 1, 20 ], 391 | 28: [ 1, 21 ] 392 | }, { 393 | 16: 22, 394 | 18: [ 1, 23 ], 395 | 21: [ 1, 24 ], 396 | 22: [ 1, 25 ] 397 | }, o([ 20, 27, 28, 31 ], [ 2, 17 ]), o($V0, [ 2, 6 ]), o($V0, [ 2, 18 ]), o($V0, [ 2, 9 ]), o($V0, [ 2, 25 ]), { 398 | 17: 26, 399 | 24: $V1 400 | }, { 401 | 24: [ 2, 20 ], 402 | 26: 27, 403 | 29: [ 1, 28 ], 404 | 30: [ 1, 29 ] 405 | }, o($V3, [ 2, 21 ]), o($V3, [ 2, 22 ]), { 406 | 17: 30, 407 | 24: $V1 408 | }, { 409 | 17: 32, 410 | 19: 31, 411 | 24: $V1 412 | }, { 413 | 24: [ 2, 14 ] 414 | }, { 415 | 24: [ 2, 15 ] 416 | }, { 417 | 14: 33, 418 | 31: $V2 419 | }, { 420 | 24: [ 2, 19 ] 421 | }, { 422 | 24: [ 2, 23 ] 423 | }, { 424 | 24: [ 2, 24 ] 425 | }, { 426 | 14: 34, 427 | 31: $V2 428 | }, { 429 | 14: 35, 430 | 31: $V2 431 | }, { 432 | 20: [ 1, 36 ], 433 | 31: [ 2, 12 ] 434 | }, o($V0, [ 2, 16 ]), o($V0, [ 2, 10 ]), o($V0, [ 2, 11 ]), { 435 | 17: 37, 436 | 24: $V1 437 | }, { 438 | 31: [ 2, 13 ] 439 | } ], 440 | defaultActions: { 441 | 3: [ 2, 1 ], 442 | 24: [ 2, 14 ], 443 | 25: [ 2, 15 ], 444 | 27: [ 2, 19 ], 445 | 28: [ 2, 23 ], 446 | 29: [ 2, 24 ], 447 | 37: [ 2, 13 ] 448 | }, 449 | parseError: function(str, hash) { 450 | if (!hash.recoverable) throw new Error(str); 451 | this.trace(str); 452 | }, 453 | parse: function(input) { 454 | function lex() { 455 | var token; 456 | return token = lexer.lex() || EOF, "number" != typeof token && (token = self.symbols_[token] || token), 457 | token; 458 | } 459 | var self = this, stack = [ 0 ], vstack = [ null ], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1, args = lstack.slice.call(arguments, 1), lexer = Object.create(this.lexer), sharedState = { 460 | yy: {} 461 | }; 462 | for (var k in this.yy) Object.prototype.hasOwnProperty.call(this.yy, k) && (sharedState.yy[k] = this.yy[k]); 463 | lexer.setInput(input, sharedState.yy), sharedState.yy.lexer = lexer, sharedState.yy.parser = this, 464 | "undefined" == typeof lexer.yylloc && (lexer.yylloc = {}); 465 | var yyloc = lexer.yylloc; 466 | lstack.push(yyloc); 467 | var ranges = lexer.options && lexer.options.ranges; 468 | "function" == typeof sharedState.yy.parseError ? this.parseError = sharedState.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError; 469 | for (var symbol, preErrorSymbol, state, action, r, p, len, newState, expected, yyval = {}; ;) { 470 | if (state = stack[stack.length - 1], this.defaultActions[state] ? action = this.defaultActions[state] : (null !== symbol && "undefined" != typeof symbol || (symbol = lex()), 471 | action = table[state] && table[state][symbol]), "undefined" == typeof action || !action.length || !action[0]) { 472 | var errStr = ""; 473 | expected = []; 474 | for (p in table[state]) this.terminals_[p] && p > TERROR && expected.push("'" + this.terminals_[p] + "'"); 475 | errStr = lexer.showPosition ? "Parse error on line " + (yylineno + 1) + ":\n" + lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'" : "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"), 476 | this.parseError(errStr, { 477 | text: lexer.match, 478 | token: this.terminals_[symbol] || symbol, 479 | line: lexer.yylineno, 480 | loc: yyloc, 481 | expected: expected 482 | }); 483 | } 484 | if (action[0] instanceof Array && action.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); 485 | switch (action[0]) { 486 | case 1: 487 | stack.push(symbol), vstack.push(lexer.yytext), lstack.push(lexer.yylloc), stack.push(action[1]), 488 | symbol = null, preErrorSymbol ? (symbol = preErrorSymbol, preErrorSymbol = null) : (yyleng = lexer.yyleng, 489 | yytext = lexer.yytext, yylineno = lexer.yylineno, yyloc = lexer.yylloc, recovering > 0 && recovering--); 490 | break; 491 | 492 | case 2: 493 | if (len = this.productions_[action[1]][1], yyval.$ = vstack[vstack.length - len], 494 | yyval._$ = { 495 | first_line: lstack[lstack.length - (len || 1)].first_line, 496 | last_line: lstack[lstack.length - 1].last_line, 497 | first_column: lstack[lstack.length - (len || 1)].first_column, 498 | last_column: lstack[lstack.length - 1].last_column 499 | }, ranges && (yyval._$.range = [ lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1] ]), 500 | r = this.performAction.apply(yyval, [ yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack ].concat(args)), 501 | "undefined" != typeof r) return r; 502 | len && (stack = stack.slice(0, -1 * len * 2), vstack = vstack.slice(0, -1 * len), 503 | lstack = lstack.slice(0, -1 * len)), stack.push(this.productions_[action[1]][0]), 504 | vstack.push(yyval.$), lstack.push(yyval._$), newState = table[stack[stack.length - 2]][stack[stack.length - 1]], 505 | stack.push(newState); 506 | break; 507 | 508 | case 3: 509 | return !0; 510 | } 511 | } 512 | return !0; 513 | } 514 | }, lexer = function() { 515 | var lexer = { 516 | EOF: 1, 517 | parseError: function(str, hash) { 518 | if (!this.yy.parser) throw new Error(str); 519 | this.yy.parser.parseError(str, hash); 520 | }, 521 | // resets the lexer, sets new input 522 | setInput: function(input, yy) { 523 | return this.yy = yy || this.yy || {}, this._input = input, this._more = this._backtrack = this.done = !1, 524 | this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = [ "INITIAL" ], 525 | this.yylloc = { 526 | first_line: 1, 527 | first_column: 0, 528 | last_line: 1, 529 | last_column: 0 530 | }, this.options.ranges && (this.yylloc.range = [ 0, 0 ]), this.offset = 0, this; 531 | }, 532 | // consumes and returns one char from the input 533 | input: function() { 534 | var ch = this._input[0]; 535 | this.yytext += ch, this.yyleng++, this.offset++, this.match += ch, this.matched += ch; 536 | var lines = ch.match(/(?:\r\n?|\n).*/g); 537 | return lines ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, 538 | this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), 539 | ch; 540 | }, 541 | // unshifts one char (or a string) into the input 542 | unput: function(ch) { 543 | var len = ch.length, lines = ch.split(/(?:\r\n?|\n)/g); 544 | this._input = ch + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - len), 545 | //this.yyleng -= len; 546 | this.offset -= len; 547 | var oldLines = this.match.split(/(?:\r\n?|\n)/g); 548 | this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), 549 | lines.length - 1 && (this.yylineno -= lines.length - 1); 550 | var r = this.yylloc.range; 551 | return this.yylloc = { 552 | first_line: this.yylloc.first_line, 553 | last_line: this.yylineno + 1, 554 | first_column: this.yylloc.first_column, 555 | last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len 556 | }, this.options.ranges && (this.yylloc.range = [ r[0], r[0] + this.yyleng - len ]), 557 | this.yyleng = this.yytext.length, this; 558 | }, 559 | // When called from action, caches matched text and appends it on next action 560 | more: function() { 561 | return this._more = !0, this; 562 | }, 563 | // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. 564 | reject: function() { 565 | 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(), { 566 | text: "", 567 | token: null, 568 | line: this.yylineno 569 | }); 570 | }, 571 | // retain first n characters of the match 572 | less: function(n) { 573 | this.unput(this.match.slice(n)); 574 | }, 575 | // displays already matched input, i.e. for error messages 576 | pastInput: function() { 577 | var past = this.matched.substr(0, this.matched.length - this.match.length); 578 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); 579 | }, 580 | // displays upcoming input, i.e. for error messages 581 | upcomingInput: function() { 582 | var next = this.match; 583 | return next.length < 20 && (next += this._input.substr(0, 20 - next.length)), (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); 584 | }, 585 | // displays the character position where the lexing error occurred, i.e. for error messages 586 | showPosition: function() { 587 | var pre = this.pastInput(), c = new Array(pre.length + 1).join("-"); 588 | return pre + this.upcomingInput() + "\n" + c + "^"; 589 | }, 590 | // test the lexed token: return FALSE when not a match, otherwise return token 591 | test_match: function(match, indexed_rule) { 592 | var token, lines, backup; 593 | if (this.options.backtrack_lexer && (// save context 594 | backup = { 595 | yylineno: this.yylineno, 596 | yylloc: { 597 | first_line: this.yylloc.first_line, 598 | last_line: this.last_line, 599 | first_column: this.yylloc.first_column, 600 | last_column: this.yylloc.last_column 601 | }, 602 | yytext: this.yytext, 603 | match: this.match, 604 | matches: this.matches, 605 | matched: this.matched, 606 | yyleng: this.yyleng, 607 | offset: this.offset, 608 | _more: this._more, 609 | _input: this._input, 610 | yy: this.yy, 611 | conditionStack: this.conditionStack.slice(0), 612 | done: this.done 613 | }, this.options.ranges && (backup.yylloc.range = this.yylloc.range.slice(0))), lines = match[0].match(/(?:\r\n?|\n).*/g), 614 | lines && (this.yylineno += lines.length), this.yylloc = { 615 | first_line: this.yylloc.last_line, 616 | last_line: this.yylineno + 1, 617 | first_column: this.yylloc.last_column, 618 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length 619 | }, this.yytext += match[0], this.match += match[0], this.matches = match, this.yyleng = this.yytext.length, 620 | this.options.ranges && (this.yylloc.range = [ this.offset, this.offset += this.yyleng ]), 621 | this._more = !1, this._backtrack = !1, this._input = this._input.slice(match[0].length), 622 | this.matched += match[0], token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]), 623 | this.done && this._input && (this.done = !1), token) return token; 624 | if (this._backtrack) { 625 | // recover context 626 | for (var k in backup) this[k] = backup[k]; 627 | return !1; 628 | } 629 | return !1; 630 | }, 631 | // return next match in input 632 | next: function() { 633 | if (this.done) return this.EOF; 634 | this._input || (this.done = !0); 635 | var token, match, tempMatch, index; 636 | this._more || (this.yytext = "", this.match = ""); 637 | for (var rules = this._currentRules(), i = 0; i < rules.length; i++) if (tempMatch = this._input.match(this.rules[rules[i]]), 638 | tempMatch && (!match || tempMatch[0].length > match[0].length)) { 639 | if (match = tempMatch, index = i, this.options.backtrack_lexer) { 640 | if (token = this.test_match(tempMatch, rules[i]), token !== !1) return token; 641 | if (this._backtrack) { 642 | match = !1; 643 | continue; 644 | } 645 | // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) 646 | return !1; 647 | } 648 | if (!this.options.flex) break; 649 | } 650 | return match ? (token = this.test_match(match, rules[index]), token !== !1 && token) : "" === this._input ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { 651 | text: "", 652 | token: null, 653 | line: this.yylineno 654 | }); 655 | }, 656 | // return next match that has a token 657 | lex: function() { 658 | var r = this.next(); 659 | return r ? r : this.lex(); 660 | }, 661 | // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) 662 | begin: function(condition) { 663 | this.conditionStack.push(condition); 664 | }, 665 | // pop the previously active lexer condition state off the condition stack 666 | popState: function() { 667 | var n = this.conditionStack.length - 1; 668 | return n > 0 ? this.conditionStack.pop() : this.conditionStack[0]; 669 | }, 670 | // produce the lexer rule set which is active for the currently active lexer condition state 671 | _currentRules: function() { 672 | return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules; 673 | }, 674 | // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available 675 | topState: function(n) { 676 | return n = this.conditionStack.length - 1 - Math.abs(n || 0), n >= 0 ? this.conditionStack[n] : "INITIAL"; 677 | }, 678 | // alias for begin(condition) 679 | pushState: function(condition) { 680 | this.begin(condition); 681 | }, 682 | // return the number of states currently on the stack 683 | stateStackSize: function() { 684 | return this.conditionStack.length; 685 | }, 686 | options: { 687 | "case-insensitive": !0 688 | }, 689 | performAction: function(yy, yy_, $avoiding_name_collisions, YY_START) { 690 | switch ($avoiding_name_collisions) { 691 | case 0: 692 | return 8; 693 | 694 | case 1: 695 | /* skip whitespace */ 696 | break; 697 | 698 | case 2: 699 | /* skip comments */ 700 | break; 701 | 702 | case 3: 703 | return 9; 704 | 705 | case 4: 706 | return 21; 707 | 708 | case 5: 709 | return 22; 710 | 711 | case 6: 712 | return 18; 713 | 714 | case 7: 715 | return 15; 716 | 717 | case 8: 718 | return 13; 719 | 720 | case 9: 721 | return 20; 722 | 723 | case 10: 724 | return 24; 725 | 726 | case 11: 727 | return 24; 728 | 729 | case 12: 730 | return 28; 731 | 732 | case 13: 733 | return 27; 734 | 735 | case 14: 736 | return 30; 737 | 738 | case 15: 739 | return 29; 740 | 741 | case 16: 742 | return 31; 743 | 744 | case 17: 745 | return 5; 746 | 747 | case 18: 748 | return "INVALID"; 749 | } 750 | }, 751 | rules: [ /^(?:[\r\n]+)/i, /^(?:\s+)/i, /^(?:#[^\r\n]*)/i, /^(?:participant\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:title\b)/i, /^(?:,)/i, /^(?:[^\->:,\r\n"]+)/i, /^(?:"[^"]+")/i, /^(?:--)/i, /^(?:-)/i, /^(?:>>)/i, /^(?:>)/i, /^(?:[^\r\n]+)/i, /^(?:$)/i, /^(?:.)/i ], 752 | conditions: { 753 | INITIAL: { 754 | rules: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ], 755 | inclusive: !0 756 | } 757 | } 758 | }; 759 | return lexer; 760 | }(); 761 | return parser.lexer = lexer, Parser.prototype = parser, parser.Parser = Parser, 762 | new Parser(); 763 | }(); 764 | 765 | "undefined" != typeof require && "undefined" != typeof exports && (exports.parser = parser, 766 | exports.Parser = parser.Parser, exports.parse = function() { 767 | return parser.parse.apply(parser, arguments); 768 | }, exports.main = function(args) { 769 | args[1] || (console.log("Usage: " + args[0] + " FILE"), process.exit(1)); 770 | var source = require("fs").readFileSync(require("path").normalize(args[1]), "utf8"); 771 | return exports.parser.parse(source); 772 | }, "undefined" != typeof module && require.main === module && exports.main(process.argv.slice(1))); 773 | /** 774 | * jison doesn't have a good exception, so we make one. 775 | * This is brittle as it depends on jison internals 776 | */ 777 | function ParseError(message, hash) { 778 | _.extend(this, hash); 779 | 780 | this.name = 'ParseError'; 781 | this.message = (message || ''); 782 | } 783 | ParseError.prototype = new Error(); 784 | Diagram.ParseError = ParseError; 785 | 786 | Diagram.parse = function(input) { 787 | // TODO jison v0.4.17 changed their API slightly, so parser is no longer defined: 788 | 789 | // Create the object to track state and deal with errors 790 | parser.yy = new Diagram(); 791 | parser.yy.parseError = function(message, hash) { 792 | throw new ParseError(message, hash); 793 | }; 794 | 795 | // Parse 796 | var diagram = parser.parse(input); 797 | 798 | // Then clean up the parseError key that a user won't care about 799 | delete diagram.parseError; 800 | return diagram; 801 | }; 802 | 803 | 804 | /** js sequence diagrams 805 | * https://bramp.github.io/js-sequence-diagrams/ 806 | * (c) 2012-2017 Andrew Brampton (bramp.net) 807 | * Simplified BSD license. 808 | */ 809 | /*global Diagram, _ */ 810 | 811 | // Following the CSS convention 812 | // Margin is the gap outside the box 813 | // Padding is the gap inside the box 814 | // Each object has x/y/width/height properties 815 | // The x/y should be top left corner 816 | // width/height is with both margin and padding 817 | 818 | // TODO 819 | // Image width is wrong, when there is a note in the right hand col 820 | // Title box could look better 821 | // Note box could look better 822 | 823 | var DIAGRAM_MARGIN = 10; 824 | 825 | var ACTOR_MARGIN = 10; // Margin around a actor 826 | var ACTOR_PADDING = 10; // Padding inside a actor 827 | 828 | var SIGNAL_MARGIN = 5; // Margin around a signal 829 | var SIGNAL_PADDING = 5; // Padding inside a signal 830 | 831 | var NOTE_MARGIN = 10; // Margin around a note 832 | var NOTE_PADDING = 5; // Padding inside a note 833 | var NOTE_OVERLAP = 15; // Overlap when using a "note over A,B" 834 | 835 | var TITLE_MARGIN = 0; 836 | var TITLE_PADDING = 5; 837 | 838 | var SELF_SIGNAL_WIDTH = 20; // How far out a self signal goes 839 | 840 | var PLACEMENT = Diagram.PLACEMENT; 841 | var LINETYPE = Diagram.LINETYPE; 842 | var ARROWTYPE = Diagram.ARROWTYPE; 843 | 844 | var ALIGN_LEFT = 0; 845 | var ALIGN_CENTER = 1; 846 | 847 | function AssertException(message) { this.message = message; } 848 | AssertException.prototype.toString = function() { 849 | return 'AssertException: ' + this.message; 850 | }; 851 | 852 | function assert(exp, message) { 853 | if (!exp) { 854 | throw new AssertException(message); 855 | } 856 | } 857 | 858 | if (!String.prototype.trim) { 859 | String.prototype.trim = function() { 860 | return this.replace(/^\s+|\s+$/g, ''); 861 | }; 862 | } 863 | 864 | Diagram.themes = {}; 865 | function registerTheme(name, theme) { 866 | Diagram.themes[name] = theme; 867 | } 868 | 869 | /****************** 870 | * Drawing extras 871 | ******************/ 872 | 873 | function getCenterX(box) { 874 | return box.x + box.width / 2; 875 | } 876 | 877 | function getCenterY(box) { 878 | return box.y + box.height / 2; 879 | } 880 | 881 | /****************** 882 | * SVG Path extras 883 | ******************/ 884 | 885 | function clamp(x, min, max) { 886 | if (x < min) { 887 | return min; 888 | } 889 | if (x > max) { 890 | return max; 891 | } 892 | return x; 893 | } 894 | 895 | function wobble(x1, y1, x2, y2) { 896 | assert(_.all([x1,x2,y1,y2], _.isFinite), 'x1,x2,y1,y2 must be numeric'); 897 | 898 | // Wobble no more than 1/25 of the line length 899 | var factor = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) / 25; 900 | 901 | // Distance along line where the control points are 902 | // Clamp between 20% and 80% so any arrow heads aren't angled too much 903 | var r1 = clamp(Math.random(), 0.2, 0.8); 904 | var r2 = clamp(Math.random(), 0.2, 0.8); 905 | 906 | var xfactor = Math.random() > 0.5 ? factor : -factor; 907 | var yfactor = Math.random() > 0.5 ? factor : -factor; 908 | 909 | var p1 = { 910 | x: (x2 - x1) * r1 + x1 + xfactor, 911 | y: (y2 - y1) * r1 + y1 + yfactor 912 | }; 913 | 914 | var p2 = { 915 | x: (x2 - x1) * r2 + x1 - xfactor, 916 | y: (y2 - y1) * r2 + y1 - yfactor 917 | }; 918 | 919 | return 'C' + p1.x.toFixed(1) + ',' + p1.y.toFixed(1) + // start control point 920 | ' ' + p2.x.toFixed(1) + ',' + p2.y.toFixed(1) + // end control point 921 | ' ' + x2.toFixed(1) + ',' + y2.toFixed(1); // end point 922 | } 923 | 924 | /** 925 | * Draws a wobbly (hand drawn) rect 926 | */ 927 | function handRect(x, y, w, h) { 928 | assert(_.all([x, y, w, h], _.isFinite), 'x, y, w, h must be numeric'); 929 | return 'M' + x + ',' + y + 930 | wobble(x, y, x + w, y) + 931 | wobble(x + w, y, x + w, y + h) + 932 | wobble(x + w, y + h, x, y + h) + 933 | wobble(x, y + h, x, y); 934 | } 935 | 936 | /** 937 | * Draws a wobbly (hand drawn) line 938 | */ 939 | function handLine(x1, y1, x2, y2) { 940 | assert(_.all([x1,x2,y1,y2], _.isFinite), 'x1,x2,y1,y2 must be numeric'); 941 | return 'M' + x1.toFixed(1) + ',' + y1.toFixed(1) + wobble(x1, y1, x2, y2); 942 | } 943 | 944 | /****************** 945 | * BaseTheme 946 | ******************/ 947 | 948 | var BaseTheme = function(diagram, options) { 949 | this.init(diagram, options); 950 | }; 951 | 952 | _.extend(BaseTheme.prototype, { 953 | 954 | // Init called while creating the Theme 955 | init: function(diagram, options) { 956 | this.diagram = diagram; 957 | 958 | this.actorsHeight_ = 0; 959 | this.signalsHeight_ = 0; 960 | this.title_ = undefined; // hack - This should be somewhere better 961 | }, 962 | 963 | setupPaper: function(container) {}, 964 | 965 | draw: function(container) { 966 | this.setupPaper(container); 967 | 968 | this.layout(); 969 | 970 | var titleHeight = this.title_ ? this.title_.height : 0; 971 | var y = DIAGRAM_MARGIN + titleHeight; 972 | 973 | this.drawTitle(); 974 | this.drawActors(y); 975 | this.drawSignals(y + this.actorsHeight_); 976 | }, 977 | 978 | layout: function() { 979 | // Local copies 980 | var diagram = this.diagram; 981 | var font = this.font_; 982 | var actors = diagram.actors; 983 | var signals = diagram.signals; 984 | 985 | diagram.width = 0; // min width 986 | diagram.height = 0; // min height 987 | 988 | // Setup some layout stuff 989 | if (diagram.title) { 990 | var title = this.title_ = {}; 991 | var bb = this.textBBox(diagram.title, font); 992 | title.textBB = bb; 993 | title.message = diagram.title; 994 | 995 | title.width = bb.width + (TITLE_PADDING + TITLE_MARGIN) * 2; 996 | title.height = bb.height + (TITLE_PADDING + TITLE_MARGIN) * 2; 997 | title.x = DIAGRAM_MARGIN; 998 | title.y = DIAGRAM_MARGIN; 999 | 1000 | diagram.width += title.width; 1001 | diagram.height += title.height; 1002 | } 1003 | 1004 | _.each(actors, function(a) { 1005 | var bb = this.textBBox(a.name, font); 1006 | a.textBB = bb; 1007 | 1008 | a.x = 0; a.y = 0; 1009 | a.width = bb.width + (ACTOR_PADDING + ACTOR_MARGIN) * 2; 1010 | a.height = bb.height + (ACTOR_PADDING + ACTOR_MARGIN) * 2; 1011 | 1012 | a.distances = []; 1013 | a.paddingRight = 0; 1014 | this.actorsHeight_ = Math.max(a.height, this.actorsHeight_); 1015 | }, this); 1016 | 1017 | function actorEnsureDistance(a, b, d) { 1018 | assert(a < b, 'a must be less than or equal to b'); 1019 | 1020 | if (a < 0) { 1021 | // Ensure b has left margin 1022 | b = actors[b]; 1023 | b.x = Math.max(d - b.width / 2, b.x); 1024 | } else if (b >= actors.length) { 1025 | // Ensure a has right margin 1026 | a = actors[a]; 1027 | a.paddingRight = Math.max(d, a.paddingRight); 1028 | } else { 1029 | a = actors[a]; 1030 | a.distances[b] = Math.max(d, a.distances[b] ? a.distances[b] : 0); 1031 | } 1032 | } 1033 | 1034 | _.each(signals, function(s) { 1035 | // Indexes of the left and right actors involved 1036 | var a; 1037 | var b; 1038 | 1039 | var bb = this.textBBox(s.message, font); 1040 | 1041 | //var bb = t.attr("text", s.message).getBBox(); 1042 | s.textBB = bb; 1043 | s.width = bb.width; 1044 | s.height = bb.height; 1045 | 1046 | var extraWidth = 0; 1047 | 1048 | if (s.type == 'Signal') { 1049 | 1050 | s.width += (SIGNAL_MARGIN + SIGNAL_PADDING) * 2; 1051 | s.height += (SIGNAL_MARGIN + SIGNAL_PADDING) * 2; 1052 | 1053 | if (s.isSelf()) { 1054 | // TODO Self signals need a min height 1055 | a = s.actorA.index; 1056 | b = a + 1; 1057 | s.width += SELF_SIGNAL_WIDTH; 1058 | } else { 1059 | a = Math.min(s.actorA.index, s.actorB.index); 1060 | b = Math.max(s.actorA.index, s.actorB.index); 1061 | } 1062 | 1063 | } else if (s.type == 'Note') { 1064 | s.width += (NOTE_MARGIN + NOTE_PADDING) * 2; 1065 | s.height += (NOTE_MARGIN + NOTE_PADDING) * 2; 1066 | 1067 | // HACK lets include the actor's padding 1068 | extraWidth = 2 * ACTOR_MARGIN; 1069 | 1070 | if (s.placement == PLACEMENT.LEFTOF) { 1071 | b = s.actor.index; 1072 | a = b - 1; 1073 | } else if (s.placement == PLACEMENT.RIGHTOF) { 1074 | a = s.actor.index; 1075 | b = a + 1; 1076 | } else if (s.placement == PLACEMENT.OVER && s.hasManyActors()) { 1077 | // Over multiple actors 1078 | a = Math.min(s.actor[0].index, s.actor[1].index); 1079 | b = Math.max(s.actor[0].index, s.actor[1].index); 1080 | 1081 | // We don't need our padding, and we want to overlap 1082 | extraWidth = -(NOTE_PADDING * 2 + NOTE_OVERLAP * 2); 1083 | 1084 | } else if (s.placement == PLACEMENT.OVER) { 1085 | // Over single actor 1086 | a = s.actor.index; 1087 | actorEnsureDistance(a - 1, a, s.width / 2); 1088 | actorEnsureDistance(a, a + 1, s.width / 2); 1089 | this.signalsHeight_ += s.height; 1090 | 1091 | return; // Bail out early 1092 | } 1093 | } else { 1094 | throw new Error('Unhandled signal type:' + s.type); 1095 | } 1096 | 1097 | actorEnsureDistance(a, b, s.width + extraWidth); 1098 | this.signalsHeight_ += s.height; 1099 | }, this); 1100 | 1101 | // Re-jig the positions 1102 | var actorsX = 0; 1103 | _.each(actors, function(a) { 1104 | a.x = Math.max(actorsX, a.x); 1105 | 1106 | // TODO This only works if we loop in sequence, 0, 1, 2, etc 1107 | _.each(a.distances, function(distance, b) { 1108 | // lodash (and possibly others) do not like sparse arrays 1109 | // so sometimes they return undefined 1110 | if (typeof distance == 'undefined') { 1111 | return; 1112 | } 1113 | 1114 | b = actors[b]; 1115 | distance = Math.max(distance, a.width / 2, b.width / 2); 1116 | b.x = Math.max(b.x, a.x + a.width / 2 + distance - b.width / 2); 1117 | }); 1118 | 1119 | actorsX = a.x + a.width + a.paddingRight; 1120 | }, this); 1121 | 1122 | diagram.width = Math.max(actorsX, diagram.width); 1123 | 1124 | // TODO Refactor a little 1125 | diagram.width += 2 * DIAGRAM_MARGIN; 1126 | diagram.height += 2 * DIAGRAM_MARGIN + 2 * this.actorsHeight_ + this.signalsHeight_; 1127 | 1128 | return this; 1129 | }, 1130 | 1131 | // TODO Instead of one textBBox function, create a function for each element type, e.g 1132 | // layout_title, layout_actor, etc that returns it's bounding box 1133 | textBBox: function(text, font) {}, 1134 | 1135 | drawTitle: function() { 1136 | var title = this.title_; 1137 | if (title) { 1138 | this.drawTextBox(title, title.message, TITLE_MARGIN, TITLE_PADDING, this.font_, ALIGN_LEFT); 1139 | } 1140 | }, 1141 | 1142 | drawActors: function(offsetY) { 1143 | var y = offsetY; 1144 | _.each(this.diagram.actors, function(a) { 1145 | // Top box 1146 | this.drawActor(a, y, this.actorsHeight_); 1147 | 1148 | // Bottom box 1149 | this.drawActor(a, y + this.actorsHeight_ + this.signalsHeight_, this.actorsHeight_); 1150 | 1151 | // Veritical line 1152 | var aX = getCenterX(a); 1153 | this.drawLine( 1154 | aX, y + this.actorsHeight_ - ACTOR_MARGIN, 1155 | aX, y + this.actorsHeight_ + ACTOR_MARGIN + this.signalsHeight_); 1156 | }, this); 1157 | }, 1158 | 1159 | drawActor: function(actor, offsetY, height) { 1160 | actor.y = offsetY; 1161 | actor.height = height; 1162 | this.drawTextBox(actor, actor.name, ACTOR_MARGIN, ACTOR_PADDING, this.font_, ALIGN_CENTER); 1163 | }, 1164 | 1165 | drawSignals: function(offsetY) { 1166 | var y = offsetY; 1167 | _.each(this.diagram.signals, function(s) { 1168 | // TODO Add debug mode, that draws padding/margin box 1169 | if (s.type == 'Signal') { 1170 | if (s.isSelf()) { 1171 | this.drawSelfSignal(s, y); 1172 | } else { 1173 | this.drawSignal(s, y); 1174 | } 1175 | 1176 | } else if (s.type == 'Note') { 1177 | this.drawNote(s, y); 1178 | } 1179 | 1180 | y += s.height; 1181 | }, this); 1182 | }, 1183 | 1184 | drawSelfSignal: function(signal, offsetY) { 1185 | assert(signal.isSelf(), 'signal must be a self signal'); 1186 | 1187 | var textBB = signal.textBB; 1188 | var aX = getCenterX(signal.actorA); 1189 | 1190 | var x = aX + SELF_SIGNAL_WIDTH + SIGNAL_PADDING; 1191 | var y = offsetY + SIGNAL_PADDING + signal.height / 2 + textBB.y; 1192 | 1193 | this.drawText(x, y, signal.message, this.font_, ALIGN_LEFT); 1194 | 1195 | var y1 = offsetY + SIGNAL_MARGIN + SIGNAL_PADDING; 1196 | var y2 = y1 + signal.height - 2 * SIGNAL_MARGIN - SIGNAL_PADDING; 1197 | 1198 | // Draw three lines, the last one with a arrow 1199 | this.drawLine(aX, y1, aX + SELF_SIGNAL_WIDTH, y1, signal.linetype); 1200 | this.drawLine(aX + SELF_SIGNAL_WIDTH, y1, aX + SELF_SIGNAL_WIDTH, y2, signal.linetype); 1201 | this.drawLine(aX + SELF_SIGNAL_WIDTH, y2, aX, y2, signal.linetype, signal.arrowtype); 1202 | }, 1203 | 1204 | drawSignal: function(signal, offsetY) { 1205 | var aX = getCenterX(signal.actorA); 1206 | var bX = getCenterX(signal.actorB); 1207 | 1208 | // Mid point between actors 1209 | var x = (bX - aX) / 2 + aX; 1210 | var y = offsetY + SIGNAL_MARGIN + 2 * SIGNAL_PADDING; 1211 | 1212 | // Draw the text in the middle of the signal 1213 | this.drawText(x, y, signal.message, this.font_, ALIGN_CENTER); 1214 | 1215 | // Draw the line along the bottom of the signal 1216 | y = offsetY + signal.height - SIGNAL_MARGIN - SIGNAL_PADDING; 1217 | this.drawLine(aX, y, bX, y, signal.linetype, signal.arrowtype); 1218 | }, 1219 | 1220 | drawNote: function(note, offsetY) { 1221 | note.y = offsetY; 1222 | var actorA = note.hasManyActors() ? note.actor[0] : note.actor; 1223 | var aX = getCenterX(actorA); 1224 | switch (note.placement) { 1225 | case PLACEMENT.RIGHTOF: 1226 | note.x = aX + ACTOR_MARGIN; 1227 | break; 1228 | case PLACEMENT.LEFTOF: 1229 | note.x = aX - ACTOR_MARGIN - note.width; 1230 | break; 1231 | case PLACEMENT.OVER: 1232 | if (note.hasManyActors()) { 1233 | var bX = getCenterX(note.actor[1]); 1234 | var overlap = NOTE_OVERLAP + NOTE_PADDING; 1235 | note.x = Math.min(aX, bX) - overlap; 1236 | note.width = (Math.max(aX, bX) + overlap) - note.x; 1237 | } else { 1238 | note.x = aX - note.width / 2; 1239 | } 1240 | break; 1241 | default: 1242 | throw new Error('Unhandled note placement: ' + note.placement); 1243 | } 1244 | return this.drawTextBox(note, note.message, NOTE_MARGIN, NOTE_PADDING, this.font_, ALIGN_LEFT); 1245 | }, 1246 | 1247 | /** 1248 | * Draw text surrounded by a box 1249 | */ 1250 | drawTextBox: function(box, text, margin, padding, font, align) { 1251 | var x = box.x + margin; 1252 | var y = box.y + margin; 1253 | var w = box.width - 2 * margin; 1254 | var h = box.height - 2 * margin; 1255 | 1256 | // Draw inner box 1257 | this.drawRect(x, y, w, h); 1258 | 1259 | // Draw text (in the center) 1260 | if (align == ALIGN_CENTER) { 1261 | x = getCenterX(box); 1262 | y = getCenterY(box); 1263 | } else { 1264 | x += padding; 1265 | y += padding; 1266 | } 1267 | 1268 | return this.drawText(x, y, text, font, align); 1269 | } 1270 | }); 1271 | 1272 | /** js sequence diagrams 1273 | * https://bramp.github.io/js-sequence-diagrams/ 1274 | * (c) 2012-2017 Andrew Brampton (bramp.net) 1275 | * Simplified BSD license. 1276 | */ 1277 | /*global Diagram, Snap, WebFont _ */ 1278 | // TODO Move defintion of font onto the , so it can easily be override at each level 1279 | if (typeof Snap != 'undefined') { 1280 | 1281 | var xmlns = 'http://www.w3.org/2000/svg'; 1282 | 1283 | var LINE = { 1284 | 'stroke': '#000000', 1285 | 'stroke-width': 2, // BUG TODO This gets set as a style, not as a attribute. Look at eve.on("snap.util.attr"... 1286 | 'fill': 'none' 1287 | }; 1288 | 1289 | var RECT = { 1290 | 'stroke': '#000000', 1291 | 'stroke-width': 2, 1292 | 'fill': '#fff' 1293 | }; 1294 | 1295 | var LOADED_FONTS = {}; 1296 | 1297 | /****************** 1298 | * SnapTheme 1299 | ******************/ 1300 | 1301 | var SnapTheme = function(diagram, options, resume) { 1302 | _.defaults(options, { 1303 | 'css-class': 'simple', 1304 | 'font-size': 16, 1305 | 'font-family': 'Andale Mono, monospace' 1306 | }); 1307 | 1308 | this.init(diagram, options, resume); 1309 | }; 1310 | 1311 | _.extend(SnapTheme.prototype, BaseTheme.prototype, { 1312 | 1313 | init: function(diagram, options, resume) { 1314 | BaseTheme.prototype.init.call(this, diagram); 1315 | 1316 | this.paper_ = undefined; 1317 | this.cssClass_ = options['css-class'] || undefined; 1318 | this.font_ = { 1319 | 'font-size': options['font-size'], 1320 | 'font-family': options['font-family'] 1321 | }; 1322 | 1323 | var a = this.arrowTypes_ = {}; 1324 | a[ARROWTYPE.FILLED] = 'Block'; 1325 | a[ARROWTYPE.OPEN] = 'Open'; 1326 | 1327 | var l = this.lineTypes_ = {}; 1328 | l[LINETYPE.SOLID] = ''; 1329 | l[LINETYPE.DOTTED] = '6,2'; 1330 | 1331 | var that = this; 1332 | this.waitForFont(function() { 1333 | resume(that); 1334 | }); 1335 | }, 1336 | 1337 | // Wait for loading of the font 1338 | waitForFont: function(callback) { 1339 | var fontFamily = this.font_['font-family']; 1340 | 1341 | if (typeof WebFont == 'undefined') { 1342 | throw new Error('WebFont is required (https://github.com/typekit/webfontloader).'); 1343 | } 1344 | 1345 | if (LOADED_FONTS[fontFamily]) { 1346 | // If already loaded, just return instantly. 1347 | callback(); 1348 | return; 1349 | } 1350 | 1351 | WebFont.load({ 1352 | custom: { 1353 | families: [fontFamily] // TODO replace this with something that reads the css 1354 | }, 1355 | classes: false, // No need to place classes on the DOM, just use JS Events 1356 | active: function() { 1357 | LOADED_FONTS[fontFamily] = true; 1358 | callback(); 1359 | }, 1360 | inactive: function() { 1361 | // If we fail to fetch the font, still continue. 1362 | LOADED_FONTS[fontFamily] = true; 1363 | callback(); 1364 | } 1365 | }); 1366 | }, 1367 | 1368 | addDescription: function(svg, description) { 1369 | var desc = document.createElementNS(xmlns, 'desc'); 1370 | desc.appendChild(document.createTextNode(description)); 1371 | svg.appendChild(desc); 1372 | }, 1373 | 1374 | setupPaper: function(container) { 1375 | // Container must be a SVG element. We assume it's a div, so lets create a SVG and insert 1376 | var svg = document.createElementNS(xmlns, 'svg'); 1377 | container.appendChild(svg); 1378 | 1379 | this.addDescription(svg, this.diagram.title || ''); 1380 | 1381 | this.paper_ = Snap(svg); 1382 | this.paper_.addClass('sequence'); 1383 | 1384 | if (this.cssClass_) { 1385 | this.paper_.addClass(this.cssClass_); 1386 | } 1387 | 1388 | this.beginGroup(); 1389 | 1390 | // TODO Perhaps only include the markers if we actually use them. 1391 | var a = this.arrowMarkers_ = {}; 1392 | var arrow = this.paper_.path('M 0 0 L 5 2.5 L 0 5 z'); 1393 | a[ARROWTYPE.FILLED] = arrow.marker(0, 0, 5, 5, 5, 2.5) 1394 | .attr({id: 'markerArrowBlock'}); 1395 | 1396 | arrow = this.paper_.path('M 9.6,8 1.92,16 0,13.7 5.76,8 0,2.286 1.92,0 9.6,8 z'); 1397 | a[ARROWTYPE.OPEN] = arrow.marker(0, 0, 9.6, 16, 9.6, 8) 1398 | .attr({markerWidth: '4', id: 'markerArrowOpen'}); 1399 | }, 1400 | 1401 | layout: function() { 1402 | BaseTheme.prototype.layout.call(this); 1403 | this.paper_.attr({ 1404 | width: this.diagram.width + 'px', 1405 | height: this.diagram.height + 'px' 1406 | }); 1407 | }, 1408 | 1409 | textBBox: function(text, font) { 1410 | // TODO getBBox will return the bounds with any whitespace/kerning. This makes some of our aligments screwed up 1411 | var t = this.createText(text, font); 1412 | var bb = t.getBBox(); 1413 | t.remove(); 1414 | return bb; 1415 | }, 1416 | 1417 | // For each drawn element, push onto the stack, so it can be wrapped in a single outer element 1418 | pushToStack: function(element) { 1419 | this._stack.push(element); 1420 | return element; 1421 | }, 1422 | 1423 | // Begin a group of elements 1424 | beginGroup: function() { 1425 | this._stack = []; 1426 | }, 1427 | 1428 | // Finishes the group, and returns the element 1429 | finishGroup: function() { 1430 | var g = this.paper_.group.apply(this.paper_, this._stack); 1431 | this.beginGroup(); // Reset the group 1432 | return g; 1433 | }, 1434 | 1435 | createText: function(text, font) { 1436 | text = _.invoke(text.split('\n'), 'trim'); 1437 | var t = this.paper_.text(0, 0, text); 1438 | t.attr(font || {}); 1439 | if (text.length > 1) { 1440 | // Every row after the first, set tspan to be 1.2em below the previous line 1441 | t.selectAll('tspan:nth-child(n+2)').attr({ 1442 | dy: '1.2em', 1443 | x: 0 1444 | }); 1445 | } 1446 | 1447 | return t; 1448 | }, 1449 | 1450 | drawLine: function(x1, y1, x2, y2, linetype, arrowhead) { 1451 | var line = this.paper_.line(x1, y1, x2, y2).attr(LINE); 1452 | if (linetype !== undefined) { 1453 | line.attr('strokeDasharray', this.lineTypes_[linetype]); 1454 | } 1455 | if (arrowhead !== undefined) { 1456 | line.attr('markerEnd', this.arrowMarkers_[arrowhead]); 1457 | } 1458 | return this.pushToStack(line); 1459 | }, 1460 | 1461 | drawRect: function(x, y, w, h) { 1462 | var rect = this.paper_.rect(x, y, w, h).attr(RECT); 1463 | return this.pushToStack(rect); 1464 | }, 1465 | 1466 | /** 1467 | * Draws text with a optional white background 1468 | * x,y (int) x,y top left point of the text, or the center of the text (depending on align param) 1469 | * text (string) text to print 1470 | * font (Object) 1471 | * align (string) ALIGN_LEFT or ALIGN_CENTER 1472 | */ 1473 | drawText: function(x, y, text, font, align) { 1474 | var t = this.createText(text, font); 1475 | var bb = t.getBBox(); 1476 | 1477 | if (align == ALIGN_CENTER) { 1478 | x = x - bb.width / 2; 1479 | y = y - bb.height / 2; 1480 | } 1481 | 1482 | // Now move the text into place 1483 | // `y - bb.y` because text(..) is positioned from the baseline, so this moves it down. 1484 | t.attr({x: x - bb.x, y: y - bb.y}); 1485 | t.selectAll('tspan').attr({x: x}); 1486 | 1487 | this.pushToStack(t); 1488 | return t; 1489 | }, 1490 | 1491 | drawTitle: function() { 1492 | this.beginGroup(); 1493 | BaseTheme.prototype.drawTitle.call(this); 1494 | return this.finishGroup().addClass('title'); 1495 | }, 1496 | 1497 | drawActor: function(actor, offsetY, height) { 1498 | this.beginGroup(); 1499 | BaseTheme.prototype.drawActor.call(this, actor, offsetY, height); 1500 | return this.finishGroup().addClass('actor'); 1501 | }, 1502 | 1503 | drawSignal: function(signal, offsetY) { 1504 | this.beginGroup(); 1505 | BaseTheme.prototype.drawSignal.call(this, signal, offsetY); 1506 | return this.finishGroup().addClass('signal'); 1507 | }, 1508 | 1509 | drawSelfSignal: function(signal, offsetY) { 1510 | this.beginGroup(); 1511 | BaseTheme.prototype.drawSelfSignal.call(this, signal, offsetY); 1512 | return this.finishGroup().addClass('signal'); 1513 | }, 1514 | 1515 | drawNote: function(note, offsetY) { 1516 | this.beginGroup(); 1517 | BaseTheme.prototype.drawNote.call(this, note, offsetY); 1518 | return this.finishGroup().addClass('note'); 1519 | }, 1520 | }); 1521 | 1522 | /****************** 1523 | * SnapHandTheme 1524 | ******************/ 1525 | 1526 | var SnapHandTheme = function(diagram, options, resume) { 1527 | _.defaults(options, { 1528 | 'css-class': 'hand', 1529 | 'font-size': 16, 1530 | 'font-family': 'danielbd' 1531 | }); 1532 | 1533 | this.init(diagram, options, resume); 1534 | }; 1535 | 1536 | // Take the standard SnapTheme and make all the lines wobbly 1537 | _.extend(SnapHandTheme.prototype, SnapTheme.prototype, { 1538 | drawLine: function(x1, y1, x2, y2, linetype, arrowhead) { 1539 | var line = this.paper_.path(handLine(x1, y1, x2, y2)).attr(LINE); 1540 | if (linetype !== undefined) { 1541 | line.attr('strokeDasharray', this.lineTypes_[linetype]); 1542 | } 1543 | if (arrowhead !== undefined) { 1544 | line.attr('markerEnd', this.arrowMarkers_[arrowhead]); 1545 | } 1546 | return this.pushToStack(line); 1547 | }, 1548 | 1549 | drawRect: function(x, y, w, h) { 1550 | var rect = this.paper_.path(handRect(x, y, w, h)).attr(RECT); 1551 | return this.pushToStack(rect); 1552 | } 1553 | }); 1554 | 1555 | registerTheme('snapSimple', SnapTheme); 1556 | registerTheme('snapHand', SnapHandTheme); 1557 | } 1558 | 1559 | 1560 | /** js sequence diagrams 1561 | * https://bramp.github.io/js-sequence-diagrams/ 1562 | * (c) 2012-2017 Andrew Brampton (bramp.net) 1563 | * Simplified BSD license. 1564 | */ 1565 | /*global Diagram, _ */ 1566 | 1567 | if (typeof Raphael == 'undefined' && typeof Snap == 'undefined') { 1568 | throw new Error('Raphael or Snap.svg is required to be included.'); 1569 | } 1570 | 1571 | if (_.isEmpty(Diagram.themes)) { 1572 | // If you are using stock js-sequence-diagrams you should never see this. This only 1573 | // happens if you have removed the built in themes. 1574 | throw new Error('No themes were registered. Please call registerTheme(...).'); 1575 | } 1576 | 1577 | // Set the default hand/simple based on which theme is available. 1578 | Diagram.themes.hand = Diagram.themes.snapHand || Diagram.themes.raphaelHand; 1579 | Diagram.themes.simple = Diagram.themes.snapSimple || Diagram.themes.raphaelSimple; 1580 | 1581 | /* Draws the diagram. Creates a SVG inside the container 1582 | * container (HTMLElement|string) DOM element or its ID to draw on 1583 | * options (Object) 1584 | */ 1585 | Diagram.prototype.drawSVG = function(container, options) { 1586 | var defaultOptions = { 1587 | theme: 'hand' 1588 | }; 1589 | 1590 | options = _.defaults(options || {}, defaultOptions); 1591 | 1592 | if (!(options.theme in Diagram.themes)) { 1593 | throw new Error('Unsupported theme: ' + options.theme); 1594 | } 1595 | 1596 | // TODO Write tests for this check 1597 | var div = _.isString(container) ? document.getElementById(container) : container; 1598 | if (div === null || !div.tagName) { 1599 | throw new Error('Invalid container: ' + container); 1600 | } 1601 | 1602 | var Theme = Diagram.themes[options.theme]; 1603 | new Theme(this, options, function(drawing) { 1604 | drawing.draw(div); 1605 | }); 1606 | }; // end of drawSVG 1607 | /** js sequence diagrams 1608 | * https://bramp.github.io/js-sequence-diagrams/ 1609 | * (c) 2012-2017 Andrew Brampton (bramp.net) 1610 | * Simplified BSD license. 1611 | */ 1612 | /*global jQuery */ 1613 | if (typeof jQuery != 'undefined') { 1614 | (function($) { 1615 | $.fn.sequenceDiagram = function(options) { 1616 | return this.each(function() { 1617 | var $this = $(this); 1618 | var diagram = Diagram.parse($this.text()); 1619 | $this.html(''); 1620 | diagram.drawSVG(this, options); 1621 | }); 1622 | }; 1623 | })(jQuery); 1624 | } 1625 | 1626 | // Taken from underscore.js: 1627 | // Establish the root object, `window` (`self`) in the browser, or `global` on the server. 1628 | // We use `self` instead of `window` for `WebWorker` support. 1629 | var root = (typeof self == 'object' && self.self == self && self) || 1630 | (typeof global == 'object' && global.global == global && global); 1631 | 1632 | // Export the Diagram object for **Node.js**, with 1633 | // backwards-compatibility for their old module API. If we're in 1634 | // the browser, add `Diagram` as a global object. 1635 | if (typeof exports !== 'undefined') { 1636 | if (typeof module !== 'undefined' && module.exports) { 1637 | exports = module.exports = Diagram; 1638 | } 1639 | exports.Diagram = Diagram; 1640 | } else { 1641 | root.Diagram = Diagram; 1642 | } 1643 | }()); 1644 | 1645 | -------------------------------------------------------------------------------- /src/deps/js-sequence-diagrams/snap.svg-min.js: -------------------------------------------------------------------------------- 1 | // Snap.svg 0.4.1 2 | // 3 | // Copyright (c) 2013 – 2015 Adobe Systems Incorporated. All rights reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | // build: 2015-04-13 18 | 19 | !function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g=/\s*,\s*/,h="*",i=function(a,b){return a-b},j={n:{}},k=function(){for(var a=0,b=this.length;b>a;a++)if("undefined"!=typeof this[a])return this[a]},l=function(){for(var a=this.length;--a;)if("undefined"!=typeof this[a])return this[a]},m=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=m.listeners(a),j=0,n=[],o={},p=[],q=b;p.firstDefined=k,p.lastDefined=l,b=a,c=0;for(var r=0,s=h.length;s>r;r++)"zIndex"in h[r]&&(n.push(h[r].zIndex),h[r].zIndex<0&&(o[h[r].zIndex]=h[r]));for(n.sort(i);n[j]<0;)if(e=o[n[j++]],p.push(e.apply(d,g)),c)return c=f,p;for(r=0;s>r;r++)if(e=h[r],"zIndex"in e)if(e.zIndex==n[j]){if(p.push(e.apply(d,g)),c)break;do if(j++,e=o[n[j]],e&&p.push(e.apply(d,g)),c)break;while(e)}else o[e.zIndex]=e;else if(p.push(e.apply(d,g)),c)break;return c=f,b=q,p};m._events=j,m.listeners=function(a){var b,c,d,e,g,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,g=m.length;g>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[h]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},m.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(g),d=0,e=c.length;e>d;d++)!function(a){for(var c,d=a.split(f),e=j,g=0,h=d.length;h>g;g++)e=e.n,e=e.hasOwnProperty(d[g])&&e[d[g]]||(e[d[g]]={n:{}});for(e.f=e.f||[],g=0,h=e.f.length;h>g;g++)if(e.f[g]==b){c=!0;break}!c&&e.f.push(b)}(c[d]);return function(a){+a==+a&&(b.zIndex=+a)}},m.f=function(a){var b=[].slice.call(arguments,1);return function(){m.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},m.stop=function(){c=1},m.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},m.nts=function(){return b.split(f)},m.off=m.unbind=function(a,b){if(!a)return void(m._events=j={n:{}});var c=a.split(g);if(c.length>1)for(var d=0,i=c.length;i>d;d++)m.off(c[d],b);else{c=a.split(f);var k,l,n,d,i,o,p,q=[j];for(d=0,i=c.length;i>d;d++)for(o=0;od;d++)for(k=q[d];k.n;){if(b){if(k.f){for(o=0,p=k.f.length;p>o;o++)if(k.f[o]==b){k.f.splice(o,1);break}!k.f.length&&delete k.f}for(l in k.n)if(k.n[e](l)&&k.n[l].f){var r=k.n[l].f;for(o=0,p=r.length;p>o;o++)if(r[o]==b){r.splice(o,1);break}!r.length&&delete k.n[l].f}}else{delete k.f;for(l in k.n)k.n[e](l)&&k.n[l].f&&delete k.n[l].f}k=k.n}}},m.once=function(a,b){var c=function(){return m.unbind(a,c),b.apply(this,arguments)};return m.on(a,c)},m.version=d,m.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=m:"function"==typeof define&&define.amd?define("eve",[],function(){return m}):a.eve=m}(this),function(a,b){if("function"==typeof define&&define.amd)define(["eve"],function(c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("eve");module.exports=b(a,c)}else b(a,a.eve)}(window||this,function(a,b){var c=function(b){var c={},d=a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||function(a){setTimeout(a,16)},e=Array.isArray||function(a){return a instanceof Array||"[object Array]"==Object.prototype.toString.call(a)},f=0,g="M"+(+new Date).toString(36),h=function(){return g+(f++).toString(36)},i=Date.now||function(){return+new Date},j=function(a){var b=this;if(null==a)return b.s;var c=b.s-a;b.b+=b.dur*c,b.B+=b.dur*c,b.s=a},k=function(a){var b=this;return null==a?b.spd:void(b.spd=a)},l=function(a){var b=this;return null==a?b.dur:(b.s=b.s*a/b.dur,void(b.dur=a))},m=function(){var a=this;delete c[a.id],a.update(),b("mina.stop."+a.id,a)},n=function(){var a=this;a.pdif||(delete c[a.id],a.update(),a.pdif=a.get()-a.b)},o=function(){var a=this;a.pdif&&(a.b=a.get()-a.pdif,delete a.pdif,c[a.id]=a)},p=function(){var a,b=this;if(e(b.start)){a=[];for(var c=0,d=b.start.length;d>c;c++)a[c]=+b.start[c]+(b.end[c]-b.start[c])*b.easing(b.s)}else a=+b.start+(b.end-b.start)*b.easing(b.s);b.set(a)},q=function(){var a=0;for(var e in c)if(c.hasOwnProperty(e)){var f=c[e],g=f.get();a++,f.s=(g-f.b)/(f.dur/f.spd),f.s>=1&&(delete c[e],f.s=1,a--,function(a){setTimeout(function(){b("mina.finish."+a.id,a)})}(f)),f.update()}a&&d(q)},r=function(a,b,e,f,g,i,s){var t={id:h(),start:a,end:b,b:e,s:0,dur:f-e,spd:1,get:g,set:i,easing:s||r.linear,status:j,speed:k,duration:l,stop:m,pause:n,resume:o,update:p};c[t.id]=t;var u,v=0;for(u in c)if(c.hasOwnProperty(u)&&(v++,2==v))break;return 1==v&&d(q),t};return r.time=i,r.getById=function(a){return c[a]||null},r.linear=function(a){return a},r.easeout=function(a){return Math.pow(a,1.7)},r.easein=function(a){return Math.pow(a,.48)},r.easeinout=function(a){if(1==a)return 1;if(0==a)return 0;var b=.48-a/1.04,c=Math.sqrt(.1734+b*b),d=c-b,e=Math.pow(Math.abs(d),1/3)*(0>d?-1:1),f=-c-b,g=Math.pow(Math.abs(f),1/3)*(0>f?-1:1),h=e+g+.5;return 3*(1-h)*h*h+h*h*h},r.backin=function(a){if(1==a)return 1;var b=1.70158;return a*a*((b+1)*a-b)},r.backout=function(a){if(0==a)return 0;a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},r.elastic=function(a){return a==!!a?a:Math.pow(2,-10*a)*Math.sin(2*(a-.075)*Math.PI/.3)+1},r.bounce=function(a){var b,c=7.5625,d=2.75;return 1/d>a?b=c*a*a:2/d>a?(a-=1.5/d,b=c*a*a+.75):2.5/d>a?(a-=2.25/d,b=c*a*a+.9375):(a-=2.625/d,b=c*a*a+.984375),b},a.mina=r,r}("undefined"==typeof b?function(){}:b),d=function(a){function c(a,b){if(a){if(a.nodeType)return w(a);if(e(a,"array")&&c.set)return c.set.apply(c,a);if(a instanceof s)return a;if(null==b)return a=y.doc.querySelector(String(a)),w(a)}return a=null==a?"100%":a,b=null==b?"100%":b,new v(a,b)}function d(a,b){if(b){if("#text"==a&&(a=y.doc.createTextNode(b.text||b["#text"]||"")),"#comment"==a&&(a=y.doc.createComment(b.text||b["#text"]||"")),"string"==typeof a&&(a=d(a)),"string"==typeof b)return 1==a.nodeType?"xlink:"==b.substring(0,6)?a.getAttributeNS(T,b.substring(6)):"xml:"==b.substring(0,4)?a.getAttributeNS(U,b.substring(4)):a.getAttribute(b):"text"==b?a.nodeValue:null;if(1==a.nodeType){for(var c in b)if(b[z](c)){var e=A(b[c]);e?"xlink:"==c.substring(0,6)?a.setAttributeNS(T,c.substring(6),e):"xml:"==c.substring(0,4)?a.setAttributeNS(U,c.substring(4),e):a.setAttribute(c,e):a.removeAttribute(c)}}else"text"in b&&(a.nodeValue=b.text)}else a=y.doc.createElementNS(U,a);return a}function e(a,b){return b=A.prototype.toLowerCase.call(b),"finite"==b?isFinite(a):"array"==b&&(a instanceof Array||Array.isArray&&Array.isArray(a))?!0:"null"==b&&null===a||b==typeof a&&null!==a||"object"==b&&a===Object(a)||J.call(a).slice(8,-1).toLowerCase()==b}function f(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[z](c)&&(b[c]=f(a[c]));return b}function h(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function i(a,b,c){function d(){var e=Array.prototype.slice.call(arguments,0),f=e.join("␀"),g=d.cache=d.cache||{},i=d.count=d.count||[];return g[z](f)?(h(i,f),c?c(g[f]):g[f]):(i.length>=1e3&&delete g[i.shift()],i.push(f),g[f]=a.apply(b,e),c?c(g[f]):g[f])}return d}function j(a,b,c,d,e,f){if(null==e){var g=a-c,h=b-d;return g||h?(180+180*D.atan2(-h,-g)/H+360)%360:0}return j(a,b,e,f)-j(c,d,e,f)}function k(a){return a%360*H/180}function l(a){return 180*a/H%360}function m(a){var b=[];return a=a.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,function(a,c,d){return d=d.split(/\s*,\s*|\s+/),"rotate"==c&&1==d.length&&d.push(0,0),"scale"==c&&(d.length>2?d=d.slice(0,2):2==d.length&&d.push(0,0),1==d.length&&d.push(d[0],0,0)),b.push("skewX"==c?["m",1,0,D.tan(k(d[0])),1,0,0]:"skewY"==c?["m",1,D.tan(k(d[0])),0,1,0,0]:[c.charAt(0)].concat(d)),a}),b}function n(a,b){var d=ab(a),e=new c.Matrix;if(d)for(var f=0,g=d.length;g>f;f++){var h,i,j,k,l,m=d[f],n=m.length,o=A(m[0]).toLowerCase(),p=m[0]!=o,q=p?e.invert():0;"t"==o&&2==n?e.translate(m[1],0):"t"==o&&3==n?p?(h=q.x(0,0),i=q.y(0,0),j=q.x(m[1],m[2]),k=q.y(m[1],m[2]),e.translate(j-h,k-i)):e.translate(m[1],m[2]):"r"==o?2==n?(l=l||b,e.rotate(m[1],l.x+l.width/2,l.y+l.height/2)):4==n&&(p?(j=q.x(m[2],m[3]),k=q.y(m[2],m[3]),e.rotate(m[1],j,k)):e.rotate(m[1],m[2],m[3])):"s"==o?2==n||3==n?(l=l||b,e.scale(m[1],m[n-1],l.x+l.width/2,l.y+l.height/2)):4==n?p?(j=q.x(m[2],m[3]),k=q.y(m[2],m[3]),e.scale(m[1],m[1],j,k)):e.scale(m[1],m[1],m[2],m[3]):5==n&&(p?(j=q.x(m[3],m[4]),k=q.y(m[3],m[4]),e.scale(m[1],m[2],j,k)):e.scale(m[1],m[2],m[3],m[4])):"m"==o&&7==n&&e.add(m[1],m[2],m[3],m[4],m[5],m[6])}return e}function o(a){var b=a.node.ownerSVGElement&&w(a.node.ownerSVGElement)||a.node.parentNode&&w(a.node.parentNode)||c.select("svg")||c(0,0),d=b.select("defs"),e=null==d?!1:d.node;return e||(e=u("defs",b.node).node),e}function p(a){return a.node.ownerSVGElement&&w(a.node.ownerSVGElement)||c.select("svg")}function q(a,b,c){function e(a){if(null==a)return I;if(a==+a)return a;d(j,{width:a});try{return j.getBBox().width}catch(b){return 0}}function f(a){if(null==a)return I;if(a==+a)return a;d(j,{height:a});try{return j.getBBox().height}catch(b){return 0}}function g(d,e){null==b?i[d]=e(a.attr(d)||0):d==b&&(i=e(null==c?a.attr(d)||0:c))}var h=p(a).node,i={},j=h.querySelector(".svg---mgr");switch(j||(j=d("rect"),d(j,{x:-9e9,y:-9e9,width:10,height:10,"class":"svg---mgr",fill:"none"}),h.appendChild(j)),a.type){case"rect":g("rx",e),g("ry",f);case"image":g("width",e),g("height",f);case"text":g("x",e),g("y",f);break;case"circle":g("cx",e),g("cy",f),g("r",e);break;case"ellipse":g("cx",e),g("cy",f),g("rx",e),g("ry",f);break;case"line":g("x1",e),g("x2",e),g("y1",f),g("y2",f);break;case"marker":g("refX",e),g("markerWidth",e),g("refY",f),g("markerHeight",f);break;case"radialGradient":g("fx",e),g("fy",f);break;case"tspan":g("dx",e),g("dy",f);break;default:g(b,e)}return h.removeChild(j),i}function r(a){e(a,"array")||(a=Array.prototype.slice.call(arguments,0));for(var b=0,c=0,d=this.node;this[b];)delete this[b++];for(b=0;bc;c++){var e={type:a[c].type,attr:a[c].attr()},f=a[c].children();b.push(e),f.length&&x(f,e.childNodes=[])}}c.version="0.4.0",c.toString=function(){return"Snap v"+this.version},c._={};var y={win:a.window,doc:a.window.document};c._.glob=y;{var z="hasOwnProperty",A=String,B=parseFloat,C=parseInt,D=Math,E=D.max,F=D.min,G=D.abs,H=(D.pow,D.PI),I=(D.round,""),J=Object.prototype.toString,K=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,L=(c._.separator=/[,\s]+/,/[\s]*,[\s]*/),M={hs:1,rg:1},N=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/gi,O=/([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/gi,P=/(-?\d*\.?\d*(?:e[\-+]?\\d+)?)[\s]*,?[\s]*/gi,Q=0,R="S"+(+new Date).toString(36),S=function(a){return(a&&a.type?a.type:I)+R+(Q++).toString(36)},T="http://www.w3.org/1999/xlink",U="http://www.w3.org/2000/svg",V={};c.url=function(a){return"url('#"+a+"')"}}c._.$=d,c._.id=S,c.format=function(){var a=/\{([^\}]+)\}/g,b=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,c=function(a,c,d){var e=d;return c.replace(b,function(a,b,c,d,f){b=b||d,e&&(b in e&&(e=e[b]),"function"==typeof e&&f&&(e=e()))}),e=(null==e||e==d?a:e)+""};return function(b,d){return A(b).replace(a,function(a,b){return c(a,b,d)})}}(),c._.clone=f,c._.cacher=i,c.rad=k,c.deg=l,c.sin=function(a){return D.sin(c.rad(a))},c.tan=function(a){return D.tan(c.rad(a))},c.cos=function(a){return D.cos(c.rad(a))},c.asin=function(a){return c.deg(D.asin(a))},c.acos=function(a){return c.deg(D.acos(a))},c.atan=function(a){return c.deg(D.atan(a))},c.atan2=function(a){return c.deg(D.atan2(a))},c.angle=j,c.len=function(a,b,d,e){return Math.sqrt(c.len2(a,b,d,e))},c.len2=function(a,b,c,d){return(a-c)*(a-c)+(b-d)*(b-d)},c.closestPoint=function(a,b,c){function d(a){var d=a.x-b,e=a.y-c;return d*d+e*e}for(var e,f,g,h,i=a.node,j=i.getTotalLength(),k=j/i.pathSegList.numberOfItems*.125,l=1/0,m=0;j>=m;m+=k)(h=d(g=i.getPointAtLength(m))).5;){var n,o,p,q,r,s;(p=f-k)>=0&&(r=d(n=i.getPointAtLength(p)))f)return b-f;if(f>a-c)return b-f+a}return b},c.getRGB=i(function(a){if(!a||(a=A(a)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z};if("none"==a)return{r:-1,g:-1,b:-1,hex:"none",toString:Z};if(!(M[z](a.toLowerCase().substring(0,2))||"#"==a.charAt())&&(a=W(a)),!a)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z};var b,d,f,g,h,i,j=a.match(K);return j?(j[2]&&(f=C(j[2].substring(5),16),d=C(j[2].substring(3,5),16),b=C(j[2].substring(1,3),16)),j[3]&&(f=C((h=j[3].charAt(3))+h,16),d=C((h=j[3].charAt(2))+h,16),b=C((h=j[3].charAt(1))+h,16)),j[4]&&(i=j[4].split(L),b=B(i[0]),"%"==i[0].slice(-1)&&(b*=2.55),d=B(i[1]),"%"==i[1].slice(-1)&&(d*=2.55),f=B(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),"rgba"==j[1].toLowerCase().slice(0,4)&&(g=B(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100)),j[5]?(i=j[5].split(L),b=B(i[0]),"%"==i[0].slice(-1)&&(b/=100),d=B(i[1]),"%"==i[1].slice(-1)&&(d/=100),f=B(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(b/=360),"hsba"==j[1].toLowerCase().slice(0,4)&&(g=B(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),c.hsb2rgb(b,d,f,g)):j[6]?(i=j[6].split(L),b=B(i[0]),"%"==i[0].slice(-1)&&(b/=100),d=B(i[1]),"%"==i[1].slice(-1)&&(d/=100),f=B(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(b/=360),"hsla"==j[1].toLowerCase().slice(0,4)&&(g=B(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),c.hsl2rgb(b,d,f,g)):(b=F(D.round(b),255),d=F(D.round(d),255),f=F(D.round(f),255),g=F(E(g,0),1),j={r:b,g:d,b:f,toString:Z},j.hex="#"+(16777216|f|d<<8|b<<16).toString(16).slice(1),j.opacity=e(g,"finite")?g:1,j)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z}},c),c.hsb=i(function(a,b,d){return c.hsb2rgb(a,b,d).hex}),c.hsl=i(function(a,b,d){return c.hsl2rgb(a,b,d).hex}),c.rgb=i(function(a,b,c,d){if(e(d,"finite")){var f=D.round;return"rgba("+[f(a),f(b),f(c),+d.toFixed(2)]+")"}return"#"+(16777216|c|b<<8|a<<16).toString(16).slice(1)});var W=function(a){var b=y.doc.getElementsByTagName("head")[0]||y.doc.getElementsByTagName("svg")[0],c="rgb(255, 0, 0)";return(W=i(function(a){if("red"==a.toLowerCase())return c;b.style.color=c,b.style.color=a;var d=y.doc.defaultView.getComputedStyle(b,I).getPropertyValue("color");return d==c?null:d}))(a)},X=function(){return"hsb("+[this.h,this.s,this.b]+")"},Y=function(){return"hsl("+[this.h,this.s,this.l]+")"},Z=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},$=function(a,b,d){if(null==b&&e(a,"object")&&"r"in a&&"g"in a&&"b"in a&&(d=a.b,b=a.g,a=a.r),null==b&&e(a,string)){var f=c.getRGB(a);a=f.r,b=f.g,d=f.b}return(a>1||b>1||d>1)&&(a/=255,b/=255,d/=255),[a,b,d]},_=function(a,b,d,f){a=D.round(255*a),b=D.round(255*b),d=D.round(255*d);var g={r:a,g:b,b:d,opacity:e(f,"finite")?f:1,hex:c.rgb(a,b,d),toString:Z};return e(f,"finite")&&(g.opacity=f),g};c.color=function(a){var b;return e(a,"object")&&"h"in a&&"s"in a&&"b"in a?(b=c.hsb2rgb(a),a.r=b.r,a.g=b.g,a.b=b.b,a.opacity=1,a.hex=b.hex):e(a,"object")&&"h"in a&&"s"in a&&"l"in a?(b=c.hsl2rgb(a),a.r=b.r,a.g=b.g,a.b=b.b,a.opacity=1,a.hex=b.hex):(e(a,"string")&&(a=c.getRGB(a)),e(a,"object")&&"r"in a&&"g"in a&&"b"in a&&!("error"in a)?(b=c.rgb2hsl(a),a.h=b.h,a.s=b.s,a.l=b.l,b=c.rgb2hsb(a),a.v=b.b):(a={hex:"none"},a.r=a.g=a.b=a.h=a.s=a.v=a.l=-1,a.error=1)),a.toString=Z,a},c.hsb2rgb=function(a,b,c,d){e(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(c=a.b,b=a.s,d=a.o,a=a.h),a*=360;var f,g,h,i,j;return a=a%360/60,j=c*b,i=j*(1-G(a%2-1)),f=g=h=c-j,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,d)},c.hsl2rgb=function(a,b,c,d){e(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(c=a.l,b=a.s,a=a.h),(a>1||b>1||c>1)&&(a/=360,b/=100,c/=100),a*=360;var f,g,h,i,j;return a=a%360/60,j=2*b*(.5>c?c:1-c),i=j*(1-G(a%2-1)),f=g=h=c-j/2,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,d)},c.rgb2hsb=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;return f=E(a,b,c),g=f-F(a,b,c),d=0==g?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=(d+360)%6*60/360,e=0==g?0:g/f,{h:d,s:e,b:f,toString:X}},c.rgb2hsl=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;return g=E(a,b,c),h=F(a,b,c),i=g-h,d=0==i?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=(d+360)%6*60/360,f=(g+h)/2,e=0==i?0:.5>f?i/(2*f):i/(2-2*f),{h:d,s:e,l:f,toString:Y}},c.parsePathString=function(a){if(!a)return null;var b=c.path(a);if(b.arr)return c.path.clone(b.arr);var d={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},f=[];return e(a,"array")&&e(a[0],"array")&&(f=c.path.clone(a)),f.length||A(a).replace(N,function(a,b,c){var e=[],g=b.toLowerCase();if(c.replace(P,function(a,b){b&&e.push(+b)}),"m"==g&&e.length>2&&(f.push([b].concat(e.splice(0,2))),g="l",b="m"==b?"l":"L"),"o"==g&&1==e.length&&f.push([b,e[0]]),"r"==g)f.push([b].concat(e));else for(;e.length>=d[g]&&(f.push([b].concat(e.splice(0,d[g]))),d[g]););}),f.toString=c.path.toString,b.arr=c.path.clone(f),f};var ab=c.parseTransformString=function(a){if(!a)return null;var b=[];return e(a,"array")&&e(a[0],"array")&&(b=c.path.clone(a)),b.length||A(a).replace(O,function(a,c,d){{var e=[];c.toLowerCase()}d.replace(P,function(a,b){b&&e.push(+b)}),b.push([c].concat(e))}),b.toString=c.path.toString,b};c._.svgTransform2string=m,c._.rgTransform=/^[a-z][\s]*-?\.?\d/i,c._.transform2matrix=n,c._unit2px=q;y.doc.contains||y.doc.compareDocumentPosition?function(a,b){var c=9==a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a==d||!(!d||1!=d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b;)if(b=b.parentNode,b==a)return!0;return!1};c._.getSomeDefs=o,c._.getSomeSVG=p,c.select=function(a){return a=A(a).replace(/([^\\]):/g,"$1\\:"),w(y.doc.querySelector(a))},c.selectAll=function(a){for(var b=y.doc.querySelectorAll(a),d=(c.set||Array)(),e=0;ei;i++)h[g[i].nodeName]=g[i].nodeValue;return h}if(e(a,"string")){if(!(arguments.length>1))return b("snap.util.getattr."+a,d).firstDefined();var k={};k[a]=c,a=k}for(var l in a)a[z](l)&&b("snap.util.attr."+l,d,a[l]);return d},c.parse=function(a){var b=y.doc.createDocumentFragment(),c=!0,d=y.doc.createElement("div");if(a=A(a),a.match(/^\s*<\s*svg(?:\s|>)/)||(a=""+a+"",c=!1),d.innerHTML=a,a=d.getElementsByTagName("svg")[0])if(c)b=a;else for(;a.firstChild;)b.appendChild(a.firstChild);return new t(b)},c.fragment=function(){for(var a=Array.prototype.slice.call(arguments,0),b=y.doc.createDocumentFragment(),d=0,e=a.length;e>d;d++){var f=a[d];f.node&&f.node.nodeType&&b.appendChild(f.node),f.nodeType&&b.appendChild(f),"string"==typeof f&&b.appendChild(c.parse(f).node)}return new t(b)},c._.make=u,c._.wrap=w,v.prototype.el=function(a,b){var c=u(a,this.node);return b&&c.attr(b),c},s.prototype.children=function(){for(var a=[],b=this.node.childNodes,d=0,e=b.length;e>d;d++)a[d]=c(b[d]);return a},s.prototype.toJSON=function(){var a=[];return x([this],a),a[0]},b.on("snap.util.getattr",function(){var a=b.nt();a=a.substring(a.lastIndexOf(".")+1);var c=a.replace(/[A-Z]/g,function(a){return"-"+a.toLowerCase()});return bb[z](c)?this.node.ownerDocument.defaultView.getComputedStyle(this.node,null).getPropertyValue(c):d(this.node,a)});var bb={"alignment-baseline":0,"baseline-shift":0,clip:0,"clip-path":0,"clip-rule":0,color:0,"color-interpolation":0,"color-interpolation-filters":0,"color-profile":0,"color-rendering":0,cursor:0,direction:0,display:0,"dominant-baseline":0,"enable-background":0,fill:0,"fill-opacity":0,"fill-rule":0,filter:0,"flood-color":0,"flood-opacity":0,font:0,"font-family":0,"font-size":0,"font-size-adjust":0,"font-stretch":0,"font-style":0,"font-variant":0,"font-weight":0,"glyph-orientation-horizontal":0,"glyph-orientation-vertical":0,"image-rendering":0,kerning:0,"letter-spacing":0,"lighting-color":0,marker:0,"marker-end":0,"marker-mid":0,"marker-start":0,mask:0,opacity:0,overflow:0,"pointer-events":0,"shape-rendering":0,"stop-color":0,"stop-opacity":0,stroke:0,"stroke-dasharray":0,"stroke-dashoffset":0,"stroke-linecap":0,"stroke-linejoin":0,"stroke-miterlimit":0,"stroke-opacity":0,"stroke-width":0,"text-anchor":0,"text-decoration":0,"text-rendering":0,"unicode-bidi":0,visibility:0,"word-spacing":0,"writing-mode":0};b.on("snap.util.attr",function(a){var c=b.nt(),e={};c=c.substring(c.lastIndexOf(".")+1),e[c]=a;var f=c.replace(/-(\w)/gi,function(a,b){return b.toUpperCase()}),g=c.replace(/[A-Z]/g,function(a){return"-"+a.toLowerCase()});bb[z](g)?this.node.style[f]=null==a?I:a:d(this.node,e)}),function(){}(v.prototype),c.ajax=function(a,c,d,f){var g=new XMLHttpRequest,h=S();if(g){if(e(c,"function"))f=d,d=c,c=null;else if(e(c,"object")){var i=[];for(var j in c)c.hasOwnProperty(j)&&i.push(encodeURIComponent(j)+"="+encodeURIComponent(c[j]));c=i.join("&")}return g.open(c?"POST":"GET",a,!0),c&&(g.setRequestHeader("X-Requested-With","XMLHttpRequest"),g.setRequestHeader("Content-type","application/x-www-form-urlencoded")),d&&(b.once("snap.ajax."+h+".0",d),b.once("snap.ajax."+h+".200",d),b.once("snap.ajax."+h+".304",d)),g.onreadystatechange=function(){4==g.readyState&&b("snap.ajax."+h+"."+g.status,f,g)},4==g.readyState?g:(g.send(c),g)}},c.load=function(a,b,d){c.ajax(a,function(a){var e=c.parse(a.responseText);d?b.call(d,e):b(e)})};var cb=function(a){var b=a.getBoundingClientRect(),c=a.ownerDocument,d=c.body,e=c.documentElement,f=e.clientTop||d.clientTop||0,h=e.clientLeft||d.clientLeft||0,i=b.top+(g.win.pageYOffset||e.scrollTop||d.scrollTop)-f,j=b.left+(g.win.pageXOffset||e.scrollLeft||d.scrollLeft)-h;return{y:i,x:j}};return c.getElementByPoint=function(a,b){var c=this,d=(c.canvas,y.doc.elementFromPoint(a,b));if(y.win.opera&&"svg"==d.tagName){var e=cb(d),f=d.createSVGRect();f.x=a-e.x,f.y=b-e.y,f.width=f.height=1;var g=d.getIntersectionList(f,null);g.length&&(d=g[g.length-1])}return d?w(d):null},c.plugin=function(a){a(c,s,v,y,t)},y.win.Snap=c,c}(a||this);return d.plugin(function(d,e,f,g,h){function i(a,b){if(null==b){var c=!0;if(b=a.node.getAttribute("linearGradient"==a.type||"radialGradient"==a.type?"gradientTransform":"pattern"==a.type?"patternTransform":"transform"),!b)return new d.Matrix;b=d._.svgTransform2string(b)}else b=d._.rgTransform.test(b)?o(b).replace(/\.{3}|\u2026/g,a._.transform||""):d._.svgTransform2string(b),n(b,"array")&&(b=d.path?d.path.toString.call(b):o(b)),a._.transform=b;var e=d._.transform2matrix(b,a.getBBox(1));return c?e:void(a.matrix=e)}function j(a){function b(a,b){var c=q(a.node,b);c=c&&c.match(f),c=c&&c[2],c&&"#"==c.charAt()&&(c=c.substring(1),c&&(h[c]=(h[c]||[]).concat(function(c){var d={};d[b]=URL(c),q(a.node,d)})))}function c(a){var b=q(a.node,"xlink:href");b&&"#"==b.charAt()&&(b=b.substring(1),b&&(h[b]=(h[b]||[]).concat(function(b){a.attr("xlink:href","#"+b)})))}for(var d,e=a.selectAll("*"),f=/^\s*url\(("|'|)(.*)\1\)\s*$/,g=[],h={},i=0,j=e.length;j>i;i++){d=e[i],b(d,"fill"),b(d,"stroke"),b(d,"filter"),b(d,"mask"),b(d,"clip-path"),c(d);var k=q(d.node,"id");k&&(q(d.node,{id:d.id}),g.push({old:k,id:d.id}))}for(i=0,j=g.length;j>i;i++){var l=h[g[i].old];if(l)for(var m=0,n=l.length;n>m;m++)l[m](g[i].id)}}function k(a,b,c){return function(d){var e=d.slice(a,b);return 1==e.length&&(e=e[0]),c?c(e):e}}function l(a){return function(){var b=a?"<"+this.type:"",c=this.node.attributes,d=this.node.childNodes;if(a)for(var e=0,f=c.length;f>e;e++)b+=" "+c[e].name+'="'+c[e].value.replace(/"/g,'\\"')+'"';if(d.length){for(a&&(b+=">"),e=0,f=d.length;f>e;e++)3==d[e].nodeType?b+=d[e].nodeValue:1==d[e].nodeType&&(b+=u(d[e]).toString());a&&(b+="")}else a&&(b+="/>");return b}}var m=e.prototype,n=d.is,o=String,p=d._unit2px,q=d._.$,r=d._.make,s=d._.getSomeDefs,t="hasOwnProperty",u=d._.wrap;m.getBBox=function(a){if(!d.Matrix||!d.path)return this.node.getBBox();var b=this,c=new d.Matrix;if(b.removed)return d._.box();for(;"use"==b.type;)if(a||(c=c.add(b.transform().localMatrix.translate(b.attr("x")||0,b.attr("y")||0))),b.original)b=b.original;else{var e=b.attr("xlink:href");b=b.original=b.node.ownerDocument.getElementById(e.substring(e.indexOf("#")+1))}var f=b._,g=d.path.get[b.type]||d.path.get.deflt;try{return a?(f.bboxwt=g?d.path.getBBox(b.realPath=g(b)):d._.box(b.node.getBBox()),d._.box(f.bboxwt)):(b.realPath=g(b),b.matrix=b.transform().localMatrix,f.bbox=d.path.getBBox(d.path.map(b.realPath,c.add(b.matrix))),d._.box(f.bbox))}catch(h){return d._.box()}};var v=function(){return this.string};m.transform=function(a){var b=this._;if(null==a){for(var c,e=this,f=new d.Matrix(this.node.getCTM()),g=i(this),h=[g],j=new d.Matrix,k=g.toTransformString(),l=o(g)==o(this.matrix)?o(b.transform):k;"svg"!=e.type&&(e=e.parent());)h.push(i(e));for(c=h.length;c--;)j.add(h[c]);return{string:l,globalMatrix:f,totalMatrix:j,localMatrix:g,diffMatrix:f.clone().add(g.invert()),global:f.toTransformString(),total:j.toTransformString(),local:k,toString:v}}return a instanceof d.Matrix?(this.matrix=a,this._.transform=a.toTransformString()):i(this,a),this.node&&("linearGradient"==this.type||"radialGradient"==this.type?q(this.node,{gradientTransform:this.matrix}):"pattern"==this.type?q(this.node,{patternTransform:this.matrix}):q(this.node,{transform:this.matrix})),this},m.parent=function(){return u(this.node.parentNode)},m.append=m.add=function(a){if(a){if("set"==a.type){var b=this;return a.forEach(function(a){b.add(a)}),this}a=u(a),this.node.appendChild(a.node),a.paper=this.paper}return this},m.appendTo=function(a){return a&&(a=u(a),a.append(this)),this},m.prepend=function(a){if(a){if("set"==a.type){var b,c=this;return a.forEach(function(a){b?b.after(a):c.prepend(a),b=a}),this}a=u(a);var d=a.parent();this.node.insertBefore(a.node,this.node.firstChild),this.add&&this.add(),a.paper=this.paper,this.parent()&&this.parent().add(),d&&d.add()}return this},m.prependTo=function(a){return a=u(a),a.prepend(this),this},m.before=function(a){if("set"==a.type){var b=this;return a.forEach(function(a){var c=a.parent();b.node.parentNode.insertBefore(a.node,b.node),c&&c.add()}),this.parent().add(),this}a=u(a);var c=a.parent();return this.node.parentNode.insertBefore(a.node,this.node),this.parent()&&this.parent().add(),c&&c.add(),a.paper=this.paper,this},m.after=function(a){a=u(a);var b=a.parent();return this.node.nextSibling?this.node.parentNode.insertBefore(a.node,this.node.nextSibling):this.node.parentNode.appendChild(a.node),this.parent()&&this.parent().add(),b&&b.add(),a.paper=this.paper,this},m.insertBefore=function(a){a=u(a);var b=this.parent();return a.node.parentNode.insertBefore(this.node,a.node),this.paper=a.paper,b&&b.add(),a.parent()&&a.parent().add(),this},m.insertAfter=function(a){a=u(a);var b=this.parent();return a.node.parentNode.insertBefore(this.node,a.node.nextSibling),this.paper=a.paper,b&&b.add(),a.parent()&&a.parent().add(),this},m.remove=function(){var a=this.parent();return this.node.parentNode&&this.node.parentNode.removeChild(this.node),delete this.paper,this.removed=!0,a&&a.add(),this},m.select=function(a){return u(this.node.querySelector(a))},m.selectAll=function(a){for(var b=this.node.querySelectorAll(a),c=(d.set||Array)(),e=0;eb;b++)a[b].stop();return this},m.animate=function(a,d,e,f){"function"!=typeof e||e.length||(f=e,e=c.linear),a instanceof w&&(f=a.callback,e=a.easing,d=a.dur,a=a.attr);var g,h,i,j,l=[],m=[],p={},q=this;for(var r in a)if(a[t](r)){q.equal?(j=q.equal(r,o(a[r])),g=j.from,h=j.to,i=j.f):(g=+q.attr(r),h=+a[r]);var s=n(g,"array")?g.length:1;p[r]=k(l.length,l.length+s,i),l=l.concat(g),m=m.concat(h)}var u=c.time(),v=c(l,m,u,u+d,c.time,function(a){var b={};for(var c in p)p[t](c)&&(b[c]=p[c](a));q.attr(b)},e);return q.anims[v.id]=v,v._attrs=a,v._callback=f,b("snap.animcreated."+q.id,v),b.once("mina.finish."+v.id,function(){delete q.anims[v.id],f&&f.call(q)}),b.once("mina.stop."+v.id,function(){delete q.anims[v.id]}),q};var x={};m.data=function(a,c){var e=x[this.id]=x[this.id]||{};if(0==arguments.length)return b("snap.data.get."+this.id,this,e,null),e; 20 | if(1==arguments.length){if(d.is(a,"object")){for(var f in a)a[t](f)&&this.data(f,a[f]);return this}return b("snap.data.get."+this.id,this,e[a],a),e[a]}return e[a]=c,b("snap.data.set."+this.id,this,c,a),this},m.removeData=function(a){return null==a?x[this.id]={}:x[this.id]&&delete x[this.id][a],this},m.outerSVG=m.toString=l(1),m.innerSVG=l(),m.toDataURL=function(){if(a&&a.btoa){var b=this.getBBox(),c=d.format('{contents}',{x:+b.x.toFixed(3),y:+b.y.toFixed(3),width:+b.width.toFixed(3),height:+b.height.toFixed(3),contents:this.outerSVG()});return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(c)))}},h.prototype.select=m.select,h.prototype.selectAll=m.selectAll}),d.plugin(function(a){function b(a,b,d,e,f,g){return null==b&&"[object SVGMatrix]"==c.call(a)?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.e=a.e,void(this.f=a.f)):void(null!=a?(this.a=+a,this.b=+b,this.c=+d,this.d=+e,this.e=+f,this.f=+g):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0))}var c=Object.prototype.toString,d=String,e=Math,f="";!function(c){function g(a){return a[0]*a[0]+a[1]*a[1]}function h(a){var b=e.sqrt(g(a));a[0]&&(a[0]/=b),a[1]&&(a[1]/=b)}c.add=function(a,c,d,e,f,g){var h,i,j,k,l=[[],[],[]],m=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],n=[[a,d,f],[c,e,g],[0,0,1]];for(a&&a instanceof b&&(n=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),h=0;3>h;h++)for(i=0;3>i;i++){for(k=0,j=0;3>j;j++)k+=m[h][j]*n[j][i];l[h][i]=k}return this.a=l[0][0],this.b=l[1][0],this.c=l[0][1],this.d=l[1][1],this.e=l[0][2],this.f=l[1][2],this},c.invert=function(){var a=this,c=a.a*a.d-a.b*a.c;return new b(a.d/c,-a.b/c,-a.c/c,a.a/c,(a.c*a.f-a.d*a.e)/c,(a.b*a.e-a.a*a.f)/c)},c.clone=function(){return new b(this.a,this.b,this.c,this.d,this.e,this.f)},c.translate=function(a,b){return this.add(1,0,0,1,a,b)},c.scale=function(a,b,c,d){return null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d),this},c.rotate=function(b,c,d){b=a.rad(b),c=c||0,d=d||0;var f=+e.cos(b).toFixed(9),g=+e.sin(b).toFixed(9);return this.add(f,g,-g,f,c,d),this.add(1,0,0,1,-c,-d)},c.x=function(a,b){return a*this.a+b*this.c+this.e},c.y=function(a,b){return a*this.b+b*this.d+this.f},c.get=function(a){return+this[d.fromCharCode(97+a)].toFixed(4)},c.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},c.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},c.determinant=function(){return this.a*this.d-this.b*this.c},c.split=function(){var b={};b.dx=this.e,b.dy=this.f;var c=[[this.a,this.c],[this.b,this.d]];b.scalex=e.sqrt(g(c[0])),h(c[0]),b.shear=c[0][0]*c[1][0]+c[0][1]*c[1][1],c[1]=[c[1][0]-c[0][0]*b.shear,c[1][1]-c[0][1]*b.shear],b.scaley=e.sqrt(g(c[1])),h(c[1]),b.shear/=b.scaley,this.determinant()<0&&(b.scalex=-b.scalex);var d=-c[0][1],f=c[1][1];return 0>f?(b.rotate=a.deg(e.acos(f)),0>d&&(b.rotate=360-b.rotate)):b.rotate=a.deg(e.asin(d)),b.isSimple=!(+b.shear.toFixed(9)||b.scalex.toFixed(9)!=b.scaley.toFixed(9)&&b.rotate),b.isSuperSimple=!+b.shear.toFixed(9)&&b.scalex.toFixed(9)==b.scaley.toFixed(9)&&!b.rotate,b.noRotation=!+b.shear.toFixed(9)&&!b.rotate,b},c.toTransformString=function(a){var b=a||this.split();return+b.shear.toFixed(9)?"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]:(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[+b.dx.toFixed(4),+b.dy.toFixed(4)]:f)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:f)+(b.rotate?"r"+[+b.rotate.toFixed(4),0,0]:f))}}(b.prototype),a.Matrix=b,a.matrix=function(a,c,d,e,f,g){return new b(a,c,d,e,f,g)}}),d.plugin(function(a,c,d,e,f){function g(d){return function(e){if(b.stop(),e instanceof f&&1==e.node.childNodes.length&&("radialGradient"==e.node.firstChild.tagName||"linearGradient"==e.node.firstChild.tagName||"pattern"==e.node.firstChild.tagName)&&(e=e.node.firstChild,n(this).appendChild(e),e=l(e)),e instanceof c)if("radialGradient"==e.type||"linearGradient"==e.type||"pattern"==e.type){e.node.id||p(e.node,{id:e.id});var g=q(e.node.id)}else g=e.attr(d);else if(g=a.color(e),g.error){var h=a(n(this).ownerSVGElement).gradient(e);h?(h.node.id||p(h.node,{id:h.id}),g=q(h.node.id)):g=e}else g=r(g);var i={};i[d]=g,p(this.node,i),this.node.style[d]=t}}function h(a){b.stop(),a==+a&&(a+="px"),this.node.style.fontSize=a}function i(a){for(var b=[],c=a.childNodes,d=0,e=c.length;e>d;d++){var f=c[d];3==f.nodeType&&b.push(f.nodeValue),"tspan"==f.tagName&&b.push(1==f.childNodes.length&&3==f.firstChild.nodeType?f.firstChild.nodeValue:i(f))}return b}function j(){return b.stop(),this.node.style.fontSize}var k=a._.make,l=a._.wrap,m=a.is,n=a._.getSomeDefs,o=/^url\(#?([^)]+)\)$/,p=a._.$,q=a.url,r=String,s=a._.separator,t="";b.on("snap.util.attr.mask",function(a){if(a instanceof c||a instanceof f){if(b.stop(),a instanceof f&&1==a.node.childNodes.length&&(a=a.node.firstChild,n(this).appendChild(a),a=l(a)),"mask"==a.type)var d=a;else d=k("mask",n(this)),d.node.appendChild(a.node);!d.node.id&&p(d.node,{id:d.id}),p(this.node,{mask:q(d.id)})}}),function(a){b.on("snap.util.attr.clip",a),b.on("snap.util.attr.clip-path",a),b.on("snap.util.attr.clipPath",a)}(function(a){if(a instanceof c||a instanceof f){if(b.stop(),"clipPath"==a.type)var d=a;else d=k("clipPath",n(this)),d.node.appendChild(a.node),!d.node.id&&p(d.node,{id:d.id});p(this.node,{"clip-path":q(d.node.id||d.id)})}}),b.on("snap.util.attr.fill",g("fill")),b.on("snap.util.attr.stroke",g("stroke"));var u=/^([lr])(?:\(([^)]*)\))?(.*)$/i;b.on("snap.util.grad.parse",function(a){a=r(a);var b=a.match(u);if(!b)return null;var c=b[1],d=b[2],e=b[3];return d=d.split(/\s*,\s*/).map(function(a){return+a==a?+a:a}),1==d.length&&0==d[0]&&(d=[]),e=e.split("-"),e=e.map(function(a){a=a.split(":");var b={color:a[0]};return a[1]&&(b.offset=parseFloat(a[1])),b}),{type:c,params:d,stops:e}}),b.on("snap.util.attr.d",function(c){b.stop(),m(c,"array")&&m(c[0],"array")&&(c=a.path.toString.call(c)),c=r(c),c.match(/[ruo]/i)&&(c=a.path.toAbsolute(c)),p(this.node,{d:c})})(-1),b.on("snap.util.attr.#text",function(a){b.stop(),a=r(a);for(var c=e.doc.createTextNode(a);this.node.firstChild;)this.node.removeChild(this.node.firstChild);this.node.appendChild(c)})(-1),b.on("snap.util.attr.path",function(a){b.stop(),this.attr({d:a})})(-1),b.on("snap.util.attr.class",function(a){b.stop(),this.node.className.baseVal=a})(-1),b.on("snap.util.attr.viewBox",function(a){var c;c=m(a,"object")&&"x"in a?[a.x,a.y,a.width,a.height].join(" "):m(a,"array")?a.join(" "):a,p(this.node,{viewBox:c}),b.stop()})(-1),b.on("snap.util.attr.transform",function(a){this.transform(a),b.stop()})(-1),b.on("snap.util.attr.r",function(a){"rect"==this.type&&(b.stop(),p(this.node,{rx:a,ry:a}))})(-1),b.on("snap.util.attr.textpath",function(a){if(b.stop(),"text"==this.type){var d,e,f;if(!a&&this.textPath){for(e=this.textPath;e.node.firstChild;)this.node.appendChild(e.node.firstChild);return e.remove(),void delete this.textPath}if(m(a,"string")){var g=n(this),h=l(g.parentNode).path(a);g.appendChild(h.node),d=h.id,h.attr({id:d})}else a=l(a),a instanceof c&&(d=a.attr("id"),d||(d=a.id,a.attr({id:d})));if(d)if(e=this.textPath,f=this.node,e)e.attr({"xlink:href":"#"+d});else{for(e=p("textPath",{"xlink:href":"#"+d});f.firstChild;)e.appendChild(f.firstChild);f.appendChild(e),this.textPath=l(e)}}})(-1),b.on("snap.util.attr.text",function(a){if("text"==this.type){for(var c=this.node,d=function(a){var b=p("tspan");if(m(a,"array"))for(var c=0;c1&&(a=Array.prototype.slice.call(arguments,0));var b={};return h(a,"object")&&!h(a,"array")?b=a:null!=a&&(b={points:a}),this.el("polyline",b)},g.polygon=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b={};return h(a,"object")&&!h(a,"array")?b=a:null!=a&&(b={points:a}),this.el("polygon",b)},function(){function d(){return this.selectAll("stop")}function e(a,b){var d=k("stop"),e={offset:+b+"%"};return a=c.color(a),e["stop-color"]=a.hex,a.opacity<1&&(e["stop-opacity"]=a.opacity),k(d,e),this.node.appendChild(d),this}function f(){if("linearGradient"==this.type){var a=k(this.node,"x1")||0,b=k(this.node,"x2")||1,d=k(this.node,"y1")||0,e=k(this.node,"y2")||0;return c._.box(a,d,math.abs(b-a),math.abs(e-d))}var f=this.node.cx||.5,g=this.node.cy||.5,h=this.node.r||0;return c._.box(f-h,g-h,2*h,2*h)}function h(a,c){function d(a,b){for(var c=(b-l)/(a-m),d=m;a>d;d++)g[d].offset=+(+l+c*(d-m)).toFixed(2);m=a,l=b}var e,f=b("snap.util.grad.parse",null,c).firstDefined();if(!f)return null;f.params.unshift(a),e="l"==f.type.toLowerCase()?i.apply(0,f.params):j.apply(0,f.params),f.type!=f.type.toLowerCase()&&k(e.node,{gradientUnits:"userSpaceOnUse"});var g=f.stops,h=g.length,l=0,m=0;h--;for(var n=0;h>n;n++)"offset"in g[n]&&d(n,g[n].offset);for(g[h].offset=g[h].offset||100,d(h,g[h].offset),n=0;h>=n;n++){var o=g[n];e.addStop(o.color,o.offset)}return e}function i(a,b,g,h,i){var j=c._.make("linearGradient",a);return j.stops=d,j.addStop=e,j.getBBox=f,null!=b&&k(j.node,{x1:b,y1:g,x2:h,y2:i}),j}function j(a,b,g,h,i,j){var l=c._.make("radialGradient",a);return l.stops=d,l.addStop=e,l.getBBox=f,null!=b&&k(l.node,{cx:b,cy:g,r:h}),null!=i&&null!=j&&k(l.node,{fx:i,fy:j}),l}var k=c._.$;g.gradient=function(a){return h(this.defs,a)},g.gradientLinear=function(a,b,c,d){return i(this.defs,a,b,c,d)},g.gradientRadial=function(a,b,c,d,e){return j(this.defs,a,b,c,d,e)},g.toString=function(){var a,b=this.node.ownerDocument,d=b.createDocumentFragment(),e=b.createElement("div"),f=this.node.cloneNode(!0);return d.appendChild(e),e.appendChild(f),c._.$(f,{xmlns:"http://www.w3.org/2000/svg"}),a=e.innerHTML,d.removeChild(d.firstChild),a},g.toDataURL=function(){return a&&a.btoa?"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(this))):void 0},g.clear=function(){for(var a,b=this.node.firstChild;b;)a=b.nextSibling,"defs"!=b.tagName?b.parentNode.removeChild(b):g.clear.call({node:b}),b=a}}()}),d.plugin(function(a,b){function c(a){var b=c.ps=c.ps||{};return b[a]?b[a].sleep=100:b[a]={sleep:100},setTimeout(function(){for(var c in b)b[K](c)&&c!=a&&(b[c].sleep--,!b[c].sleep&&delete b[c])}),b[a]}function d(a,b,c,d){return null==a&&(a=b=c=d=0),null==b&&(b=a.y,c=a.width,d=a.height,a=a.x),{x:a,y:b,width:c,w:c,height:d,h:d,x2:a+c,y2:b+d,cx:a+c/2,cy:b+d/2,r1:N.min(c,d)/2,r2:N.max(c,d)/2,r0:N.sqrt(c*c+d*d)/2,path:w(a,b,c,d),vb:[a,b,c,d].join(" ")}}function e(){return this.join(",").replace(L,"$1")}function f(a){var b=J(a);return b.toString=e,b}function g(a,b,c,d,e,f,g,h,j){return null==j?n(a,b,c,d,e,f,g,h):i(a,b,c,d,e,f,g,h,o(a,b,c,d,e,f,g,h,j))}function h(c,d){function e(a){return+(+a).toFixed(3)}return a._.cacher(function(a,f,h){a instanceof b&&(a=a.attr("d")),a=E(a);for(var j,k,l,m,n,o="",p={},q=0,r=0,s=a.length;s>r;r++){if(l=a[r],"M"==l[0])j=+l[1],k=+l[2];else{if(m=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6]),q+m>f){if(d&&!p.start){if(n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q),o+=["C"+e(n.start.x),e(n.start.y),e(n.m.x),e(n.m.y),e(n.x),e(n.y)],h)return o;p.start=o,o=["M"+e(n.x),e(n.y)+"C"+e(n.n.x),e(n.n.y),e(n.end.x),e(n.end.y),e(l[5]),e(l[6])].join(),q+=m,j=+l[5],k=+l[6];continue}if(!c&&!d)return n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q)}q+=m,j=+l[5],k=+l[6]}o+=l.shift()+l}return p.end=o,n=c?q:d?p:i(j,k,l[0],l[1],l[2],l[3],l[4],l[5],1)},null,a._.clone)}function i(a,b,c,d,e,f,g,h,i){var j=1-i,k=R(j,3),l=R(j,2),m=i*i,n=m*i,o=k*a+3*l*i*c+3*j*i*i*e+n*g,p=k*b+3*l*i*d+3*j*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,w=j*e+i*g,x=j*f+i*h,y=90-180*N.atan2(q-s,r-t)/O;return{x:o,y:p,m:{x:q,y:r},n:{x:s,y:t},start:{x:u,y:v},end:{x:w,y:x},alpha:y}}function j(b,c,e,f,g,h,i,j){a.is(b,"array")||(b=[b,c,e,f,g,h,i,j]);var k=D.apply(null,b);return d(k.min.x,k.min.y,k.max.x-k.min.x,k.max.y-k.min.y)}function k(a,b,c){return b>=a.x&&b<=a.x+a.width&&c>=a.y&&c<=a.y+a.height}function l(a,b){return a=d(a),b=d(b),k(b,a.x,a.y)||k(b,a.x2,a.y)||k(b,a.x,a.y2)||k(b,a.x2,a.y2)||k(a,b.x,b.y)||k(a,b.x2,b.y)||k(a,b.x,b.y2)||k(a,b.x2,b.y2)||(a.xb.x||b.xa.x)&&(a.yb.y||b.ya.y)}function m(a,b,c,d,e){var f=-3*b+9*c-9*d+3*e,g=a*f+6*b-12*c+6*d;return a*g-3*b+3*c}function n(a,b,c,d,e,f,g,h,i){null==i&&(i=1),i=i>1?1:0>i?0:i;for(var j=i/2,k=12,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],n=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],o=0,p=0;k>p;p++){var q=j*l[p]+j,r=m(q,a,c,e,g),s=m(q,b,d,f,h),t=r*r+s*s;o+=n[p]*N.sqrt(t)}return j*o}function o(a,b,c,d,e,f,g,h,i){if(!(0>i||n(a,b,c,d,e,f,g,h)o;)l/=2,m+=(i>j?1:-1)*l,j=n(a,b,c,d,e,f,g,h,m);return m}}function p(a,b,c,d,e,f,g,h){if(!(Q(a,c)Q(e,g)||Q(b,d)Q(f,h))){var i=(a*d-b*c)*(e-g)-(a-c)*(e*h-f*g),j=(a*d-b*c)*(f-h)-(b-d)*(e*h-f*g),k=(a-c)*(f-h)-(b-d)*(e-g);if(k){var l=i/k,m=j/k,n=+l.toFixed(2),o=+m.toFixed(2);if(!(n<+P(a,c).toFixed(2)||n>+Q(a,c).toFixed(2)||n<+P(e,g).toFixed(2)||n>+Q(e,g).toFixed(2)||o<+P(b,d).toFixed(2)||o>+Q(b,d).toFixed(2)||o<+P(f,h).toFixed(2)||o>+Q(f,h).toFixed(2)))return{x:l,y:m}}}}function q(a,b,c){var d=j(a),e=j(b);if(!l(d,e))return c?0:[];for(var f=n.apply(0,a),g=n.apply(0,b),h=~~(f/8),k=~~(g/8),m=[],o=[],q={},r=c?0:[],s=0;h+1>s;s++){var t=i.apply(0,a.concat(s/h));m.push({x:t.x,y:t.y,t:s/h})}for(s=0;k+1>s;s++)t=i.apply(0,b.concat(s/k)),o.push({x:t.x,y:t.y,t:s/k});for(s=0;h>s;s++)for(var u=0;k>u;u++){var v=m[s],w=m[s+1],x=o[u],y=o[u+1],z=S(w.x-v.x)<.001?"y":"x",A=S(y.x-x.x)<.001?"y":"x",B=p(v.x,v.y,w.x,w.y,x.x,x.y,y.x,y.y);if(B){if(q[B.x.toFixed(4)]==B.y.toFixed(4))continue;q[B.x.toFixed(4)]=B.y.toFixed(4);var C=v.t+S((B[z]-v[z])/(w[z]-v[z]))*(w.t-v.t),D=x.t+S((B[A]-x[A])/(y[A]-x[A]))*(y.t-x.t);C>=0&&1>=C&&D>=0&&1>=D&&(c?r++:r.push({x:B.x,y:B.y,t1:C,t2:D}))}}return r}function r(a,b){return t(a,b)}function s(a,b){return t(a,b,1)}function t(a,b,c){a=E(a),b=E(b);for(var d,e,f,g,h,i,j,k,l,m,n=c?0:[],o=0,p=a.length;p>o;o++){var r=a[o];if("M"==r[0])d=h=r[1],e=i=r[2];else{"C"==r[0]?(l=[d,e].concat(r.slice(1)),d=l[6],e=l[7]):(l=[d,e,d,e,h,i,h,i],d=h,e=i);for(var s=0,t=b.length;t>s;s++){var u=b[s];if("M"==u[0])f=j=u[1],g=k=u[2];else{"C"==u[0]?(m=[f,g].concat(u.slice(1)),f=m[6],g=m[7]):(m=[f,g,f,g,j,k,j,k],f=j,g=k);var v=q(l,m,c);if(c)n+=v;else{for(var w=0,x=v.length;x>w;w++)v[w].segment1=o,v[w].segment2=s,v[w].bez1=l,v[w].bez2=m;n=n.concat(v)}}}}}return n}function u(a,b,c){var d=v(a);return k(d,b,c)&&t(a,[["M",b,c],["H",d.x2+10]],1)%2==1}function v(a){var b=c(a);if(b.bbox)return J(b.bbox);if(!a)return d();a=E(a);for(var e,f=0,g=0,h=[],i=[],j=0,k=a.length;k>j;j++)if(e=a[j],"M"==e[0])f=e[1],g=e[2],h.push(f),i.push(g);else{var l=D(f,g,e[1],e[2],e[3],e[4],e[5],e[6]);h=h.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),f=e[5],g=e[6]}var m=P.apply(0,h),n=P.apply(0,i),o=Q.apply(0,h),p=Q.apply(0,i),q=d(m,n,o-m,p-n);return b.bbox=J(q),q}function w(a,b,c,d,f){if(f)return[["M",+a+ +f,b],["l",c-2*f,0],["a",f,f,0,0,1,f,f],["l",0,d-2*f],["a",f,f,0,0,1,-f,f],["l",2*f-c,0],["a",f,f,0,0,1,-f,-f],["l",0,2*f-d],["a",f,f,0,0,1,f,-f],["z"]];var g=[["M",a,b],["l",c,0],["l",0,d],["l",-c,0],["z"]];return g.toString=e,g}function x(a,b,c,d,f){if(null==f&&null==d&&(d=c),a=+a,b=+b,c=+c,d=+d,null!=f)var g=Math.PI/180,h=a+c*Math.cos(-d*g),i=a+c*Math.cos(-f*g),j=b+c*Math.sin(-d*g),k=b+c*Math.sin(-f*g),l=[["M",h,j],["A",c,c,0,+(f-d>180),0,i,k]];else l=[["M",a,b],["m",0,-d],["a",c,d,0,1,1,0,2*d],["a",c,d,0,1,1,0,-2*d],["z"]];return l.toString=e,l}function y(b){var d=c(b),g=String.prototype.toLowerCase;if(d.rel)return f(d.rel);a.is(b,"array")&&a.is(b&&b[0],"array")||(b=a.parsePathString(b));var h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=b[0][1],j=b[0][2],k=i,l=j,m++,h.push(["M",i,j]));for(var n=m,o=b.length;o>n;n++){var p=h[n]=[],q=b[n];if(q[0]!=g.call(q[0]))switch(p[0]=g.call(q[0]),p[0]){case"a":p[1]=q[1],p[2]=q[2],p[3]=q[3],p[4]=q[4],p[5]=q[5],p[6]=+(q[6]-i).toFixed(3),p[7]=+(q[7]-j).toFixed(3);break;case"v":p[1]=+(q[1]-j).toFixed(3);break;case"m":k=q[1],l=q[2];default:for(var r=1,s=q.length;s>r;r++)p[r]=+(q[r]-(r%2?i:j)).toFixed(3)}else{p=h[n]=[],"m"==q[0]&&(k=q[1]+i,l=q[2]+j);for(var t=0,u=q.length;u>t;t++)h[n][t]=q[t]}var v=h[n].length;switch(h[n][0]){case"z":i=k,j=l;break;case"h":i+=+h[n][v-1];break;case"v":j+=+h[n][v-1];break;default:i+=+h[n][v-2],j+=+h[n][v-1]}}return h.toString=e,d.rel=f(h),h}function z(b){var d=c(b);if(d.abs)return f(d.abs);if(I(b,"array")&&I(b&&b[0],"array")||(b=a.parsePathString(b)),!b||!b.length)return[["M",0,0]];var g,h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=+b[0][1],j=+b[0][2],k=i,l=j,m++,h[0]=["M",i,j]);for(var n,o,p=3==b.length&&"M"==b[0][0]&&"R"==b[1][0].toUpperCase()&&"Z"==b[2][0].toUpperCase(),q=m,r=b.length;r>q;q++){if(h.push(n=[]),o=b[q],g=o[0],g!=g.toUpperCase())switch(n[0]=g.toUpperCase(),n[0]){case"A":n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=+o[6]+i,n[7]=+o[7]+j;break;case"V":n[1]=+o[1]+j;break;case"H":n[1]=+o[1]+i;break;case"R":for(var s=[i,j].concat(o.slice(1)),t=2,u=s.length;u>t;t++)s[t]=+s[t]+i,s[++t]=+s[t]+j;h.pop(),h=h.concat(G(s,p));break;case"O":h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);break;case"U":h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));break;case"M":k=+o[1]+i,l=+o[2]+j;default:for(t=1,u=o.length;u>t;t++)n[t]=+o[t]+(t%2?i:j)}else if("R"==g)s=[i,j].concat(o.slice(1)),h.pop(),h=h.concat(G(s,p)),n=["R"].concat(o.slice(-2));else if("O"==g)h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);else if("U"==g)h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));else for(var v=0,w=o.length;w>v;v++)n[v]=o[v];if(g=g.toUpperCase(),"O"!=g)switch(n[0]){case"Z":i=+k,j=+l;break;case"H":i=n[1];break;case"V":j=n[1];break;case"M":k=n[n.length-2],l=n[n.length-1];default:i=n[n.length-2],j=n[n.length-1]}}return h.toString=e,d.abs=f(h),h}function A(a,b,c,d){return[a,b,c,d,c,d]}function B(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]}function C(b,c,d,e,f,g,h,i,j,k){var l,m=120*O/180,n=O/180*(+f||0),o=[],p=a._.cacher(function(a,b,c){var d=a*N.cos(c)-b*N.sin(c),e=a*N.sin(c)+b*N.cos(c);return{x:d,y:e}});if(k)y=k[0],z=k[1],w=k[2],x=k[3];else{l=p(b,c,-n),b=l.x,c=l.y,l=p(i,j,-n),i=l.x,j=l.y;var q=(N.cos(O/180*f),N.sin(O/180*f),(b-i)/2),r=(c-j)/2,s=q*q/(d*d)+r*r/(e*e);s>1&&(s=N.sqrt(s),d=s*d,e=s*e);var t=d*d,u=e*e,v=(g==h?-1:1)*N.sqrt(S((t*u-t*r*r-u*q*q)/(t*r*r+u*q*q))),w=v*d*r/e+(b+i)/2,x=v*-e*q/d+(c+j)/2,y=N.asin(((c-x)/e).toFixed(9)),z=N.asin(((j-x)/e).toFixed(9));y=w>b?O-y:y,z=w>i?O-z:z,0>y&&(y=2*O+y),0>z&&(z=2*O+z),h&&y>z&&(y-=2*O),!h&&z>y&&(z-=2*O)}var A=z-y;if(S(A)>m){var B=z,D=i,E=j;z=y+m*(h&&z>y?1:-1),i=w+d*N.cos(z),j=x+e*N.sin(z),o=C(i,j,d,e,f,0,h,D,E,[z,B,w,x])}A=z-y;var F=N.cos(y),G=N.sin(y),H=N.cos(z),I=N.sin(z),J=N.tan(A/4),K=4/3*d*J,L=4/3*e*J,M=[b,c],P=[b+K*G,c-L*F],Q=[i+K*I,j-L*H],R=[i,j];if(P[0]=2*M[0]-P[0],P[1]=2*M[1]-P[1],k)return[P,Q,R].concat(o);o=[P,Q,R].concat(o).join().split(",");for(var T=[],U=0,V=o.length;V>U;U++)T[U]=U%2?p(o[U-1],o[U],n).y:p(o[U],o[U+1],n).x;return T}function D(a,b,c,d,e,f,g,h){for(var i,j,k,l,m,n,o,p,q=[],r=[[],[]],s=0;2>s;++s)if(0==s?(j=6*a-12*c+6*e,i=-3*a+9*c-9*e+3*g,k=3*c-3*a):(j=6*b-12*d+6*f,i=-3*b+9*d-9*f+3*h,k=3*d-3*b),S(i)<1e-12){if(S(j)<1e-12)continue;l=-k/j,l>0&&1>l&&q.push(l)}else o=j*j-4*k*i,p=N.sqrt(o),0>o||(m=(-j+p)/(2*i),m>0&&1>m&&q.push(m),n=(-j-p)/(2*i),n>0&&1>n&&q.push(n));for(var t,u=q.length,v=u;u--;)l=q[u],t=1-l,r[0][u]=t*t*t*a+3*t*t*l*c+3*t*l*l*e+l*l*l*g,r[1][u]=t*t*t*b+3*t*t*l*d+3*t*l*l*f+l*l*l*h;return r[0][v]=a,r[1][v]=b,r[0][v+1]=g,r[1][v+1]=h,r[0].length=r[1].length=v+2,{min:{x:P.apply(0,r[0]),y:P.apply(0,r[1])},max:{x:Q.apply(0,r[0]),y:Q.apply(0,r[1])}}}function E(a,b){var d=!b&&c(a);if(!b&&d.curve)return f(d.curve);for(var e=z(a),g=b&&z(b),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},j=(function(a,b,c){var d,e;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];switch(!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null),a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"].concat(C.apply(0,[b.x,b.y].concat(a.slice(1))));break;case"S":"C"==c||"S"==c?(d=2*b.x-b.bx,e=2*b.y-b.by):(d=b.x,e=b.y),a=["C",d,e].concat(a.slice(1));break;case"T":"Q"==c||"T"==c?(b.qx=2*b.x-b.qx,b.qy=2*b.y-b.qy):(b.qx=b.x,b.qy=b.y),a=["C"].concat(B(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"].concat(B(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"].concat(A(b.x,b.y,a[1],a[2]));break;case"H":a=["C"].concat(A(b.x,b.y,a[1],b.y));break;case"V":a=["C"].concat(A(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"].concat(A(b.x,b.y,b.X,b.Y))}return a}),k=function(a,b){if(a[b].length>7){a[b].shift();for(var c=a[b];c.length;)m[b]="A",g&&(n[b]="A"),a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),r=Q(e.length,g&&g.length||0)}},l=function(a,b,c,d,f){a&&b&&"M"==a[f][0]&&"M"!=b[f][0]&&(b.splice(f,0,["M",d.x,d.y]),c.bx=0,c.by=0,c.x=a[f][1],c.y=a[f][2],r=Q(e.length,g&&g.length||0))},m=[],n=[],o="",p="",q=0,r=Q(e.length,g&&g.length||0);r>q;q++){e[q]&&(o=e[q][0]),"C"!=o&&(m[q]=o,q&&(p=m[q-1])),e[q]=j(e[q],h,p),"A"!=m[q]&&"C"==o&&(m[q]="C"),k(e,q),g&&(g[q]&&(o=g[q][0]),"C"!=o&&(n[q]=o,q&&(p=n[q-1])),g[q]=j(g[q],i,p),"A"!=n[q]&&"C"==o&&(n[q]="C"),k(g,q)),l(e,g,h,i,q),l(g,e,i,h,q);var s=e[q],t=g&&g[q],u=s.length,v=g&&t.length;h.x=s[u-2],h.y=s[u-1],h.bx=M(s[u-4])||h.x,h.by=M(s[u-3])||h.y,i.bx=g&&(M(t[v-4])||i.x),i.by=g&&(M(t[v-3])||i.y),i.x=g&&t[v-2],i.y=g&&t[v-1]}return g||(d.curve=f(e)),g?[e,g]:e}function F(a,b){if(!b)return a;var c,d,e,f,g,h,i;for(a=E(a),e=0,g=a.length;g>e;e++)for(i=a[e],f=1,h=i.length;h>f;f+=2)c=b.x(i[f],i[f+1]),d=b.y(i[f],i[f+1]),i[f]=c,i[f+1]=d;return a}function G(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}var H=b.prototype,I=a.is,J=a._.clone,K="hasOwnProperty",L=/,?([a-z]),?/gi,M=parseFloat,N=Math,O=N.PI,P=N.min,Q=N.max,R=N.pow,S=N.abs,T=h(1),U=h(),V=h(0,1),W=a._unit2px,X={path:function(a){return a.attr("path")},circle:function(a){var b=W(a);return x(b.cx,b.cy,b.r)},ellipse:function(a){var b=W(a);return x(b.cx||0,b.cy||0,b.rx,b.ry)},rect:function(a){var b=W(a);return w(b.x||0,b.y||0,b.width,b.height,b.rx,b.ry)},image:function(a){var b=W(a);return w(b.x||0,b.y||0,b.width,b.height)},line:function(a){return"M"+[a.attr("x1")||0,a.attr("y1")||0,a.attr("x2"),a.attr("y2")]},polyline:function(a){return"M"+a.attr("points")},polygon:function(a){return"M"+a.attr("points")+"z"},deflt:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)}};a.path=c,a.path.getTotalLength=T,a.path.getPointAtLength=U,a.path.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return V(a,b).end;var d=V(a,c,1);return b?V(d,b).end:d},H.getTotalLength=function(){return this.node.getTotalLength?this.node.getTotalLength():void 0},H.getPointAtLength=function(a){return U(this.attr("d"),a)},H.getSubpath=function(b,c){return a.path.getSubpath(this.attr("d"),b,c)},a._.box=d,a.path.findDotsAtSegment=i,a.path.bezierBBox=j,a.path.isPointInsideBBox=k,a.closest=function(b,c,e,f){for(var g=100,h=d(b-g/2,c-g/2,g,g),i=[],j=e[0].hasOwnProperty("x")?function(a){return{x:e[a].x,y:e[a].y}}:function(a){return{x:e[a],y:f[a]}},l=0;1e6>=g&&!l;){for(var m=0,n=e.length;n>m;m++){var o=j(m);if(k(h,o.x,o.y)){l++,i.push(o);break}}l||(g*=2,h=d(b-g/2,c-g/2,g,g))}if(1e6!=g){var p,q=1/0;for(m=0,n=i.length;n>m;m++){var r=a.len(b,c,i[m].x,i[m].y);q>r&&(q=r,i[m].len=r,p=i[m])}return p}},a.path.isBBoxIntersect=l,a.path.intersection=r,a.path.intersectionNumber=s,a.path.isPointInside=u,a.path.getBBox=v,a.path.get=X,a.path.toRelative=y,a.path.toAbsolute=z,a.path.toCubic=E,a.path.map=F,a.path.toString=e,a.path.clone=f}),d.plugin(function(a){var d=Math.max,e=Math.min,f=function(a){if(this.items=[],this.bindings={},this.length=0,this.type="set",a)for(var b=0,c=a.length;c>b;b++)a[b]&&(this[this.items.length]=this.items[this.items.length]=a[b],this.length++)},g=f.prototype;g.push=function(){for(var a,b,c=0,d=arguments.length;d>c;c++)a=arguments[c],a&&(b=this.items.length,this[b]=this.items[b]=a,this.length++);return this},g.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},g.forEach=function(a,b){for(var c=0,d=this.items.length;d>c;c++)if(a.call(b,this.items[c],c)===!1)return this;return this},g.animate=function(d,e,f,g){"function"!=typeof f||f.length||(g=f,f=c.linear),d instanceof a._.Animation&&(g=d.callback,f=d.easing,e=f.dur,d=d.attr);var h=arguments;if(a.is(d,"array")&&a.is(h[h.length-1],"array"))var i=!0;var j,k=function(){j?this.b=j:j=this.b},l=0,m=this,n=g&&function(){++l==m.length&&g.call(this) 21 | };return this.forEach(function(a,c){b.once("snap.animcreated."+a.id,k),i?h[c]&&a.animate.apply(a,h[c]):a.animate(d,e,f,n)})},g.remove=function(){for(;this.length;)this.pop().remove();return this},g.bind=function(a,b,c){var d={};if("function"==typeof b)this.bindings[a]=b;else{var e=c||a;this.bindings[a]=function(a){d[e]=a,b.attr(d)}}return this},g.attr=function(a){var b={};for(var c in a)this.bindings[c]?this.bindings[c](a[c]):b[c]=a[c];for(var d=0,e=this.items.length;e>d;d++)this.items[d].attr(b);return this},g.clear=function(){for(;this.length;)this.pop()},g.splice=function(a,b){a=0>a?d(this.length+a,0):a,b=d(0,e(this.length-a,b));var c,g=[],h=[],i=[];for(c=2;cc;c++)h.push(this[a+c]);for(;cc?i[c]:g[c-j];for(c=this.items.length=this.length-=b-j;this[c];)delete this[c++];return new f(h)},g.exclude=function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]==a)return this.splice(b,1),!0;return!1},g.insertAfter=function(a){for(var b=this.items.length;b--;)this.items[b].insertAfter(a);return this},g.getBBox=function(){for(var a=[],b=[],c=[],f=[],g=this.items.length;g--;)if(!this.items[g].removed){var h=this.items[g].getBBox();a.push(h.x),b.push(h.y),c.push(h.x+h.width),f.push(h.y+h.height)}return a=e.apply(0,a),b=e.apply(0,b),c=d.apply(0,c),f=d.apply(0,f),{x:a,y:b,x2:c,y2:f,width:c-a,height:f-b,cx:a+(c-a)/2,cy:b+(f-b)/2}},g.clone=function(a){a=new f;for(var b=0,c=this.items.length;c>b;b++)a.push(this.items[b].clone());return a},g.toString=function(){return"Snap‘s set"},g.type="set",a.Set=f,a.set=function(){var a=new f;return arguments.length&&a.push.apply(a,Array.prototype.slice.call(arguments,0)),a}}),d.plugin(function(a,c){function d(a){var b=a[0];switch(b.toLowerCase()){case"t":return[b,0,0];case"m":return[b,1,0,0,1,0,0];case"r":return 4==a.length?[b,0,a[2],a[3]]:[b,0];case"s":return 5==a.length?[b,1,1,a[3],a[4]]:3==a.length?[b,1,1]:[b,1]}}function e(b,c,e){c=p(c).replace(/\.{3}|\u2026/g,b),b=a.parseTransformString(b)||[],c=a.parseTransformString(c)||[];for(var f,g,h,i,l=Math.max(b.length,c.length),m=[],n=[],o=0;l>o;o++){if(h=b[o]||d(c[o]),i=c[o]||d(h),h[0]!=i[0]||"r"==h[0].toLowerCase()&&(h[2]!=i[2]||h[3]!=i[3])||"s"==h[0].toLowerCase()&&(h[3]!=i[3]||h[4]!=i[4])){b=a._.transform2matrix(b,e()),c=a._.transform2matrix(c,e()),m=[["m",b.a,b.b,b.c,b.d,b.e,b.f]],n=[["m",c.a,c.b,c.c,c.d,c.e,c.f]];break}for(m[o]=[],n[o]=[],f=0,g=Math.max(h.length,i.length);g>f;f++)f in h&&(m[o][f]=h[f]),f in i&&(n[o][f]=i[f])}return{from:k(m),to:k(n),f:j(m)}}function f(a){return a}function g(a){return function(b){return+b.toFixed(3)+a}}function h(a){return a.join(" ")}function i(b){return a.rgb(b[0],b[1],b[2])}function j(a){var b,c,d,e,f,g,h=0,i=[];for(b=0,c=a.length;c>b;b++){for(f="[",g=['"'+a[b][0]+'"'],d=1,e=a[b].length;e>d;d++)g[d]="val["+h++ +"]";f+=g+"]",i[b]=f}return Function("val","return Snap.path.toString.call(["+i+"])")}function k(a){for(var b=[],c=0,d=a.length;d>c;c++)for(var e=1,f=a[c].length;f>e;e++)b.push(a[c][e]);return b}function l(a){return isFinite(parseFloat(a))}function m(b,c){return a.is(b,"array")&&a.is(c,"array")?b.toString()==c.toString():!1}var n={},o=/[a-z]+$/i,p=String;n.stroke=n.fill="colour",c.prototype.equal=function(a,c){return b("snap.util.equal",this,a,c).firstDefined()},b.on("snap.util.equal",function(b,c){var d,q,r=p(this.attr(b)||""),s=this;if(l(r)&&l(c))return{from:parseFloat(r),to:parseFloat(c),f:f};if("colour"==n[b])return d=a.color(r),q=a.color(c),{from:[d.r,d.g,d.b,d.opacity],to:[q.r,q.g,q.b,q.opacity],f:i};if("viewBox"==b)return d=this.attr(b).vb.split(" ").map(Number),q=c.split(" ").map(Number),{from:d,to:q,f:h};if("transform"==b||"gradientTransform"==b||"patternTransform"==b)return c instanceof a.Matrix&&(c=c.toTransformString()),a._.rgTransform.test(c)||(c=a._.svgTransform2string(c)),e(r,c,function(){return s.getBBox(1)});if("d"==b||"path"==b)return d=a.path.toCubic(r,c),{from:k(d[0]),to:k(d[1]),f:j(d[0])};if("points"==b)return d=p(r).split(a._.separator),q=p(c).split(a._.separator),{from:d,to:q,f:function(a){return a}};var t=r.match(o),u=p(c).match(o);return t&&m(t,u)?{from:parseFloat(r),to:parseFloat(c),f:g(t)}:{from:this.asPX(b),to:this.asPX(b,c),f:f}})}),d.plugin(function(a,c,d,e){for(var f=c.prototype,g="hasOwnProperty",h=("createTouch"in e.doc),i=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","touchstart","touchmove","touchend","touchcancel"],j={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},k=(function(a,b){var c="y"==a?"scrollTop":"scrollLeft",d=b&&b.node?b.node.ownerDocument:e.doc;return d[c in d.documentElement?"documentElement":"body"][c]}),l=function(){return this.originalEvent.preventDefault()},m=function(){return this.originalEvent.stopPropagation()},n=function(a,b,c,d){var e=h&&j[b]?j[b]:b,f=function(e){var f=k("y",d),i=k("x",d);if(h&&j[g](b))for(var n=0,o=e.targetTouches&&e.targetTouches.length;o>n;n++)if(e.targetTouches[n].target==a||a.contains(e.targetTouches[n].target)){var p=e;e=e.targetTouches[n],e.originalEvent=p,e.preventDefault=l,e.stopPropagation=m;break}var q=e.clientX+i,r=e.clientY+f;return c.call(d,e,q,r)};return b!==e&&a.addEventListener(b,f,!1),a.addEventListener(e,f,!1),function(){return b!==e&&a.removeEventListener(b,f,!1),a.removeEventListener(e,f,!1),!0}},o=[],p=function(a){for(var c,d=a.clientX,e=a.clientY,f=k("y"),g=k("x"),i=o.length;i--;){if(c=o[i],h){for(var j,l=a.touches&&a.touches.length;l--;)if(j=a.touches[l],j.identifier==c.el._drag.id||c.el.node.contains(j.target)){d=j.clientX,e=j.clientY,(a.originalEvent?a.originalEvent:a).preventDefault();break}}else a.preventDefault();{var m=c.el.node;m.nextSibling,m.parentNode,m.style.display}d+=g,e+=f,b("snap.drag.move."+c.el.id,c.move_scope||c.el,d-c.el._drag.x,e-c.el._drag.y,d,e,a)}},q=function(c){a.unmousemove(p).unmouseup(q);for(var d,e=o.length;e--;)d=o[e],d.el._drag={},b("snap.drag.end."+d.el.id,d.end_scope||d.start_scope||d.move_scope||d.el,c),b.off("snap.drag.*."+d.el.id);o=[]},r=i.length;r--;)!function(b){a[b]=f[b]=function(c,d){if(a.is(c,"function"))this.events=this.events||[],this.events.push({name:b,f:c,unbind:n(this.node||document,b,c,d||this)});else for(var e=0,f=this.events.length;f>e;e++)if(this.events[e].name==b)try{this.events[e].f.call(this)}catch(g){}return this},a["un"+b]=f["un"+b]=function(a){for(var c=this.events||[],d=c.length;d--;)if(c[d].name==b&&(c[d].f==a||!a))return c[d].unbind(),c.splice(d,1),!c.length&&delete this.events,this;return this}}(i[r]);f.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)},f.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};var s=[];f.drag=function(c,d,e,f,g,h){function i(i,j,l){(i.originalEvent||i).preventDefault(),k._drag.x=j,k._drag.y=l,k._drag.id=i.identifier,!o.length&&a.mousemove(p).mouseup(q),o.push({el:k,move_scope:f,start_scope:g,end_scope:h}),d&&b.on("snap.drag.start."+k.id,d),c&&b.on("snap.drag.move."+k.id,c),e&&b.on("snap.drag.end."+k.id,e),b("snap.drag.start."+k.id,g||f||k,j,l,i)}function j(a,c,d){b("snap.draginit."+k.id,k,a,c,d)}var k=this;if(!arguments.length){var l;return k.drag(function(a,b){this.attr({transform:l+(l?"T":"t")+[a,b]})},function(){l=this.transform().local})}return b.on("snap.draginit."+k.id,i),k._drag={},s.push({el:k,start:i,init:j}),k.mousedown(j),k},f.undrag=function(){for(var c=s.length;c--;)s[c].el==this&&(this.unmousedown(s[c].init),s.splice(c,1),b.unbind("snap.drag.*."+this.id),b.unbind("snap.draginit."+this.id));return!s.length&&a.unmousemove(p).unmouseup(q),this}}),d.plugin(function(a,c,d){var e=(c.prototype,d.prototype),f=/^\s*url\((.+)\)/,g=String,h=a._.$;a.filter={},e.filter=function(b){var d=this;"svg"!=d.type&&(d=d.paper);var e=a.parse(g(b)),f=a._.id(),i=(d.node.offsetWidth,d.node.offsetHeight,h("filter"));return h(i,{id:f,filterUnits:"userSpaceOnUse"}),i.appendChild(e.node),d.defs.appendChild(i),new c(i)},b.on("snap.util.getattr.filter",function(){b.stop();var c=h(this.node,"filter");if(c){var d=g(c).match(f);return d&&a.select(d[1])}}),b.on("snap.util.attr.filter",function(d){if(d instanceof c&&"filter"==d.type){b.stop();var e=d.node.id;e||(h(d.node,{id:d.id}),e=d.id),h(this.node,{filter:a.url(e)})}d&&"none"!=d||(b.stop(),this.node.removeAttribute("filter"))}),a.filter.blur=function(b,c){null==b&&(b=2);var d=null==c?b:[b,c];return a.format('',{def:d})},a.filter.blur.toString=function(){return this()},a.filter.shadow=function(b,c,d,e,f){return"string"==typeof d&&(e=d,f=e,d=4),"string"!=typeof e&&(f=e,e="#000"),e=e||"#000",null==d&&(d=4),null==f&&(f=1),null==b&&(b=0,c=2),null==c&&(c=b),e=a.color(e),a.format('',{color:e,dx:b,dy:c,blur:d,opacity:f})},a.filter.shadow.toString=function(){return this()},a.filter.grayscale=function(b){return null==b&&(b=1),a.format('',{a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},a.filter.grayscale.toString=function(){return this()},a.filter.sepia=function(b){return null==b&&(b=1),a.format('',{a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},a.filter.sepia.toString=function(){return this()},a.filter.saturate=function(b){return null==b&&(b=1),a.format('',{amount:1-b})},a.filter.saturate.toString=function(){return this()},a.filter.hueRotate=function(b){return b=b||0,a.format('',{angle:b})},a.filter.hueRotate.toString=function(){return this()},a.filter.invert=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:1-b})},a.filter.invert.toString=function(){return this()},a.filter.brightness=function(b){return null==b&&(b=1),a.format('',{amount:b})},a.filter.brightness.toString=function(){return this()},a.filter.contrast=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:.5-b/2})},a.filter.contrast.toString=function(){return this()}}),d.plugin(function(a,b){var c=a._.box,d=a.is,e=/^[^a-z]*([tbmlrc])/i,f=function(){return"T"+this.dx+","+this.dy};b.prototype.getAlign=function(a,b){null==b&&d(a,"string")&&(b=a,a=null),a=a||this.paper;var g=a.getBBox?a.getBBox():c(a),h=this.getBBox(),i={};switch(b=b&&b.match(e),b=b?b[1].toLowerCase():"c"){case"t":i.dx=0,i.dy=g.y-h.y;break;case"b":i.dx=0,i.dy=g.y2-h.y2;break;case"m":i.dx=0,i.dy=g.cy-h.cy;break;case"l":i.dx=g.x-h.x,i.dy=0;break;case"r":i.dx=g.x2-h.x2,i.dy=0;break;default:i.dx=g.cx-h.cx,i.dy=0}return i.toString=f,i},b.prototype.align=function(a,b){return this.transform("..."+this.getAlign(a,b))}}),d}); 22 | --------------------------------------------------------------------------------