Add the WWW directory. It is a mess currently, but...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 18 Nov 2013 20:58:15 +0000 (21:58 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 18 Nov 2013 20:58:15 +0000 (21:58 +0100)
23 files changed:
www/LICENSE.txt [new file with mode: 0644]
www/analysis.pl [new file with mode: 0755]
www/app.psgi [new file with mode: 0644]
www/css/chessboard-0.3.0.css [new file with mode: 0644]
www/css/chessboard-0.3.0.min.css [new file with mode: 0644]
www/img/chesspieces/wikipedia/bB.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/bK.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/bN.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/bP.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/bQ.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/bR.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wB.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wK.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wN.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wP.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wQ.png [new file with mode: 0644]
www/img/chesspieces/wikipedia/wR.png [new file with mode: 0644]
www/index.html [new file with mode: 0644]
www/js/chessboard-0.3.0.js [new file with mode: 0644]
www/js/chessboard-0.3.0.min.js [new file with mode: 0644]
www/js/jquery-1.10.2.min.js [new file with mode: 0644]
www/js/jquery.jsPlumb-1.5.3-min.js [new file with mode: 0644]
www/js/json3.min.js [new file with mode: 0644]

diff --git a/www/LICENSE.txt b/www/LICENSE.txt
new file mode 100644 (file)
index 0000000..4d3575e
--- /dev/null
@@ -0,0 +1,21 @@
+Copyright 2013 Chris Oakman
+http://chessboardjs.com/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/www/analysis.pl b/www/analysis.pl
new file mode 100755 (executable)
index 0000000..9b45cc7
--- /dev/null
@@ -0,0 +1,63 @@
+#! /usr/bin/perl
+use CGI;
+use POSIX;
+use Date::Manip;
+use Linux::Inotify2;
+use AnyEvent;
+use strict;
+use warnings;
+
+my $cv = AnyEvent->condvar;
+my $updated = 0;
+my $cgi = CGI->new;
+my $inotify = Linux::Inotify2->new;
+$inotify->watch("/srv/analysis.sesse.net/analysis.json", IN_MODIFY, sub {
+       $updated = 1;
+       $cv->send;
+});
+        
+my $inotify_w = AnyEvent->io (
+       fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
+);
+my $wait = AnyEvent->timer (
+       after => 30,
+       cb    => sub { $cv->send; },
+);
+
+my $ims = 0;
+if (exists($ENV{'HTTP_IF_MODIFIED_SINCE'})) {
+       my $date = Date::Manip::Date->new;
+       $date->parse($ENV{'HTTP_IF_MODIFIED_SINCE'});
+       $ims = $date->printf("%s");
+}
+my $time = (stat("/srv/analysis.sesse.net/analysis.json"))[9];
+
+# If we have something that's modified since IMS, send it out at once
+if ($time > $ims) {
+       output();
+       exit;
+}
+
+# If not, wait, then send. Apache will deal with the 304-ing.
+if (defined($cgi->param('first')) && $cgi->param('first') != 1) {
+       $cv->recv;
+}
+output();
+
+sub output {
+       my $time = (stat("/srv/analysis.sesse.net/analysis.json"))[9];
+       my $lm_str = POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", localtime($time));
+
+       print CGI->header(-type=>'text/json',
+                         -last_modified=>$lm_str,
+                         -access_control_allow_origin=>'http://analysis.sesse.net',
+                         -expires=>'now');
+       open my $fh, "<", "/srv/analysis.sesse.net/analysis.json"
+               or die "/srv/analysis.sesse.net/analysis.json: $!";
+       my $data;
+       {
+               local $/ = undef;
+               $data = <$fh>;
+       }
+       print $data;
+}
diff --git a/www/app.psgi b/www/app.psgi
new file mode 100644 (file)
index 0000000..2666248
--- /dev/null
@@ -0,0 +1,28 @@
+#! /usr/bin/perl -T
+
+use strict;
+use warnings;
+use lib qw(./include);
+
+# These need to come before the Billig modules, so that exit is properly redirected.
+use CGI::PSGI;
+use CGI::Emulate::PSGI;
+use CGI::Compile;
+
+use Plack::Request;
+
+# Older versions of File::pushd (used by CGI::Compile) have a performance trap
+# that's hard to pin down. Warn about it.
+use File::pushd;
+if ($File::pushd::VERSION < 1.005) {
+       print STDERR "WARNING: You are using a version of File::pushd older than 1.005. This will work, but it has performance implications.\n";
+       print STDERR "Do not run in production!\n\n";
+}
+
+my $cgi = CGI::Compile->compile('/srv/analysis.sesse.net/analysis.pl');
+my $handler = CGI::Emulate::PSGI->handler($cgi);
+
+sub {
+       my $env = shift;
+       return &$handler($env);
+}
diff --git a/www/css/chessboard-0.3.0.css b/www/css/chessboard-0.3.0.css
new file mode 100644 (file)
index 0000000..e987b52
--- /dev/null
@@ -0,0 +1,70 @@
+/*!\r
+ * chessboard.js v0.3.0\r
+ *\r
+ * Copyright 2013 Chris Oakman\r
+ * Released under the MIT license\r
+ * https://github.com/oakmac/chessboardjs/blob/master/LICENSE\r
+ *\r
+ * Date: 10 Aug 2013\r
+ */\r
+\r
+/* clearfix */\r
+.clearfix-7da63 {\r
+  clear: both;\r
+}\r
+\r
+/* board */\r
+.board-b72b1 {\r
+  border: 2px solid #404040;\r
+  -moz-box-sizing: content-box;\r
+  box-sizing: content-box;\r
+}\r
+\r
+/* square */\r
+.square-55d63 {\r
+  float: left;\r
+  position: relative;\r
+\r
+  /* disable any native browser highlighting */\r
+  -webkit-touch-callout: none;\r
+    -webkit-user-select: none;\r
+     -khtml-user-select: none;\r
+       -moz-user-select: none;\r
+        -ms-user-select: none;\r
+            user-select: none;\r
+}\r
+\r
+/* white square */\r
+.white-1e1d7 {\r
+  background-color: #f0d9b5;\r
+  color: #b58863;\r
+}\r
+\r
+/* black square */\r
+.black-3c85d {\r
+  background-color: #b58863;\r
+  color: #f0d9b5;\r
+}\r
+\r
+/* highlighted square */\r
+.highlight1-32417, .highlight2-9c5d2 {\r
+  -webkit-box-shadow: inset 0 0 3px 3px yellow;\r
+  -moz-box-shadow: inset 0 0 3px 3px yellow;\r
+  box-shadow: inset 0 0 3px 3px yellow;\r
+}\r
+\r
+/* notation */\r
+.notation-322f9 {\r
+  cursor: default;\r
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;\r
+  font-size: 14px;\r
+  position: absolute;\r
+}\r
+.alpha-d2270 {\r
+  bottom: 1px;\r
+  right: 3px;\r
+}\r
+.numeric-fc462 {\r
+  top: 2px;\r
+  left: 2px;\r
+}
\ No newline at end of file
diff --git a/www/css/chessboard-0.3.0.min.css b/www/css/chessboard-0.3.0.min.css
new file mode 100644 (file)
index 0000000..52781a9
--- /dev/null
@@ -0,0 +1,2 @@
+/*! chessboard.js v0.3.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */
+.clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;-moz-box-sizing:content-box;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{-webkit-box-shadow:inset 0 0 3px 3px yellow;-moz-box-shadow:inset 0 0 3px 3px yellow;box-shadow:inset 0 0 3px 3px yellow}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px}
\ No newline at end of file
diff --git a/www/img/chesspieces/wikipedia/bB.png b/www/img/chesspieces/wikipedia/bB.png
new file mode 100644 (file)
index 0000000..be3007d
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bB.png differ
diff --git a/www/img/chesspieces/wikipedia/bK.png b/www/img/chesspieces/wikipedia/bK.png
new file mode 100644 (file)
index 0000000..de9880c
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bK.png differ
diff --git a/www/img/chesspieces/wikipedia/bN.png b/www/img/chesspieces/wikipedia/bN.png
new file mode 100644 (file)
index 0000000..e31a6d0
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bN.png differ
diff --git a/www/img/chesspieces/wikipedia/bP.png b/www/img/chesspieces/wikipedia/bP.png
new file mode 100644 (file)
index 0000000..afa0c9d
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bP.png differ
diff --git a/www/img/chesspieces/wikipedia/bQ.png b/www/img/chesspieces/wikipedia/bQ.png
new file mode 100644 (file)
index 0000000..4649bb8
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bQ.png differ
diff --git a/www/img/chesspieces/wikipedia/bR.png b/www/img/chesspieces/wikipedia/bR.png
new file mode 100644 (file)
index 0000000..c7eb127
Binary files /dev/null and b/www/img/chesspieces/wikipedia/bR.png differ
diff --git a/www/img/chesspieces/wikipedia/wB.png b/www/img/chesspieces/wikipedia/wB.png
new file mode 100644 (file)
index 0000000..70e0e14
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wB.png differ
diff --git a/www/img/chesspieces/wikipedia/wK.png b/www/img/chesspieces/wikipedia/wK.png
new file mode 100644 (file)
index 0000000..bbf5664
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wK.png differ
diff --git a/www/img/chesspieces/wikipedia/wN.png b/www/img/chesspieces/wikipedia/wN.png
new file mode 100644 (file)
index 0000000..237250c
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wN.png differ
diff --git a/www/img/chesspieces/wikipedia/wP.png b/www/img/chesspieces/wikipedia/wP.png
new file mode 100644 (file)
index 0000000..5f9315c
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wP.png differ
diff --git a/www/img/chesspieces/wikipedia/wQ.png b/www/img/chesspieces/wikipedia/wQ.png
new file mode 100644 (file)
index 0000000..c3dfc15
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wQ.png differ
diff --git a/www/img/chesspieces/wikipedia/wR.png b/www/img/chesspieces/wikipedia/wR.png
new file mode 100644 (file)
index 0000000..cc69760
Binary files /dev/null and b/www/img/chesspieces/wikipedia/wR.png differ
diff --git a/www/index.html b/www/index.html
new file mode 100644 (file)
index 0000000..95297b0
--- /dev/null
@@ -0,0 +1,482 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset="utf-8" />
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+  <title>analysis.sesse.net</title>
+
+  <link rel="stylesheet" href="http://chessboardjs.com/css/chessboard.css" />
+  <style>
+body {
+font-family: sans-serif;
+}
+.window {
+    position:absolute;    
+    width: 0px; height:0px;
+    opacity:0.0; 
+}
+.c1 { opacity: 0.75; }
+.l1arrow { opacity: 1.0; }
+.hidden { display: none; }
+.vir path { opacity: 0.0; }
+.vir path.l1arrow { opacity: 1.0; }
+#credits { font-size: smaller; }
+td { vertical-align: top; }
+p { margin-top: 0; }
+#refutationlines { font-size: smaller; }
+#refutationlines .move { width: 3.5em; }
+#refutationlines .score { width: 3em; text-align: right; padding-right: 0.5em; }
+#refutationlines .depth { width: 2em; text-align: right; padding-right: 0.7em; }
+/* .white-1e1d7 { background-color: #f0d9b5; color: #b58863; }
+/* .black-3c85d { background-color: #b58863; color: #f0d9b5; } */
+/* .white-1e1d7.nonuglyhighlight { background-color: #f3e1a4; }
+.black-3c85d.nonuglyhighlight { background-color: #c7a859; } */
+.white-1e1d7.nonuglyhighlight { background-color: #cce5cf; }
+.black-3c85d.nonuglyhighlight { background-color: #9ab6a6; }
+  </style>
+</head>
+<body>
+<h1 id="headline">Analysis</h1>
+<table>
+<tr>
+<td>
+<div id="board" style="width: 400px"></div>
+</td>
+<td>
+  <p id="score">Score:</p>
+  <p><strong>PV:</strong> <span id="pv"></span></p>
+  <p id="searchstats"></p>
+  <h3 style="margin-top: 1em; margin-bottom: 0;">Shallow search of all legal moves (multi-PV)</h3>
+  <table id="refutationlines">
+  </table>
+</td>
+</tr>
+</table>
+<h2>Symbol explanation</h2>
+<ul>
+  <li><strong>Score:</strong> 1.00 is the value of one pawn (in the opening). Positive values are better for white.</li>
+  <li><strong>PV:</strong> Principal Variation, the series of moves the engine thinks is the best.</li>
+  <li><strong>Thick red line:</strong> Marks the best move (in the view of the engine). Multiple chained arrows
+    means that the PV starts with multiple successive moves with the same piece, ie., the engine thinks
+    that the piece will execute a maneuver.</li>
+  <li><strong>Thin red lines:</strong> Other good moves, maximum two. Note that even though these are also
+    quality checked, these are less thoroughly analyzed by the engine,
+    and should be taken with a grain of salt.</li>
+  <li><strong>Thick blue line:</strong> Marks the best <em>response</em> move. Note that this is only rarely shown,
+    since usually, the best response move depends on what the first move is. A typical case is when the current move
+    is forced or nearly so.</li>
+</ul>
+<p id="credits"><a href="http://git.sesse.net/?p=remoteglot;a=summary">remoteglot</a>
+  &copy; 2007-2013 <a href="http://www.sesse.net/">Steinar H. Gunderson</a>.
+  Chess analysis by <a href="http://stockfishchess.org/">Stockfish</a> (main analysis: 12x2.3GHz Sandy Bridge,
+  multi-PV search: 8x2.27GHz Nehalem).
+  Moves provided by <a href="http://www.freechess.org/">FICS</a>.
+  Hosting and main analysis hardware by <a href="http://www.samfundet.no/">Studentersamfundet i Trondhjem</a>.
+  JavaScript chessboard powered by <a href="http://chessboardjs.com/">chessboard.js</a>.
+  Arrows by <a href="http://jsplumbtoolkit.com">jsPlumb</a>&mdash;who would think you could
+  draw such beautiful arrows in just 161 kB of JavaScript on top of the
+  323 kB needed for jQuery and jQuery UI? How far technology has come. If you want something
+  more retro, the <a href="/text.pl">text interface</a> is still available.</p>
+
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
+<script type="text/javascript" src="js/jquery.jsPlumb-1.5.3-min.js"></script>
+<script type="text/javascript" src="http://chessboardjs.com/js/chessboard.js"></script>
+<script>
+var arrows = [];
+var arrow_targets = [];
+var occupied_by_arrows = [];
+
+var request_update = function(board, first) {
+       $.ajax({
+               //url: "http://analysis.sesse.net/analysis.pl?first=" + first
+               url: "http://analysis.sesse.net:5000/analysis.pl?first=" + first
+       }).done(function(data) {
+               update_board(board, data);
+       });
+}
+
+var clear_arrows = function() {
+       for (var i = 0; i < arrows.length; ++i) {
+               jsPlumb.detach(arrows[i]);
+       }
+       arrows = [];
+
+       for (var i = 0; i < arrow_targets.length; ++i) {
+               document.body.removeChild(arrow_targets[i]);
+       }
+       arrow_targets = [];
+       
+       occupied_by_arrows = [];        
+       for (var y = 0; y < 8; ++y) {
+               occupied_by_arrows.push([false, false, false, false, false, false, false, false]);
+       }
+}
+
+var sign = function(x) {
+       if (x > 0) {
+               return 1;
+       } else if (x < 0) {
+               return -1;
+       } else {
+               return 0;
+       }
+}
+
+// See if drawing this arrow on the board would cause unduly amount of confusion.
+var interfering_arrow = function(from, to) {
+       var from_col = from.charCodeAt(0) - "a1".charCodeAt(0);
+       var from_row = from.charCodeAt(1) - "a1".charCodeAt(1);
+       var to_col   = to.charCodeAt(0) - "a1".charCodeAt(0);
+       var to_row   = to.charCodeAt(1) - "a1".charCodeAt(1);
+
+       occupied_by_arrows[from_row][from_col] = true;
+
+       // Knight move: Just check that we haven't been at the destination before.
+       if ((Math.abs(to_col - from_col) == 2 && Math.abs(to_row - from_row) == 1) ||
+           (Math.abs(to_col - from_col) == 1 && Math.abs(to_row - from_row) == 2)) {
+               return occupied_by_arrows[to_row][to_col];
+       }
+
+       // Sliding piece: Check if anything except the from-square is seen before.
+       var dx = sign(to_col - from_col);
+       var dy = sign(to_row - from_row);
+       var x = from_col;
+       var y = from_row;
+       do {
+               x += dx;
+               y += dy;
+               if (occupied_by_arrows[y][x]) {
+                       return true;
+               }
+               occupied_by_arrows[y][x] = true;
+       } while (x != to_col || y != to_row);
+
+       return false;
+}
+
+var add_target = function() {
+       var elem = document.createElement("div");
+       $(elem).addClass("window");
+       elem.id = "target" + arrow_targets.length;
+       document.body.appendChild(elem);        
+       arrow_targets.push(elem);
+       return elem.id;
+}
+
+var create_arrow = function(from_square, to_square, fg_color, line_width, arrow_size) {
+       var from_col = from_square.charCodeAt(0) - "a1".charCodeAt(0);
+       var from_row = from_square.charCodeAt(1) - "a1".charCodeAt(1);
+       var to_col   = to_square.charCodeAt(0) - "a1".charCodeAt(0);
+       var to_row   = to_square.charCodeAt(1) - "a1".charCodeAt(1);
+
+       var from_y = (7 - from_row)*49 + 25;
+       var to_y = (7 - to_row)*49 + 25;
+       var from_x = from_col*49 + 25;
+       var to_x = to_col*49 + 25;
+
+       var dx = to_x - from_x;
+       var dy = to_y - from_y;
+       var len = Math.sqrt(dx * dx + dy * dy);
+       dx /= len;
+       dy /= len;
+
+       // Create arrow.
+       var s1 = add_target();
+       var d1 = add_target();
+       var s1v = add_target();
+       var d1v = add_target();
+       var pos = $("#board").position();
+       $("#" + s1).css({ top: pos.top + from_y + (0.5 * arrow_size) * dy, left: pos.left + from_x + (0.5 * arrow_size) * dx });
+       $("#" + d1).css({ top: pos.top + to_y - (0.5 * arrow_size) * dy, left: pos.left + to_x - (0.5 * arrow_size) * dx });
+       $("#" + s1v).css({ top: pos.top + from_y - 0 * dy, left: pos.left + from_x - 0 * dx });
+       $("#" + d1v).css({ top: pos.top + to_y + 0 * dy, left: pos.left + to_x + 0 * dx });
+       var connection1 = jsPlumb.connect({
+               source: s1,
+               target: d1,
+               connector:["Straight"],
+               cssClass:"c1",
+               endpoint:"Blank",
+               endpointClass:"c1Endpoint",                                                                                                        
+               anchor:"Continuous",
+               paintStyle:{ 
+                       lineWidth:line_width,
+                       strokeStyle:fg_color,
+                       outlineWidth:1,
+                       outlineColor:"#666",
+                       opacity:"60%"
+               }
+       });            
+       var connection2 = jsPlumb.connect({
+               source: s1v,
+               target: d1v,
+               connector:["Straight"],
+               cssClass:"vir",
+               endpoint:"Blank",
+               endpointClass:"c1Endpoint",                                                                                                        
+               anchor:"Continuous",
+               paintStyle:{ 
+                       lineWidth:0,
+                       strokeStyle:fg_color,
+                       outlineWidth:0,
+                       outlineColor:"#666",
+               },
+               overlays : [
+                       ["Arrow", {
+                               cssClass:"l1arrow",
+                               location:1.0,
+                               width: arrow_size, length: arrow_size,
+                               paintStyle:{ 
+                                       lineWidth:line_width,
+                                       strokeStyle:"#000",
+                               },
+                       }]
+               ]
+       });
+       arrows.push(connection1);
+       arrows.push(connection2);
+}
+
+// Fake multi-PV using the refutation lines. Find all “relevant” moves,
+// sorted by quality, descending.
+var find_nonstupid_moves = function(data, margin) {
+       // First of all, if there are any moves that are more than 0.5 ahead of
+       // the primary move, the refutation lines are probably bunk, so just
+       // kill them all. 
+       var best_score = undefined;
+       var pv_score = undefined;
+       for (var move in data.refutation_lines) {
+               var score = data.refutation_lines[move].score_sort_key;
+               if (move == data.pv_uci[0]) {
+                       pv_score = score;
+               }
+               if (best_score === undefined || score > best_score) {
+                       best_score = score;
+               }
+               if (!(data.refutation_lines[move].depth >= 8)) {
+                       return [];
+               }
+       }
+
+       if (best_score - pv_score > 50) {
+               return [];
+       }
+
+       // Now find all moves that are within “margin” of the best score.
+       // The PV move will always be first.
+       var moves = [];
+       for (var move in data.refutation_lines) {
+               var score = data.refutation_lines[move].score_sort_key;
+               if (move != data.pv_uci[0] && best_score - score <= margin) {
+                       moves.push(move);
+               }
+       }
+       moves = moves.sort(function(a, b) { return data.refutation_lines[b].score_sort_key - data.refutation_lines[a].score_sort_key; });
+       moves.unshift(data.pv_uci[0]);
+
+       return moves;
+}
+
+var thousands = function(x) {
+       return String(x).split('').reverse().join('').replace(/(\d{3}\B)/g, '$1,').split('').reverse().join('');
+}
+
+var print_pv = function(pretty_pv, move_num, toplay, limit) {
+       var pv = '';
+       var i = 0;
+       if (toplay == 'B') {
+               pv = move_num + '. … ' + pretty_pv[0];
+               toplay = 'W';
+               ++i;    
+       }
+       ++move_num;
+       for ( ; i < pretty_pv.length; ++i) {
+               if (toplay == 'W') {
+                       if (i > limit) {
+                               return pv + ' (…)';
+                       }
+                       if (pv != '') {
+                               pv += ' ';
+                       }
+                       pv += move_num + '. ' + pretty_pv[i];
+                       ++move_num;
+                       toplay = 'B';
+               } else {
+                       pv += ' ' + pretty_pv[i];
+                       toplay = 'W';
+               }
+       }
+       return pv;
+}
+
+var compare_by_sort_key = function(data, a, b) {
+       var ska = data.refutation_lines[a].sort_key;
+       var skb = data.refutation_lines[b].sort_key;
+       if (ska < skb) return -1;
+       if (ska > skb) return 1;
+       return 0;
+};
+
+var update_board = function(board, data) {
+       // The headline.
+       var headline = 'Analysis';
+       if (data.position.last_move !== 'none') {
+               headline += ' after ' + data.position.move_num + '. ';
+               if (data.position.toplay == 'W') {
+                       headline += '… ';
+               }
+               headline += data.position.last_move;
+               if (data.id.name) {
+                       headline += ', ';
+               }
+       }
+
+       if (data.id.name) {
+               headline += ' by ' + data.id.name;  // + ':';
+       } else {
+               //headline += ':';
+       }
+       $("#headline").text(headline);
+
+       // The score.
+       if (data.score !== null) {
+               $("#score").text(data.score);
+       }
+
+       // The search stats.
+       if (data.nodes && data.nps && data.depth) {
+               var stats = thousands(data.nodes) + ' nodes, ' + thousands(data.nps) + ' nodes/sec, depth ' + data.depth + ' ply';
+               if (data.seldepth) {
+                       stats += ' (' + data.seldepth + ' selective)';
+               }
+               if (data.tbhits && data.tbhits > 0) {
+                       if (data.tbhits == 1) {
+                               stats += ', one Nalimov hit';
+                       } else {
+                               stats += ', ' + data.tbhits + ' Nalimov hits';
+                       }
+               }
+               
+
+               $("#searchstats").text(stats);
+       }
+
+       // Update the board itself.
+       board.position(data.position.fen);
+
+       $("#board").find('.square-55d63').removeClass('nonuglyhighlight');
+       if (data.position.last_move_uci) {
+               var from = data.position.last_move_uci.substr(0, 2);
+               var to = data.position.last_move_uci.substr(2, 4);
+               $("#board").find('.square-' + from).addClass('nonuglyhighlight');
+               $("#board").find('.square-' + to).addClass('nonuglyhighlight');
+       }
+
+       // Print the PV.
+       var pv = print_pv(data.pv_pretty, data.position.move_num, data.position.toplay);
+       $("#pv").text(pv);
+
+       // Update the PV arrow.
+       clear_arrows();
+       if (data.pv_uci.length >= 1) {
+               // draw a continuation arrow as long as it's the same piece
+               for (var i = 0; i < data.pv_uci.length; i += 2) {
+                       var from = data.pv_uci[i].substr(0, 2);
+                       var to = data.pv_uci[i].substr(2,4);
+                       if ((i >= 2 && from != data.pv_uci[i - 2].substr(2, 4)) ||
+                            interfering_arrow(from, to)) {
+                               break;
+                       }
+                       create_arrow(from, to, '#f66', 6, 20);
+               }
+
+               var alt_moves = find_nonstupid_moves(data, 30);
+               for (var i = 1; i < alt_moves.length && i < 3; ++i) {
+                       create_arrow(alt_moves[i].substr(0, 2),
+                                    alt_moves[i].substr(2, 4), '#f66', 1, 10);
+               }
+       }
+
+       // See if all semi-reasonable moves have only one possible response.
+       if (data.pv_uci.length >= 2) {
+               var nonstupid_moves = find_nonstupid_moves(data, 300);
+               var response = data.pv_uci[1];
+               for (var i = 0; i < nonstupid_moves.length; ++i) {
+                       if (nonstupid_moves[i] == data.pv_uci[0]) {
+                               // ignore the PV move for refutation lines.
+                               continue;
+                       }
+                       if (!data.refutation_lines ||
+                           !data.refutation_lines[nonstupid_moves[i]] ||
+                           !data.refutation_lines[nonstupid_moves[i]].pv_uci ||
+                           data.refutation_lines[nonstupid_moves[i]].pv_uci.length < 1) {
+                               // Incomplete PV, abort.
+                               response = undefined;
+                               break;
+                       }
+                       var this_response = data.refutation_lines[nonstupid_moves[i]].pv_uci[1];
+                       if (response !== this_response) {
+                               // Different response depending on lines, abort.
+                               response = undefined;
+                               break;
+                       }
+               }
+
+               if (nonstupid_moves.length > 0 && response !== undefined) {
+                       create_arrow(response.substr(0, 2),
+                                    response.substr(2, 4), '#66f', 6, 20);
+               }
+       }
+
+       // Show the refutation lines.
+       var tbl = $("#refutationlines");
+       tbl.empty();
+
+       moves = [];
+       for (var move in data.refutation_lines) {
+               moves.push(move);
+       }
+       moves = moves.sort(function(a, b) { return compare_by_sort_key(data, a, b) });
+       for (var i = 0; i < moves.length; ++i) {
+               var line = data.refutation_lines[moves[i]];
+
+               var tr = document.createElement("tr");
+
+               var move_td = document.createElement("td");
+               tr.appendChild(move_td);
+               $(move_td).addClass("move");
+               $(move_td).text(line.pretty_move);
+
+               var score_td = document.createElement("td");
+               tr.appendChild(score_td);
+               $(score_td).addClass("score");
+               $(score_td).text(line.pretty_score);
+
+               var depth_td = document.createElement("td");
+               tr.appendChild(depth_td);
+               $(depth_td).addClass("depth");
+               $(depth_td).text("d" + line.depth);
+
+               var pv_td = document.createElement("td");
+               tr.appendChild(pv_td);
+               $(pv_td).addClass("pv");
+               $(pv_td).text(print_pv(line.pv_pretty, data.position.move_num, data.position.toplay, 10));
+
+               tbl.append(tr);
+       }
+
+       // Next update.
+       setTimeout(function() { request_update(board, 0); }, 100);
+}
+
+var init = function() {
+       // Create board.
+       var board = new ChessBoard('board', 'start');
+
+       request_update(board, 1);
+
+};
+$(document).ready(init);
+</script>
+</body>
+</html>
diff --git a/www/js/chessboard-0.3.0.js b/www/js/chessboard-0.3.0.js
new file mode 100644 (file)
index 0000000..8f1ac2d
--- /dev/null
@@ -0,0 +1,1714 @@
+/*!
+ * chessboard.js v0.3.0
+ *
+ * Copyright 2013 Chris Oakman
+ * Released under the MIT license
+ * http://chessboardjs.com/license
+ *
+ * Date: 10 Aug 2013
+ */
+
+// start anonymous scope
+;(function() {
+'use strict';
+
+//------------------------------------------------------------------------------
+// Chess Util Functions
+//------------------------------------------------------------------------------
+var COLUMNS = 'abcdefgh'.split('');
+
+function validMove(move) {
+  // move should be a string
+  if (typeof move !== 'string') return false;
+
+  // move should be in the form of "e2-e4", "f6-d5"
+  var tmp = move.split('-');
+  if (tmp.length !== 2) return false;
+
+  return (validSquare(tmp[0]) === true && validSquare(tmp[1]) === true);
+}
+
+function validSquare(square) {
+  if (typeof square !== 'string') return false;
+  return (square.search(/^[a-h][1-8]$/) !== -1);
+}
+
+function validPieceCode(code) {
+  if (typeof code !== 'string') return false;
+  return (code.search(/^[bw][KQRNBP]$/) !== -1);
+}
+
+// TODO: this whole function could probably be replaced with a single regex
+function validFen(fen) {
+  if (typeof fen !== 'string') return false;
+
+  // cut off any move, castling, etc info from the end
+  // we're only interested in position information
+  fen = fen.replace(/ .+$/, '');
+
+  // FEN should be 8 sections separated by slashes
+  var chunks = fen.split('/');
+  if (chunks.length !== 8) return false;
+
+  // check the piece sections
+  for (var i = 0; i < 8; i++) {
+    if (chunks[i] === '' ||
+        chunks[i].length > 8 ||
+        chunks[i].search(/[^kqrbnpKQRNBP1-8]/) !== -1) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+function validPositionObject(pos) {
+  if (typeof pos !== 'object') return false;
+
+  for (var i in pos) {
+    if (pos.hasOwnProperty(i) !== true) continue;
+
+    if (validSquare(i) !== true || validPieceCode(pos[i]) !== true) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+// convert FEN piece code to bP, wK, etc
+function fenToPieceCode(piece) {
+  // black piece
+  if (piece.toLowerCase() === piece) {
+    return 'b' + piece.toUpperCase();
+  }
+
+  // white piece
+  return 'w' + piece.toUpperCase();
+}
+
+// convert bP, wK, etc code to FEN structure
+function pieceCodeToFen(piece) {
+  var tmp = piece.split('');
+
+  // white piece
+  if (tmp[0] === 'w') {
+    return tmp[1].toUpperCase();
+  }
+
+  // black piece
+  return tmp[1].toLowerCase();
+}
+
+// convert FEN string to position object
+// returns false if the FEN string is invalid
+function fenToObj(fen) {
+  if (validFen(fen) !== true) {
+    return false;
+  }
+
+  // cut off any move, castling, etc info from the end
+  // we're only interested in position information
+  fen = fen.replace(/ .+$/, '');
+
+  var rows = fen.split('/');
+  var position = {};
+
+  var currentRow = 8;
+  for (var i = 0; i < 8; i++) {
+    var row = rows[i].split('');
+    var colIndex = 0;
+
+    // loop through each character in the FEN section
+    for (var j = 0; j < row.length; j++) {
+      // number / empty squares
+      if (row[j].search(/[1-8]/) !== -1) {
+        var emptySquares = parseInt(row[j], 10);
+        colIndex += emptySquares;
+      }
+      // piece
+      else {
+        var square = COLUMNS[colIndex] + currentRow;
+        position[square] = fenToPieceCode(row[j]);
+        colIndex++;
+      }
+    }
+
+    currentRow--;
+  }
+
+  return position;
+}
+
+// position object to FEN string
+// returns false if the obj is not a valid position object
+function objToFen(obj) {
+  if (validPositionObject(obj) !== true) {
+    return false;
+  }
+
+  var fen = '';
+
+  var currentRow = 8;
+  for (var i = 0; i < 8; i++) {
+    for (var j = 0; j < 8; j++) {
+      var square = COLUMNS[j] + currentRow;
+
+      // piece exists
+      if (obj.hasOwnProperty(square) === true) {
+        fen += pieceCodeToFen(obj[square]);
+      }
+
+      // empty space
+      else {
+        fen += '1';
+      }
+    }
+
+    if (i !== 7) {
+      fen += '/';
+    }
+
+    currentRow--;
+  }
+
+  // squeeze the numbers together
+  // haha, I love this solution...
+  fen = fen.replace(/11111111/g, '8');
+  fen = fen.replace(/1111111/g, '7');
+  fen = fen.replace(/111111/g, '6');
+  fen = fen.replace(/11111/g, '5');
+  fen = fen.replace(/1111/g, '4');
+  fen = fen.replace(/111/g, '3');
+  fen = fen.replace(/11/g, '2');
+
+  return fen;
+}
+
+window['ChessBoard'] = window['ChessBoard'] || function(containerElOrId, cfg) {
+'use strict';
+
+cfg = cfg || {};
+
+//------------------------------------------------------------------------------
+// Constants
+//------------------------------------------------------------------------------
+
+var MINIMUM_JQUERY_VERSION = '1.7.0',
+  START_FEN = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR',
+  START_POSITION = fenToObj(START_FEN);
+
+// use unique class names to prevent clashing with anything else on the page
+// and simplify selectors
+var CSS = {
+  alpha: 'alpha-d2270',
+  black: 'black-3c85d',
+  board: 'board-b72b1',
+  chessboard: 'chessboard-63f37',
+  clearfix: 'clearfix-7da63',
+  highlight1: 'highlight1-32417',
+  highlight2: 'highlight2-9c5d2',
+  notation: 'notation-322f9',
+  numeric: 'numeric-fc462',
+  piece: 'piece-417db',
+  row: 'row-5277c',
+  sparePieces: 'spare-pieces-7492f',
+  sparePiecesBottom: 'spare-pieces-bottom-ae20f',
+  sparePiecesTop: 'spare-pieces-top-4028b',
+  square: 'square-55d63',
+  white: 'white-1e1d7'
+};
+
+//------------------------------------------------------------------------------
+// Module Scope Variables
+//------------------------------------------------------------------------------
+
+// DOM elements
+var containerEl,
+  boardEl,
+  draggedPieceEl,
+  sparePiecesTopEl,
+  sparePiecesBottomEl;
+
+// constructor return object
+var widget = {};
+
+//------------------------------------------------------------------------------
+// Stateful
+//------------------------------------------------------------------------------
+
+var ANIMATION_HAPPENING = false,
+  BOARD_BORDER_SIZE = 2,
+  CURRENT_ORIENTATION = 'white',
+  CURRENT_POSITION = {},
+  SQUARE_SIZE,
+  DRAGGED_PIECE,
+  DRAGGED_PIECE_LOCATION,
+  DRAGGED_PIECE_SOURCE,
+  DRAGGING_A_PIECE = false,
+  SPARE_PIECE_ELS_IDS = {},
+  SQUARE_ELS_IDS = {},
+  SQUARE_ELS_OFFSETS;
+
+//------------------------------------------------------------------------------
+// JS Util Functions
+//------------------------------------------------------------------------------
+
+// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
+function createId() {
+  return 'xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/x/g, function(c) {
+    var r = Math.random() * 16 | 0;
+    return r.toString(16);
+  });
+}
+
+function deepCopy(thing) {
+  return JSON.parse(JSON.stringify(thing));
+}
+
+function parseSemVer(version) {
+  var tmp = version.split('.');
+  return {
+    major: parseInt(tmp[0], 10),
+    minor: parseInt(tmp[1], 10),
+    patch: parseInt(tmp[2], 10)
+  };
+}
+
+// returns true if version is >= minimum
+function compareSemVer(version, minimum) {
+  version = parseSemVer(version);
+  minimum = parseSemVer(minimum);
+
+  var versionNum = (version.major * 10000 * 10000) +
+    (version.minor * 10000) + version.patch;
+  var minimumNum = (minimum.major * 10000 * 10000) +
+    (minimum.minor * 10000) + minimum.patch;
+
+  return (versionNum >= minimumNum);
+}
+
+//------------------------------------------------------------------------------
+// Validation / Errors
+//------------------------------------------------------------------------------
+
+function error(code, msg, obj) {
+  // do nothing if showErrors is not set
+  if (cfg.hasOwnProperty('showErrors') !== true ||
+      cfg.showErrors === false) {
+    return;
+  }
+
+  var errorText = 'ChessBoard Error ' + code + ': ' + msg;
+
+  // print to console
+  if (cfg.showErrors === 'console' &&
+      typeof console === 'object' &&
+      typeof console.log === 'function') {
+    console.log(errorText);
+    if (arguments.length >= 2) {
+      console.log(obj);
+    }
+    return;
+  }
+
+  // alert errors
+  if (cfg.showErrors === 'alert') {
+    if (obj) {
+      errorText += '\n\n' + JSON.stringify(obj);
+    }
+    window.alert(errorText);
+    return;
+  }
+
+  // custom function
+  if (typeof cfg.showErrors === 'function') {
+    cfg.showErrors(code, msg, obj);
+  }
+}
+
+// check dependencies
+function checkDeps() {
+  // if containerId is a string, it must be the ID of a DOM node
+  if (typeof containerElOrId === 'string') {
+    // cannot be empty
+    if (containerElOrId === '') {
+      window.alert('ChessBoard Error 1001: ' +
+        'The first argument to ChessBoard() cannot be an empty string.' +
+        '\n\nExiting...');
+      return false;
+    }
+
+    // make sure the container element exists in the DOM
+    var el = document.getElementById(containerElOrId);
+    if (! el) {
+      window.alert('ChessBoard Error 1002: Element with id "' +
+        containerElOrId + '" does not exist in the DOM.' +
+        '\n\nExiting...');
+      return false;
+    }
+
+    // set the containerEl
+    containerEl = $(el);
+  }
+
+  // else it must be something that becomes a jQuery collection
+  // with size 1
+  // ie: a single DOM node or jQuery object
+  else {
+    containerEl = $(containerElOrId);
+
+    if (containerEl.length !== 1) {
+      window.alert('ChessBoard Error 1003: The first argument to ' +
+        'ChessBoard() must be an ID or a single DOM node.' +
+        '\n\nExiting...');
+      return false;
+    }
+  }
+
+  // JSON must exist
+  if (! window.JSON ||
+      typeof JSON.stringify !== 'function' ||
+      typeof JSON.parse !== 'function') {
+    window.alert('ChessBoard Error 1004: JSON does not exist. ' +
+      'Please include a JSON polyfill.\n\nExiting...');
+    return false;
+  }
+
+  // check for a compatible version of jQuery
+  if (! (typeof window.$ && $.fn && $.fn.jquery &&
+      compareSemVer($.fn.jquery, MINIMUM_JQUERY_VERSION) === true)) {
+    window.alert('ChessBoard Error 1005: Unable to find a valid version ' +
+      'of jQuery. Please include jQuery ' + MINIMUM_JQUERY_VERSION + ' or ' +
+      'higher on the page.\n\nExiting...');
+    return false;
+  }
+
+  return true;
+}
+
+function validAnimationSpeed(speed) {
+  if (speed === 'fast' || speed === 'slow') {
+    return true;
+  }
+
+  if ((parseInt(speed, 10) + '') !== (speed + '')) {
+    return false;
+  }
+
+  return (speed >= 0);
+}
+
+// validate config / set default options
+function expandConfig() {
+  if (typeof cfg === 'string' || validPositionObject(cfg) === true) {
+    cfg = {
+      position: cfg
+    };
+  }
+
+  // default for orientation is white
+  if (cfg.orientation !== 'black') {
+    cfg.orientation = 'white';
+  }
+  CURRENT_ORIENTATION = cfg.orientation;
+
+  // default for showNotation is true
+  if (cfg.showNotation !== false) {
+    cfg.showNotation = true;
+  }
+
+  // default for draggable is false
+  if (cfg.draggable !== true) {
+    cfg.draggable = false;
+  }
+
+  // default for dropOffBoard is 'snapback'
+  if (cfg.dropOffBoard !== 'trash') {
+    cfg.dropOffBoard = 'snapback';
+  }
+
+  // default for sparePieces is false
+  if (cfg.sparePieces !== true) {
+    cfg.sparePieces = false;
+  }
+
+  // draggable must be true if sparePieces is enabled
+  if (cfg.sparePieces === true) {
+    cfg.draggable = true;
+  }
+
+  // default piece theme is wikipedia
+  if (cfg.hasOwnProperty('pieceTheme') !== true ||
+      (typeof cfg.pieceTheme !== 'string' &&
+       typeof cfg.pieceTheme !== 'function')) {
+    cfg.pieceTheme = 'img/chesspieces/wikipedia/{piece}.png';
+  }
+
+  // animation speeds
+  if (cfg.hasOwnProperty('appearSpeed') !== true ||
+      validAnimationSpeed(cfg.appearSpeed) !== true) {
+    cfg.appearSpeed = 200;
+  }
+  if (cfg.hasOwnProperty('moveSpeed') !== true ||
+      validAnimationSpeed(cfg.moveSpeed) !== true) {
+    cfg.moveSpeed = 200;
+  }
+  if (cfg.hasOwnProperty('snapbackSpeed') !== true ||
+      validAnimationSpeed(cfg.snapbackSpeed) !== true) {
+    cfg.snapbackSpeed = 50;
+  }
+  if (cfg.hasOwnProperty('snapSpeed') !== true ||
+      validAnimationSpeed(cfg.snapSpeed) !== true) {
+    cfg.snapSpeed = 25;
+  }
+  if (cfg.hasOwnProperty('trashSpeed') !== true ||
+      validAnimationSpeed(cfg.trashSpeed) !== true) {
+    cfg.trashSpeed = 100;
+  }
+
+  // make sure position is valid
+  if (cfg.hasOwnProperty('position') === true) {
+    if (cfg.position === 'start') {
+      CURRENT_POSITION = deepCopy(START_POSITION);
+    }
+
+    else if (validFen(cfg.position) === true) {
+      CURRENT_POSITION = fenToObj(cfg.position);
+    }
+
+    else if (validPositionObject(cfg.position) === true) {
+      CURRENT_POSITION = deepCopy(cfg.position);
+    }
+
+    else {
+      error(7263, 'Invalid value passed to config.position.', cfg.position);
+    }
+  }
+
+  return true;
+}
+
+//------------------------------------------------------------------------------
+// DOM Misc
+//------------------------------------------------------------------------------
+
+// calculates square size based on the width of the container
+// got a little CSS black magic here, so let me explain:
+// get the width of the container element (could be anything), reduce by 1 for
+// fudge factor, and then keep reducing until we find an exact mod 8 for
+// our square size
+function calculateSquareSize() {
+  var containerWidth = parseInt(containerEl.css('width'), 10);
+
+  // defensive, prevent infinite loop
+  if (! containerWidth || containerWidth <= 0) {
+    return 0;
+  }
+
+  // pad one pixel
+  var boardWidth = containerWidth - 1;
+
+  while (boardWidth % 8 !== 0 && boardWidth > 0) {
+    boardWidth--;
+  }
+
+  return (boardWidth / 8);
+}
+
+// create random IDs for elements
+function createElIds() {
+  // squares on the board
+  for (var i = 0; i < COLUMNS.length; i++) {
+    for (var j = 1; j <= 8; j++) {
+      var square = COLUMNS[i] + j;
+      SQUARE_ELS_IDS[square] = square + '-' + createId();
+    }
+  }
+
+  // spare pieces
+  var pieces = 'KQRBNP'.split('');
+  for (var i = 0; i < pieces.length; i++) {
+    var whitePiece = 'w' + pieces[i];
+    var blackPiece = 'b' + pieces[i];
+    SPARE_PIECE_ELS_IDS[whitePiece] = whitePiece + '-' + createId();
+    SPARE_PIECE_ELS_IDS[blackPiece] = blackPiece + '-' + createId();
+  }
+}
+
+//------------------------------------------------------------------------------
+// Markup Building
+//------------------------------------------------------------------------------
+
+function buildBoardContainer() {
+  var html = '<div class="' + CSS.chessboard + '">';
+
+  if (cfg.sparePieces === true) {
+    html += '<div class="' + CSS.sparePieces + ' ' +
+      CSS.sparePiecesTop + '"></div>';
+  }
+
+  html += '<div class="' + CSS.board + '"></div>';
+
+  if (cfg.sparePieces === true) {
+    html += '<div class="' + CSS.sparePieces + ' ' +
+      CSS.sparePiecesBottom + '"></div>';
+  }
+
+  html += '</div>';
+
+  return html;
+}
+
+/*
+var buildSquare = function(color, size, id) {
+  var html = '<div class="' + CSS.square + ' ' + CSS[color] + '" ' +
+  'style="width: ' + size + 'px; height: ' + size + 'px" ' +
+  'id="' + id + '">';
+
+  if (cfg.showNotation === true) {
+
+  }
+
+  html += '</div>';
+
+  return html;
+};
+*/
+
+function buildBoard(orientation) {
+  if (orientation !== 'black') {
+    orientation = 'white';
+  }
+
+  var html = '';
+
+  // algebraic notation / orientation
+  var alpha = deepCopy(COLUMNS);
+  var row = 8;
+  if (orientation === 'black') {
+    alpha.reverse();
+    row = 1;
+  }
+
+  var squareColor = 'white';
+  for (var i = 0; i < 8; i++) {
+    html += '<div class="' + CSS.row + '">';
+    for (var j = 0; j < 8; j++) {
+      var square = alpha[j] + row;
+
+      html += '<div class="' + CSS.square + ' ' + CSS[squareColor] + ' ' +
+        'square-' + square + '" ' +
+        'style="width: ' + SQUARE_SIZE + 'px; height: ' + SQUARE_SIZE + 'px" ' +
+        'id="' + SQUARE_ELS_IDS[square] + '" ' +
+        'data-square="' + square + '">';
+
+      if (cfg.showNotation === true) {
+        // alpha notation
+        if ((orientation === 'white' && row === 1) ||
+            (orientation === 'black' && row === 8)) {
+          html += '<div class="' + CSS.notation + ' ' + CSS.alpha + '">' +
+            alpha[j] + '</div>';
+        }
+
+        // numeric notation
+        if (j === 0) {
+          html += '<div class="' + CSS.notation + ' ' + CSS.numeric + '">' +
+            row + '</div>';
+        }
+      }
+
+      html += '</div>'; // end .square
+
+      squareColor = (squareColor === 'white' ? 'black' : 'white');
+    }
+    html += '<div class="' + CSS.clearfix + '"></div></div>';
+
+    squareColor = (squareColor === 'white' ? 'black' : 'white');
+
+    if (orientation === 'white') {
+      row--;
+    }
+    else {
+      row++;
+    }
+  }
+
+  return html;
+}
+
+function buildPieceImgSrc(piece) {
+  if (typeof cfg.pieceTheme === 'function') {
+    return cfg.pieceTheme(piece);
+  }
+
+  if (typeof cfg.pieceTheme === 'string') {
+    return cfg.pieceTheme.replace(/{piece}/g, piece);
+  }
+
+  // NOTE: this should never happen
+  error(8272, 'Unable to build image source for cfg.pieceTheme.');
+  return '';
+}
+
+function buildPiece(piece, hidden, id) {
+  var html = '<img src="' + buildPieceImgSrc(piece) + '" ';
+  if (id && typeof id === 'string') {
+    html += 'id="' + id + '" ';
+  }
+  html += 'alt="" ' +
+  'class="' + CSS.piece + '" ' +
+  'data-piece="' + piece + '" ' +
+  'style="width: ' + SQUARE_SIZE + 'px;' +
+  'height: ' + SQUARE_SIZE + 'px;';
+  if (hidden === true) {
+    html += 'display:none;';
+  }
+  html += '" />';
+
+  return html;
+}
+
+function buildSparePieces(color) {
+  var pieces = ['wK', 'wQ', 'wR', 'wB', 'wN', 'wP'];
+  if (color === 'black') {
+    pieces = ['bK', 'bQ', 'bR', 'bB', 'bN', 'bP'];
+  }
+
+  var html = '';
+  for (var i = 0; i < pieces.length; i++) {
+    html += buildPiece(pieces[i], false, SPARE_PIECE_ELS_IDS[pieces[i]]);
+  }
+
+  return html;
+}
+
+//------------------------------------------------------------------------------
+// Animations
+//------------------------------------------------------------------------------
+
+function animateSquareToSquare(src, dest, piece, completeFn) {
+  // get information about the source and destination squares
+  var srcSquareEl = $('#' + SQUARE_ELS_IDS[src]);
+  var srcSquarePosition = srcSquareEl.offset();
+  var destSquareEl = $('#' + SQUARE_ELS_IDS[dest]);
+  var destSquarePosition = destSquareEl.offset();
+
+  // create the animated piece and absolutely position it
+  // over the source square
+  var animatedPieceId = createId();
+  $('body').append(buildPiece(piece, true, animatedPieceId));
+  var animatedPieceEl = $('#' + animatedPieceId);
+  animatedPieceEl.css({
+    display: '',
+    position: 'absolute',
+    top: srcSquarePosition.top,
+    left: srcSquarePosition.left
+  });
+
+  // remove original piece from source square
+  srcSquareEl.find('.' + CSS.piece).remove();
+
+  // on complete
+  var complete = function() {
+    // add the "real" piece to the destination square
+    destSquareEl.append(buildPiece(piece));
+
+    // remove the animated piece
+    animatedPieceEl.remove();
+
+    // run complete function
+    if (typeof completeFn === 'function') {
+      completeFn();
+    }
+  };
+
+  // animate the piece to the destination square
+  var opts = {
+    duration: cfg.moveSpeed,
+    complete: complete
+  };
+  animatedPieceEl.animate(destSquarePosition, opts);
+}
+
+function animateSparePieceToSquare(piece, dest, completeFn) {
+  var srcOffset = $('#' + SPARE_PIECE_ELS_IDS[piece]).offset();
+  var destSquareEl = $('#' + SQUARE_ELS_IDS[dest]);
+  var destOffset = destSquareEl.offset();
+
+  // create the animate piece
+  var pieceId = createId();
+  $('body').append(buildPiece(piece, true, pieceId));
+  var animatedPieceEl = $('#' + pieceId);
+  animatedPieceEl.css({
+    display: '',
+    position: 'absolute',
+    left: srcOffset.left,
+    top: srcOffset.top
+  });
+
+  // on complete
+  var complete = function() {
+    // add the "real" piece to the destination square
+    destSquareEl.find('.' + CSS.piece).remove();
+    destSquareEl.append(buildPiece(piece));
+
+    // remove the animated piece
+    animatedPieceEl.remove();
+
+    // run complete function
+    if (typeof completeFn === 'function') {
+      completeFn();
+    }
+  };
+
+  // animate the piece to the destination square
+  var opts = {
+    duration: cfg.moveSpeed,
+    complete: complete
+  };
+  animatedPieceEl.animate(destOffset, opts);
+}
+
+// execute an array of animations
+function doAnimations(a, oldPos, newPos) {
+  ANIMATION_HAPPENING = true;
+
+  var numFinished = 0;
+  function onFinish() {
+    numFinished++;
+
+    // exit if all the animations aren't finished
+    if (numFinished !== a.length) return;
+
+    drawPositionInstant();
+    ANIMATION_HAPPENING = false;
+
+    // run their onMoveEnd function
+    if (cfg.hasOwnProperty('onMoveEnd') === true &&
+      typeof cfg.onMoveEnd === 'function') {
+      cfg.onMoveEnd(deepCopy(oldPos), deepCopy(newPos));
+    }
+  }
+
+  for (var i = 0; i < a.length; i++) {
+    // clear a piece
+    if (a[i].type === 'clear') {
+      $('#' + SQUARE_ELS_IDS[a[i].square] + ' .' + CSS.piece)
+        .fadeOut(cfg.trashSpeed, onFinish);
+    }
+
+    // add a piece (no spare pieces)
+    if (a[i].type === 'add' && cfg.sparePieces !== true) {
+      $('#' + SQUARE_ELS_IDS[a[i].square])
+        .append(buildPiece(a[i].piece, true))
+        .find('.' + CSS.piece)
+        .fadeIn(cfg.appearSpeed, onFinish);
+    }
+
+    // add a piece from a spare piece
+    if (a[i].type === 'add' && cfg.sparePieces === true) {
+      animateSparePieceToSquare(a[i].piece, a[i].square, onFinish);
+    }
+
+    // move a piece
+    if (a[i].type === 'move') {
+      animateSquareToSquare(a[i].source, a[i].destination, a[i].piece,
+        onFinish);
+    }
+  }
+}
+
+// returns the distance between two squares
+function squareDistance(s1, s2) {
+  s1 = s1.split('');
+  var s1x = COLUMNS.indexOf(s1[0]) + 1;
+  var s1y = parseInt(s1[1], 10);
+
+  s2 = s2.split('');
+  var s2x = COLUMNS.indexOf(s2[0]) + 1;
+  var s2y = parseInt(s2[1], 10);
+
+  var xDelta = Math.abs(s1x - s2x);
+  var yDelta = Math.abs(s1y - s2y);
+
+  if (xDelta >= yDelta) return xDelta;
+  return yDelta;
+}
+
+// returns an array of closest squares from square
+function createRadius(square) {
+  var squares = [];
+
+  // calculate distance of all squares
+  for (var i = 0; i < 8; i++) {
+    for (var j = 0; j < 8; j++) {
+      var s = COLUMNS[i] + (j + 1);
+
+      // skip the square we're starting from
+      if (square === s) continue;
+
+      squares.push({
+        square: s,
+        distance: squareDistance(square, s)
+      });
+    }
+  }
+
+  // sort by distance
+  squares.sort(function(a, b) {
+    return a.distance - b.distance;
+  });
+
+  // just return the square code
+  var squares2 = [];
+  for (var i = 0; i < squares.length; i++) {
+    squares2.push(squares[i].square);
+  }
+
+  return squares2;
+}
+
+// returns the square of the closest instance of piece
+// returns false if no instance of piece is found in position
+function findClosestPiece(position, piece, square) {
+  // create array of closest squares from square
+  var closestSquares = createRadius(square);
+
+  // search through the position in order of distance for the piece
+  for (var i = 0; i < closestSquares.length; i++) {
+    var s = closestSquares[i];
+
+    if (position.hasOwnProperty(s) === true && position[s] === piece) {
+      return s;
+    }
+  }
+
+  return false;
+}
+
+// calculate an array of animations that need to happen in order to get
+// from pos1 to pos2
+function calculateAnimations(pos1, pos2) {
+  // make copies of both
+  pos1 = deepCopy(pos1);
+  pos2 = deepCopy(pos2);
+
+  var animations = [];
+  var squaresMovedTo = {};
+
+  // remove pieces that are the same in both positions
+  for (var i in pos2) {
+    if (pos2.hasOwnProperty(i) !== true) continue;
+
+    if (pos1.hasOwnProperty(i) === true && pos1[i] === pos2[i]) {
+      delete pos1[i];
+      delete pos2[i];
+    }
+  }
+
+  // find all the "move" animations
+  for (var i in pos2) {
+    if (pos2.hasOwnProperty(i) !== true) continue;
+
+    var closestPiece = findClosestPiece(pos1, pos2[i], i);
+    if (closestPiece !== false) {
+      animations.push({
+        type: 'move',
+        source: closestPiece,
+        destination: i,
+        piece: pos2[i]
+      });
+
+      delete pos1[closestPiece];
+      delete pos2[i];
+      squaresMovedTo[i] = true;
+    }
+  }
+
+  // add pieces to pos2
+  for (var i in pos2) {
+    if (pos2.hasOwnProperty(i) !== true) continue;
+
+    animations.push({
+      type: 'add',
+      square: i,
+      piece: pos2[i]
+    })
+
+    delete pos2[i];
+  }
+
+  // clear pieces from pos1
+  for (var i in pos1) {
+    if (pos1.hasOwnProperty(i) !== true) continue;
+
+    // do not clear a piece if it is on a square that is the result
+    // of a "move", ie: a piece capture
+    if (squaresMovedTo.hasOwnProperty(i) === true) continue;
+
+    animations.push({
+      type: 'clear',
+      square: i,
+      piece: pos1[i]
+    });
+
+    delete pos1[i];
+  }
+
+  return animations;
+}
+
+//------------------------------------------------------------------------------
+// Control Flow
+//------------------------------------------------------------------------------
+
+function drawPositionInstant() {
+  // clear the board
+  boardEl.find('.' + CSS.piece).remove();
+
+  // add the pieces
+  for (var i in CURRENT_POSITION) {
+    if (CURRENT_POSITION.hasOwnProperty(i) !== true) continue;
+
+    $('#' + SQUARE_ELS_IDS[i]).append(buildPiece(CURRENT_POSITION[i]));
+  }
+}
+
+function drawBoard() {
+  boardEl.html(buildBoard(CURRENT_ORIENTATION));
+  drawPositionInstant();
+
+  if (cfg.sparePieces === true) {
+    if (CURRENT_ORIENTATION === 'white') {
+      sparePiecesTopEl.html(buildSparePieces('black'));
+      sparePiecesBottomEl.html(buildSparePieces('white'));
+    }
+    else {
+      sparePiecesTopEl.html(buildSparePieces('white'));
+      sparePiecesBottomEl.html(buildSparePieces('black'));
+    }
+  }
+}
+
+// given a position and a set of moves, return a new position
+// with the moves executed
+function calculatePositionFromMoves(position, moves) {
+  position = deepCopy(position);
+
+  for (var i in moves) {
+    if (moves.hasOwnProperty(i) !== true) continue;
+
+    // skip the move if the position doesn't have a piece on the source square
+    if (position.hasOwnProperty(i) !== true) continue;
+
+    var piece = position[i];
+    delete position[i];
+    position[moves[i]] = piece;
+  }
+
+  return position;
+}
+
+function setCurrentPosition(position) {
+  var oldPos = deepCopy(CURRENT_POSITION);
+  var newPos = deepCopy(position);
+  var oldFen = objToFen(oldPos);
+  var newFen = objToFen(newPos);
+
+  // do nothing if no change in position
+  if (oldFen === newFen) return;
+
+  // run their onChange function
+  if (cfg.hasOwnProperty('onChange') === true &&
+    typeof cfg.onChange === 'function') {
+    cfg.onChange(oldPos, newPos);
+  }
+
+  // update state
+  CURRENT_POSITION = position;
+}
+
+function isXYOnSquare(x, y) {
+  for (var i in SQUARE_ELS_OFFSETS) {
+    if (SQUARE_ELS_OFFSETS.hasOwnProperty(i) !== true) continue;
+
+    var s = SQUARE_ELS_OFFSETS[i];
+    if (x >= s.left && x < s.left + SQUARE_SIZE &&
+        y >= s.top && y < s.top + SQUARE_SIZE) {
+      return i;
+    }
+  }
+
+  return 'offboard';
+}
+
+// records the XY coords of every square into memory
+function captureSquareOffsets() {
+  SQUARE_ELS_OFFSETS = {};
+
+  for (var i in SQUARE_ELS_IDS) {
+    if (SQUARE_ELS_IDS.hasOwnProperty(i) !== true) continue;
+
+    SQUARE_ELS_OFFSETS[i] = $('#' + SQUARE_ELS_IDS[i]).offset();
+  }
+}
+
+function removeSquareHighlights() {
+  boardEl.find('.' + CSS.square)
+    .removeClass(CSS.highlight1 + ' ' + CSS.highlight2);
+}
+
+function snapbackDraggedPiece() {
+  // there is no "snapback" for spare pieces
+  if (DRAGGED_PIECE_SOURCE === 'spare') {
+    trashDraggedPiece();
+    return;
+  }
+
+  removeSquareHighlights();
+
+  // animation complete
+  function complete() {
+    drawPositionInstant();
+    draggedPieceEl.css('display', 'none');
+
+    // run their onSnapbackEnd function
+    if (cfg.hasOwnProperty('onSnapbackEnd') === true &&
+      typeof cfg.onSnapbackEnd === 'function') {
+      cfg.onSnapbackEnd(DRAGGED_PIECE, DRAGGED_PIECE_SOURCE,
+        deepCopy(CURRENT_POSITION), CURRENT_ORIENTATION);
+    }
+  }
+
+  // get source square position
+  var sourceSquarePosition =
+    $('#' + SQUARE_ELS_IDS[DRAGGED_PIECE_SOURCE]).offset();
+
+  // animate the piece to the target square
+  var opts = {
+    duration: cfg.snapbackSpeed,
+    complete: complete
+  };
+  draggedPieceEl.animate(sourceSquarePosition, opts);
+
+  // set state
+  DRAGGING_A_PIECE = false;
+}
+
+function trashDraggedPiece() {
+  removeSquareHighlights();
+
+  // remove the source piece
+  var newPosition = deepCopy(CURRENT_POSITION);
+  delete newPosition[DRAGGED_PIECE_SOURCE];
+  setCurrentPosition(newPosition);
+
+  // redraw the position
+  drawPositionInstant();
+
+  // hide the dragged piece
+  draggedPieceEl.fadeOut(cfg.trashSpeed);
+
+  // set state
+  DRAGGING_A_PIECE = false;
+}
+
+function dropDraggedPieceOnSquare(square) {
+  removeSquareHighlights();
+
+  // update position
+  var newPosition = deepCopy(CURRENT_POSITION);
+  delete newPosition[DRAGGED_PIECE_SOURCE];
+  newPosition[square] = DRAGGED_PIECE;
+  setCurrentPosition(newPosition);
+
+  // get target square information
+  var targetSquarePosition = $('#' + SQUARE_ELS_IDS[square]).offset();
+
+  // animation complete
+  var complete = function() {
+    drawPositionInstant();
+    draggedPieceEl.css('display', 'none');
+
+    // execute their onSnapEnd function
+    if (cfg.hasOwnProperty('onSnapEnd') === true &&
+      typeof cfg.onSnapEnd === 'function') {
+      cfg.onSnapEnd(DRAGGED_PIECE_SOURCE, square, DRAGGED_PIECE);
+    }
+  };
+
+  // snap the piece to the target square
+  var opts = {
+    duration: cfg.snapSpeed,
+    complete: complete
+  };
+  draggedPieceEl.animate(targetSquarePosition, opts);
+
+  // set state
+  DRAGGING_A_PIECE = false;
+}
+
+function beginDraggingPiece(source, piece, x, y) {
+  // run their custom onDragStart function
+  // their custom onDragStart function can cancel drag start
+  if (typeof cfg.onDragStart === 'function' &&
+      cfg.onDragStart(source, piece,
+        deepCopy(CURRENT_POSITION), CURRENT_ORIENTATION) === false) {
+    return;
+  }
+
+  // set state
+  DRAGGING_A_PIECE = true;
+  DRAGGED_PIECE = piece;
+  DRAGGED_PIECE_SOURCE = source;
+
+  // if the piece came from spare pieces, location is offboard
+  if (source === 'spare') {
+    DRAGGED_PIECE_LOCATION = 'offboard';
+  }
+  else {
+    DRAGGED_PIECE_LOCATION = source;
+  }
+
+  // capture the x, y coords of all squares in memory
+  captureSquareOffsets();
+
+  // create the dragged piece
+  draggedPieceEl.attr('src', buildPieceImgSrc(piece))
+    .css({
+      display: '',
+      position: 'absolute',
+      left: x - (SQUARE_SIZE / 2),
+      top: y - (SQUARE_SIZE / 2)
+    });
+
+  if (source !== 'spare') {
+    // highlight the source square and hide the piece
+    $('#' + SQUARE_ELS_IDS[source]).addClass(CSS.highlight1)
+      .find('.' + CSS.piece).css('display', 'none');
+  }
+}
+
+function updateDraggedPiece(x, y) {
+  // put the dragged piece over the mouse cursor
+  draggedPieceEl.css({
+    left: x - (SQUARE_SIZE / 2),
+    top: y - (SQUARE_SIZE / 2)
+  });
+
+  // get location
+  var location = isXYOnSquare(x, y);
+
+  // do nothing if the location has not changed
+  if (location === DRAGGED_PIECE_LOCATION) return;
+
+  // remove highlight from previous square
+  if (validSquare(DRAGGED_PIECE_LOCATION) === true) {
+    $('#' + SQUARE_ELS_IDS[DRAGGED_PIECE_LOCATION])
+      .removeClass(CSS.highlight2);
+  }
+
+  // add highlight to new square
+  if (validSquare(location) === true) {
+    $('#' + SQUARE_ELS_IDS[location]).addClass(CSS.highlight2);
+  }
+
+  // run onDragMove
+  if (typeof cfg.onDragMove === 'function') {
+    cfg.onDragMove(location, DRAGGED_PIECE_LOCATION,
+      DRAGGED_PIECE_SOURCE, DRAGGED_PIECE,
+      deepCopy(CURRENT_POSITION), CURRENT_ORIENTATION);
+  }
+
+  // update state
+  DRAGGED_PIECE_LOCATION = location;
+}
+
+function stopDraggedPiece(location) {
+  // determine what the action should be
+  var action = 'drop';
+  if (location === 'offboard' && cfg.dropOffBoard === 'snapback') {
+    action = 'snapback';
+  }
+  if (location === 'offboard' && cfg.dropOffBoard === 'trash') {
+    action = 'trash';
+  }
+
+  // run their onDrop function, which can potentially change the drop action
+  if (cfg.hasOwnProperty('onDrop') === true &&
+    typeof cfg.onDrop === 'function') {
+    var newPosition = deepCopy(CURRENT_POSITION);
+
+    // source piece is a spare piece and position is off the board
+    //if (DRAGGED_PIECE_SOURCE === 'spare' && location === 'offboard') {...}
+    // position has not changed; do nothing
+
+    // source piece is a spare piece and position is on the board
+    if (DRAGGED_PIECE_SOURCE === 'spare' && validSquare(location) === true) {
+      // add the piece to the board
+      newPosition[location] = DRAGGED_PIECE;
+    }
+
+    // source piece was on the board and position is off the board
+    if (validSquare(DRAGGED_PIECE_SOURCE) === true && location === 'offboard') {
+      // remove the piece from the board
+      delete newPosition[DRAGGED_PIECE_SOURCE];
+    }
+
+    // source piece was on the board and position is on the board
+    if (validSquare(DRAGGED_PIECE_SOURCE) === true &&
+      validSquare(location) === true) {
+      // move the piece
+      delete newPosition[DRAGGED_PIECE_SOURCE];
+      newPosition[location] = DRAGGED_PIECE;
+    }
+
+    var oldPosition = deepCopy(CURRENT_POSITION);
+
+    var result = cfg.onDrop(DRAGGED_PIECE_SOURCE, location, DRAGGED_PIECE,
+      newPosition, oldPosition, CURRENT_ORIENTATION);
+    if (result === 'snapback' || result === 'trash') {
+      action = result;
+    }
+  }
+
+  // do it!
+  if (action === 'snapback') {
+    snapbackDraggedPiece();
+  }
+  else if (action === 'trash') {
+    trashDraggedPiece();
+  }
+  else if (action === 'drop') {
+    dropDraggedPieceOnSquare(location);
+  }
+}
+
+//------------------------------------------------------------------------------
+// Public Methods
+//------------------------------------------------------------------------------
+
+// clear the board
+widget.clear = function(useAnimation) {
+  widget.position({}, useAnimation);
+};
+
+/*
+// get or set config properties
+// TODO: write this, GitHub Issue #1
+widget.config = function(arg1, arg2) {
+  // get the current config
+  if (arguments.length === 0) {
+    return deepCopy(cfg);
+  }
+};
+*/
+
+// remove the widget from the page
+widget.destroy = function() {
+  // remove markup
+  containerEl.html('');
+  draggedPieceEl.remove();
+
+  // remove event handlers
+  containerEl.unbind();
+};
+
+// shorthand method to get the current FEN
+widget.fen = function() {
+  return widget.position('fen');
+};
+
+// flip orientation
+widget.flip = function() {
+  widget.orientation('flip');
+};
+
+/*
+// TODO: write this, GitHub Issue #5
+widget.highlight = function() {
+
+};
+*/
+
+// move pieces
+widget.move = function() {
+  // no need to throw an error here; just do nothing
+  if (arguments.length === 0) return;
+
+  var useAnimation = true;
+
+  // collect the moves into an object
+  var moves = {};
+  for (var i = 0; i < arguments.length; i++) {
+    // any "false" to this function means no animations
+    if (arguments[i] === false) {
+      useAnimation = false;
+      continue;
+    }
+
+    // skip invalid arguments
+    if (validMove(arguments[i]) !== true) {
+      error(2826, 'Invalid move passed to the move method.', arguments[i]);
+      continue;
+    }
+
+    var tmp = arguments[i].split('-');
+    moves[tmp[0]] = tmp[1];
+  }
+
+  // calculate position from moves
+  var newPos = calculatePositionFromMoves(CURRENT_POSITION, moves);
+
+  // update the board
+  widget.position(newPos, useAnimation);
+
+  // return the new position object
+  return newPos;
+};
+
+widget.orientation = function(arg) {
+  // no arguments, return the current orientation
+  if (arguments.length === 0) {
+    return CURRENT_ORIENTATION;
+  }
+
+  // set to white or black
+  if (arg === 'white' || arg === 'black') {
+    CURRENT_ORIENTATION = arg;
+    drawBoard();
+    return;
+  }
+
+  // flip orientation
+  if (arg === 'flip') {
+    CURRENT_ORIENTATION = (CURRENT_ORIENTATION === 'white') ? 'black' : 'white';
+    drawBoard();
+    return;
+  }
+
+  error(5482, 'Invalid value passed to the orientation method.', arg);
+};
+
+widget.position = function(position, useAnimation) {
+  // no arguments, return the current position
+  if (arguments.length === 0) {
+    return deepCopy(CURRENT_POSITION);
+  }
+
+  // get position as FEN
+  if (typeof position === 'string' && position.toLowerCase() === 'fen') {
+    return objToFen(CURRENT_POSITION);
+  }
+
+  // default for useAnimations is true
+  if (useAnimation !== false) {
+    useAnimation = true;
+  }
+
+  // start position
+  if (typeof position === 'string' && position.toLowerCase() === 'start') {
+    position = deepCopy(START_POSITION);
+  }
+
+  // convert FEN to position object
+  if (validFen(position) === true) {
+    position = fenToObj(position);
+  }
+
+  // validate position object
+  if (validPositionObject(position) !== true) {
+    error(6482, 'Invalid value passed to the position method.', position);
+    return;
+  }
+
+  if (useAnimation === true) {
+    // start the animations
+    doAnimations(calculateAnimations(CURRENT_POSITION, position),
+      CURRENT_POSITION, position);
+
+    // set the new position
+    setCurrentPosition(position);
+  }
+  // instant update
+  else {
+    setCurrentPosition(position);
+    drawPositionInstant();
+  }
+};
+
+widget.resize = function() {
+  // calulate the new square size
+  SQUARE_SIZE = calculateSquareSize();
+
+  // set board width
+  boardEl.css('width', (SQUARE_SIZE * 8) + 'px');
+
+  // set drag piece size
+  draggedPieceEl.css({
+    height: SQUARE_SIZE,
+    width: SQUARE_SIZE
+  });
+
+  // spare pieces
+  if (cfg.sparePieces === true) {
+    containerEl.find('.' + CSS.sparePieces)
+      .css('paddingLeft', (SQUARE_SIZE + BOARD_BORDER_SIZE) + 'px');
+  }
+
+  // redraw the board
+  drawBoard();
+};
+
+// set the starting position
+widget.start = function(useAnimation) {
+  widget.position('start', useAnimation);
+};
+
+//------------------------------------------------------------------------------
+// Browser Events
+//------------------------------------------------------------------------------
+
+function isTouchDevice() {
+  return ('ontouchstart' in document.documentElement);
+}
+
+// reference: http://www.quirksmode.org/js/detect.html
+function isMSIE() {
+  return (navigator && navigator.userAgent &&
+      navigator.userAgent.search(/MSIE/) !== -1);
+}
+
+function stopDefault(e) {
+  e.preventDefault();
+}
+
+function mousedownSquare(e) {
+  // do nothing if we're not draggable
+  if (cfg.draggable !== true) return;
+
+  var square = $(this).attr('data-square');
+
+  // no piece on this square
+  if (validSquare(square) !== true ||
+      CURRENT_POSITION.hasOwnProperty(square) !== true) {
+    return;
+  }
+
+  beginDraggingPiece(square, CURRENT_POSITION[square], e.pageX, e.pageY);
+}
+
+function touchstartSquare(e) {
+  // do nothing if we're not draggable
+  if (cfg.draggable !== true) return;
+
+  var square = $(this).attr('data-square');
+
+  // no piece on this square
+  if (validSquare(square) !== true ||
+      CURRENT_POSITION.hasOwnProperty(square) !== true) {
+    return;
+  }
+
+  e = e.originalEvent;
+  beginDraggingPiece(square, CURRENT_POSITION[square],
+    e.changedTouches[0].pageX, e.changedTouches[0].pageY);
+}
+
+function mousedownSparePiece(e) {
+  // do nothing if sparePieces is not enabled
+  if (cfg.sparePieces !== true) return;
+
+  var piece = $(this).attr('data-piece');
+
+  beginDraggingPiece('spare', piece, e.pageX, e.pageY);
+}
+
+function touchstartSparePiece(e) {
+  // do nothing if sparePieces is not enabled
+  if (cfg.sparePieces !== true) return;
+
+  var piece = $(this).attr('data-piece');
+
+  e = e.originalEvent;
+  beginDraggingPiece('spare', piece,
+    e.changedTouches[0].pageX, e.changedTouches[0].pageY);
+}
+
+function mousemoveWindow(e) {
+  // do nothing if we are not dragging a piece
+  if (DRAGGING_A_PIECE !== true) return;
+
+  updateDraggedPiece(e.pageX, e.pageY);
+}
+
+function touchmoveWindow(e) {
+  // do nothing if we are not dragging a piece
+  if (DRAGGING_A_PIECE !== true) return;
+
+  // prevent screen from scrolling
+  e.preventDefault();
+
+  updateDraggedPiece(e.originalEvent.changedTouches[0].pageX,
+    e.originalEvent.changedTouches[0].pageY);
+}
+
+function mouseupWindow(e) {
+  // do nothing if we are not dragging a piece
+  if (DRAGGING_A_PIECE !== true) return;
+
+  // get the location
+  var location = isXYOnSquare(e.pageX, e.pageY);
+
+  stopDraggedPiece(location);
+}
+
+function touchendWindow(e) {
+  // do nothing if we are not dragging a piece
+  if (DRAGGING_A_PIECE !== true) return;
+
+  // get the location
+  var location = isXYOnSquare(e.originalEvent.changedTouches[0].pageX,
+    e.originalEvent.changedTouches[0].pageY);
+
+  stopDraggedPiece(location);
+}
+
+function mouseenterSquare(e) {
+  // do not fire this event if we are dragging a piece
+  // NOTE: this should never happen, but it's a safeguard
+  if (DRAGGING_A_PIECE !== false) return;
+
+  if (cfg.hasOwnProperty('onMouseoverSquare') !== true ||
+    typeof cfg.onMouseoverSquare !== 'function') return;
+
+  // get the square
+  var square = $(e.currentTarget).attr('data-square');
+
+  // NOTE: this should never happen; defensive
+  if (validSquare(square) !== true) return;
+
+  // get the piece on this square
+  var piece = false;
+  if (CURRENT_POSITION.hasOwnProperty(square) === true) {
+    piece = CURRENT_POSITION[square];
+  }
+
+  // execute their function
+  cfg.onMouseoverSquare(square, piece, deepCopy(CURRENT_POSITION),
+    CURRENT_ORIENTATION);
+}
+
+function mouseleaveSquare(e) {
+  // do not fire this event if we are dragging a piece
+  // NOTE: this should never happen, but it's a safeguard
+  if (DRAGGING_A_PIECE !== false) return;
+
+  if (cfg.hasOwnProperty('onMouseoutSquare') !== true ||
+    typeof cfg.onMouseoutSquare !== 'function') return;
+
+  // get the square
+  var square = $(e.currentTarget).attr('data-square');
+
+  // NOTE: this should never happen; defensive
+  if (validSquare(square) !== true) return;
+
+  // get the piece on this square
+  var piece = false;
+  if (CURRENT_POSITION.hasOwnProperty(square) === true) {
+    piece = CURRENT_POSITION[square];
+  }
+
+  // execute their function
+  cfg.onMouseoutSquare(square, piece, deepCopy(CURRENT_POSITION),
+    CURRENT_ORIENTATION);
+}
+
+//------------------------------------------------------------------------------
+// Initialization
+//------------------------------------------------------------------------------
+
+function addEvents() {
+  // prevent browser "image drag"
+  $('body').on('mousedown mousemove', '.' + CSS.piece, stopDefault);
+
+  // mouse drag pieces
+  boardEl.on('mousedown', '.' + CSS.square, mousedownSquare);
+  containerEl.on('mousedown', '.' + CSS.sparePieces + ' .' + CSS.piece,
+    mousedownSparePiece);
+
+  // mouse enter / leave square
+  boardEl.on('mouseenter', '.' + CSS.square, mouseenterSquare);
+  boardEl.on('mouseleave', '.' + CSS.square, mouseleaveSquare);
+
+  // IE doesn't like the events on the window object, but other browsers
+  // perform better that way
+  if (isMSIE() === true) {
+    // IE-specific prevent browser "image drag"
+    document.ondragstart = function() { return false; };
+
+    $('body').on('mousemove', mousemoveWindow);
+    $('body').on('mouseup', mouseupWindow);
+  }
+  else {
+    $(window).on('mousemove', mousemoveWindow);
+    $(window).on('mouseup', mouseupWindow);
+  }
+
+  // touch drag pieces
+  if (isTouchDevice() === true) {
+    boardEl.on('touchstart', '.' + CSS.square, touchstartSquare);
+    containerEl.on('touchstart', '.' + CSS.sparePieces + ' .' + CSS.piece,
+      touchstartSparePiece);
+    $(window).on('touchmove', touchmoveWindow);
+    $(window).on('touchend', touchendWindow);
+  }
+}
+
+function initDom() {
+  // build board and save it in memory
+  containerEl.html(buildBoardContainer());
+  boardEl = containerEl.find('.' + CSS.board);
+
+  if (cfg.sparePieces === true) {
+    sparePiecesTopEl = containerEl.find('.' + CSS.sparePiecesTop);
+    sparePiecesBottomEl = containerEl.find('.' + CSS.sparePiecesBottom);
+  }
+
+  // create the drag piece
+  var draggedPieceId = createId();
+  $('body').append(buildPiece('wP', true, draggedPieceId));
+  draggedPieceEl = $('#' + draggedPieceId);
+
+  // get the border size
+  BOARD_BORDER_SIZE = parseInt(boardEl.css('borderLeftWidth'), 10);
+
+  // set the size and draw the board
+  widget.resize();
+}
+
+function init() {
+  if (checkDeps() !== true ||
+      expandConfig() !== true) return;
+
+  // create unique IDs for all the elements we will create
+  createElIds();
+
+  initDom();
+  addEvents();
+}
+
+// go time
+init();
+
+// return the widget object
+return widget;
+
+}; // end window.ChessBoard
+
+// expose util functions
+window.ChessBoard.fenToObj = fenToObj;
+window.ChessBoard.objToFen = objToFen;
+
+})(); // end anonymous wrapper
diff --git a/www/js/chessboard-0.3.0.min.js b/www/js/chessboard-0.3.0.min.js
new file mode 100644 (file)
index 0000000..81a29a1
--- /dev/null
@@ -0,0 +1,31 @@
+/*! chessboard.js v0.3.0 | (c) 2013 Chris Oakman | MIT License chessboardjs.com/license */
+(function(){function l(f){return"string"!==typeof f?!1:-1!==f.search(/^[a-h][1-8]$/)}function Q(f){if("string"!==typeof f)return!1;f=f.replace(/ .+$/,"");f=f.split("/");if(8!==f.length)return!1;for(var b=0;8>b;b++)if(""===f[b]||8<f[b].length||-1!==f[b].search(/[^kqrbnpKQRNBP1-8]/))return!1;return!0}function F(f){if("object"!==typeof f)return!1;for(var b in f)if(!0===f.hasOwnProperty(b)){var n;(n=!0!==l(b))||(n=f[b],n="string"!==typeof n?!1:-1!==n.search(/^[bw][KQRNBP]$/),n=!0!==n);if(n)return!1}return!0}
+function K(f){if(!0!==Q(f))return!1;f=f.replace(/ .+$/,"");f=f.split("/");for(var b={},n=8,m=0;8>m;m++){for(var l=f[m].split(""),r=0,w=0;w<l.length;w++)if(-1!==l[w].search(/[1-8]/))var I=parseInt(l[w],10),r=r+I;else{var I=b,F=B[r]+n,A;A=l[w];A=A.toLowerCase()===A?"b"+A.toUpperCase():"w"+A.toUpperCase();I[F]=A;r++}n--}return b}function L(f){if(!0!==F(f))return!1;for(var b="",n=8,m=0;8>m;m++){for(var l=0;8>l;l++){var r=B[l]+n;!0===f.hasOwnProperty(r)?(r=f[r].split(""),r="w"===r[0]?r[1].toUpperCase():
+r[1].toLowerCase(),b+=r):b+="1"}7!==m&&(b+="/");n--}b=b.replace(/11111111/g,"8");b=b.replace(/1111111/g,"7");b=b.replace(/111111/g,"6");b=b.replace(/11111/g,"5");b=b.replace(/1111/g,"4");b=b.replace(/111/g,"3");return b=b.replace(/11/g,"2")}var B="abcdefgh".split("");window.ChessBoard=window.ChessBoard||function(f,b){function n(){return"xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx".replace(/x/g,function(a){return(16*Math.random()|0).toString(16)})}function m(a){return JSON.parse(JSON.stringify(a))}function X(a){a=
+a.split(".");return{major:parseInt(a[0],10),minor:parseInt(a[1],10),patch:parseInt(a[2],10)}}function r(a,e,c){if(!0===b.hasOwnProperty("showErrors")&&!1!==b.showErrors){var d="ChessBoard Error "+a+": "+e;"console"===b.showErrors&&"object"===typeof console&&"function"===typeof console.log?(console.log(d),2<=arguments.length&&console.log(c)):"alert"===b.showErrors?(c&&(d+="\n\n"+JSON.stringify(c)),window.alert(d)):"function"===typeof b.showErrors&&b.showErrors(a,e,c)}}function w(a){return"fast"===
+a||"slow"===a?!0:parseInt(a,10)+""!==a+""?!1:0<=a}function I(){for(var a=0;a<B.length;a++)for(var b=1;8>=b;b++){var c=B[a]+b;s[c]=c+"-"+n()}b="KQRBNP".split("");for(a=0;a<b.length;a++){var c="w"+b[a],d="b"+b[a];M[c]=c+"-"+n();M[d]=d+"-"+n()}}function ga(){var a='<div class="'+h.chessboard+'">';!0===b.sparePieces&&(a+='<div class="'+h.sparePieces+" "+h.sparePiecesTop+'"></div>');a+='<div class="'+h.board+'"></div>';!0===b.sparePieces&&(a+='<div class="'+h.sparePieces+" "+h.sparePiecesBottom+'"></div>');
+return a+"</div>"}function A(a){"black"!==a&&(a="white");var e="",c=m(B),d=8;"black"===a&&(c.reverse(),d=1);for(var C="white",f=0;8>f;f++){for(var e=e+('<div class="'+h.row+'">'),k=0;8>k;k++){var g=c[k]+d,e=e+('<div class="'+h.square+" "+h[C]+" square-"+g+'" style="width: '+p+"px; height: "+p+'px" id="'+s[g]+'" data-square="'+g+'">');if(!0===b.showNotation){if("white"===a&&1===d||"black"===a&&8===d)e+='<div class="'+h.notation+" "+h.alpha+'">'+c[k]+"</div>";0===k&&(e+='<div class="'+h.notation+" "+
+h.numeric+'">'+d+"</div>")}e+="</div>";C="white"===C?"black":"white"}e+='<div class="'+h.clearfix+'"></div></div>';C="white"===C?"black":"white";"white"===a?d--:d++}return e}function Y(a){if("function"===typeof b.pieceTheme)return b.pieceTheme(a);if("string"===typeof b.pieceTheme)return b.pieceTheme.replace(/{piece}/g,a);r(8272,"Unable to build image source for cfg.pieceTheme.");return""}function D(a,b,c){var d='<img src="'+Y(a)+'" ';c&&"string"===typeof c&&(d+='id="'+c+'" ');d+='alt="" class="'+
+h.piece+'" data-piece="'+a+'" style="width: '+p+"px;height: "+p+"px;";!0===b&&(d+="display:none;");return d+'" />'}function N(a){var b="wK wQ wR wB wN wP".split(" ");"black"===a&&(b="bK bQ bR bB bN bP".split(" "));a="";for(var c=0;c<b.length;c++)a+=D(b[c],!1,M[b[c]]);return a}function ha(a,e,c,d){a=$("#"+s[a]);var C=a.offset(),f=$("#"+s[e]);e=f.offset();var k=n();$("body").append(D(c,!0,k));var g=$("#"+k);g.css({display:"",position:"absolute",top:C.top,left:C.left});a.find("."+h.piece).remove();g.animate(e,
+{duration:b.moveSpeed,complete:function(){f.append(D(c));g.remove();"function"===typeof d&&d()}})}function ia(a,e,c){var d=$("#"+M[a]).offset(),f=$("#"+s[e]);e=f.offset();var g=n();$("body").append(D(a,!0,g));var k=$("#"+g);k.css({display:"",position:"absolute",left:d.left,top:d.top});k.animate(e,{duration:b.moveSpeed,complete:function(){f.find("."+h.piece).remove();f.append(D(a));k.remove();"function"===typeof c&&c()}})}function ja(a,e,c){function d(){f++;if(f===a.length&&(G(),!0===b.hasOwnProperty("onMoveEnd")&&
+"function"===typeof b.onMoveEnd))b.onMoveEnd(m(e),m(c))}for(var f=0,g=0;g<a.length;g++)"clear"===a[g].type&&$("#"+s[a[g].square]+" ."+h.piece).fadeOut(b.trashSpeed,d),"add"===a[g].type&&!0!==b.sparePieces&&$("#"+s[a[g].square]).append(D(a[g].piece,!0)).find("."+h.piece).fadeIn(b.appearSpeed,d),"add"===a[g].type&&!0===b.sparePieces&&ia(a[g].piece,a[g].square,d),"move"===a[g].type&&ha(a[g].source,a[g].destination,a[g].piece,d)}function ka(a,b){a=a.split("");var c=B.indexOf(a[0])+1,d=parseInt(a[1],10);
+b=b.split("");var g=B.indexOf(b[0])+1,f=parseInt(b[1],10),c=Math.abs(c-g),d=Math.abs(d-f);return c>=d?c:d}function la(a){for(var b=[],c=0;8>c;c++)for(var d=0;8>d;d++){var g=B[c]+(d+1);a!==g&&b.push({square:g,distance:ka(a,g)})}b.sort(function(a,b){return a.distance-b.distance});a=[];for(c=0;c<b.length;c++)a.push(b[c].square);return a}function G(){x.find("."+h.piece).remove();for(var a in g)!0===g.hasOwnProperty(a)&&$("#"+s[a]).append(D(g[a]))}function R(){x.html(A(u));G();!0===b.sparePieces&&("white"===
+u?(S.html(N("black")),T.html(N("white"))):(S.html(N("white")),T.html(N("black"))))}function O(a){var e=m(g),c=m(a),d=L(e),f=L(c);if(d!==f){if(!0===b.hasOwnProperty("onChange")&&"function"===typeof b.onChange)b.onChange(e,c);g=a}}function U(a,b){for(var c in J)if(!0===J.hasOwnProperty(c)){var d=J[c];if(a>=d.left&&a<d.left+p&&b>=d.top&&b<d.top+p)return c}return"offboard"}function V(){x.find("."+h.square).removeClass(h.highlight1+" "+h.highlight2)}function ma(){function a(){G();y.css("display","none");
+if(!0===b.hasOwnProperty("onSnapbackEnd")&&"function"===typeof b.onSnapbackEnd)b.onSnapbackEnd(E,t,m(g),u)}if("spare"===t)Z();else{V();var e=$("#"+s[t]).offset();y.animate(e,{duration:b.snapbackSpeed,complete:a});z=!1}}function Z(){V();var a=m(g);delete a[t];O(a);G();y.fadeOut(b.trashSpeed);z=!1}function na(a){V();var e=m(g);delete e[t];e[a]=E;O(e);e=$("#"+s[a]).offset();y.animate(e,{duration:b.snapSpeed,complete:function(){G();y.css("display","none");if(!0===b.hasOwnProperty("onSnapEnd")&&"function"===
+typeof b.onSnapEnd)b.onSnapEnd(t,a,E)}});z=!1}function P(a,e,c,d){if("function"!==typeof b.onDragStart||!1!==b.onDragStart(a,e,m(g),u)){z=!0;E=e;t=a;H="spare"===a?"offboard":a;J={};for(var f in s)!0===s.hasOwnProperty(f)&&(J[f]=$("#"+s[f]).offset());y.attr("src",Y(e)).css({display:"",position:"absolute",left:c-p/2,top:d-p/2});"spare"!==a&&$("#"+s[a]).addClass(h.highlight1).find("."+h.piece).css("display","none")}}function aa(a,e){y.css({left:a-p/2,top:e-p/2});var c=U(a,e);if(c!==H){!0===l(H)&&$("#"+
+s[H]).removeClass(h.highlight2);!0===l(c)&&$("#"+s[c]).addClass(h.highlight2);if("function"===typeof b.onDragMove)b.onDragMove(c,H,t,E,m(g),u);H=c}}function ba(a){var e="drop";"offboard"===a&&"snapback"===b.dropOffBoard&&(e="snapback");"offboard"===a&&"trash"===b.dropOffBoard&&(e="trash");if(!0===b.hasOwnProperty("onDrop")&&"function"===typeof b.onDrop){var c=m(g);"spare"===t&&!0===l(a)&&(c[a]=E);!0===l(t)&&"offboard"===a&&delete c[t];!0===l(t)&&!0===l(a)&&(delete c[t],c[a]=E);var d=m(g),c=b.onDrop(t,
+a,E,c,d,u);if("snapback"===c||"trash"===c)e=c}"snapback"===e?ma():"trash"===e?Z():"drop"===e&&na(a)}function oa(a){a.preventDefault()}function pa(a){if(!0===b.draggable){var e=$(this).attr("data-square");!0===l(e)&&!0===g.hasOwnProperty(e)&&P(e,g[e],a.pageX,a.pageY)}}function qa(a){if(!0===b.draggable){var e=$(this).attr("data-square");!0===l(e)&&!0===g.hasOwnProperty(e)&&(a=a.originalEvent,P(e,g[e],a.changedTouches[0].pageX,a.changedTouches[0].pageY))}}function ra(a){if(!0===b.sparePieces){var e=
+$(this).attr("data-piece");P("spare",e,a.pageX,a.pageY)}}function sa(a){if(!0===b.sparePieces){var e=$(this).attr("data-piece");a=a.originalEvent;P("spare",e,a.changedTouches[0].pageX,a.changedTouches[0].pageY)}}function ca(a){!0===z&&aa(a.pageX,a.pageY)}function ta(a){!0===z&&(a.preventDefault(),aa(a.originalEvent.changedTouches[0].pageX,a.originalEvent.changedTouches[0].pageY))}function da(a){!0===z&&(a=U(a.pageX,a.pageY),ba(a))}function ua(a){!0===z&&(a=U(a.originalEvent.changedTouches[0].pageX,
+a.originalEvent.changedTouches[0].pageY),ba(a))}function va(a){if(!1===z&&(!0===b.hasOwnProperty("onMouseoverSquare")&&"function"===typeof b.onMouseoverSquare)&&(a=$(a.currentTarget).attr("data-square"),!0===l(a))){var e=!1;!0===g.hasOwnProperty(a)&&(e=g[a]);b.onMouseoverSquare(a,e,m(g),u)}}function wa(a){if(!1===z&&(!0===b.hasOwnProperty("onMouseoutSquare")&&"function"===typeof b.onMouseoutSquare)&&(a=$(a.currentTarget).attr("data-square"),!0===l(a))){var e=!1;!0===g.hasOwnProperty(a)&&(e=g[a]);
+b.onMouseoutSquare(a,e,m(g),u)}}function xa(){$("body").on("mousedown mousemove","."+h.piece,oa);x.on("mousedown","."+h.square,pa);v.on("mousedown","."+h.sparePieces+" ."+h.piece,ra);x.on("mouseenter","."+h.square,va);x.on("mouseleave","."+h.square,wa);!0===(navigator&&navigator.userAgent&&-1!==navigator.userAgent.search(/MSIE/))?(document.ondragstart=function(){return!1},$("body").on("mousemove",ca),$("body").on("mouseup",da)):($(window).on("mousemove",ca),$(window).on("mouseup",da));!0==="ontouchstart"in
+document.documentElement&&(x.on("touchstart","."+h.square,qa),v.on("touchstart","."+h.sparePieces+" ."+h.piece,sa),$(window).on("touchmove",ta),$(window).on("touchend",ua))}function ya(){v.html(ga());x=v.find("."+h.board);!0===b.sparePieces&&(S=v.find("."+h.sparePiecesTop),T=v.find("."+h.sparePiecesBottom));var a=n();$("body").append(D("wP",!0,a));y=$("#"+a);ea=parseInt(x.css("borderLeftWidth"),10);q.resize()}b=b||{};var fa=K("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"),h={alpha:"alpha-d2270",black:"black-3c85d",
+board:"board-b72b1",chessboard:"chessboard-63f37",clearfix:"clearfix-7da63",highlight1:"highlight1-32417",highlight2:"highlight2-9c5d2",notation:"notation-322f9",numeric:"numeric-fc462",piece:"piece-417db",row:"row-5277c",sparePieces:"spare-pieces-7492f",sparePiecesBottom:"spare-pieces-bottom-ae20f",sparePiecesTop:"spare-pieces-top-4028b",square:"square-55d63",white:"white-1e1d7"},v,x,y,S,T,q={},ea=2,u="white",g={},p,E,H,t,z=!1,M={},s={},J;q.clear=function(a){q.position({},a)};q.destroy=function(){v.html("");
+y.remove();v.unbind()};q.fen=function(){return q.position("fen")};q.flip=function(){q.orientation("flip")};q.move=function(){if(0!==arguments.length){for(var a=!0,b={},c=0;c<arguments.length;c++)if(!1===arguments[c])a=!1;else{var d;d=arguments[c];"string"!==typeof d?d=!1:(d=d.split("-"),d=2!==d.length?!1:!0===l(d[0])&&!0===l(d[1]));!0!==d?r(2826,"Invalid move passed to the move method.",arguments[c]):(d=arguments[c].split("-"),b[d[0]]=d[1])}var c=g,c=m(c),f;for(f in b)!0===b.hasOwnProperty(f)&&!0===
+c.hasOwnProperty(f)&&(d=c[f],delete c[f],c[b[f]]=d);b=c;q.position(b,a);return b}};q.orientation=function(a){if(0===arguments.length)return u;"white"===a||"black"===a?(u=a,R()):"flip"===a?(u="white"===u?"black":"white",R()):r(5482,"Invalid value passed to the orientation method.",a)};q.position=function(a,b){if(0===arguments.length)return m(g);if("string"===typeof a&&"fen"===a.toLowerCase())return L(g);!1!==b&&(b=!0);"string"===typeof a&&"start"===a.toLowerCase()&&(a=m(fa));!0===Q(a)&&(a=K(a));if(!0!==
+F(a))r(6482,"Invalid value passed to the position method.",a);else if(!0===b){var c=g,d=a,c=m(c),d=m(d),f=[],h={},k;for(k in d)!0===d.hasOwnProperty(k)&&(!0===c.hasOwnProperty(k)&&c[k]===d[k])&&(delete c[k],delete d[k]);for(k in d)if(!0===d.hasOwnProperty(k)){var l;a:{l=c;for(var n=d[k],s=la(k),p=0;p<s.length;p++){var q=s[p];if(!0===l.hasOwnProperty(q)&&l[q]===n){l=q;break a}}l=!1}!1!==l&&(f.push({type:"move",source:l,destination:k,piece:d[k]}),delete c[l],delete d[k],h[k]=!0)}for(k in d)!0===d.hasOwnProperty(k)&&
+(f.push({type:"add",square:k,piece:d[k]}),delete d[k]);for(k in c)!0===c.hasOwnProperty(k)&&!0!==h.hasOwnProperty(k)&&(f.push({type:"clear",square:k,piece:c[k]}),delete c[k]);ja(f,g,a);O(a)}else O(a),G()};q.resize=function(){var a=parseInt(v.css("width"),10);if(!a||0>=a)p=0;else{for(a-=1;0!==a%8&&0<a;)a--;p=a/8}x.css("width",8*p+"px");y.css({height:p,width:p});!0===b.sparePieces&&v.find("."+h.sparePieces).css("paddingLeft",p+ea+"px");R()};q.start=function(a){q.position("start",a)};var W;if(W=!0===
+function(){if("string"===typeof f){if(""===f)return window.alert("ChessBoard Error 1001: The first argument to ChessBoard() cannot be an empty string.\n\nExiting..."),!1;var a=document.getElementById(f);if(!a)return window.alert('ChessBoard Error 1002: Element with id "'+f+'" does not exist in the DOM.\n\nExiting...'),!1;v=$(a)}else if(v=$(f),1!==v.length)return window.alert("ChessBoard Error 1003: The first argument to ChessBoard() must be an ID or a single DOM node.\n\nExiting..."),!1;if(!window.JSON||
+"function"!==typeof JSON.stringify||"function"!==typeof JSON.parse)return window.alert("ChessBoard Error 1004: JSON does not exist. Please include a JSON polyfill.\n\nExiting..."),!1;if(a=typeof window.$)if(a=$.fn)if(a=$.fn.jquery)var a=$.fn.jquery,b="1.7.0",a=X(a),b=X(b),a=!0===1E8*a.major+1E4*a.minor+a.patch>=1E8*b.major+1E4*b.minor+b.patch;return a?!0:(window.alert("ChessBoard Error 1005: Unable to find a valid version of jQuery. Please include jQuery 1.7.0 or higher on the page.\n\nExiting..."),
+!1)}()){if("string"===typeof b||!0===F(b))b={position:b};"black"!==b.orientation&&(b.orientation="white");u=b.orientation;!1!==b.showNotation&&(b.showNotation=!0);!0!==b.draggable&&(b.draggable=!1);"trash"!==b.dropOffBoard&&(b.dropOffBoard="snapback");!0!==b.sparePieces&&(b.sparePieces=!1);!0===b.sparePieces&&(b.draggable=!0);if(!0!==b.hasOwnProperty("pieceTheme")||"string"!==typeof b.pieceTheme&&"function"!==typeof b.pieceTheme)b.pieceTheme="img/chesspieces/wikipedia/{piece}.png";if(!0!==b.hasOwnProperty("appearSpeed")||
+!0!==w(b.appearSpeed))b.appearSpeed=200;if(!0!==b.hasOwnProperty("moveSpeed")||!0!==w(b.moveSpeed))b.moveSpeed=200;if(!0!==b.hasOwnProperty("snapbackSpeed")||!0!==w(b.snapbackSpeed))b.snapbackSpeed=50;if(!0!==b.hasOwnProperty("snapSpeed")||!0!==w(b.snapSpeed))b.snapSpeed=25;if(!0!==b.hasOwnProperty("trashSpeed")||!0!==w(b.trashSpeed))b.trashSpeed=100;!0===b.hasOwnProperty("position")&&("start"===b.position?g=m(fa):!0===Q(b.position)?g=K(b.position):!0===F(b.position)?g=m(b.position):r(7263,"Invalid value passed to config.position.",
+b.position));W=!0}W&&(I(),ya(),xa());return q};window.ChessBoard.fenToObj=K;window.ChessBoard.objToFen=L})();
\ No newline at end of file
diff --git a/www/js/jquery-1.10.2.min.js b/www/js/jquery-1.10.2.min.js
new file mode 100644 (file)
index 0000000..da41706
--- /dev/null
@@ -0,0 +1,6 @@
+/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
+//@ sourceMappingURL=jquery-1.10.2.min.map
+*/
+(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
+}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
+u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
diff --git a/www/js/jquery.jsPlumb-1.5.3-min.js b/www/js/jquery.jsPlumb-1.5.3-min.js
new file mode 100644 (file)
index 0000000..3070470
--- /dev/null
@@ -0,0 +1,6 @@
+!function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var a={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},b=64,c=Math.pow(2,-b-1),d=function(b,c){for(var d=[],e=f(b,c),h=c.length-1,i=2*h-1,j=g(e,i,d,0),k=a.subtract(b,c[0]),m=a.square(k),n=0,o=0;j>o;o++){k=a.subtract(b,l(c,h,d[o],null,null));var p=a.square(k);m>p&&(m=p,n=d[o])}return k=a.subtract(b,c[h]),p=a.square(k),m>p&&(m=p,n=1),{location:n,distance:m}},e=function(a,b){var c=d(a,b);return{point:l(b,b.length-1,c.location,null,null),location:c.location}},f=function(b,c){for(var d=c.length-1,e=2*d-1,f=[],g=[],h=[],i=[],k=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],l=0;d>=l;l++)f[l]=a.subtract(c[l],b);for(var l=0;d-1>=l;l++)g[l]=a.subtract(c[l+1],c[l]),g[l]=a.scale(g[l],3);for(var m=0;d-1>=m;m++)for(var n=0;d>=n;n++)h[m]||(h[m]=[]),h[m][n]=a.dotProduct(g[m],f[n]);for(l=0;e>=l;l++)i[l]||(i[l]=[]),i[l].y=0,i[l].x=parseFloat(l)/e;for(var o=d,p=d-1,q=0;o+p>=q;q++){var r=Math.max(0,q-p),s=Math.min(q,o);for(l=r;s>=l;l++)j=q-l,i[l+j].y+=h[j][l]*k[j][l]}return i},g=function(a,c,d,e){var f,j,m=[],n=[],o=[],p=[];switch(h(a,c)){case 0:return 0;case 1:if(e>=b)return d[0]=(a[0].x+a[c].x)/2,1;if(i(a,c))return d[0]=k(a,c),1}l(a,c,.5,m,n),f=g(m,c,o,e+1),j=g(n,c,p,e+1);for(var q=0;f>q;q++)d[q]=o[q];for(var q=0;j>q;q++)d[q+f]=p[q];return f+j},h=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},i=function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;for(var t=max_distance_below=0,u=1;b>u;u++){var v=i*a[u].x+j*a[u].y+k;v>t?t=v:max_distance_below>v&&(max_distance_below=v)}return n=0,o=1,p=0,q=i,r=j,s=k-t,l=n*r-q*o,m=1/l,e=(o*s-r*p)*m,q=i,r=j,s=k-max_distance_below,l=n*r-q*o,m=1/l,f=(o*s-r*p)*m,g=Math.min(e,f),h=Math.max(e,f),d=h-g,c>d?1:0},k=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},l=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},m={},n=function(a){var b=m[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;d<a.length;d++)c*=a[d](b);return c}};b.push(new c);for(var i=1;a>i;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),m[a]=b}return b},o=function(a,b){for(var c=n(a.length-1),d=0,e=0,f=0;f<a.length;f++)d+=a[f].x*c[f](b),e+=a[f].y*c[f](b);return{x:d,y:e}},p=function(a,b){return Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2))},q=function(a){return a[0].x==a[1].x&&a[0].y==a[1].y},r=function(a,b,c){if(q(a))return{point:a[0],location:b};for(var d=o(a,b),e=0,f=b,g=c>0?1:-1,h=null;e<Math.abs(c);)f+=.005*g,h=o(a,f),e+=p(h,d),d=h;return{point:h,location:f}},s=function(a){if(q(a))return 0;for(var b=o(a,0),c=0,d=0,e=1,f=null;1>d;)d+=.005*e,f=o(a,d),c+=p(f,b),b=f;return c},t=function(a,b,c){return r(a,b,c).point},u=function(a,b,c){return r(a,b,c).location},v=function(a,b){var c=o(a,b),d=o(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0==e?1/0:Math.atan(e/f)},w=function(a,b,c){var d=r(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),v(a,d.location)},x=function(a,b,c,d){d=null==d?0:d;var e=r(a,b,d),f=v(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]};window.jsBezier={distanceFromCurve:d,gradientAtPoint:v,gradientAtPointAlongCurveFrom:w,nearestPointOnCurve:e,pointOnCurve:o,pointAlongCurveFrom:t,perpendicularToCurveAt:x,locationAlongCurveFrom:u,getLength:s}}(),function(){"use strict";var a,b=this;a="undefined"!=typeof exports?exports:b.jsPlumbGeom={};var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a,b,d){return a=c(a)?a:[a.x,a.y],b=c(b)?b:[b.x,b.y],d(a,b)},e=a.gradient=function(a,b){return d(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-1/0:b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},f=(a.normal=function(a,b){return-1/e(a,b)},a.lineLength=function(a,b){return d(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},a.quadrant=function(a,b){return d(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),g=(a.theta=function(a,b){return d(a,b,function(a,b){var c=e(a,b),d=Math.atan(c),g=f(a,b);return(4==g||3==g)&&(d+=Math.PI),0>d&&(d+=2*Math.PI),d})},a.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),h=[null,[-1,-1],[-1,1],[1,1],[1,-1]];a.pointOnLine=function(a,b,c){var d=e(a,b),i=f(a,b),j=c>0?g[i]:h[i],k=Math.atan(d),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},a.perpendicularLineTo=function(a,b,c){var d=e(a,b),f=Math.atan(-1/d),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call(this),function(){var a=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b=function(a){return"[object Number]"===Object.prototype.toString.call(a)},c=function(a){return"string"==typeof a},d=function(a){return"boolean"==typeof a},e=function(a){return null==a},f=function(a){return null==a?!1:"[object Object]"===Object.prototype.toString.call(a)},g=function(a){return"[object Date]"===Object.prototype.toString.call(a)},h=function(a){return"[object Function]"===Object.prototype.toString.call(a)},i=function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0};jsPlumbUtil={isArray:a,isString:c,isBoolean:d,isNull:e,isObject:f,isDate:g,isFunction:h,isEmpty:i,isNumber:b,clone:function(b){if(c(b))return""+b;if(d(b))return!!b;if(g(b))return new Date(b.getTime());if(h(b))return b;if(a(b)){for(var e=[],i=0;i<b.length;i++)e.push(this.clone(b[i]));return e}if(f(b)){var j={};for(var k in b)j[k]=this.clone(b[k]);return j}return b},merge:function(b,e){var g=this.clone(b);for(var h in e)if(null==g[h]||c(e[h])||d(e[h]))g[h]=e[h];else if(a(e[h])){var i=[];a(g[h])&&i.push.apply(i,g[h]),i.push.apply(i,e[h]),g[h]=i}else if(f(e[h])){f(g[h])||(g[h]={});for(var j in e[h])g[h][j]=e[h][j]}return g},copyValues:function(a,b,c){for(var d=0;d<a.length;d++)c[a[d]]=b[a[d]]},functionChain:function(a,b,c){for(var d=0;d<c.length;d++){var e=c[d][0][c[d][1]].apply(c[d][0],c[d][2]);if(e===b)return e}return a},populate:function(b,d){var e=function(a){var b=a.match(/(\${.*?})/g);if(null!=b)for(var c=0;c<b.length;c++){var e=d[b[c].substring(2,b[c].length-1)];null!=e&&(a=a.replace(b[c],e))}return a},g=function(b){if(null!=b){if(c(b))return e(b);if(a(b)){for(var d=[],h=0;h<b.length;h++)d.push(g(b[h]));return d}if(f(b)){var i={};for(var j in b)i[j]=g(b[j]);return i}return b}};return g(b)},convertStyle:function(a,b){if("transparent"===a)return a;var c=a,d=function(a){return 1==a.length?"0"+a:a},e=function(a){return d(Number(a).toString(16))},f=/(rgb[a]?\()(.*)(\))/;if(a.match(f)){var g=a.match(f)[2].split(",");c="#"+e(g[0])+e(g[1])+e(g[2]),b||4!=g.length||(c+=e(g[3]))}return c},findWithFunction:function(a,b){if(a)for(var c=0;c<a.length;c++)if(b(a[c]))return c;return-1},clampToGrid:function(a,b,c,d,e){var f=function(a,b){var c=a%b,d=Math.floor(a/b),e=c>=b/2?1:0;return(d+e)*b};return[d||null==c?a:f(a,c[0]),e||null==c?b:f(b,c[1])]},indexOf:function(a,b){return jsPlumbUtil.findWithFunction(a,function(a){return a==b})},removeWithFunction:function(a,b){var c=jsPlumbUtil.findWithFunction(a,b);return c>-1&&a.splice(c,1),-1!=c},remove:function(a,b){var c=jsPlumbUtil.indexOf(a,b);return c>-1&&a.splice(c,1),-1!=c},addWithFunction:function(a,b,c){-1==jsPlumbUtil.findWithFunction(a,c)&&a.push(b)},addToList:function(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e},extend:function(b,c,d,e){d=d||{},e=e||{},c=a(c)?c:[c];for(var f=0;f<c.length;f++)for(var g in c[f].prototype)c[f].prototype.hasOwnProperty(g)&&(b.prototype[g]=c[f].prototype[g]);var h=function(a){return function(){for(var b=0;b<c.length;b++)c[b].prototype[a]&&c[b].prototype[a].apply(this,arguments);return d[a].apply(this,arguments)}};for(var i in d)b.prototype[i]=h(i);return b},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=0|16*Math.random(),c="x"==a?b:8|3&b;return c.toString(16)})},logEnabled:!0,log:function(){if(jsPlumbUtil.logEnabled&&"undefined"!=typeof console)try{var a=arguments[arguments.length-1];console.log(a)}catch(b){}},group:function(a){jsPlumbUtil.logEnabled&&"undefined"!=typeof console&&console.group(a)},groupEnd:function(a){jsPlumbUtil.logEnabled&&"undefined"!=typeof console&&console.groupEnd(a)},time:function(a){jsPlumbUtil.logEnabled&&"undefined"!=typeof console&&console.time(a)},timeEnd:function(a){jsPlumbUtil.logEnabled&&"undefined"!=typeof console&&console.timeEnd(a)},removeElement:function(a){null!=a&&null!=a.parentNode&&a.parentNode.removeChild(a)},removeElements:function(a){for(var b=0;b<a.length;b++)jsPlumbUtil.removeElement(a[b])},sizeElement:function(a,b,c,d,e){a&&(a.style.height=e+"px",a.height=e,a.style.width=d+"px",a.width=d,a.style.left=b+"px",a.style.top=c+"px")},wrap:function(a,b,c){return a=a||function(){},b=b||function(){},function(){var d=null;try{d=b.apply(this,arguments)}catch(e){jsPlumbUtil.log("jsPlumb function failed : "+e)}if(null==c||d!==c)try{d=a.apply(this,arguments)}catch(e){jsPlumbUtil.log("wrapped function failed : "+e)}return d}}},jsPlumbUtil.EventGenerator=function(){var a={},b=!1,c=["ready"];this.bind=function(b,c,d){return jsPlumbUtil.addToList(a,b,c,d),this},this.fire=function(d,e,f){if(!b&&a[d]){var g=a[d].length,h=0,i=!1,j=null;if(!this.shouldFireEvent||this.shouldFireEvent(d,e,f))for(;!i&&g>h&&j!==!1;){if(-1!=jsPlumbUtil.findWithFunction(c,function(a){return a===d}))a[d][h](e,f);else try{j=a[d][h](e,f)}catch(k){jsPlumbUtil.log("jsPlumb: fire failed for event "+d+" : "+k)}h++,(null==a||null==a[d])&&(i=!0)}}return this},this.unbind=function(b){return b?delete a[b]:a={},this},this.getListener=function(b){return a[b]},this.setSuspendEvents=function(a){b=a},this.isSuspendEvents=function(){return b},this.cleanupListeners=function(){for(var b in a)a[b].splice(0),delete a[b]}},jsPlumbUtil.EventGenerator.prototype={cleanup:function(){this.cleanupListeners()}},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e})}(),function(){var a=!!document.createElement("canvas").getContext,b=!!window.SVGAngle||document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"),c=function(){if(void 0===c.vml){var a=document.body.appendChild(document.createElement("div"));a.innerHTML='<v:shape id="vml_flag1" adj="1" />';var b=a.firstChild;null!=b&&null!=b.style?(b.style.behavior="url(#default#VML)",c.vml=b?"object"==typeof b.adj:!0):c.vml=!1,a.parentNode.removeChild(a)}return c.vml},d=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h=jsPlumb.CurrentLibrary,i=h.getElementObject(g),j=a.getId(g),k=h.getOffset(i);b[j]||(b[j]=g,c.push(g),d[j]={});var l=function(b){if(b)for(var c=0;c<b.childNodes.length;c++)if(3!=b.childNodes[c].nodeType&&8!=b.childNodes[c].nodeType){var g=h.getElementObject(b.childNodes[c]),i=a.getId(b.childNodes[c],null,!0);if(i&&e[i]&&e[i]>0){var m=h.getOffset(g);d[j][i]={id:i,offset:{left:m.left-k.left,top:m.top-k.top}},f[i]=j}l(b.childNodes[c])}};l(g)},this.updateOffsets=function(b){var c=jsPlumb.CurrentLibrary,e=c.getElementObject(b),g=c.getDOMElement(e),h=a.getId(g),i=d[h],j=c.getOffset(e);if(i)for(var k in i){var l=c.getElementObject(k),m=c.getOffset(l);d[h][k]={id:k,offset:{left:m.left-j.left,top:m.top-j.top}},f[k]=h}},this.endpointAdded=function(c){var g=jsPlumb.CurrentLibrary,h=document.body,i=a.getId(c),j=g.getElementObject(c),k=jsPlumb.CurrentLibrary.getOffset(j),l=c.parentNode;for(e[i]=e[i]?e[i]+1:1;null!=l&&l!=h;){var m=a.getId(l,null,!0);if(m&&b[m]){var n=g.getElementObject(l),o=g.getOffset(n);null==d[m][i]&&(d[m][i]={id:i,offset:{left:k.left-o.left,top:k.top-o.top}},f[i]=m);break}l=l.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)},this.setParent=function(a,b,c,e){var g=f[b];if(g){d[e]||(d[e]={}),d[e][b]=d[g][b],delete d[g][b];var h=jsPlumb.CurrentLibrary.getOffset(c),i=jsPlumb.CurrentLibrary.getOffset(a);d[e][b].offset={left:i.left-h.left,top:i.top-h.top},f[b]=e}}};window.console||(window.console={time:function(){},timeEnd:function(){},group:function(){},groupEnd:function(){},log:function(){}}),window.jsPlumbAdapter={headless:!1,getAttribute:function(a,b){return a.getAttribute(b)},setAttribute:function(a,b,c){a.setAttribute(b,c)},appendToRoot:function(a){document.body.appendChild(a)},getRenderModes:function(){return["canvas","svg","vml"]},isRenderModeAvailable:function(d){return{canvas:a,svg:b,vml:c()}[d]},getDragManager:function(a){return new d(a)},setRenderMode:function(a){var b;if(a){a=a.toLowerCase();var c=this.isRenderModeAvailable("canvas"),d=this.isRenderModeAvailable("svg"),e=this.isRenderModeAvailable("vml");"svg"===a?d?b="svg":c?b="canvas":e&&(b="vml"):"canvas"===a&&c?b="canvas":e&&(b="vml")}return b}}}(),function(){var a=jsPlumbUtil,b=function(a,b){y.CurrentLibrary.addClass(d(a),b)},c=function(a,b){y.CurrentLibrary.removeClass(d(a),b)},d=function(a){return y.CurrentLibrary.getElementObject(a)},e=function(a){return y.CurrentLibrary.getDOMElement(a)},f=function(a,b){var c=y.CurrentLibrary.getOffset(d(a));if(null!=b){var e=b.getZoom();return{left:c.left/e,top:c.top/e}}return c},g=function(a){return y.CurrentLibrary.getSize(d(a))},h=function(){return""+(new Date).getTime()},i=function(a){if(a._jsPlumb.paintStyle&&a._jsPlumb.hoverPaintStyle){var b={};y.extend(b,a._jsPlumb.paintStyle),y.extend(b,a._jsPlumb.hoverPaintStyle),delete a._jsPlumb.hoverPaintStyle,b.gradient&&a._jsPlumb.paintStyle.fillStyle&&delete b.gradient,a._jsPlumb.hoverPaintStyle=b}},j=["click","dblclick","mouseenter","mouseout","mousemove","mousedown","mouseup","contextmenu"],k={mouseout:"mouseexit"},l=function(a,b,c,d){var e=a.getAttachedElements();if(e)for(var f=0,g=e.length;g>f;f++)d&&d==e[f]||e[f].setHover(b,!0,c)},m=function(a){return null==a?null:a.split(" ")},n=function(b,c,d){if(b.getDefaultType){for(var e=b.getTypeDescriptor(),f=a.merge({},b.getDefaultType()),g=0,h=b._jsPlumb.types.length;h>g;g++)f=a.merge(f,b._jsPlumb.instance.getType(b._jsPlumb.types[g],e));c&&(f=a.populate(f,c)),b.applyType(f,d),d||b.repaint()}},o=window.jsPlumbUIComponent=function(b){jsPlumbUtil.EventGenerator.apply(this,arguments);var c=this,d=arguments,e=c.idPrefix,f=e+(new Date).getTime(),g=y.CurrentLibrary;if(this._jsPlumb={instance:b._jsPlumb,parameters:b.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:b.beforeDetach,beforeDrop:b.beforeDrop,overlayPlacements:[],hoverClass:b.hoverClass||b._jsPlumb.Defaults.HoverClass||y.Defaults.HoverClass,types:[]},this.getId=function(){return f},b.events)for(var h in b.events)c.bind(h,b.events[h]);this.clone=function(){var a={};return this.constructor.apply(a,d),a}.bind(this),this.isDetachAllowed=function(b){var c=!0;if(this._jsPlumb.beforeDetach)try{c=this._jsPlumb.beforeDetach(b)}catch(d){a.log("jsPlumb: beforeDetach callback failed",d)}return c},this.isDropAllowed=function(b,c,d,e,f){var g=this._jsPlumb.instance.checkCondition("beforeDrop",{sourceId:b,targetId:c,scope:d,connection:e,dropEndpoint:f});if(this._jsPlumb.beforeDrop)try{g=this._jsPlumb.beforeDrop({sourceId:b,targetId:c,scope:d,connection:e,dropEndpoint:f})}catch(h){a.log("jsPlumb: beforeDrop callback failed",h)}return g};var i=[],l=function(a,b,c){i.push([a,b,c]),a.bind(b,c)},m=[],n=function(a,b,c){var d=k[c]||c,e=function(a){b.fire(d,b,a)};m.push([a,c,e]),g.bind(a,c,e)},o=function(a,b,c){k[b]||b,g.unbind(a,b,c)};this.bindListeners=function(a,b,c){l(a,"click",function(a,c){b.fire("click",b,c)}),l(a,"dblclick",function(a,c){b.fire("dblclick",b,c)}),l(a,"contextmenu",function(a,c){b.fire("contextmenu",b,c)}),l(a,"mouseenter",function(a,d){b.isHover()||(c(!0),b.fire("mouseenter",b,d))}),l(a,"mouseexit",function(a,d){b.isHover()&&(c(!1),b.fire("mouseexit",b,d))}),l(a,"mousedown",function(a,c){b.fire("mousedown",b,c)}),l(a,"mouseup",function(a,c){b.fire("mouseup",b,c)})},this.unbindListeners=function(){for(var a=0;a<i.length;a++){var b=i[a];b[0].unbind(b[1],b[2])}i=null},this.attachListeners=function(a,b){for(var c=0,d=j.length;d>c;c++)n(a,b,j[c])},this.detachListeners=function(){for(var a=0;a<m.length;a++)o(m[a][0],m[a][1],m[a][2]);m=null},this.reattachListenersForElement=function(a){if(arguments.length>1){for(var b=0,c=j.length;c>b;b++)o(a,j[b]);for(b=1,c=arguments.length;c>b;b++)this.attachListeners(a,arguments[b])}}};jsPlumbUtil.extend(o,jsPlumbUtil.EventGenerator,{getParameter:function(a){return this._jsPlumb.parameters[a]},setParameter:function(a,b){this._jsPlumb.parameters[a]=b},getParameters:function(){return this._jsPlumb.parameters},setParameters:function(a){this._jsPlumb.parameters=a},addClass:function(a){null!=this.canvas&&b(this.canvas,a)},removeClass:function(a){null!=this.canvas&&c(this.canvas,a)},setType:function(a,b,c){this._jsPlumb.types=m(a)||[],n(this,b,c)},getType:function(){return this._jsPlumb.types},reapplyTypes:function(a,b){n(this,a,b)},hasType:function(a){return-1!=jsPlumbUtil.indexOf(this._jsPlumb.types,a)},addType:function(a,b,c){var d=m(a),e=!1;if(null!=d){for(var f=0,g=d.length;g>f;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&n(this,b,c)}},removeType:function(b,c){var d=m(b),e=!1,f=function(b){var c=a.indexOf(this._jsPlumb.types,b);return-1!=c?(this._jsPlumb.types.splice(c,1),!0):!1}.bind(this);if(null!=d){for(var g=0,h=d.length;h>g;g++)e=f(d[g])||e;e&&n(this,null,c)}},toggleType:function(a,b,c){var d=m(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var g=jsPlumbUtil.indexOf(this._jsPlumb.types,d[e]);-1!=g?this._jsPlumb.types.splice(g,1):this._jsPlumb.types.push(d[e])}n(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c])},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,i(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,i(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},cleanup:function(){this.unbindListeners(),this.detachListeners()},destroy:function(){this.cleanupListeners(),this.clone=null,this._jsPlumb=null},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,c){var d=y.CurrentLibrary;!this._jsPlumb||this._jsPlumb.instance.currentlyDragging||this._jsPlumb.instance.isHoverSuspended()||(this._jsPlumb.hover=a,null!=this.canvas&&null!=this._jsPlumb.instance.hoverClass&&d[a?"addClass":"removeClass"](this.canvas,this._jsPlumb.instance.hoverClass),null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(c=c||h(),this.repaint({timestamp:c,recalc:!1}))),this.getAttachedElements&&!b&&l(this,a,h(),this))}});var p="__label",q=function(a,b){for(var c=-1,d=0,e=a._jsPlumb.overlays.length;e>d;d++)if(b===a._jsPlumb.overlays[d].id){c=d;break}return c},r=function(a,b){var c={cssClass:b.cssClass,labelStyle:a.labelStyle,id:p,component:a,_jsPlumb:a._jsPlumb.instance},d=y.extend(c,b);return new(y.Overlays[a._jsPlumb.instance.getRenderMode()].Label)(d)},s=function(b,c){var d=null;if(a.isArray(c)){var e=c[0],f=y.extend({component:b,_jsPlumb:b._jsPlumb.instance},c[1]);3==c.length&&y.extend(f,c[2]),d=new(y.Overlays[b._jsPlumb.instance.getRenderMode()][e])(f)}else d=c.constructor==String?new(y.Overlays[b._jsPlumb.instance.getRenderMode()][c])({component:b,_jsPlumb:b._jsPlumb.instance}):c;b._jsPlumb.overlays.push(d)},t=function(a,b){var c=a.defaultOverlayKeys||[],d=b.overlays,e=function(b){return a._jsPlumb.instance.Defaults[b]||y.Defaults[b]||[]};d||(d=[]);for(var f=0,g=c.length;g>f;f++)d.unshift.apply(d,e(c[f]));return d},u=window.OverlayCapableJsPlumbUIComponent=function(a){o.apply(this,arguments),this._jsPlumb.overlays=[];var b=t(this,a);if(b)for(var c=0,d=b.length;d>c;c++)s(this,b[c]);if(a.label){var e=a.labelLocation||this.defaultLabelLocation||.5,f=a.labelStyle||this._jsPlumb.instance.Defaults.LabelStyle||y.Defaults.LabelStyle;this._jsPlumb.overlays.push(r(this,{label:a.label,location:e,labelStyle:f}))}};jsPlumbUtil.extend(u,o,{applyType:function(a,b){if(this.removeAllOverlays(b),a.overlays)for(var c=0,d=a.overlays.length;d>c;c++)this.addOverlay(a.overlays[c],!0)},setHover:function(a){if(this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged())for(var b=0,c=this._jsPlumb.overlays.length;c>b;b++)this._jsPlumb.overlays[b][a?"addClass":"removeClass"](this._jsPlumb.instance.hoverClass)},addOverlay:function(a,b){s(this,a),b||this.repaint()},getOverlay:function(a){var b=q(this,a);return b>=0?this._jsPlumb.overlays[b]:null},getOverlays:function(){return this._jsPlumb.overlays},hideOverlay:function(a){var b=this.getOverlay(a);b&&b.hide()},hideOverlays:function(){for(var a=0,b=this._jsPlumb.overlays.length;b>a;a++)this._jsPlumb.overlays[a].hide()},showOverlay:function(a){var b=this.getOverlay(a);b&&b.show()},showOverlays:function(){for(var a=0,b=this._jsPlumb.overlays.length;b>a;a++)this._jsPlumb.overlays[a].show()},removeAllOverlays:function(a){for(var b=0,c=this._jsPlumb.overlays.length;c>b;b++)this._jsPlumb.overlays[b].cleanup&&this._jsPlumb.overlays[b].cleanup();this._jsPlumb.overlays.splice(0,this._jsPlumb.overlays.length),a||this.repaint()},removeOverlay:function(a){var b=q(this,a);if(-1!=b){var c=this._jsPlumb.overlays[b];c.cleanup&&c.cleanup(),this._jsPlumb.overlays.splice(b,1)}},removeOverlays:function(){for(var a=0,b=arguments.length;b>a;a++)this.removeOverlay(arguments[a])},getLabel:function(){var a=this.getOverlay(p);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(p)},setLabel:function(a){var b=this.getOverlay(p);if(b)a.constructor==String||a.constructor==Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor==String||a.constructor==Function?{label:a}:a;b=r(this,c),this._jsPlumb.overlays.push(b)}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(){for(var a=0;a<this._jsPlumb.overlays.length;a++)this._jsPlumb.overlays[a].cleanup(),this._jsPlumb.overlays[a].destroy();this._jsPlumb.overlays.splice(0)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()}});var v=0,w=function(){var a=v+1;return v++,a},x=window.jsPlumbInstance=function(i){this.Defaults={Anchor:"BottomCenter",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fillStyle:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{lineWidth:8,strokeStyle:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},i&&y.extend(this.Defaults,i),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},jsPlumbUtil.EventGenerator.apply(this);var j=this,k=w(),l=j.bind,m={},n=1,p=function(a){var b=e(a);return{el:b,id:jsPlumbUtil.isString(a)&&null==b?a:bb(b)}};this.getInstanceIndex=function(){return k},this.setZoom=function(a,b){n=a,b&&j.repaintEverything()},this.getZoom=function(){return n};for(var q in this.Defaults)m[q]=this.Defaults[q];this.bind=function(a,b){"ready"===a&&s?b():l.apply(j,[a,b])},j.importDefaults=function(a){for(var b in a)j.Defaults[b]=a[b];return j},j.restoreDefaults=function(){return j.Defaults=y.extend({},m),j};var r=null,s=!1,t=[],u={},v={},x={},z={},A={},B={},C=!1,D=[],E=!1,F=null,G=this.Defaults.Scope,H=null,I=1,J=function(){return""+I++},K=function(a,b){j.Defaults.Container?y.CurrentLibrary.appendElement(a,j.Defaults.Container):b?y.CurrentLibrary.appendElement(a,b):jsPlumbAdapter.appendToRoot(a)},L=function(a){return a._nodes?a._nodes:a},M=function(a,b,c,d){if(!jsPlumbAdapter.headless&&!E){var e=bb(a),f=j.dragManager.getElementsForDraggable(e);null==c&&(c=h());var g=_({elId:e,offset:b,recalc:!1,timestamp:c});if(f)for(var i in f)_({elId:f[i].id,offset:{left:g.o.left+f[i].offset.left,top:g.o.top+f[i].offset.top},recalc:!1,timestamp:c});if(j.anchorManager.redraw(e,b,c,null,d),f)for(var k in f)j.anchorManager.redraw(f[k].id,b,c,f[k].offset,d,!0)}},N=function(b,c){var e,f,g=null;if(a.isArray(b)){g=[];for(var h=0,i=b.length;i>h;h++)e=d(b[h]),f=j.getAttribute(e,"id"),g.push(c(e,f))}else e=d(b),f=j.getAttribute(e,"id"),g=c(e,f);return g},O=function(a){return v[a]},P=function(d,e,f){if(!jsPlumbAdapter.headless){var g=null==e?!1:e,h=y.CurrentLibrary;if(g&&h.isDragSupported(d)&&!h.isAlreadyDraggable(d)){var i=f||j.Defaults.DragOptions||y.Defaults.DragOptions;i=y.extend({},i);var k=h.dragEvents.drag,l=h.dragEvents.stop,m=h.dragEvents.start;i[m]=a.wrap(i[m],function(){j.setHoverSuspended(!0),j.select({source:d}).addClass(j.elementDraggingClass+" "+j.sourceElementDraggingClass,!0),j.select({target:d}).addClass(j.elementDraggingClass+" "+j.targetElementDraggingClass,!0),j.setConnectionBeingDragged(!0)}),i[k]=a.wrap(i[k],function(){var a=h.getUIPosition(arguments,j.getZoom());M(d,a,null,!0),b(d,"jsPlumb_dragged")}),i[l]=a.wrap(i[l],function(){var a=h.getUIPosition(arguments,j.getZoom());M(d,a),c(d,"jsPlumb_dragged"),j.setHoverSuspended(!1),j.select({source:d}).removeClass(j.elementDraggingClass+" "+j.sourceElementDraggingClass,!0),j.select({target:d}).removeClass(j.elementDraggingClass+" "+j.targetElementDraggingClass,!0),j.setConnectionBeingDragged(!1),j.dragManager.dragEnded(d)});var n=bb(d);B[n]=!0;var o=B[n];i.disabled=null==o?!1:!o,h.initDraggable(d,i,!1,j),j.dragManager.register(d)}}},Q=function(b,c){var d=y.extend({},b);if(c&&y.extend(d,c),d.source&&(d.source.endpoint?d.sourceEndpoint=d.source:d.source=e(d.source)),d.target&&(d.target.endpoint?d.targetEndpoint=d.target:d.target=e(d.target)),b.uuids&&(d.sourceEndpoint=O(b.uuids[0]),d.targetEndpoint=O(b.uuids[1])),d.sourceEndpoint&&d.sourceEndpoint.isFull())return a.log(j,"could not add connection; source endpoint is full"),void 0;if(d.targetEndpoint&&d.targetEndpoint.isFull())return a.log(j,"could not add connection; target endpoint is full"),void 0;if(!d.type&&d.sourceEndpoint&&(d.type=d.sourceEndpoint.connectionType),d.sourceEndpoint&&d.sourceEndpoint.connectorOverlays){d.overlays=d.overlays||[];for(var f=0,g=d.sourceEndpoint.connectorOverlays.length;g>f;f++)d.overlays.push(d.sourceEndpoint.connectorOverlays[f])}!d["pointer-events"]&&d.sourceEndpoint&&d.sourceEndpoint.connectorPointerEvents&&(d["pointer-events"]=d.sourceEndpoint.connectorPointerEvents);var h,i,k,l;if(d.target&&!d.target.endpoint&&!d.targetEndpoint&&!d.newConnection&&(h=bb(d.target),i=tb[h],k=ub[h],i)){if(!Eb[h])return;i.isTarget=!0,l=null!=k?k:j.addEndpoint(d.target,i),vb[h]&&(ub[h]=l),d.targetEndpoint=l,l._doNotDeleteOnDetach=!1,l._deleteOnDetach=!0}if(d.source&&!d.source.endpoint&&!d.sourceEndpoint&&!d.newConnection&&(h=bb(d.source),i=yb[h],k=zb[h],i)){if(!Bb[h])return;l=null!=k?k:j.addEndpoint(d.source,i),Ab[h]&&(zb[h]=l),d.sourceEndpoint=l,l._doNotDeleteOnDetach=!1,l._deleteOnDetach=!0}return d},R=function(a){var b=j.Defaults.ConnectionType||j.getDefaultConnectionType(),c=j.Defaults.EndpointType||y.Endpoint,d=y.CurrentLibrary.getParent;a.parent=a.container?a.container:a.sourceEndpoint?a.sourceEndpoint.parent:a.source.constructor==c?a.source.parent:d(a.source),a._jsPlumb=j,a.newConnection=R,a.newEndpoint=V,a.endpointsByUUID=v,a.endpointsByElement=u,a.finaliseConnection=S;var e=new b(a);return e.id="con_"+J(),T("click","click",e),T("dblclick","dblclick",e),T("contextmenu","contextmenu",e),e.isDetachable()&&(e.endpoints[0].initDraggable(),e.endpoints[1].initDraggable()),e},S=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||t.push(a),(null==a.suspendedEndpoint||d)&&j.anchorManager.newConnection(a),M(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};j.fire("connection",e,c)}},T=function(a,b,c){c.bind(a,function(a,d){j.fire(b,c,d)})},U=function(a){if(a.container)return a.container;var b=y.CurrentLibrary.getTagName(a.source),c=y.CurrentLibrary.getParent(a.source);return b&&"td"===b.toLowerCase()?y.CurrentLibrary.getParent(c):c},V=function(a){var b=j.Defaults.EndpointType||y.Endpoint,c=y.extend({},a);c.parent=U(c),c._jsPlumb=j,c.newConnection=R,c.newEndpoint=V,c.endpointsByUUID=v,c.endpointsByElement=u,c.finaliseConnection=S,c.fireDetachEvent=cb,c.fireMoveEvent=db,c.floatingConnections=A,c.getParentFromParams=U,c.elementId=bb(c.source);var d=new b(c);return d.id="ep_"+J(),T("click","endpointClick",d),T("dblclick","endpointDblClick",d),T("contextmenu","contextmenu",d),jsPlumbAdapter.headless||j.dragManager.endpointAdded(c.source),d},W=function(a,b,c){var d=u[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},X=function(a,b){return N(a,function(a,c){B[c]=b,y.CurrentLibrary.isDragSupported(a)&&y.CurrentLibrary.setDraggable(a,b)})},Y=function(a,b,c){b="block"===b;var d=null;c&&(d=b?function(a){a.setVisible(!0,!0,!0)}:function(a){a.setVisible(!1,!0,!0)});var e=p(a);W(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},Z=function(a){return N(a,function(a,b){var c=null==B[b]?!1:B[b];return c=!c,B[b]=c,y.CurrentLibrary.setDraggable(a,c),c})},$=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),W(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},_=function(a){var b,c=a.timestamp,e=a.recalc,h=a.offset,i=a.elId;return E&&!c&&(c=F),!e&&c&&c===z[i]?{o:a.offset||x[i],s:D[i]}:(e||!h?(b=d(i),null!=b&&(D[i]=g(b),x[i]=f(b,j),z[i]=c)):(x[i]=h,null==D[i]&&(b=d(i),null!=b&&(D[i]=g(b))),z[i]=c),x[i]&&!x[i].right&&(x[i].right=x[i].left+D[i][0],x[i].bottom=x[i].top+D[i][1],x[i].width=D[i][0],x[i].height=D[i][1],x[i].centerx=x[i].left+x[i].width/2,x[i].centery=x[i].top+x[i].height/2),{o:x[i],s:D[i]})
+},ab=function(a){var b=x[a];return b?{o:b,s:D[a]}:_({elId:a})},bb=function(a,b,c){if(jsPlumbUtil.isString(a))return a;if(null==a)return null;var d=jsPlumbAdapter.getAttribute(a,"id");return d&&"undefined"!==d||(2==arguments.length&&void 0!==arguments[1]?d=b:(1==arguments.length||3==arguments.length&&!arguments[2])&&(d="jsPlumb_"+k+"_"+J()),c||jsPlumbAdapter.setAttribute(a,"id",d)),d};this.setConnectionBeingDragged=function(a){C=a},this.isConnectionBeingDragged=function(){return C},this.connectorClass="_jsPlumb_connector",this.hoverClass="_jsPlumb_hover",this.endpointClass="_jsPlumb_endpoint",this.endpointConnectedClass="_jsPlumb_endpoint_connected",this.endpointFullClass="_jsPlumb_endpoint_full",this.endpointDropAllowedClass="_jsPlumb_endpoint_drop_allowed",this.endpointDropForbiddenClass="_jsPlumb_endpoint_drop_forbidden",this.overlayClass="_jsPlumb_overlay",this.draggingClass="_jsPlumb_dragging",this.elementDraggingClass="_jsPlumb_element_dragging",this.sourceElementDraggingClass="_jsPlumb_source_element_dragging",this.targetElementDraggingClass="_jsPlumb_target_element_dragging",this.endpointAnchorClassPrefix="_jsPlumb_endpoint_anchor",this.hoverSourceClass="_jsPlumb_source_hover",this.hoverTargetClass="_jsPlumb_target_hover",this.dragSelectClass="_jsPlumb_drag_select",this.Anchors={},this.Connectors={canvas:{},svg:{},vml:{}},this.Endpoints={canvas:{},svg:{},vml:{}},this.Overlays={canvas:{},svg:{},vml:{}},this.ConnectorRenderers={},this.SVG="svg",this.CANVAS="canvas",this.VML="vml",this.addEndpoint=function(b,c,d){d=d||{};var f=y.extend({},d);y.extend(f,c),f.endpoint=f.endpoint||j.Defaults.Endpoint||y.Defaults.Endpoint,f.paintStyle=f.paintStyle||j.Defaults.EndpointStyle||y.Defaults.EndpointStyle,b=L(b);for(var g=[],h=a.isArray(b)||null!=b.length&&!a.isString(b)?b:[b],i=0,k=h.length;k>i;i++){var l=e(h[i]),m=bb(l);f.source=l,_({elId:m,timestamp:F});var n=V(f);f.parentAnchor&&(n.parentAnchor=f.parentAnchor),a.addToList(u,m,n);var o=x[m],p=D[m],q=n.anchor.compute({xy:[o.left,o.top],wh:p,element:n,timestamp:F}),r={anchorLoc:q,timestamp:F};E&&(r.recalc=!1),E||n.paint(r),g.push(n),n._doNotDeleteOnDetach=!0}return 1==g.length?g[0]:g},this.addEndpoints=function(b,c,d){for(var e=[],f=0,g=c.length;g>f;f++){var h=j.addEndpoint(b,c[f],d);a.isArray(h)?Array.prototype.push.apply(e,h):e.push(h)}return e},this.animate=function(b,c,e){e=e||{};var f=d(b),g=bb(b),h=y.CurrentLibrary.dragEvents.step,i=y.CurrentLibrary.dragEvents.complete;e[h]=a.wrap(e[h],function(){j.repaint(g)}),e[i]=a.wrap(e[i],function(){j.repaint(g)}),y.CurrentLibrary.animate(f,c,e)},this.checkCondition=function(b,c){var d=j.getListener(b),e=!0;if(d&&d.length>0)try{for(var f=0,g=d.length;g>f;f++)e=e&&d[f](c)}catch(h){a.log(j,"cannot check condition ["+b+"]"+h)}return e},this.checkASyncCondition=function(b,c,d,e){var f=j.getListener(b);if(f&&f.length>0)try{f[0](c,d,e)}catch(g){a.log(j,"cannot asynchronously check condition ["+b+"]"+g)}},this.connect=function(a,b){var c,d=Q(a,b);return d&&(c=R(d),S(c,d)),c},this.deleteEndpoint=function(a,b){var c=j.setSuspendDrawing(!0),d="string"==typeof a?v[a]:a;return d&&j.deleteObject({endpoint:d}),c||j.setSuspendDrawing(!1,b),j},this.deleteEveryEndpoint=function(){var a=j.setSuspendDrawing(!0);for(var b in u){var c=u[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)j.deleteEndpoint(c[d],!0)}return u={},v={},j.anchorManager.reset(),j.dragManager.reset(),a||j.setSuspendDrawing(!1),j};var cb=function(a,b,c){var d=j.Defaults.ConnectionType||j.getDefaultConnectionType(),e=a.constructor==d,f=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&j.fire("connectionDetached",f,c),j.anchorManager.connectionDetached(f)},db=function(a,b){j.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(v[a._jsPlumb.uuid]=null),j.anchorManager.deleteEndpoint(a);for(var b in u){var c=u[b];if(c){for(var d=[],e=0,f=c.length;f>e;e++)c[e]!=a&&d.push(c[e]);u[b]=d}u[b].length<1&&delete u[b]}},this.detach=function(){if(0!==arguments.length){var a=j.Defaults.ConnectionType||j.getDefaultConnectionType(),b=arguments[0].constructor==a,c=2==arguments.length?b?arguments[1]||{}:arguments[0]:arguments[0],d=c.fireEvent!==!1,f=c.forceDetach,g=b?arguments[0]:c.connection;if(g)(f||jsPlumbUtil.functionChain(!0,!1,[[g.endpoints[0],"isDetachAllowed",[g]],[g.endpoints[1],"isDetachAllowed",[g]],[g,"isDetachAllowed",[g]],[j,"checkCondition",["beforeDetach",g]]]))&&g.endpoints[0].detach(g,!1,!0,d);else{var h=y.extend({},c);if(h.uuids)O(h.uuids[0]).detachFrom(O(h.uuids[1]),d);else if(h.sourceEndpoint&&h.targetEndpoint)h.sourceEndpoint.detachFrom(h.targetEndpoint);else{var i=bb(e(h.source)),k=bb(e(h.target));W(i,function(a){(a.sourceId==i&&a.targetId==k||a.targetId==i&&a.sourceId==k)&&j.checkCondition("beforeDetach",a)&&a.endpoints[0].detach(a,!1,!0,d)})}}}},this.detachAllConnections=function(a,b){b=b||{},a=e(a);var c=bb(a),d=u[c];if(d&&d.length)for(var f=0,g=d.length;g>f;f++)d[f].detachAll(b.fireEvent!==!1);return j},this.detachEveryConnection=function(a){return a=a||{},j.doWhileSuspended(function(){for(var b in u){var c=u[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)c[d].detachAll(a.fireEvent!==!1)}t.splice(0)}),j},this.deleteObject=function(a){var b={endpoints:{},connections:{},endpointCount:0,connectionCount:0},c=a.fireEvent!==!1,d=a.deleteAttachedObjects!==!1,e=function(a){if(null!=a&&null==b.connections[a.id]&&(null!=a._jsPlumb&&a.setHover(!1),b.connections[a.id]=a,b.connectionCount++,d))for(var c=0;c<a.endpoints.length;c++)a.endpoints[c]._deleteOnDetach&&f(a.endpoints[c])},f=function(a){if(null!=a&&null==b.endpoints[a.id]&&(null!=a._jsPlumb&&a.setHover(!1),b.endpoints[a.id]=a,b.endpointCount++,d))for(var c=0;c<a.connections.length;c++){var f=a.connections[c];e(f)}};a.connection?e(a.connection):f(a.endpoint);for(var g in b.connections){var h=b.connections[g];h.endpoints[0].detachFromConnection(h),h.endpoints[1].detachFromConnection(h),jsPlumbUtil.removeWithFunction(t,function(a){return h.id==a.id}),cb(h,c,a.originalEvent),h.cleanup(),h.destroy()}for(var i in b.endpoints){var k=b.endpoints[i];j.unregisterEndpoint(k),k.cleanup(),k.destroy()}return b},this.draggable=function(a,b){var c,d,f;if("object"==typeof a&&a.length)for(c=0,d=a.length;d>c;c++)f=e(a[c]),f&&P(f,!0,b);else if(a._nodes)for(c=0,d=a._nodes.length;d>c;c++)f=e(a._nodes[c]),f&&P(f,!0,b);else f=e(a),f&&P(f,!0,b);return j},this.extend=function(a,b){return y.CurrentLibrary.extend(a,b)};var eb=function(a,b,c,d){for(var e=0,f=a.length;f>e;e++)a[e][b].apply(a[e],c);return d(a)},fb=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},gb=function(a,b,c){return function(){return eb(a,b,arguments,c)}},hb=function(a,b){return function(){return fb(a,b,arguments)}},ib=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(a=d(a),b)c=a;else for(var e=0,f=a.length;f>e;e++)c.push(p(a[e]).id);return c},jb=function(a,b,c){return"*"===a?!0:a.length>0?-1!=jsPlumbUtil.indexOf(a,b):!c};this.getConnections=function(a,b){a?a.constructor==String&&(a={scope:a}):a={};for(var c=a.scope||j.getDefaultScope(),d=ib(c,!0),e=ib(a.source),f=ib(a.target),g=!b&&d.length>1?{}:[],h=function(a,c){if(!b&&d.length>1){var e=g[a];null==e&&(e=g[a]=[]),e.push(c)}else g.push(c)},i=0,k=t.length;k>i;i++){var l=t[i];jb(d,l.scope)&&jb(e,l.sourceId)&&jb(f,l.targetId)&&h(l.scope,l)}return g};var kb=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},lb=function(a){return function(b){return a[b]}},mb=function(a,b){var c,d,e={length:a.length,each:kb(a,b),get:lb(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=gb(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=hb(a,g[c]);return e},nb=function(a){var b=mb(a,nb);return y.CurrentLibrary.extend(b,{setDetachable:gb(a,"setDetachable",nb),setReattach:gb(a,"setReattach",nb),setConnector:gb(a,"setConnector",nb),detach:function(){for(var b=0,c=a.length;c>b;b++)j.detach(a[b])},isDetachable:hb(a,"isDetachable"),isReattach:hb(a,"isReattach")})},ob=function(a){var b=mb(a,ob);return y.CurrentLibrary.extend(b,{setEnabled:gb(a,"setEnabled",ob),setAnchor:gb(a,"setAnchor",ob),isEnabled:hb(a,"isEnabled"),detachAll:function(){for(var b=0,c=a.length;c>b;b++)a[b].detachAll()},remove:function(){for(var b=0,c=a.length;c>b;b++)j.deleteObject({endpoint:a[b]})}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",nb(a.connections||j.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":ib(a.element),d=b?"*":ib(a.source),e=b?"*":ib(a.target),f=ib(a.scope,!0),g=[];for(var h in u){var i=jb(c,h,!0),j=jb(d,h,!0),k="*"!=d,l=jb(e,h,!0),m="*"!=e;if(i||j||l)a:for(var n=0,o=u[h].length;o>n;n++){var p=u[h][n];if(jb(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return ob(g)},this.getAllConnections=function(){return t},this.getDefaultScope=function(){return G},this.getEndpoint=O,this.getEndpoints=function(a){return u[p(a).id]},this.getDefaultEndpointType=function(){return y.Endpoint},this.getDefaultConnectionType=function(){return y.Connection},this.getId=bb,this.getOffset=function(a){return x[a],_({elId:a})},this.getSelector=function(){return y.CurrentLibrary.getSelector.apply(null,arguments)},this.getSize=function(a){var b=D[a];return b||_({elId:a}),D[a]},this.appendElement=K;var pb=!1;this.isHoverSuspended=function(){return pb},this.setHoverSuspended=function(a){pb=a};var qb=function(a){return function(){return jsPlumbAdapter.isRenderModeAvailable(a)}};this.isCanvasAvailable=qb("canvas"),this.isSVGAvailable=qb("svg"),this.isVMLAvailable=qb("vml"),this.hide=function(a,b){return Y(a,"none",b),j},this.idstamp=J,this.connectorsInitialized=!1;var rb=[],sb=["canvas","svg","vml"];this.registerConnectorType=function(a,b){rb.push([a,b])},this.init=function(){var a=function(a,b,c){y.Connectors[a][b]=function(){c.apply(this,arguments),y.ConnectorRenderers[a].apply(this,arguments)},jsPlumbUtil.extend(y.Connectors[a][b],[c,y.ConnectorRenderers[a]])};if(!y.connectorsInitialized){for(var b=0;b<rb.length;b++)for(var c=0;c<sb.length;c++)a(sb[c],rb[b][1],rb[b][0]);y.connectorsInitialized=!0}s||(j.anchorManager=new y.AnchorManager({jsPlumbInstance:j}),j.setRenderMode(j.Defaults.RenderMode),s=!0,j.fire("ready",j))}.bind(this),this.log=r,this.jsPlumbUIComponent=o,this.makeAnchor=function(){var b,c=function(a,b){if(y.Anchors[a])return new y.Anchors[a](b);if(!j.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown anchor type '"+a+"'"}};if(0===arguments.length)return null;var d=arguments[0],e=arguments[1],f=arguments[2],g=null;if(d.compute&&d.getOrientation)return d;if("string"==typeof d)g=c(arguments[0],{elementId:e,jsPlumbInstance:j});else if(a.isArray(d))if(a.isArray(d[0])||a.isString(d[0]))2==d.length&&a.isObject(d[1])?a.isString(d[0])?(b=y.extend({elementId:e,jsPlumbInstance:j},d[1]),g=c(d[0],b)):(b=y.extend({elementId:e,jsPlumbInstance:j,anchors:d[0]},d[1]),g=new y.DynamicAnchor(b)):g=new y.DynamicAnchor({anchors:d,selector:null,elementId:e,jsPlumbInstance:f});else{var h={x:d[0],y:d[1],orientation:d.length>=4?[d[2],d[3]]:[0,0],offsets:d.length>=6?[d[4],d[5]]:[0,0],elementId:e,jsPlumbInstance:f,cssClass:7==d.length?d[6]:null};g=new y.Anchor(h),g.clone=function(){return new y.Anchor(h)}}return g.id||(g.id="anchor_"+J()),g},this.makeAnchors=function(b,c,d){for(var e=[],f=0,g=b.length;g>f;f++)"string"==typeof b[f]?e.push(y.Anchors[b[f]]({elementId:c,jsPlumbInstance:d})):a.isArray(b[f])&&e.push(j.makeAnchor(b[f],c,d));return e},this.makeDynamicAnchor=function(a,b){return new y.DynamicAnchor({anchors:a,selector:b,elementId:null,jsPlumbInstance:j})};var tb={},ub={},vb={},wb={},xb=function(a,b){a.paintStyle=a.paintStyle||j.Defaults.EndpointStyles[b]||j.Defaults.EndpointStyle||y.Defaults.EndpointStyles[b]||y.Defaults.EndpointStyle,a.hoverPaintStyle=a.hoverPaintStyle||j.Defaults.EndpointHoverStyles[b]||j.Defaults.EndpointHoverStyle||y.Defaults.EndpointHoverStyles[b]||y.Defaults.EndpointHoverStyle,a.anchor=a.anchor||j.Defaults.Anchors[b]||j.Defaults.Anchor||y.Defaults.Anchors[b]||y.Defaults.Anchor,a.endpoint=a.endpoint||j.Defaults.Endpoints[b]||j.Defaults.Endpoint||y.Defaults.Endpoints[b]||y.Defaults.Endpoint},yb={},zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb=function(a,b,c){for(var d=a.target||a.srcElement,e=!1,f=j.getSelector(b,c),g=0;g<f.length;g++)if(f[g]==d){e=!0;break}return e};this.makeTarget=function(b,c,e){var h=y.extend({_jsPlumb:j},e);y.extend(h,c),xb(h,1);var i=y.CurrentLibrary,k=h.scope||j.Defaults.Scope,l=!(h.deleteEndpointsOnDetach===!1),m=h.maxConnections||-1,n=h.onMaxConnections,q=function(b){var c=p(b),e=c.id,q=new o(h),r=y.extend({},h.dropOptions||{});tb[e]=h,vb[e]=h.uniqueEndpoint,wb[e]=m,Eb[e]=!0;var s=function(){j.currentlyDragging=!1;var a=y.CurrentLibrary.getDropEvent(arguments),b=j.select({target:e}).length,k=d(i.getDragObject(arguments)),m=j.getAttribute(k,"dragId"),o=j.getAttribute(k,"originalScope"),p=A[m],r=p.endpoints[0].isFloating()?0:1,s=p.endpoints[0];if(h.endpoint?y.extend({},h.endpoint):{},!Eb[e]||wb[e]>0&&b>=wb[e])return n&&n({element:c.el,connection:p},a),!1;if(s.anchor.locked=!1,o&&i.setDragScope(k,o),null==p.suspendedEndpoint&&!p.pending)return!1;var t=q.isDropAllowed(0===r?e:p.sourceId,0===r?p.targetId:e,p.scope,p,null);if(p.suspendedEndpoint&&(p[r?"targetId":"sourceId"]=p.suspendedEndpoint.elementId,p[r?"target":"source"]=p.suspendedEndpoint.element,p.endpoints[r]=p.suspendedEndpoint),t){var u=i.getElementObject(c.el),v=ub[e]||j.addEndpoint(u,h);if(h.uniqueEndpoint&&(ub[e]=v),v._doNotDeleteOnDetach=!1,v._deleteOnDetach=!0,null!=v.anchor.positionFinder){var w=i.getUIPosition(arguments,j.getZoom()),x=f(u,j),z=g(u),B=v.anchor.positionFinder(w,x,z,v.anchor.constructorParams);v.anchor.x=B[0],v.anchor.y=B[1]}p[r?"target":"source"]=v.element,p[r?"targetId":"sourceId"]=v.elementId,p.endpoints[r].detachFromConnection(p),p.endpoints[r]._deleteOnDetach&&(p.endpoints[r].deleteAfterDragStop=!0),v.addConnection(p),p.endpoints[r]=v,p.deleteEndpointsOnDetach=l,1==r?j.anchorManager.updateOtherEndpoint(p.sourceId,p.suspendedElementId,p.targetId,p):j.anchorManager.sourceChanged(p.suspendedEndpoint.elementId,p.sourceId,p),S(p,null,a),p.pending=!1}else p.suspendedEndpoint&&(p.isReattach()?(p.setHover(!1),p.floatingAnchorIndex=null,p.suspendedEndpoint.addConnection(p),j.repaint(s.elementId)):s.detach(p,!1,!0,!0,a))},t=i.dragEvents.drop;r.scope=r.scope||k,r[t]=a.wrap(r[t],s),i.initDroppable(d(c.el),r,!0)};b=L(b);for(var r=b.length&&b.constructor!=String?b:[b],s=0,t=r.length;t>s;s++)q(r[s]);return j},this.unmakeTarget=function(a,b){var c=p(a);return y.CurrentLibrary.destroyDroppable(c.el),b||(delete tb[c.id],delete vb[c.id],delete wb[c.id],delete Eb[c.id]),j},this.makeSource=function(b,c,f){var g=y.extend({},f);y.extend(g,c),xb(g,0);var h=y.CurrentLibrary,i=g.maxConnections||-1,k=g.onMaxConnections,l=function(b){var c=b.id,f=d(b.el),l=function(){return null==g.parent?null:"parent"===g.parent?b.el.parentNode:e(g.parent)},m=null!=g.parent?j.getId(l()):c;yb[m]=g,Ab[m]=g.uniqueEndpoint,Bb[m]=!0;var n=h.dragEvents.stop,o=h.dragEvents.drag,p=y.extend({},g.dragOptions||{}),q=p.drag,r=p.stop,s=null,u=!1;Db[m]=i,p.scope=p.scope||g.scope,p[o]=a.wrap(p[o],function(){q&&q.apply(this,arguments),u=!1}),p[n]=a.wrap(p[n],function(){if(r&&r.apply(this,arguments),j.currentlyDragging=!1,null!=s._jsPlumb){h.unbind(s.canvas,"mousedown");var a=g.anchor||j.Defaults.Anchor,b=(s.anchor,s.connections[0]);if(s.setAnchor(j.makeAnchor(a,c,j),!0),g.parent){var d=l();if(d){var e=(s.elementId,g.container||j.Defaults.Container||y.Defaults.Container);s.setElement(d,e),s.endpointWillMoveAfterConnection=!1,b.previousConnection=null,jsPlumbUtil.removeWithFunction(t,function(a){return a.id===b.id}),j.anchorManager.connectionDetached({sourceId:b.sourceId,targetId:b.targetId,connection:b}),S(b)}}s.repaint(),j.repaint(s.elementId),j.repaint(b.targetId)}});var v=function(a){if(Bb[m]){if(g.filter){var b=h.getOriginalEvent(a),d=jsPlumbUtil.isString(g.filter)?Fb(b,f,g.filter):g.filter(b,f);if(d===!1)return}var e=j.select({source:m}).length;if(Db[m]>=0&&e>=Db[m])return k&&k({element:f,maxConnections:i},a),!1;var n=_({elId:c}).o,o=j.getZoom(),q=((a.pageX||a.page.x)/o-n.left)/n.width,r=((a.pageY||a.page.y)/o-n.top)/n.height,t=q,v=r;if(g.parent){var w=l(),x=bb(w);n=_({elId:x}).o,t=((a.pageX||a.page.x)-n.left)/n.width,v=((a.pageY||a.page.y)-n.top)/n.height}var z={};if(y.extend(z,g),z.isSource=!0,z.anchor=[q,r,0,0],z.parentAnchor=[t,v,0,0],z.dragOptions=p,g.parent){var A=z.container||j.Defaults.Container||y.Defaults.Container;z.container=A?A:y.CurrentLibrary.getParent(l())}s=j.addEndpoint(c,z),u=!0,s.endpointWillMoveAfterConnection=null!=g.parent,s.endpointWillMoveTo=g.parent?l():null,s._doNotDeleteOnDetach=!1,s._deleteOnDetach=!0;var B=function(){u&&(u=!1,j.deleteEndpoint(s))};j.registerListener(s.canvas,"mouseup",B),j.registerListener(f,"mouseup",B),h.trigger(s.canvas,"mousedown",a)}};j.registerListener(f,"mousedown",v),Cb[c]=v,g.filter&&jsPlumbUtil.isString(g.filter)&&h.setDragFilter(f,g.filter)};b=L(b);for(var m=b.length&&b.constructor!=String?b:[b],n=0,o=m.length;o>n;n++)l(p(m[n]));return j},this.unmakeSource=function(a,b){var c=p(a),d=Cb[c.id];return d&&j.unregisterListener(c.el,"mousedown",d),b||(delete yb[c.id],delete Ab[c.id],delete Bb[c.id],delete Cb[c.id],delete Db[c.id]),j},this.unmakeEverySource=function(){for(var a in Bb)j.unmakeSource(a,!0);yb={},Ab={},Bb={},Cb={}},this.unmakeEveryTarget=function(){for(var a in Eb)j.unmakeTarget(a,!0);return tb={},vb={},wb={},Eb={},j};var Gb=function(b,c,d,e){var f="source"==b?Bb:Eb;if(c=L(c),a.isString(c))f[c]=e?!f[c]:d;else if(c.length)for(var g=0,h=c.length;h>g;g++){var i=p(c[g]);f[i.id]=e?!f[i.id]:d}return j};this.toggleSourceEnabled=function(a){return Gb("source",a,null,!0),j.isSourceEnabled(a)},this.setSourceEnabled=function(a,b){return Gb("source",a,b)},this.isSource=function(a){return null!=Bb[p(a).id]},this.isSourceEnabled=function(a){return Bb[p(a).id]===!0},this.toggleTargetEnabled=function(a){return Gb("target",a,null,!0),j.isTargetEnabled(a)},this.isTarget=function(a){return null!=Eb[p(a).id]},this.isTargetEnabled=function(a){return Eb[p(a).id]===!0},this.setTargetEnabled=function(a,b){return Gb("target",a,b)},this.ready=function(a){j.bind("ready",a)},this.repaint=function(a,b,c){if("object"==typeof a&&a.length)for(var d=0,e=a.length;e>d;d++)M(a[d],b,c);else M(a,b,c);return j},this.repaintEverything=function(){var a=h();for(var b in u)M(b,null,a);return j},this.removeAllEndpoints=function(a,b){var c=function(a){var d,e,f=p(a),g=u[f.id];if(g)for(d=0,e=g.length;e>d;d++)j.deleteEndpoint(g[d]);if(delete u[f.id],b&&f.el&&3!=f.el.nodeType&&8!=f.el.nodeType)for(d=0,e=f.el.childNodes.length;e>d;d++)c(f.el.childNodes[d])};return c(a),j},this.remove=function(a,b){var c=p(a);j.doWhileSuspended(function(){j.removeAllEndpoints(c.id,!0),j.dragManager.elementRemoved(c.id),delete A[c.id],j.anchorManager.clearFor(c.id),j.anchorManager.removeFloatingConnection(c.id)},b===!1),c.el&&y.CurrentLibrary.removeElement(c.el)};var Hb={},Ib=function(){for(var a in Hb)for(var b=0,c=Hb[a].length;c>b;b++){var d=Hb[a][b];y.CurrentLibrary.unbind(d.el,d.event,d.listener)}Hb={}};this.registerListener=function(a,b,c){y.CurrentLibrary.bind(a,b,c),jsPlumbUtil.addToList(Hb,b,{el:a,event:b,listener:c})},this.unregisterListener=function(a,b,c){y.CurrentLibrary.unbind(a,b,c),jsPlumbUtil.removeWithFunction(Hb,function(a){return a.type==b&&a.listener==c})},this.reset=function(){j.deleteEveryEndpoint(),j.unbind(),tb={},ub={},vb={},wb={},yb={},zb={},Ab={},Db={},t.splice(0),Ib(),j.anchorManager.reset(),jsPlumbAdapter.headless||j.dragManager.reset()},this.setDefaultScope=function(a){return G=a,j},this.setDraggable=X,this.setId=function(a,b,c){var d;jsPlumbUtil.isString(a)?d=a:(a=e(a),d=j.getId(a));var f=j.getConnections({source:d,scope:"*"},!0),g=j.getConnections({target:d,scope:"*"},!0);b=""+b,c?a=e(b):(a=e(d),jsPlumbAdapter.setAttribute(a,"id",b)),u[b]=u[d]||[];for(var h=0,i=u[b].length;i>h;h++)u[b][h].setElementId(b),u[b][h].setReferenceElement(a);delete u[d],j.anchorManager.changeId(d,b),jsPlumbAdapter.headless||j.dragManager.changeId(d,b);var k=function(c,d,e){for(var f=0,g=c.length;g>f;f++)c[f].endpoints[d].setElementId(b),c[f].endpoints[d].setReferenceElement(a),c[f][e+"Id"]=b,c[f][e]=a};k(f,0,"source"),k(g,1,"target"),j.repaint(b)},this.setDebugLog=function(a){r=a},this.setSuspendDrawing=function(a,b){var c=E;return E=a,F=a?(new Date).getTime():null,b&&j.repaintEverything(),c},this.isSuspendDrawing=function(){return E},this.getSuspendedAt=function(){return F},this.doWhileSuspended=function(b,c){var d=j.isSuspendDrawing();d||j.setSuspendDrawing(!0);try{b()}catch(e){a.log("Function run while suspended failed",e)}d||j.setSuspendDrawing(!1,!c)},this.updateOffset=_,this.getOffset=function(a){return x[a]},this.getSize=function(a){return D[a]},this.getCachedData=ab,this.timestamp=h,this.setRenderMode=function(a){H=jsPlumbAdapter.setRenderMode(a);var b,c;if(H==y.CANVAS){var d=function(a){y.CurrentLibrary.bind(document,a,function(d){if(!j.currentlyDragging&&H==y.CANVAS){for(b=0,c=t.length;c>b;b++){var e=t[b].getConnector()[a](d);if(e)return}for(var f in u){var g=u[f];for(b=0,c=g.length;c>b;b++)if(g[b].endpoint[a]&&g[b].endpoint[a](d))return}}})};d("click"),d("dblclick"),d("mousemove"),d("mousedown"),d("mouseup"),d("contextmenu")}return H},this.getRenderMode=function(){return H},this.show=function(a,b){return Y(a,"block",b),j},this.getTestHarness=function(){return{endpointsByElement:u,endpointCount:function(a){var b=u[a];return b?b.length:0},connectionCount:function(a){a=a||G;var b=j.getConnections({scope:a});return b?b.length:0},getId:bb,makeAnchor:self.makeAnchor,makeDynamicAnchor:self.makeDynamicAnchor}},this.toggleVisible=$,this.toggleDraggable=Z,this.addListener=this.bind,this.adjustForParentOffsetAndScroll=function(a,b){var c=null,d=a;if("svg"===b.tagName.toLowerCase()&&b.parentNode?c=b.parentNode:b.offsetParent&&(c=b.offsetParent),null!=c){var e="body"===c.tagName.toLowerCase()?{left:0,top:0}:f(c,j),g="body"===c.tagName.toLowerCase()?{left:0,top:0}:{left:c.scrollLeft,top:c.scrollTop};d[0]=a[0]-e.left+g.left,d[1]=a[1]-e.top+g.top}return d},jsPlumbAdapter.headless||(j.dragManager=jsPlumbAdapter.getDragManager(j),j.recalculateOffsets=j.dragManager.updateOffsets)};jsPlumbUtil.extend(x,jsPlumbUtil.EventGenerator,{setAttribute:function(a,b,c){jsPlumbAdapter.setAttribute(a,b,c)},getAttribute:function(a,b){return jsPlumbAdapter.getAttribute(y.CurrentLibrary.getDOMElement(a),b)},registerConnectionType:function(a,b){this._connectionTypes[a]=y.extend({},b)},registerConnectionTypes:function(a){for(var b in a)this._connectionTypes[b]=y.extend({},a[b])},registerEndpointType:function(a,b){this._endpointTypes[a]=y.extend({},b)},registerEndpointTypes:function(a){for(var b in a)this._endpointTypes[b]=y.extend({},a[b])},getType:function(a,b){return"connection"===b?this._connectionTypes[a]:this._endpointTypes[a]},setIdChanged:function(a,b){this.setId(a,b,!0)},setParent:function(a,b){var c=y.CurrentLibrary,d=c.getElementObject(a),e=c.getDOMElement(d),f=this.getId(e),g=c.getElementObject(b),h=c.getDOMElement(g),i=this.getId(h);e.parentNode.removeChild(e),h.appendChild(e),this.dragManager.setParent(d,f,g,i)}});var y=new x;"undefined"!=typeof window&&(window.jsPlumb=y),y.getInstance=function(a){var b=new x(a);return b.init(),b},"function"==typeof define&&(define("jsplumb",[],function(){return y}),define("jsplumbinstance",[],function(){return y.getInstance()})),"undefined"!=typeof exports&&(exports.jsPlumb=y)}(),function(){var a=function(a,b){var c=!1;return{drag:function(){if(c)return c=!1,!0;var d=jsPlumb.CurrentLibrary.getUIPosition(arguments,b.getZoom());a.element&&(jsPlumb.CurrentLibrary.setOffset(a.element,d),b.repaint(a.element,d))},stopDrag:function(){c=!0}}},b=function(a,b,c){var d=document.createElement("div");d.style.position="absolute",jsPlumb.CurrentLibrary.getElementObject(d),jsPlumb.CurrentLibrary.appendElement(d,b);var e=c.getId(d);c.updateOffset({elId:e}),a.id=e,a.element=d},c=function(a,b,c,d,e,f,g){var h=new jsPlumb.FloatingAnchor({reference:b,referenceCanvas:d,jsPlumbInstance:f});return g({paintStyle:a,endpoint:c,anchor:h,source:e,scope:"__floating"})},d=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],e=function(a,b){var c=0;if(null!=b)for(var d=0;d<a.connections.length;d++)if(a.connections[d].sourceId==b||a.connections[d].targetId==b){c=d;break}return a.connections[c]},f=function(a,b){return jsPlumbUtil.findWithFunction(b.connections,function(b){return b.id==a.id})};jsPlumb.Endpoint=function(g){var h=g._jsPlumb,i=jsPlumb.CurrentLibrary,j=(jsPlumbAdapter.getAttribute,i.getElementObject),k=i.getDOMElement,l=jsPlumbUtil,m=g.newConnection,n=g.newEndpoint,o=g.finaliseConnection,p=(g.fireDetachEvent,g.fireMoveEvent),q=g.floatingConnections;this.idPrefix="_jsplumb_e_",this.defaultLabelLocation=[.5,.5],this.defaultOverlayKeys=["Overlays","EndpointOverlays"],this.parent=g.parent,OverlayCapableJsPlumbUIComponent.apply(this,arguments),this.getDefaultType=function(){return{parameters:{},scope:null,maxConnections:this._jsPlumb.instance.Defaults.MaxConnections,paintStyle:this._jsPlumb.instance.Defaults.EndpointStyle||jsPlumb.Defaults.EndpointStyle,endpoint:this._jsPlumb.instance.Defaults.Endpoint||jsPlumb.Defaults.Endpoint,hoverPaintStyle:this._jsPlumb.instance.Defaults.EndpointHoverStyle||jsPlumb.Defaults.EndpointHoverStyle,overlays:this._jsPlumb.instance.Defaults.EndpointOverlays||jsPlumb.Defaults.EndpointOverlays,connectorStyle:g.connectorStyle,connectorHoverStyle:g.connectorHoverStyle,connectorClass:g.connectorClass,connectorHoverClass:g.connectorHoverClass,connectorOverlays:g.connectorOverlays,connector:g.connector,connectorTooltip:g.connectorTooltip}},this._jsPlumb.enabled=!(g.enabled===!1),this._jsPlumb.visible=!0,this.element=k(g.source),this._jsPlumb.uuid=g.uuid,this._jsPlumb.floatingEndpoint=null;var r=null;this._jsPlumb.uuid&&(g.endpointsByUUID[this._jsPlumb.uuid]=this),this.elementId=g.elementId,this._jsPlumb.connectionCost=g.connectionCost,this._jsPlumb.connectionsDirected=g.connectionsDirected,this._jsPlumb.currentAnchorClass="",this._jsPlumb.events={};var s=function(){i.removeClass(this.element,h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),this.removeClass(h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),this._jsPlumb.currentAnchorClass=this.anchor.getCssClass(),this.addClass(h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),i.addClass(this.element,h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass)}.bind(this);this.setAnchor=function(a,b){return this._jsPlumb.instance.continuousAnchorFactory.clear(this.elementId),this.anchor=this._jsPlumb.instance.makeAnchor(a,this.elementId,h),s(),this.anchor.bind("anchorChanged",function(a){this.fire("anchorChanged",{endpoint:this,anchor:a}),s()}.bind(this)),b||this._jsPlumb.instance.repaint(this.elementId),this};var t=g.anchor?g.anchor:g.anchors?g.anchors:h.Defaults.Anchor||"Top";this.setAnchor(t,!0);var u=function(a){this.connections.length>0?this.connections[0].setHover(a,!1):this.setHover(a)}.bind(this);g._transient||this._jsPlumb.instance.anchorManager.add(this,this.elementId),this.setEndpoint=function(a){null!=this.endpoint&&(this.endpoint.cleanup(),this.endpoint.destroy());var b=function(a,b){var c=h.getRenderMode();if(jsPlumb.Endpoints[c][a])return new jsPlumb.Endpoints[c][a](b);if(!h.Defaults.DoNotThrowErrors)throw{msg:"jsPlumb: unknown endpoint type '"+a+"'"}},c={_jsPlumb:this._jsPlumb.instance,cssClass:g.cssClass,parent:g.parent,container:g.container,tooltip:g.tooltip,connectorTooltip:g.connectorTooltip,endpoint:this};l.isString(a)?this.endpoint=b(a,c):l.isArray(a)?(c=l.merge(a[1],c),this.endpoint=b(a[0],c)):this.endpoint=a.clone(),jsPlumb.extend({},c),this.endpoint.clone=function(){return l.isString(a)?b(a,c):l.isArray(a)?(c=l.merge(a[1],c),b(a[0],c)):void 0}.bind(this),this.type=this.endpoint.type,this.bindListeners(this.endpoint,this,u)},this.setEndpoint(g.endpoint||h.Defaults.Endpoint||jsPlumb.Defaults.Endpoint||"Dot"),this.setPaintStyle(g.paintStyle||g.style||h.Defaults.EndpointStyle||jsPlumb.Defaults.EndpointStyle,!0),this.setHoverPaintStyle(g.hoverPaintStyle||h.Defaults.EndpointHoverStyle||jsPlumb.Defaults.EndpointHoverStyle,!0),this._jsPlumb.paintStyleInUse=this.getPaintStyle(),l.copyValues(d,g,this),this.isSource=g.isSource||!1,this.isTarget=g.isTarget||!1,this._jsPlumb.maxConnections=g.maxConnections||h.Defaults.MaxConnections,this.canvas=this.endpoint.canvas,this.addClass(h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),i.addClass(this.element,h.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),this.connections=g.connections||[],this.connectorPointerEvents=g["connector-pointer-events"],this.scope=g.scope||h.getDefaultScope(),this.timestamp=null,this.reattachConnections=g.reattach||h.Defaults.ReattachConnections,this.connectionsDetachable=h.Defaults.ConnectionsDetachable,(g.connectionsDetachable===!1||g.detachable===!1)&&(this.connectionsDetachable=!1),this.dragAllowedWhenFull=g.dragAllowedWhenFull||!0,g.onMaxConnections&&this.bind("maxConnections",g.onMaxConnections),this.addConnection=function(a){this.connections.push(a),this[(this.connections.length>0?"add":"remove")+"Class"](h.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](h.endpointFullClass)},this.detachFromConnection=function(a,b){b=null==b?f(a,this):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](h.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](h.endpointFullClass))},this.detach=function(a,b,c,d,e,g,i){var j=null==i?f(a,this):i,k=!1;return d=d!==!1,j>=0&&(c||a._forceDetach||a.isDetachable()&&a.isDetachAllowed(a)&&this.isDetachAllowed(a))&&(h.deleteObject({connection:a,fireEvent:!b&&d,originalEvent:e}),k=!0),k},this.detachAll=function(a,b){for(;this.connections.length>0;)this.detach(this.connections[0],!1,!0,a!==!1,b,this,0);return this},this.detachFrom=function(a,b,c){for(var d=[],e=0;e<this.connections.length;e++)(this.connections[e].endpoints[1]==a||this.connections[e].endpoints[0]==a)&&d.push(this.connections[e]);for(var f=0;f<d.length;f++)this.detach(d[f],!1,!0,b,c);return this},this.getElement=function(){return this.element},this.setElement=function(a){var b=this._jsPlumb.instance.getId(a),c=this.elementId;return l.removeWithFunction(g.endpointsByElement[this.elementId],function(a){return a.id==this.id}.bind(this)),this.element=k(a),this.elementId=h.getId(this.element),h.anchorManager.rehomeEndpoint(this,c,this.element),h.dragManager.endpointAdded(this.element),l.addToList(g.endpointsByElement,b,this),this},this.makeInPlaceCopy=function(){var a=this.anchor.getCurrentLocation({element:this}),b=this.anchor.getOrientation(this),c=this.anchor.getCssClass(),d={bind:function(){},compute:function(){return[a[0],a[1]]},getCurrentLocation:function(){return[a[0],a[1]]},getOrientation:function(){return b},getCssClass:function(){return c}};return n({anchor:d,source:this.element,paintStyle:this.getPaintStyle(),endpoint:g.hideOnDrag?"Blank":this.endpoint,_transient:!0,scope:this.scope})},this.isFloating=function(){return null!=this.anchor&&this.anchor.isFloating
+},this.connectorSelector=function(){var a=this.connections[0];return this.isTarget&&a?a:this.connections.length<this._jsPlumb.maxConnections||-1==this._jsPlumb.maxConnections?null:a},this.setStyle=this.setPaintStyle,this.paint=function(a){a=a||{};var b=a.timestamp,c=!(a.recalc===!1);if(!b||this.timestamp!==b){var d=h.updateOffset({elId:this.elementId,timestamp:b}),f=a.offset?a.offset.o:d.o;if(null!=f){var g=a.anchorPoint,i=a.connectorPaintStyle;if(null==g){var j=a.dimensions||d.s,k={xy:[f.left,f.top],wh:j,element:this,timestamp:b};if(c&&this.anchor.isDynamic&&this.connections.length>0){var l=e(this,a.elementWithPrecedence),m=l.endpoints[0]==this?1:0,n=0===m?l.sourceId:l.targetId,o=h.getCachedData(n),p=o.o,q=o.s;k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}g=this.anchor.compute(k)}this.endpoint.compute(g,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,i||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r=0;r<this._jsPlumb.overlays.length;r++){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.repaint=this.paint;var v=!1;this.initDraggable=function(){if(!v&&i.isDragSupported(this.element)){var d={id:null,element:null},e=null,f=!1,k=null,o=a(d,h),p=function(){e=this.connectorSelector();var a=!0;if(this.isEnabled()||(a=!1),null!=e||this.isSource||(a=!1),this.isSource&&this.isFull()&&!this.dragAllowedWhenFull&&(a=!1),null==e||e.isDetachable()||(a=!1),a===!1)return i.stopDrag&&i.stopDrag(),o.stopDrag(),!1;for(var p=0;p<this.connections.length;p++)this.connections[p].setHover(!1);this.addClass("endpointDrag"),h.setConnectionBeingDragged(!0),e&&!this.isFull()&&this.isSource&&(e=null),h.updateOffset({elId:this.elementId}),r=this.makeInPlaceCopy(),r.referenceEndpoint=this,r.paint(),b(d,this.parent,h);var s=j(r.canvas),t=jsPlumb.CurrentLibrary.getOffset(s,h),u=h.adjustForParentOffsetAndScroll([t.left,t.top],r.canvas),v=j(this.canvas);if(i.setOffset(d.element,{left:u[0],top:u[1]}),this.parentAnchor&&(this.anchor=h.makeAnchor(this.parentAnchor,this.elementId,h)),h.setAttribute(this.canvas,"dragId",d.id),h.setAttribute(this.canvas,"elId",this.elementId),this._jsPlumb.floatingEndpoint=c(this.getPaintStyle(),this.anchor,this.endpoint,this.canvas,d.element,h,n),this.canvas.style.visibility="hidden",null==e)this.anchor.locked=!0,this.setHover(!1,!1),e=m({sourceEndpoint:this,targetEndpoint:this._jsPlumb.floatingEndpoint,source:this.endpointWillMoveTo||this.element,target:d.element,anchors:[this.anchor,this._jsPlumb.floatingEndpoint.anchor],paintStyle:g.connectorStyle,hoverPaintStyle:g.connectorHoverStyle,connector:g.connector,overlays:g.connectorOverlays,type:this.connectionType,cssClass:this.connectorClass,hoverClass:this.connectorHoverClass}),e.pending=!0,e.addClass(h.draggingClass),this._jsPlumb.floatingEndpoint.addClass(h.draggingClass),h.fire("connectionDrag",e);else{f=!0,e.setHover(!1),w(s,!1,!0);var x=e.endpoints[0].id==this.id?0:1;e.floatingAnchorIndex=x,this.detachFromConnection(e);var y=jsPlumb.CurrentLibrary.getDragScope(v);h.setAttribute(this.canvas,"originalScope",y);var z=i.getDropScope(v);i.setDragScope(v,z),h.fire("connectionDrag",e),0===x?(k=[e.source,e.sourceId,v,y],e.source=d.element,e.sourceId=d.id):(k=[e.target,e.targetId,v,y],e.target=d.element,e.targetId=d.id),e.endpoints[0===x?1:0].anchor.locked=!0,e.suspendedEndpoint=e.endpoints[x],e.suspendedElement=e.endpoints[x].getElement(),e.suspendedElementId=e.endpoints[x].elementId,e.suspendedElementType=0===x?"source":"target",e.suspendedEndpoint.setHover(!1),this._jsPlumb.floatingEndpoint.referenceEndpoint=e.suspendedEndpoint,e.endpoints[x]=this._jsPlumb.floatingEndpoint,e.addClass(h.draggingClass),this._jsPlumb.floatingEndpoint.addClass(h.draggingClass)}q[d.id]=e,h.anchorManager.addFloatingConnection(d.id,e),l.addToList(g.endpointsByElement,d.id,this._jsPlumb.floatingEndpoint),h.currentlyDragging=!0}.bind(this),s=g.dragOptions||{},t=jsPlumb.extend({},i.defaultDragOptions),u=i.dragEvents.start,x=i.dragEvents.stop,y=i.dragEvents.drag;s=jsPlumb.extend(t,s),s.scope=s.scope||this.scope,s[u]=l.wrap(s[u],p,!1),s[y]=l.wrap(s[y],o.drag),s[x]=l.wrap(s[x],function(){if(h.setConnectionBeingDragged(!1),null!=e.endpoints){var a=i.getDropEvent(arguments),b=null==e.floatingAnchorIndex?1:e.floatingAnchorIndex;e.endpoints[0===b?1:0].anchor.locked=!1,e.removeClass(h.draggingClass),e.endpoints[b]==this._jsPlumb.floatingEndpoint&&f&&e.suspendedEndpoint&&(0===b?(e.source=k[0],e.sourceId=k[1]):(e.target=k[0],e.targetId=k[1]),i.setDragScope(k[2],k[3]),e.endpoints[b]=e.suspendedEndpoint,(e.isReattach()||e._forceReattach||e._forceDetach||!e.endpoints[0===b?1:0].detach(e,!1,!1,!0,a))&&(e.setHover(!1),e.floatingAnchorIndex=null,e._forceDetach=null,e._forceReattach=null,this._jsPlumb.floatingEndpoint.detachFromConnection(e),e.suspendedEndpoint.addConnection(e),h.repaint(k[1])))}h.remove(d.element,!1),h.remove(r.canvas,!1),this.deleteAfterDragStop?h.deleteObject({endpoint:this}):this._jsPlumb&&(this._jsPlumb.floatingEndpoint=null,this.canvas.style.visibility="visible",this.anchor.locked=!1,this.paint({recalc:!1})),h.fire("connectionDragStop",e),h.currentlyDragging=!1,e=null}.bind(this));var z=j(this.canvas);i.initDraggable(z,s,!0,h),v=!0}},(this.isSource||this.isTarget)&&this.initDraggable();var w=function(a,b,c,d){if((this.isTarget||b)&&i.isDropSupported(this.element)){var e=g.dropOptions||h.Defaults.DropOptions||jsPlumb.Defaults.DropOptions;e=jsPlumb.extend({},e),e.scope=e.scope||this.scope;var f=i.dragEvents.drop,k=i.dragEvents.over,m=i.dragEvents.out,n=function(){this.removeClass(h.endpointDropAllowedClass),this.removeClass(h.endpointDropForbiddenClass);var a=i.getDropEvent(arguments),b=j(i.getDragObject(arguments)),c=h.getAttribute(b,"dragId"),e=(h.getAttribute(b,"elId"),h.getAttribute(b,"originalScope")),f=q[c],g=f.suspendedEndpoint&&(f.suspendedEndpoint.id==this.id||this.referenceEndpoint&&f.suspendedEndpoint.id==this.referenceEndpoint.id);if(g)return f._forceReattach=!0,void 0;if(null!=f){var k=null==f.floatingAnchorIndex?1:f.floatingAnchorIndex;e&&jsPlumb.CurrentLibrary.setDragScope(b,e);var l=null!=d?d.isEnabled():!0;if(this.isFull()&&this.fire("maxConnections",{endpoint:this,connection:f,maxConnections:this._jsPlumb.maxConnections},a),!this.isFull()&&(0!==k||this.isSource)&&(1!=k||this.isTarget)&&l){var m=!0;f.suspendedEndpoint&&f.suspendedEndpoint.id!=this.id&&(0===k?(f.source=f.suspendedEndpoint.element,f.sourceId=f.suspendedEndpoint.elementId):(f.target=f.suspendedEndpoint.element,f.targetId=f.suspendedEndpoint.elementId),f.isDetachAllowed(f)&&f.endpoints[k].isDetachAllowed(f)&&f.suspendedEndpoint.isDetachAllowed(f)&&h.checkCondition("beforeDetach",f)||(m=!1)),0===k?(f.source=this.element,f.sourceId=this.elementId):(f.target=this.element,f.targetId=this.elementId);var n=function(){f.floatingAnchorIndex=null},r=function(){f.pending=!1,f.endpoints[k].detachFromConnection(f),f.suspendedEndpoint&&f.suspendedEndpoint.detachFromConnection(f),f.endpoints[k]=this,this.addConnection(f);var b=this.getParameters();for(var c in b)f.setParameter(c,b[c]);if(f.suspendedEndpoint){var d=(f.suspendedEndpoint.getElement(),f.suspendedEndpoint.elementId);p({index:k,originalSourceId:0===k?d:f.sourceId,newSourceId:0===k?this.elementId:f.sourceId,originalTargetId:1==k?d:f.targetId,newTargetId:1==k?this.elementId:f.targetId,originalSourceEndpoint:0===k?f.suspendedEndpoint:f.endpoints[0],newSourceEndpoint:0===k?this:f.endpoints[0],originalTargetEndpoint:1==k?f.suspendedEndpoint:f.endpoints[1],newTargetEndpoint:1==k?this:f.endpoints[1],connection:f},a)}else b.draggable&&jsPlumb.CurrentLibrary.initDraggable(this.element,dragOptions,!0,h);1==k?h.anchorManager.updateOtherEndpoint(f.sourceId,f.suspendedElementId,f.targetId,f):h.anchorManager.sourceChanged(f.suspendedEndpoint.elementId,f.sourceId,f),o(f,null,a),n()}.bind(this),s=function(){f.suspendedEndpoint&&(f.endpoints[k]=f.suspendedEndpoint,f.setHover(!1),f._forceDetach=!0,0===k?(f.source=f.suspendedEndpoint.element,f.sourceId=f.suspendedEndpoint.elementId):(f.target=f.suspendedEndpoint.element,f.targetId=f.suspendedEndpoint.elementId),f.suspendedEndpoint.addConnection(f),f.endpoints[0].repaint(),f.repaint(),h.repaint(f.sourceId),f._forceDetach=!1),n()};m=m&&this.isDropAllowed(f.sourceId,f.targetId,f.scope,f,this),m?r():s()}h.currentlyDragging=!1}}.bind(this);e[f]=l.wrap(e[f],n),e[k]=l.wrap(e[k],function(){var a=i.getDragObject(arguments),b=h.getAttribute(a,"dragId"),c=q[b];if(null!=c){var d=null==c.floatingAnchorIndex?1:c.floatingAnchorIndex,e=this.isTarget&&0!==c.floatingAnchorIndex||c.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==c.suspendedEndpoint.id;if(e){var f=h.checkCondition("checkDropAllowed",{sourceEndpoint:c.endpoints[d],targetEndpoint:this,connection:c});this[(f?"add":"remove")+"Class"](h.endpointDropAllowedClass),this[(f?"remove":"add")+"Class"](h.endpointDropForbiddenClass),c.endpoints[d].anchor.over(this.anchor,this)}}}.bind(this)),e[m]=l.wrap(e[m],function(){var a=i.getDragObject(arguments),b=h.getAttribute(a,"dragId"),c=q[b];if(null!=c){var d=null==c.floatingAnchorIndex?1:c.floatingAnchorIndex,e=this.isTarget&&0!==c.floatingAnchorIndex||c.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==c.suspendedEndpoint.id;e&&(this.removeClass(h.endpointDropAllowedClass),this.removeClass(h.endpointDropForbiddenClass),c.endpoints[d].anchor.out())}}.bind(this)),i.initDroppable(a,e,!0,c)}}.bind(this);return w(j(this.canvas),!0,!(g._transient||this.anchor.isFloating),this),g.type&&this.addType(g.type,g.data,h.isSuspendDrawing()),this},jsPlumbUtil.extend(jsPlumb.Endpoint,OverlayCapableJsPlumbUIComponent,{getTypeDescriptor:function(){return"endpoint"},isVisible:function(){return this._jsPlumb.visible},setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;d<this.connections.length;d++)if(this.connections[d].setVisible(a),!c){var e=this===this.connections[d].endpoints[0]?1:0;1==this.connections[d].endpoints[e].connections.length&&this.connections[d].endpoints[e].setVisible(a,!0,!0)}},getAttachedElements:function(){return this.connections},applyType:function(a){null!=a.maxConnections&&(this._jsPlumb.maxConnections=a.maxConnections),a.scope&&(this.scope=a.scope),jsPlumbUtil.copyValues(d,a,this),a.anchor&&(this.anchor=this._jsPlumb.instance.makeAnchor(a.anchor))},isEnabled:function(){return this._jsPlumb.enabled},setEnabled:function(a){this._jsPlumb.enabled=a},cleanup:function(){jsPlumb.CurrentLibrary.removeClass(this.element,this._jsPlumb.instance.endpointAnchorClassPrefix+"_"+this._jsPlumb.currentAnchorClass),this.anchor=null,this.endpoint.cleanup(),this.endpoint.destroy(),this.endpoint=null;var a=jsPlumb.CurrentLibrary.getElementObject(this.canvas);jsPlumb.CurrentLibrary.destroyDraggable(a),jsPlumb.CurrentLibrary.destroyDroppable(a)},setHover:function(a){this.endpoint&&this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged()&&this.endpoint.setHover(a)},isFull:function(){return!(this.isFloating()||this._jsPlumb.maxConnections<1||this.connections.length<this._jsPlumb.maxConnections)},getConnectionCost:function(){return this._jsPlumb.connectionCost},setConnectionCost:function(a){this._jsPlumb.connectionCost=a},areConnectionsDirected:function(){return this._jsPlumb.connectionsDirected},setConnectionsDirected:function(a){this._jsPlumb.connectionsDirected=a},setElementId:function(a){this.elementId=a,this.anchor.elementId=a},setReferenceElement:function(a){this.element=jsPlumb.CurrentLibrary.getDOMElement(a)},setDragAllowedWhenFull:function(a){this.dragAllowedWhenFull=a},equals:function(a){return this.anchor.equals(a.anchor)},getUuid:function(){return this._jsPlumb.uuid},computeAnchor:function(a){return this.anchor.compute(a)}})}(),function(){var a=function(a,b,c,d){if(!a.Defaults.DoNotThrowErrors&&null==jsPlumb.Connectors[b][c])throw{msg:"jsPlumb: unknown connector type '"+c+"'"};return new jsPlumb.Connectors[b][c](d)},b=function(a,b,c){return a?c.makeAnchor(a,b,c):null},c=function(a,c,d,e,f,g,h,i,j,k){var l;if(e)d.endpoints[f]=e,e.addConnection(d);else{g.endpoints||(g.endpoints=[null,null]);var m=g.endpoints[f]||g.endpoint||a.Defaults.Endpoints[f]||jsPlumb.Defaults.Endpoints[f]||a.Defaults.Endpoint||jsPlumb.Defaults.Endpoint;g.endpointStyles||(g.endpointStyles=[null,null]),g.endpointHoverStyles||(g.endpointHoverStyles=[null,null]);var n=g.endpointStyles[f]||g.endpointStyle||a.Defaults.EndpointStyles[f]||jsPlumb.Defaults.EndpointStyles[f]||a.Defaults.EndpointStyle||jsPlumb.Defaults.EndpointStyle;null==n.fillStyle&&null!=j&&(n.fillStyle=j.strokeStyle),null==n.outlineColor&&null!=j&&(n.outlineColor=j.outlineColor),null==n.outlineWidth&&null!=j&&(n.outlineWidth=j.outlineWidth);var o=g.endpointHoverStyles[f]||g.endpointHoverStyle||a.Defaults.EndpointHoverStyles[f]||jsPlumb.Defaults.EndpointHoverStyles[f]||a.Defaults.EndpointHoverStyle||jsPlumb.Defaults.EndpointHoverStyle;null!=k&&(null==o&&(o={}),null==o.fillStyle&&(o.fillStyle=k.strokeStyle));var p=g.anchors?g.anchors[f]:g.anchor?g.anchor:b(a.Defaults.Anchors[f],i,a)||b(jsPlumb.Defaults.Anchors[f],i,a)||b(a.Defaults.Anchor,i,a)||b(jsPlumb.Defaults.Anchor,i,a),q=g.uuids?g.uuids[f]:null;l=c({paintStyle:n,hoverPaintStyle:o,endpoint:m,connections:[d],uuid:q,anchor:p,source:h,scope:g.scope,container:g.container,reattach:g.reattach||a.Defaults.ReattachConnections,detachable:g.detachable||a.Defaults.ConnectionsDetachable}),d.endpoints[f]=l,g.drawEndpoints===!1&&l.setVisible(!1,!0,!0)}return l};jsPlumb.Connection=function(a){var b=(a.newConnection,a.newEndpoint),d=jsPlumb.CurrentLibrary,e=(d.getAttribute,d.getElementObject,d.getDOMElement),f=jsPlumbUtil;d.getOffset,this.connector=null,this.idPrefix="_jsplumb_c_",this.defaultLabelLocation=.5,this.defaultOverlayKeys=["Overlays","ConnectionOverlays"],this.parent=a.parent,this.previousConnection=a.previousConnection,this.source=e(a.source),this.target=e(a.target),a.sourceEndpoint&&(this.source=a.sourceEndpoint.endpointWillMoveTo||a.sourceEndpoint.getElement()),a.targetEndpoint&&(this.target=a.targetEndpoint.getElement()),OverlayCapableJsPlumbUIComponent.apply(this,arguments),this.sourceId=this._jsPlumb.instance.getId(this.source),this.targetId=this._jsPlumb.instance.getId(this.target),this.scope=a.scope,this.endpoints=[],this.endpointStyles=[];var g=this._jsPlumb.instance;this._jsPlumb.visible=!0,this._jsPlumb.editable=a.editable===!0,this._jsPlumb.params={parent:a.parent,cssClass:a.cssClass,container:a.container,"pointer-events":a["pointer-events"],editorParams:a.editorParams},this._jsPlumb.lastPaintedAt=null,this.getDefaultType=function(){return{parameters:{},scope:null,detachable:this._jsPlumb.instance.Defaults.ConnectionsDetachable,rettach:this._jsPlumb.instance.Defaults.ReattachConnections,paintStyle:this._jsPlumb.instance.Defaults.PaintStyle||jsPlumb.Defaults.PaintStyle,connector:this._jsPlumb.instance.Defaults.Connector||jsPlumb.Defaults.Connector,hoverPaintStyle:this._jsPlumb.instance.Defaults.HoverPaintStyle||jsPlumb.Defaults.HoverPaintStyle,overlays:this._jsPlumb.instance.Defaults.ConnectorOverlays||jsPlumb.Defaults.ConnectorOverlays}};var h=c(g,b,this,a.sourceEndpoint,0,a,this.source,this.sourceId,a.paintStyle,a.hoverPaintStyle);h&&f.addToList(a.endpointsByElement,this.sourceId,h);var i=c(g,b,this,a.targetEndpoint,1,a,this.target,this.targetId,a.paintStyle,a.hoverPaintStyle);i&&f.addToList(a.endpointsByElement,this.targetId,i),this.scope||(this.scope=this.endpoints[0].scope),null!=a.deleteEndpointsOnDetach?(this.endpoints[0]._deleteOnDetach=a.deleteEndpointsOnDetach,this.endpoints[1]._deleteOnDetach=a.deleteEndpointsOnDetach):(this.endpoints[0]._doNotDeleteOnDetach||(this.endpoints[0]._deleteOnDetach=!0),this.endpoints[1]._doNotDeleteOnDetach||(this.endpoints[1]._deleteOnDetach=!0)),this.setConnector(this.endpoints[0].connector||this.endpoints[1].connector||a.connector||g.Defaults.Connector||jsPlumb.Defaults.Connector,!0),a.path&&this.connector.setPath(a.path),this.setPaintStyle(this.endpoints[0].connectorStyle||this.endpoints[1].connectorStyle||a.paintStyle||g.Defaults.PaintStyle||jsPlumb.Defaults.PaintStyle,!0),this.setHoverPaintStyle(this.endpoints[0].connectorHoverStyle||this.endpoints[1].connectorHoverStyle||a.hoverPaintStyle||g.Defaults.HoverPaintStyle||jsPlumb.Defaults.HoverPaintStyle,!0),this._jsPlumb.paintStyleInUse=this.getPaintStyle();var j=g.getSuspendedAt();if(g.updateOffset({elId:this.sourceId,timestamp:j}),g.updateOffset({elId:this.targetId,timestamp:j}),!g.isSuspendDrawing()){var k=g.getCachedData(this.sourceId),l=k.o,m=k.s,n=g.getCachedData(this.targetId),o=n.o,p=n.s,q=j||g.timestamp(),r=this.endpoints[0].anchor.compute({xy:[l.left,l.top],wh:m,element:this.endpoints[0],elementId:this.endpoints[0].elementId,txy:[o.left,o.top],twh:p,tElement:this.endpoints[1],timestamp:q});this.endpoints[0].paint({anchorLoc:r,timestamp:q}),r=this.endpoints[1].anchor.compute({xy:[o.left,o.top],wh:p,element:this.endpoints[1],elementId:this.endpoints[1].elementId,txy:[l.left,l.top],twh:m,tElement:this.endpoints[0],timestamp:q}),this.endpoints[1].paint({anchorLoc:r,timestamp:q})}this._jsPlumb.detachable=g.Defaults.ConnectionsDetachable,a.detachable===!1&&(this._jsPlumb.detachable=!1),this.endpoints[0].connectionsDetachable===!1&&(this._jsPlumb.detachable=!1),this.endpoints[1].connectionsDetachable===!1&&(this._jsPlumb.detachable=!1),this._jsPlumb.reattach=a.reattach||this.endpoints[0].reattachConnections||this.endpoints[1].reattachConnections||g.Defaults.ReattachConnections,this._jsPlumb.cost=a.cost||this.endpoints[0].getConnectionCost(),this._jsPlumb.directed=a.directed,null==a.directed&&(this._jsPlumb.directed=this.endpoints[0].areConnectionsDirected());var s=jsPlumb.extend({},this.endpoints[1].getParameters());jsPlumb.extend(s,this.endpoints[0].getParameters()),jsPlumb.extend(s,this.getParameters()),this.setParameters(s);var t=a.type||this.endpoints[0].connectionType||this.endpoints[1].connectionType;t&&this.addType(t,a.data,!0)},jsPlumbUtil.extend(jsPlumb.Connection,OverlayCapableJsPlumbUIComponent,{applyType:function(a,b){null!=a.detachable&&this.setDetachable(a.detachable),null!=a.reattach&&this.setReattach(a.reattach),a.scope&&(this.scope=a.scope),this.setConnector(a.connector,b)},getTypeDescriptor:function(){return"connection"},getAttachedElements:function(){return this.endpoints},addClass:function(a,b){b&&(this.endpoints[0].addClass(a),this.endpoints[1].addClass(a),this.suspendedEndpoint&&this.suspendedEndpoint.addClass(a)),this.connector&&this.connector.addClass(a)},removeClass:function(a,b){b&&(this.endpoints[0].removeClass(a),this.endpoints[1].removeClass(a),this.suspendedEndpoint&&this.suspendedEndpoint.removeClass(a)),this.connector&&this.connector.removeClass(a)},isVisible:function(){return this._jsPlumb.visible},setVisible:function(a){this._jsPlumb.visible=a,this.connector&&this.connector.setVisible(a),this.repaint()},setEditable:function(a){return this.connector&&this.connector.isEditable()&&(this._jsPlumb.editable=a),this._jsPlumb.editable},isEditable:function(){return this._jsPlumb.editable},editStarted:function(){this.setSuspendEvents(!0),this.fire("editStarted",{path:this.connector.getPath()}),this._jsPlumb.instance.setHoverSuspended(!0)},editCompleted:function(){this.fire("editCompleted",{path:this.connector.getPath()}),this.setSuspendEvents(!1),this.setHover(!1),this._jsPlumb.instance.setHoverSuspended(!1)},editCanceled:function(){this.fire("editCanceled",{path:this.connector.getPath()}),this.setHover(!1),this._jsPlumb.instance.setHoverSuspended(!1)},cleanup:function(){this.endpoints=null,this.source=null,this.target=null,null!=this.connector&&(this.connector.cleanup(),this.connector.destroy()),this.connector=null},isDetachable:function(){return this._jsPlumb.detachable===!0},setDetachable:function(a){this._jsPlumb.detachable=a===!0},isReattach:function(){return this._jsPlumb.reattach===!0},setReattach:function(a){this._jsPlumb.reattach=a===!0},setHover:function(a){this.connector&&this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged()&&(this.connector.setHover(a),jsPlumb.CurrentLibrary[a?"addClass":"removeClass"](this.source,this._jsPlumb.instance.hoverSourceClass),jsPlumb.CurrentLibrary[a?"addClass":"removeClass"](this.target,this._jsPlumb.instance.hoverTargetClass))},getCost:function(){return this._jsPlumb.cost},setCost:function(a){this._jsPlumb.cost=a},isDirected:function(){return this._jsPlumb.directed===!0},moveParent:function(a){var b=jsPlumb.CurrentLibrary;b.getParent(this.connector.canvas),this.connector.bgCanvas&&(b.removeElement(this.connector.bgCanvas),b.appendElement(this.connector.bgCanvas,a)),b.removeElement(this.connector.canvas),b.appendElement(this.connector.canvas,a);for(var c=0;c<this._jsPlumb.overlays.length;c++)this._jsPlumb.overlays[c].isAppendedAtTopLevel&&(b.removeElement(this._jsPlumb.overlays[c].canvas),b.appendElement(this._jsPlumb.overlays[c].canvas,a),this._jsPlumb.overlays[c].reattachListeners&&this._jsPlumb.overlays[c].reattachListeners(this.connector));this.connector.reattachListeners&&this.connector.reattachListeners()},getConnector:function(){return this.connector},setConnector:function(b,c){var d=jsPlumbUtil;null!=this.connector&&(this.connector.cleanup(),this.connector.destroy());var e={_jsPlumb:this._jsPlumb.instance,parent:this._jsPlumb.params.parent,cssClass:this._jsPlumb.params.cssClass,container:this._jsPlumb.params.container,"pointer-events":this._jsPlumb.params["pointer-events"]},f=this._jsPlumb.instance.getRenderMode();d.isString(b)?this.connector=a(this._jsPlumb.instance,f,b,e):d.isArray(b)&&(this.connector=1==b.length?a(this._jsPlumb.instance,f,b[0],e):a(this._jsPlumb.instance,f,b[0],d.merge(b[1],e))),this.bindListeners(this.connector,this,function(a){this.setHover(a,!1)}.bind(this)),this.canvas=this.connector.canvas,this._jsPlumb.editable&&null!=jsPlumb.ConnectorEditors&&jsPlumb.ConnectorEditors[this.connector.type]&&this.connector.isEditable()?new jsPlumb.ConnectorEditors[this.connector.type]({connector:this.connector,connection:this,params:this._jsPlumb.params.editorParams||{}}):this._jsPlumb.editable=!1,c||this.repaint()},paint:function(a){if(!this._jsPlumb.instance.isSuspendDrawing()&&this._jsPlumb.visible){a=a||{};var b=(a.elId,a.ui),c=a.recalc,d=a.timestamp,e=!1,f=e?this.sourceId:this.targetId,g=e?this.targetId:this.sourceId,h=e?0:1,i=e?1:0;if(null==d||d!=this._jsPlumb.lastPaintedAt){var j=this._jsPlumb.instance.updateOffset({elId:g,offset:b,recalc:c,timestamp:d}).o,k=this._jsPlumb.instance.updateOffset({elId:f,timestamp:d}).o,l=this.endpoints[i],m=this.endpoints[h];a.clearEdits&&(l.anchor.clearUserDefinedLocation(),m.anchor.clearUserDefinedLocation(),this.connector.setEdited(!1));var n=l.anchor.getCurrentLocation({xy:[j.left,j.top],wh:[j.width,j.height],element:l,timestamp:d}),o=m.anchor.getCurrentLocation({xy:[k.left,k.top],wh:[k.width,k.height],element:m,timestamp:d});this.connector.resetBounds(),this.connector.compute({sourcePos:n,targetPos:o,sourceEndpoint:this.endpoints[i],targetEndpoint:this.endpoints[h],lineWidth:this._jsPlumb.paintStyleInUse.lineWidth,sourceInfo:j,targetInfo:k,clearEdits:a.clearEdits===!0});for(var p={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},q=0;q<this._jsPlumb.overlays.length;q++){var r=this._jsPlumb.overlays[q];r.isVisible()&&(this._jsPlumb.overlayPlacements[q]=r.draw(this.connector,this._jsPlumb.paintStyleInUse),p.minX=Math.min(p.minX,this._jsPlumb.overlayPlacements[q].minX),p.maxX=Math.max(p.maxX,this._jsPlumb.overlayPlacements[q].maxX),p.minY=Math.min(p.minY,this._jsPlumb.overlayPlacements[q].minY),p.maxY=Math.max(p.maxY,this._jsPlumb.overlayPlacements[q].maxY))}var s=parseFloat(this._jsPlumb.paintStyleInUse.lineWidth||1)/2,t=parseFloat(this._jsPlumb.paintStyleInUse.lineWidth||0),u={xmin:Math.min(this.connector.bounds.minX-(s+t),p.minX),ymin:Math.min(this.connector.bounds.minY-(s+t),p.minY),xmax:Math.max(this.connector.bounds.maxX+(s+t),p.maxX),ymax:Math.max(this.connector.bounds.maxY+(s+t),p.maxY)};this.connector.paint(this._jsPlumb.paintStyleInUse,null,u);for(var v=0;v<this._jsPlumb.overlays.length;v++){var w=this._jsPlumb.overlays[v];w.isVisible()&&w.paint(this._jsPlumb.overlayPlacements[v],u)}}this._jsPlumb.lastPaintedAt=d}},repaint:function(a){a=a||{},this.paint({elId:this.sourceId,recalc:!(a.recalc===!1),timestamp:a.timestamp,clearEdits:a.clearEdits})}})}(),function(){jsPlumb.AnchorManager=function(a){var b={},c={},d={},e={},f={},g={HORIZONTAL:"horizontal",VERTICAL:"vertical",DIAGONAL:"diagonal",IDENTITY:"identity"},h={},i=this,j={},k=a.jsPlumbInstance,l=jsPlumb.CurrentLibrary,m={},n=function(a,b,c,d,e,f){if(a===b)return{orientation:g.IDENTITY,a:["top","top"]};var h=Math.atan2(d.centery-c.centery,d.centerx-c.centerx),i=Math.atan2(c.centery-d.centery,c.centerx-d.centerx),j=c.left<=d.left&&c.right>=d.left||c.left<=d.right&&c.right>=d.right||c.left<=d.left&&c.right>=d.right||d.left<=c.left&&d.right>=c.right,k=c.top<=d.top&&c.bottom>=d.top||c.top<=d.bottom&&c.bottom>=d.bottom||c.top<=d.top&&c.bottom>=d.bottom||d.top<=c.top&&d.bottom>=c.bottom,l=function(a){return[e.isContinuous?e.verifyEdge(a[0]):a[0],f.isContinuous?f.verifyEdge(a[1]):a[1]]},m={orientation:g.DIAGONAL,theta:h,theta2:i};return j||k?j?(m.orientation=g.HORIZONTAL,m.a=c.top<d.top?["bottom","top"]:["top","bottom"]):(m.orientation=g.VERTICAL,m.a=c.left<d.left?["right","left"]:["left","right"]):d.left>c.left&&d.top>c.top?m.a=["right","top"]:d.left>c.left&&c.top>d.top?m.a=["top","left"]:d.left<c.left&&d.top<c.top?m.a=["top","right"]:d.left<c.left&&d.top>c.top&&(m.a=["left","top"]),m.a=l(m.a),m},o=function(a,b,c,d,e,f,g){for(var h=[],i=b[e?0:1]/(d.length+1),j=0;j<d.length;j++){var k=(j+1)*i,l=f*b[e?1:0];g&&(k=b[e?0:1]-k);var m=e?k:l,n=c[0]+m,o=m/b[0],p=e?l:k,q=c[1]+p,r=p/b[1];h.push([n,q,o,r,d[j][1],d[j][2]])}return h},p=function(a){return function(b,c){var d=!0;return d=a?b[0][0]<c[0][0]:b[0][0]>c[0][0],d===!1?-1:1}},q=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:a[0][1]>b[0][1]?1:-1},r={top:function(a,b){return a[0]>b[0]?1:-1},right:p(!0),bottom:p(!0),left:q},s=function(a,b){return a.sort(b)},t=function(a,b){var c=k.getCachedData(a),e=c.s,g=c.o,h=function(b,c,e,g,h,i,j){if(g.length>0)for(var l=s(g,r[b]),m="right"===b||"top"===b,n=o(b,c,e,l,h,i,m),p=function(a,b){var c=k.adjustForParentOffsetAndScroll([b[0],b[1]],a.canvas);d[a.id]=[c[0],c[1],b[2],b[3]],f[a.id]=j},q=0;q<n.length;q++){var t=n[q][4],u=t.endpoints[0].elementId===a,v=t.endpoints[1].elementId===a;u?p(t.endpoints[0],n[q]):v&&p(t.endpoints[1],n[q])}};h("bottom",e,[g.left,g.top],b.bottom,!0,1,[0,1]),h("top",e,[g.left,g.top],b.top,!0,0,[0,-1]),h("left",e,[g.left,g.top],b.left,!1,0,[-1,0]),h("right",e,[g.left,g.top],b.right,!1,1,[1,0])};this.reset=function(){b={},h={},j={}},this.addFloatingConnection=function(a,b){m[a]=b},this.removeFloatingConnection=function(a){delete m[a]},this.newConnection=function(a){var b=a.sourceId,c=a.targetId,d=a.endpoints,e=!0,f=function(a,f,g,i,j){b==c&&g.isContinuous&&(l.removeElement(d[1].canvas),e=!1),jsPlumbUtil.addToList(h,i,[j,f,g.constructor==jsPlumb.DynamicAnchor])};f(0,d[0],d[0].anchor,c,a),e&&f(1,d[1],d[1].anchor,b,a)};var u=function(a){!function(a,b){if(a){var c=function(a){return a[4]==b};jsPlumbUtil.removeWithFunction(a.top,c),jsPlumbUtil.removeWithFunction(a.left,c),jsPlumbUtil.removeWithFunction(a.bottom,c),jsPlumbUtil.removeWithFunction(a.right,c)}}(j[a.elementId],a.id)};this.connectionDetached=function(a){var b=a.connection||a,c=a.sourceId,d=a.targetId,e=b.endpoints,f=function(a,b,c,d,e){null!=c&&c.constructor==jsPlumb.FloatingAnchor||jsPlumbUtil.removeWithFunction(h[d],function(a){return a[0].id==e.id})};f(1,e[1],e[1].anchor,c,b),f(0,e[0],e[0].anchor,d,b),u(b.endpoints[0]),u(b.endpoints[1]),i.redraw(b.sourceId),i.redraw(b.targetId)},this.add=function(a,c){jsPlumbUtil.addToList(b,c,a)},this.changeId=function(a,c){h[c]=h[a],b[c]=b[a],delete h[a],delete b[a]},this.getConnectionsFor=function(a){return h[a]||[]},this.getEndpointsFor=function(a){return b[a]||[]},this.deleteEndpoint=function(a){jsPlumbUtil.removeWithFunction(b[a.elementId],function(b){return b.id==a.id}),u(a)},this.clearFor=function(a){delete b[a],b[a]=[]};var v=function(b,c,d,e,f,g,h,i,j,k,l,m){var n=-1,o=-1,p=e.endpoints[h],q=p.id,r=[1,0][h],s=[[c,d],e,f,g,q],t=b[j],u=p._continuousAnchorEdge?b[p._continuousAnchorEdge]:null;if(u){var v=jsPlumbUtil.findWithFunction(u,function(a){return a[4]==q});if(-1!=v){u.splice(v,1);for(var w=0;w<u.length;w++)jsPlumbUtil.addWithFunction(l,u[w][1],function(a){return a.id==u[w][1].id}),jsPlumbUtil.addWithFunction(m,u[w][1].endpoints[h],function(a){return a.id==u[w][1].endpoints[h].id}),jsPlumbUtil.addWithFunction(m,u[w][1].endpoints[r],function(a){return a.id==u[w][1].endpoints[r].id})}}for(w=0;w<t.length;w++)1==a.idx&&t[w][3]===g&&-1==o&&(o=w),jsPlumbUtil.addWithFunction(l,t[w][1],function(a){return a.id==t[w][1].id}),jsPlumbUtil.addWithFunction(m,t[w][1].endpoints[h],function(a){return a.id==t[w][1].endpoints[h].id}),jsPlumbUtil.addWithFunction(m,t[w][1].endpoints[r],function(a){return a.id==t[w][1].endpoints[r].id});if(-1!=n)t[n]=s;else{var x=i?-1!=o?o:0:t.length;t.splice(x,0,s)}p._continuousAnchorEdge=j};this.updateOtherEndpoint=function(a,b,c,d){var e=jsPlumbUtil.findWithFunction(h[a],function(a){return a[0].id===d.id}),f=jsPlumbUtil.findWithFunction(h[b],function(a){return a[0].id===d.id});-1!=e&&(h[a][e][0]=d,h[a][e][1]=d.endpoints[1],h[a][e][2]=d.endpoints[1].anchor.constructor==jsPlumb.DynamicAnchor),f>-1&&(h[b].splice(f,1),jsPlumbUtil.addToList(h,c,[d,d.endpoints[0],d.endpoints[0].anchor.constructor==jsPlumb.DynamicAnchor]))},this.sourceChanged=function(a,b,c){jsPlumbUtil.removeWithFunction(h[a],function(a){return a[0].id===c.id});var d=jsPlumbUtil.findWithFunction(h[c.targetId],function(a){return a[0].id===c.id});d>-1&&(h[c.targetId][d][0]=c,h[c.targetId][d][1]=c.endpoints[0],h[c.targetId][d][2]=c.endpoints[0].anchor.constructor==jsPlumb.DynamicAnchor),jsPlumbUtil.addToList(h,b,[c,c.endpoints[1],c.endpoints[1].anchor.constructor==jsPlumb.DynamicAnchor])},this.rehomeEndpoint=function(a,c,d){var e=b[c]||[],f=k.getId(d);if(f!==c){var g=jsPlumbUtil.indexOf(e,a);if(g>-1){var h=e.splice(g,1)[0];i.add(h,f)}}for(var j=0;j<a.connections.length;j++)a.connections[j].sourceId==c?(a.connections[j].sourceId=a.elementId,a.connections[j].source=a.element,i.sourceChanged(c,a.elementId,a.connections[j])):a.connections[j].targetId==c&&(a.connections[j].targetId=a.elementId,a.connections[j].target=a.element,i.updateOtherEndpoint(a.connections[j].sourceId,c,a.elementId,a.connections[j]))},this.redraw=function(a,c,d,e,f,g){if(!k.isSuspendDrawing()){var i=b[a]||[],l=h[a]||[],o=[],p=[],q=[];d=d||k.timestamp(),e=e||{left:0,top:0},c&&(c={left:c.left+e.left,top:c.top+e.top});for(var r=k.updateOffset({elId:a,offset:c,recalc:!1,timestamp:d}),s={},u=0;u<l.length;u++){var w=l[u][0],x=w.sourceId,y=w.targetId,z=w.endpoints[0].anchor.isContinuous,A=w.endpoints[1].anchor.isContinuous;if(z||A){var B=x+"_"+y,C=s[B],D=w.sourceId==a?1:0;z&&!j[x]&&(j[x]={top:[],right:[],bottom:[],left:[]}),A&&!j[y]&&(j[y]={top:[],right:[],bottom:[],left:[]}),a!=y&&k.updateOffset({elId:y,timestamp:d}),a!=x&&k.updateOffset({elId:x,timestamp:d});var E=k.getCachedData(y),F=k.getCachedData(x);y==x&&(z||A)?v(j[x],-Math.PI/2,0,w,!1,y,0,!1,"top",x,o,p):(C||(C=n(x,y,F.o,E.o,w.endpoints[0].anchor,w.endpoints[1].anchor),s[B]=C),z&&v(j[x],C.theta,0,w,!1,y,0,!1,C.a[0],x,o,p),A&&v(j[y],C.theta2,-1,w,!0,x,1,!0,C.a[1],y,o,p)),z&&jsPlumbUtil.addWithFunction(q,x,function(a){return a===x}),A&&jsPlumbUtil.addWithFunction(q,y,function(a){return a===y}),jsPlumbUtil.addWithFunction(o,w,function(a){return a.id==w.id}),(z&&0===D||A&&1===D)&&jsPlumbUtil.addWithFunction(p,w.endpoints[D],function(a){return a.id==w.endpoints[D].id
+})}}for(u=0;u<i.length;u++)0===i[u].connections.length&&i[u].anchor.isContinuous&&(j[a]||(j[a]={top:[],right:[],bottom:[],left:[]}),v(j[a],-Math.PI/2,0,{endpoints:[i[u],i[u]],paint:function(){}},!1,a,0,!1,"top",a,o,p),jsPlumbUtil.addWithFunction(q,a,function(b){return b===a}));for(u=0;u<q.length;u++)t(q[u],j[q[u]]);for(u=0;u<i.length;u++)i[u].paint({timestamp:d,offset:r,dimensions:r.s,recalc:g!==!0});for(u=0;u<p.length;u++){var G=k.getCachedData(p[u].elementId);p[u].paint({timestamp:d,offset:G,dimensions:G.s})}for(u=0;u<l.length;u++){var H=l[u][1];if(H.anchor.constructor==jsPlumb.DynamicAnchor){H.paint({elementWithPrecedence:a,timestamp:d}),jsPlumbUtil.addWithFunction(o,l[u][0],function(a){return a.id==l[u][0].id});for(var I=0;I<H.connections.length;I++)H.connections[I]!==l[u][0]&&jsPlumbUtil.addWithFunction(o,H.connections[I],function(a){return a.id==H.connections[I].id})}else H.anchor.constructor==jsPlumb.Anchor&&jsPlumbUtil.addWithFunction(o,l[u][0],function(a){return a.id==l[u][0].id})}var J=m[a];for(J&&J.paint({timestamp:d,recalc:!1,elId:a}),u=0;u<o.length;u++){var K=d;o[u].paint({elId:a,timestamp:K,recalc:!1,clearEdits:f})}}};var w=function(a){jsPlumbUtil.EventGenerator.apply(this),this.type="Continuous",this.isDynamic=!0,this.isContinuous=!0;for(var b=a.faces||["top","right","bottom","left"],c=!(a.clockwise===!1),g={},h={top:"bottom",right:"left",left:"right",bottom:"top"},i={top:"right",right:"bottom",left:"top",bottom:"left"},j={top:"left",right:"top",left:"bottom",bottom:"right"},k=c?i:j,l=c?j:i,m=a.cssClass||"",n=0;n<b.length;n++)g[b[n]]=!0;this.verifyEdge=function(a){return g[a]?a:g[h[a]]?h[a]:g[k[a]]?k[a]:g[l[a]]?l[a]:a},this.compute=function(a){return e[a.element.id]||d[a.element.id]||[0,0]},this.getCurrentLocation=function(a){return e[a.element.id]||d[a.element.id]||[0,0]},this.getOrientation=function(a){return f[a.id]||[0,0]},this.clearUserDefinedLocation=function(){delete e[a.elementId]},this.setUserDefinedLocation=function(b){e[a.elementId]=b},this.getCssClass=function(){return m},this.setCssClass=function(a){m=a}};k.continuousAnchorFactory={get:function(a){var b=c[a.elementId];return b||(b=new w(a),c[a.elementId]=b),b},clear:function(a){delete c[a]}}},jsPlumb.Anchor=function(a){this.x=a.x||0,this.y=a.y||0,this.elementId=a.elementId,this.cssClass=a.cssClass||"",this.userDefinedLocation=null,this.orientation=a.orientation||[0,0],jsPlumbUtil.EventGenerator.apply(this);var b=a.jsPlumbInstance;this.lastReturnValue=null,this.offsets=a.offsets||[0,0],this.timestamp=null,this.compute=function(a){var c=a.xy,d=a.wh,e=a.element,f=a.timestamp;return a.clearUserDefinedLocation&&(this.userDefinedLocation=null),f&&f===self.timestamp?this.lastReturnValue:(null!=this.userDefinedLocation?this.lastReturnValue=this.userDefinedLocation:(this.lastReturnValue=[c[0]+this.x*d[0]+this.offsets[0],c[1]+this.y*d[1]+this.offsets[1]],this.lastReturnValue=b.adjustForParentOffsetAndScroll(this.lastReturnValue,e.canvas)),this.timestamp=f,this.lastReturnValue)},this.getCurrentLocation=function(a){return null==this.lastReturnValue||null!=a.timestamp&&this.timestamp!=a.timestamp?this.compute(a):this.lastReturnValue}},jsPlumbUtil.extend(jsPlumb.Anchor,jsPlumbUtil.EventGenerator,{equals:function(a){if(!a)return!1;var b=a.getOrientation(),c=this.getOrientation();return this.x==a.x&&this.y==a.y&&this.offsets[0]==a.offsets[0]&&this.offsets[1]==a.offsets[1]&&c[0]==b[0]&&c[1]==b[1]},getUserDefinedLocation:function(){return this.userDefinedLocation},setUserDefinedLocation:function(a){this.userDefinedLocation=a},clearUserDefinedLocation:function(){this.userDefinedLocation=null},getOrientation:function(){return this.orientation},getCssClass:function(){return this.cssClass}}),jsPlumb.FloatingAnchor=function(a){jsPlumb.Anchor.apply(this,arguments);var b=a.reference,c=jsPlumb.CurrentLibrary,d=a.jsPlumbInstance,e=a.referenceCanvas,f=c.getSize(c.getElementObject(e)),g=0,h=0,i=null,j=null;this.orientation=null,this.x=0,this.y=0,this.isFloating=!0,this.compute=function(a){var b=a.xy,c=a.element,e=[b[0]+f[0]/2,b[1]+f[1]/2];return e=d.adjustForParentOffsetAndScroll(e,c.canvas),j=e,e},this.getOrientation=function(a){if(i)return i;var c=b.getOrientation(a);return[-1*Math.abs(c[0])*g,-1*Math.abs(c[1])*h]},this.over=function(a,b){i=a.getOrientation(b)},this.out=function(){i=null},this.getCurrentLocation=function(a){return null==j?this.compute(a):j}},jsPlumbUtil.extend(jsPlumb.FloatingAnchor,jsPlumb.Anchor);var a=function(a,b,c){return a.constructor==jsPlumb.Anchor?a:b.makeAnchor(a,c,b)};jsPlumb.DynamicAnchor=function(b){jsPlumb.Anchor.apply(this,arguments),this.isSelective=!0,this.isDynamic=!0,this.anchors=[],this.elementId=b.elementId,this.jsPlumbInstance=b.jsPlumbInstance;for(var c=0;c<b.anchors.length;c++)this.anchors[c]=a(b.anchors[c],this.jsPlumbInstance,this.elementId);this.addAnchor=function(b){this.anchors.push(a(b,this.jsPlumbInstance,this.elementId))},this.getAnchors=function(){return this.anchors},this.locked=!1;var d=this.anchors.length>0?this.anchors[0]:null,e=(this.anchors.length>0?0:-1,d),f=this,g=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},h=b.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,h=c[1]+d[1]/2,i=-1,j=1/0,k=0;k<e.length;k++){var l=g(e[k],f,h,a,b);j>l&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,g=a.timestamp,i=a.txy,j=a.twh;a.clearUserDefinedLocation&&(userDefinedLocation=null),this.timestamp=g;var k=f.getUserDefinedLocation();return null!=k?k:this.locked||null==i||null==j?d.compute(a):(a.timestamp=null,d=h(b,c,i,j,this.anchors),this.x=d.x,this.y=d.y,d!=e&&this.fire("anchorChanged",d),e=d,d.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=d?d.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=d?d.getOrientation(a):[0,0]},this.over=function(a,b){null!=d&&d.over(a,b)},this.out=function(){null!=d&&d.out()},this.getCssClass=function(){return d&&d.getCssClass()||""}},jsPlumbUtil.extend(jsPlumb.DynamicAnchor,jsPlumb.Anchor);var b=function(a,b,c,d,e,f){jsPlumb.Anchors[e]=function(g){var h=g.jsPlumbInstance.makeAnchor([a,b,c,d,0,0],g.elementId,g.jsPlumbInstance);return h.type=e,f&&f(h,g),h}};b(.5,0,0,-1,"TopCenter"),b(.5,1,0,1,"BottomCenter"),b(0,.5,-1,0,"LeftMiddle"),b(1,.5,1,0,"RightMiddle"),b(.5,0,0,-1,"Top"),b(.5,1,0,1,"Bottom"),b(0,.5,-1,0,"Left"),b(1,.5,1,0,"Right"),b(.5,.5,0,0,"Center"),b(1,0,0,-1,"TopRight"),b(1,1,0,1,"BottomRight"),b(0,0,0,-1,"TopLeft"),b(0,1,0,1,"BottomLeft"),jsPlumb.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},jsPlumb.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(jsPlumb.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var c=function(a,b){jsPlumb.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};jsPlumb.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},c("ContinuousLeft",["left"]),c("ContinuousTop",["top"]),c("ContinuousBottom",["bottom"]),c("ContinuousRight",["right"]),jsPlumb.Anchors.Assign=b(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor==String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),jsPlumb.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},jsPlumb.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f<a.length;f++)e.apply(null,a[f]);return d},f=function(a){for(var b=[],c=0;c<a.length;c++)b.push([a[c][0],a[c][1],a[c][2],a[c][3],1/a.length]);return e(b)},g=function(){return f([[0,0,1,0],[1,0,1,1],[1,1,0,1],[0,1,0,0]])},h={Circle:d,Ellipse:d,Diamond:function(){return f([[.5,0,1,.5],[1,.5,.5,1],[.5,1,0,.5],[0,.5,.5,0]])},Rectangle:g,Square:g,Triangle:function(){return f([[.5,0,1,1],[1,1,0,1],[0,1,.5,0]])},Path:function(a){for(var b=a.points,c=[],d=0,f=0;f<b.length-1;f++){var g=Math.sqrt(Math.pow(b[f][2]-b[f][0])+Math.pow(b[f][3]-b[f][1]));d+=g,c.push([b[f][0],b[f][1],b[f+1][0],b[f+1][1],g])}for(var h=0;h<c.length;h++)c[h][4]=c[h][4]/d;return e(c)}},i=function(a,b){for(var c=[],d=b/180*Math.PI,e=0;e<a.length;e++){var f=a[e][0]-.5,g=a[e][1]-.5;c.push([.5+(f*Math.cos(d)-g*Math.sin(d)),.5+(f*Math.sin(d)+g*Math.cos(d)),a[e][2],a[e][3]])}return c};if(!h[c])throw new Error("Shape ["+c+"] is unknown by Perimeter Anchor type");var j=h[c](a);a.rotation&&(j=i(j,a.rotation));var k=a.jsPlumbInstance.makeDynamicAnchor(j);return k.type="Perimeter",k}}(),function(){jsPlumb.DOMElementComponent=jsPlumbUtil.extend(jsPlumb.jsPlumbUIComponent,function(){this.mousemove=this.dblclick=this.click=this.mousedown=this.mouseup=function(){}}),jsPlumb.Segments={AbstractSegment:function(a){this.params=a,this.findClosestPointOnPath=function(){return{d:1/0,x:null,y:null,l:null}},this.getBounds=function(){return{minX:Math.min(a.x1,a.x2),minY:Math.min(a.y1,a.y2),maxX:Math.max(a.x1,a.x2),maxY:Math.max(a.y1,a.y2)}}},Straight:function(a){var b,c,d,e,f,g,h,i=(jsPlumb.Segments.AbstractSegment.apply(this,arguments),function(){b=Math.sqrt(Math.pow(f-e,2)+Math.pow(h-g,2)),c=jsPlumbGeom.gradient({x:e,y:g},{x:f,y:h}),d=-1/c});this.type="Straight",this.getLength=function(){return b},this.getGradient=function(){return c},this.getCoordinates=function(){return{x1:e,y1:g,x2:f,y2:h}},this.setCoordinates=function(a){e=a.x1,g=a.y1,f=a.x2,h=a.y2,i()},this.setCoordinates({x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2}),this.getBounds=function(){return{minX:Math.min(e,f),minY:Math.min(g,h),maxX:Math.max(e,f),maxY:Math.max(g,h)}},this.pointOnPath=function(a,c){if(0!==a||c){if(1!=a||c){var d=c?a>0?a:b+a:a*b;return jsPlumbGeom.pointOnLine({x:e,y:g},{x:f,y:h},d)}return{x:f,y:h}}return{x:e,y:g}},this.gradientAtPoint=function(){return c},this.pointAlongPathFrom=function(a,b,c){var d=this.pointOnPath(a,c),i=0>=b?{x:e,y:g}:{x:f,y:h};return 0>=b&&Math.abs(b)>1&&(b*=-1),jsPlumbGeom.pointOnLine(d,i,b)},this.findClosestPointOnPath=function(a,f){if(0===c)return{x:a,y:g,d:Math.abs(f-g)};if(1/0==c||c==-1/0)return{x:e,y:f,d:Math.abs(a-1)};var h=g-c*e,i=f-d*a,j=(i-h)/(c-d),k=c*j+h,l=jsPlumbGeom.lineLength([a,f],[j,k]),m=jsPlumbGeom.lineLength([j,k],[e,g]);return{d:l,x:j,y:k,l:m/b}}},Arc:function(a){var b=(jsPlumb.Segments.AbstractSegment.apply(this,arguments),function(b,c){return jsPlumbGeom.theta([a.cx,a.cy],[b,c])}),c=function(a,b){if(a.anticlockwise){var c=a.startAngle<a.endAngle?a.startAngle+d:a.startAngle,e=Math.abs(c-a.endAngle);return c-e*b}var f=a.endAngle<a.startAngle?a.endAngle+d:a.endAngle,g=Math.abs(f-a.startAngle);return a.startAngle+g*b},d=2*Math.PI;this.radius=a.r,this.anticlockwise=a.ac,this.type="Arc",a.startAngle&&a.endAngle?(this.startAngle=a.startAngle,this.endAngle=a.endAngle,this.x1=a.cx+this.radius*Math.cos(a.startAngle),this.y1=a.cy+this.radius*Math.sin(a.startAngle),this.x2=a.cx+this.radius*Math.cos(a.endAngle),this.y2=a.cy+this.radius*Math.sin(a.endAngle)):(this.startAngle=b(a.x1,a.y1),this.endAngle=b(a.x2,a.y2),this.x1=a.x1,this.y1=a.y1,this.x2=a.x2,this.y2=a.y2),this.endAngle<0&&(this.endAngle+=d),this.startAngle<0&&(this.startAngle+=d),this.segment=jsPlumbGeom.quadrant([this.x1,this.y1],[this.x2,this.y2]);var e=this.endAngle<this.startAngle?this.endAngle+d:this.endAngle;this.sweep=Math.abs(e-this.startAngle),this.anticlockwise&&(this.sweep=d-this.sweep);var f=2*Math.PI*this.radius,g=this.sweep/d,h=f*g;this.getLength=function(){return h},this.getBounds=function(){return{minX:a.cx-a.r,maxX:a.cx+a.r,minY:a.cy-a.r,maxY:a.cy+a.r}};var i=1e-10,j=function(a){var b=Math.floor(a),c=Math.ceil(a);return i>a-b?b:i>c-a?c:a};this.pointOnPath=function(b,d){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1==b)return{x:this.x2,y:this.y2,theta:this.endAngle};d&&(b/=h);var e=c(this,b),f=a.cx+a.r*Math.cos(e),g=a.cy+a.r*Math.sin(e);return{x:j(f),y:j(g),theta:e}},this.gradientAtPoint=function(b,c){var d=this.pointOnPath(b,c),e=jsPlumbGeom.normal([a.cx,a.cy],[d.x,d.y]);return this.anticlockwise||1/0!=e&&e!=-1/0||(e*=-1),e},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),g=2*(c/f)*Math.PI,h=this.anticlockwise?-1:1,i=e.theta+h*g,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(a){var b=(jsPlumb.Segments.AbstractSegment.apply(this,arguments),[{x:a.x1,y:a.y1},{x:a.cp1x,y:a.cp1y},{x:a.cp2x,y:a.cp2y},{x:a.x2,y:a.y2}]),c={minX:Math.min(a.x1,a.x2,a.cp1x,a.cp2x),minY:Math.min(a.y1,a.y2,a.cp1y,a.cp2y),maxX:Math.max(a.x1,a.x2,a.cp1x,a.cp2x),maxY:Math.max(a.y1,a.y2,a.cp1y,a.cp2y)};this.type="Bezier";var d=function(a,b,c){return c&&(b=jsBezier.locationAlongCurveFrom(a,b>0?0:1,b)),b};this.pointOnPath=function(a,c){return a=d(b,a,c),jsBezier.pointOnCurve(b,a)},this.gradientAtPoint=function(a,c){return a=d(b,a,c),jsBezier.gradientAtPoint(b,a)},this.pointAlongPathFrom=function(a,c,e){return a=d(b,a,e),jsBezier.pointAlongCurveFrom(b,a,c)},this.getLength=function(){return jsBezier.getLength(b)},this.getBounds=function(){return c}}};var a=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}},this.resetBounds()};jsPlumb.Connectors.AbstractConnector=function(b){a.apply(this,arguments);var c=[],d=0,e=[],f=[],g=b.stub||0,h=jsPlumbUtil.isArray(g)?g[0]:g,i=jsPlumbUtil.isArray(g)?g[1]:g,j=b.gap||0,k=jsPlumbUtil.isArray(j)?j[0]:j,l=jsPlumbUtil.isArray(j)?j[1]:j,m=null,n=!1,o=null;this.isEditable=function(){return!1},this.setEdited=function(a){n=a},this.getPath=function(){},this.setPath=function(){},this.findSegmentForPoint=function(a,b){for(var d={d:1/0,s:null,x:null,y:null,l:null},e=0;e<c.length;e++){var f=c[e].findClosestPointOnPath(a,b);f.d<d.d&&(d.d=f.d,d.l=f.l,d.x=f.x,d.y=f.y,d.s=c[e])}return d};var p=function(){for(var a=0,b=0;b<c.length;b++){var g=c[b].getLength();f[b]=g/d,e[b]=[a,a+=g/d]}},q=function(a,b){b&&(a=a>0?a/d:(d+a)/d);for(var g=e.length-1,h=1,i=0;i<e.length;i++)if(e[i][1]>=a){g=i,h=1==a?1:0===a?0:(a-e[i][0])/f[i];break}return{segment:c[g],proportion:h,index:g}},r=function(a,b,e){if(e.x1!=e.x2||e.y1!=e.y2){var f=new jsPlumb.Segments[b](e);c.push(f),d+=f.getLength(),a.updateBounds(f)}},s=function(){d=0,c.splice(0,c.length),e.splice(0,e.length),f.splice(0,f.length)};this.setSegments=function(a){m=[],d=0;for(var b=0;b<a.length;b++)m.push(a[b]),d+=a[b].getLength()};var t=function(a){this.lineWidth=a.lineWidth;var b=jsPlumbGeom.quadrant(a.sourcePos,a.targetPos),c=a.targetPos[0]<a.sourcePos[0],d=a.targetPos[1]<a.sourcePos[1],e=a.lineWidth||1,f=a.sourceEndpoint.anchor.getOrientation(a.sourceEndpoint),g=a.targetEndpoint.anchor.getOrientation(a.targetEndpoint),j=c?a.targetPos[0]:a.sourcePos[0],m=d?a.targetPos[1]:a.sourcePos[1],n=Math.abs(a.targetPos[0]-a.sourcePos[0]),o=Math.abs(a.targetPos[1]-a.sourcePos[1]);if(0===f[0]&&0===f[1]||0===g[0]&&0===g[1]){var p=n>o?0:1,q=[1,0][p];f=[],g=[],f[p]=a.sourcePos[p]>a.targetPos[p]?-1:1,g[p]=a.sourcePos[p]>a.targetPos[p]?1:-1,f[q]=0,g[q]=0}var r=c?n+k*f[0]:k*f[0],s=d?o+k*f[1]:k*f[1],t=c?l*g[0]:n+l*g[0],u=d?l*g[1]:o+l*g[1],v=f[0]*g[0]+f[1]*g[1],w={sx:r,sy:s,tx:t,ty:u,lw:e,xSpan:Math.abs(t-r),ySpan:Math.abs(u-s),mx:(r+t)/2,my:(s+u)/2,so:f,to:g,x:j,y:m,w:n,h:o,segment:b,startStubX:r+f[0]*h,startStubY:s+f[1]*h,endStubX:t+g[0]*i,endStubY:u+g[1]*i,isXGreaterThanStubTimes2:Math.abs(r-t)>h+i,isYGreaterThanStubTimes2:Math.abs(s-u)>h+i,opposite:-1==v,perpendicular:0===v,orthogonal:1==v,sourceAxis:0===f[0]?"y":"x",points:[j,m,n,o,r,s,t,u]};return w.anchorOrientation=w.opposite?"opposite":w.orthogonal?"orthogonal":"perpendicular",w};return this.getSegments=function(){return c},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)},this.pointOnPath=function(a,b){var c=q(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,b)||[0,0]},this.gradientAtPoint=function(a){var b=q(a,absolute);return b.segment&&b.segment.gradientAtPoint(b.proportion,absolute)||0},this.pointAlongPathFrom=function(a,b,c){var d=q(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){n||(o=t.call(this,a)),s(),this._compute(o,a),this.x=o.points[0],this.y=o.points[1],this.w=o.points[2],this.h=o.points[3],this.segment=o.segment,p()},{addSegment:r,prepareCompute:t,sourceStub:h,targetStub:i,maxStub:Math.max(h,i),sourceGap:k,targetGap:l,maxGap:Math.max(k,l)}},jsPlumbUtil.extend(jsPlumb.Connectors.AbstractConnector,a);var b=jsPlumb.Connectors.Straight=function(){this.type="Straight";var a=jsPlumb.Connectors.AbstractConnector.apply(this,arguments);this._compute=function(b){a.addSegment(this,"Straight",{x1:b.sx,y1:b.sy,x2:b.startStubX,y2:b.startStubY}),a.addSegment(this,"Straight",{x1:b.startStubX,y1:b.startStubY,x2:b.endStubX,y2:b.endStubY}),a.addSegment(this,"Straight",{x1:b.endStubX,y1:b.endStubY,x2:b.tx,y2:b.ty})}};jsPlumbUtil.extend(jsPlumb.Connectors.Straight,jsPlumb.Connectors.AbstractConnector),jsPlumb.registerConnectorType(b,"Straight");var c=function(a){a=a||{};var b=jsPlumb.Connectors.AbstractConnector.apply(this,arguments),c=(a.stub||50,a.curviness||150),d=10;this.type="Bezier",this.getCurviness=function(){return c},this._findControlPoint=function(a,b,e,f,g){var h=f.anchor.getOrientation(f),i=g.anchor.getOrientation(g),j=h[0]!=i[0]||h[1]==i[1],k=[];return j?(0===i[0]?k.push(e[0]<b[0]?a[0]+d:a[0]-d):k.push(a[0]+c*i[0]),0===i[1]?k.push(e[1]<b[1]?a[1]+d:a[1]-d):k.push(a[1]+c*h[1])):(0===h[0]?k.push(b[0]<e[0]?a[0]+d:a[0]-d):k.push(a[0]-c*h[0]),0===h[1]?k.push(b[1]<e[1]?a[1]+d:a[1]-d):k.push(a[1]+c*i[1])),k},this._compute=function(a,c){var d=c.sourcePos,e=c.targetPos,f=Math.abs(d[0]-e[0]),g=Math.abs(d[1]-e[1]),h=d[0]<e[0]?f:0,i=d[1]<e[1]?g:0,j=d[0]<e[0]?0:f,k=d[1]<e[1]?0:g,l=this._findControlPoint([h,i],d,e,c.sourceEndpoint,c.targetEndpoint),m=this._findControlPoint([j,k],e,d,c.targetEndpoint,c.sourceEndpoint);b.addSegment(this,"Bezier",{x1:h,y1:i,x2:j,y2:k,cp1x:l[0],cp1y:l[1],cp2x:m[0],cp2y:m[1]})}};jsPlumbUtil.extend(c,jsPlumb.Connectors.AbstractConnector),jsPlumb.registerConnectorType(c,"Bezier"),jsPlumb.Endpoints.AbstractEndpoint=function(b){a.apply(this,arguments);var c=this.compute=function(){var a=this._compute.apply(this,arguments);return this.x=a[0],this.y=a[1],this.w=a[2],this.h=a[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,a};return{compute:c,cssClass:b.cssClass}},jsPlumbUtil.extend(jsPlumb.Endpoints.AbstractEndpoint,a),jsPlumb.Endpoints.Dot=function(a){this.type="Dot",jsPlumb.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c){this.radius=c.radius||this.radius;var d=a[0]-this.radius,e=a[1]-this.radius,f=2*this.radius,g=2*this.radius;if(c.strokeStyle){var h=c.lineWidth||1;d-=h,e-=h,f+=2*h,g+=2*h}return[d,e,f,g,this.radius]}},jsPlumbUtil.extend(jsPlumb.Endpoints.Dot,jsPlumb.Endpoints.AbstractEndpoint),jsPlumb.Endpoints.Rectangle=function(a){this.type="Rectangle",jsPlumb.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c){var d=c.width||this.width,e=c.height||this.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}},jsPlumbUtil.extend(jsPlumb.Endpoints.Rectangle,jsPlumb.Endpoints.AbstractEndpoint);var d=function(){jsPlumb.DOMElementComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};jsPlumbUtil.extend(d,jsPlumb.DOMElementComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),jsPlumb.Endpoints.Image=function(a){this.type="Image",d.apply(this,arguments),jsPlumb.Endpoints.AbstractEndpoint.apply(this,arguments);var b=a.onload,c=a.src||a.url,e=a.parent,f=a.cssClass?" "+a.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=a.width,this._jsPlumb.heightToUse=a.height,this._jsPlumb.endpoint=a.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,b&&b(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,c){var d=a.constructor==String?a:a.src;b=c,this._jsPlumb.img.src=d,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(c,b),this._compute=function(a){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=document.createElement("img"),this.canvas.style.margin=0,this.canvas.style.padding=0,this.canvas.style.outline=0,this.canvas.style.position="absolute",this.canvas.className=this._jsPlumb.instance.endpointClass+f,this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas,e),this.attachListeners(this.canvas,this),this.actuallyPaint=function(){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var a=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,b=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;jsPlumbUtil.sizeElement(this.canvas,a,b,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(a,b){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(a,b):window.setTimeout(function(){this.paint(a,b)}.bind(this),200))}},jsPlumbUtil.extend(jsPlumb.Endpoints.Image,[d,jsPlumb.Endpoints.AbstractEndpoint],{cleanup:function(){this._jsPlumb.deleted=!0,jsPlumbUtil.removeElement(this.canvas),this.canvas=null}}),jsPlumb.Endpoints.Blank=function(a){jsPlumb.Endpoints.AbstractEndpoint.apply(this,arguments),this.type="Blank",d.apply(this,arguments),this._compute=function(a){return[a[0],a[1],10,0]},this.canvas=document.createElement("div"),this.canvas.style.display="block",this.canvas.style.width="1px",this.canvas.style.height="1px",this.canvas.style.background="transparent",this.canvas.style.position="absolute",this.canvas.className=this._jsPlumb.endpointClass,jsPlumb.appendElement(this.canvas,a.parent),this.paint=function(){jsPlumbUtil.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},jsPlumbUtil.extend(jsPlumb.Endpoints.Blank,[jsPlumb.Endpoints.AbstractEndpoint,d],{cleanup:function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)}}),jsPlumb.Endpoints.Triangle=function(a){this.type="Triangle",jsPlumb.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,c){var d=c.width||self.width,e=c.height||self.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}};var e=jsPlumb.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation};e.prototype={cleanup:function(){this.component=null,this.canvas=null,this.endpointLoc=null},setVisible:function(a){this.visible=a},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc}},jsPlumb.Overlays.Arrow=function(a){this.type="Arrow",e.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{};var b=jsPlumbUtil,c=jsPlumbGeom;this.length=a.length||20,this.width=a.width||20,this.id=a.id;var d=(a.direction||1)<0?-1:1,f=a.paintStyle||{lineWidth:1},g=a.foldback||.623;this.computeMaxSize=function(){return 1.5*self.width},this.draw=function(a,e){var h,i,j,k,l;if(a.pointAlongPathFrom){if(b.isString(this.loc)||this.loc>3||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;h=a.pointAlongPathFrom(n,m,!1),i=a.pointAlongPathFrom(n,m-d*this.length/2,!1),j=c.pointOnLine(h,i,this.length)}else if(1==this.loc){if(h=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,-this.length),j=c.pointOnLine(h,i,this.length),-1==d){var o=j;j=h,h=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,this.length),h=c.pointOnLine(j,i,this.length),-1==d){var p=j;j=h,h=p}}else h=a.pointAlongPathFrom(this.loc,d*this.length/2),i=a.pointOnPath(this.loc),j=c.pointOnLine(h,i,this.length);k=c.perpendicularLineTo(h,j,this.width),l=c.pointOnLine(h,j,g*this.length);var q={hxy:h,tail:k,cxy:l},r=f.strokeStyle||e.strokeStyle,s=f.fillStyle||e.strokeStyle,t=f.lineWidth||e.lineWidth,u={component:a,d:q,lineWidth:t,strokeStyle:r,fillStyle:s,minX:Math.min(h.x,k[0].x,k[1].x),maxX:Math.max(h.x,k[0].x,k[1].x),minY:Math.min(h.y,k[0].y,k[1].y),maxY:Math.max(h.y,k[0].y,k[1].y)};return u}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},jsPlumbUtil.extend(jsPlumb.Overlays.Arrow,e),jsPlumb.Overlays.PlainArrow=function(a){a=a||{};var b=jsPlumb.extend(a,{foldback:1});jsPlumb.Overlays.Arrow.call(this,b),this.type="PlainArrow"},jsPlumbUtil.extend(jsPlumb.Overlays.PlainArrow,jsPlumb.Overlays.Arrow),jsPlumb.Overlays.Diamond=function(a){a=a||{};var b=a.length||40,c=jsPlumb.extend(a,{length:b/2,foldback:2});jsPlumb.Overlays.Arrow.call(this,c),this.type="Diamond"},jsPlumbUtil.extend(jsPlumb.Overlays.Diamond,jsPlumb.Overlays.Arrow);var f=function(a){return null==a._jsPlumb.cachedDimensions&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},g=function(a){jsPlumb.DOMElementComponent.apply(this,arguments),e.apply(this,arguments);var b=jsPlumb.CurrentLibrary;this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this.getElement=function(){if(null==this._jsPlumb.div){var c=this._jsPlumb.div=b.getDOMElement(this._jsPlumb.create(this._jsPlumb.component));c.style.position="absolute";var d=a._jsPlumb.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:"");c.className=d,this._jsPlumb.instance.appendElement(c,this._jsPlumb.component.parent),this._jsPlumb.instance.getId(c),this.attachListeners(c,this),this.canvas=c}return this._jsPlumb.div},this.draw=function(a){var b=f(this);if(null!=b&&2==b.length){var c={x:0,y:0};if(a.pointOnPath){var d=this.loc,e=!1;(jsPlumbUtil.isString(this.loc)||this.loc<0||this.loc>3)&&(d=parseInt(this.loc,10),e=!0),c=a.pointOnPath(d,e)}else{var g=this.loc.constructor==Array?this.loc:this.endpointLoc;c={x:g[0]*a.w,y:g[1]*a.h}}var h=c.x-b[0]/2,i=c.y-b[1]/2;return{component:a,d:{minx:h,miny:i,td:b,cxy:c},minX:h,maxX:h+b[0],minY:i,maxY:i+b[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};jsPlumbUtil.extend(g,[jsPlumb.DOMElementComponent,e],{getDimensions:function(){return jsPlumb.CurrentLibrary.getSize(jsPlumb.CurrentLibrary.getElementObject(this.getElement()))},setVisible:function(a){this._jsPlumb.div.style.display=a?"block":"none"},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(){null!=this._jsPlumb.div&&jsPlumb.CurrentLibrary.removeElement(this._jsPlumb.div)},computeMaxSize:function(){var a=f(this);return Math.max(a[0],a[1])},reattachListeners:function(a){this._jsPlumb.div&&this.reattachListenersForElement(this._jsPlumb.div,this,a)},paint:function(a){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this.attachListeners(this._jsPlumb.div,a.component),this._jsPlumb.initialised=!0),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),jsPlumb.Overlays.Custom=function(){this.type="Custom",g.apply(this,arguments)},jsPlumbUtil.extend(jsPlumb.Overlays.Custom,g),jsPlumb.Overlays.GuideLines=function(){var a=this;a.length=50,a.lineWidth=5,this.type="GuideLines",e.apply(this,arguments),jsPlumb.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b){var c=b.pointAlongPathFrom(a.loc,a.length/2),d=b.pointOnPath(a.loc),e=jsPlumbGeom.pointOnLine(c,d,a.length),f=jsPlumbGeom.perpendicularLineTo(c,e,40),g=jsPlumbGeom.perpendicularLineTo(e,c,20);return{connector:b,head:c,tail:e,headLine:g,tailLine:f,minX:Math.min(c.x,e.x,g[0].x,g[1].x),minY:Math.min(c.y,e.y,g[0].y,g[1].y),maxX:Math.max(c.x,e.x,g[0].x,g[1].x),maxY:Math.max(c.y,e.y,g[0].y,g[1].y)}}},jsPlumb.Overlays.Label=function(a){this.labelStyle=a.labelStyle,this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var b=jsPlumb.extend({create:function(){return document.createElement("div")}},a);if(jsPlumb.Overlays.Custom.call(this,b),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var c=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",c.style.font=this.labelStyle.font,c.style.color=this.labelStyle.color||"black",this.labelStyle.fillStyle&&(c.style.background=this.labelStyle.fillStyle),this.labelStyle.borderWidth>0){var d=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";c.style.border=this.labelStyle.borderWidth+"px solid "+d}this.labelStyle.padding&&(c.style.padding=this.labelStyle.padding)}},jsPlumbUtil.extend(jsPlumb.Overlays.Label,jsPlumb.Overlays.Custom,{cleanup:function(){this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),g.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"<br/>")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"<br/>"))}})}(),function(){var a=function(a){this.type="Flowchart",a=a||{},a.stub=null==a.stub?30:a.stub;var b,c=jsPlumb.Connectors.AbstractConnector.apply(this,arguments),d=null==a.midpoint?.5:a.midpoint,e=[],f=(a.grid,a.alwaysRespectStubs),g=null,h=null,i=null,j=null!=a.cornerRadius?a.cornerRadius:0,k=function(a){return 0>a?-1:0===a?0:1},l=function(a,b,c,d){if(h!=b||i!=c){var e=null==h?d.sx:h,f=null==i?d.sy:i,g=e==b?"v":"h",j=k(b-e),l=k(c-f);h=b,i=c,a.push([e,f,b,c,g,j,l])}},m=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},n=function(a){var b=[];return b.push.apply(b,a),b},o=function(a,b,d){for(var e,f,g=0;g<b.length-1;g++){if(e=e||n(b[g]),f=n(b[g+1]),j>0&&e[4]!=f[4]){var h=Math.min(j,m(e),m(f));e[2]-=e[5]*h,e[3]-=e[6]*h,f[0]+=f[5]*h,f[1]+=f[6]*h;var i=e[6]==f[5]&&1==f[5]||e[6]==f[5]&&0===f[5]&&e[5]!=f[6]||e[6]==f[5]&&-1==f[5],k=f[1]>e[3]?1:-1,l=f[0]>e[2]?1:-1,o=k==l,p=o&&i||!o&&!i?f[0]:e[2],q=o&&i||!o&&!i?e[3]:f[1];c.addSegment(a,"Straight",{x1:e[0],y1:e[1],x2:e[2],y2:e[3]}),c.addSegment(a,"Arc",{r:h,x1:e[2],y1:e[3],x2:f[0],y2:f[1],cx:p,cy:q,ac:i})
+}else{var r=e[2]==e[0]?0:e[2]>e[0]?d.lw/2:-(d.lw/2),s=e[3]==e[1]?0:e[3]>e[1]?d.lw/2:-(d.lw/2);c.addSegment(a,"Straight",{x1:e[0]-r,y1:e[1]-s,x2:e[2]+r,y2:e[3]+s})}e=f}c.addSegment(a,"Straight",{x1:f[0],y1:f[1],x2:f[2],y2:f[3]})};this.setSegments=function(a){g=a},this.isEditable=function(){return!0},this.getOriginalSegments=function(){return g||e},this._compute=function(a,j){if(j.clearEdits&&(g=null),null!=g)return o(this,g,a),void 0;e=[],h=null,i=null,b=null;var k=a.startStubX+(a.endStubX-a.startStubX)*d,m=a.startStubY+(a.endStubY-a.startStubY)*d,n={x:[0,1],y:[1,0]},p=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},q={perpendicular:p,orthogonal:p,opposite:function(b){var c=a,d="x"==b?0:1,e={x:function(){return 1==c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1==c.so[d]&&(c.startStubX<c.endStubX&&c.tx<c.startStubX||c.sx<c.endStubX&&c.tx<c.sx)},y:function(){return 1==c.so[d]&&(c.startStubY>c.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1==c.so[d]&&(c.startStubY<c.endStubY&&c.ty<c.startStubY||c.sy<c.endStubY&&c.ty<c.sy)}};return!f&&e[b]()?{x:[(a.sx+a.tx)/2,a.startStubY,(a.sx+a.tx)/2,a.endStubY],y:[a.startStubX,(a.sy+a.ty)/2,a.endStubX,(a.sy+a.ty)/2]}[b]:[a.startStubX,a.startStubY,a.endStubX,a.endStubY]}},r={perpendicular:function(b){var c=a,d={x:[[[1,2,3,4],null,[2,1,4,3]],null,[[4,3,2,1],null,[3,4,1,2]]],y:[[[3,2,1,4],null,[2,3,4,1]],null,[[4,1,2,3],null,[1,4,3,2]]]},e={x:[[c.startStubX,c.endStubX],null,[c.endStubX,c.startStubX]],y:[[c.startStubY,c.endStubY],null,[c.endStubY,c.startStubY]]},f={x:[[k,c.startStubY],[k,c.endStubY]],y:[[c.startStubX,m],[c.endStubX,m]]},g={x:[[c.endStubX,c.startStubY]],y:[[c.startStubX,c.endStubY]]},h={x:[[c.startStubX,c.endStubY],[c.endStubX,c.endStubY]],y:[[c.endStubX,c.startStubY],[c.endStubX,c.endStubY]]},i={x:[[c.startStubX,m],[c.endStubX,m],[c.endStubX,c.endStubY]],y:[[k,c.startStubY],[k,c.endStubY],[c.endStubX,c.endStubY]]},j={x:[c.startStubY,c.endStubY],y:[c.startStubX,c.endStubX]},l=n[b][0],o=n[b][1],p=c.so[l]+1,q=c.to[o]+1,r=-1==c.to[o]&&j[b][1]<j[b][0]||1==c.to[o]&&j[b][1]>j[b][0],s=e[b][p][0],t=e[b][p][1],u=d[b][p][q];return c.segment==u[3]||c.segment==u[2]&&r?f[b]:c.segment==u[2]&&s>t?g[b]:c.segment==u[2]&&t>=s||c.segment==u[1]&&!r?i[b]:c.segment==u[0]||c.segment==u[1]&&r?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1==g.so[0]?Math.min(c,e):Math.max(c,e),y:-1==g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(b,d,e,f){var g=a,h={x:"y",y:"x"}[b],i={x:"height",y:"width"}[b],l=g["is"+b.toUpperCase()+"GreaterThanStubTimes2"];if(j.sourceEndpoint.elementId==j.targetEndpoint.elementId){var n=e+(1-j.sourceEndpoint.anchor[h])*j.sourceInfo[i]+c.maxStub;return{x:[[d,n],[f,n]],y:[[n,d],[n,f]]}[b]}return!l||1==g.so[t]&&d>f||-1==g.so[t]&&f>d?{x:[[d,m],[f,m]],y:[[k,d],[k,f]]}[b]:1==g.so[t]&&f>d||-1==g.so[t]&&d>f?{x:[[k,g.sy],[k,g.ty]],y:[[g.sx,m],[g.tx,m]]}[b]:void 0}},s=q[a.anchorOrientation](a.sourceAxis),t="x"==a.sourceAxis?0:1,u="x"==a.sourceAxis?1:0,v=s[t],w=s[u],x=s[t+2],y=s[u+2];l(e,s[0],s[1],a);var z=r[a.anchorOrientation](a.sourceAxis,v,w,x,y);if(z)for(var A=0;A<z.length;A++)l(e,z[A][0],z[A][1],a);l(e,s[2],s[3],a),l(e,a.tx,a.ty,a),o(this,e,a)},this.getPath=function(){for(var a=null,b=null,c=[],d=g||e,f=0;f<d.length;f++){var h=d[f],i=h[4],j="v"==i?3:2;null!=a&&b===i?a[j]=h[j]:(h[0]!=h[2]||h[1]!=h[3])&&(c.push({start:[h[0],h[1]],end:[h[2],h[3]]}),a=h,b=h[4])}return c},this.setPath=function(a){g=[];for(var b=0;b<a.length;b++){var c=a[b].start[0],d=a[b].start[1],e=a[b].end[0],f=a[b].end[1],h=c==e?"v":"h",i=k(e-c),j=k(f-d);g.push([c,d,e,f,h,i,j])}}};jsPlumbUtil.extend(a,jsPlumb.Connectors.AbstractConnector),jsPlumb.registerConnectorType(a,"Flowchart")}(),function(){var a=function(a,b,c,d){return c>=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},b=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+1*f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+1*f,b+-1*g]:void 0},c=function(c){c=c||{},this.type="StateMachine";var d=jsPlumb.Connectors.AbstractConnector.apply(this,arguments),e=c.curviness||10,f=c.margin||5,g=c.proximityLimit||80,h=c.orientation&&"clockwise"===c.orientation,i=c.loopbackRadius||25,j=c.showLoopback!==!1;this._compute=function(c,k){var l=Math.abs(k.sourcePos[0]-k.targetPos[0]),m=Math.abs(k.sourcePos[1]-k.targetPos[1]);if(Math.min(k.sourcePos[0],k.targetPos[0]),Math.min(k.sourcePos[1],k.targetPos[1]),j&&k.sourceEndpoint.elementId===k.targetEndpoint.elementId){var n=k.sourcePos[0],o=(k.sourcePos[0],k.sourcePos[1]-f),p=(k.sourcePos[1]-f,n),q=o-i,r=2*i,s=2*i,t=p-i,u=q-i;c.points[0]=t,c.points[1]=u,c.points[2]=r,c.points[3]=s,d.addSegment(this,"Arc",{loopback:!0,x1:n-t+4,y1:o-u,startAngle:0,endAngle:2*Math.PI,r:i,ac:!h,x2:n-t-4,y2:o-u,cx:p-t,cy:q-u})}else{var v=k.sourcePos[0]<k.targetPos[0]?0:l,w=k.sourcePos[1]<k.targetPos[1]?0:m,x=k.sourcePos[0]<k.targetPos[0]?l:0,y=k.sourcePos[1]<k.targetPos[1]?m:0;0===k.sourcePos[2]&&(v-=f),1===k.sourcePos[2]&&(v+=f),0===k.sourcePos[3]&&(w-=f),1===k.sourcePos[3]&&(w+=f),0===k.targetPos[2]&&(x-=f),1===k.targetPos[2]&&(x+=f),0===k.targetPos[3]&&(y-=f),1===k.targetPos[3]&&(y+=f);var z=(v+x)/2,A=(w+y)/2,B=-1*z/A,C=Math.atan(B),D=(1/0==B||B==-1/0?0:Math.abs(e/2*Math.sin(C)),1/0==B||B==-1/0?0:Math.abs(e/2*Math.cos(C)),a(v,w,x,y)),E=Math.sqrt(Math.pow(x-v,2)+Math.pow(y-w,2)),F=b(z,A,D,k.sourcePos,k.targetPos,e,e,E,g);d.addSegment(this,"Bezier",{x1:x,y1:y,x2:v,y2:w,cp1x:F[0],cp1y:F[1],cp2x:F[0],cp2y:F[1]})}}};jsPlumb.registerConnectorType(c,"StateMachine")}(),function(){var a=function(a){a=a||{};var b=this,c=jsPlumb.Connectors.AbstractConnector.apply(this,arguments),d=(a.stub||50,a.curviness||150),e=10;this.type="Bezier",this.getCurviness=function(){return d},this._findControlPoint=function(a,b,c,f,g){var h=f.anchor.getOrientation(f),i=g.anchor.getOrientation(g),j=h[0]!=i[0]||h[1]==i[1],k=[];return j?(0===i[0]?k.push(c[0]<b[0]?a[0]+e:a[0]-e):k.push(a[0]+d*i[0]),0===i[1]?k.push(c[1]<b[1]?a[1]+e:a[1]-e):k.push(a[1]+d*h[1])):(0===h[0]?k.push(b[0]<c[0]?a[0]+e:a[0]-e):k.push(a[0]-d*h[0]),0===h[1]?k.push(b[1]<c[1]?a[1]+e:a[1]-e):k.push(a[1]+d*i[1])),k},this._compute=function(a,d){var e=d.sourcePos,f=d.targetPos,g=Math.abs(e[0]-f[0]),h=Math.abs(e[1]-f[1]),i=e[0]<f[0]?g:0,j=e[1]<f[1]?h:0,k=e[0]<f[0]?0:g,l=e[1]<f[1]?0:h,m=b._findControlPoint([i,j],e,f,d.sourceEndpoint,d.targetEndpoint),n=b._findControlPoint([k,l],f,e,d.targetEndpoint,d.sourceEndpoint);c.addSegment(this,"Bezier",{x1:i,y1:j,x2:k,y2:l,cp1x:m[0],cp1y:m[1],cp2x:n[0],cp2y:n[1]})}};jsPlumb.registerConnectorType(a,"Bezier")}(),function(){var a=null,b=function(a,b){return jsPlumb.CurrentLibrary.hasClass(c(a),b)},c=function(a){return jsPlumb.CurrentLibrary.getElementObject(a)},d=function(a){return jsPlumb.CurrentLibrary.getOffset(c(a))},e=function(a){return jsPlumb.CurrentLibrary.getPageXY(a)},f=function(a){return jsPlumb.CurrentLibrary.getClientXY(a)},g=window.CanvasMouseAdapter=function(){var g=this;this.overlayPlacements=[],jsPlumb.jsPlumbUIComponent.apply(this,arguments),jsPlumbUtil.EventGenerator.apply(this,arguments),this._over=function(a){var b=d(c(g.canvas)),f=e(a),h=f[0]-b.left,i=f[1]-b.top;if(h>0&&i>0&&h<g.canvas.width&&i<g.canvas.height){for(var j=0;j<g.overlayPlacements.length;j++){var k=g.overlayPlacements[j];if(k&&k[0]<=h&&k[1]>=h&&k[2]<=i&&k[3]>=i)return!0}var l=g.canvas.getContext("2d").getImageData(parseInt(h,10),parseInt(i,10),1,1);return 0!==l.data[0]||0!==l.data[1]||0!==l.data[2]||0!==l.data[3]}return!1};var h=!1,i=!1,j=null,k=!1,l=function(a,c){return null!==a&&b(a,c)};this.mousemove=function(b){var c=(e(b),f(b)),d=document.elementFromPoint(c[0],c[1]),i=l(d,"_jsPlumb_overlay"),j=null===a&&(l(d,"_jsPlumb_endpoint")||l(d,"_jsPlumb_connector"));return!h&&j&&g._over(b)?(h=!0,g.fire("mouseenter",g,b),!0):(!h||g._over(b)&&j||i||(h=!1,g.fire("mouseexit",g,b)),g.fire("mousemove",g,b),void 0)},this.click=function(a){h&&g._over(a)&&!k&&g.fire("click",g,a),k=!1},this.dblclick=function(a){h&&g._over(a)&&!k&&g.fire("dblclick",g,a),k=!1},this.mousedown=function(a){g._over(a)&&!i&&(i=!0,j=d(c(g.canvas)),g.fire("mousedown",g,a))},this.mouseup=function(a){i=!1,g.fire("mouseup",g,a)},this.contextmenu=function(a){h&&g._over(a)&&!k&&g.fire("contextmenu",g,a),k=!1}};jsPlumbUtil.extend(g,[jsPlumb.jsPlumbUIComponent,jsPlumbUtil.EventGenerator]);var h=function(a){var b=document.createElement("canvas");return a._jsPlumb.instance.appendElement(b,a.parent),b.style.position="absolute",a["class"]&&(b.className=a["class"]),a._jsPlumb.instance.getId(b,a.uuid),a.tooltip&&b.setAttribute("title",a.tooltip),b},i=window.CanvasComponent=function(){g.apply(this,arguments);var a=[];this.getDisplayElements=function(){return a},this.appendDisplayElement=function(b){a.push(b)}};jsPlumbUtil.extend(i,g,{setVisible:function(a){this.canvas.style.display=a?"block":"none"}});var j=[null,[1,-1],[1,1],[-1,1],[-1,-1]],k=function(a,b,c){if(b.gradient){for(var d=c(),e=0;e<b.gradient.stops.length;e++)d.addColorStop(b.gradient.stops[e][0],b.gradient.stops[e][1]);a.strokeStyle=d}},l=function(a,b,c,d,e){({Straight:function(a,b,c,d,e){var f=a.params;if(b.save(),k(b,c,function(){return b.createLinearGradient(f.x1,f.y1,f.x2,f.y2)}),b.beginPath(),b.translate(d,e),c.dashstyle&&2===c.dashstyle.split(" ").length){var g=c.dashstyle.split(" ");2!==g.length&&(g=[2,2]);for(var h=[g[0]*c.lineWidth,g[1]*c.lineWidth],i=(f.x2-f.x1)/(f.y2-f.y1),l=jsPlumbUtil.segment([f.x1,f.y1],[f.x2,f.y2]),m=j[l],n=Math.atan(i),o=Math.sqrt(Math.pow(f.x2-f.x1,2)+Math.pow(f.y2-f.y1,2)),p=Math.floor(o/(h[0]+h[1])),q=[f.x1,f.y1],r=0;p>r;r++){b.moveTo(q[0],q[1]);var s=q[0]+Math.abs(Math.sin(n)*h[0])*m[0],t=q[1]+Math.abs(Math.cos(n)*h[0])*m[1],u=q[0]+Math.abs(Math.sin(n)*(h[0]+h[1]))*m[0],v=q[1]+Math.abs(Math.cos(n)*(h[0]+h[1]))*m[1];b.lineTo(s,t),q=[u,v]}b.moveTo(q[0],q[1]),b.lineTo(f.x2,f.y2)}else b.moveTo(f.x1,f.y1),b.lineTo(f.x2,f.y2);b.stroke(),b.restore()},Bezier:function(a,b,c,d,e){var f=a.params;b.save(),k(b,c,function(){return b.createLinearGradient(f.x2+d,f.y2+e,f.x1+d,f.y1+e)}),b.beginPath(),b.translate(d,e),b.moveTo(f.x1,f.y1),b.bezierCurveTo(f.cp1x,f.cp1y,f.cp2x,f.cp2y,f.x2,f.y2),b.stroke(),b.restore()},Arc:function(a,b,c,d,e){var f=a.params;b.save(),b.beginPath(),b.translate(d,e),b.arc(f.cx,f.cy,f.r,a.startAngle,a.endAngle,f.ac),b.stroke(),b.restore()}})[a.type](a,b,c,d,e)},m=jsPlumb.ConnectorRenderers.canvas=function(a){i.apply(this,arguments);var b=function(a,b,c){this.ctx.save(),jsPlumb.extend(this.ctx,a);for(var d=this.getSegments(),e=0;e<d.length;e++)l(d[e],this.ctx,a,b,c);this.ctx.restore()}.bind(this),c=this._jsPlumb.instance.connectorClass+" "+(a.cssClass||"");this.canvas=h({"class":c,_jsPlumb:this._jsPlumb,parent:a.parent}),this.ctx=this.canvas.getContext("2d"),this.appendDisplayElement(this.canvas),this.paint=function(a,c,d){if(null!=a){var e=[this.x,this.y],f=[this.w,this.h],g=0,h=0;if(null!=d&&(d.xmin<0&&(e[0]+=d.xmin,g=-d.xmin),d.ymin<0&&(e[1]+=d.ymin,h=-d.ymin),f[0]=d.xmax+(d.xmin<0?-d.xmin:0),f[1]=d.ymax+(d.ymin<0?-d.ymin:0)),this.translateX=g,this.translateY=h,jsPlumbUtil.sizeElement(this.canvas,e[0],e[1],f[0],f[1]),null!=a.outlineColor){var i=a.outlineWidth||1,j=a.lineWidth+2*i,k={strokeStyle:a.outlineColor,lineWidth:j};b(k,g,h)}b(a,g,h)}}};jsPlumbUtil.extend(m,i);var n=function(a){i.apply(this,arguments);var b=this._jsPlumb.instance.endpointClass+" "+(a.cssClass||""),c={"class":b,_jsPlumb:this._jsPlumb,parent:a.parent,tooltip:self.tooltip};this.canvas=h(c),this.ctx=this.canvas.getContext("2d"),this.appendDisplayElement(this.canvas),this.paint=function(a){if(jsPlumbUtil.sizeElement(this.canvas,this.x,this.y,this.w,this.h),null!=a.outlineColor){var b=a.outlineWidth||1,c=a.lineWidth+2*b;({strokeStyle:a.outlineColor,lineWidth:c})}this._paint.apply(this,arguments)}};jsPlumbUtil.extend(n,i),jsPlumb.Endpoints.canvas.Dot=function(a){jsPlumb.Endpoints.Dot.apply(this,arguments),n.apply(this,arguments);var b=this,c=function(a){try{return parseInt(a,10)}catch(b){if("%"==a.substring(a.length-1))return parseInt(a.substring(0,a-1),10)}},d=function(a){var d=b.defaultOffset,e=b.defaultInnerRadius;return a.offset&&(d=c(a.offset)),a.innerRadius&&(e=c(a.innerRadius)),[d,e]};this._paint=function(c){if(null!=c){var e=b.canvas.getContext("2d"),f=a.endpoint.anchor.getOrientation(a.endpoint);if(jsPlumb.extend(e,c),c.gradient){for(var g=d(c.gradient),h=1==f[1]?-1*g[0]:g[0],i=1==f[0]?-1*g[0]:g[0],j=e.createRadialGradient(b.radius,b.radius,b.radius,b.radius+i,b.radius+h,g[1]),k=0;k<c.gradient.stops.length;k++)j.addColorStop(c.gradient.stops[k][0],c.gradient.stops[k][1]);e.fillStyle=j}e.beginPath(),e.arc(b.radius,b.radius,b.radius,0,2*Math.PI,!0),e.closePath(),(c.fillStyle||c.gradient)&&e.fill(),c.strokeStyle&&e.stroke()}}},jsPlumbUtil.extend(jsPlumb.Endpoints.canvas.Dot,[jsPlumb.Endpoints.Dot,n]),jsPlumb.Endpoints.canvas.Rectangle=function(a){var b=this;jsPlumb.Endpoints.Rectangle.apply(this,arguments),n.apply(this,arguments),this._paint=function(c){var d=b.canvas.getContext("2d"),e=a.endpoint.anchor.getOrientation(a.endpoint);if(jsPlumb.extend(d,c),c.gradient){for(var f=1==e[1]?b.h:0===e[1]?b.h/2:0,g=-1==e[1]?b.h:0===e[1]?b.h/2:0,h=1==e[0]?b.w:0===e[0]?b.w/2:0,i=-1==e[0]?b.w:0===e[0]?b.w/2:0,j=d.createLinearGradient(h,f,i,g),k=0;k<c.gradient.stops.length;k++)j.addColorStop(c.gradient.stops[k][0],c.gradient.stops[k][1]);d.fillStyle=j}d.beginPath(),d.rect(0,0,b.w,b.h),d.closePath(),(c.fillStyle||c.gradient)&&d.fill(),c.strokeStyle&&d.stroke()}},jsPlumbUtil.extend(jsPlumb.Endpoints.canvas.Rectangle,[jsPlumb.Endpoints.Rectangle,n]),jsPlumb.Endpoints.canvas.Triangle=function(a){var b=this;jsPlumb.Endpoints.Triangle.apply(this,arguments),n.apply(this,arguments),this._paint=function(c){var d=b.canvas.getContext("2d"),e=0,f=0,g=0,h=a.endpoint.anchor.getOrientation(a.endpoint);1==h[0]&&(e=b.width,f=b.height,g=180),-1==h[1]&&(e=b.width,g=90),1==h[1]&&(f=b.height,g=-90),d.fillStyle=c.fillStyle,d.translate(e,f),d.rotate(g*Math.PI/180),d.beginPath(),d.moveTo(0,0),d.lineTo(b.width/2,b.height/2),d.lineTo(0,b.height),d.closePath(),(c.fillStyle||c.gradient)&&d.fill(),c.strokeStyle&&d.stroke()}},jsPlumbUtil.extend(jsPlumb.Endpoints.canvas.Triangle,[jsPlumb.Endpoints.Triangle,n]),jsPlumb.Endpoints.canvas.Image=jsPlumb.Endpoints.Image,jsPlumb.Endpoints.canvas.Blank=jsPlumb.Endpoints.Blank,jsPlumb.Overlays.canvas.Label=jsPlumb.Overlays.Label,jsPlumb.Overlays.canvas.Custom=jsPlumb.Overlays.Custom;var o=function(){jsPlumb.jsPlumbUIComponent.apply(this,arguments)};jsPlumbUtil.extend(o,jsPlumb.jsPlumbUIComponent,{setVisible:function(a){this.visible=a,this.component.repaint()}});var p=function(a,b){a.apply(this,b),o.apply(this,b),this.paint=function(a){var b=a.component.ctx,c=a.d;c&&(b.save(),b.lineWidth=a.lineWidth,b.beginPath(),b.translate(a.component.translateX,a.component.translateY),b.moveTo(c.hxy.x,c.hxy.y),b.lineTo(c.tail[0].x,c.tail[0].y),b.lineTo(c.cxy.x,c.cxy.y),b.lineTo(c.tail[1].x,c.tail[1].y),b.lineTo(c.hxy.x,c.hxy.y),b.closePath(),a.strokeStyle&&(b.strokeStyle=a.strokeStyle,b.stroke()),a.fillStyle&&(b.fillStyle=a.fillStyle,b.fill()),b.restore())}};jsPlumb.Overlays.canvas.Arrow=function(){p.apply(this,[jsPlumb.Overlays.Arrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.canvas.Arrow,[jsPlumb.Overlays.Arrow,o]),jsPlumb.Overlays.canvas.PlainArrow=function(){p.apply(this,[jsPlumb.Overlays.PlainArrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.canvas.PlainArrow,[jsPlumb.Overlays.PlainArrow,o]),jsPlumb.Overlays.canvas.Diamond=function(){p.apply(this,[jsPlumb.Overlays.Diamond,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.canvas.Diamond,[jsPlumb.Overlays.Diamond,o])}(),function(){var a={joinstyle:"stroke-linejoin","stroke-linejoin":"stroke-linejoin","stroke-dashoffset":"stroke-dashoffset","stroke-linecap":"stroke-linecap"},b="stroke-dasharray",c="dashstyle",d="linearGradient",e="radialGradient",f="fill",g="stop",h="stroke",i="stroke-width",j="style",k="none",l="jsplumb_gradient_",m="lineWidth",n={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml"},o=function(a,b){for(var c in b)a.setAttribute(c,""+b[c])},p=function(a,b){var c=document.createElementNS(n.svg,a);return b=b||{},b.version="1.1",b.xmlns=n.xhtml,o(c,b),c},q=function(a){return"position:absolute;left:"+a[0]+"px;top:"+a[1]+"px"},r=function(a){for(var b=0;b<a.childNodes.length;b++)(a.childNodes[b].tagName==d||a.childNodes[b].tagName==e)&&a.removeChild(a.childNodes[b])},s=function(a,b,c,i,k){var m=l+k._jsPlumb.instance.idstamp();r(a);var n;n=c.gradient.offset?p(e,{id:m}):p(d,{id:m,gradientUnits:"userSpaceOnUse"}),a.appendChild(n);for(var o=0;o<c.gradient.stops.length;o++){var q=1==k.segment||2==k.segment?o:c.gradient.stops.length-1-o,s=jsPlumbUtil.convertStyle(c.gradient.stops[q][1],!0),t=p(g,{offset:Math.floor(100*c.gradient.stops[o][0])+"%","stop-color":s});n.appendChild(t)}var u=c.strokeStyle?h:f;b.setAttribute(j,u+":url(#"+m+")")},t=function(d,e,g,l,n){if(g.gradient?s(d,e,g,l,n):(r(d),e.setAttribute(j,"")),e.setAttribute(f,g.fillStyle?jsPlumbUtil.convertStyle(g.fillStyle,!0):k),e.setAttribute(h,g.strokeStyle?jsPlumbUtil.convertStyle(g.strokeStyle,!0):k),g.lineWidth&&e.setAttribute(i,g.lineWidth),g[c]&&g[m]&&!g[b]){var o=-1==g[c].indexOf(",")?" ":",",p=g[c].split(o),q="";p.forEach(function(a){q+=Math.floor(a*g.lineWidth)+o}),e.setAttribute(b,q)}else g[b]&&e.setAttribute(b,g[b]);for(var t in a)g[t]&&e.setAttribute(a[t],g[t])},u=function(a,b,c){for(var d=c.split(" "),e=a.className,f=e.baseVal.split(" "),g=0;g<d.length;g++)if(b)-1==f.indexOf(d[g])&&f.push(d[g]);else{var h=f.indexOf(d[g]);-1!=h&&f.splice(h,1)}a.className.baseVal=f.join(" ")},v=function(a,b){u(a,!0,b)},w=function(a,b){u(a,!1,b)},x=function(a,b,c){a.childNodes.length>c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};jsPlumbUtil.svg={addClass:v,removeClass:w,node:p,attr:o,pos:q};var y=function(a){var b=a.pointerEventsSpec||"all",c={};jsPlumb.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null;var d=a.cssClass+" "+(a.originalArgs[0].cssClass||""),e={style:"",width:0,height:0,"pointer-events":b,position:"absolute"};this.svg=p("svg",e),a.useDivWrapper?(this.canvas=document.createElement("div"),this.canvas.style.position="absolute",jsPlumbUtil.sizeElement(this.canvas,0,0,1,1),this.canvas.className=d):(o(this.svg,{"class":d}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var f=[this.canvas];return this.getDisplayElements=function(){return f},this.appendDisplayElement=function(a){f.push(a)},this.paint=function(b,d,e){if(null!=b){var f,g=[this.x,this.y],h=[this.w,this.h];null!=e&&(e.xmin<0&&(g[0]+=e.xmin),e.ymin<0&&(g[1]+=e.ymin),h[0]=e.xmax+(e.xmin<0?-e.xmin:0),h[1]=e.ymax+(e.ymin<0?-e.ymin:0)),a.useDivWrapper?(jsPlumbUtil.sizeElement(this.canvas,g[0],g[1],h[0],h[1]),g[0]=0,g[1]=0,f=q([0,0])):f=q([g[0],g[1]]),c.paint.apply(this,arguments),o(this.svg,{style:f,width:h[0],height:h[1]})}},{renderer:c}};jsPlumbUtil.extend(y,jsPlumb.jsPlumbUIComponent,{cleanup:function(){jsPlumbUtil.removeElement(this.canvas),this.svg=null,this.canvas=null,this.path=null},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none"),this.bgCanvas&&(this.bgCanvas.style.display=a?"block":"none")}}),jsPlumb.ConnectorRenderers.svg=function(a){var b=this,c=y.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);c.renderer.paint=function(c,d,e){var f=b.getSegments(),g="",h=[0,0];e.xmin<0&&(h[0]=-e.xmin),e.ymin<0&&(h[1]=-e.ymin);for(var i=0;i<f.length;i++)g+=jsPlumb.Segments.svg.SegmentRenderer.getPath(f[i]),g+=" ";var j={d:g,transform:"translate("+h[0]+","+h[1]+")","pointer-events":a["pointer-events"]||"visibleStroke"},k=null,l=[b.x,b.y,b.w,b.h];if(c.outlineColor){var m=c.outlineWidth||1,n=c.lineWidth+2*m;k=jsPlumb.CurrentLibrary.extend({},c),k.strokeStyle=jsPlumbUtil.convertStyle(c.outlineColor),k.lineWidth=n,null==b.bgPath?(b.bgPath=p("path",j),x(b.svg,b.bgPath,0),b.attachListeners(b.bgPath,b)):o(b.bgPath,j),t(b.svg,b.bgPath,k,l,b)}null==b.path?(b.path=p("path",j),x(b.svg,b.path,c.outlineColor?1:0),b.attachListeners(b.path,b)):o(b.path,j),t(b.svg,b.path,c,l,b)},this.reattachListeners=function(){this.bgPath&&this.reattachListenersForElement(this.bgPath,this),this.path&&this.reattachListenersForElement(this.path,this)}},jsPlumbUtil.extend(jsPlumb.ConnectorRenderers.svg,y),jsPlumb.Segments.svg={SegmentRenderer:{getPath:function(a){return{Straight:function(){var b=a.getCoordinates();return"M "+b.x1+" "+b.y1+" L "+b.x2+" "+b.y2},Bezier:function(){var b=a.params;return"M "+b.x1+" "+b.y1+" C "+b.cp1x+" "+b.cp1y+" "+b.cp2x+" "+b.cp2y+" "+b.x2+" "+b.y2},Arc:function(){var b=a.params,c=a.sweep>Math.PI?1:0,d=a.anticlockwise?0:1;return"M"+a.x1+" "+a.y1+" A "+a.radius+" "+b.r+" 0 "+c+","+d+" "+a.x2+" "+a.y2}}[a.type]()}}};var z=window.SvgEndpoint=function(a){var b=y.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);b.renderer.paint=function(a){var b=jsPlumb.extend({},a);b.outlineColor&&(b.strokeWidth=b.outlineWidth,b.strokeStyle=jsPlumbUtil.convertStyle(b.outlineColor,!0)),null==this.node?(this.node=this.makeNode(b),this.svg.appendChild(this.node),this.attachListeners(this.node,this)):null!=this.updateNode&&this.updateNode(this.node),t(this.svg,this.node,b,[this.x,this.y,this.w,this.h],this),q(this.node,[this.x,this.y])}.bind(this)};jsPlumbUtil.extend(z,y,{reattachListeners:function(){this.node&&this.reattachListenersForElement(this.node,this)}}),jsPlumb.Endpoints.svg.Dot=function(){jsPlumb.Endpoints.Dot.apply(this,arguments),z.apply(this,arguments),this.makeNode=function(){return p("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){o(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},jsPlumbUtil.extend(jsPlumb.Endpoints.svg.Dot,[jsPlumb.Endpoints.Dot,z]),jsPlumb.Endpoints.svg.Rectangle=function(){jsPlumb.Endpoints.Rectangle.apply(this,arguments),z.apply(this,arguments),this.makeNode=function(){return p("rect",{width:this.w,height:this.h})},this.updateNode=function(a){o(a,{width:this.w,height:this.h})}},jsPlumbUtil.extend(jsPlumb.Endpoints.svg.Rectangle,[jsPlumb.Endpoints.Rectangle,z]),jsPlumb.Endpoints.svg.Image=jsPlumb.Endpoints.Image,jsPlumb.Endpoints.svg.Blank=jsPlumb.Endpoints.Blank,jsPlumb.Overlays.svg.Label=jsPlumb.Overlays.Label,jsPlumb.Overlays.svg.Custom=jsPlumb.Overlays.Custom;var A=function(a,b){a.apply(this,b),jsPlumb.jsPlumbUIComponent.apply(this,b),this.isAppendedAtTopLevel=!1,this.path=null,this.paint=function(a,d){if(a.component.svg&&d){null==this.path&&(this.path=p("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.attachListeners(this.path,a.component),this.attachListeners(this.path,this));var e=b&&1==b.length?b[0].cssClass||"":"",f=[0,0];d.xmin<0&&(f[0]=-d.xmin),d.ymin<0&&(f[1]=-d.ymin),o(this.path,{d:c(a.d),"class":e,stroke:a.strokeStyle?a.strokeStyle:null,fill:a.fillStyle?a.fillStyle:null,transform:"translate("+f[0]+","+f[1]+")"})}};var c=function(a){return"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.reattachListeners=function(){this.path&&this.reattachListenersForElement(this.path,this)}};jsPlumbUtil.extend(A,[jsPlumb.jsPlumbUIComponent,jsPlumb.Overlays.AbstractOverlay],{cleanup:function(){null!=this.path&&jsPlumb.CurrentLibrary.removeElement(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),jsPlumb.Overlays.svg.Arrow=function(){A.apply(this,[jsPlumb.Overlays.Arrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.svg.Arrow,[jsPlumb.Overlays.Arrow,A]),jsPlumb.Overlays.svg.PlainArrow=function(){A.apply(this,[jsPlumb.Overlays.PlainArrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.svg.PlainArrow,[jsPlumb.Overlays.PlainArrow,A]),jsPlumb.Overlays.svg.Diamond=function(){A.apply(this,[jsPlumb.Overlays.Diamond,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.svg.Diamond,[jsPlumb.Overlays.Diamond,A]),jsPlumb.Overlays.svg.GuideLines=function(){var a,b,c=null,d=this;jsPlumb.Overlays.GuideLines.apply(this,arguments),this.paint=function(f,g){null==c&&(c=p("path"),f.connector.svg.appendChild(c),d.attachListeners(c,f.connector),d.attachListeners(c,d),a=p("path"),f.connector.svg.appendChild(a),d.attachListeners(a,f.connector),d.attachListeners(a,d),b=p("path"),f.connector.svg.appendChild(b),d.attachListeners(b,f.connector),d.attachListeners(b,d));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),o(c,{d:e(f.head,f.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),o(a,{d:e(f.tailLine[0],f.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),o(b,{d:e(f.headLine[0],f.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var e=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},jsPlumbUtil.extend(jsPlumb.Overlays.svg.GuideLines,jsPlumb.Overlays.GuideLines)}(),function(){var a={"stroke-linejoin":"joinstyle",joinstyle:"joinstyle",endcap:"endcap",miterlimit:"miterlimit"},b=null;if(document.createStyleSheet&&document.namespaces){var c=[".jsplumb_vml","jsplumb\\:textbox","jsplumb\\:oval","jsplumb\\:rect","jsplumb\\:stroke","jsplumb\\:shape","jsplumb\\:group"],d="behavior:url(#default#VML);position:absolute;";b=document.createStyleSheet();for(var e=0;e<c.length;e++)b.addRule(c[e],d);document.namespaces.add("jsplumb","urn:schemas-microsoft-com:vml")}jsPlumb.vml={};var f=1e3,g=function(a,b){for(var c in b)a[c]=b[c]},h=function(a,b,c,d,e,f){c=c||{};var h=document.createElement("jsplumb:"+a);return f?e.appendElement(h,d):jsPlumb.CurrentLibrary.appendElement(h,d),h.className=(c["class"]?c["class"]+" ":"")+"jsplumb_vml",i(h,b),g(h,c),h},i=function(a,b,c){a.style.left=b[0]+"px",a.style.top=b[1]+"px",a.style.width=b[2]+"px",a.style.height=b[3]+"px",a.style.position="absolute",c&&(a.style.zIndex=c)},j=jsPlumb.vml.convertValue=function(a){return Math.floor(a*f)},k=function(a,b,c,d){"transparent"===b?d.setOpacity(c,"0.0"):d.setOpacity(c,"1.0")},l=function(a,b,c,d){var e={};if(b.strokeStyle){e.stroked="true";var f=jsPlumbUtil.convertStyle(b.strokeStyle,!0);e.strokecolor=f,k(e,f,"stroke",c),e.strokeweight=b.lineWidth+"px"}else e.stroked="false";if(b.fillStyle){e.filled="true";var i=jsPlumbUtil.convertStyle(b.fillStyle,!0);e.fillcolor=i,k(e,i,"fill",c)}else e.filled="false";if(b.dashstyle)null==c.strokeNode?c.strokeNode=h("stroke",[0,0,0,0],{dashstyle:b.dashstyle},a,d):c.strokeNode.dashstyle=b.dashstyle;else if(b["stroke-dasharray"]&&b.lineWidth){for(var j=-1==b["stroke-dasharray"].indexOf(",")?" ":",",l=b["stroke-dasharray"].split(j),m="",n=0;n<l.length;n++)m+=Math.floor(l[n]/b.lineWidth)+j;null==c.strokeNode?c.strokeNode=h("stroke",[0,0,0,0],{dashstyle:m},a,d):c.strokeNode.dashstyle=m}g(a,e)},m=function(){var a=this;jsPlumb.jsPlumbUIComponent.apply(this,arguments),this.opacityNodes={stroke:null,fill:null},this.initOpacityNodes=function(b){a.opacityNodes.stroke=h("stroke",[0,0,1,1],{opacity:"0.0"},b,a._jsPlumb.instance),a.opacityNodes.fill=h("fill",[0,0,1,1],{opacity:"0.0"},b,a._jsPlumb.instance)},this.setOpacity=function(b,c){var d=a.opacityNodes[b];d&&(d.opacity=""+c)};var b=[];this.getDisplayElements=function(){return b},this.appendDisplayElement=function(c,d){d||a.canvas.parentNode.appendChild(c),b.push(c)}};jsPlumbUtil.extend(m,jsPlumb.jsPlumbUIComponent,{cleanup:function(){this.bgCanvas&&jsPlumbUtil.removeElement(this.bgCanvas),jsPlumbUtil.removeElement(this.canvas)}});var n=jsPlumb.ConnectorRenderers.vml=function(b){this.strokeNode=null,this.canvas=null,m.apply(this,arguments);var c=this._jsPlumb.instance.connectorClass+(b.cssClass?" "+b.cssClass:"");this.paint=function(d){if(null!==d){this.w=Math.max(this.w,1),this.h=Math.max(this.h,1);for(var e=this.getSegments(),j={path:""},k=[this.x,this.y,this.w,this.h],m=0;m<e.length;m++)j.path+=jsPlumb.Segments.vml.SegmentRenderer.getPath(e[m]),j.path+=" ";if(d.outlineColor){var n=d.outlineWidth||1,o=d.lineWidth+2*n,p={strokeStyle:jsPlumbUtil.convertStyle(d.outlineColor),lineWidth:o};for(var q in a)p[q]=d[q];null==this.bgCanvas?(j["class"]=c,j.coordsize=k[2]*f+","+k[3]*f,this.bgCanvas=h("shape",k,j,b.parent,this._jsPlumb.instance,!0),i(this.bgCanvas,k),this.appendDisplayElement(this.bgCanvas,!0),this.attachListeners(this.bgCanvas,this),this.initOpacityNodes(this.bgCanvas,["stroke"])):(j.coordsize=k[2]*f+","+k[3]*f,i(this.bgCanvas,k),g(this.bgCanvas,j)),l(this.bgCanvas,p,this)}null==this.canvas?(j["class"]=c,j.coordsize=k[2]*f+","+k[3]*f,this.canvas=h("shape",k,j,b.parent,this._jsPlumb.instance,!0),this.appendDisplayElement(this.canvas,!0),this.attachListeners(this.canvas,this),this.initOpacityNodes(this.canvas,["stroke"])):(j.coordsize=k[2]*f+","+k[3]*f,i(this.canvas,k),g(this.canvas,j)),l(this.canvas,d,this,this._jsPlumb.instance)}}};jsPlumbUtil.extend(n,m,{reattachListeners:function(){this.canvas&&this.reattachListenersForElement(this.canvas,this)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none"),this.bgCanvas&&(this.bgCanvas.style.display=a?"block":"none")}});var o=window.VmlEndpoint=function(a){m.apply(this,arguments),this._jsPlumb.vml=null,this.canvas=document.createElement("div"),this.canvas.style.position="absolute",this._jsPlumb.clazz=this._jsPlumb.instance.endpointClass+(a.cssClass?" "+a.cssClass:""),a._jsPlumb.appendElement(this.canvas,a.parent),this.paint=function(a,b){var c={},d=this._jsPlumb.vml;jsPlumbUtil.sizeElement(this.canvas,this.x,this.y,this.w,this.h),null==this._jsPlumb.vml?(c["class"]=this._jsPlumb.clazz,d=this._jsPlumb.vml=this.getVml([0,0,this.w,this.h],c,b,this.canvas,this._jsPlumb.instance),this.attachListeners(d,this),this.appendDisplayElement(d,!0),this.appendDisplayElement(this.canvas,!0),this.initOpacityNodes(d,["fill"])):(i(d,[0,0,this.w,this.h]),g(d,c)),l(d,a,this)}};jsPlumbUtil.extend(o,m,{reattachListeners:function(){this._jsPlumb.vml&&this.reattachListenersForElement(this._jsPlumb.vml,this)}}),jsPlumb.Segments.vml={SegmentRenderer:{getPath:function(a){return{Straight:function(a){var b=a.params;return"m"+j(b.x1)+","+j(b.y1)+" l"+j(b.x2)+","+j(b.y2)+" e"},Bezier:function(a){var b=a.params;return"m"+j(b.x1)+","+j(b.y1)+" c"+j(b.cp1x)+","+j(b.cp1y)+","+j(b.cp2x)+","+j(b.cp2y)+","+j(b.x2)+","+j(b.y2)+" e"},Arc:function(a){var b=a.params,c=Math.min(b.x1,b.x2),d=(Math.max(b.x1,b.x2),Math.min(b.y1,b.y2)),e=(Math.max(b.y1,b.y2),a.anticlockwise?1:0),f=a.anticlockwise?"at ":"wa ",g=function(){if(b.loopback)return"0,0,"+j(2*b.r)+","+j(2*b.r);var f=[null,[function(){return[c,d]},function(){return[c-b.r,d-b.r]}],[function(){return[c-b.r,d]},function(){return[c,d-b.r]}],[function(){return[c-b.r,d-b.r]},function(){return[c,d]}],[function(){return[c,d-b.r]},function(){return[c-b.r,d]}]][a.segment][e]();return j(f[0])+","+j(f[1])+","+j(f[0]+2*b.r)+","+j(f[1]+2*b.r)};return f+" "+g()+","+j(b.x1)+","+j(b.y1)+","+j(b.x2)+","+j(b.y2)+" e"}}[a.type](a)}}},jsPlumb.Endpoints.vml.Dot=function(){jsPlumb.Endpoints.Dot.apply(this,arguments),o.apply(this,arguments),this.getVml=function(a,b,c,d,e){return h("oval",a,b,d,e)}},jsPlumbUtil.extend(jsPlumb.Endpoints.vml.Dot,o),jsPlumb.Endpoints.vml.Rectangle=function(){jsPlumb.Endpoints.Rectangle.apply(this,arguments),o.apply(this,arguments),this.getVml=function(a,b,c,d,e){return h("rect",a,b,d,e)}},jsPlumbUtil.extend(jsPlumb.Endpoints.vml.Rectangle,o),jsPlumb.Endpoints.vml.Image=jsPlumb.Endpoints.Image,jsPlumb.Endpoints.vml.Blank=jsPlumb.Endpoints.Blank,jsPlumb.Overlays.vml.Label=jsPlumb.Overlays.Label,jsPlumb.Overlays.vml.Custom=jsPlumb.Overlays.Custom;
+var p=function(a,b){a.apply(this,b),m.apply(this,b);var c=this;c.canvas=null,c.isAppendedAtTopLevel=!0;var d=function(a){return"m "+j(a.hxy.x)+","+j(a.hxy.y)+" l "+j(a.tail[0].x)+","+j(a.tail[0].y)+" "+j(a.cxy.x)+","+j(a.cxy.y)+" "+j(a.tail[1].x)+","+j(a.tail[1].y)+" x e"};this.paint=function(a,e){if(a.component.canvas&&e){var j={},k=a.d,l=a.component;a.strokeStyle&&(j.stroked="true",j.strokecolor=jsPlumbUtil.convertStyle(a.strokeStyle,!0)),a.lineWidth&&(j.strokeweight=a.lineWidth+"px"),a.fillStyle&&(j.filled="true",j.fillcolor=a.fillStyle);var m=Math.min(k.hxy.x,k.tail[0].x,k.tail[1].x,k.cxy.x),n=Math.min(k.hxy.y,k.tail[0].y,k.tail[1].y,k.cxy.y),o=Math.max(k.hxy.x,k.tail[0].x,k.tail[1].x,k.cxy.x),p=Math.max(k.hxy.y,k.tail[0].y,k.tail[1].y,k.cxy.y),q=Math.abs(o-m),r=Math.abs(p-n),s=[m,n,q,r];if(j.path=d(k),j.coordsize=l.w*f+","+l.h*f,s[0]=l.x,s[1]=l.y,s[2]=l.w,s[3]=l.h,null==c.canvas){var t=l._jsPlumb.overlayClass||"",u=b&&1==b.length?b[0].cssClass||"":"";j["class"]=u+" "+t,c.canvas=h("shape",s,j,l.canvas.parentNode,l._jsPlumb.instance,!0),l.appendDisplayElement(c.canvas,!0),c.attachListeners(c.canvas,l),c.attachListeners(c.canvas,c)}else i(c.canvas,s),g(c.canvas,j)}},this.reattachListeners=function(){c.canvas&&c.reattachListenersForElement(c.canvas,c)},this.cleanup=function(){null!=c.canvas&&jsPlumb.CurrentLibrary.removeElement(c.canvas)}};jsPlumbUtil.extend(p,[m,jsPlumb.Overlays.AbstractOverlay],{setVisible:function(a){this.canvas.style.display=a?"block":"none"}}),jsPlumb.Overlays.vml.Arrow=function(){p.apply(this,[jsPlumb.Overlays.Arrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.vml.Arrow,[jsPlumb.Overlays.Arrow,p]),jsPlumb.Overlays.vml.PlainArrow=function(){p.apply(this,[jsPlumb.Overlays.PlainArrow,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.vml.PlainArrow,[jsPlumb.Overlays.PlainArrow,p]),jsPlumb.Overlays.vml.Diamond=function(){p.apply(this,[jsPlumb.Overlays.Diamond,arguments])},jsPlumbUtil.extend(jsPlumb.Overlays.vml.Diamond,[jsPlumb.Overlays.Diamond,p])}(),function(a){var b=function(b){return"string"==typeof b?a("#"+b):a(b)};jsPlumb.CurrentLibrary={addClass:function(a,c){a=b(a);try{a[0].className.constructor==SVGAnimatedString&&jsPlumbUtil.svg.addClass(a[0],c)}catch(d){}try{a.addClass(c)}catch(d){}},animate:function(a,b,c){a.animate(b,c)},appendElement:function(a,c){b(c).append(a)},ajax:function(b){b=b||{},b.type=b.type||"get",a.ajax(b)},bind:function(a,c,d){a=b(a),a.bind(c,d)},destroyDraggable:function(b){a(b).data("draggable")&&a(b).draggable("destroy")},destroyDroppable:function(b){a(b).data("droppable")&&a(b).droppable("destroy")},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete"},extend:function(b,c){return a.extend(b,c)},getClientXY:function(a){return[a.clientX,a.clientY]},getDragObject:function(a){return a[1].draggable||a[1].helper},getDragScope:function(b){return a(b).draggable("option","scope")},getDropEvent:function(a){return a[0]},getDropScope:function(b){return a(b).droppable("option","scope")},getDOMElement:function(a){return null==a?null:"string"==typeof a?document.getElementById(a):a.context||null!=a.length?a[0]:a},getElementObject:b,getOffset:function(a){return a.offset()},getOriginalEvent:function(a){return a.originalEvent},getPageXY:function(a){return[a.pageX,a.pageY]},getParent:function(a){return b(a).parent()},getScrollLeft:function(a){return a.scrollLeft()},getScrollTop:function(a){return a.scrollTop()},getSelector:function(c,d){return 2==arguments.length?b(c).find(d):a(c)},getSize:function(b){return b=a(b),[b.outerWidth(),b.outerHeight()]},getTagName:function(a){var c=b(a);return c.length>0?c[0].tagName:null},getUIPosition:function(a,b){if(b=b||1,1==a.length)ret={left:a[0].pageX,top:a[0].pageY};else{var c=a[1],d=c.offset;ret=d||c.absolutePosition,c.position.left/=b,c.position.top/=b}return{left:ret.left/b,top:ret.top/b}},hasClass:function(a,b){return a.hasClass(b)},initDraggable:function(b,c,d,e){c=c||{},b=a(b),c.start=jsPlumbUtil.wrap(c.start,function(){a("body").addClass(e.dragSelectClass)},!1),c.stop=jsPlumbUtil.wrap(c.stop,function(){a("body").removeClass(e.dragSelectClass)}),c.doNotRemoveHelper||(c.helper=null),d&&(c.scope=c.scope||jsPlumb.Defaults.Scope),b.draggable(c)},initDroppable:function(b,c){c.scope=c.scope||jsPlumb.Defaults.Scope,a(b).droppable(c)},isAlreadyDraggable:function(b){return a(b).hasClass("ui-draggable")},isDragSupported:function(b){return a(b).draggable},isDropSupported:function(b){return a(b).droppable},removeClass:function(a,c){a=b(a);try{if(a[0].className.constructor==SVGAnimatedString)return jsPlumbUtil.svg.removeClass(a[0],c),void 0}catch(d){}a.removeClass(c)},removeElement:function(a){b(a).remove()},setDragFilter:function(a,b){jsPlumb.CurrentLibrary.isAlreadyDraggable(a)&&a.draggable("option","cancel",b)},setDraggable:function(a,b){a.draggable("option","disabled",!b)},setDragScope:function(a,b){a.draggable("option","scope",b)},setOffset:function(a,c){b(a).offset(c)},trigger:function(a,c,d){var e=jQuery._data(b(a)[0],"handle");e(d)},unbind:function(a,c,d){a=b(a),a.unbind(c,d)}},a(document).ready(jsPlumb.init)}(jQuery);
diff --git a/www/js/json3.min.js b/www/js/json3.min.js
new file mode 100644 (file)
index 0000000..508e910
--- /dev/null
@@ -0,0 +1,17 @@
+/*! JSON v3.2.4 | http://bestiejs.github.com/json3 | Copyright 2012, Kit Cambridge | http://kit.mit-license.org */
+;(function(){var e=void 0,i=!0,k=null,l={}.toString,m,n,p="function"===typeof define&&define.c,q=!p&&"object"==typeof exports&&exports;q||p?"object"==typeof JSON&&JSON?p?q=JSON:(q.stringify=JSON.stringify,q.parse=JSON.parse):p&&(q=this.JSON={}):q=this.JSON||(this.JSON={});var r,t,u,x,z,B,C,D,E,F,G,H,I,J=new Date(-3509827334573292),K,O,P;try{J=-109252==J.getUTCFullYear()&&0===J.getUTCMonth()&&1==J.getUTCDate()&&10==J.getUTCHours()&&37==J.getUTCMinutes()&&6==J.getUTCSeconds()&&708==J.getUTCMilliseconds()}catch(Q){}
+function R(b){var c,a,d,j=b=="json";if(j||b=="json-stringify"||b=="json-parse"){if(b=="json-stringify"||j){if(c=typeof q.stringify=="function"&&J){(d=function(){return 1}).toJSON=d;try{c=q.stringify(0)==="0"&&q.stringify(new Number)==="0"&&q.stringify(new String)=='""'&&q.stringify(l)===e&&q.stringify(e)===e&&q.stringify()===e&&q.stringify(d)==="1"&&q.stringify([d])=="[1]"&&q.stringify([e])=="[null]"&&q.stringify(k)=="null"&&q.stringify([e,l,k])=="[null,null,null]"&&q.stringify({A:[d,i,false,k,"\x00\u0008\n\u000c\r\t"]})==
+'{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'&&q.stringify(k,d)==="1"&&q.stringify([1,2],k,1)=="[\n 1,\n 2\n]"&&q.stringify(new Date(-864E13))=='"-271821-04-20T00:00:00.000Z"'&&q.stringify(new Date(864E13))=='"+275760-09-13T00:00:00.000Z"'&&q.stringify(new Date(-621987552E5))=='"-000001-01-01T00:00:00.000Z"'&&q.stringify(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch(f){c=false}}if(!j)return c}if(b=="json-parse"||j){if(typeof q.parse=="function")try{if(q.parse("0")===0&&!q.parse(false)){d=
+q.parse('{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');if(a=d.a.length==5&&d.a[0]==1){try{a=!q.parse('"\t"')}catch(o){}if(a)try{a=q.parse("01")!=1}catch(g){}}}}catch(h){a=false}if(!j)return a}return c&&a}}
+if(!R("json")){J||(K=Math.floor,O=[0,31,59,90,120,151,181,212,243,273,304,334],P=function(b,c){return O[c]+365*(b-1970)+K((b-1969+(c=+(c>1)))/4)-K((b-1901+c)/100)+K((b-1601+c)/400)});if(!(m={}.hasOwnProperty))m=function(b){var c={},a;if((c.__proto__=k,c.__proto__={toString:1},c).toString!=l)m=function(a){var b=this.__proto__,a=a in(this.__proto__=k,this);this.__proto__=b;return a};else{a=c.constructor;m=function(b){var c=(this.constructor||a).prototype;return b in this&&!(b in c&&this[b]===c[b])}}c=
+k;return m.call(this,b)};n=function(b,c){var a=0,d,j,f;(d=function(){this.valueOf=0}).prototype.valueOf=0;j=new d;for(f in j)m.call(j,f)&&a++;d=j=k;if(a)a=a==2?function(a,b){var c={},d=l.call(a)=="[object Function]",f;for(f in a)!(d&&f=="prototype")&&!m.call(c,f)&&(c[f]=1)&&m.call(a,f)&&b(f)}:function(a,b){var c=l.call(a)=="[object Function]",d,f;for(d in a)!(c&&d=="prototype")&&m.call(a,d)&&!(f=d==="constructor")&&b(d);(f||m.call(a,d="constructor"))&&b(d)};else{j=["valueOf","toString","toLocaleString",
+"propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];a=function(a,b){var c=l.call(a)=="[object Function]",d;for(d in a)!(c&&d=="prototype")&&m.call(a,d)&&b(d);for(c=j.length;d=j[--c];m.call(a,d)&&b(d));}}a(b,c)};R("json-stringify")||(r={"\\":"\\\\",'"':'\\"',"\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},t=function(b,c){return("000000"+(c||0)).slice(-b)},u=function(b){for(var c='"',a=0,d;d=b.charAt(a);a++)c=c+('\\"\u0008\u000c\n\r\t'.indexOf(d)>-1?r[d]:r[d]=d<" "?
+"\\u00"+t(2,d.charCodeAt(0).toString(16)):d);return c+'"'},x=function(b,c,a,d,j,f,o){var g=c[b],h,s,v,w,L,M,N,y,A;if(typeof g=="object"&&g){h=l.call(g);if(h=="[object Date]"&&!m.call(g,"toJSON"))if(g>-1/0&&g<1/0){if(P){v=K(g/864E5);for(h=K(v/365.2425)+1970-1;P(h+1,0)<=v;h++);for(s=K((v-P(h,0))/30.42);P(h,s+1)<=v;s++);v=1+v-P(h,s);w=(g%864E5+864E5)%864E5;L=K(w/36E5)%24;M=K(w/6E4)%60;N=K(w/1E3)%60;w=w%1E3}else{h=g.getUTCFullYear();s=g.getUTCMonth();v=g.getUTCDate();L=g.getUTCHours();M=g.getUTCMinutes();
+N=g.getUTCSeconds();w=g.getUTCMilliseconds()}g=(h<=0||h>=1E4?(h<0?"-":"+")+t(6,h<0?-h:h):t(4,h))+"-"+t(2,s+1)+"-"+t(2,v)+"T"+t(2,L)+":"+t(2,M)+":"+t(2,N)+"."+t(3,w)+"Z"}else g=k;else if(typeof g.toJSON=="function"&&(h!="[object Number]"&&h!="[object String]"&&h!="[object Array]"||m.call(g,"toJSON")))g=g.toJSON(b)}a&&(g=a.call(c,b,g));if(g===k)return"null";h=l.call(g);if(h=="[object Boolean]")return""+g;if(h=="[object Number]")return g>-1/0&&g<1/0?""+g:"null";if(h=="[object String]")return u(g);if(typeof g==
+"object"){for(b=o.length;b--;)if(o[b]===g)throw TypeError();o.push(g);y=[];c=f;f=f+j;if(h=="[object Array]"){s=0;for(b=g.length;s<b;A||(A=i),s++){h=x(s,g,a,d,j,f,o);y.push(h===e?"null":h)}b=A?j?"[\n"+f+y.join(",\n"+f)+"\n"+c+"]":"["+y.join(",")+"]":"[]"}else{n(d||g,function(b){var c=x(b,g,a,d,j,f,o);c!==e&&y.push(u(b)+":"+(j?" ":"")+c);A||(A=i)});b=A?j?"{\n"+f+y.join(",\n"+f)+"\n"+c+"}":"{"+y.join(",")+"}":"{}"}o.pop();return b}},q.stringify=function(b,c,a){var d,j,f,o,g,h;if(typeof c=="function"||
+typeof c=="object"&&c)if(l.call(c)=="[object Function]")j=c;else if(l.call(c)=="[object Array]"){f={};o=0;for(g=c.length;o<g;h=c[o++],(l.call(h)=="[object String]"||l.call(h)=="[object Number]")&&(f[h]=1));}if(a)if(l.call(a)=="[object Number]"){if((a=a-a%1)>0){d="";for(a>10&&(a=10);d.length<a;d=d+" ");}}else l.call(a)=="[object String]"&&(d=a.length<=10?a:a.slice(0,10));return x("",(h={},h[""]=b,h),j,f,d,"",[])});R("json-parse")||(z=String.fromCharCode,B={"\\":"\\",'"':'"',"/":"/",b:"\u0008",t:"\t",
+n:"\n",f:"\u000c",r:"\r"},C=function(){H=I=k;throw SyntaxError();},D=function(){for(var b=I,c=b.length,a,d,j,f,o;H<c;){a=b.charAt(H);if("\t\r\n ".indexOf(a)>-1)H++;else{if("{}[]:,".indexOf(a)>-1){H++;return a}if(a=='"'){d="@";for(H++;H<c;){a=b.charAt(H);if(a<" ")C();else if(a=="\\"){a=b.charAt(++H);if('\\"/btnfr'.indexOf(a)>-1){d=d+B[a];H++}else if(a=="u"){j=++H;for(f=H+4;H<f;H++){a=b.charAt(H);a>="0"&&a<="9"||a>="a"&&a<="f"||a>="A"&&a<="F"||C()}d=d+z("0x"+b.slice(j,H))}else C()}else{if(a=='"')break;
+d=d+a;H++}}if(b.charAt(H)=='"'){H++;return d}}else{j=H;if(a=="-"){o=i;a=b.charAt(++H)}if(a>="0"&&a<="9"){for(a=="0"&&(a=b.charAt(H+1),a>="0"&&a<="9")&&C();H<c&&(a=b.charAt(H),a>="0"&&a<="9");H++);if(b.charAt(H)=="."){for(f=++H;f<c&&(a=b.charAt(f),a>="0"&&a<="9");f++);f==H&&C();H=f}a=b.charAt(H);if(a=="e"||a=="E"){a=b.charAt(++H);(a=="+"||a=="-")&&H++;for(f=H;f<c&&(a=b.charAt(f),a>="0"&&a<="9");f++);f==H&&C();H=f}return+b.slice(j,H)}o&&C();if(b.slice(H,H+4)=="true"){H=H+4;return i}if(b.slice(H,H+5)==
+"false"){H=H+5;return false}if(b.slice(H,H+4)=="null"){H=H+4;return k}}C()}}return"$"},E=function(b){var c,a;b=="$"&&C();if(typeof b=="string"){if(b.charAt(0)=="@")return b.slice(1);if(b=="["){for(c=[];;a||(a=i)){b=D();if(b=="]")break;if(a)if(b==","){b=D();b=="]"&&C()}else C();b==","&&C();c.push(E(b))}return c}if(b=="{"){for(c={};;a||(a=i)){b=D();if(b=="}")break;if(a)if(b==","){b=D();b=="}"&&C()}else C();(b==","||typeof b!="string"||b.charAt(0)!="@"||D()!=":")&&C();c[b.slice(1)]=E(D())}return c}C()}return b},
+G=function(b,c,a){a=F(b,c,a);a===e?delete b[c]:b[c]=a},F=function(b,c,a){var d=b[c],j;if(typeof d=="object"&&d)if(l.call(d)=="[object Array]")for(j=d.length;j--;)G(d,j,a);else n(d,function(b){G(d,b,a)});return a.call(b,c,d)},q.parse=function(b,c){var a,d;H=0;I=b;a=E(D());D()!="$"&&C();H=I=k;return c&&l.call(c)=="[object Function]"?F((d={},d[""]=a,d),"",c):a})}p&&define(function(){return q});
+}());
\ No newline at end of file