diff --git a/qcodes/__init__.py b/qcodes/__init__.py index 542d2c10359..cfa0e3f04a6 100644 --- a/qcodes/__init__.py +++ b/qcodes/__init__.py @@ -32,6 +32,13 @@ from qcodes.loops import Loop, active_loop, active_data_set from qcodes.measure import Measure from qcodes.actions import Task, Wait, BreakIf +haswebsockets = True +try: + import websockets +except ImportError: + haswebsockets = False +if haswebsockets: + from qcodes.monitor.monitor import Monitor from qcodes.data.data_set import DataSet, new_data, load_data from qcodes.data.location import FormatLocation diff --git a/qcodes/monitor/__init__.py b/qcodes/monitor/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/qcodes/monitor/dist/css/main.0963d6b9.css b/qcodes/monitor/dist/css/main.0963d6b9.css new file mode 100644 index 00000000000..911f710db2c --- /dev/null +++ b/qcodes/monitor/dist/css/main.0963d6b9.css @@ -0,0 +1 @@ +body{font-family:Source Sans Pro,Trebuchet MS,Lucida Grande,Bitstream Vera Sans,Helvetica Neue,sans-serif;font-size:13px;margin:0;text-align:center;color:#293c4b}.header{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.parameters{margin:1em}.table-fill{background:#fff;border-radius:8px;border-collapse:collapse;height:320px;margin:auto;max-width:600px;padding:5px;width:100%;box-shadow:0 5px 10px rgba(0,0,0,.1)}.parameters th{color:#d5dde5;background:#1b1e24;border-bottom:4px solid #9ea7af;border-right:1px solid #343a45;font-size:13px;font-weight:100;padding:5px;text-align:left;text-shadow:0 1px 1px rgba(0,0,0,.1);vertical-align:middle}.parameters th:first-child{border-top-left-radius:3px}.parameters th:last-child{border-top-right-radius:3px;border-right:none}.parameters tr{border-top:1px solid #c1c3d1;border-bottom-:1px solid #c1c3d1;color:#666b85;font-size:13px;font-weight:400;text-shadow:0 1px 1px hsla(0,0%,100%,.1)}.parameters tr:hover td{background:#4e5066;color:#fff;border-top:1px solid #22262e;border-bottom:1px solid #22262e}.parameters tr:first-child{border-top:none}.parameters tr:last-child{border-bottom:none}.parameters tr:nth-child(odd) td{background:#ebebeb}.parameters tr:nth-child(odd):hover td{background:#4e5066}.parameters tr:last-child td:first-child{border-bottom-left-radius:3px}.parameters tr:last-child td:last-child{border-bottom-right-radius:3px}.parameters td{background:#fff;padding:3px;text-align:left;vertical-align:middle;font-weight:300;font-size:13px;text-shadow:-1px -1px 1px rgba(0,0,0,.1);border-right:1px solid #c1c3d1}.parameters td:last-child{border-right:0}.instrument{margin:5px;text-align:left}.instrument :hover{background:#4e5066;color:#fff}.parametersContainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap} \ No newline at end of file diff --git a/qcodes/monitor/dist/favicon.ico b/qcodes/monitor/dist/favicon.ico new file mode 100644 index 00000000000..d7057bd07e9 Binary files /dev/null and b/qcodes/monitor/dist/favicon.ico differ diff --git a/qcodes/monitor/dist/index.html b/qcodes/monitor/dist/index.html new file mode 100644 index 00000000000..12db717023c --- /dev/null +++ b/qcodes/monitor/dist/index.html @@ -0,0 +1 @@ +QCoDeS montior
\ No newline at end of file diff --git a/qcodes/monitor/dist/js/main.b221ee88.js b/qcodes/monitor/dist/js/main.b221ee88.js new file mode 100644 index 00000000000..08c84d652c7 --- /dev/null +++ b/qcodes/monitor/dist/js/main.b221ee88.js @@ -0,0 +1,3 @@ +!function(t){function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var e={};return r.m=t,r.c=e,r.p="/",r(0)}([function(t,r,e){t.exports=e(1)},function(t,r,e){e(2);var n=e(6),o=document.getElementById("root"),u=Date.now();n.Main.embed(o,{startTime:u})},function(t,r){},,,,function(t,r){(function(){"use strict";function r(t){function r(r){return function(e){return t(r,e)}}return r.arity=2,r.func=t,r}function e(t){function r(r){return function(e){return function(n){return t(r,e,n)}}}return r.arity=3,r.func=t,r}function n(t){function r(r){return function(e){return function(n){return function(o){return t(r,e,n,o)}}}}return r.arity=4,r.func=t,r}function o(t){function r(r){return function(e){return function(n){return function(o){return function(u){return t(r,e,n,o,u)}}}}}return r.arity=5,r.func=t,r}function u(t){function r(r){return function(e){return function(n){return function(o){return function(u){return function(c){return t(r,e,n,o,u,c)}}}}}}return r.arity=6,r.func=t,r}function c(t){function r(r){return function(e){return function(n){return function(o){return function(u){return function(c){return function(a){return t(r,e,n,o,u,c,a)}}}}}}}return r.arity=7,r.func=t,r}function a(t){function r(r){return function(e){return function(n){return function(o){return function(u){return function(c){return function(a){return function(i){return t(r,e,n,o,u,c,a,i)}}}}}}}}return r.arity=8,r.func=t,r}function i(t){function r(r){return function(e){return function(n){return function(o){return function(u){return function(c){return function(a){return function(i){return function(f){return t(r,e,n,o,u,c,a,i,f)}}}}}}}}}return r.arity=9,r.func=t,r}function f(t,r,e){return 2===t.arity?t.func(r,e):t(r)(e)}function _(t,r,e,n){return 3===t.arity?t.func(r,e,n):t(r)(e)(n)}function l(t,r,e,n,o){return 4===t.arity?t.func(r,e,n,o):t(r)(e)(n)(o)}function s(t,r,e,n,o,u){return 5===t.arity?t.func(r,e,n,o,u):t(r)(e)(n)(o)(u)}function d(t,r,e,n,o,u,c){return 6===t.arity?t.func(r,e,n,o,u,c):t(r)(e)(n)(o)(u)(c)}var h=function(){function t(t,r){if(t<0||t>=D(r))throw new Error("Index "+t+" is out of range. Check the length of your array first or use getMaybe or getWithDefault.");return n(t,r)}function n(t,r){for(var e=r.height;e>0;e--){for(var n=t>>5*e;r.lengths[n]<=t;)n++;n>0&&(t-=r.lengths[n-1]),r=r.table[n]}return r.table[t]}function o(t,r,e){return t<0||D(e)<=t?e:u(t,r,e)}function u(t,r,e){if(e=I(e),0===e.height)e.table[t]=r;else{var n=J(t,e);n>0&&(t-=e.lengths[n-1]),e.table[n]=u(t,r,e.table[n])}return e}function c(t,r){if(t<=0)return G;var e=Math.floor(Math.log(t)/Math.log(K));return a(r,e,0,t)}function a(t,r,e,n){if(0===r){for(var o=new Array((n-e)%(K+1)),u=0;u0?i[u-1]:0);return{ctor:"_Array",height:r,table:o,lengths:i}}function i(t){if("[]"===t.ctor)return G;for(var r=new Array(K),e=[],n=0;"[]"!==t.ctor;)if(r[n]=t._0,t=t._1,n++,n===K){var o={ctor:"_Array",height:0,table:r};_(o,e),r=new Array(K),n=0}if(n>0){var o={ctor:"_Array",height:0,table:r.splice(0,n)};_(o,e)}for(var u=0;u0&&_(e[u],e);var c=e[e.length-1];return c.height>0&&1===c.table.length?c.table[0]:c}function _(t,r){var e=t.height;if(r.length===e){var n={ctor:"_Array",height:e+1,table:[],lengths:[]};r.push(n)}r[e].table.push(t);var o=D(t);r[e].lengths.length>0&&(o+=r[e].lengths[r[e].lengths.length-1]),r[e].lengths.push(o),r[e].table.length===K&&(_(r[e],r),r[e]={ctor:"_Array",height:e+1,table:[],lengths:[]})}function l(t,r){var e=s(t,r);if(null!==e)return e;var n=j(t,r.height);return W(r,n)}function s(t,r){if(0===r.height){if(r.table.length=0;e--)t=0===r.height?E.Cons(r.table[e],t):h(t,r.table[e]);return t}function v(t,r){var e={ctor:"_Array",height:r.height,table:new Array(r.table.length)};r.height>0&&(e.lengths=r.lengths);for(var n=0;n0&&(n.lengths=r.lengths);for(var o=0;o0?r.lengths[n-1]:0),r.table[n]);if(0===n)return o;var e={ctor:"_Array",height:r.height,table:r.table.slice(0,n),lengths:r.lengths.slice(0,n)};return o.table.length>0&&(e.table[n]=o,e.lengths[n]=D(o)+(n>0?e.lengths[n-1]:0)),e}function w(t,r){if(0===t)return r;if(0===r.height){var e={ctor:"_Array",height:0};return e.table=r.table.slice(t,r.table.length+1),e}var n=J(t,r),o=w(t-(n>0?r.lengths[n-1]:0),r.table[n]);if(n===r.table.length-1)return o;var e={ctor:"_Array",height:r.height,table:r.table.slice(n,r.table.length+1),lengths:new Array(r.table.length-n)};e.table[0]=o;for(var u=0,c=0;c0){for(var n=D(e[0]),o=0;o0){var u=x(t,r);u>$&&(e=O(e[0],e[1],u))}return W(e[0],e[1])}function N(t,r){if(0===t.height&&0===r.height)return[t,r];if(1!==t.height||1!==r.height)if(t.height===r.height){t=I(t),r=I(r);var e=N(L(t),P(r));B(t,e[1]),R(r,e[0])}else if(t.height>r.height){t=I(t);var e=N(L(t),r);B(t,e[0]),r=F(e[1],e[1].height+1)}else{r=I(r);var e=N(t,P(r)),n=0===e[0].table.length?0:1,o=0===n?1:0;R(r,e[n]),t=F(e[o],e[o].height+1)}if(0===t.table.length||0===r.table.length)return[t,r];var u=x(t,r);return u<=$?[t,r]:O(t,r,u)}function B(t,r){var e=t.table.length-1;t.table[e]=r,t.lengths[e]=D(r),t.lengths[e]+=e>0?t.lengths[e-1]:0}function R(t,r){if(r.table.length>0){t.table[0]=r,t.lengths[0]=D(r);for(var e=D(t.table[0]),n=1;n0&&(e.lengths=new Array(r)),e}function O(t,r,e){for(var n=M(t.height,Math.min(K,t.table.length+r.table.length-e)),o=M(t.height,n.table.length-(t.table.length+r.table.length-e)),u=0;A(t.table,r.table,u).table.length%K===0;)S(n.table,o.table,u,A(t.table,r.table,u)),S(n.lengths,o.lengths,u,A(t.lengths,r.lengths,u)),u++;for(var c=u,a=new M(t.height-1,0),i=0;u-c-(a.table.length>0?1:0)0)for(var l=a.lengths.length,s=l;s0?a.lengths[s-1]:0;i+=_,f.table.length<=_&&(u++,i=0),a.table.length===K&&(C(n,o,c,a),a=M(t.height-1,0),c++)}for(a.table.length>0&&(C(n,o,c,a),c++);u0&&(r.lengths=t.lengths.slice()),r}function D(t){return 0===t.height?t.table.length:t.lengths[t.lengths.length-1]}function J(t,r){for(var e=t>>5*r.height;r.lengths[e]<=t;)e++;return e}function j(t,r){return 0===r?{ctor:"_Array",height:0,table:[t]}:{ctor:"_Array",height:r,table:[j(t,r-1)],lengths:[1]}}function F(t,r){return r===t.height?t:{ctor:"_Array",height:r,table:[F(t,r-1)],lengths:[D(t)]}}function W(t,r){return{ctor:"_Array",height:t.height+1,table:[t,r],lengths:[D(t),D(t)+D(r)]}}function q(t){var r=new Array(D(t));return U(r,0,t),r}function U(t,r,e){for(var n=0;n0?c[a-1]:0);return{ctor:"_Array",height:r,table:u,lengths:c}}var K=32,$=2,G={ctor:"_Array",height:0,table:[]};return{empty:G,fromList:i,toList:d,initialize:r(c),append:r(T),push:r(l),slice:e(y),get:r(t),set:e(o),map:r(v),indexedMap:r(g),foldl:e(m),foldr:e(b),length:D,toJSArray:q,fromJSArray:z}}(),v=function(){function t(t,r){return t/r|0}function n(t,r){return t%r}function o(t,r){if(0===r)throw new Error("Cannot perform mod 0. Division by zero error.");var e=t%r,n=0===t?0:r>0?t>=0?e:e+r:-o(-t,-r);return n===r?0:n}function u(t,r){return Math.log(r)/Math.log(t)}function c(t){return-t}function a(t){return t<0?-t:t}function i(t,r){return g.cmp(t,r)<0?t:r}function f(t,r){return g.cmp(t,r)>0?t:r}function _(t,r,e){return g.cmp(e,t)<0?t:g.cmp(e,r)>0?r:e}function l(t,r){return{ctor:k[g.cmp(t,r)+1]}}function s(t,r){return t!==r}function d(t){return!t}function h(t){return t===1/0||t===-(1/0)}function v(t){return 0|t}function p(t){return t*Math.PI/180}function m(t){return 2*Math.PI*t}function b(t){var r=t._0,e=t._1;return g.Tuple2(r*Math.cos(e),r*Math.sin(e))}function y(t){var r=t._0,e=t._1;return g.Tuple2(Math.sqrt(r*r+e*e),Math.atan2(e,r))}var k=["LT","EQ","GT"];return{div:r(t),rem:r(n),mod:r(o),pi:Math.PI,e:Math.E,cos:Math.cos,sin:Math.sin,tan:Math.tan,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:r(Math.atan2),degrees:p,turns:m,fromPolar:b,toPolar:y,sqrt:Math.sqrt,logBase:r(u),negate:c,abs:a,min:r(i),max:r(f),clamp:e(_),compare:r(l),xor:r(s),not:d,truncate:v,ceiling:Math.ceil,floor:Math.floor,round:Math.round,toFloat:function(t){return t},isNaN:isNaN,isInfinite:h}}(),g=function(){function t(t,r){for(var n,o=[],u=e(t,r,0,o);u&&(n=o.pop());)u=e(n.x,n.y,0,o);return u}function e(t,r,n,o){if(n>100)return o.push({x:t,y:r}),!0;if(t===r)return!0;if("object"!=typeof t){if("function"==typeof t)throw new Error('Trying to use `(==)` on functions. There is no way to know if functions are "the same" in the Elm sense. Read more about this at http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#== which describes why it is this way and what the better version will look like.');return!1}if(null===t||null===r)return!1;if(t instanceof Date)return t.getTime()===r.getTime();if(!("ctor"in t)){for(var u in t)if(!e(t[u],r[u],n+1,o))return!1;return!0}if("RBNode_elm_builtin"!==t.ctor&&"RBEmpty_elm_builtin"!==t.ctor||(t=ut(t),r=ut(r)),"Set_elm_builtin"===t.ctor&&(t=_elm_lang$core$Set$toList(t),r=_elm_lang$core$Set$toList(r)),"::"===t.ctor){for(var c=t,a=r;"::"===c.ctor&&"::"===a.ctor;){if(!e(c._0,a._0,n+1,o))return!1;c=c._1,a=a._1}return c.ctor===a.ctor}if("_Array"===t.ctor){var i=h.toJSArray(t),f=h.toJSArray(r);if(i.length!==f.length)return!1;for(var _=0;_=1){if(u=n(t._0,r._0),u!==p)return u;if(c>=2){if(u=n(t._1,r._1),u!==p)return u;if(c>=3){if(u=n(t._2,r._2),u!==p)return u;if(c>=4){if(u=n(t._3,r._3),u!==p)return u;if(c>=5){if(u=n(t._4,r._4),u!==p)return u;if(c>=6){if(u=n(t._5,r._5),u!==p)return u;if(c>=7)throw new Error("Comparison error: "+a)}}}}}}return p}throw new Error("Comparison error: comparison is only defined on ints, floats, times, chars, strings, lists of comparable values, and tuples of comparable values.")}function o(t,r){return{ctor:"_Tuple2",_0:t,_1:r}}function u(t){return new String(t)}function c(t){return y++}function a(t,r){var e={};for(var n in t)e[n]=t[n];for(var n in r)e[n]=r[n];return e}function i(t,r){return{ctor:"::",_0:t,_1:r}}function f(t,r){if("string"==typeof t)return t+r;if("[]"===t.ctor)return r;var e=i(t._0,k),n=e;for(t=t._1;"[]"!==t.ctor;)n._1=i(t._0,k),t=t._1,n=n._1;return n._1=r,e}function _(t,r){return function(e){throw new Error("Ran into a `Debug.crash` in module `"+t+"` "+s(r)+"\nThe message provided by the code author is:\n\n "+e)}}function l(t,r,e){return function(n){throw new Error("Ran into a `Debug.crash` in module `"+t+"`\n\nThis was caused by the `case` expression "+s(r)+".\nOne of the branches ended with a crash and the following value got through:\n\n "+d(e)+"\n\nThe message provided by the code author is:\n\n "+n)}}function s(t){return t.start.line==t.end.line?"on line "+t.start.line:"between lines "+t.start.line+" and "+t.end.line}function d(t){var r=typeof t;if("function"===r)return"";if("boolean"===r)return t?"True":"False";if("number"===r)return t+"";if(t instanceof String)return"'"+v(t,!0)+"'";if("string"===r)return'"'+v(t,!1)+'"';if(null===t)return"null";if("object"===r&&"ctor"in t){var e=t.ctor.substring(0,5);if("_Tupl"===e){var n=[];for(var o in t)"ctor"!==o&&n.push(d(t[o]));return"("+n.join(",")+")"}if("_Task"===e)return"";if("_Array"===t.ctor){var u=G(t);return"Array.fromList "+d(u)}if(""===t.ctor)return"";if("_Process"===t.ctor)return"";if("::"===t.ctor){var n="["+d(t._0);for(t=t._1;"::"===t.ctor;)n+=","+d(t._0),t=t._1;return n+"]"}if("[]"===t.ctor)return"[]";if("Set_elm_builtin"===t.ctor)return"Set.fromList "+d(_elm_lang$core$Set$toList(t));if("RBNode_elm_builtin"===t.ctor||"RBEmpty_elm_builtin"===t.ctor)return"Dict.fromList "+d(ut(t));var n="";for(var c in t)if("ctor"!==c){var a=d(t[c]),i=a[0],f="{"===i||"("===i||"<"===i||'"'===i||a.indexOf(" ")<0;n+=" "+(f?a:"("+a+")")}return t.ctor+n}if("object"===r){if(t instanceof Date)return"<"+t.toString()+">";if(t.elm_web_socket)return"";var n=[];for(var o in t)n.push(o+" = "+d(t[o]));return 0===n.length?"{}":"{ "+n.join(", ")+" }"}return""}function v(t,r){var e=t.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/\v/g,"\\v").replace(/\0/g,"\\0");return r?e.replace(/\'/g,"\\'"):e.replace(/\"/g,'\\"')}var g=-1,p=0,m=1,b={ctor:"_Tuple0"},y=0,k={ctor:"[]"};return{eq:t,cmp:n,Tuple0:b,Tuple2:o,chr:u,update:a,guid:c,append:r(f),crash:_,crashCase:l,toString:d}}(),p=(r(function(t,r){var e=r;return f(t,e._0,e._1)}),e(function(t,r,e){return t({ctor:"_Tuple2",_0:r,_1:e})}),e(function(t,r,e){return f(t,e,r)}),r(function(t,r){return t})),m=function(t){return t},b=b||{};b["<|"]=r(function(t,r){return t(r)});var b=b||{};b["|>"]=r(function(t,r){return r(t)});var b=b||{};b[">>"]=e(function(t,r,e){return r(t(e))});var b=b||{};b["<<"]=e(function(t,r,e){return t(r(e))});var b=b||{};b["++"]=g.append;var y=g.toString,k=(v.isInfinite,v.isNaN,v.toFloat),b=(v.ceiling,v.floor,v.truncate,v.round,v.not,v.xor,b||{});b["||"]=v.or;var b=b||{};b["&&"]=v.and;var w=(v.max,v.min,v.compare),b=b||{};b[">="]=v.ge;var b=b||{};b["<="]=v.le;var b=b||{};b[">"]=v.gt;var b=b||{};b["<"]=v.lt;var b=b||{};b["/="]=v.neq;var b=b||{};b["=="]=v.eq;var b=(v.e,v.pi,v.clamp,v.logBase,v.abs,v.negate,v.sqrt,v.atan2,v.atan,v.asin,v.acos,v.tan,v.sin,v.cos,b||{});b["^"]=v.exp;var b=b||{};b["%"]=v.mod;var b=(v.rem,b||{});b["//"]=v.div;var b=b||{};b["/"]=v.floatDiv;var b=b||{};b["*"]=v.mul;var b=b||{};b["-"]=v.sub;var b=b||{};b["+"]=v.add;var T=(v.toPolar,v.fromPolar,v.turns,v.degrees,r(function(t,r){var e=r;return"Just"===e.ctor?e._0:t})),N={ctor:"Nothing"},B=(r(function(t,r){var e=r;return"Just"===e.ctor?t(e._0):N}),function(t){return{ctor:"Just",_0:t}}),R=(r(function(t,r){var e=r;return"Just"===e.ctor?B(t(e._0)):N}),e(function(t,r,e){var n={ctor:"_Tuple2",_0:r,_1:e};return"_Tuple2"===n.ctor&&"Just"===n._0.ctor&&"Just"===n._1.ctor?B(f(t,n._0._0,n._1._0)):N})),E=(n(function(t,r,e,n){var o={ctor:"_Tuple3",_0:r,_1:e,_2:n};return"_Tuple3"===o.ctor&&"Just"===o._0.ctor&&"Just"===o._1.ctor&&"Just"===o._2.ctor?B(_(t,o._0._0,o._1._0,o._2._0)):N}),o(function(t,r,e,n,o){var u={ctor:"_Tuple4",_0:r,_1:e,_2:n,_3:o};return"_Tuple4"===u.ctor&&"Just"===u._0.ctor&&"Just"===u._1.ctor&&"Just"===u._2.ctor&&"Just"===u._3.ctor?B(l(t,u._0._0,u._1._0,u._2._0,u._3._0)):N}),u(function(t,r,e,n,o,u){var c={ctor:"_Tuple5",_0:r,_1:e,_2:n,_3:o,_4:u};return"_Tuple5"===c.ctor&&"Just"===c._0.ctor&&"Just"===c._1.ctor&&"Just"===c._2.ctor&&"Just"===c._3.ctor&&"Just"===c._4.ctor?B(s(t,c._0._0,c._1._0,c._2._0,c._3._0,c._4._0)):N}),function(){function t(t,r){return{ctor:"::",_0:t,_1:r}}function c(r){for(var e=y,n=r.length;n--;)e=t(r[n],e);return e}function a(t){for(var r=[];"[]"!==t.ctor;)r.push(t._0),t=t._1;return r}function i(t,r,e){for(var n=a(e),o=r,u=n.length;u--;)o=f(t,n[u],o);return o}function d(t,r,e){for(var n=[];"[]"!==r.ctor&&"[]"!==e.ctor;)n.push(f(t,r._0,e._0)),r=r._1,e=e._1;return c(n)}function h(t,r,e,n){for(var o=[];"[]"!==r.ctor&&"[]"!==e.ctor&&"[]"!==n.ctor;)o.push(_(t,r._0,e._0,n._0)),r=r._1,e=e._1,n=n._1;return c(o)}function v(t,r,e,n,o){for(var u=[];"[]"!==r.ctor&&"[]"!==e.ctor&&"[]"!==n.ctor&&"[]"!==o.ctor;)u.push(l(t,r._0,e._0,n._0,o._0)),r=r._1,e=e._1,n=n._1,o=o._1;return c(u)}function p(t,r,e,n,o,u){for(var a=[];"[]"!==r.ctor&&"[]"!==e.ctor&&"[]"!==n.ctor&&"[]"!==o.ctor&&"[]"!==u.ctor;)a.push(s(t,r._0,e._0,n._0,o._0,u._0)),r=r._1,e=e._1,n=n._1,o=o._1,u=u._1;return c(a)}function m(t,r){return c(a(r).sort(function(r,e){return g.cmp(t(r),t(e))}))}function b(t,r){return c(a(r).sort(function(r,e){var n=t(r)(e).ctor;return"EQ"===n?0:"LT"===n?-1:1}))}var y={ctor:"[]"};return{Nil:y,Cons:t,cons:r(t),toArray:a,fromArray:c,foldr:e(i),map2:e(d),map3:n(h),map4:o(v),map5:u(p),sortBy:r(m),sortWith:r(b)}}()),x=(E.sortWith,E.sortBy,r(function(t,r){for(;;){if(g.cmp(t,0)<1)return r;var e=r;if("[]"===e.ctor)return r;var n=t-1,o=e._1;t=n,r=o}}),E.map5,E.map4,E.map3,E.map2),A=r(function(t,r){for(;;){var e=r;if("[]"===e.ctor)return!1;if(t(e._0))return!0;var n=t,o=e._1;t=n,r=o}}),S=(r(function(t,r){return!f(A,function(r){return!t(r)},r)}),E.foldr),C=e(function(t,r,e){for(;;){var n=e;if("[]"===n.ctor)return r;var o=t,u=f(t,n._0,r),c=n._1;t=o,r=u,e=c}}),M=function(t){return _(C,r(function(t,r){return r+1}),0,t)},O=r(function(t,r){return f(A,function(r){return g.eq(r,t)},r)}),L=L||{};L["::"]=E.cons;var P=r(function(t,e){return _(S,r(function(r,e){return{ctor:"::",_0:t(r),_1:e}}),{ctor:"[]"},e)}),I=r(function(t,e){var n=r(function(r,e){return t(r)?{ctor:"::",_0:r,_1:e}:e});return _(S,n,{ctor:"[]"},e)}),D=e(function(t,r,e){var n=t(r);return"Just"===n.ctor?{ctor:"::",_0:n._0,_1:e}:e}),J=r(function(t,r){return _(S,D(t),{ctor:"[]"},r)}),j=function(t){return _(C,r(function(t,r){return{ctor:"::",_0:t,_1:r}}),{ctor:"[]"},t)},F=(e(function(t,e,n){var o=r(function(r,e){var n=e;return"::"===n.ctor?{ctor:"::",_0:f(t,r,n._0),_1:e}:{ctor:"[]"}});return j(_(C,o,{ctor:"::",_0:e,_1:{ctor:"[]"}},n))}),r(function(t,e){var n=e;return"[]"===n.ctor?t:_(S,r(function(t,r){return{ctor:"::",_0:t,_1:r}}),e,t)})),W=function(t){return _(S,F,{ctor:"[]"},t)},q=(r(function(t,r){return W(f(P,t,r))}),r(function(t,e){var n=r(function(r,e){var n=e,o=n._0,u=n._1;return t(r)?{ctor:"_Tuple2",_0:{ctor:"::",_0:r,_1:o},_1:u}:{ctor:"_Tuple2",_0:o,_1:{ctor:"::",_0:r,_1:u}}});return _(S,n,{ctor:"_Tuple2",_0:{ctor:"[]"},_1:{ctor:"[]"}},e)}),r(function(t,e){var n=e;if("[]"===n.ctor)return{ctor:"[]"};var o=r(function(r,e){return{ctor:"::",_0:t,_1:{ctor:"::",_0:r,_1:e}}}),u=_(S,o,{ctor:"[]"},n._1);return{ctor:"::",_0:n._0,_1:u}}),e(function(t,r,e){for(;;){if(g.cmp(t,0)<1)return e;var n=r;if("[]"===n.ctor)return e;var o=t-1,u=n._1,c={ctor:"::",_0:n._0,_1:e};t=o,r=u,e=c}})),U=r(function(t,r){return j(_(q,t,r,{ctor:"[]"}))}),z=e(function(t,r,e){if(g.cmp(r,0)<1)return{ctor:"[]"};var n={ctor:"_Tuple2",_0:r,_1:e};t:do{r:do{if("_Tuple2"!==n.ctor)break t;if("[]"===n._1.ctor)return e;if("::"!==n._1._1.ctor){if(1===n._0)break r;break t}switch(n._0){case 1:break r;case 2:return{ctor:"::",_0:n._1._0,_1:{ctor:"::",_0:n._1._1._0,_1:{ctor:"[]"}}};case 3:if("::"===n._1._1._1.ctor)return{ctor:"::",_0:n._1._0,_1:{ctor:"::",_0:n._1._1._0,_1:{ctor:"::",_0:n._1._1._1._0,_1:{ctor:"[]"}}}};break t;default:if("::"===n._1._1._1.ctor&&"::"===n._1._1._1._1.ctor){var o=n._1._1._1._0,u=n._1._1._0,c=n._1._0,a=n._1._1._1._1._0,i=n._1._1._1._1._1;return g.cmp(t,1e3)>0?{ctor:"::",_0:c,_1:{ctor:"::",_0:u,_1:{ctor:"::",_0:o,_1:{ctor:"::",_0:a,_1:f(U,r-4,i)}}}}:{ctor:"::",_0:c,_1:{ctor:"::",_0:u,_1:{ctor:"::",_0:o,_1:{ctor:"::",_0:a,_1:_(z,t+1,r-4,i)}}}}}break t}}while(!1);return{ctor:"::",_0:n._1._0,_1:{ctor:"[]"}}}while(!1);return e}),Q=(r(function(t,r){return _(z,0,t,r)}),e(function(t,r,e){for(;;){if(g.cmp(r,0)<1)return t;var n={ctor:"::",_0:e,_1:t},o=r-1,u=e;t=n,r=o,e=u}})),K=(r(function(t,r){return _(Q,{ctor:"[]"},t,r)}),e(function(t,r,e){for(;;){if(!(g.cmp(t,r)<1))return e;var n=t,o=r-1,u={ctor:"::",_0:r,_1:e};t=n,r=o,e=u}})),$=r(function(t,r){return _(K,t,r,{ctor:"[]"})}),G=(r(function(t,r){return _(x,t,f($,0,M(r)-1),r)}),h.append,h.length,h.slice,h.set,r(function(t,r){return g.cmp(0,t)<1&&g.cmp(t,h.length(r))<0?B(f(h.get,t,r)):N}),h.push,h.empty,r(function(t,e){var n=r(function(r,e){return t(r)?f(h.push,r,e):e});return _(h.foldl,n,h.empty,e)}),h.foldr,h.foldl,h.indexedMap,h.map,h.toList),H=(h.fromList,h.initialize),V=(r(function(t,r){return f(H,t,p(r))}),function(){function t(t,r){var e=t+": "+g.toString(r),n=n||{};return n.stdout?n.stdout.write(e):console.log(e),r}function e(t){throw new Error(t)}return{crash:e,log:r(t)}}()),X=function(){function t(t){return 0===t.length}function n(t,r){return t+r}function o(t){var r=t[0];return r?B(g.Tuple2(g.chr(r),t.slice(1))):N}function u(t,r){return t+r}function c(t){return E.toArray(t).join("")}function a(t){return t.length}function i(t,r){for(var e=r.split(""),n=e.length;n--;)e[n]=t(g.chr(e[n]));return e.join("")}function _(t,r){return r.split("").map(g.chr).filter(t).join("")}function l(t){return t.split("").reverse().join("")}function s(t,r,e){for(var n=e.length,o=0;o0;)1&t&&(e+=r),t>>=1,r+=r;return e}function m(t,r,e){return e.slice(t,r)}function b(t,r){return t<1?"":r.slice(0,t)}function y(t,r){return t<1?"":r.slice(-t)}function k(t,r){return t<1?r:r.slice(t)}function w(t,r){return t<1?r:r.slice(0,-t)}function T(t,r,e){var n=(t-e.length)/2;return p(Math.ceil(n),r)+e+p(0|n,r)}function R(t,r,e){return e+p(t-e.length,r)}function x(t,r,e){return p(t-e.length,r)+e}function A(t){return t.trim()}function S(t){return t.replace(/^\s+/,"")}function C(t){return t.replace(/\s+$/,"")}function M(t){return E.fromArray(t.trim().split(/\s+/g))}function O(t){return E.fromArray(t.split(/\r\n|\r|\n/g))}function L(t){return t.toUpperCase()}function P(t){return t.toLowerCase()}function I(t,r){for(var e=r.length;e--;)if(t(g.chr(r[e])))return!0;return!1}function D(t,r){for(var e=r.length;e--;)if(!t(g.chr(r[e])))return!1;return!0}function J(t,r){return r.indexOf(t)>-1}function j(t,r){return 0===r.indexOf(t)}function F(t,r){return r.length>=t.length&&r.lastIndexOf(t)===r.length-t.length}function W(t,r){var e=t.length;if(e<1)return E.Nil;for(var n=0,o=[];(n=r.indexOf(t,n))>-1;)o.push(n),n+=e;return E.fromArray(o)}function q(t){var r=t.length;if(0===r)return U(t);var e=t[0];if("0"===e&&"x"===t[1]){for(var n=2;n"9"||e<"0"&&"-"!==e&&"+"!==e)return U(t);for(var n=1;n-1&&g.cmp(n,Z(r))<1})),rt=(f(tt,g.chr("A"),g.chr("Z")),f(tt,g.chr("a"),g.chr("z")),f(tt,g.chr("0"),g.chr("9")),f(tt,g.chr("0"),g.chr("7")),r(function(t,r){var e=r;return"Ok"===e.ctor?e._0:t}),function(t){return{ctor:"Err",_0:t}}),et=(r(function(t,r){var e=r;return"Ok"===e.ctor?t(e._0):rt(e._0)}),function(t){return{ctor:"Ok",_0:t}}),nt=(r(function(t,r){var e=r;return"Ok"===e.ctor?et(t(e._0)):rt(e._0)}),e(function(t,r,e){var n={ctor:"_Tuple2",_0:r,_1:e};return"Ok"===n._0.ctor?"Ok"===n._1.ctor?et(f(t,n._0._0,n._1._0)):rt(n._1._0):rt(n._0._0)}),n(function(t,r,e,n){var o={ctor:"_Tuple3",_0:r,_1:e,_2:n};return"Ok"===o._0.ctor?"Ok"===o._1.ctor?"Ok"===o._2.ctor?et(_(t,o._0._0,o._1._0,o._2._0)):rt(o._2._0):rt(o._1._0):rt(o._0._0)}),o(function(t,r,e,n,o){var u={ctor:"_Tuple4",_0:r,_1:e,_2:n,_3:o};return"Ok"===u._0.ctor?"Ok"===u._1.ctor?"Ok"===u._2.ctor?"Ok"===u._3.ctor?et(l(t,u._0._0,u._1._0,u._2._0,u._3._0)):rt(u._3._0):rt(u._2._0):rt(u._1._0):rt(u._0._0)}),u(function(t,r,e,n,o,u){var c={ctor:"_Tuple5",_0:r,_1:e,_2:n,_3:o,_4:u};return"Ok"===c._0.ctor?"Ok"===c._1.ctor?"Ok"===c._2.ctor?"Ok"===c._3.ctor?"Ok"===c._4.ctor?et(s(t,c._0._0,c._1._0,c._2._0,c._3._0,c._4._0)):rt(c._4._0):rt(c._3._0):rt(c._2._0):rt(c._1._0):rt(c._0._0)}),r(function(t,r){var e=r;return"Ok"===e.ctor?et(e._0):rt(t(e._0))}),r(function(t,r){var e=r;return"Just"===e.ctor?et(e._0):rt(t)}),X.fromList,X.toList,X.toFloat,X.toInt,X.indexes,X.indexes,X.endsWith,X.startsWith,X.contains,X.all,X.any,X.toLower,X.toUpper,X.lines,X.words,X.trimRight,X.trimLeft,X.trim,X.padRight,X.padLeft,X.pad,X.dropRight,X.dropLeft,X.right,X.left,X.slice,X.repeat,X.join,X.split,X.foldr,X.foldl,X.reverse,X.filter,X.map,X.length,X.concat),ot=(X.append,X.uncons,X.cons,X.isEmpty,e(function(t,r,e){for(;;){var n=e;if("RBEmpty_elm_builtin"===n.ctor)return r;var o=t,u=_(t,n._1,n._2,_(ot,t,r,n._4)),c=n._3;t=o,r=u,e=c}})),ut=function(t){return _(ot,e(function(t,r,e){return{ctor:"::",_0:{ctor:"_Tuple2",_0:t,_1:r},_1:e}}),{ctor:"[]"},t)},ct=e(function(t,r,e){for(;;){var n=e;if("RBEmpty_elm_builtin"===n.ctor)return r;var o=t,u=_(t,n._1,n._2,_(ct,t,r,n._3)),c=n._4;t=o,r=u,e=c}}),at=u(function(t,n,o,u,c,a){var i=e(function(r,e,u){for(;;){var c=u,a=c._1,i=c._0,f=i;if("[]"===f.ctor)return{ctor:"_Tuple2",_0:i,_1:_(o,r,e,a)};var s=f._1,d=f._0._1,h=f._0._0;if(!(g.cmp(h,r)<0))return g.cmp(h,r)>0?{ctor:"_Tuple2",_0:i,_1:_(o,r,e,a)}:{ctor:"_Tuple2",_0:s,_1:l(n,h,d,e,a)};var v=r,p=e,m={ctor:"_Tuple2",_0:s,_1:_(t,h,d,a)};r=v,e=p,u=m}}),f=_(ct,i,{ctor:"_Tuple2",_0:ut(u),_1:a},c),s=f._0,d=f._1;return _(C,r(function(r,e){var n=r;return _(t,n._0,n._1,e)}),d,s)}),it=n(function(t,r,e,n){return V.crash(nt({ctor:"::",_0:"Internal red-black tree invariant violated, expected ",_1:{ctor:"::",_0:t,_1:{ctor:"::",_0:" and got ",_1:{ctor:"::",_0:y(r),_1:{ctor:"::",_0:"/",_1:{ctor:"::",_0:e,_1:{ctor:"::",_0:"/",_1:{ctor:"::",_0:n,_1:{ctor:"::",_0:"\nPlease report this bug to ",_1:{ctor:"[]"}}}}}}}}}}))}),ft=function(t){var r=t;t:do{if("RBNode_elm_builtin"===r.ctor){if("BBlack"===r._0.ctor)return!0;break t}if("LBBlack"===r._0.ctor)return!0;break t}while(!1);return!1},_t=r(function(t,r){for(;;){var e=r;if("RBEmpty_elm_builtin"===e.ctor)return t;var n=f(_t,t+1,e._4),o=e._3;t=n,r=o}}),lt=r(function(t,r){t:for(;;){var e=r;if("RBEmpty_elm_builtin"===e.ctor)return N;var n=f(w,t,e._1);switch(n.ctor){case"LT":var o=t,u=e._3;t=o,r=u;continue t;case"EQ":return B(e._2);default:var c=t,a=e._4;t=c,r=a;continue t}}}),st=r(function(t,r){var e=f(lt,t,r);return"Just"===e.ctor}),dt=e(function(t,r,e){for(;;){var n=e;if("RBEmpty_elm_builtin"===n.ctor)return{ctor:"_Tuple2",_0:t,_1:r};var o=n._1,u=n._2,c=n._4;t=o,r=u,e=c}}),ht={ctor:"NBlack"},vt={ctor:"BBlack"},gt={ctor:"Black"},pt=function(t){var r=t;if("RBNode_elm_builtin"===r.ctor){var e=r._0;return g.eq(e,gt)||g.eq(e,vt)}return!0},mt={ctor:"Red"},bt=function(t){var r=t;switch(r.ctor){case"Black":return vt;case"Red":return gt;case"NBlack":return mt;default:return V.crash("Can't make a double black node more black!")}},yt=function(t){var r=t;switch(r.ctor){case"BBlack":return gt;case"Black":return mt;case"Red":return ht;default:return V.crash("Can't make a negative black node less black!")}},kt={ctor:"LBBlack"},wt={ctor:"LBlack"},Tt=function(t){return{ctor:"RBEmpty_elm_builtin",_0:t}},Nt=Tt(wt),Bt=o(function(t,r,e,n,o){return{ctor:"RBNode_elm_builtin",_0:t,_1:r,_2:e,_3:n,_4:o}}),Rt=function(t){var r=t;return"RBNode_elm_builtin"===r.ctor&&"Red"===r._0.ctor?s(Bt,gt,r._1,r._2,r._3,r._4):t},Et=function(t){var r=t;return"RBNode_elm_builtin"===r.ctor?s(Bt,yt(r._0),r._1,r._2,r._3,r._4):Tt(wt)},xt=function(t){return function(r){return function(e){return function(n){return function(o){return function(u){return function(c){return function(a){return function(i){return function(f){return function(_){return s(Bt,yt(t),n,o,s(Bt,gt,r,e,a,i),s(Bt,gt,u,c,f,_))}}}}}}}}}}},At=function(t){var r=t;return"RBEmpty_elm_builtin"===r.ctor?Tt(wt):s(Bt,gt,r._1,r._2,r._3,r._4)},St=function(t){var r=t;return"RBEmpty_elm_builtin"===r.ctor?V.crash("can't make a Leaf red"):s(Bt,mt,r._1,r._2,r._3,r._4)},Ct=function(t){var r=t;t:do{r:do{e:do{n:do{o:do{u:do{ +c:do{if("RBNode_elm_builtin"!==r.ctor)break t;if("RBNode_elm_builtin"===r._3.ctor)if("RBNode_elm_builtin"===r._4.ctor)switch(r._3._0.ctor){case"Red":switch(r._4._0.ctor){case"Red":if("RBNode_elm_builtin"===r._3._3.ctor&&"Red"===r._3._3._0.ctor)break c;if("RBNode_elm_builtin"===r._3._4.ctor&&"Red"===r._3._4._0.ctor)break u;if("RBNode_elm_builtin"===r._4._3.ctor&&"Red"===r._4._3._0.ctor)break o;if("RBNode_elm_builtin"===r._4._4.ctor&&"Red"===r._4._4._0.ctor)break n;break t;case"NBlack":if("RBNode_elm_builtin"===r._3._3.ctor&&"Red"===r._3._3._0.ctor)break c;if("RBNode_elm_builtin"===r._3._4.ctor&&"Red"===r._3._4._0.ctor)break u;if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._4._3.ctor&&"Black"===r._4._3._0.ctor&&"RBNode_elm_builtin"===r._4._4.ctor&&"Black"===r._4._4._0.ctor)break e;break t;default:if("RBNode_elm_builtin"===r._3._3.ctor&&"Red"===r._3._3._0.ctor)break c;if("RBNode_elm_builtin"===r._3._4.ctor&&"Red"===r._3._4._0.ctor)break u;break t}case"NBlack":switch(r._4._0.ctor){case"Red":if("RBNode_elm_builtin"===r._4._3.ctor&&"Red"===r._4._3._0.ctor)break o;if("RBNode_elm_builtin"===r._4._4.ctor&&"Red"===r._4._4._0.ctor)break n;if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._3._3.ctor&&"Black"===r._3._3._0.ctor&&"RBNode_elm_builtin"===r._3._4.ctor&&"Black"===r._3._4._0.ctor)break r;break t;case"NBlack":if("BBlack"===r._0.ctor){if("RBNode_elm_builtin"===r._4._3.ctor&&"Black"===r._4._3._0.ctor&&"RBNode_elm_builtin"===r._4._4.ctor&&"Black"===r._4._4._0.ctor)break e;if("RBNode_elm_builtin"===r._3._3.ctor&&"Black"===r._3._3._0.ctor&&"RBNode_elm_builtin"===r._3._4.ctor&&"Black"===r._3._4._0.ctor)break r;break t}break t;default:if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._3._3.ctor&&"Black"===r._3._3._0.ctor&&"RBNode_elm_builtin"===r._3._4.ctor&&"Black"===r._3._4._0.ctor)break r;break t}default:switch(r._4._0.ctor){case"Red":if("RBNode_elm_builtin"===r._4._3.ctor&&"Red"===r._4._3._0.ctor)break o;if("RBNode_elm_builtin"===r._4._4.ctor&&"Red"===r._4._4._0.ctor)break n;break t;case"NBlack":if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._4._3.ctor&&"Black"===r._4._3._0.ctor&&"RBNode_elm_builtin"===r._4._4.ctor&&"Black"===r._4._4._0.ctor)break e;break t;default:break t}}else switch(r._3._0.ctor){case"Red":if("RBNode_elm_builtin"===r._3._3.ctor&&"Red"===r._3._3._0.ctor)break c;if("RBNode_elm_builtin"===r._3._4.ctor&&"Red"===r._3._4._0.ctor)break u;break t;case"NBlack":if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._3._3.ctor&&"Black"===r._3._3._0.ctor&&"RBNode_elm_builtin"===r._3._4.ctor&&"Black"===r._3._4._0.ctor)break r;break t;default:break t}else{if("RBNode_elm_builtin"!==r._4.ctor)break t;switch(r._4._0.ctor){case"Red":if("RBNode_elm_builtin"===r._4._3.ctor&&"Red"===r._4._3._0.ctor)break o;if("RBNode_elm_builtin"===r._4._4.ctor&&"Red"===r._4._4._0.ctor)break n;break t;case"NBlack":if("BBlack"===r._0.ctor&&"RBNode_elm_builtin"===r._4._3.ctor&&"Black"===r._4._3._0.ctor&&"RBNode_elm_builtin"===r._4._4.ctor&&"Black"===r._4._4._0.ctor)break e;break t;default:break t}}}while(!1);return xt(r._0)(r._3._3._1)(r._3._3._2)(r._3._1)(r._3._2)(r._1)(r._2)(r._3._3._3)(r._3._3._4)(r._3._4)(r._4)}while(!1);return xt(r._0)(r._3._1)(r._3._2)(r._3._4._1)(r._3._4._2)(r._1)(r._2)(r._3._3)(r._3._4._3)(r._3._4._4)(r._4)}while(!1);return xt(r._0)(r._1)(r._2)(r._4._3._1)(r._4._3._2)(r._4._1)(r._4._2)(r._3)(r._4._3._3)(r._4._3._4)(r._4._4)}while(!1);return xt(r._0)(r._1)(r._2)(r._4._1)(r._4._2)(r._4._4._1)(r._4._4._2)(r._3)(r._4._3)(r._4._4._3)(r._4._4._4)}while(!1);return s(Bt,gt,r._4._3._1,r._4._3._2,s(Bt,gt,r._1,r._2,r._3,r._4._3._3),s(Mt,gt,r._4._1,r._4._2,r._4._3._4,St(r._4._4)))}while(!1);return s(Bt,gt,r._3._4._1,r._3._4._2,s(Mt,gt,r._3._1,r._3._2,St(r._3._3),r._3._4._3),s(Bt,gt,r._1,r._2,r._3._4._4,r._4))}while(!1);return t},Mt=o(function(t,r,e,n,o){var u=s(Bt,t,r,e,n,o);return pt(u)?Ct(u):u}),Ot=o(function(t,r,e,n,o){return ft(n)||ft(o)?s(Mt,bt(t),r,e,Et(n),Et(o)):s(Bt,t,r,e,n,o)}),Lt=o(function(t,r,e,n,o){var u=o;return"RBEmpty_elm_builtin"===u.ctor?_(Pt,t,n,o):s(Ot,t,r,e,n,s(Lt,u._0,u._1,u._2,u._3,u._4))}),Pt=e(function(t,r,e){var n={ctor:"_Tuple2",_0:r,_1:e};if("RBEmpty_elm_builtin"!==n._0.ctor){if("RBEmpty_elm_builtin"===n._1.ctor){var o=n._1._0,u=n._0._0,c={ctor:"_Tuple3",_0:t,_1:u,_2:o};return"_Tuple3"===c.ctor&&"Black"===c._0.ctor&&"Red"===c._1.ctor&&"LBlack"===c._2.ctor?s(Bt,gt,n._0._1,n._0._2,n._0._3,n._0._4):l(it,"Black/Red/LBlack",t,y(u),y(o))}var a=n._0._2,i=n._0._4,f=n._0._1,d=s(Lt,n._0._0,f,a,n._0._3,i),h=_(dt,f,a,i),v=h._0,g=h._1;return s(Ot,t,v,g,d,e)}if("RBEmpty_elm_builtin"!==n._1.ctor){var p=n._1._0,m=n._0._0,b={ctor:"_Tuple3",_0:t,_1:m,_2:p};return"_Tuple3"===b.ctor&&"Black"===b._0.ctor&&"LBlack"===b._1.ctor&&"Red"===b._2.ctor?s(Bt,gt,n._1._1,n._1._2,n._1._3,n._1._4):l(it,"Black/LBlack/Red",t,y(m),y(p))}var k=t;switch(k.ctor){case"Red":return Tt(wt);case"Black":return Tt(kt);default:return V.crash("cannot have bblack or nblack nodes at this point")}}),It=r(function(t,r){var e=r;if("RBEmpty_elm_builtin"===e.ctor)return Tt(wt);var n=e._1;return s(Bt,e._0,n,f(t,n,e._2),f(It,t,e._3),f(It,t,e._4))}),Dt={ctor:"Same"},Jt={ctor:"Remove"},jt={ctor:"Insert"},Ft=e(function(t,r,e){var n=function(e){var o=e;if("RBEmpty_elm_builtin"===o.ctor){var u=r(N);return"Nothing"===u.ctor?{ctor:"_Tuple2",_0:Dt,_1:Nt}:{ctor:"_Tuple2",_0:jt,_1:s(Bt,mt,t,u._0,Nt,Nt)}}var c=o._2,a=o._4,i=o._3,l=o._1,d=o._0,h=f(w,t,l);switch(h.ctor){case"EQ":var v=r(B(c));return"Nothing"===v.ctor?{ctor:"_Tuple2",_0:Jt,_1:_(Pt,d,i,a)}:{ctor:"_Tuple2",_0:Dt,_1:s(Bt,d,l,v._0,i,a)};case"LT":var g=n(i),p=g._0,m=g._1,b=p;switch(b.ctor){case"Same":return{ctor:"_Tuple2",_0:Dt,_1:s(Bt,d,l,c,m,a)};case"Insert":return{ctor:"_Tuple2",_0:jt,_1:s(Mt,d,l,c,m,a)};default:return{ctor:"_Tuple2",_0:Jt,_1:s(Ot,d,l,c,m,a)}}default:var y=n(a),p=y._0,k=y._1,T=p;switch(T.ctor){case"Same":return{ctor:"_Tuple2",_0:Dt,_1:s(Bt,d,l,c,i,k)};case"Insert":return{ctor:"_Tuple2",_0:jt,_1:s(Mt,d,l,c,i,k)};default:return{ctor:"_Tuple2",_0:Jt,_1:s(Ot,d,l,c,i,k)}}}},o=n(e),u=o._0,c=o._1,a=u;switch(a.ctor){case"Same":return c;case"Insert":return Rt(c);default:return At(c)}}),Wt=e(function(t,r,e){return _(Ft,t,p(B(r)),e)}),qt=(r(function(t,r){return _(Wt,t,r,Nt)}),r(function(t,r){return _(ct,Wt,r,t)})),Ut=r(function(t,r){var n=e(function(r,e,n){return f(t,r,e)?_(Wt,r,e,n):n});return _(ct,n,Nt,r)}),zt=(r(function(t,e){return f(Ut,r(function(t,r){return f(st,t,e)}),t)}),r(function(t,r){var n=e(function(r,e,n){var o=n,u=o._1,c=o._0;return f(t,r,e)?{ctor:"_Tuple2",_0:_(Wt,r,e,c),_1:u}:{ctor:"_Tuple2",_0:c,_1:_(Wt,r,e,u)}});return _(ct,n,{ctor:"_Tuple2",_0:Nt,_1:Nt},r)}),r(function(t,r){return _(Ft,t,p(N),r)})),Qt=(r(function(t,r){return _(ct,e(function(t,r,e){return f(zt,t,e)}),t,r)}),function(){function t(t){return{ctor:"",tag:"succeed",msg:t}}function f(t){return{ctor:"",tag:"fail",msg:t}}function _(t){return{ctor:"",tag:t}}function l(t,r){return{ctor:"",tag:t,decoder:r}}function s(t){return{ctor:"",tag:"null",value:t}}function d(t,r){return{ctor:"",tag:"field",field:t,decoder:r}}function v(t,r){return{ctor:"",tag:"index",index:t,decoder:r}}function p(t){return{ctor:"",tag:"key-value",decoder:t}}function m(t,r){return{ctor:"",tag:"map-many",func:t,decoders:r}}function b(t,r){return{ctor:"",tag:"andThen",decoder:r,callback:t}}function y(t){return{ctor:"",tag:"oneOf",decoders:t}}function k(t,r){return m(t,[r])}function w(t,r,e){return m(t,[r,e])}function T(t,r,e,n){return m(t,[r,e,n])}function R(t,r,e,n,o){return m(t,[r,e,n,o])}function x(t,r,e,n,o,u){return m(t,[r,e,n,o,u])}function A(t,r,e,n,o,u,c){return m(t,[r,e,n,o,u,c])}function S(t,r,e,n,o,u,c,a){return m(t,[r,e,n,o,u,c,a])}function C(t,r,e,n,o,u,c,a,i){return m(t,[r,e,n,o,u,c,a,i])}function M(t){return{tag:"ok",value:t}}function O(t,r){return{tag:"primitive",type:t,value:r}}function L(t,r){return{tag:"index",index:t,rest:r}}function P(t,r){return{tag:"field",field:t,rest:r}}function L(t,r){return{tag:"index",index:t,rest:r}}function I(t){return{tag:"oneOf",problems:t}}function D(t){return{tag:"fail",msg:t}}function J(t){for(var r="_";t;)switch(t.tag){case"primitive":return"Expecting "+t.type+("_"===r?"":" at "+r)+" but instead got: "+j(t.value);case"index":r+="["+t.index+"]",t=t.rest;break;case"field":r+="."+t.field,t=t.rest;break;case"oneOf":for(var e=t.problems,n=0;n=r.length)return O("a longer array. Need index "+i+" but there are only "+r.length+" entries",r);var o=q(t.decoder,r[i]);return"ok"===o.tag?o:L(i,o);case"key-value":if("object"!=typeof r||null===r||r instanceof Array)return O("an object",r);var f=E.Nil;for(var _ in r){var o=q(t.decoder,r[_]);if("ok"!==o.tag)return P(_,o);var l=g.Tuple2(_,o.value);f=E.Cons(l,f)}return M(f);case"map-many":for(var s=t.func,d=t.decoders,n=0;n=0&&u.splice(r,1)}var u=[],c=A[t].converter,a=dr.succeed(null);return A[t].init=a,A[t].onEffects=e(r),{subscribe:n,unsubscribe:o}}function R(t,r){return T(t),A[t]={tag:"sub",subMap:C,converter:r,isForeign:!0},v(t)}function x(t,r){function n(t,r,e){for(var n=o(t,r,e),u=0;u<_.length;u++)a(_[u]);return _=null,h=a,d=o,n}function o(t,r,e){return l=r,v}function u(t,r,e){return d(t,r,e)}function c(t){_.push(t)}function a(t){for(var e=l;"[]"!==e.ctor;)r(e._0(t)),e=e._1}function i(r){var e=f(Zt,s,r);if("Err"===e.ctor)throw new Error("Trying to send an unexpected type of value through port `"+t+"`:\n"+e._0);h(e._0)}var _=[],l=E.Nil,s=A[t].converter,d=n,h=c,v=dr.succeed(null);return A[t].init=v,A[t].onEffects=e(u),{send:i}}var A={},S=r(function(t,r){return r}),C=r(function(t,r){return function(e){return t(r(e))}});return{sendToApp:r(s),sendToSelf:r(d),effectManagers:A,outgoingPort:N,incomingPort:R,htmlToProgram:u,program:t,programWithFlags:n,initialize:c,leaf:v,batch:p,map:r(m)}}()),dr=function(){function t(t){return{ctor:"_Task_succeed",value:t}}function e(t){return{ctor:"_Task_fail",value:t}}function n(t){return{ctor:"_Task_nativeBinding",callback:t,cancel:null}}function o(t,r){return{ctor:"_Task_andThen",callback:t,task:r}}function u(t,r){return{ctor:"_Task_onError",callback:t,task:r}}function c(t){return{ctor:"_Task_receive",callback:t}}function a(t){var r={ctor:"_Process",id:g.guid(),root:t,stack:null,mailbox:[]};return h(r),r}function i(r){return n(function(e){var n=a(r);e(t(n))})}function f(t,r){t.mailbox.push(r),h(t)}function _(r,e){return n(function(n){f(r,e),n(t(g.Tuple0))})}function l(r){return n(function(e){var n=r.root;"_Task_nativeBinding"===n.ctor&&n.cancel&&n.cancel(),r.root=null,e(t(g.Tuple0))})}function s(r){return n(function(e){var n=setTimeout(function(){e(t(g.Tuple0))},r);return function(){clearTimeout(n)}})}function d(t,r){for(;t0&&e.push(M("p-thunk",n,_)));case"tagger":for(var l=t.tagger,s=r.tagger,d=!1,h=t.node;"tagger"===h.type;)d=!0,"object"!=typeof l?l=[l,h.tagger]:l.push(h.tagger),h=h.node;for(var v=r.node;"tagger"===v.type;)d=!0,"object"!=typeof s?s=[s,v.tagger]:s.push(v.tagger),v=v.node;return d&&l.length!==s.length?void e.push(M("p-redraw",n,r)):((d?L(l,s):l===s)||e.push(M("p-tagger",n,s)),void O(h,v,e,n+1));case"text":if(t.text!==r.text)return void e.push(M("p-text",n,r.text));return;case"node":if(t.tag!==r.tag||t.namespace!==r.namespace)return void e.push(M("p-redraw",n,r));var g=P(t.facts,r.facts);return"undefined"!=typeof g&&e.push(M("p-facts",n,g)),void I(t,r,e,n);case"keyed-node":if(t.tag!==r.tag||t.namespace!==r.namespace)return void e.push(M("p-redraw",n,r));var g=P(t.facts,r.facts);return"undefined"!=typeof g&&e.push(M("p-facts",n,g)),void D(t,r,e,n);case"custom":if(t.impl!==r.impl)return void e.push(M("p-redraw",n,r));var g=P(t.facts,r.facts);"undefined"!=typeof g&&e.push(M("p-facts",n,g));var p=r.impl.diff(t,r);if(p)return void e.push(M("p-custom",n,p));return}}}function L(t,r){for(var e=0;ea?e.push(M("p-remove-last",n,c-a)):c0||c.length>0||"undefined"!=typeof S)&&e.push(M("p-reorder",n,{patches:o,inserts:c,endInserts:S}))}function J(t,r,e,n,o,u){var c=t[e];if("undefined"==typeof c)return c={tag:"insert",vnode:n,index:o,data:void 0},u.push({index:o,entry:c}),void(t[e]=c);if("remove"===c.tag){u.push({index:o,entry:c}),c.tag="move";var a=[];return O(c.vnode,n,a,c.index),c.index=o,void(c.data.data={patches:a,entry:c})}J(t,r,e+gt,n,o,u)}function j(t,r,e,n,o){var u=t[e];if("undefined"==typeof u){var c=M("p-remove",o,void 0);return r.push(c),void(t[e]={tag:"remove",vnode:n,index:o,data:c})}if("insert"===u.tag){u.tag="move";var a=[];O(n,u.vnode,a,o);var c=M("p-remove",o,{patches:a,entry:u});return void r.push(c)}j(t,r,e+gt,n,o)}function F(t,r,e,n){W(t,r,e,0,0,r.descendantsCount,n)}function W(t,r,e,n,o,u,c){for(var a=e[n],i=a.index;i===o;){var f=a.type;if("p-thunk"===f)F(t,r.node,a.data,c);else if("p-reorder"===f){a.domNode=t,a.eventNode=c;var _=a.data.patches;_.length>0&&W(t,r,_,0,o,u,c)}else if("p-remove"===f){a.domNode=t,a.eventNode=c;var l=a.data;if("undefined"!=typeof l){ +l.entry.data=t;var _=l.patches;_.length>0&&W(t,r,_,0,o,u,c)}}else a.domNode=t,a.eventNode=c;if(n++,!(a=e[n])||(i=a.index)>u)return n}switch(r.type){case"tagger":for(var s=r.node;"tagger"===s.type;)s=s.node;return W(t,s,e,n,o+1,u,t.elm_event_node_ref);case"node":for(var d=r.children,h=t.childNodes,v=0;vu))return n;o=p}return n;case"keyed-node":for(var d=r.children,h=t.childNodes,v=0;vu))return n;o=p}return n;case"text":case"thunk":throw new Error("should never traverse `text` or `thunk` nodes like this")}}function q(t,r,e,n){return 0===e.length?t:(F(t,r,e,n),U(t,e))}function U(t,r){for(var e=0;e"),new Error(t)}function Z(t,r,e,n){r.embed=function(r,e){for(;r.lastChild;)r.removeChild(r.lastChild);return sr.initialize(n(t.init,e,r),t.update,t.subscriptions,tt(r,t.view))},r.fullscreen=function(r){return sr.initialize(n(t.init,r,document.body),t.update,t.subscriptions,tt(document.body,t.view))}}function tt(t,r){return function(e,n){var o={tagger:e,parent:void 0},u=r(n),c=N(u,o);return t.appendChild(c),rt(c,r,u,o)}}function rt(t,r,e,n){function o(){switch(c){case"NO_REQUEST":throw new Error("Unexpected draw callback.\nPlease report this to .");case"PENDING_REQUEST":bt(o),c="EXTRA_REQUEST";var e=r(u),i=C(a,e);return t=q(t,a,i,n),void(a=e);case"EXTRA_REQUEST":return void(c="NO_REQUEST")}}var u,c="NO_REQUEST",a=e;return function(t){"NO_REQUEST"===c&&bt(o),c="PENDING_REQUEST",u=t}}function et(t,r,e,n){r.fullscreen=function(r){var o={doc:void 0};return sr.initialize(n(t.init,r,document.body),t.update(nt(o)),t.subscriptions,ot(e,document.body,o,t.view,t.viewIn,t.viewOut))},r.embed=function(r,o){var u={doc:void 0};return sr.initialize(n(t.init,o,r),t.update(nt(u)),t.subscriptions,ot(e,r,u,t.view,t.viewIn,t.viewOut))}}function nt(t){return dr.nativeBinding(function(r){var e=t.doc;if(e){var n=e.getElementsByClassName("debugger-sidebar-messages")[0];n&&(n.scrollTop=n.scrollHeight)}r(dr.succeed(g.Tuple0))})}function ot(t,r,e,n,o,u){return function(c,a){var i={tagger:c,parent:void 0},f={tagger:c,parent:void 0},_=n(a),l=N(_,i);r.appendChild(l);var s=rt(l,n,_,i),d=o(a)._1,h=N(d,f);r.appendChild(h);var v=at(i,h,o),g=rt(h,v,d,f),p=ut(a,u,f,r,t,e);return function(t){s(t),g(t),p(t)}}}function ut(t,r,e,n,o,u){var c,a;return function(t){if(t.isDebuggerOpen){if(!u.doc)return c=r(t),void(a=ct(o,u,c,e));vt=u.doc;var n=r(t),i=C(c,n);a=q(a,c,i,e),c=n,vt=document}}}function ct(t,r,e,n){function o(){r.doc=void 0,f.close()}var u=900,c=360,a=screen.width-u,i=screen.height-c,f=window.open("","","width="+u+",height="+c+",left="+a+",top="+i);vt=f.document,r.doc=vt,vt.title="Debugger - "+t,vt.body.style.margin="0",vt.body.style.padding="0";var _=N(e,n);return vt.body.appendChild(_),vt.addEventListener("keydown",function(t){t.metaKey&&82===t.which&&window.location.reload(),38===t.which&&(n.tagger({ctor:"Up"}),t.preventDefault()),40===t.which&&(n.tagger({ctor:"Down"}),t.preventDefault())}),window.addEventListener("unload",o),f.addEventListener("unload",function(){r.doc=void 0,window.removeEventListener("unload",o),n.tagger({ctor:"Close"})}),vt=document,_}function at(t,r,e){var n,o=_t(r),u="Normal",c=t.tagger,a=function(){};return function(r){var i=e(r),f=i._0.ctor;return t.tagger="Normal"===f?c:a,u!==f&&(it("removeEventListener",o,u),it("addEventListener",o,f),"Normal"===u&&(n=document.body.style.overflow,document.body.style.overflow="hidden"),"Normal"===f&&(document.body.style.overflow=n),u=f),i._1}}function it(t,r,e){switch(e){case"Normal":return;case"Pause":return ft(t,r,yt);case"Message":return ft(t,r,kt)}}function ft(t,r,e){for(var n=0;n"]=r(function(t,r){return f(Er,function(t){return r},t)});var Ge=e(function(t,r,e){for(;;){var n=t;if("[]"===n.ctor)return Sr(e);var o=n._1,u=n._0._0,c=n._0._1,a=f(lt,u,r);if("Just"===a.ctor&&"Connected"===a._0.ctor)return f($e["&>"],f(De,a._0._0,c),_(Ge,o,r,e));var i=o,l=r,s=_(Ft,u,Qe(c),e);t=i,r=l,e=s}}),He=sr.leaf("WebSocket"),Ve=sr.leaf("WebSocket"),Xe=e(function(t,r,e){return{sockets:t,queues:r,subs:e}}),Ye=Sr(_(Xe,Nt,Nt,Nt)),Ze=r(function(t,r){return{ctor:"Send",_0:t,_1:r}}),tn=(r(function(t,r){return Ve(f(Ze,t,r))}),r(function(t,r){var e=r;return f(Ze,e._0,e._1)})),rn=function(t){return{ctor:"KeepAlive",_0:t}},en=r(function(t,r){return{ctor:"Listen",_0:t,_1:r}}),nn=r(function(t,r){return He(f(en,t,r))}),on=r(function(t,r){var e=r;return"Listen"===e.ctor?f(en,e._0,function(r){return t(e._1(r))}):rn(e._0)}),un=function(t){return{ctor:"Connected",_0:t}},cn=r(function(t,r){return{ctor:"Opening",_0:t,_1:r}}),an=function(t){return{ctor:"BadOpen",_0:t}},fn=r(function(t,r){return{ctor:"GoodOpen",_0:t,_1:r}}),_n=function(t){return{ctor:"Die",_0:t}},ln=r(function(t,r){return{ctor:"Receive",_0:t,_1:r}}),sn=r(function(t,e){return f(Fe,t,{onMessage:r(function(r,n){return f(br,e,f(ln,t,n))}),onClose:function(r){return f(br,e,_n(t))}})}),dn=e(function(t,r,e){var n=function(r){return f(br,t,an(e))},o=function(r){return f(br,t,f(fn,e,r))},u=f(Rr,n,f(Er,o,f(sn,e,t)));return ie(f($e["&>"],qe(r),u))}),hn=n(function(t,o,u,c){var a=f(Ke,u,Nt),i=function(o){var u=e(function(t,r,e){return f($e["&>"],We(r),e)}),i=n(function(t,r,e,n){return f(Cr,f(Wt,t,e),n)}),l=e(function(r,e,n){return f(Er,function(e){return f(Er,function(t){return Sr(_(Wt,r,f(cn,0,t),e))},_(dn,t,0,r))},n)}),s=f(qt,o,f(It,r(function(t,r){return{ctor:"[]"}}),a)),h=d(at,l,i,u,s,c.sockets,Sr(Nt));return f(Er,function(t){return Sr(_(Xe,t,o,a))},h)},l=_(Ge,o,c.sockets,c.queues);return f(Er,i,l)}),vn=e(function(t,e,n){var o=e;switch(o.ctor){case"Receive":var u=f(P,function(r){return f(yr,t,r(o._1))},f(T,{ctor:"[]"},f(lt,o._0,n.subs)));return f($e["&>"],Or(u),Sr(n));case"Die":var c=o._0,a=f(lt,c,n.sockets);return"Nothing"===a.ctor?Sr(n):f(Er,function(t){return Sr(_(ze,c,f(cn,0,t),n))},_(dn,t,0,c));case"GoodOpen":var i=o._1,l=o._0,s=f(lt,l,n.queues);return"Nothing"===s.ctor?Sr(_(ze,l,un(i),n)):_(C,r(function(t,r){return f($e["&>"],f(De,i,t),r)}),Sr(f(Ue,l,_(ze,l,un(i),n))),s._0);default:var d=o._0,h=f(lt,d,n.sockets);if("Nothing"===h.ctor)return Sr(n);if("Opening"===h._0.ctor){var v=h._0._0;return f(Er,function(t){return Sr(_(ze,d,f(cn,v+1,t),n))},_(dn,t,v+1,d))}return Sr(n)}});sr.effectManagers.WebSocket={pkg:"elm-lang/websocket",init:Ye,onEffects:hn,onSelfMsg:vn,tag:"fx",cmdMap:tn,subMap:on};var gn=r(function(t,r){var e=t;return"Nothing"===e.ctor||f(O,e._0,r)}),pn=function(t){var r=t.unit;return"Nothing"===r.ctor?f(Re,{ctor:"[]"},{ctor:"::",_0:be(t.value),_1:{ctor:"[]"}}):f(Re,{ctor:"::",_0:Se("value"),_1:{ctor:"[]"}},{ctor:"::",_0:be(f(b["++"],t.value,f(b["++"]," (",f(b["++"],r._0,")")))),_1:{ctor:"[]"}})},mn=function(t){return f(b["++"],y(oe(t)),f(b["++"],"-",f(b["++"],y(ne(t)),f(b["++"]," ",f(b["++"],y(ee(t)),f(b["++"],":",f(b["++"],y(re(t)),f(b["++"],":",y(te(t))))))))))},bn=function(t){return f(Be,{ctor:"[]"},{ctor:"::",_0:f(Re,{ctor:"[]"},{ctor:"::",_0:be(t.name),_1:{ctor:"[]"}}),_1:{ctor:"::",_0:pn(t),_1:{ctor:"::",_0:f(Re,{ctor:"[]"},{ctor:"::",_0:be(mn(ue(1e3*t.ts))),_1:{ctor:"[]"}}),_1:{ctor:"[]"}}}})},yn=function(t){return f(we,{ctor:"[]"},{ctor:"::",_0:f(Ne,{ctor:"[]"},{ctor:"::",_0:f(Be,{ctor:"[]"},{ctor:"::",_0:f(Ee,{ctor:"[]"},{ctor:"::",_0:be("Name"),_1:{ctor:"[]"}}),_1:{ctor:"::",_0:f(Ee,{ctor:"[]"},{ctor:"::",_0:be("Value"),_1:{ctor:"[]"}}),_1:{ctor:"::",_0:f(Ee,{ctor:"[]"},{ctor:"::",_0:be("Timestamp"),_1:{ctor:"[]"}}),_1:{ctor:"[]"}}}}),_1:{ctor:"[]"}}),_1:{ctor:"::",_0:f(Te,{ctor:"[]"},f(P,bn,t)),_1:{ctor:"[]"}}})},kn=function(t){var r=t.ts;return"Nothing"===r.ctor?f(ke,{ctor:"[]"},{ctor:"[]"}):f(ke,{ctor:"::",_0:Se("header"),_1:{ctor:"[]"}},{ctor:"::",_0:f(ke,{ctor:"[]"},{ctor:"::",_0:be("updated at:"),_1:{ctor:"[]"}}),_1:{ctor:"::",_0:f(ke,{ctor:"[]"},{ctor:"::",_0:be(mn(r._0)),_1:{ctor:"[]"}}),_1:{ctor:"[]"}}})},wn=r(function(t,r){return f(O,r,t.hidden)?g.update(t,{hidden:f(I,function(t){return!g.eq(t,r)},t.hidden)}):g.update(t,{hidden:{ctor:"::",_0:r,_1:t.hidden}})}),Tn=o(function(t,r,e,n,o){return{startTime:t,ts:r,status:e,hidden:n,parameters:o}}),Nn=function(t){return{ctor:"_Tuple2",_0:s(Tn,ue(t.startTime),N,"Waiting",{ctor:"[]"},N),_1:vr}},Bn=r(function(t,r){return{instrument:t,parameters:r}}),Rn=r(function(t,r){return{instrument:t,parameters:r}}),En=n(function(t,r,e,n){return{name:t,unit:r,value:e,ts:n}}),xn=_(Nr,"ts",ar(ir),_(Nr,"value",ar(lr),_(Nr,"unit",ar(lr),_(Nr,"name",lr,kr(En))))),An=_(Nr,"parameters",cr(xn),_(Nr,"instrument",ar(lr),kr(Rn))),Sn=r(function(t,r){return{ts:t,parameters:r}}),Cn=_(Nr,"parameters",cr(An),_(Nr,"ts",ir,kr(Sn))),Mn=n(function(t,r,e,n){return{name:t,unit:r,value:e,ts:n}}),On=function(t){return _(R,f(Mn,t.name,t.unit),t.value,t.ts)},Ln=function(t){return f(Bn,t.instrument,f(J,On,t.parameters))},Pn=r(function(t,r){return function(e){return s(Tn,r.startTime,B(ue(1e3*t.ts)),"Running",r.hidden,B(e))}(f(P,Ln,t.parameters))}),In=r(function(t,r){var e=t;return"Err"===e.ctor?s(Tn,ue(0),N,f(b["++"],"error:",e._0),{ctor:"[]"},N):f(Pn,e._0,r)}),Dn=r(function(t,r){var e=t;switch(e.ctor){case"NoOp":return{ctor:"_Tuple2",_0:r,_1:vr};case"WsMessage":var n=f(In,f(tr,Cn,e._0),r);return{ctor:"_Tuple2",_0:n,_1:vr};default:return{ctor:"_Tuple2",_0:f(wn,r,e._0),_1:vr}}}),Jn=function(t){return{ctor:"Hide",_0:t}},jn=function(t){var r=t;if("Nothing"===r.ctor)return{ctor:"::",_0:be(""),_1:{ctor:"[]"}};var e=r._0;return{ctor:"::",_0:f(ke,{ctor:"::",_0:Pe(Jn(e)),_1:{ctor:"[]"}},{ctor:"::",_0:be(e),_1:{ctor:"[]"}}),_1:{ctor:"[]"}}},Fn=r(function(t,r){return f(ke,{ctor:"[]"},{ctor:"::",_0:f(ke,{ctor:"::",_0:Se("instrument"),_1:{ctor:"[]"}},jn(r.instrument)),_1:{ctor:"::",_0:f(ke,{ctor:"::",_0:Se("parameters"),_1:{ctor:"::",_0:Me(f(gn,r.instrument,t)),_1:{ctor:"[]"}}},{ctor:"::",_0:yn(r.parameters),_1:{ctor:"[]"}}),_1:{ctor:"[]"}}})}),Wn=r(function(t,r){return f(ke,{ctor:"::",_0:Se("parametersContainer"),_1:{ctor:"[]"}},f(P,Fn(t),r))}),qn=function(t){var r=t.parameters;return"Nothing"===r.ctor?f(ke,{ctor:"[]"},{ctor:"::",_0:be(f(b["++"],"Status:",t.status)),_1:{ctor:"[]"}}):f(Wn,t.hidden,r._0)},Un=function(t){return f(ke,{ctor:"::",_0:Se("container"),_1:{ctor:"[]"}},{ctor:"::",_0:kn(t),_1:{ctor:"::",_0:qn(t),_1:{ctor:"[]"}}})},zn=function(t){return{ctor:"WsMessage",_0:t}},Qn=function(t){return f(nn,"ws://localhost:5678",zn)},Kn=me({view:Un,init:Nn,update:Dn,subscriptions:Qn})(f(Vt,function(t){return Yt({startTime:t})},f(or,"startTime",ir))),$n={};if($n.Main=$n.Main||{},"undefined"!=typeof Kn&&Kn($n.Main,"Main",void 0),"function"==typeof define&&define.amd)return void define([],function(){return $n});if("object"==typeof t)return void(t.exports=$n);var Gn=this.Elm;if("undefined"==typeof Gn)return void(this.Elm=$n);for(var Hn in $n){if(Hn in Gn)throw new Error("There are two Elm modules called `"+Hn+"` on this page! Rename one of them.");Gn[Hn]=$n[Hn]}}).call(this)}]); \ No newline at end of file diff --git a/qcodes/monitor/dist/webpack-assets.json b/qcodes/monitor/dist/webpack-assets.json new file mode 100644 index 00000000000..397e5d7b63a --- /dev/null +++ b/qcodes/monitor/dist/webpack-assets.json @@ -0,0 +1 @@ +{"main":{"js":"/js/main.b221ee88.js","css":"/css/main.0963d6b9.css"}} \ No newline at end of file diff --git a/qcodes/monitor/monitor.py b/qcodes/monitor/monitor.py new file mode 100644 index 00000000000..43ed7615cff --- /dev/null +++ b/qcodes/monitor/monitor.py @@ -0,0 +1,218 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 +# +# Copyright © 2017 unga +# +# Distributed under terms of the MIT license. +""" +Monitor a set of parameter in a background thread +stream opuput over websocket +""" + +import asyncio +import logging +import os +import time +import json +import http.server +import socketserver +import webbrowser + +from threading import Thread +from typing import Dict +from concurrent.futures import Future +from concurrent.futures import CancelledError +import functools + +import websockets + +SERVER_PORT = 3000 + +log = logging.getLogger(__name__) + + +def _get_metadata(*parameters) -> Dict[float, list]: + """ + Return a dict that contains the parameter metadata grouped by the + instrument it belongs to. + """ + ts = time.time() + # group meta data by instrument if any + metas = {} + for parameter in parameters: + _meta = getattr(parameter, "_latest", None) + if _meta: + meta = _meta() + else: + raise ValueError("Input is not a parameter; Refusing to proceed") + # convert to string + meta['value'] = str(meta['value']) + if meta["ts"] is not None: + meta["ts"] = time.mktime(meta["ts"].timetuple()) + meta["name"] = parameter.label or parameter.name + meta["unit"] = parameter.unit + # find the base instrument in case this is a channel parameter + baseinst = parameter._instrument + while hasattr(baseinst, '_parent'): + baseinst = baseinst._parent + accumulator = metas.get(str(baseinst), []) + accumulator.append(meta) + metas[str(baseinst)] = accumulator + parameters = [] + for instrument in metas: + temp = {"instrument": instrument, "parameters": metas[instrument]} + parameters.append(temp) + state = {"ts": ts, "parameters": parameters} + return state + + +def _handler(parameters, interval: int): + + async def serverFunc(websocket, path): + while True: + try: + try: + meta = _get_metadata(*parameters) + except ValueError as e: + log.exception(e) + break + log.debug("sending..") + try: + await websocket.send(json.dumps(meta)) + # mute browser discconects + except websockets.exceptions.ConnectionClosed as e: + log.debug(e) + await asyncio.sleep(interval) + except CancelledError: + break + log.debug("closing sever") + + return serverFunc + + +class Monitor(Thread): + running = None + server = None + + def __init__(self, *parameters, interval=1): + """ + Monitor qcodes parameters. + + Args: + *parameters: Parameters to monitor + interval: How often one wants to refresh the values + """ + # let the thread start + time.sleep(0.01) + super().__init__() + self.loop = None + self._monitor(*parameters, interval=1) + + def run(self): + """ + Start the event loop and run forever + """ + self.loop = asyncio.new_event_loop() + asyncio.set_event_loop(self.loop) + Monitor.running = self + self.loop.run_forever() + + def stop(self): + """ + Shutdown the server, close the event loop and join the thread + """ + # this contains the server + # or any exception + server = self.future_restult.result() + # server.close() + self.loop.call_soon_threadsafe(server.close) + self.loop.call_soon_threadsafe(self.loop.stop) + self.join() + Monitor.running = None + + @staticmethod + def show(): + """ + Overwrite this method to show/raise your monitor GUI + F.ex. + + :: + + import webbrowser + url = "localhost:3000" + # Open URL in new window, raising the window if possible. + webbrowser.open_new(url) + + """ + webbrowser.open("http://localhost:{}".format(SERVER_PORT)) + + def _monitor(self, *parameters, interval=1): + handler = _handler(parameters, interval=interval) + # TODO (giulioungaretti) read from config + server = websockets.serve(handler, '127.0.0.1', 5678) + + log.debug("Start monitoring thread") + + if Monitor.running: + # stop the old server + log.debug("Stoppging and restarting server") + Monitor.running.stop() + + self.start() + + # let the thread start + time.sleep(0.01) + + log.debug("Start monitoring server") + self._add_task(server) + + def _create_task(self, future, coro): + task = self.loop.create_task(coro) + future.set_result(task) + + def _add_task(self, coro): + future = Future() + self.task = coro + p = functools.partial(self._create_task, future, coro) + self.loop.call_soon_threadsafe(p) + # this stores the result of the future + self.future_restult = future.result() + self.future_restult.add_done_callback(_log_result) + + +def _log_result(future): + try: + future.result() + log.debug("Started server loop") + except: + log.exception("Could not start server loop") + + +class Server(): + + def __init__(self, port=3000): + self.port = port + self.handler = http.server.SimpleHTTPRequestHandler + self.httpd = socketserver.TCPServer(("", self.port), self.handler) + self.static_dir = os.path.join(os.path.dirname(__file__), 'dist') + + def run(self): + os.chdir(self.static_dir) + log.debug("serving directory %s", self.static_dir) + log.info("Open broswer at http://localhost::{}".format(self.port)) + self.httpd.serve_forever() + + def stop(self): + self.httpd.shutdown() + self.join() + + +if __name__ == "__main__": + server = Server(SERVER_PORT) + print("Open broswer at http://localhost:{}".format(server.port)) + try: + webbrowser.open("http://localhost:{}".format(server.port)) + server.run() + except KeyboardInterrupt: + exit() diff --git a/qcodes/monitor/readme.md b/qcodes/monitor/readme.md new file mode 100644 index 00000000000..6226565cb19 --- /dev/null +++ b/qcodes/monitor/readme.md @@ -0,0 +1,9 @@ +This is a WebBased Monitor for displaying QCoDeS +parameters written in ELM. + +To launch do `python monitor.py` +and from your QCoDeS shell launch as +`qcodes.Monitor(*listofparamterstomonitor)` + +The ELM source code is available at +https://github.com/QCoDeS/GUI diff --git a/setup.py b/setup.py index 2aafa475040..d8ca9bf8632 100644 --- a/setup.py +++ b/setup.py @@ -55,11 +55,13 @@ def readme(): # if we want to install without tests: # packages=find_packages(exclude=["*.tests", "tests"]), packages=find_packages(), - package_data={'qcodes': ['widgets/*.js', 'widgets/*.css', 'config/*.json']}, - install_requires= [ + package_data={'qcodes': ['monitor/dist/*', 'monitor/dist/js/*', + 'monitor/dist/css/*', 'config/*.json']}, + install_requires=[ 'numpy>=1.10', 'pyvisa>=1.8', - 'h5py>=2.6' + 'h5py>=2.6', + 'websockets>=3.2,<3.4' ], test_suite='qcodes.tests',