orbotix/sphero.js

View on GitHub
dist/sphero.min.js

Summary

Maintainability
A
0 mins
Test Coverage
/*! Sphero.js (c) 2015 Orbotix. MIT License */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.sphero=e()}}(function(){return function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return o(r?r:e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(e,t,r){"use strict";var n,o=e("util"),i=e("events").EventEmitter,s="undefined"!=typeof chrome;try{n=e(s?"browser-serialport":"serialport")}catch(a){n=null}if(null==n){var u=["It looks like serialport didn't compile properly.","This is a common problem, and it's fix is documented here:","https://github.com/voodootikigod/node-serialport#to-install"].join(" ");throw console.error(u),new Error("Missing serialport dependency")}var c=t.exports=function(e){this.conn=e,this.serialport=null};o.inherits(c,i),c.prototype.open=function(e){function t(e){return r.emit.bind(r,e)}var r=this,o=this.serialport=new n.SerialPort(this.conn,{});o.on("open",function(n){return n?void e(n):(r.emit("open"),o.on("error",t("error")),o.on("close",t("close")),o.on("data",t("data")),void e())})},c.prototype.write=function(e,t){this.serialport.write(e,t)},c.prototype.onRead=function(e){this.on("data",e)},c.prototype.close=function(e){this.serialport.close(e)}},{"browser-serialport":14,events:20,serialport:15,util:24}],2:[function(e,t,r){"use strict";t.exports={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074}},{}],3:[function(e,t,r){"use strict";t.exports={ping:1,version:2,controlUARTTx:3,setDeviceName:16,getBtInfo:17,setAutoReconnect:18,getAutoReconnect:19,getPwrState:32,setPwrNotify:33,sleep:34,getPowerTrips:35,setPowerTrips:36,setInactiveTimer:37,goToBl:48,runL1Diags:64,runL2Diags:65,clearCounters:66,assignTime:80,pollTimes:81}},{}],4:[function(e,t,r){"use strict";t.exports={setHeading:1,setStabilization:2,setRotationRate:3,setCreationDate:4,getBallRegWebsite:5,reEnableDemo:6,getChassisId:7,setChassisId:8,selfLevel:9,setVdl:10,setDataStreaming:17,setCollisionDetection:18,locator:19,setAccelerometer:20,readLocator:21,setRgbLed:32,setBackLed:33,getRgbLed:34,roll:48,boost:49,move:50,setRawMotors:51,setMotionTimeout:52,setOptionsFlag:53,getOptionsFlag:54,setTempOptionFlags:55,getTempOptionFlags:56,getConfigBlock:64,setSsbParams:65,setDeviceMode:66,setConfigBlock:67,getDeviceMode:68,getSsb:70,setSsb:71,ssbRefill:72,ssbBuy:73,ssbUseConsumeable:74,ssbGrantCores:75,ssbAddXp:76,ssbLevelUpAttr:77,getPwSeed:78,ssbEnableAsync:79,runMacro:80,saveTempMacro:81,saveMacro:82,initMacroExecutive:84,abortMacro:85,macroStatus:86,setMacroParam:87,appendTempMacroChunk:88,eraseOBStorage:96,appendOBFragment:97,execOBProgram:98,abortOBProgram:99,answerInput:100,commitToFlash:101,commitToFlashAlias:112}},{}],5:[function(e,t,r){"use strict";var n=e("../utils"),o=e("../commands/core");t.exports=function(e){var t=e.command.bind(e,0);e.ping=function(e){t(o.ping,null,e)},e.version=function(e){t(o.version,null,e)},e.controlUartTx=function(e){t(o.controlUARTTx,null,e)},e.setDeviceName=function(e,r){for(var n=[],i=0;i<e.length;++i)n[i]=e.charCodeAt(i);t(o.setDeviceName,n,r)},e.getBluetoothInfo=function(e){t(o.getBtInfo,null,e)},e.setAutoReconnect=function(e,r,n){t(o.setAutoReconnect,[e,r],n)},e.getAutoReconnect=function(e){t(o.getAutoReconnect,null,e)},e.getPowerState=function(e){t(o.getPwrState,null,e)},e.setPowerNotification=function(e,r){t(o.setPwrNotify,[e],r)},e.sleep=function(e,r,i,s){e=n.intToHexArray(e,2),i=n.intToHexArray(i,2);var a=[].concat(e,r,i);t(o.sleep,a,s)},e.getVoltageTripPoints=function(e){t(o.getPowerTrips,null,e)},e.setVoltageTripPoints=function(e,r,i){e=n.intToHexArray(e,2),r=n.intToHexArray(r,2);var s=[].concat(e,r);t(o.setPowerTrips,s,i)},e.setInactivityTimeout=function(e,r){var i=n.intToHexArray(e,2);t(o.setInactiveTimer,i,r)},e.jumpToBootloader=function(e){t(o.goToBl,null,e)},e.runL1Diags=function(e){t(o.runL1Diags,null,e)},e.runL2Diags=function(e){t(o.runL2Diags,null,e)},e.clearCounters=function(e){t(o.clearCounters,null,e)},e._coreTimeCmd=function(e,r,o){var i=n.intToHexArray(r,4);t(e,i,o)},e.assignTime=function(t,r){e._coreTimeCmd(o.assignTime,t,r)},e.pollPacketTimes=function(t,r){e._coreTimeCmd(o.pollTimes,t,r)}}},{"../commands/core":3,"../utils":13}],6:[function(e,t,r){"use strict";function n(e){return{red:e>>16&255,green:e>>8&255,blue:255&e}}var o=e("../colors"),i=e("../utils"),s=/^[A-Fa-f0-9]{6}$/m;t.exports=function(e){function t(t,r,n){return n?(r=i.xor32bit(r),e.ds[t]&r):e.ds[t]|r}e.streamData=function(r){var n={n:Math.round(400/(r.sps||2)),m:1,mask1:t("mask1",r.mask1,r.remove),pcnt:0,mask2:t("mask2",r.mask2,r.remove)};e.on("dataStreaming",function(t){for(var n={},o=0;o<r.fields.length;o++)n[r.fields[o]]=t[r.fields[o]];e.emit(r.event,n)}),e.setDataStreaming(n)},e.color=function(t,r){switch(typeof t){case"number":t=n(t);break;case"string":if(o[t]){t=n(o[t]);break}if("#"===t[0]&&(t=t.slice(1)),s.test(t)){var i=s.exec(t);t=n(parseInt(i[0],16))}else console.error("invalid color provided",t),t=n(16777215);break;case"object":["red","green","blue"].forEach(function(e){var r=e[0];t[r]&&"undefined"==typeof t[e]&&(t[e]=t[r])})}e.setRgbLed(t,r)},e.randomColor=function(t){e.setRgbLed(i.randomColor(),t)},e.getColor=function(t){e.getRgbLed(t)},e.detectCollisions=function(t){e.configureCollisions({meth:1,xt:64,yt:64,xs:80,ys:80,dead:80},t)},e.startCalibration=function(t){e.setBackLed(127),e.setStabilization(0,t)},e.finishCalibration=function(t){e.setHeading(0),e.setBackLed(0),e.setStabilization(1,t)},e.streamOdometer=function(t,r){e.streamData({event:"odometer",mask2:201326592,fields:["xOdometer","yOdometer"],sps:t,remove:r})},e.streamVelocity=function(t,r){e.streamData({event:"velocity",mask2:25165824,fields:["xVelocity","yVelocity"],sps:t,remove:r})},e.streamAccelOne=function(t,r){e.streamData({event:"accelOne",mask2:33554432,fields:["accelOne"],sps:t,remove:r})},e.streamImuAngles=function(t,r){e.streamData({event:"imuAngles",mask1:458752,fields:["pitchAngle","rollAngle","yawAngle"],sps:t,remove:r})},e.streamAccelerometer=function(t,r){e.streamData({event:"accelerometer",mask1:57344,fields:["xAccel","yAccel","zAccel"],sps:t,remove:r})},e.streamGyroscope=function(t,r){e.streamData({event:"gyroscope",mask1:7168,fields:["xGyro","yGyro","zGyro"],sps:t,remove:r})},e.streamMotorsBackEmf=function(t,r){e.streamData({event:"motorsBackEmf",mask1:96,fields:["rMotorBackEmf","lMotorBackEmf"],sps:t,remove:r})},e.stopOnDisconnect=function(t,r){"function"==typeof t&&(r=t,t=!1);var n=t?0:1;e.setTempOptionFlags(n,r)}}},{"../colors":2,"../utils":13}],7:[function(e,t,r){"use strict";var n=e("../utils"),o=e("../commands/sphero");t.exports=function(e){var t=e.command.bind(e,2);e.setHeading=function(e,r){e=n.intToHexArray(e,2),t(o.setHeading,e,r)},e.setStabilization=function(e,r){e&=1,t(o.setStabilization,[e],r)},e.setRotationRate=function(e,r){e&=255,t(o.setRotationRate,[e],r)},e.getChassisId=function(e){t(o.getChassisId,null,e)},e.setChassisId=function(e,r){e=n.intToHexArray(e,2),t(o.getChassisId,e,r)},e.selfLevel=function(e,r){var n=[e.options,e.angleLimit,e.timeout,e.trueTime];t(o.selfLevel,n,r)},e.setDataStreaming=function(r,i){var s=n.intToHexArray(r.n,2),a=n.intToHexArray(r.m,2),u=n.intToHexArray(r.mask1,4),c=r.pcnt&=255,l=n.intToHexArray(r.mask2,4);e.ds={mask1:r.mask1,mask2:r.mask2};var f=[].concat(s,a,u,c,l);t(o.setDataStreaming,f,i)},e.configureCollisions=function(e,r){var n=[e.meth,e.xt,e.xs,e.yt,e.ys,e.dead];t(o.setCollisionDetection,n,r)},e.configureLocator=function(e,r){var i=255&e.flags,s=n.intToHexArray(e.x,2),a=n.intToHexArray(e.y,2),u=n.intToHexArray(e.yawTare,2),c=[].concat(i,s,a,u);t(o.locator,c,r)},e.setAccelRange=function(e,r){e&=e,t(o.setAccelerometer,[e],r)},e.readLocator=function(e){t(o.readLocator,null,e)},e.setRgbLed=function(e,r){for(var n=[e.red,e.green,e.blue,e.flag||1],i=0;i<n.length;i++)n[i]&=255;t(o.setRgbLed,n,r)},e.setBackLed=function(e,r){t(o.setBackLed,[e],r)},e.getRgbLed=function(e){t(o.getRgbLed,null,e)},e.roll=function(e,r,i,s){("function"==typeof i||"undefined"==typeof i)&&(s=i,i=1),e&=255,r=n.intToHexArray(r,2),i&=3;var a=[].concat(e,r,i);t(o.roll,a,s)},e.boost=function(e,r){e&=1,t(o.boost,[e],r)},e.setRawMotors=function(e,r){var n=7&e.lmode,i=255&e.lpower,s=7&e.rmode,a=255&e.rpower,u=[n,i,s,a];t(o.setRawMotors,u,r)},e.setMotionTimeout=function(e,r){e=n.intToHexArray(e,2),t(o.setMotionTimeout,e,r)},e.setPermOptionFlags=function(e,r){e=n.intToHexArray(e,4),t(o.setOptionsFlag,e,r)},e.getPermOptionFlags=function(e){t(o.getOptionsFlag,null,e)},e.setTempOptionFlags=function(e,r){e=n.intToHexArray(e,4),t(o.setTempOptionFlags,e,r)},e.getTempOptionFlags=function(e){t(o.getTempOptionFlags,null,e)},e.getConfigBlock=function(e,r){e&=255,t(o.getConfigBlock,[e],r)},e._setSsbBlock=function(e,r,o,i){r=n.intToHexArray(r,4);var s=[].concat(r,o);t(e,s,i)},e.setSsbModBlock=function(t,r,n){e._setSsbBlock(o.setSsbParams,t,r,n)},e.setDeviceMode=function(e,r){e&=1,t(o.setDeviceMode,[e],r)},e.setConfigBlock=function(e,r){t(o.setConfigBlock,e,r)},e.getDeviceMode=function(e){t(o.getDeviceMode,null,e)},e.getSsb=function(e){t(o.getSsb,null,e)},e.setSsb=function(t,r,n){e._setSsbBlock(o.setSsb,t,r,n)},e.refillBank=function(e,r){e&=255,t(o.ssbRefill,[e],r)},e.buyConsumable=function(e,r,n){e&=255,r&=255,t(o.ssbBuy,[e,r],n)},e.useConsumable=function(e,r){e&=255,t(o.ssbUseConsumeable,[e],r)},e.grantCores=function(e,r,i,s){e=n.intToHexArray(e,4),r=n.intToHexArray(r,4),i&=255;var a=[].concat(e,r,i);t(o.ssbGrantCores,a,s)},e._xpOrLevelUp=function(e,r,o,i){r=n.intToHexArray(r,4),o&=255,t(e,[].concat(r,o),i)},e.addXp=function(t,r,n){e._xpOrLevelUp(o.ssbAddXp,t,r,n)},e.levelUpAttr=function(t,r,n){e._xpOrLevelUp(o.ssbLevelUpAttr,t,r,n)},e.getPasswordSeed=function(e){t(o.getPwSeed,null,e)},e.enableSsbAsyncMsg=function(e,r){e&=1,t(o.ssbEnableAsync,[e],r)},e.runMacro=function(e,r){e&=255,t(o.runMacro,[e],r)},e.saveTempMacro=function(e,r){t(o.saveTempMacro,e,r)},e.saveMacro=function(e,r){t(o.saveMacro,e,r)},e.reInitMacroExec=function(e){t(o.initMacroExecutive,null,e)},e.abortMacro=function(e){t(o.abortMacro,null,e)},e.getMacroStatus=function(e){t(o.macroStatus,null,e)},e.setMacroParam=function(e,r,i,s){t(o.setMacroParam,n.argsToHexArray(e,r,i),s)},e.appendMacroChunk=function(e,r){t(o.appendTempMacroChunk,e,r)},e.eraseOrbBasicStorage=function(e,r){e&=255,t(o.eraseOBStorage,[e],r)},e.appendOrbBasicFragment=function(e,r,n){e&=255;var i=[].concat(e,r);t(o.appendOBFragment,i,n)},e.executeOrbBasicProgram=function(e,r,i,s){t(o.execOBProgram,n.argsToHexArray(e,r,i),s)},e.abortOrbBasicProgram=function(e){t(o.abortOBProgram,null,e)},e.submitValueToInput=function(e,r){e=n.intToHexArray(e,4),t(o.answerInput,e,r)},e.commitToFlash=function(e){t(o.commitToFlash,null,e)},e._commitToFlashAlias=function(e){t(o.commitToFlashAlias,null,e)}}},{"../commands/sphero":4,"../utils":13}],8:[function(e,t,r){"use strict";function n(e){return/(\/dev\/|com\d+).*/i.test(e)}t.exports.load=function(t){var r,o=n(t);"undefined"!=typeof chrome;return o&&(r=e("./adaptors/serialport")),new r(t)}},{"./adaptors/serialport":1}],9:[function(e,t,r){(function(r){"use strict";var n=e("util").inherits,o=e("events").EventEmitter,i=e("./utils"),s=e("./parsers/response.js"),a=e("./parsers/async.js"),u=6,c={size:5,sop1:{pos:0,hex:255},sop2:{pos:1,sync:255,async:254},mrspHex:0,seqHex:0,mrspIdCode:2,seqMsb:3,dlenLsb:4,checksum:5,didHex:0,cidHex:1},l=t.exports=function(){this.partialBuffer=new r(0),this.partialCounter=0};n(l,o),l.prototype.create=function(e){e=e||{};var t=void 0===e.sop1?c.sop1.hex:e.sop1,r=void 0===e.sop2?c.sop2.sync:e.sop2,n=void 0===e.did?c.didHex:e.did,o=void 0===e.cid?c.cidHex:e.cid,s=void 0===e.seq?c.seqHex:e.seq,a=e.data?e.data:[],u=a.length+1,l=0,f=[t,r,n,o,s,u].concat(a);return l=i.checksum(f.slice(2)),f.push(l),f},l.prototype.parse=function(e){if(this.partialBuffer.length>0?(e=r.concat([this.partialBuffer,e],e.length+this.partialBuffer.length),this.partialBuffer=new r(0)):this.partialBuffer=new r(e),this._checkSOPs(e)){if(this._checkMinSize(e)&&this._checkExpectedSize(e)>-1)return this._parse(e);this.partialBuffer=new r(e)}return null},l.prototype._parse=function(e){var t={};t.sop1=e[c.sop1.pos],t.sop2=e[c.sop2.pos];var n=e[c.mrspIdCode],o=e[c.seqMsb],i=e[c.dlenLsb];return c.sop2.sync===e[c.sop2.pos]?(t.mrsp=n,t.seq=o,t.dlen=i):(t.idCode=n,t.dlenMsb=o,t.dlenLsb=i),t.dlen=this._extractDlen(e),t.data=new r(t.dlen-1),e.copy(t.data,0,c.size,c.size+t.dlen-1),t.checksum=e[c.size+t.dlen-1],this._dealWithExtraBytes(e),this._verifyChecksum(e,t)},l.prototype._dealWithExtraBytes=function(e){var t=this._checkExpectedSize(e);e.length>t?(this.partialBuffer=new r(e.length-t),e.copy(this.partialBuffer,0,t)):this.partialBuffer=new r(0)},l.prototype._verifyChecksum=function(e,t){var n=e.slice(c.mrspIdCode,c.checksum+t.dlen-1),o=i.checksum(n);return o!==t.checksum&&(t=null,this.partialBuffer=new r(0),this.emit("error",new Error("Incorrect checksum, packet discarded!"))),t},l.prototype.parseAsyncData=function(e,t){var r=a[e.idCode];return this._parseData(r,e,t)},l.prototype.parseResponseData=function(e,t){if(!e||!e.did||!e.cid)return t;var r=e.did.toString(16)+":"+e.cid.toString(16),n=s[r];return this._parseData(n,t)},l.prototype._parseData=function(e,t,r){var n,o,i,s=t.data;if(e&&s.length>0){if(r=this._checkDSMasks(r,e),-1===r)return t;o=e.fields,n={desc:e.desc,idCode:e.idCode,event:e.event,did:e.did,cid:e.cid,packet:t};for(var a=0,u=0,c=0;c<o.length;){if(i=o[c],u=this._checkDSBit(r,i),1===u)i.from=a,i.to=a+=2;else if(0===u){c=this._incParserIndex(c,o,s,u,a);continue}n[i.name]=this._parseField(i,s,n),c=this._incParserIndex(c,o,s,u,a)}}else n=t;return n},l.prototype._checkDSMasks=function(e,t){return 3!==t.idCode?null:e&&null!=e.mask1&&null!=e.mask2?e:-1},l.prototype._incParserIndex=function(e,t,r,n,o){return e++,n>=0&&e===t.length&&o<r.length&&(e=0),e},l.prototype._checkDSBit=function(e,t){return e?Math.abs(e[t.maskField]&t.bitmask)>0?1:0:-1},l.prototype._parseField=function(e,t,n){var o;switch(t=t.slice(e.from,e.to),o=i.bufferToInt(t),e.type){case"number":"hex"===e.format&&(o="0x"+o.toString(16).toUpperCase());break;case"string":o=t.toString(e.format).replace(/\0/g,"0");break;case"raw":o=new r(t);break;case"predefined":null!=e.mask&&(o&=e.mask),o=e.values[o];break;case"bitmask":o=this._parseBitmaskField(o,e,n);break;default:this.emit("error",new Error("Data could not be parsed!")),o="Data could not be parsed!"}return o},l.prototype._parseBitmaskField=function(e,t,r){var n={};return e>t.range.top&&(e=i.twosToInt(e,2)),r[t.name]?(n=r[t.name],n.value.push(e)):n={sensor:t.sensor,range:t.range,units:t.units,value:[e]},n},l.prototype._checkSOPs=function(e){return this._checkSOP1(e)?this._checkSOP2(e):!1},l.prototype._checkSOP1=function(e){return e[c.sop1.pos]===c.sop1.hex},l.prototype._checkSOP2=function(e){var t=e[c.sop2.pos];return t===c.sop2.sync?"sync":t===c.sop2.async?"async":!1},l.prototype._checkExpectedSize=function(e){var t=c.size+this._extractDlen(e),r=e.length;return t>r?-1:t},l.prototype._checkMinSize=function(e){return e.length>=u},l.prototype._extractDlen=function(e){return e[c.sop2.pos]===c.sop2.sync?e[c.dlenLsb]:e[c.seqMsb]<<8|e[c.dlenLsb]}}).call(this,e("buffer").Buffer)},{"./parsers/async.js":10,"./parsers/response.js":11,"./utils":13,buffer:16,events:20,util:24}],10:[function(e,t,r){"use strict";t.exports={1:{desc:"Battery Power State",idCode:1,did:0,cid:33,event:"battery",fields:[{name:"state",type:"predefined",values:{1:"Battery Charging",2:"Battery OK",3:"Battery Low",4:"Battery Critical"}}]},2:{desc:"Level 1 Diagnostic Response",idCode:2,did:0,cid:64,event:"level1Diagnostic",fields:[{name:"diagnostic",type:"string",format:"ascii",from:0,to:void 0}]},3:{desc:"Sensor Data Streaming",idCode:3,did:2,cid:17,event:"dataStreaming",fields:[{name:"xAccelRaw",type:"bitmask",bitmask:2147483648,maskField:"mask1",sensor:"accelerometer axis X, raw",range:{bottom:-2048,top:2047},units:"4mg"},{name:"yAccelRaw",type:"bitmask",bitmask:1073741824,maskField:"mask1",sensor:"accelerometer axis Y, raw",range:{bottom:-2048,top:2047},units:"4mG"},{name:"zAccelRaw",type:"bitmask",bitmask:536870912,maskField:"mask1",sensor:"accelerometer axis Z, raw",range:{bottom:-2048,top:2047},units:"4mG"},{name:"xGyroRaw",type:"bitmask",bitmask:268435456,maskField:"mask1",sensor:"gyroscope axis X, raw",range:{bottom:-32768,top:32767},units:"0.068 degrees"},{name:"yGyroRaw",type:"bitmask",bitmask:134217728,maskField:"mask1",sensor:"gyroscope axis Y, raw",range:{bottom:-32768,top:32767},units:"0.068 degrees"},{name:"zGyroRaw",type:"bitmask",bitmask:67108864,maskField:"mask1",sensor:"gyroscope axis Z, raw",range:{bottom:-32768,top:32767},units:"0.068 degrees"},{name:"rMotorBackEmfRaw",type:"bitmask",bitmask:4194304,maskField:"mask1",sensor:"right motor back EMF, raw",range:{bottom:-32768,top:32767},units:"22.5cm"},{name:"lMotorBackEmfRaw",type:"bitmask",bitmask:2097152,maskField:"mask1",sensor:"left motor back EMF, raw",range:{bottom:-32768,top:32767},units:"22.5cm"},{name:"lMotorPWMRaw",type:"bitmask",bitmask:1048576,maskField:"mask1",sensor:"left motor PWM, raw",range:{bottom:-2048,top:2047},units:"dutyCycle"},{name:"rMotorPWMRaw",type:"bitmask",bitmask:524288,maskField:"mask1",sensor:"right motor PWM, raw",range:{bottom:-2048,top:2047},units:"dutyCycle"},{name:"pitchAngle",type:"bitmask",bitmask:262144,maskField:"mask1",sensor:"IMU pitch angle, filtered",range:{bottom:-179,top:180},units:"degrees"},{name:"rollAngle",type:"bitmask",bitmask:131072,maskField:"mask1",sensor:"IMU roll angle, filtered",range:{bottom:-179,top:180},units:"degrees"},{name:"yawAngle",type:"bitmask",bitmask:65536,maskField:"mask1",sensor:"IMU yaw angle, filtered",range:{bottom:-179,top:180},units:"degrees"},{name:"xAccel",type:"bitmask",bitmask:32768,maskField:"mask1",sensor:"accelerometer axis X, filtered",range:{bottom:-32768,top:32767},units:"1/4096 G"},{name:"yAccel",type:"bitmask",bitmask:16384,maskField:"mask1",sensor:"accelerometer axis Y, filtered",range:{bottom:-32768,top:32767},units:"1/4096 G"},{name:"zAccel",type:"bitmask",bitmask:8192,maskField:"mask1",sensor:"accelerometer axis Z, filtered",range:{bottom:-32768,top:32767},units:"1/4096 G"},{name:"xGyro",type:"bitmask",bitmask:4096,maskField:"mask1",sensor:"gyro axis X, filtered",range:{bottom:-2e4,top:2e4},units:"0.1 dps"},{name:"yGyro",type:"bitmask",bitmask:2048,maskField:"mask1",sensor:"gyro axis Y, filtered",range:{bottom:-2e4,top:2e4},units:"0.1 dps"},{name:"zGyro",type:"bitmask",bitmask:1024,maskField:"mask1",sensor:"gyro axis Z, filtered",range:{bottom:-2e4,top:2e4},units:"0.1 dps"},{name:"rMotorBackEmf",type:"bitmask",bitmask:64,maskField:"mask1",sensor:"right motor back EMF, filtered",range:{bottom:-32768,top:32767},units:"22.5 cm"},{name:"lMotorBackEmf",type:"bitmask",bitmask:32,maskField:"mask1",sensor:"left motor back EMF, filtered",range:{bottom:-32768,top:32767},units:"22.5 cm"},{name:"quaternionQ0",type:"bitmask",bitmask:2147483648,maskField:"mask2",sensor:"quaternion Q0",range:{bottom:-1e4,top:1e4},units:"1/10000 Q"},{name:"quaternionQ1",type:"bitmask",bitmask:1073741824,maskField:"mask2",sensor:"quaternion Q1",range:{bottom:-1e4,top:1e4},units:"1/10000 Q"},{name:"quaternionQ2",type:"bitmask",bitmask:536870912,maskField:"mask2",sensor:"quaternion Q2",range:{bottom:-1e4,top:1e4},units:"1/10000 Q"},{name:"quaternionQ3",type:"bitmask",bitmask:268435456,maskField:"mask2",sensor:"quaternion Q3",range:{bottom:-1e4,top:1e4},units:"1/10000 Q"},{name:"xOdometer",type:"bitmask",bitmask:134217728,maskField:"mask2",sensor:"odomoter X",range:{bottom:-32768,top:32767},units:"cm"},{name:"yOdometer",type:"bitmask",bitmask:67108864,maskField:"mask2",sensor:"odomoter Y",range:{bottom:-32768,top:32767},units:"cm"},{name:"accelOne",type:"bitmask",bitmask:33554432,maskField:"mask2",sensor:"acceleration one",range:{bottom:0,top:8e3},units:"1mG"},{name:"xVelocity",type:"bitmask",bitmask:16777216,maskField:"mask2",sensor:"velocity X",range:{bottom:-32768,top:32767},units:"mm/s"},{name:"yVelocity",type:"bitmask",bitmask:8388608,maskField:"mask2",sensor:"velocity Y",range:{bottom:-32768,top:32767},units:"mm/s"}]},4:{desc:"Config Block Contents",idCode:4,did:2,cid:64,event:"configBlock",fields:[{name:"content",type:"raw"}]},5:{desc:"Pre-sleep Warning",idCode:5,did:null,cid:null,event:"preSleepWarning",fields:[{name:"content",type:"raw"}]},6:{desc:"Macro Markers",idCode:6,did:null,cid:null,event:"macroMarkers",fields:[{name:"content",type:"raw"}]},7:{desc:"Collision detected",idCode:7,did:2,cid:18,event:"collision",fields:[{name:"x",type:"number",from:0,to:2},{name:"y",type:"number",from:2,to:4},{name:"z",type:"number",from:4,to:6},{name:"axis",type:"number",from:6,to:7},{name:"xMagnitude",type:"number",from:7,to:9},{name:"yMagnitude",type:"number",from:9,to:11},{name:"speed",type:"number",from:11,to:12},{name:"timestamp",type:"number",from:12,to:16}]},8:{desc:"Orb-basic Print Message",idCode:8,did:null,cid:null,event:"obPrint",fields:[{name:"content",type:"raw"}]},9:{desc:"Orb-basic ASCII Error Message",idCode:9,did:null,cid:null,event:"obAsciiError",fields:[{name:"content",type:"string",format:"ascii",from:0,to:void 0}]},10:{desc:"Orb-basic Binary Error Message",idCode:10,did:null,cid:null,event:"obBinaryError",fields:[{name:"content",type:"raw"}]},11:{desc:"Self Level",idCode:11,did:2,cid:9,event:"selfLevel",fields:[{name:"result",type:"predefined",values:{0:"Unknown",1:"Timed Out (level was not achived)",2:"Sensors Error",3:"Self Level Disabled (see Option flags)",4:"Aborted (by API call)",5:"Charger Not Found",6:"Success"}}]},12:{desc:"Gyro Axis Limit Exceeded",idCode:12,did:null,cid:null,event:"gyroAxisExceeded",fields:[{name:"x",type:"predefined",mask:3,values:{0:"none",1:"positive",2:"negative"}},{name:"y",type:"predefined",mask:12,values:{0:"none",4:"positive",8:"negative"}},{name:"z",type:"predefined",mask:48,values:{0:"none",16:"positive",32:"negative"}}]},13:{desc:"Sphero's Soul Data",idCode:13,did:2,cid:67,event:"spheroSoulData",fields:[{name:"content",type:"raw"}]},14:{desc:"Level Up",idCode:14,did:null,cid:null,event:"levelUp",fields:[{name:"robotLevel",type:"number",from:0,to:2},{name:"attributePoints",type:"number",from:2,to:4}]},15:{desc:"Shield Damage",idCode:15,did:null,cid:null,event:"shieldDamage",fields:[{name:"robotLevel",type:"number",from:0,to:1}]},16:{desc:"XP % towards next robot level (0 = 0%, 255 = 100%)",idCode:16,did:null,cid:null,event:"xpUpdate",fields:[{name:"cp",type:"number",from:0,to:1}]},17:{desc:"Boost power left (0 = 0%, 255 = 100%)",idCode:17,did:null,cid:null,event:"boostUpdate",fields:[{name:"boost",type:"number",from:0,to:1}]}}},{}],11:[function(e,t,r){"use strict";t.exports={"0:2":{desc:"Get Version",did:0,cid:2,event:"version",fields:[{name:"recv",type:"number",from:0,to:1},{name:"mdl",type:"number",from:1,to:2},{name:"hw",type:"number",from:2,to:3},{name:"msaVer",type:"number",from:3,to:4},{name:"msaRev",type:"number",from:4,to:5},{name:"bl",type:"number",format:"hex",from:5,to:6},{name:"bas",type:"number",format:"hex",from:6,to:7},{name:"macro",type:"number",format:"hex",from:7,to:8},{name:"apiMaj",type:"number",from:8,to:9},{name:"apiMin",type:"number",from:9,to:10}]},"0:11":{desc:"Get Bluetooth Info",did:0,cid:17,event:"bluetoothInfo",fields:[{name:"name",type:"string",format:"ascii",from:0,to:16},{name:"btAddress",type:"string",format:"ascii",from:16,to:28},{name:"separator",type:"number",from:28,to:29},{name:"colors",type:"number",format:"hex",from:29,to:32}]},"0:13":{desc:"Get Auto-reconnect Info",did:0,cid:19,event:"autoReconnectInfo",fields:[{name:"flag",type:"number",from:0,to:1},{name:"time",type:"number",from:1,to:2}]},"0:20":{desc:"Get Power State Info",did:0,cid:32,event:"powerStateInfo",fields:[{name:"recVer",type:"number",from:0,to:1},{name:"batteryState",type:"predefined",from:1,to:2,values:{1:"Battery Charging",2:"Battery OK",3:"Battery Low",4:"Battery Critical"}},{name:"batteryVoltage",type:"number",from:2,to:4},{name:"chargeCount",type:"number",from:4,to:6},{name:"secondsSinceCharge",type:"number",from:6,to:8}]},"0:23":{desc:"Get Voltage Trip Points",did:0,cid:35,event:"voltageTripPoints",fields:[{name:"vLow",type:"number",from:0,to:2},{name:"vCrit",type:"number",from:2,to:4}]},"0:41":{desc:"Level 2 Diagnostics",did:0,cid:65,event:"level2Diagnostics",fields:[{name:"recVer",type:"number",from:0,to:2},{name:"rxGood",type:"number",from:3,to:7},{name:"rxBadDID",type:"number",from:7,to:11},{name:"rxBadDlen",type:"number",from:11,to:15},{name:"rxBadCID",type:"number",from:15,to:19},{name:"rxBadCheck",type:"number",from:19,to:23},{name:"rxBufferOvr",type:"number",from:23,to:27},{name:"txMsg",type:"number",from:27,to:31},{name:"txBufferOvr",type:"number",from:31,to:35},{name:"lastBootReason",type:"number",from:35,to:36},{name:"bootCounters",type:"number",format:"hex",from:36,to:68},{name:"chargeCount",type:"number",from:70,to:72},{name:"secondsSinceCharge",type:"number",from:72,to:74},{name:"secondsOn",type:"number",from:74,to:78},{name:"distanceRolled",type:"number",from:78,to:82},{name:"sensorFailures",type:"number",from:82,to:84},{name:"gyroAdjustCount",type:"number",from:84,to:88}]},"0:51":{desc:"Poll Packet Times",did:0,cid:81,event:"packetTimes",fields:[{name:"t1",type:"number",from:0,to:4},{name:"t2",type:"number",from:4,to:8},{name:"t3",type:"number",from:8,to:12}]},"2:7":{desc:"Get Chassis Id",did:2,cid:7,event:"chassisId",fields:[{name:"chassisId",type:"number"}]},"2:21":{desc:"Read Locator",did:2,cid:33,event:"readLocator",fields:[{name:"xpos",type:"number",from:0,to:2},{name:"ypos",type:"number",from:2,to:4},{name:"xvel",type:"number",from:4,to:6},{name:"yvel",type:"number",from:6,to:8},{name:"sog",type:"number",from:8,to:10}]},"2:22":{desc:"Get RGB LED",did:2,cid:34,event:"rgbLedColor",fields:[{name:"color",type:"number",format:"hex",from:0,to:3},{name:"red",type:"number",from:0,to:1},{name:"green",type:"number",from:1,to:2},{name:"blue",type:"number",from:2,to:3}]},"2:36":{desc:"Get Permanent Option Flags",did:2,cid:54,event:"permanentOptionFlags",fields:[{name:"sleepOnCharger",type:"predefined",mask:1,values:{0:!1,1:!0}},{name:"vectorDrive",type:"predefined",mask:2,values:{0:!1,2:!0}},{name:"selfLevelOnCharger",type:"predefined",mask:4,values:{0:!1,4:!0}},{name:"tailLedAlwaysOn",type:"predefined",mask:8,values:{0:!1,8:!0}},{name:"motionTimeouts",type:"predefined",mask:16,values:{0:!1,16:!0}},{name:"retailDemoOn",type:"predefined",mask:32,values:{0:!1,32:!0}},{name:"awakeSensitivityLight",type:"predefined",mask:64,values:{0:!1,64:!0}},{name:"awakeSensitivityHeavy",type:"predefined",mask:128,values:{0:!1,128:!0}},{name:"gyroMaxAsyncMsg",type:"predefined",mask:256,values:{0:!1,256:!0}}]},"2:38":{desc:"Get Temporal Option Flags",did:2,cid:56,event:"temporalOptionFlags",fields:[{name:"stopOnDisconnect",type:"predefined",mask:1,values:{0:!1,1:!0}}]},"2:44":{desc:"Get Device Mode",did:2,cid:68,event:"deviceMode",fields:[{name:"mode",type:"predefined",values:{0:"Normal",1:"User Hack"}}]},"2:48":{desc:"Refill Bank",did:2,cid:72,event:"refillBank",fields:[{name:"coresRemaining",type:"number"}]},"2:49":{desc:"Buy Consumable",did:2,cid:73,event:"buyConsumable",fields:[{name:"qtyRemaining",type:"number",from:0,to:1},{name:"coresRemaining",type:"number",from:1,to:5}]},"2:4A":{desc:"Use Consumable",did:2,cid:74,event:"buyConsumable",fields:[{name:"id",type:"number",from:0,to:1},{name:"qtyRemaining",type:"number",from:1,to:2}]},"2:4B":{desc:"Grant Cores",did:2,cid:75,event:"grantCores",fields:[{name:"coresRemaining",type:"number"}]},"2:4C":{desc:"Add XP",did:2,cid:76,event:"addXp",fields:[{name:"toNextLevel",type:"number"}]},"2:4D":{desc:"Level up Attr",did:2,cid:77,event:"addXp",fields:[{name:"attrId",type:"number",from:0,to:1},{name:"attrLevel",type:"number",from:1,to:2},{name:"attrPtsRemaining",type:"number",from:2,to:4}]},"2:4E":{desc:"GET PWD SEED",did:2,cid:78,event:"passwordSeed",fields:[{name:"seed",type:"number"}]},"2:55":{desc:"Abort Macro",did:2,cid:85,event:"abortMacro",fields:[{name:"id",type:"number",from:0,to:1},{name:"cmdNum",type:"number",from:1,to:3}]},"2:56":{desc:"Get Macro Status",did:2,cid:85,event:"macroStatus",fields:[{name:"idCode",type:"number",from:0,to:1},{name:"cmdNum",type:"number",from:1,to:3}]}}},{}],12:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=e("util"),i=e("events").EventEmitter,s=e("./packet"),a=e("./devices/core"),u=e("./devices/sphero"),c=e("./devices/custom"),l=e("./loader"),f={answer:253,resetTimeout:254,both:255,none:252,sync:255,async:254},p=t.exports=function d(e,t){n(this,d),t=t||{},this.busy=!1,this.ready=!1,this.packet=new s,this.connection=t.adaptor||l.load(e),this.callbackQueue=[],this.commandQueue=[],this.sop2Bitfield=f[t.sop2]||f.answer,this.seqCounter=0,this.timeout=t.timeout||500,this.ds={},a(this),u(this),c(this)};o.inherits(p,i),p.prototype.connect=function(e){function t(e){return r.emit.bind(r,e)}var r=this,n=this.connection,o=this.packet;o.on("error",t("error")),n.open(function(){r.ready=!0,
n.onRead(function(e){r.emit("data",e);var t,n,i=o.parse(e);i&&i.sop1&&(i.sop2===f.sync?(r.emit("response",i),n=r._responseCmd(i.seq),t=o.parseResponseData(n,i),r._execCallback(i.seq,t)):i.sop2===f.async&&(t=o.parseAsyncData(i,r.ds),r.emit("async",t)),t&&t.event&&r.emit(t.event,t))}),n.on("close",t("close")),n.on("error",t("error")),r.emit("ready"),"function"==typeof e&&e()})},p.prototype.disconnect=function(e){this.connection.close(e)},p.prototype.command=function(e,t,r,n){var o=this._incSeq(),i={sop2:this.sop2Bitfield,did:e,cid:t,seq:o,data:r},s=this.packet.create(i);this._queueCommand(s,n),this._execCommand()},p.prototype._queueCommand=function(e,t){256===this.commandQueue.length&&this.commandQueue.shift(),this.commandQueue.push({packet:e,cb:t})},p.prototype._execCommand=function(){var e;!this.busy&&this.commandQueue.length>0&&(e=this.commandQueue.shift(),this.busy=!0,this._queueCallback(e.packet,e.cb),this.connection.write(e.packet))},p.prototype._queueCallback=function(e,t){var r=e[4],n=function(e,n){if(clearTimeout(this.callbackQueue[r].timeoutId),this.callbackQueue[r]=null,this.busy=!1,"function"==typeof t)if(!e&&n)t(null,n);else{var o=new Error("Command sync response was lost.");t(o,null)}this._execCommand()},o=setTimeout(n.bind(this),this.timeout);this.callbackQueue[r]={callback:n.bind(this),timeoutId:o,did:e[2],cid:e[3]}},p.prototype._execCallback=function(e,t){var r=this.callbackQueue[e];r&&r.callback(null,t)},p.prototype._responseCmd=function(e){var t=this.callbackQueue[e];return t?{did:t.did,cid:t.cid}:null},p.prototype._incSeq=function(){return this.seqCounter>255&&(this.seqCounter=0),this.seqCounter++}},{"./devices/core":5,"./devices/custom":6,"./devices/sphero":7,"./loader":8,"./packet":9,events:20,util:24}],13:[function(e,t,r){(function(e){"use strict";var r=t.exports;r.rgbToHex=function(e,t,r){return r|t<<8|e<<16},r.randomColor=function(){function e(){return Math.floor(255*Math.random())}return{red:e(),green:e(),blue:e()}},r.checksum=function(t){for(var r=e.isBuffer(t),n=0,o=0;o<t.length;o++)n+=r?t.readUInt8(o):t[o];return n%256^255},r.intToHexArray=function(e,t){for(var r=new Array(t),n=t-1;n>=0;n--)r[n]=255&e,e>>=8;return r},r.argsToHexArray=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(255&arguments[t]);return e},r.bufferToInt=function(e){for(var t=e[0],r=1;r<e.length;r++)t<<=8,t|=e[r];return t},r.twosToInt=function(e,t){var r=0;t=t||2;for(var n=0;t>n;n++)r=r<<8|255;return~(e^r)},r.xor32bit=function(e,t){var n=r.intToHexArray(e,4);t=t||255;for(var o=0;o<n.length;o++)n[o]^=t;return r.bufferToInt(n)}}).call(this,e("buffer").Buffer)},{buffer:16}],14:[function(e,t,r){(function(r,n){"use strict";function o(e){switch(e.dataBits){case 7:e.dataBits="seven";break;case 8:e.dataBits="eight"}switch(e.stopBits){case 1:e.stopBits="one";break;case 2:e.stopBits="two"}switch(e.parity){case"none":e.parity="no"}return e}function i(e,t,n,i){l.call(this);var s=this,a=Array.prototype.slice.call(arguments);i=a.pop(),"function"!=typeof i&&(i=null),t="function"!=typeof t&&t||{},n=void 0===n||null===n?!0:n,i=i||function(e){e&&s.emit("error",e)};var u;if(t.baudRate=t.baudRate||t.baudrate||y.baudrate,t.dataBits=t.dataBits||t.databits||y.databits,-1===p.indexOf(t.dataBits))return u=new Error('Invalid "databits": '+t.dataBits),void i(u);if(t.stopBits=t.stopBits||t.stopbits||y.stopbits,-1===d.indexOf(t.stopBits))return u=new Error('Invalid "stopbits": '+t.stopbits),void i(u);if(t.parity=t.parity||y.parity,-1===m.indexOf(t.parity))return u=new Error('Invalid "parity": '+t.parity),void i(u);if(!e)return u=new Error("Invalid port specified: "+e),void i(u);if(t.rtscts=y.rtscts,t.flowControl||t.flowcontrol){var c=t.flowControl||t.flowcontrol;if("boolean"==typeof c)t.rtscts=!0;else{var f=c.every(function(e){var r=e.toUpperCase(),n=h.indexOf(r);if(0>n){var o=new Error('Invalid "flowControl": '+r+". Valid options: "+h.join(", "));return i(o),!1}switch(n){case 0:t.rtscts=!0}return!0});if(!f)return}}if(t.bufferSize=t.bufferSize||t.buffersize||y.buffersize,t.serial=t.serial||"undefined"!=typeof chrome&&chrome.serial,!t.serial)throw new Error("No access to serial ports. Try loading as a Chrome Application.");this.options=o(t),this.options.serial.onReceiveError.addListener(function(e){switch(e.error){case"disconnected":case"device_lost":case"system_error":u=new Error("Disconnected"),s.options.disconnectedCallback?s.options.disconnectedCallback(u):s.emit("disconnect",u),s.connectionId=-1,s.emit("close"),s.removeAllListeners();break;case"timeout":}}),this.path=e,n&&r.nextTick(function(){s.open(i)})}function s(e){"undefined"!=typeof chrome&&chrome.serial?chrome.serial.getDevices(function(t){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]={comName:t[n].path,manufacturer:t[n].displayName,serialNumber:"",pnpId:"",locationId:"",vendorId:"0x"+(t[n].vendorId||0).toString(16),productId:"0x"+(t[n].productId||0).toString(16)};e(chrome.runtime.lastError,r)}):e(new Error("No access to serial ports. Try loading as a Chrome Application."),null)}function a(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}function u(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e[n];return t}function c(e){for(var t=new n(e.byteLength),r=new Uint8Array(e),o=0;o<t.length;++o)t[o]=r[o];return t}var l=e("events").EventEmitter,f=e("util"),p=[7,8],d=[1,2],m=["none","even","mark","odd","space"],h=["RTSCTS"],y={baudrate:9600,parity:"none",rtscts:!1,databits:8,stopbits:1,buffersize:256};f.inherits(i,l),i.prototype.connectionId=-1,i.prototype.open=function(e){var t={bitrate:parseInt(this.options.baudRate,10),dataBits:this.options.dataBits,parityBit:this.options.parity,stopBits:this.options.stopBits,ctsFlowControl:this.options.rtscts};this.options.serial.connect(this.path,t,this.proxy("onOpen",e))},i.prototype.onOpen=function(e,t){return chrome.runtime.lastError?void("function"==typeof e?e(chrome.runtime.lastError):this.emit("error",chrome.runtime.lastError)):(this.connectionId=t.connectionId,-1===this.connectionId?void this.emit("error",new Error("Could not open port.")):(this.emit("open",t),this._reader=this.proxy("onRead"),this.options.serial.onReceive.addListener(this._reader),void("function"==typeof e&&e(chrome.runtime.lastError,t))))},i.prototype.onRead=function(e){e&&this.connectionId===e.connectionId&&(this.options.dataCallback?this.options.dataCallback(c(e.data)):this.emit("data",c(e.data)))},i.prototype.write=function(e,t){if(this.connectionId<0){var r=new Error("Serialport not open.");return void("function"==typeof t?t(r):this.emit("error",r))}"string"==typeof e&&(e=a(e)),e instanceof ArrayBuffer==!1&&(e=u(e)),this.options.serial.send(this.connectionId,e,function(e){"function"==typeof t&&t(chrome.runtime.lastError,e)})},i.prototype.close=function(e){if(this.connectionId<0){var t=new Error("Serialport not open.");return void("function"==typeof e?e(t):this.emit("error",t))}this.options.serial.disconnect(this.connectionId,this.proxy("onClose",e))},i.prototype.onClose=function(e,t){this.connectionId=-1,this.emit("close"),this.removeAllListeners(),this._reader&&(this.options.serial.onReceive.removeListener(this._reader),this._reader=null),"function"==typeof e&&e(chrome.runtime.lastError,t)},i.prototype.flush=function(e){if(this.connectionId<0){var t=new Error("Serialport not open.");return void("function"==typeof e?e(t):this.emit("error",t))}var r=this;this.options.serial.flush(this.connectionId,function(t){return chrome.runtime.lastError?void("function"==typeof e?e(chrome.runtime.lastError,t):r.emit("error",chrome.runtime.lastError)):void e(null,t)})},i.prototype.drain=function(e){if(this.connectionId<0){var t=new Error("Serialport not open.");return void("function"==typeof e?e(t):this.emit("error",t))}"function"==typeof e&&e()},i.prototype.proxy=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t.splice(0,1)[0],o=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=t.concat(r);e[n].apply(e,i)};return o},i.prototype.set=function(e,t){this.options.serial.setControlSignals(this.connectionId,e,function(e){t(chrome.runtime.lastError,e)})},t.exports={SerialPort:i,list:s,buffer2ArrayBuffer:u,used:[]}}).call(this,e("_process"),e("buffer").Buffer)},{_process:22,buffer:16,events:20,util:24}],15:[function(e,t,r){},{}],16:[function(e,t,r){function n(e){return this instanceof n?(this.length=0,this.parent=void 0,"number"==typeof e?o(this,e):"string"==typeof e?i(this,e,arguments.length>1?arguments[1]:"utf8"):s(this,e)):arguments.length>1?new n(e,arguments[1]):new n(e)}function o(e,t){if(e=p(e,0>t?0:0|d(t)),!n.TYPED_ARRAY_SUPPORT)for(var r=0;t>r;r++)e[r]=0;return e}function i(e,t,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|h(t,r);return e=p(e,n),e.write(t,r),e}function s(e,t){if(n.isBuffer(t))return a(e,t);if(Q(t))return u(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer?c(e,t):t.length?l(e,t):f(e,t)}function a(e,t){var r=0|d(t.length);return e=p(e,r),t.copy(e,0,0,r),e}function u(e,t){var r=0|d(t.length);e=p(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function c(e,t){var r=0|d(t.length);e=p(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function l(e,t){var r=0|d(t.length);e=p(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function f(e,t){var r,n=0;"Buffer"===t.type&&Q(t.data)&&(r=t.data,n=0|d(r.length)),e=p(e,n);for(var o=0;n>o;o+=1)e[o]=255&r[o];return e}function p(e,t){n.TYPED_ARRAY_SUPPORT?e=n._augment(new Uint8Array(t)):(e.length=t,e._isBuffer=!0);var r=0!==t&&t<=n.poolSize>>>1;return r&&(e.parent=X),e}function d(e){if(e>=V)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+V.toString(16)+" bytes");return 0|e}function m(e,t){if(!(this instanceof m))return new m(e,t);var r=new n(e,t);return delete r.parent,r}function h(e,t){if("string"!=typeof e&&(e=String(e)),0===e.length)return 0;switch(t||"utf8"){case"ascii":case"binary":case"raw":return e.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e.length;case"hex":return e.length>>>1;case"utf8":case"utf-8":return F(e).length;case"base64":return q(e).length;default:return e.length}}function y(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var i=t.length;if(i%2!==0)throw new Error("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;n>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[r+s]=a}return s}function g(e,t,r,n){return N(F(t,e.length-r),e,r,n)}function v(e,t,r,n){return N(z(t),e,r,n)}function b(e,t,r,n){return v(e,t,r,n)}function w(e,t,r,n){return N(q(t),e,r,n)}function k(e,t,r,n){return N(H(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?Y.fromByteArray(e):Y.fromByteArray(e.slice(t,r))}function x(e,t,r){var n="",o="";r=Math.min(e.length,r);for(var i=t;r>i;i++)e[i]<=127?(n+=j(o)+String.fromCharCode(e[i]),o=""):o+="%"+e[i].toString(16);return n+j(o)}function A(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;r>o;o++)n+=String.fromCharCode(127&e[o]);return n}function B(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;r>o;o++)n+=String.fromCharCode(e[o]);return n}function I(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=t;r>i;i++)o+=U(e[i]);return o}function _(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function C(e,t,r){if(e%1!==0||0>e)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function S(e,t,r,o,i,s){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||s>t)throw new RangeError("value is out of bounds");if(r+o>e.length)throw new RangeError("index out of range")}function T(e,t,r,n){0>t&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);i>o;o++)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function L(e,t,r,n){0>t&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);i>o;o++)e[r+o]=t>>>8*(n?o:3-o)&255}function R(e,t,r,n,o,i){if(t>o||i>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function M(e,t,r,n,o){return o||R(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,o){return o||R(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,r,n,52,8),r+8}function P(e){if(e=D(e).replace(J,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function D(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function U(e){return 16>e?"0"+e.toString(16):e.toString(16)}function F(e,t){t=t||1/0;for(var r,n=e.length,o=null,i=[],s=0;n>s;s++){if(r=e.charCodeAt(s),r>55295&&57344>r){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=o-55296<<10|r-56320|65536,o=null}else o&&((t-=3)>-1&&i.push(239,191,189),o=null);if(128>r){if((t-=1)<0)break;i.push(r)}else if(2048>r){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function z(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t}function H(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);s++)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function q(e){return Y.toByteArray(P(e))}function N(e,t,r,n){for(var o=0;n>o&&!(o+r>=t.length||o>=e.length);o++)t[o+r]=e[o];return o}function j(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var Y=e("base64-js"),G=e("ieee754"),Q=e("is-array");r.Buffer=n,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var V=1073741823,X={};n.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(e){return!(null==e||!e._isBuffer)},n.compare=function(e,t){if(!n.isBuffer(e)||!n.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,o=t.length,i=0,s=Math.min(r,o);s>i&&e[i]===t[i];)++i;return i!==s&&(r=e[i],o=t[i]),o>r?-1:r>o?1:0},n.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(e,t){if(!Q(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new n(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r<e.length;r++)t+=e[r].length;var o=new n(t),i=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(o,i),i+=s.length}return o},n.byteLength=h,n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(e,t,r){var n=!1;if(t=0|t,r=void 0===r||r===1/0?this.length:0|r,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return A(this,t,r);case"binary":return B(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}},n.prototype.equals=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===n.compare(this,e)},n.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},n.prototype.compare=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:n.compare(this,e)},n.prototype.indexOf=function(e,t){function r(e,t,r){for(var n=-1,o=0;r+o<e.length;o++)if(e[r+o]===t[-1===n?0:o-n]){if(-1===n&&(n=o),o-n+1===t.length)return r+n}else n=-1;return-1}if(t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(n.isBuffer(e))return r(this,e,t);if("number"==typeof e)return n.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},n.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},n.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},n.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var o=n;n=t,t=0|r,r=o}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(0>r||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return g(this,e,t,r);case"ascii":return v(this,e,t,r);case"binary":return b(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var o;if(n.TYPED_ARRAY_SUPPORT)o=n._augment(this.subarray(e,t));else{var i=t-e;o=new n(i,void 0);for(var s=0;i>s;s++)o[s]=this[s+e]}return o.length&&(o.parent=this.parent||this),o},n.prototype.readUIntLE=function(e,t,r){e=0|e,t=0|t,r||C(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},n.prototype.readUIntBE=function(e,t,r){e=0|e,t=0|t,r||C(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},n.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},n.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},n.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},n.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},n.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},n.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||C(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n},n.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||C(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},n.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},n.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},n.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},n.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),G.read(this,e,!0,23,4)},n.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),G.read(this,e,!1,23,4)},n.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),G.read(this,e,!0,52,8)},n.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),G.read(this,e,!1,52,8)},n.prototype.writeUIntLE=function(e,t,r,n){e=+e,t=0|t,r=0|r,n||S(this,e,t,r,Math.pow(2,8*r),0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},n.prototype.writeUIntBE=function(e,t,r,n){e=+e,t=0|t,r=0|r,n||S(this,e,t,r,Math.pow(2,8*r),0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},n.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,1,255,0),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},n.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},n.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):T(this,e,t,!1),t+2},n.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):L(this,e,t,!0),t+4},n.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):L(this,e,t,!1),t+4},n.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=0|t,!n){var o=Math.pow(2,8*r-1);S(this,e,t,r,o-1,-o)}var i=0,s=1,a=0>e?1:0;for(this[t]=255&e;++i<r&&(s*=256);)this[t+i]=(e/s>>0)-a&255;return t+r},n.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=0|t,!n){var o=Math.pow(2,8*r-1);S(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0>e?1:0;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=(e/s>>0)-a&255;return t+r},n.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,1,127,-128),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},n.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},n.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):T(this,e,t,!1),t+2},n.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},n.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||S(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):L(this,e,t,!1),t+4},n.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},n.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},n.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},n.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},n.prototype.copy=function(e,t,r,o){if(r||(r=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&r>o&&(o=r),o===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>o)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-r&&(o=e.length-t+r);var i=o-r;if(1e3>i||!n.TYPED_ARRAY_SUPPORT)for(var s=0;i>s;s++)e[s+t]=this[s+r];else e._set(this.subarray(r,r+i),t);return i},n.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof e)for(n=t;r>n;n++)this[n]=e;else{var o=F(e.toString()),i=o.length;for(n=t;r>n;n++)this[n]=o[n%i]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var W=n.prototype;n._augment=function(e){return e.constructor=n,e._isBuffer=!0,e._set=e.set,e.get=W.get,e.set=W.set,e.write=W.write,e.toString=W.toString,e.toLocaleString=W.toString,e.toJSON=W.toJSON,e.equals=W.equals,e.compare=W.compare,e.indexOf=W.indexOf,e.copy=W.copy,e.slice=W.slice,e.readUIntLE=W.readUIntLE,e.readUIntBE=W.readUIntBE,e.readUInt8=W.readUInt8,e.readUInt16LE=W.readUInt16LE,e.readUInt16BE=W.readUInt16BE,e.readUInt32LE=W.readUInt32LE,e.readUInt32BE=W.readUInt32BE,e.readIntLE=W.readIntLE,e.readIntBE=W.readIntBE,e.readInt8=W.readInt8,e.readInt16LE=W.readInt16LE,e.readInt16BE=W.readInt16BE,e.readInt32LE=W.readInt32LE,e.readInt32BE=W.readInt32BE,e.readFloatLE=W.readFloatLE,e.readFloatBE=W.readFloatBE,e.readDoubleLE=W.readDoubleLE,e.readDoubleBE=W.readDoubleBE,e.writeUInt8=W.writeUInt8,e.writeUIntLE=W.writeUIntLE,e.writeUIntBE=W.writeUIntBE,e.writeUInt16LE=W.writeUInt16LE,e.writeUInt16BE=W.writeUInt16BE,e.writeUInt32LE=W.writeUInt32LE,e.writeUInt32BE=W.writeUInt32BE,e.writeIntLE=W.writeIntLE,e.writeIntBE=W.writeIntBE,e.writeInt8=W.writeInt8,e.writeInt16LE=W.writeInt16LE,e.writeInt16BE=W.writeInt16BE,e.writeInt32LE=W.writeInt32LE,e.writeInt32BE=W.writeInt32BE,e.writeFloatLE=W.writeFloatLE,e.writeFloatBE=W.writeFloatBE,e.writeDoubleLE=W.writeDoubleLE,e.writeDoubleBE=W.writeDoubleBE,e.fill=W.fill,e.inspect=W.inspect,e.toArrayBuffer=W.toArrayBuffer,e};var J=/[^+\/0-9A-z\-]/g},{"base64-js":17,ieee754:18,"is-array":19}],17:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===f?62:t===a||t===p?63:u>t?-1:u+10>t?t-u+26+26:l+26>t?t-l:c+26>t?t-c+26:void 0}function r(e){function r(e){c[f++]=e}var n,o,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=e.length;u="="===e.charAt(l-2)?2:"="===e.charAt(l-1)?1:0,c=new i(3*e.length/4-u),s=u>0?e.length-4:e.length;var f=0;for(n=0,o=0;s>n;n+=4,o+=3)a=t(e.charAt(n))<<18|t(e.charAt(n+1))<<12|t(e.charAt(n+2))<<6|t(e.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=t(e.charAt(n))<<2|t(e.charAt(n+1))>>4,r(255&a)):1===u&&(a=t(e.charAt(n))<<10|t(e.charAt(n+1))<<4|t(e.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function o(e){function t(e){return n.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var o,i,s,a=e.length%3,u="";for(o=0,s=e.length-a;s>o;o+=3)i=(e[o]<<16)+(e[o+1]<<8)+e[o+2],u+=r(i);switch(a){case 1:i=e[e.length-1],u+=t(i>>2),u+=t(i<<4&63),u+="==";break;case 2:i=(e[e.length-2]<<8)+e[e.length-1],u+=t(i>>10),u+=t(i>>4&63),u+=t(i<<2&63),u+="="}return u}var i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),l="A".charCodeAt(0),f="-".charCodeAt(0),p="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=o}("undefined"==typeof r?this.base64js={}:r)},{}],18:[function(e,t,r){r.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?o-1:0,p=r?-1:1,d=e[t+f];for(f+=p,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=p,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:(d?-1:1)*(1/0);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,m=n?1:-1,h=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+f>=1?p/u:p*Math.pow(2,1-f),t*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=m,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=255&s,d+=m,s/=256,c-=8);e[r+d-m]|=128*h}},{}],19:[function(e,t,r){var n=Array.isArray,o=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==o.call(e)}},{}],20:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function i(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,i,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],a(r))return!1;if(o(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,i=new Array(n-1),u=1;n>u;u++)i[u-1]=arguments[u];r.apply(this,i)}else if(s(r)){for(n=arguments.length,i=new Array(n-1),u=1;n>u;u++)i[u-1]=arguments[u];for(c=r.slice(),n=c.length,u=0;n>u;u++)c[u].apply(this,i)}return!0},n.prototype.addListener=function(e,t){var r;if(!o(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,i,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],i=r.length,n=-1,r===t||o(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=i;a-->0;)if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],o(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var r;return r=e._events&&e._events[t]?o(e._events[t])?1:e._events[t].length:0}},{}],21:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){
e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],22:[function(e,t,r){function n(){l=!1,a.length?c=a.concat(c):f=-1,c.length&&o()}function o(){if(!l){var e=setTimeout(n);l=!0;for(var t=c.length;t;){for(a=c,c=[];++f<t;)a[f].run();f=-1,t=c.length}a=null,l=!1,clearTimeout(e)}}function i(e,t){this.fun=e,this.array=t}function s(){}var a,u=t.exports={},c=[],l=!1,f=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new i(e,t)),1!==c.length||l||setTimeout(o,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=s,u.addListener=s,u.once=s,u.off=s,u.removeListener=s,u.removeAllListeners=s,u.emit=s,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},{}],23:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],24:[function(e,t,r){(function(t,n){function o(e,t){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(t)?n.showHidden=t:t&&r._extend(n,t),k(n.showHidden)&&(n.showHidden=!1),k(n.depth)&&(n.depth=2),k(n.colors)&&(n.colors=!1),k(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=i),u(n,e,n.depth)}function i(e,t){var r=o.styles[t];return r?"["+o.colors[r][0]+"m"+e+"["+o.colors[r][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,t,n){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(n,e);return b(o)||(o=u(e,o,n)),o}var i=c(e,t);if(i)return i;var s=Object.keys(t),h=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),B(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(t);if(0===s.length){if(I(t)){var y=t.name?": "+t.name:"";return e.stylize("[Function"+y+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(A(t))return e.stylize(Date.prototype.toString.call(t),"date");if(B(t))return l(t)}var g="",v=!1,w=["{","}"];if(m(t)&&(v=!0,w=["[","]"]),I(t)){var k=t.name?": "+t.name:"";g=" [Function"+k+"]"}if(E(t)&&(g=" "+RegExp.prototype.toString.call(t)),A(t)&&(g=" "+Date.prototype.toUTCString.call(t)),B(t)&&(g=" "+l(t)),0===s.length&&(!v||0==t.length))return w[0]+g+w[1];if(0>n)return E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var x;return x=v?f(e,t,n,h,s):s.map(function(r){return p(e,t,n,h,r,v)}),e.seen.pop(),d(x,g,w)}function c(e,t){if(k(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return v(t)?e.stylize(""+t,"number"):h(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,o){for(var i=[],s=0,a=t.length;a>s;++s)L(t,String(s))?i.push(p(e,t,r,n,String(s),!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(p(e,t,r,n,o,!0))}),i}function p(e,t,r,n,o,i){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),L(n,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(r)?u(e,c.value,null):u(e,c.value,r-1),a.indexOf("\n")>-1&&(a=i?a.split("\n").map(function(e){return"  "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return"   "+e}).join("\n"))):a=e.stylize("[Circular]","special")),k(s)){if(i&&o.match(/^\d+$/))return a;s=JSON.stringify(""+o),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e,t,r){var n=0,o=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return o>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function m(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function y(e){return null===e}function g(e){return null==e}function v(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function k(e){return void 0===e}function E(e){return x(e)&&"[object RegExp]"===C(e)}function x(e){return"object"==typeof e&&null!==e}function A(e){return x(e)&&"[object Date]"===C(e)}function B(e){return x(e)&&("[object Error]"===C(e)||e instanceof Error)}function I(e){return"function"==typeof e}function _(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function C(e){return Object.prototype.toString.call(e)}function S(e){return 10>e?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[S(e.getHours()),S(e.getMinutes()),S(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var R=/%[sdj%]/g;r.format=function(e){if(!b(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(o(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,s=String(e).replace(R,function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}}),a=n[r];i>r;a=n[++r])s+=y(a)||!x(a)?" "+a:" "+o(a);return s},r.deprecate=function(e,o){function i(){if(!s){if(t.throwDeprecation)throw new Error(o);t.traceDeprecation?console.trace(o):console.error(o),s=!0}return e.apply(this,arguments)}if(k(n.process))return function(){return r.deprecate(e,o).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return i};var M,O={};r.debuglog=function(e){if(k(M)&&(M=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!O[e])if(new RegExp("\\b"+e+"\\b","i").test(M)){var n=t.pid;O[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else O[e]=function(){};return O[e]},r.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=m,r.isBoolean=h,r.isNull=y,r.isNullOrUndefined=g,r.isNumber=v,r.isString=b,r.isSymbol=w,r.isUndefined=k,r.isRegExp=E,r.isObject=x,r.isDate=A,r.isError=B,r.isFunction=I,r.isPrimitive=_,r.isBuffer=e("./support/isBuffer");var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",T(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!x(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":23,_process:22,inherits:21}],25:[function(e,t,r){"use strict";var n=e("./lib/sphero");t.exports=function(e,t){return new n(e,t)}},{"./lib/sphero":12}]},{},[25])(25)});