clustergrammer
Version:
This is a clustergram implemented in D3.js. I started from the example http://bost.ocks.org/mike/miserables/ and added the following features
2 lines • 352 kB
JavaScript
var Clustergrammer=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){function e(){d3.select(S.params.viz.viz_svg).style("opacity",.5);var t=500;this.params.viz.run_trans===!0&&(t=2500),setTimeout(n,t,this)}function n(t){s(t)}function b(t){f(this,t)}function z(t,e,r){_(this,t,e,r)}function k(){return y}function A(t,e){"sum"===e&&(e="rank"),"var"===e&&(e="rankvar"),w(this,e,t)}function E(){return x(this.params)}function N(t,e){h(this,t,e)}var M=o(t),S={};if(S.params=a(M),S.config=M,S.params.zoom_behavior=d3.behavior.zoom().scaleExtent([1,S.params.viz.square_zoom*S.params.viz.zoom_ratio.x]).on("zoom",function(){g(S)}),S.params.zoom_behavior.translate([S.params.viz.clust.margin.left,S.params.viz.clust.margin.top]),S.params.use_sidebar){var O=r(271);O(S)}return i(S),S.update_view=h,S.resize_viz=e,S.play_demo=l,S.ini_demo=c,S.filter_viz_using_nodes=u,S.filter_viz_using_names=d,S.update_cats=b,S.reset_cats=p,S.zoom=z,S.save_matrix=v,S.brush_crop_matrix=m,S.d3_tip_custom=k,S.reorder=A,S.export_matrix_string=E,S.update_view=N,S}var o=r(1),a=r(9),i=r(89),s=r(152),l=r(229),c=r(247),u=r(250),d=r(251),f=r(252),p=r(253),_=r(144),h=r(202),v=r(255),m=r(259),g=r(153),y=r(100),w=r(143),x=r(257);d3.slider=r(261);r(263);r(265),r(269),t.exports=n},function(t,e,r){"use strict";var n=r(2),o=r(3),a=r(4),i=r(5),s=r(6),l=r(7),c=r(8);t.exports=function(t){var e=s(),r=n.extend(e,t);r.network_data=t.network_data;var u=": ";_.each(["row","col"],function(t){var e=r.network_data[t+"_nodes"],n=c(e);e.forEach(function(e,o){e[t+"_index"]=o,n&&(r.super_labels=!0,r.super[t]=e.name.split(u)[0],e.name=e.name.split(u)[1]),e.name=String(e.name),e.name=e.name.replace(/_/g," ")})}),r.network_data.row_nodes_names=n.pluck(r.network_data.row_nodes,"name"),r.network_data.col_nodes_names=n.pluck(r.network_data.col_nodes,"name"),r.sim_mat=l(r);var d=a(r.network_data.views),f={};_.each(_.keys(d.possible_filters),function(t){var e=i(d.filter_data,t);f[t]=e}),_.has(r.network_data,"views")&&r.network_data.views.forEach(function(t){_.each(_.keys(d.possible_filters),function(e){_.has(t,e)||(t[e]=f[e])});var e=t.nodes;_.each(["row","col"],function(t){var r=c(e[t+"_nodes"]);e[t+"_nodes"].forEach(function(e,n){e[t+"_index"]=n,r&&(e.name=e.name.split(u)[1]),e.name=String(e.name),e.name=e.name.replace(/_/g," ")})})});var p=r.network_data.col_nodes,h=r.network_data.row_nodes;if(_.has(r.network_data,"mat")){for(var v=[],m=r.network_data.mat,g={},y=0;y<m.length;y++)for(var w=0;w<m[0].length;w++)g={},g.source=y,g.target=w,g.value=m[y][w],v.push(g);r.network_data.links=v}if(r.network_data.links.forEach(function(t){t.name=h[t.source].name+"_"+p[t.target].name,t.row_name=h[t.source].name,t.col_name=p[t.target].name}),r.transpose){r.network_data=o(r.network_data);var x=t.col_label,b=t.row_label;t.row_label=x,t.col_label=b}n.is_undefined(t.row_label)||n.is_undefined(t.col_label)||(r.super_labels=!0,r.super={},r.super.row=t.row_label,r.super.col=t.col_label),r.inst_order={},!n.is_undefined(t.order)&&n.is_supported_order(t.order)?(r.inst_order.row=t.order,r.inst_order.col=t.order):(r.inst_order.row="clust",r.inst_order.col="clust"),!n.is_undefined(t.row_order)&&n.is_supported_order(t.row_order)&&(r.inst_order.col=t.row_order),!n.is_undefined(t.col_order)&&n.is_supported_order(t.col_order)&&(r.inst_order.row=t.col_order);var z=n.has(r.network_data.row_nodes[0],"group"),k=n.has(r.network_data.col_nodes[0],"group");return r.show_dendrogram=z||k,n.has(r.network_data.links[0],"value_orig")?r.keep_orig=!0:r.keep_orig=!1,r}},function(t,e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={normal_name:function(t){var e=t.name.replace(/_/g," ").split("#")[0];return e},is_supported_order:function(t){return"ini"===t||"clust"===t||"rank_var"===t||"rank"===t||"class"===t||"alpha"==t},has:function(t,e){return null!=t&&hasOwnProperty.call(t,e)},property:function(t){return function(e){return null==e?void 0:e[t]}},pluck:function(t,e){var r=this;if(window._){if("function"==typeof _.pluck)return _.pluck(t,e);if("function"==typeof _.map)return _.map(t,r.property(e))}else if(t.map&&"function"==typeof t.map)return t.map(r.property(e))},is_undefined:function(t){return void 0===t},extend:function(t,e){t=t||{};for(var n in e)"object"===r(e[n])?t[n]=this.extend(t[n],e[n]):t[n]=e[n];return t}}},function(t,e,r){"use strict";var n=r(2);t.exports=function(t){var e,r,o={};for(o.row_nodes=t.col_nodes,o.col_nodes=t.row_nodes,o.links=[],r=0;r<t.links.length;r++)e={},e.source=t.links[r].target,e.target=t.links[r].source,e.value=t.links[r].value,n.has(t.links[r],"highlight")&&(e.highlight=t.links[r].highlight),n.has(t.links[r],"value_up")&&(e.value_up=t.links[r].value_up),n.has(t.links[r],"value_dn")&&(e.value_dn=t.links[r].value_dn),n.has(t.links[r],"info")&&(e.info=t.links[r].info),o.links.push(e);return o}},function(t,e){"use strict";t.exports=function(t){var e={},r={};_.each(t,function(t){var e=_.keys(t);_.each(e,function(e){"nodes"!=e&&(_.has(r,e)||(r[e]=[]),r[e].push(t[e]),r[e]=_.uniq(r[e]))})});var n=_.keys(r);_.each(n,function(t){var n=r[t],o=n.length,a="categorical";_.each(n,function(t){"number"==typeof t&&(a="numerical")}),o>1&&(e[t]=a)});var o={};return o.possible_filters=e,o.filter_data=r,o}},function(t,e){"use strict";t.exports=function(t,e){var r=t[e].sort(function(t,e){return e-t})[0];return r=String(r)}},function(t,e){"use strict";t.exports=function(){var t={row_label_scale:1,col_label_scale:1,super_labels:!1,super:{},show_label_tooltips:!0,show_tile_tooltips:!0,transpose:!1,tile_colors:["#FF0000","#1C86EE"],bar_colors:["#FF0000","#1C86EE"],cat_value_colors:["#2F4F4F","#9370DB"],outline_colors:["orange","black"],highlight_color:"#FFFF00",tile_title:!1,input_domain:0,opacity_scale:"linear",do_zoom:!0,is_zoom:0,is_slider_drag:!1,is_cropping:!1,background_color:"#FFFFFF",super_border_color:"#F5F5F5",outer_margins:{top:0,bottom:0,left:0,right:0},ini_expand:!1,grey_border_width:2,tile_click_hlight:!1,super_label_scale:1,make_tile_tooltip:function(t){return t.info},ini_view:null,requested_view:null,use_sidebar:!0,title:null,about:null,sidebar_width:160,sidebar_icons:!0,row_search_placeholder:"Row",buffer_width:10,show_sim_mat:!1,cat_colors:null,resize:!0,clamp_opacity:.85,expand_button:!0,max_allow_fs:20,dendro_filter:{row:!1,col:!1},cat_filter:{row:!1,col:!1},crop_filter_nodes:{row:!1,col:!1},row_tip_callback:null,col_tip_callback:null,tile_tip_callback:null,matrix_update_callback:null,cat_update_callback:null,dendro_callback:null,dendro_click_callback:null,new_row_cats:null,make_modals:!0,show_viz_border:!1};return t}},function(t,e){"use strict";t.exports=function(t){var e=!1,r=t.network_data.row_nodes_names.length,n=t.network_data.col_nodes_names.length;if(r==n){var o=t.network_data.row_nodes_names,a=t.network_data.col_nodes_names;e=!0,_.each(o,function(t){var r=o.indexOf(t);t!==a[r]&&(e=!1)})}return e&&(t.expand_button=!1),e}},function(t,e){"use strict";t.exports=function(t){var e=": ",r=!0;return _.each(t,function(t){var n=String(t.name);n.indexOf(e)<0&&(r=!1)}),r}},function(t,e,r){"use strict";var n=r(10),o=r(64),a=r(65),i=r(4),s=r(66),l=r(88);t.exports=function(t){var e=$.extend(!0,{},t),r=e;if(r.inst_nodes={},r.inst_nodes.row_nodes=r.network_data.row_nodes,r.inst_nodes.col_nodes=r.network_data.col_nodes,null!==r.ini_view){var c=r.ini_view,u=i(r.network_data.views);r.viz={},r.viz.possible_filters=u.possible_filters,r.viz.filter_data=u.filter_data,c=a(r,c),r.network_data=n(e,r,c),r.requested_view=c}return r=s(r),r.use_sidebar&&(r.sidebar=o(r)),r.zoom_info=l(),r}},function(t,e,r){"use strict";var n=r(11),o=r(63);t.exports=function(t,e,r){var a=t.network_data.views,i=!1;_.has(a[0],"enr_score_type")&&(i=!0);var s=o(e,a,r);i&&0==s.length&&(r={N_row_sum:"all",N_col_sum:"10"},s=o(e,a,r));var l,c=s[0];if("undefined"!=typeof c){var u=c.nodes;l=n(t,u)}else l=t.network_data;return l}},function(t,e,r){"use strict";var n=r(2),o=r(12),a=o.create();a.import(r(25)),a.import(r(62)),t.exports=function(t,e){var r=t.network_data.links,o=n.pluck(e.row_nodes,"name"),i=n.pluck(e.col_nodes,"name"),s=a.matrix(a.zeros([e.row_nodes.length,e.col_nodes.length]));s=s.toArray();var l=_.filter(r,function(t){var e=t.name.split("_")[0],r=t.name.split("_")[1],n=_.indexOf(o,e),a=_.indexOf(i,r);if(n>-1&a>-1)return t.source=n,t.target=a,s[n][a]=t.value,t}),c={};return c.row_nodes=e.row_nodes,c.row_nodes_names=o,c.col_nodes=e.col_nodes,c.col_nodes_names=i,c.links=l,c.all_links=r,c.mat=s,c.views=t.network_data.views,_.has(t.network_data,"cat_colors")&&(c.cat_colors=t.network_data.cat_colors),c}},function(t,e,r){"use strict";t.exports=r(13)},function(t,e,r){"use strict";var n=r(14).isFactory,o=r(16),a=r(20),i=r(22),s=r(24);e.create=function(t){function e(t){if(!n(t))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var o,a=r.indexOf(t);return a===-1?(o=t.math===!0?t.factory(c.type,u,e,c.typed,c):t.factory(c.type,u,e,c.typed),r.push(t),l.push(o)):o=l[a],o}if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r=[],l=[],c=a.mixin({});c.type={},c.expression={transform:{},mathWithTransform:{}},c.typed=o.create(c.type);var u={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};return c.import=e(i),c.config=e(s),c.expression.mathWithTransform.config=c.config,t&&c.config(t),c}},function(t,e,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=r(15);e.clone=function t(r){var a="undefined"==typeof r?"undefined":n(r);if("number"===a||"string"===a||"boolean"===a||null===r||void 0===r)return r;if("function"==typeof r.clone)return r.clone();if(Array.isArray(r))return r.map(function(e){return t(e)});if(r instanceof Number)return new Number(r.valueOf());if(r instanceof String)return new String(r.valueOf());if(r instanceof Boolean)return new Boolean(r.valueOf());if(r instanceof Date)return new Date(r.valueOf());if(o(r))return r;if(r instanceof RegExp)throw new TypeError("Cannot clone "+r);return e.map(r,t)},e.map=function(t,r){var n={};for(var o in t)e.hasOwnProperty(t,o)&&(n[o]=r(t[o]));return n},e.extend=function(t,r){for(var n in r)e.hasOwnProperty(r,n)&&(t[n]=r[n]);return t},e.deepExtend=function t(r,n){if(Array.isArray(n))throw new TypeError("Arrays are not supported by deepExtend");for(var o in n)if(e.hasOwnProperty(n,o))if(n[o]&&n[o].constructor===Object)void 0===r[o]&&(r[o]={}),r[o].constructor===Object?t(r[o],n[o]):r[o]=n[o];else{if(Array.isArray(n[o]))throw new TypeError("Arrays are not supported by deepExtend");r[o]=n[o]}return r},e.deepEqual=function(t,r){var o,a,i;if(Array.isArray(t)){if(!Array.isArray(r))return!1;if(t.length!=r.length)return!1;for(a=0,i=t.length;a<i;a++)if(!e.deepEqual(t[a],r[a]))return!1;return!0}if(t instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(o in t)if(!e.deepEqual(t[o],r[o]))return!1;for(o in r)if(!e.deepEqual(t[o],r[o]))return!1;return!0}return("undefined"==typeof t?"undefined":n(t))===("undefined"==typeof r?"undefined":n(r))&&t==r},e.canDefineProperty=function(){try{if(Object.defineProperty)return Object.defineProperty({},"x",{get:function(){}}),!0}catch(t){}return!1},e.lazy=function(t,r,n){if(e.canDefineProperty()){var o,a=!0;Object.defineProperty(t,r,{get:function(){return a&&(o=n(),a=!1),o},set:function(t){o=t,a=!1},configurable:!0,enumerable:!0})}else t[r]=n()},e.traverse=function(t,e){var r=t;if(e)for(var n=e.split("."),o=0;o<n.length;o++){var a=n[o];a in r||(r[a]={}),r=r[a]}return r},e.hasOwnProperty=function(t,e){return t&&Object.hasOwnProperty.call(t,e)},e.isFactory=function(t){return t&&"function"==typeof t.factory}},function(t,e){"use strict";t.exports=function(t){return t&&t.constructor.prototype.isBigNumber||!1}},function(t,e,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=r(17),a=r(18).digits,i=r(15),s=r(19),l=function(){return l=o.create,o};e.create=function(t){t.isNumber=function(t){return"number"==typeof t},t.isComplex=function(e){return t.Complex&&e instanceof t.Complex||!1},t.isBigNumber=i,t.isFraction=function(e){return t.Fraction&&e instanceof t.Fraction||!1},t.isUnit=function(t){return t&&t.constructor.prototype.isUnit||!1},t.isString=function(t){return"string"==typeof t},t.isArray=Array.isArray,t.isMatrix=s,t.isDenseMatrix=function(t){return t&&t.isDenseMatrix&&t.constructor.prototype.isMatrix||!1},t.isSparseMatrix=function(t){return t&&t.isSparseMatrix&&t.constructor.prototype.isMatrix||!1},t.isRange=function(t){return t&&t.constructor.prototype.isRange||!1},t.isIndex=function(t){return t&&t.constructor.prototype.isIndex||!1},t.isBoolean=function(t){return"boolean"==typeof t},t.isResultSet=function(t){return t&&t.constructor.prototype.isResultSet||!1},t.isHelp=function(t){return t&&t.constructor.prototype.isHelp||!1},t.isFunction=function(t){return"function"==typeof t},t.isDate=function(t){return t instanceof Date},t.isRegExp=function(t){return t instanceof RegExp},t.isObject=function(t){return"object"===("undefined"==typeof t?"undefined":n(t))},t.isNull=function(t){return null===t},t.isUndefined=function(t){return void 0===t},t.isAccessorNode=function(t){return t&&t.isAccessorNode&&t.constructor.prototype.isNode||!1},t.isArrayNode=function(t){return t&&t.isArrayNode&&t.constructor.prototype.isNode||!1},t.isAssignmentNode=function(t){return t&&t.isAssignmentNode&&t.constructor.prototype.isNode||!1},t.isBlockNode=function(t){return t&&t.isBlockNode&&t.constructor.prototype.isNode||!1},t.isConditionalNode=function(t){return t&&t.isConditionalNode&&t.constructor.prototype.isNode||!1},t.isConstantNode=function(t){return t&&t.isConstantNode&&t.constructor.prototype.isNode||!1},t.isFunctionAssignmentNode=function(t){return t&&t.isFunctionAssignmentNode&&t.constructor.prototype.isNode||!1},t.isFunctionNode=function(t){return t&&t.isFunctionNode&&t.constructor.prototype.isNode||!1},t.isIndexNode=function(t){return t&&t.isIndexNode&&t.constructor.prototype.isNode||!1},t.isNode=function(t){return t&&t.isNode&&t.constructor.prototype.isNode||!1},t.isObjectNode=function(t){return t&&t.isObjectNode&&t.constructor.prototype.isNode||!1},t.isOperatorNode=function(t){return t&&t.isOperatorNode&&t.constructor.prototype.isNode||!1},t.isParenthesisNode=function(t){return t&&t.isParenthesisNode&&t.constructor.prototype.isNode||!1},t.isRangeNode=function(t){return t&&t.isRangeNode&&t.constructor.prototype.isNode||!1},t.isSymbolNode=function(t){return t&&t.isSymbolNode&&t.constructor.prototype.isNode||!1},t.isChain=function(t){return t&&t.constructor.prototype.isChain||!1};var e=l();return e.types=[{name:"number",test:t.isNumber},{name:"Complex",test:t.isComplex},{name:"BigNumber",test:t.isBigNumber},{name:"Fraction",test:t.isFraction},{name:"Unit",test:t.isUnit},{name:"string",test:t.isString},{name:"Array",test:t.isArray},{name:"Matrix",test:t.isMatrix},{name:"DenseMatrix",test:t.isDenseMatrix},{name:"SparseMatrix",test:t.isSparseMatrix},{name:"Range",test:t.isRange},{name:"Index",test:t.isIndex},{name:"boolean",test:t.isBoolean},{name:"ResultSet",test:t.isResultSet},{name:"Help",test:t.isHelp},{name:"function",test:t.isFunction},{name:"Date",test:t.isDate},{name:"RegExp",test:t.isRegExp},{name:"Object",test:t.isObject},{name:"null",test:t.isNull},{name:"undefined",test:t.isUndefined},{name:"OperatorNode",test:t.isOperatorNode},{name:"ConstantNode",test:t.isConstantNode},{name:"SymbolNode",test:t.isSymbolNode},{name:"ParenthesisNode",test:t.isParenthesisNode},{name:"FunctionNode",test:t.isFunctionNode},{name:"FunctionAssignmentNode",test:t.isFunctionAssignmentNode},{name:"ArrayNode",test:t.isArrayNode},{name:"AssignmentNode",test:t.isAssignmentNode},{name:"BlockNode",test:t.isBlockNode},{name:"ConditionalNode",test:t.isConditionalNode},{name:"IndexNode",test:t.isIndexNode},{name:"RangeNode",test:t.isRangeNode},{name:"Node",test:t.isNode}],e.conversions=[{from:"number",to:"BigNumber",convert:function(e){if(a(e)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t.BigNumber(e)}},{from:"number",to:"Complex",convert:function(e){return new t.Complex(e,0)}},{from:"number",to:"string",convert:function(t){return t+""}},{from:"BigNumber",to:"Complex",convert:function(e){return new t.Complex(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(t){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return new t.Complex(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){var r=new t.Fraction(e);if(r.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return new t.Fraction(e)}},{from:"string",to:"number",convert:function(t){var e=Number(t);if(isNaN(e))throw new Error('Cannot convert "'+t+'" to a number');return e}},{from:"string",to:"BigNumber",convert:function(e){try{return new t.BigNumber(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){try{return new t.Fraction(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){try{return new t.Complex(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(t){return+t}},{from:"boolean",to:"BigNumber",convert:function(e){return new t.BigNumber(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return new t.Fraction(+e)}},{from:"boolean",to:"string",convert:function(t){return+t}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new t.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new t.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(e){return new t.DenseMatrix(e)}},{from:"Matrix",to:"Array",convert:function(t){return t.valueOf()}}],e}},function(t,e,r){var n,o,a,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(r,i){o=[],n=i,a="function"==typeof n?n.apply(e,o):n,!(void 0!==a&&(t.exports=a))}(void 0,function(){function t(){function e(t){for(var e,r=0;r<A.types.length;r++){var n=A.types[r];if(n.name===t){e=n.test;break}}if(!e){var o;for(r=0;r<A.types.length;r++)if(n=A.types[r],n.name.toLowerCase()==t.toLowerCase()){o=n.name;break}throw new Error('Unknown type "'+t+'"'+(o?'. Did you mean "'+o+'"?':""))}return e}function r(t){for(var e="",r=0;r<t.length;r++){var n=t[r];if(n.signatures&&""!=n.name)if(""==e)e=n.name;else if(e!=n.name){var o=new Error("Function names do not match (expected: "+e+", actual: "+n.name+")");throw o.data={actual:n.name,expected:e},o}}return e}function n(t,e,r,n,o){var a,i=v(n),s=o?o.split(","):null,l=t||"unnamed",c=s&&m(s,"any"),u={fn:t,index:r,actual:n,expected:s};a=s?e>r&&!c?"Unexpected type of argument in function "+l+" (expected: "+s.join(" or ")+", actual: "+i+", index: "+r+")":"Too few arguments in function "+l+" (expected: "+s.join(" or ")+", index: "+r+")":"Too many arguments in function "+l+" (expected: "+r+", actual: "+e+")";var d=new TypeError(a);return d.data=u,d}function o(t){this.name=t||"refs",this.categories={}}function a(t,e){if("string"==typeof t){var r=t.trim(),n="..."===r.substr(0,3);if(n&&(r=r.substr(3)),""===r)this.types=["any"];else{this.types=r.split("|");for(var o=0;o<this.types.length;o++)this.types[o]=this.types[o].trim()}}else{if(!Array.isArray(t)){if(t instanceof a)return t.clone();throw new Error("String or Array expected")}this.types=t}this.conversions=[],this.varArgs=n||e||!1,this.anyType=this.types.indexOf("any")!==-1}function s(t,e){var r;if("string"==typeof t)r=""!==t?t.split(","):[];else{if(!Array.isArray(t))throw new Error("string or Array expected");r=t}this.params=new Array(r.length),this.anyType=!1,this.varArgs=!1;for(var n=0;n<r.length;n++){var o=new a(r[n]);if(this.params[n]=o,o.anyType&&(this.anyType=!0),n===r.length-1)this.varArgs=o.varArgs;else if(o.varArgs)throw new SyntaxError('Unexpected variable arguments operator "..."')}this.fn=e}function l(t,e,r,n){this.path=t||[],this.param=t[t.length-1]||null,this.signature=e||null,this.childs=r||[],this.fallThrough=n||!1}function c(t){var e,r,n={},o=[];for(var a in t)if(t.hasOwnProperty(a)){var i=t[a];if(e=new s(a,i),e.ignore())continue;var l=e.expand();for(r=0;r<l.length;r++){var c=l[r],u=c.toString(),d=n[u];if(d){var f=s.compare(c,d);if(f<0)n[u]=c;else if(0===f)throw new Error('Signature "'+u+'" is defined twice')}else n[u]=c}}for(u in n)n.hasOwnProperty(u)&&o.push(n[u]);for(o.sort(function(t,e){return s.compare(t,e)}),r=0;r<o.length;r++)if(e=o[r],e.varArgs)for(var p=e.params.length-1,_=e.params[p],h=0;h<_.types.length;){if(_.conversions[h])for(var v=_.types[h],g=0;g<o.length;g++){var y=o[g],w=y.params[p];if(y!==e&&w&&m(w.types,v)&&!w.conversions[p]){_.types.splice(h,1),_.conversions.splice(h,1),h--;break}}h++}return o}function u(t){for(var e=[],r=0;r<t.length;r++)t[r].anyType&&e.push(t[r]);return e}function d(t){for(var e={},r=0;r<t.length;r++){var n=t[r];if(n.fn&&!n.hasConversions()){var o=n.params.join(",");e[o]=n.fn}}return e}function f(t,e,r){var n,o,i,s=e.length,c=[];for(n=0;n<t.length;n++)o=t[n],o.params.length!==s||i||(i=o),void 0!=o.params[s]&&c.push(o);c.sort(function(t,e){return a.compare(t.params[s],e.params[s])});var u=[];for(n=0;n<c.length;n++){o=c[n];var d=o.params[s],p=u.filter(function(t){return t.param.overlapping(d)})[0];if(p){if(p.param.varArgs)throw new Error('Conflicting types "'+p.param+'" and "'+d+'"');p.signatures.push(o)}else u.push({param:d,signatures:[o]})}var _=[];for(n=0;n<r.length;n++)r[n].paramsStartWith(e)&&_.push(r[n]);var h=!1;for(n=0;n<_.length;n++)if(!m(t,_[n])){h=!0;break}var v=new Array(u.length);for(n=0;n<u.length;n++){var g=u[n];v[n]=f(g.signatures,e.concat(g.param),_)}return new l(e,i,v,h)}function p(t){for(var e=[],r=0;r<t;r++)e[r]="arg"+r;return e}function _(t,e){var r=new o,a=c(e);if(0==a.length)throw new Error("No signatures provided");var i=u(a),s=f(a,[],i),l=[],_=(t||"").replace(/[^a-zA-Z0-9_$]/g,"_"),v=p(h(a));l.push("function "+_+"("+v.join(", ")+") {"),l.push(' "use strict";'),l.push(" var name = "+JSON.stringify(t||"")+";"),l.push(s.toCode(r," ",!1)),l.push("}");var m=[r.toCode(),"return "+l.join("\n")].join("\n"),g=new Function(r.name,"createError",m),y=g(r,n);return y.signatures=d(a),y}function h(t){for(var e=0,r=0;r<t.length;r++){var n=t[r].params.length;n>e&&(e=n)}return e}function v(t){for(var e,r=0;r<A.types.length;r++){var n=A.types[r];if("Object"===n.name)e=n;else if(n.test(t))return n.name}return e&&e.test(t)?e.name:"unknown"}function m(t,e){return t.indexOf(e)!==-1}function g(t){return t[t.length-1]}function y(t,e){if(!t.signatures)throw new TypeError("Function is no typed-function");var r;if("string"==typeof e){r=e.split(",");for(var n=0;n<r.length;n++)r[n]=r[n].trim()}else{if(!Array.isArray(e))throw new TypeError("String array or a comma separated string expected");r=e}var o=r.join(","),a=t.signatures[o];if(a)return a;throw new TypeError("Signature not found (signature: "+(t.name||"unnamed")+"("+r.join(", ")+"))")}function w(t,e){var r=v(t);if(e===r)return t;for(var n=0;n<A.conversions.length;n++){var o=A.conversions[n];if(o.from===r&&o.to===e)return o.convert(t)}throw new Error("Cannot convert from "+r+" to "+e)}o.prototype.add=function(t,e){var r=e||"fn";this.categories[r]||(this.categories[r]=[]);var n=this.categories[r].indexOf(t);return n==-1&&(n=this.categories[r].length,this.categories[r].push(t)),r+n},o.prototype.toCode=function(){var t=[],e=this.name+".categories",r=this.categories;for(var n in r)if(r.hasOwnProperty(n))for(var o=r[n],a=0;a<o.length;a++)t.push("var "+n+a+" = "+e+"['"+n+"']["+a+"];");return t.join("\n")},a.compare=function(t,e){if(t.anyType)return 1;if(e.anyType)return-1;if(m(t.types,"Object"))return 1;if(m(e.types,"Object"))return-1;if(t.hasConversions()){if(e.hasConversions()){var r,n,o;for(r=0;r<t.conversions.length;r++)if(void 0!==t.conversions[r]){n=t.conversions[r];break}for(r=0;r<e.conversions.length;r++)if(void 0!==e.conversions[r]){o=e.conversions[r];break}return A.conversions.indexOf(n)-A.conversions.indexOf(o)}return 1}if(e.hasConversions())return-1;var a,i;for(r=0;r<A.types.length;r++)if(A.types[r].name===t.types[0]){a=r;break}for(r=0;r<A.types.length;r++)if(A.types[r].name===e.types[0]){i=r;break}return a-i},a.prototype.overlapping=function(t){for(var e=0;e<this.types.length;e++)if(m(t.types,this.types[e]))return!0;return!1},a.prototype.matches=function(t){return this.anyType||t.anyType||this.overlapping(t)},a.prototype.clone=function(){var t=new a(this.types.slice(),this.varArgs);return t.conversions=this.conversions.slice(),t},a.prototype.hasConversions=function(){return this.conversions.length>0},a.prototype.contains=function(t){for(var e=0;e<this.types.length;e++)if(t[this.types[e]])return!0;return!1},a.prototype.toString=function(t){for(var e=[],r={},n=0;n<this.types.length;n++){var o=this.conversions[n],a=t&&o?o.to:this.types[n];a in r||(r[a]=!0,e.push(a))}return(this.varArgs?"...":"")+e.join("|")},s.prototype.clone=function(){return new s(this.params.slice(),this.fn)},s.prototype.expand=function(){function t(r,n){if(n.length<r.params.length){var o,i,l,c=r.params[n.length];if(c.varArgs){for(i=c.clone(),o=0;o<A.conversions.length;o++)if(l=A.conversions[o],!m(c.types,l.from)&&m(c.types,l.to)){var u=i.types.length;i.types[u]=l.from,i.conversions[u]=l}t(r,n.concat(i))}else{for(o=0;o<c.types.length;o++)t(r,n.concat(new a(c.types[o])));for(o=0;o<A.conversions.length;o++)l=A.conversions[o],!m(c.types,l.from)&&m(c.types,l.to)&&(i=new a(l.from),i.conversions[0]=l,t(r,n.concat(i)))}}else e.push(new s(n,r.fn))}var e=[];return t(this,[]),e},s.compare=function(t,e){if(t.params.length>e.params.length)return 1;if(t.params.length<e.params.length)return-1;var r,n=t.params.length,o=0,i=0;for(r=0;r<n;r++)t.params[r].hasConversions()&&o++,e.params[r].hasConversions()&&i++;if(o>i)return 1;if(o<i)return-1;for(r=0;r<t.params.length;r++){var s=a.compare(t.params[r],e.params[r]);if(0!==s)return s}return 0},s.prototype.hasConversions=function(){for(var t=0;t<this.params.length;t++)if(this.params[t].hasConversions())return!0;return!1},s.prototype.ignore=function(){for(var t={},e=0;e<A.ignore.length;e++)t[A.ignore[e]]=!0;for(e=0;e<this.params.length;e++)if(this.params[e].contains(t))return!0;return!1},s.prototype.paramsStartWith=function(t){if(0===t.length)return!0;for(var e=g(this.params),r=g(t),n=0;n<t.length;n++){var o=this.params[n]||(e.varArgs?e:null),a=t[n]||(r.varArgs?r:null);if(!o||!a||!o.matches(a))return!1}return!0},s.prototype.toCode=function(t,e){for(var r=[],n=new Array(this.params.length),o=0;o<this.params.length;o++){var a=this.params[o],i=a.conversions[0];a.varArgs?n[o]="varArgs":i?n[o]=t.add(i.convert,"convert")+"(arg"+o+")":n[o]="arg"+o}var s=this.fn?t.add(this.fn,"signature"):void 0;return s?e+"return "+s+"("+n.join(", ")+"); // signature: "+this.params.join(", "):r.join("\n")},s.prototype.toString=function(){return this.params.join(", ")},l.prototype.toCode=function(t,r){var n=[];if(this.param){var o=this.path.length-1,a=this.param.conversions[0],i="// type: "+(a?a.from+" (convert to "+a.to+")":this.param);if(this.param.varArgs)if(this.param.anyType)n.push(r+"if (arguments.length > "+o+") {"),n.push(r+" var varArgs = [];"),n.push(r+" for (var i = "+o+"; i < arguments.length; i++) {"),n.push(r+" varArgs.push(arguments[i]);"),n.push(r+" }"),n.push(this.signature.toCode(t,r+" ")),n.push(r+"}");else{for(var s=function(r,n){for(var o=[],a=0;a<r.length;a++)o[a]=t.add(e(r[a]),"test")+"("+n+")";return o.join(" || ")}.bind(this),l=this.param.types,c=[],u=0;u<l.length;u++)void 0===this.param.conversions[u]&&c.push(l[u]);n.push(r+"if ("+s(l,"arg"+o)+") { "+i),n.push(r+" var varArgs = [arg"+o+"];"),n.push(r+" for (var i = "+(o+1)+"; i < arguments.length; i++) {"),n.push(r+" if ("+s(c,"arguments[i]")+") {"),n.push(r+" varArgs.push(arguments[i]);");for(var u=0;u<l.length;u++){var d=this.param.conversions[u];if(d){var f=t.add(e(l[u]),"test"),p=t.add(d.convert,"convert");n.push(r+" }"),n.push(r+" else if ("+f+"(arguments[i])) {"),n.push(r+" varArgs.push("+p+"(arguments[i]));")}}n.push(r+" } else {"),n.push(r+" throw createError(name, arguments.length, i, arguments[i], '"+c.join(",")+"');"),n.push(r+" }"),n.push(r+" }"),n.push(this.signature.toCode(t,r+" ")),n.push(r+"}")}else if(this.param.anyType)n.push(r+"// type: any"),n.push(this._innerCode(t,r));else{var _=this.param.types[0],f="any"!==_?t.add(e(_),"test"):null;n.push(r+"if ("+f+"(arg"+o+")) { "+i),n.push(this._innerCode(t,r+" ")),n.push(r+"}")}}else n.push(this._innerCode(t,r));return n.join("\n")},l.prototype._innerCode=function(t,e){var r,n=[];for(this.signature&&(n.push(e+"if (arguments.length === "+this.path.length+") {"),n.push(this.signature.toCode(t,e+" ")),n.push(e+"}")),r=0;r<this.childs.length;r++)n.push(this.childs[r].toCode(t,e));if(!this.fallThrough||this.param&&this.param.anyType){var o=this._exceptions(t,e);o&&n.push(o)}return n.join("\n")},l.prototype._exceptions=function(t,e){var r=this.path.length;if(0===this.childs.length)return[e+"if (arguments.length > "+r+") {",e+" throw createError(name, arguments.length, "+r+", arguments["+r+"]);",e+"}"].join("\n");for(var n={},o=[],a=0;a<this.childs.length;a++){var i=this.childs[a];if(i.param)for(var s=0;s<i.param.types.length;s++){var l=i.param.types[s];l in n||i.param.conversions[s]||(n[l]=!0,o.push(l))}}return e+"throw createError(name, arguments.length, "+r+", arguments["+r+"], '"+o.join(",")+"');"};var x=[{name:"number",test:function(t){return"number"==typeof t}},{name:"string",test:function(t){return"string"==typeof t}},{name:"boolean",test:function(t){return"boolean"==typeof t}},{name:"Function",test:function(t){return"function"==typeof t}},{name:"Array",test:Array.isArray},{name:"Date",test:function(t){return t instanceof Date}},{name:"RegExp",test:function(t){return t instanceof RegExp}},{name:"Object",test:function(t){return"object"===("undefined"==typeof t?"undefined":i(t))}},{name:"null",test:function(t){return null===t}},{name:"undefined",test:function(t){return void 0===t}}],b={},z=[],k=[],A={config:b,types:x,conversions:z,ignore:k};return A=_("typed",{Object:function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(t[n]);var o=r(e);return _(o,t)},"string, Object":_,"...Function":function(t){for(var e,n=r(t),o={},a=0;a<t.length;a++){var s=t[a];if("object"!==i(s.signatures))throw e=new TypeError("Function is no typed-function (index: "+a+")"),e.data={index:a},e;for(var l in s.signatures)if(s.signatures.hasOwnProperty(l))if(o.hasOwnProperty(l)){if(s.signatures[l]!==o[l])throw e=new Error('Signature "'+l+'" is defined twice'),e.data={signature:l},e}else o[l]=s.signatures[l]}return _(n,o)}}),A.config=b,
A.types=x,A.conversions=z,A.ignore=k,A.create=t,A.find=y,A.convert=w,A.addType=function(t){if(!t||"string"!=typeof t.name||"function"!=typeof t.test)throw new TypeError("Object with properties {name: string, test: function} expected");A.types.push(t)},A.addConversion=function(t){if(!t||"string"!=typeof t.from||"string"!=typeof t.to||"function"!=typeof t.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");A.conversions.push(t)},A}return t()})},function(t,e){"use strict";function r(t){for(var e=[],r=0;r<t;r++)e.push(0);return e}e.isNumber=function(t){return"number"==typeof t},e.isInteger=function(t){return!!isFinite(t)&&t==Math.round(t)},e.sign=Math.sign||function(t){return t>0?1:t<0?-1:0},e.format=function(t,r){if("function"==typeof r)return r(t);if(t===1/0)return"Infinity";if(t===-(1/0))return"-Infinity";if(isNaN(t))return"NaN";var n="auto",o=void 0;switch(r&&(r.notation&&(n=r.notation),e.isNumber(r)?o=r:r.precision&&(o=r.precision)),n){case"fixed":return e.toFixed(t,o);case"exponential":return e.toExponential(t,o);case"engineering":return e.toEngineering(t,o);case"auto":return e.toPrecision(t,o,r&&r.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var t=arguments[2],e=arguments[4];return"."!==t?t+e:e});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},e.splitNumber=function(t){var e=String(t).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!e)throw new SyntaxError("Invalid number "+t);var r=e[1],n=e[2],o=parseFloat(e[4]||"0"),a=n.indexOf(".");o+=a!==-1?a-1:n.length-1;var i=n.replace(".","").replace(/^0*/,function(t){return o-=t.length,""}).replace(/0*$/,"").split("").map(function(t){return parseInt(t)});return 0===i.length&&(i.push(0),o++),{sign:r,coefficients:i,exponent:o}},e.toEngineering=function(t,n){if(isNaN(t)||!isFinite(t))return String(t);var o=e.roundDigits(e.splitNumber(t),n),a=o.exponent,i=o.coefficients,s=a%3===0?a:a<0?a-3-a%3:a-a%3,l=a>=0?a:Math.abs(s);i.length-1<l&&(i=i.concat(r(l-(i.length-1))));for(var c=Math.abs(a-s),u=1;--c>=0;)u++;var d=i.slice(u).join(""),f=d.match(/[1-9]/)?"."+d:"",p=i.slice(0,u).join("")+f+"e"+(a>=0?"+":"")+s.toString();return o.sign+p},e.toFixed=function(t,n){if(isNaN(t)||!isFinite(t))return String(t);var o=e.splitNumber(t),a=e.roundDigits(o,o.exponent+1+(n||0)),i=a.coefficients,s=a.exponent+1,l=s+(n||0);return i.length<l&&(i=i.concat(r(l-i.length))),s<0&&(i=r(-s+1).concat(i),s=1),n&&i.splice(s,0,0===s?"0.":"."),a.sign+i.join("")},e.toExponential=function(t,n){if(isNaN(t)||!isFinite(t))return String(t);var o=e.splitNumber(t),a=n?e.roundDigits(o,n):o,i=a.coefficients,s=a.exponent;i.length<n&&(i=i.concat(r(n-i.length)));var l=i.shift();return a.sign+l+(i.length>0?"."+i.join(""):"")+"e"+(s>=0?"+":"")+s},e.toPrecision=function(t,n,o){if(isNaN(t)||!isFinite(t))return String(t);var a=o&&void 0!==o.lower?o.lower:.001,i=o&&void 0!==o.upper?o.upper:1e5,s=e.splitNumber(t),l=Math.abs(Math.pow(10,s.exponent));if(l<a||l>=i)return e.toExponential(t,n);var c=n?e.roundDigits(s,n):s,u=c.coefficients,d=c.exponent;u.length<n&&(u=u.concat(r(n-u.length))),u=u.concat(r(d-u.length+1+(u.length<n?n-u.length:0))),u=r(-d).concat(u);var f=d>0?d:0;return f<u.length-1&&u.splice(f+1,0,"."),c.sign+u.join("")},e.roundDigits=function(t,e){for(var r={sign:t.sign,coefficients:t.coefficients,exponent:t.exponent},n=r.coefficients;e<=0;)n.unshift(0),r.exponent++,e++;if(n.length>e){var o=n.splice(e,n.length-e);if(o[0]>=5){var a=e-1;for(n[a]++;10===n[a];)n.pop(),0===a&&(n.unshift(0),r.exponent++,a++),a--,n[a]++}}return r},e.digits=function(t){return t.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},e.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,e.nearlyEqual=function(t,r,n){if(null==n)return t==r;if(t==r)return!0;if(isNaN(t)||isNaN(r))return!1;if(isFinite(t)&&isFinite(r)){var o=Math.abs(t-r);return o<e.DBL_EPSILON||o<=Math.max(Math.abs(t),Math.abs(r))*n}return!1}},function(t,e){"use strict";t.exports=function(t){return t&&t.constructor.prototype.isMatrix||!1}},function(t,e,r){"use strict";var n=r(21);e.mixin=function(t){var e=new n;return t.on=e.on.bind(e),t.off=e.off.bind(e),t.once=e.once.bind(e),t.emit=e.emit.bind(e),t}},function(t,e){"use strict";function r(){}r.prototype={on:function(t,e,r){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:e,ctx:r}),this},once:function(t,e,r){function n(){o.off(t,n),e.apply(r,arguments)}var o=this;return n._=e,this.on(t,n,r)},emit:function(t){var e=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),n=0,o=r.length;for(n;n<o;n++)r[n].fn.apply(r[n].ctx,e);return this},off:function(t,e){var r=this.e||(this.e={}),n=r[t],o=[];if(n&&e)for(var a=0,i=n.length;a<i;a++)n[a].fn!==e&&n[a].fn._!==e&&o.push(n[a]);return o.length?r[t]=o:delete r[t],this}},t.exports=r},function(t,e,r){"use strict";function n(t,e,r,n,c){function u(t,e){var r=arguments.length;if(1!==r&&2!==r)throw new l("import",r,1,2);if(e||(e={}),i(t))_(t,e);else if(Array.isArray(t))t.forEach(function(t){u(t,e)});else if("object"===("undefined"==typeof t?"undefined":o(t))){for(var n in t)if(t.hasOwnProperty(n)){var a=t[n];h(a)?d(n,a,e):i(t)?_(t,e):u(a,e)}}else if(!e.silent)throw new TypeError("Factory, Object, or Array expected")}function d(t,e,r){if(r.wrap&&"function"==typeof e&&(e=p(e)),v(c[t])&&v(e))return e=r.override?n(t,e.signatures):n(c[t],e),c[t]=e,f(t,e),void c.emit("import",t,function(){return e});if(void 0===c[t]||r.override)return c[t]=e,f(t,e),void c.emit("import",t,function(){return e});if(!r.silent)throw new Error('Cannot import "'+t+'": already exists')}function f(t,e){e&&"function"==typeof e.transform?(c.expression.transform[t]=e.transform,m(t)&&(c.expression.mathWithTransform[t]=e.transform)):(delete c.expression.transform[t],m(t)&&(c.expression.mathWithTransform[t]=e))}function p(t){var e=function(){for(var e=[],r=0,n=arguments.length;r<n;r++){var o=arguments[r];e[r]=o&&o.valueOf()}return t.apply(c,e)};return t.transform&&(e.transform=t.transform),e}function _(t,e){if("string"==typeof t.name){var o=t.name,i=o in c.expression.transform,l=t.path?s(c,t.path):c,u=l.hasOwnProperty(o)?l[o]:void 0,d=function(){var a=r(t);if(a&&"function"==typeof a.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(v(u)&&v(a))return e.override||(a=n(u,a)),a;if(void 0===u||e.override)return a;if(!e.silent)throw new Error('Cannot import "'+o+'": already exists')};t.lazy!==!1?(a(l,o,d),i||("expression.transform"===t.path||g(t))&&a(c.expression.mathWithTransform,o,d)):(l[o]=d(),i||("expression.transform"===t.path||g(t))&&(c.expression.mathWithTransform[o]=d())),c.emit("import",o,d,t.path)}else r(t)}function h(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||e&&t.isUnit(e)||e&&t.isComplex(e)||e&&t.isBigNumber(e)||e&&t.isFraction(e)||e&&t.isMatrix(e)||e&&Array.isArray(e)}function v(t){return"function"==typeof t&&"object"===o(t.signatures)}function m(t){return!y.hasOwnProperty(t)}function g(t){return void 0===t.path&&!y.hasOwnProperty(t.name)}var y={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return u}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=r(14).lazy,i=r(14).isFactory,s=r(14).traverse,l=r(23);e.math=!0,e.name="import",e.factory=n,e.lazy=!0},function(t,e){"use strict";function r(t,e,n,o){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.fn=t,this.count=e,this.min=n,this.max=o,this.message="Wrong number of arguments in function "+t+" ("+e+" provided, "+n+(void 0!=o?"-"+o:"")+" expected)",this.stack=(new Error).stack}r.prototype=new Error,r.prototype.constructor=Error,r.prototype.name="ArgumentsError",r.prototype.isArgumentsError=!0,t.exports=r},function(t,e,r){"use strict";function n(t,e,r,n,o){function a(t){if(t){var r=s.map(e,s.clone);i(t,"matrix",l),i(t,"number",c),s.deepExtend(e,t);var n=s.map(e,s.clone),a=s.map(t,s.clone);return o.emit("config",n,r,a),n}return s.map(e,s.clone)}var l=["Matrix","Array"],c=["number","BigNumber","Fraction"];return a.MATRIX=l,a.NUMBER=c,a}function o(t,e){return t.indexOf(e)!==-1}function a(t,e){return t.map(function(t){return t.toLowerCase()}).indexOf(e.toLowerCase())}function i(t,e,r){if(void 0!==t[e]&&!o(r,t[e])){var n=a(r,t[e]);n!==-1?(console.warn('Warning: Wrong casing for configuration option "'+e+'", should be "'+r[n]+'" instead of "'+t[e]+'".'),t[e]=r[n]):console.warn('Warning: Unknown value "'+t[e]+'" for configuration option "'+e+'". Available options: '+r.map(JSON.stringify).join(", ")+".")}}var s=r(14);e.name="config",e.math=!0,e.factory=n},function(t,e,r){"use strict";t.exports=[r(26),r(36),r(38),r(41),r(51),r(57),r(58),r(59),r(60),r(43),r(61)]},function(t,e,r){"use strict";function n(t,e,r,n){function o(){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator")}return o.prototype.type="Matrix",o.prototype.isMatrix=!0,o.storage=function(t){if(!i(t))throw new TypeError("format must be a string value");var e=o._storage[t];if(!e)throw new SyntaxError("Unsupported matrix storage format: "+t);return e},o._storage={},o.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},o.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},o.prototype.create=function(t,e){throw new Error("Cannot invoke create on a Matrix interface")},o.prototype.subset=function(t,e,r){throw new Error("Cannot invoke subset on a Matrix interface")},o.prototype.get=function(t){throw new Error("Cannot invoke get on a Matrix interface")},o.prototype.set=function(t,e,r){throw new Error("Cannot invoke set on a Matrix interface")},o.prototype.resize=function(t,e){throw new Error("Cannot invoke resize on a Matrix interface")},o.prototype.reshape=function(t,e){throw new Error("Cannot invoke reshape on a Matrix interface")},o.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},o.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},o.prototype.map=function(t,e){throw new Error("Cannot invoke map on a Matrix interface")},o.prototype.forEach=function(t){throw new Error("Cannot invoke forEach on a Matrix interface")},o.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},o.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},o.prototype.format=function(t){throw new Error("Cannot invoke format on a Matrix interface")},o.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},o}var o=r(27),a=o.string,i=a.isString;e.name="Matrix",e.path="type",e.factory=n},function(t,e,r){"use strict";e.array=r(28),e.boolean=r(34),e.function=r(35),e.number=r(18),e.object=r(14),e.string=r(29),e.types=r(31),e.emitter=r(20)},function(t,e,r){"use strict";function n(t,e,r){var o,a=t.length;if(a!=e[r])throw new u(a,e[r]);if(r<e.length-1){var i=r+1;for(o=0;o<a;o++){var s=t[o];if(!Array.isArray(s))throw new u(e.length-1,e.length,"<");n(t[o],e,i)}}else for(o=0;o<a;o++)if(Array.isArray(t[o]))throw new u(e.length+1,e.length,">")}function o(t,r,n,a){var i,s,l=t.length,c=r[n],u=Math.min(l,c);if(t.length=c,n<r.length-1){var d=n+1;for(i=0;i<u;i++)s=t[i],Array.isArray(s)||(s=[s],t[i]=s),o(s,r,d,a);for(i=u;i<c;i++)s=[],t[i]=s,o(s,r,d,a)}else{for(i=0;i<u;i++)for(;Array.isArray(t[i]);)t[i]=t[i][0];if(a!==e.UNINITIALIZED)for(i=u;i<c;i++)t[i]=a}}function a(t,e){var r,n=[];if(0===e.length){if(0===t.length)throw new u(null,null,"!=");return t.shift()}for(r=0;r<e[0];r+=1)n.push(a(t,e.slice(1)));return n}function i(t,e,r){var n,o;if(r<e){var a=r+1;for(n=0,o=t.length;n<o;n++)t[n]=i(t[n],e,a)}else for(;Array.isArray(t);)t=t[0];return t}function s(t,e,r){var n,o;if(Array.isArray(t)){var a=r+1;for(n=0,o=t.length;n<o;n++)t[n]=s(t[n],e,a)}else for(var i=r;i<e;i++)t=[t];return t}var l=r(18),c=r(29),u=(r(14),r(31),r(32)),d=r(33);e.size=function(t){for(var e=[];Array.isArray(t);)e.push(t.length),t=t[0];return e},e.validate=function(t,e){var r=0==e.length;if(r){if(Array.isArray(t))throw new u(t.length,0)}else n(t,e,0)},e.validateIndex=function(t,e){if(!l.isNumber(t)||!l.isInteger(t))throw new TypeError("Index must be an integer (value: "+t+")");if(t<0||"number"==typeof e&&t>=e)throw new d(t,e)},e.UNINITIALIZED={},e.resize=function(t,e,r){if(!Array.isArray(t)||!Array.isArray(e))throw new TypeError("Array expected");if(0===e.length)throw new Error("Resizing to scalar is not supported");e.forEach(function(t){if(!l.isNumber(t)||!l.isInteger(t)||t<0)throw new TypeError("Invalid size, must contain positive integers (size: "+c.format(e)+")")});var n=void 0!==r?r:0;return o(t,e,0,n),t},e.reshape=function(t,r){var n,o=e.flatten(t),i=function(t){return t.reduce(function(t,e){return t*e})};if(!Array.isArray(t)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new u(0,i(e.size(t)),"!=");try{n=a(o,r)}catch(n){if(n instanceof u)throw new u(i(r),i(e.size(t)),"!=");throw n}if(o.length>0)throw new u(i(r),i(e.size(t)),"!=");return n},e.squeeze=function(t,r){for(var n=r||e.size(t);Array.isArray(t)&&1===t.length;)t=t[0],n.shift();for(var o=n.length;1===n[o-1];)o--;return o<n.length&&(t=i(t,o,0),n.length=o),t},e.unsqueeze=function(t,r,n,o){var a=o||e.size(t);if(n)for(var i=0;i<n;i++)t=[t],a.unshift(1);for(t=s(t,r,0);a.length<r;)a.push(1);return t},e.flatten=function(t){if(!Array.isArray(t))return t;var e=[];return t.forEach(function t(r){Array.isArray(r)?r.forEach(t):e.push(r)}),e},e.map=function(t,e){return Array.prototype.map.call(t,e)},e.forEach=function(t,e){Array.prototype.forEach.call(t,e)},e.filter=function(t,r){if(1!==e.size(t).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(t,r)},e.filterRegExp=function(t,r){if(1!==e.size(t).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(t,function(t){return r.test(t)})},e.join=function(t,e){return Array.prototype.join.call(t,e)},e.identify=function(t){if(!Array.isArray(t))throw new TypeError("Array input expected");if(0===t.length)return t;var e=[],r=0;e[0]={value:t[0],identifier:0};for(var n=1;n<t.length;n++)t[n]===t[n-1]?r++:r=0,e.push({value:t[n],identifier:r});return e},e.generalize=function(t){if(!Array.isArray(t))throw new TypeError("Array input expected");if(0===t.length)return t;for(var e=[],r=0;r<t.length;r++)e.push(t[r].value);return e},e.isArray=Array.isArray},function(t,e,r){"use strict";function n(t,r){if(Array.isArray(t)){for(var o="[",a=t.length,i=0;i<a;i++)0!=i&&(o+=", "),o+=n(t[i],r);return o+="]"}return e.format(t,r)}function o(t){return t&&"object"===("undefined"==typeof t?"undefined":a(t))&&"number"==typeof t.s&&"number"==typeof t.n&&"number"==typeof t.d||!1}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=r(18).format,s=r(30).format,l=r(15);e.isString=function(t){return"string"==typeof t},e.endsWith=function(t,e){var r=t.length-e.length,n=t.length;return t.substring(r,n)===e},e.format=function(t,r){if("number"==typeof t)return i(t,r);if(l(t))return s(t,r);if(o(t))return r&&"decimal"===r.fraction?t.toString():t.s*t.n+"/"+t.d;if(Array.isArray(t))return n(t,r);if(e.isString(t))return'"'+t+'"';if("function"==typeof t)return t.syntax?String(t.syntax):"function";if(t&&"object"===("undefined"==typeof t?"undefined":a(t))){if("function"==typeof t.format)return t.format(r);if(t&&t.toString()!=={}.toString())return t.toString();var c=[];for(var u in t)t.hasOwnProperty(u)&&c.push('"'+u+'": '+e.format(t[u],r));return"{"+c.join(", ")+"}"}return String(t)},e.stringify=function(t){for(var e=String(t),r="",n=0;n<e.length;){var o=e.charAt(n);"\\"===o?(r+=o,n++,o=e.charAt(n),""!==o&&'"\\/bfnrtu'.indexOf(o)!==-1||(r+="\\"),r+=o):r+='"'===o?'\\"':o,n++}return'"'+r+'"'},e.escape=function(t){var e=String(t);return e=e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}},function(t,e){"use strict";e.format=function(t,r){if("function"==typeof r)return r(t);if(!t.isFinite())return t.isNaN()?"NaN":t.gt(0)?"Infinity":"-Infinity";var n="auto",o=void 0;switch(void 0!==r&&(r.notation&&(n=r.notation),"number"==typeof r?o=r:r.precision&&(o=r.precision)),n){case"fixed":return e.toFixed(t,o);case"exponential":return e.toExponential(t,o);case"auto":var a=.001,i=1e5;r&&r.exponential&&(void 0!==r.exponential.lower&&(a=r.exponential.lower),void 0!==r.exponential.upper&&(i=r.exponential.upper));({toExpNeg:t.constructor.toExpNeg,toExpPos:t.constructor.toExpPos});if(t.constructor.config({toExpNeg:Math.round(Math.log(a)/Math.LN10),toExpPos:Math.round(Math.log(i)/Math.LN10)}),t.isZero())return"0";var s,l=t.abs();return s=l.gte(a)&&l.lt(i)?t.toSignificantDigits(o).toFixed():e.toExponential(t,o),s.replace(/((\.\d*?)(0+))($|e)/,function(){var t=arguments[2],e=arguments[4];return"."!==t?t+e:e});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},e.toExponential=function(t,e){return void 0!==e?t.toExponential(e-1):t.toExponential()},e.toFixed=function(t,e){return t.toFixed(e||0)}},function(t,e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.type=function(t){var e="undefined"==typeof t?"undefined":r(t);return"object"===e?null===t?"null":Array.isArray(t)?"Array":t instanceof Date?"Date":t instanceof RegExp