PKVhy appinfo.json{ "targetPlatforms": [ "aplite" ], "displayName": "DSCam Home-Switch", "name": "dscam-h-s", "messageKeys": { "status": 10001, "username": 10003, "JSReady": 10005, "auth": 10000, "server": 10002, "password": 10004 }, "companyName": "ljonget@gmail.com", "enableMultiJS": true, "versionLabel": "1.2", "capabilities": [ "configurable" ], "sdkVersion": "3", "appKeys": { "status": 10001, "username": 10003, "JSReady": 10005, "auth": 10000, "server": 10002, "password": 10004 }, "longName": "DSCam Home-Switch", "shortName": "DSCam Home-Switch", "watchapp": { "watchface": false }, "resources": { "media": [ { "menuIcon": true, "type": "bitmap", "targetPlatforms": null, "file": "images/icon.png", "name": "IMAGE_MENU_ICON" }, { "targetPlatforms": null, "type": "bitmap", "name": "Q_MARK", "file": "images/q_mark.png" }, { "targetPlatforms": null, "type": "bitmap", "name": "HOME_OFF", "file": "images/home_off.png" }, { "targetPlatforms": null, "type": "bitmap", "name": "HOME_ON", "file": "images/home_on.png" } ] }, "uuid": "d701bcb8-1076-4adb-9e38-9c21566efc24" }PKXW= str.length) { str = Array(len + 1 - str.length).join(pad) + str; } return str; } function getOtp() { key = base32tohex(JSON.parse(localStorage.getItem('clay-settings')).OTP_seed) //console.log('-- seed:' + JSON.parse(localStorage.getItem('clay-settings')).OTP_seed) //console.log('-- key:' + key) var epoch = Math.round(new Date().getTime() / 1000.0); var time = leftpad(dec2hex(Math.floor(epoch / 30)), 16, '0'); // updated for jsSHA v2.0.0 - http://caligatio.github.io/jsSHA/ var shaObj = new jsSHA("SHA-1", "HEX"); shaObj.setHMACKey(key, "HEX"); shaObj.update(time); var hmac = shaObj.getHMAC("HEX"); //console.log('-- hmac:' + hmac) var offset = hex2dec(hmac.substring(hmac.length - 1)); //console.log('--offset:' + offset) var otp = (hex2dec(hmac.substr(offset * 2, 8)) & hex2dec('7fffffff')) + ''; otp = (otp).substr(otp.length - 6, 6); return otp } function xhr_to_syno(method, url_path, onload_function, max_retry) { console.log('------xhr start') status = ""; if (JSON.parse(localStorage.getItem('clay-settings')).server) { var server = JSON.parse(localStorage.getItem('clay-settings')).server url = server + url_path; var xhr = new XMLHttpRequest(); xhr.timeout = 6000; // time in milliseconds xhr.open(method, url, true); console.log('------xhr opened') xhr.onload = function () { console.log('------xhr onload') if (xhr.readyState === 4) { retry = 1; console.log('------xhr request returned'); if (xhr.status == 200) { onload_function(xhr); return true; } else { console.log('------xhr request returned error code ' + xhr.status); message = "Error (XHR"+xhr.status+")"; // Build message var dict = { 'status': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); return false; } } }; xhr.ontimeout = function (e) { retry++; if (retry < max_retry) { console.log('------xhr timed out retrying another time '); //send back "timeout" to watch message = "Time out, retrying..."; // Build message var dict = { 'status': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); xhr_to_syno(method, url_path, onload_function, max_retry); } else { console.log('------xhr timed out ' + retry + ' times'); //send back "timeout" to watch message = "Time out too many times, verify settings and connectivity"; // Build message var dict = { 'status': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); return false; } }; xhr.send(null); } else { Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server."); } } function authenticate() { var response; sid = ""; console.log('---- authenticate'); if (JSON.parse(localStorage.getItem('clay-settings')).username && JSON.parse(localStorage.getItem('clay-settings')).password) { var username = JSON.parse(localStorage.getItem('clay-settings')).username; var password = JSON.parse(localStorage.getItem('clay-settings')).password; console.log('-- username:' + username); console.log('-- password:' + password.substring(0, 1) + '...'); var url_path = "/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=6&account=" + username + "&passwd=" + password + "&session=SurveillanceStation&format=sid"; if (JSON.parse(localStorage.getItem('clay-settings')).OTP_enabled) { var otp_code = getOtp() console.log('-- otp_code is :' + otp_code) url_path = url_path + "&otp_code=" + otp_code } var method = "GET"; onload_function = function (xhr) { response = JSON.parse(xhr.responseText); if (response.success == true) { sid = response.data.sid; console.log('------Authentication succeeded'); if (sid != "") { message = "Welcome to Syno Cam Switch ! ready & authenticated"; // Build message var dict = { 'auth': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); get_status(); } else { console.log('------Unexpected error : authentication is OK but no SID retrieved'); message = "Auth error, no SID"; // Build message var dict = { 'auth': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); } } else { console.log('------Authentication failed : ' + JSON.stringify(response)); message = "Authentication failed"; // Build message var dict = { 'auth': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); } }; max_retry = 10; xhr_to_syno(method, url_path, onload_function, max_retry); } else { console.log("--- failed to get settings"); Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server."); } } function get_status() { var response; if (sid != "") { status = ""; console.log('---- get_status'); var url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid=" + sid; var method = "GET"; onload_function = function (xhr) { response = JSON.parse(xhr.responseText); if (response.success == true) { status = response.data.on; var message; switch (status) { case true: message = "Home mode is ON (camera is off)"; break; case false: message = "Home mode is OFF (camera is on)"; break; default: message = "something happened, try again ! (IMPOSSIBLE)"; } }else{ message = "something happened, try again ! (G200)"; } // Build message var dict = { 'status': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); } max_retry = 10; xhr_to_syno(method, url_path, onload_function, max_retry); } else { authenticate(); get_status(); } } function timed_switch_home(duration) { var response; console.log('---- authenticate'); if (sid != "") { var epoch = Math.round(new Date().getTime() / 1000.0); var start_ts = epoch + 10 var end_ts = duration + start_ts console.log('---- switching home mode for ' + duration + 'seconds'); url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=SaveOneTimeSwitch&onetime_enable_on=true&onetime_disable_on=true&onetime_enable_time=" + start_ts + "&onetime_disable_time=" + end_ts + "&_sid=" + sid; method = "GET" onload_switch_function = function (xhr) { response = JSON.parse(xhr.responseText); if (response.success == true) { message = "Home mode is ON for "+duration+" seconds"; }else{ message = "something happened, try again ! (S200)"; } // Build message dict = { 'status': message, }; // Send the message Home mode is ON for 900 seconds Pebble.sendAppMessage(dict, function (e) { console.log('sent \"'+message+'\"'); }, function () { console.log('failed'); }); } max_retry = 10; xhr_to_syno(method, url_path, onload_switch_function, max_retry); } else { authenticate(); switch_home(bool); } } function switch_home(bool) { var response; console.log('---- authenticate'); if (sid != "") { console.log('---- switching home mode to ' + bool); url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=" + bool + "&_sid=" + sid; method = "GET" onload_switch_function = function (xhr) { response = JSON.parse(xhr.responseText); if (response.success == true) { switch (bool) { case true: message = "Home mode is ON (camera is off)"; break; case false: message = "Home mode is OFF (camera is on)"; break; default: message = "something happened, try again ! (IMPOSSIBLE)"; } }else{ message = "something happened, try again ! (S200)"; } // Build message dict = { 'status': message, }; // Send the message Pebble.sendAppMessage(dict, function (e) { console.log('sent'); }, function () { console.log('failed'); }); } max_retry = 10; xhr_to_syno(method, url_path, onload_switch_function, max_retry); } else { authenticate(); switch_home(bool); } } // Get JS readiness events Pebble.addEventListener('ready', function (e) { console.log("---- local storage:"); console.log("user " + JSON.parse(localStorage.getItem('clay-settings')).username); console.log('PebbleKit JS is ready'); // Update Watch on this Pebble.sendAppMessage({ 'JSReady': 1 }); }); // Get AppMessage events Pebble.addEventListener('appmessage', function (e) { // Get the dictionary from the message var dict = e.payload; console.log(dict[0].toString()); switch (dict[0]) { case 'auth': authenticate(); break; case 'get': get_status(); break; case 'home_on': //switch_home(true); timed_switch_home(15*60) break; case 'home_off': switch_home(false); break; default: console.log('Sorry. I don\'t understand your request :' + dict[0]); } }); /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { var require;var require;/* WEBPACK VAR INJECTION */(function(require) {/* Clay - https://github.com/pebble/clay - Version: 1.0.4 - Build Date: 2016-11-21T20:14:28.839Z */ !function(t){if(true)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.pebbleClay=t()}}(function(){var t;return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return require(a,!0);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function o(t){return 3*t.length/4-r(t)}function i(t){var e,n,o,i,a,s,c=t.length;a=r(t),s=new f(3*c/4-a),o=a>0?c-4:c;var l=0;for(e=0,n=0;e>16&255,s[l++]=i>>8&255,s[l++]=255&i;return 2===a?(i=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,s[l++]=255&i):1===a&&(i=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,s[l++]=i>>8&255,s[l++]=255&i),s}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function s(t,e,n){for(var r,o=[],i=e;iu?u:c+a));return 1===r?(e=t[n-1],o+=l[e>>2],o+=l[e<<4&63],o+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],o+=l[e>>10],o+=l[e>>4&63],o+=l[e<<2&63],o+="="),i.push(o),i.join("")}n.byteLength=o,n.toByteArray=i,n.fromByteArray=c;for(var l=[],u=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,h=p.length;d * @license MIT */ "use strict";function r(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function o(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),a.alloc(+t)}function b(t,e){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(t).length;default:if(r)return W(t).length;e=(""+e).toLowerCase(),r=!0}}function y(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return D(this,e,n);case"utf8":case"utf-8":return E(this,e,n);case"ascii":return B(this,e,n);case"latin1":case"binary":return S(this,e,n);case"base64":return O(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function A(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:w(t,e,n,r,o);if("number"==typeof e)return e=255&e,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function w(t,e,n,r,o){function i(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,s=t.length,c=e.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,n/=2}var l;if(o){var u=-1;for(l=n;ls&&(n=s-c),l=n;l>=0;l--){for(var f=!0,p=0;po&&(r=o)):r=o;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a239?4:i>223?3:i>191?2:1;if(o+s<=n){var c,l,u,f;switch(s){case 1:i<128&&(a=i);break;case 2:c=t[o+1],128===(192&c)&&(f=(31&i)<<6|63&c,f>127&&(a=f));break;case 3:c=t[o+1],l=t[o+2],128===(192&c)&&128===(192&l)&&(f=(15&i)<<12|(63&c)<<6|63&l,f>2047&&(f<55296||f>57343)&&(a=f));break;case 4:c=t[o+1],l=t[o+2],u=t[o+3],128===(192&c)&&128===(192&l)&&128===(192&u)&&(f=(15&i)<<18|(63&c)<<12|(63&l)<<6|63&u,f>65535&&f<1114112&&(a=f))}}null===a?(a=65533,s=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),o+=s}return j(r)}function j(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",r=0;rr)&&(n=r);for(var o="",i=e;in)throw new RangeError("Trying to access beyond buffer length")}function F(t,e,n,r,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function z(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o>>8*(r?o:1-o)}function I(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o>>8*(r?o:3-o)&255}function L(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function K(t,e,n,r,o){return o||L(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(t,e,n,r,23,4),n+4}function G(t,e,n,r,o){return o||L(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(t,e,n,r,52,8),n+8}function C(t){if(t=X(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function X(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return t<16?"0"+t.toString(16):t.toString(16)}function W(t,e){e=e||1/0;for(var n,r=t.length,o=null,i=[],a=0;a55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Z(t){for(var e=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function U(t){return Q.toByteArray(C(t))}function q(t,e,n,r){for(var o=0;o=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function H(t){return t!==t}var Q=t("base64-js"),$=t("ieee754"),_=t("isarray");n.Buffer=a,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=o(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,n){return s(null,t,e,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,n){return l(null,t,e,n)},a.allocUnsafe=function(t){return u(null,t)},a.allocUnsafeSlow=function(t){return u(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);o0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t,e,n,r,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;for(var i=o-r,s=n-e,c=Math.min(i,s),l=this.slice(r,o),u=t.slice(e,n),f=0;fo)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return k(this,t,e,n);case"utf8":case"utf-8":return x(this,t,e,n);case"ascii":return M(this,t,e,n);case"latin1":case"binary":return T(this,t,e,n);case"base64":return R(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e0&&(o*=256);)r+=this[t+--e]*o;return r},a.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,n){t=0|t,e=0|e,n||Y(t,e,this.length);for(var r=this[t],o=1,i=0;++i=o&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,n){t=0|t,e=0|e,n||Y(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e=0|e,n=0|n,!r){var o=Math.pow(2,8*n)-1;F(this,t,e,n,o,0)}var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+n},a.prototype.writeUInt8=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):z(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):z(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);F(this,t,e,n,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+n},a.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);F(this,t,e,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},a.prototype.writeInt8=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):z(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):z(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,n){return K(this,t,e,!0,n)},a.prototype.writeFloatBE=function(t,e,n){return K(this,t,e,!1,n)},a.prototype.writeDoubleLE=function(t,e,n){return G(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return G(this,t,e,!1,n)},a.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--o)t[o+e]=this[o+n];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;in;++n)if(i=t[n],i===e||i!==i&&e!==e)return n;return-1}n.__esModule=!0;var o=Object.prototype.toString,i="undefined"!=typeof e?function(t){return e.isBuffer(t)}:function(){return!1},a="function"==typeof Object.keys?function(t){return Object.keys(t)}:function(t){var e=typeof t;if(null===t||"function"!==e&&"object"!==e)throw new TypeError("obj must be an Object");var n=[],r=void 0;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.push(r);return n},s="function"==typeof Symbol?function(t){return Object.getOwnPropertySymbols(t)}:function(){return[]};n.getKeys=a,n.getSymbols=s,n.indexOf=r,n.isBuffer=i},function(t,n,r){"use strict";function o(t,e){var n=a(t);return null!==n?n:i(t,e)}function i(t,n){if("function"!=typeof n)throw new TypeError("customizer is must be a Function");if("function"==typeof t){var r=String(t);return/^\s*function\s*\S*\([^\)]*\)\s*{\s*\[native code\]\s*}/.test(r)?t:new Function("return "+String(r))()}var o=c.call(t);if("[object Array]"===o)return[];if("[object Object]"===o&&t.constructor===Object)return{};if("[object Date]"===o)return new Date(t.getTime());if("[object RegExp]"===o){var i=String(t),a=i.lastIndexOf("/");return new RegExp(i.slice(1,a),i.slice(a+1))}if((0,s.isBuffer)(t)){var l=new e(t.length);return t.copy(l),l}var u=n(t);return void 0!==u?u:null}function a(t){var e=typeof t;return null!==t&&"object"!==e&&"function"!==e?t:null}n.__esModule=!0,n.copyValue=n.copyCollection=n.copy=void 0;var s=r(1),c=Object.prototype.toString;n.copy=o,n.copyCollection=i,n.copyValue=a},function(t,e,n){"use strict";function r(t){}function o(t){var e=arguments.length<=1||void 0===arguments[1]?r:arguments[1];if(null===t)return null;var n=(0,a.copyValue)(t);if(null!==n)return n;var o=(0,a.copyCollection)(t,e),s=null!==o?o:t,c=[t],l=[s];return i(t,e,s,c,l)}function i(t,e,n,r,o){if(null===t)return null;var c=(0,a.copyValue)(t);if(null!==c)return c;var l=(0,s.getKeys)(t).concat((0,s.getSymbols)(t)),u=void 0,f=void 0,p=void 0,d=void 0,h=void 0,m=void 0,g=void 0,b=void 0;for(u=0,f=l.length;f>u;++u)p=l[u],d=t[p],h=(0,s.indexOf)(r,d),m=void 0,g=void 0,b=void 0,-1===h?(m=(0,a.copy)(d,e),g=null!==m?m:d,null!==d&&/^(?:function|object)$/.test(typeof d)&&(r.push(d),o.push(g))):b=o[h],n[p]=b||i(d,e,g,r,o);return n}e.__esModule=!0;var a=n(2),s=n(1);e["default"]=o,t.exports=e["default"]}])})}).call(this,e("buffer").Buffer)},{buffer:2}],4:[function(t,e,n){n.read=function(t,e,n,r,o){var i,a,s=8*o-r-1,c=(1<>1,u=-7,f=n?o-1:0,p=n?-1:1,d=t[e+f];for(f+=p,i=d&(1<<-u)-1,d>>=-u,u+=s;u>0;i=256*i+t[e+f],f+=p,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+t[e+f],f+=p,u-=8);if(0===i)i=1-l;else{if(i===c)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,r),i-=l}return(d?-1:1)*a*Math.pow(2,i-r)},n.write=function(t,e,n,r,o,i){var a,s,c,l=8*i-o-1,u=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,h=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),e+=a+f>=1?p/c:p*Math.pow(2,1-f),e*c>=2&&(a++,c/=2),a+f>=u?(s=0,a=u):a+f>=1?(s=(e*c-1)*Math.pow(2,o),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;t[n+d]=255&s,d+=h,s/=256,o-=8);for(a=a<0;t[n+d]=255&a,d+=h,a/=256,l-=8);t[n+d-h]|=128*m}},{}],5:[function(t,e,n){var r={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},{}],6:[function(t,e,n){function r(t){return/^[a-z_$][0-9a-z_$]*$/gi.test(t)&&!i.test(t)}function o(t){if(a)return t.toString();var e=t.source.replace(/\//g,function(t,e,n){return 0===e||"\\"!==n[e-1]?"\\/":"/"}),n=(t.global&&"g"||"")+(t.ignoreCase&&"i"||"")+(t.multiline&&"m"||"");return"/"+e+"/"+n}/* toSource by Marcello Bastea-Forte - zlib license */ e.exports=function(t,e,n,i){function a(t,e,n,i,s){function c(t){return n.slice(1)+t.join(","+(n&&"\n")+l)+(n?" ":"")}var l=i+n;switch(t=e?e(t):t,typeof t){case"string":return JSON.stringify(t);case"boolean":case"number":case"undefined":return""+t;case"function":return t.toString()}if(null===t)return"null";if(t instanceof RegExp)return o(t);if(t instanceof Date)return"new Date("+t.getTime()+")";var u=s.indexOf(t)+1;if(u>0)return"{$circularReference:"+u+"}";if(s.push(t),Array.isArray(t))return"["+c(t.map(function(t){return a(t,e,n,l,s.slice())}))+"]";var f=Object.keys(t);return f.length?"{"+c(f.map(function(o){return(r(o)?o:JSON.stringify(o))+":"+a(t[o],e,n,l,s.slice())}))+"}":"{}"}var s=[];return a(t,e,void 0===n?" ":n||"",i||"",s)};var i=/^(abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|undefined|var|void|volatile|while|with)$/,a="\\/"===new RegExp("/").source},{}],7:[function(t,e,n){e.exports={name:"pebble-clay",version:"1.0.4",description:"Pebble Config Framework",scripts:{"test-travis":"./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run --browsers chromeTravisCI && ./node_modules/.bin/eslint ./","test-debug":"(export DEBUG=true && ./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --no-single-run)",test:"./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run",lint:"./node_modules/.bin/eslint ./",build:"gulp",dev:"gulp dev","pebble-clean":"rm -rf tmp src/js/index.js && pebble clean","pebble-publish":"npm run pebble-clean && npm run build && pebble build && pebble package publish && npm run pebble-clean","pebble-build":"npm run build && pebble build"},repository:{type:"git",url:"git+https://github.com/pebble/clay.git"},keywords:["pebble","config","configuration","pebble-package"],author:"Pebble Technology",license:"MIT",bugs:{url:"https://github.com/pebble/clay/issues"},pebble:{projectType:"package",sdkVersion:"3",targetPlatforms:["aplite","basalt","chalk","diorite","emery"],resources:{media:[]},capabilities:["configurable"]},homepage:"https://github.com/pebble/clay#readme",devDependencies:{autoprefixer:"^6.3.1",bourbon:"^4.2.6",browserify:"^13.0.0","browserify-istanbul":"^0.2.1",chai:"^3.4.1",deamdify:"^0.2.0",deepcopy:"^0.6.1",del:"^2.0.2",eslint:"^1.5.1","eslint-config-pebble":"^1.2.0","eslint-plugin-standard":"^1.3.1",gulp:"^3.9.0","gulp-autoprefixer":"^3.1.0","gulp-htmlmin":"^1.3.0","gulp-inline":"0.0.15","gulp-insert":"^0.5.0","gulp-sass":"^2.1.1","gulp-sourcemaps":"^1.6.0","gulp-uglify":"^1.5.2",joi:"^6.10.1",karma:"^0.13.19","karma-browserify":"^5.0.1","karma-chrome-launcher":"^0.2.2","karma-coverage":"^0.5.3","karma-mocha":"^0.2.1","karma-mocha-reporter":"^1.1.5","karma-source-map-support":"^1.1.0","karma-threshold-reporter":"^0.1.15",mocha:"^2.3.4",postcss:"^5.0.14","require-from-string":"^1.1.0",sassify:"^0.9.1",sinon:"^1.17.3",stringify:"^3.2.0",through:"^2.3.8",tosource:"^1.0.0","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0",watchify:"^3.7.0"},dependencies:{}}},{}],8:[function(t,e,n){"use strict";e.exports={name:"button",template:t("../../templates/components/button.tpl"),style:t("../../styles/clay/components/button.scss"),manipulator:"button",defaults:{primary:!1,attributes:{},description:""}}},{"../../styles/clay/components/button.scss":21,"../../templates/components/button.tpl":30}],9:[function(t,e,n){"use strict";e.exports={name:"checkboxgroup",template:t("../../templates/components/checkboxgroup.tpl"),style:t("../../styles/clay/components/checkboxgroup.scss"),manipulator:"checkboxgroup",defaults:{label:"",options:[],description:""}}},{"../../styles/clay/components/checkboxgroup.scss":22,"../../templates/components/checkboxgroup.tpl":31}],10:[function(t,e,n){"use strict";e.exports={name:"color",template:t("../../templates/components/color.tpl"),style:t("../../styles/clay/components/color.scss"),manipulator:"color",defaults:{label:"",description:""},initialize:function(t,e){function n(t){if("number"==typeof t)t=t.toString(16);else if(!t)return"transparent";return t=r(t),"#"+(f?p[t]:t)}function r(t){for(t=t.toLowerCase();t.length<6;)t="0"+t;return t}function o(t){switch(typeof t){case"number":return r(t.toString(16));case"string":return t.replace(/^#|^0x/,"");default:return t}}function i(t){return t.reduce(function(t,e){return t.concat(e)},[])}function a(t){t=t.replace(/^#|^0x/,"");var e=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,r=parseInt(t.slice(4),16)/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;var o=(.4124*e+.3576*n+.1805*r)/.95047,i=(.2126*e+.7152*n+.0722*r)/1,a=(.0193*e+.1192*n+.9505*r)/1.08883;return o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,[116*i-16,500*(o-i),200*(i-a)]}function s(t,e){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.sqrt(Math.pow(n,2)+Math.pow(r,2)+Math.pow(o,2))}function c(){return!e.meta.activeWatchInfo||2===e.meta.activeWatchInfo.firmware.major||["aplite","diorite"].indexOf(e.meta.activeWatchInfo.platform)>-1&&!u.config.allowGray?d.BLACK_WHITE:["aplite","diorite"].indexOf(e.meta.activeWatchInfo.platform)>-1&&u.config.allowGray?d.GRAY:d.COLOR}var l=t.HTML,u=this;u.roundColorToLayout=function(t){var e=o(t);if(m.indexOf(e)===-1){var n=a(e),r=m.map(function(t){var e=a(o(t));return s(n,e)}),i=Math.min.apply(Math,r),c=r.indexOf(i);e=m[c]}return parseInt(e,16)};var f=u.config.sunlight!==!1,p={"000000":"000000","000055":"001e41","0000aa":"004387","0000ff":"0068ca","005500":"2b4a2c","005555":"27514f","0055aa":"16638d","0055ff":"007dce","00aa00":"5e9860","00aa55":"5c9b72","00aaaa":"57a5a2","00aaff":"4cb4db","00ff00":"8ee391","00ff55":"8ee69e","00ffaa":"8aebc0","00ffff":"84f5f1",550000:"4a161b",550055:"482748","5500aa":"40488a","5500ff":"2f6bcc",555500:"564e36",555555:"545454","5555aa":"4f6790","5555ff":"4180d0","55aa00":"759a64","55aa55":"759d76","55aaaa":"71a6a4","55aaff":"69b5dd","55ff00":"9ee594","55ff55":"9de7a0","55ffaa":"9becc2","55ffff":"95f6f2",aa0000:"99353f",aa0055:"983e5a",aa00aa:"955694",aa00ff:"8f74d2",aa5500:"9d5b4d",aa5555:"9d6064",aa55aa:"9a7099",aa55ff:"9587d5",aaaa00:"afa072",aaaa55:"aea382",aaaaaa:"ababab",ffffff:"ffffff",aaaaff:"a7bae2",aaff00:"c9e89d",aaff55:"c9eaa7",aaffaa:"c7f0c8",aaffff:"c3f9f7",ff0000:"e35462",ff0055:"e25874",ff00aa:"e16aa3",ff00ff:"de83dc",ff5500:"e66e6b",ff5555:"e6727c",ff55aa:"e37fa7",ff55ff:"e194df",ffaa00:"f1aa86",ffaa55:"f1ad93",ffaaaa:"efb5b8",ffaaff:"ecc3eb",ffff00:"ffeeab",ffff55:"fff1b5",ffffaa:"fff6d3"},d={COLOR:[[!1,!1,"55ff00","aaff55",!1,"ffff55","ffffaa",!1,!1],[!1,"aaffaa","55ff55","00ff00","aaff00","ffff00","ffaa55","ffaaaa",!1],["55ffaa","00ff55","00aa00","55aa00","aaaa55","aaaa00","ffaa00","ff5500","ff5555"],["aaffff","00ffaa","00aa55","55aa55","005500","555500","aa5500","ff0000","ff0055"],[!1,"55aaaa","00aaaa","005555","ffffff","000000","aa5555","aa0000",!1],["55ffff","00ffff","00aaff","0055aa","aaaaaa","555555","550000","aa0055","ff55aa"],["55aaff","0055ff","0000ff","0000aa","000055","550055","aa00aa","ff00aa","ffaaff"],[!1,"5555aa","5555ff","5500ff","5500aa","aa00ff","ff00ff","ff55ff",!1],[!1,!1,!1,"aaaaff","aa55ff","aa55aa",!1,!1,!1]],GRAY:[["000000","aaaaaa","ffffff"]],BLACK_WHITE:[["000000","ffffff"]]},h=u.config.layout||c();"string"==typeof h&&(h=d[h]),Array.isArray(h[0])||(h=[h]);var m=i(h).map(function(t){return o(t)}).filter(function(t){return t}),g="",b=h.length,y=0;h.forEach(function(t){y=t.length>y?t.length:y});for(var v=100/y,A=100/b,w=u.$element,k=0;k'}var j=0;3===y&&(j=5),2===y&&(j=8);var B=j*v/A+"%",S=j+"%";w.select(".color-box-container").add(l(g)).set("$paddingTop",B).set("$paddingRight",S).set("$paddingBottom",B).set("$paddingLeft",S),w.select(".color-box-wrap").set("$paddingBottom",v/A*100+"%");var D=w.select(".value"),N=w.select(".picker-wrap"),Y=u.$manipulatorTarget.get("disabled");w.select("label").on("click",function(){Y||N.set("show")}),u.on("change",function(){var t=u.get();D.set("$background-color",n(t)),w.select(".color-box").set("-selected"),w.select('.color-box[data-value="'+t+'"]').set("+selected")}),w.select(".color-box.selectable").on("click",function(t){u.set(parseInt(t.target.dataset.value,10)),N.set("-show")}),N.on("click",function(){N.set("-show")}),u.on("disabled",function(){Y=!0}),u.on("enabled",function(){Y=!1}),u._layout=h}}},{"../../styles/clay/components/color.scss":23,"../../templates/components/color.tpl":32}],11:[function(t,e,n){"use strict";e.exports={name:"footer",template:t("../../templates/components/footer.tpl"),manipulator:"html"}},{"../../templates/components/footer.tpl":33}],12:[function(t,e,n){"use strict";e.exports={name:"heading",template:t("../../templates/components/heading.tpl"),manipulator:"html",defaults:{size:4}}},{"../../templates/components/heading.tpl":34}],13:[function(t,e,n){"use strict";e.exports={color:t("./color"),footer:t("./footer"),heading:t("./heading"),input:t("./input"),select:t("./select"),submit:t("./submit"),text:t("./text"),toggle:t("./toggle"),radiogroup:t("./radiogroup"),checkboxgroup:t("./checkboxgroup"),button:t("./button"),slider:t("./slider")}},{"./button":8,"./checkboxgroup":9,"./color":10,"./footer":11,"./heading":12,"./input":14,"./radiogroup":15,"./select":16,"./slider":17,"./submit":18,"./text":19,"./toggle":20}],14:[function(t,e,n){"use strict";e.exports={name:"input",template:t("../../templates/components/input.tpl"),style:t("../../styles/clay/components/input.scss"),manipulator:"val",defaults:{label:"",description:"",attributes:{}}}},{"../../styles/clay/components/input.scss":24,"../../templates/components/input.tpl":35}],15:[function(t,e,n){"use strict";e.exports={name:"radiogroup",template:t("../../templates/components/radiogroup.tpl"),style:t("../../styles/clay/components/radiogroup.scss"),manipulator:"radiogroup",defaults:{label:"",options:[],description:"",attributes:{}}}},{"../../styles/clay/components/radiogroup.scss":25,"../../templates/components/radiogroup.tpl":36}],16:[function(t,e,n){"use strict";e.exports={name:"select",template:t("../../templates/components/select.tpl"),style:t("../../styles/clay/components/select.scss"),manipulator:"val",defaults:{label:"",options:[],description:"",attributes:{}},initialize:function(){function t(){var t=e.$manipulatorTarget.get("selectedIndex"),r=e.$manipulatorTarget.select("option"),o=r[t]&&r[t].innerHTML;n.set("innerHTML",o)}var e=this,n=e.$element.select(".value");t(),e.on("change",t)}}},{"../../styles/clay/components/select.scss":26,"../../templates/components/select.tpl":37}],17:[function(t,e,n){"use strict";e.exports={name:"slider",template:t("../../templates/components/slider.tpl"),style:t("../../styles/clay/components/slider.scss"),manipulator:"slider",defaults:{label:"",description:"",min:0,max:100,step:1,attributes:{}},initialize:function(){function t(){var t=e.get().toFixed(e.precision);n.set("value",t),r.set("innerHTML",t)}var e=this,n=e.$element.select(".value"),r=e.$element.select(".value-pad"),o=e.$manipulatorTarget,i=o.get("step");i=i.toString(10).split(".")[1],e.precision=i?i.length:0,e.on("change",t),o.on("|input",t),t(),n.on("|input",function(){r.set("innerHTML",this.get("value"))}),n.on("|change",function(){e.set(this.get("value")),t()})}}},{"../../styles/clay/components/slider.scss":27,"../../templates/components/slider.tpl":38}],18:[function(t,e,n){"use strict";e.exports={name:"submit",template:t("../../templates/components/submit.tpl"),style:t("../../styles/clay/components/submit.scss"),manipulator:"button",defaults:{attributes:{}}}},{"../../styles/clay/components/submit.scss":28,"../../templates/components/submit.tpl":39}],19:[function(t,e,n){"use strict";e.exports={name:"text",template:t("../../templates/components/text.tpl"),manipulator:"html"}},{"../../templates/components/text.tpl":40}],20:[function(t,e,n){"use strict";e.exports={name:"toggle",template:t("../../templates/components/toggle.tpl"),style:t("../../styles/clay/components/toggle.scss"),manipulator:"checked",defaults:{label:"",description:"",attributes:{}}}},{"../../styles/clay/components/toggle.scss":29,"../../templates/components/toggle.tpl":41}],21:[function(t,e,n){e.exports=".component-button { text-align: center; }\n\n.section .component-button { padding-bottom: 0; }\n\n.component-button .description { padding-left: 0; padding-right: 0; }\n"},{}],22:[function(t,e,n){e.exports=".component-checkbox { display: block; }\n\n.section .component-checkbox { padding-right: 0.375rem; }\n\n.component-checkbox > .label { display: block; padding-bottom: 0.35rem; }\n\n.component-checkbox .checkbox-group { padding-bottom: 0.35rem; }\n\n.component-checkbox .checkbox-group label { padding: 0.35rem 0.375rem; }\n\n.component-checkbox .checkbox-group .label { font-size: 0.9em; }\n\n.component-checkbox .checkbox-group input { opacity: 0; position: absolute; }\n\n.component-checkbox .checkbox-group i { display: block; position: relative; border-radius: 0.25rem; width: 1.4rem; height: 1.4rem; border: 0.11765rem solid #767676; -webkit-flex-shrink: 0; flex-shrink: 0; }\n\n.component-checkbox .checkbox-group input:checked + i { border-color: #ff4700; background: #ff4700; }\n\n.component-checkbox .checkbox-group input:checked + i:after { content: ''; box-sizing: border-box; -webkit-transform: rotate(45deg); transform: rotate(45deg); position: absolute; left: 0.35rem; top: -0.05rem; display: block; width: 0.5rem; height: 1rem; border: 0 solid #ffffff; border-right-width: 0.11765rem; border-bottom-width: 0.11765rem; }\n\n.component-checkbox .description { padding-left: 0; padding-right: 0; }\n"},{}],23:[function(t,e,n){e.exports=".section .component-color { padding: 0; }\n\n.component-color .value { width: 2.2652rem; height: 1.4rem; border-radius: 0.7rem; box-shadow: 0 0.1rem 0.1rem #2f2f2f; display: block; background: #000; }\n\n.component-color .picker-wrap { left: 0; top: 0; right: 0; bottom: 0; position: fixed; padding: 0.7rem 0.375rem; background: rgba(0, 0, 0, 0.65); opacity: 0; -webkit-transition: opacity 100ms ease-in 175ms; transition: opacity 100ms ease-in 175ms; pointer-events: none; z-index: 100; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; flex-direction: column; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }\n\n.component-color .picker-wrap .picker { padding: 0.7rem 0.75rem; background: #484848; box-shadow: 0 0.17647rem 0.88235rem rgba(0, 0, 0, 0.4); border-radius: 0.25rem; width: 100%; max-width: 26rem; overflow: auto; }\n\n.component-color .picker-wrap.show { -webkit-transition-delay: 0ms; transition-delay: 0ms; pointer-events: auto; opacity: 1; }\n\n.component-color .color-box-wrap { box-sizing: border-box; position: relative; height: 0; width: 100%; padding: 0 0 100% 0; }\n\n.component-color .color-box-wrap .color-box-container { position: absolute; height: 99.97%; width: 100%; left: 0; top: 0; }\n\n.component-color .color-box-wrap .color-box-container .color-box { float: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }\n\n.component-color .color-box-wrap .color-box-container .color-box.rounded-tl { border-top-left-radius: 0.25rem; }\n\n.component-color .color-box-wrap .color-box-container .color-box.rounded-tr { border-top-right-radius: 0.25rem; }\n\n.component-color .color-box-wrap .color-box-container .color-box.rounded-bl { border-bottom-left-radius: 0.25rem; }\n\n.component-color .color-box-wrap .color-box-container .color-box.rounded-br { border-bottom-right-radius: 0.25rem; }\n\n.component-color .color-box-wrap .color-box-container .color-box.selected { -webkit-transform: scale(1.1); transform: scale(1.1); border-radius: 0.25rem; box-shadow: #111 0 0 0.24rem; position: relative; z-index: 100; }\n"},{}],24:[function(t,e,n){e.exports=".section .component-input { padding: 0; }\n\n.component-input label { display: block; }\n\n.component-input .label { padding-bottom: 0.7rem; }\n\n.component-input .input { position: relative; min-width: 100%; margin-top: 0.7rem; margin-left: 0; }\n\n.component-input input { display: block; width: 100%; background: #333333; border-radius: 0.25rem; padding: 0.35rem 0.375rem; border: none; vertical-align: baseline; color: #ffffff; font-size: inherit; -webkit-appearance: none; appearance: none; min-height: 2.1rem; }\n\n.component-input input::-webkit-input-placeholder { color: #858585; }\n\n.component-input input::-moz-placeholder { color: #858585; }\n\n.component-input input:-moz-placeholder { color: #858585; }\n\n.component-input input:-ms-input-placeholder { color: #858585; }\n\n.component-input input:focus { border: none; box-shadow: none; }\n\n.component-input input:focus::-webkit-input-placeholder { color: #666666; }\n\n.component-input input:focus::-moz-placeholder { color: #666666; }\n\n.component-input input:focus:-moz-placeholder { color: #666666; }\n\n.component-input input:focus:-ms-input-placeholder { color: #666666; }\n"},{}],25:[function(t,e,n){e.exports=".component-radio { display: block; }\n\n.section .component-radio { padding-right: 0.375rem; }\n\n.component-radio > .label { display: block; padding-bottom: 0.35rem; }\n\n.component-radio .radio-group { padding-bottom: 0.35rem; }\n\n.component-radio .radio-group label { padding: 0.35rem 0.375rem; }\n\n.component-radio .radio-group .label { font-size: 0.9em; }\n\n.component-radio .radio-group input { opacity: 0; position: absolute; }\n\n.component-radio .radio-group i { display: block; position: relative; border-radius: 1.4rem; width: 1.4rem; height: 1.4rem; border: 2px solid #767676; -webkit-flex-shrink: 0; flex-shrink: 0; }\n\n.component-radio .radio-group input:checked + i { border-color: #ff4700; }\n\n.component-radio .radio-group input:checked + i:after { content: ''; display: block; position: absolute; left: 15%; right: 15%; top: 15%; bottom: 15%; border-radius: 1.4rem; background: #ff4700; }\n\n.component-radio .description { padding-left: 0; padding-right: 0; }\n"},{}],26:[function(t,e,n){e.exports='.section .component-select { padding: 0; }\n\n.component-select label { position: relative; }\n\n.component-select .value { position: relative; padding-right: 1.1rem; display: block; }\n\n.component-select .value:after { content: ""; position: absolute; right: 0; top: 50%; margin-top: -0.1rem; height: 0; width: 0; border-left: 0.425rem solid transparent; border-right: 0.425rem solid transparent; border-top: 0.425rem solid #ff4700; }\n\n.component-select select { opacity: 0; position: absolute; display: block; left: 0; right: 0; top: 0; bottom: 0; width: 100%; border: none; margin: 0; padding: 0; }\n'},{}],27:[function(t,e,n){e.exports=".section .component-slider { padding: 0; }\n\n.component-slider label { display: block; }\n\n.component-slider .label-container { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; width: 100%; padding-bottom: 0.7rem; }\n\n.component-slider .label { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; min-width: 1rem; display: block; padding-right: 0.75rem; }\n\n.component-slider .value-wrap { display: block; position: relative; }\n\n.component-slider .value, .component-slider .value-pad { display: block; background: #333333; border-radius: 0.25rem; padding: 0.35rem 0.375rem; border: none; vertical-align: baseline; color: #ffffff; text-align: right; margin: 0; min-width: 1rem; }\n\n.component-slider .value-pad { visibility: hidden; }\n\n.component-slider .value-pad:before { content: ' '; display: inline-block; }\n\n.component-slider .value { max-width: 100%; position: absolute; left: 0; top: 0; }\n\n.component-slider .input-wrap { padding: 0 0.75rem 0.7rem; }\n\n.component-slider .input { display: block; position: relative; min-width: 100%; height: 1.4rem; overflow: hidden; margin-left: 0; }\n\n.component-slider .input:before { content: ''; display: block; position: absolute; height: 0.17647rem; background: #666666; width: 100%; top: 0.61176rem; }\n\n.component-slider .input .slider { display: block; width: 100%; -webkit-appearance: none; appearance: none; position: relative; height: 1.4rem; margin: 0; background-color: transparent; }\n\n.component-slider .input .slider:focus { outline: none; }\n\n.component-slider .input .slider::-webkit-slider-runnable-track { border: none; height: 1.4rem; width: 100%; background-color: transparent; }\n\n.component-slider .input .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; position: relative; height: 1.4rem; width: 1.4rem; background-color: #ff4700; border-radius: 50%; }\n\n.component-slider .input .slider::-webkit-slider-thumb:before { content: \"\"; position: absolute; left: -1000px; top: 0.61176rem; height: 0.17647rem; width: 1001px; background: #ff4700; }\n"},{}],28:[function(t,e,n){e.exports=".component-submit { text-align: center; }\n"},{}],29:[function(t,e,n){e.exports=".section .component-toggle { padding: 0; }\n\n.component-toggle input { display: none; }\n\n.component-toggle .graphic { display: inline-block; position: relative; }\n\n.component-toggle .graphic .slide { display: block; border-radius: 1.05rem; height: 1.05rem; width: 2.2652rem; background: #2f2f2f; -webkit-transition: background-color 150ms linear; transition: background-color 150ms linear; }\n\n.component-toggle .graphic .marker { background: #ececec; width: 1.4rem; height: 1.4rem; border-radius: 1.4rem; position: absolute; left: 0; display: block; top: -0.175rem; -webkit-transition: -webkit-transform 150ms linear; transition: -webkit-transform 150ms linear; transition: transform 150ms linear; transition: transform 150ms linear, -webkit-transform 150ms linear; box-shadow: 0 0.1rem 0.1rem #2f2f2f; }\n\n.component-toggle input:checked + .graphic .slide { background: #993d19; }\n\n.component-toggle input:checked + .graphic .marker { background: #ff4700; -webkit-transform: translateX(0.8652rem); transform: translateX(0.8652rem); }\n"},{}],30:[function(t,e,n){e.exports='
\n \n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],31:[function(t,e,n){e.exports='
\n {{{label}}}\n
\n {{each options}}\n \n {{/each}}\n
\n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],32:[function(t,e,n){e.exports='
\n \n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n
\n
\n
\n
\n
\n
\n
\n'},{}],33:[function(t,e,n){e.exports='
\n'},{}],34:[function(t,e,n){e.exports='
\n \n
\n'},{}],35:[function(t,e,n){e.exports='
\n \n\n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],36:[function(t,e,n){e.exports='
\n {{{label}}}\n
\n {{each options}}\n \n {{/each}}\n
\n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],37:[function(t,e,n){e.exports='
\n \n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],38:[function(t,e,n){e.exports='
\n \n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],39:[function(t,e,n){e.exports='
\n \n
\n'},{}],40:[function(t,e,n){e.exports='
\n

\n
\n'},{}],41:[function(t,e,n){e.exports='
\n \n {{if description}}\n
{{{description}}}
\n {{/if}}\n
\n'},{}],42:[function(t,e,n){e.exports='
'; },{}],"pebble-clay":[function(t,e,n){"use strict";function r(t,e,n){function r(){i.meta={activeWatchInfo:Pebble.getActiveWatchInfo&&Pebble.getActiveWatchInfo(),accountToken:Pebble.getAccountToken(),watchToken:Pebble.getWatchToken(),userData:s(n.userData||{})}}function o(t,e,n){Array.isArray(t)?t.forEach(function(t){o(t,e,n)}):"section"===t.type?o(t.items,e,n):e(t)&&n(t)}var i=this;if(!Array.isArray(t))throw new Error("config must be an Array");if(e&&"function"!=typeof e)throw new Error('customFn must be a function or "null"');n=n||{},i.config=s(t),i.customFn=e||function(){},i.components={},i.meta={activeWatchInfo:null,accountToken:"",watchToken:"",userData:{}},i.version=c,n.autoHandleEvents!==!1&&"undefined"!=typeof Pebble?(Pebble.addEventListener("showConfiguration",function(){r(),Pebble.openURL(i.generateUrl())}),Pebble.addEventListener("webviewclosed",function(t){t&&t.response&&Pebble.sendAppMessage(i.getSettings(t.response),function(){console.log("Sent config data to Pebble")},function(t){console.log("Failed to send config data!"),console.log(JSON.stringify(t))})})):"undefined"!=typeof Pebble&&Pebble.addEventListener("ready",function(){r()}),o(i.config,function(t){return a[t.type]},function(t){i.registerComponent(a[t.type])}),o(i.config,function(t){return t.appKey},function(){throw new Error("appKeys are no longer supported. Please follow the migration guide to upgrade your project")})}var o=t("./tmp/config-page.html"),i=t("tosource"),a=t("./src/scripts/components"),s=t("deepcopy/build/deepcopy.min"),c=t("./package.json").version,l=t("message_keys");r.prototype.registerComponent=function(t){this.components[t.name]=t},r.prototype.generateUrl=function(){var t={},e=!Pebble||"pypkjs"===Pebble.platform,n=e?"$$$RETURN_TO$$$":"pebblejs://close#";try{t=JSON.parse(localStorage.getItem("clay-settings"))||{}}catch(a){console.error(a.toString())}var s=o.replace("$$RETURN_TO$$",n).replace("$$CUSTOM_FN$$",i(this.customFn)).replace("$$CONFIG$$",i(this.config)).replace("$$SETTINGS$$",i(t)).replace("$$COMPONENTS$$",i(this.components)).replace("$$META$$",i(this.meta));return e?r.encodeDataUri(s,"http://clay.pebble.com.s3-website-us-west-2.amazonaws.com/#"):r.encodeDataUri(s)},r.prototype.getSettings=function(t,e){var n={};t=t.match(/^\{/)?t:decodeURIComponent(t);try{n=JSON.parse(t)}catch(o){throw new Error("The provided response was not valid JSON")}var i={};return Object.keys(n).forEach(function(t){"object"==typeof n[t]&&n[t]?i[t]=n[t].value:i[t]=n[t]}),localStorage.setItem("clay-settings",JSON.stringify(i)),e===!1?n:r.prepareSettingsForAppMessage(n)},r.prototype.setSettings=function(t,e){var n={};try{n=JSON.parse(localStorage.getItem("clay-settings"))||{}}catch(r){console.error(r.toString())}if("object"==typeof t){var o=t;Object.keys(o).forEach(function(t){n[t]=o[t]})}else n[t]=e;localStorage.setItem("clay-settings",JSON.stringify(n))},r.encodeDataUri=function(t,e){return e="undefined"!=typeof e?e:"data:text/html;charset=utf-8,",e+encodeURIComponent(t)},r.prepareForAppMessage=function(t){function e(t,e){return Math.floor(t*Math.pow(10,e||0))}var n;return Array.isArray(t)?(n=[],t.forEach(function(t,e){n[e]=r.prepareForAppMessage(t)})):n="object"==typeof t&&t?"number"==typeof t.value?e(t.value,t.precision):Array.isArray(t.value)?t.value.map(function(n){return"number"==typeof n?e(n,t.precision):n}):r.prepareForAppMessage(t.value):"boolean"==typeof t?t?1:0:t,n},r.prepareSettingsForAppMessage=function(t){var e={};Object.keys(t).forEach(function(n){var r=t[n],o=n.match(/(.+?)(?:\[(\d*)\])?$/);if(!o[2])return void(e[n]=r);var i=parseInt(o[2],10);n=o[1],"undefined"==typeof e[n]&&(e[n]=[]),e[n][i]=r});var n={};return Object.keys(e).forEach(function(t){var o=l[t],i=r.prepareForAppMessage(e[t]);i=Array.isArray(i)?i:[i],i.forEach(function(t,e){n[o+e]=t})}),Object.keys(n).forEach(function(t){if(Array.isArray(n[t]))throw new Error('Clay does not support 2 dimensional arrays for item values. Make sure you are not attempting to use array syntax (eg: "myMessageKey[2]") in the messageKey for components that return an array, such as a checkboxgroup')}),n},e.exports=r},{"./package.json":7,"./src/scripts/components":13,"./tmp/config-page.html":42,"deepcopy/build/deepcopy.min":3,message_keys:void 0,tosource:6}]},{},["pebble-clay"])("pebble-clay")}); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { module.exports = function(module) { switch(module) { case "message_keys": return __webpack_require__(5); } throw new Error('Module not found: ' + module); }; /***/ }), /* 5 */ /***/ (function(module, exports) { module.exports = {"JSReady":10005,"auth":10000,"password":10004,"server":10002,"status":10001,"username":10003} /***/ }), /* 6 */ /***/ (function(module, exports) { module.exports = [ { "type": "heading", "defaultValue": "DSCam Home Swtich Configuration" }, { "type": "text", "defaultValue": "Set your Synology account and server." }, { "type": "section", "items": [ { "type": "heading", "defaultValue": "Your synology account" }, { "type": "input", "messageKey": "server", "label": "Your DSM Server", "attributes": { "type": "url", "maxlength": 255 } }, { "type": "input", "messageKey": "username", "label": "Your DSM Username", "attributes": { "maxlength":40 } }, { "type": "input", "messageKey": "password", "label": "Your DSM Password", "attributes": { "type": "password", "maxlength":40 } }, { "type": "toggle", "messageKey": "OTP_enabled", "label": "toggle on if 2FA enabled on user" }, { "type": "input", "messageKey": "OTP_seed", "label": "seed provided by DSM for the user" } ] }, { "type": "submit", "defaultValue": "Save Settings" } ]; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding HMAC implementation as defined in FIPS PUB 198a Copyright Brian Turek 2008-2017 Distributed under the BSD License See http://caligatio.github.com/jsSHA/ for more information Several functions taken from Paul Johnston */ 'use strict';(function(Y){function C(c,a,b){var e=0,h=[],n=0,g,l,d,f,m,q,u,r,I=!1,v=[],w=[],t,y=!1,z=!1,x=-1;b=b||{};g=b.encoding||"UTF8";t=b.numRounds||1;if(t!==parseInt(t,10)||1>t)throw Error("numRounds must a integer >= 1");if("SHA-1"===c)m=512,q=K,u=Z,f=160,r=function(a){return a.slice()};else if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return L(a,b,c)},u=function(a,b,h,e){var k,f;if("SHA-224"===c||"SHA-256"===c)k=(b+65>>>9<<4)+15,f=16;else if("SHA-384"===c||"SHA-512"===c)k=(b+129>>>10<< 5)+31,f=32;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=k;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+h;a[k]=b&4294967295;a[k-1]=b/4294967296|0;h=a.length;for(b=0;be;e+=1)c[e]=a[e].slice();return c};x=1;if("SHA3-224"=== c)m=1152,f=224;else if("SHA3-256"===c)m=1088,f=256;else if("SHA3-384"===c)m=832,f=384;else if("SHA3-512"===c)m=576,f=512;else if("SHAKE128"===c)m=1344,f=-1,F=31,z=!0;else if("SHAKE256"===c)m=1088,f=-1,F=31,z=!0;else throw Error("Chosen SHA variant is not supported");u=function(a,c,e,b,h){e=m;var k=F,f,g=[],n=e>>>5,l=0,d=c>>>5;for(f=0;f=e;f+=n)b=D(a.slice(f,f+n),b),c-=e;a=a.slice(f);for(c%=e;a.length>>3;a[f>>2]^=k<=h)break;g.push(a.a);l+=1;0===64*l%e&&D(null,b)}return g}}else throw Error("Chosen SHA variant is not supported");d=M(a,g,x);l=A(c);this.setHMACKey=function(a,b,h){var k;if(!0===I)throw Error("HMAC key already set");if(!0===y)throw Error("Cannot set HMAC key after calling update");if(!0===z)throw Error("SHAKE is not supported for HMAC");g=(h||{}).encoding||"UTF8";b=M(b,g,x)(a);a=b.binLen;b=b.value;k=m>>>3;h=k/4-1;if(ka/8){for(;b.length<=h;)b.push(0);b[h]&=4294967040}for(a=0;a<=h;a+=1)v[a]=b[a]^909522486,w[a]=b[a]^1549556828;l=q(v,l);e=m;I=!0};this.update=function(a){var c,b,k,f=0,g=m>>>5;c=d(a,h,n);a=c.binLen;b=c.value;c=a>>>5;for(k=0;k>>5);n=a%m;y=!0};this.getHash=function(a,b){var k,g,d,m;if(!0===I)throw Error("Cannot call getHash after setting HMAC key");d=N(b);if(!0===z){if(-1===d.shakeLen)throw Error("shakeLen must be specified in options"); f=d.shakeLen}switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(p){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}m=u(h.slice(),n,e,r(l),f);for(g=1;g>>24-f%32),m=u(m,f, 0,A(c),f);return k(m)};this.getHMAC=function(a,b){var k,g,d,p;if(!1===I)throw Error("Cannot call getHMAC without first setting HMAC key");d=N(b);switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{k=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER"); }g=u(h.slice(),n,e,r(l),f);p=q(w,A(c));p=u(g,f,m,p,f);return k(p)}}function b(c,a){this.a=c;this.b=a}function O(c,a,b,e){var h="";a/=8;var n,g,d;d=-1===b?3:0;for(n=0;n>>2]>>>8*(d+n%4*b),h+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return e.outputUpper?h.toUpperCase():h}function P(c,a,b,e){var h="",n=a/8,g,d,p,f;f=-1===b?3:0;for(g=0;g>>2]:0,p=g+2>>2]:0,p=(c[g>>>2]>>>8*(f+g%4*b)&255)<<16|(d>>>8*(f+(g+1)%4*b)&255)<<8|p>>>8*(f+ (g+2)%4*b)&255,d=0;4>d;d+=1)8*g+6*d<=a?h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(p>>>6*(3-d)&63):h+=e.b64Pad;return h}function Q(c,a,b){var e="";a/=8;var h,d,g;g=-1===b?3:0;for(h=0;h>>2]>>>8*(g+h%4*b)&255,e+=String.fromCharCode(d);return e}function R(c,a,b){a/=8;var e,h=new ArrayBuffer(a),d,g;g=new Uint8Array(h);d=-1===b?3:0;for(e=0;e>>2]>>>8*(d+e%4*b)&255;return h}function N(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{}; a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if(!0===c.hasOwnProperty("shakeLen")){if(0!==c.shakeLen%8)throw Error("shakeLen must be a multiple of 8");a.shakeLen=c.shakeLen}if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function M(c,a,b){switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE"); }switch(c){case "HEX":c=function(a,c,d){var g=a.length,l,p,f,m,q,u;if(0!==g%2)throw Error("String of HEX type must be in byte increments");c=c||[0];d=d||0;q=d>>>3;u=-1===b?3:0;for(l=0;l>>1)+q;for(f=m>>>2;c.length<=f;)c.push(0);c[f]|=p<<8*(u+m%4*b)}return{value:c,binLen:4*g+d}};break;case "TEXT":c=function(c,h,d){var g,l,p=0,f,m,q,u,r,t;h=h||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(t=-1=== b?3:0,f=0;fg?l.push(g):2048>g?(l.push(192|g>>>6),l.push(128|g&63)):55296>g||57344<=g?l.push(224|g>>>12,128|g>>>6&63,128|g&63):(f+=1,g=65536+((g&1023)<<10|c.charCodeAt(f)&1023),l.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),m=0;m>>2;h.length<=u;)h.push(0);h[u]|=l[m]<<8*(t+r%4*b);p+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(t=-1===b?2:0,l="UTF16LE"===a&&1!==b||"UTF16LE"!==a&&1===b,f=0;f>>8);r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=g<<8*(t+r%4*b);p+=2}return{value:h,binLen:8*p+d}};break;case "B64":c=function(a,c,d){var g=0,l,p,f,m,q,u,r,t;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");p=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==p&&p= str.length) {\n str = Array(len + 1 - str.length).join(pad) + str;\n }\n return str;\n}\n\nfunction getOtp() {\n key = base32tohex(JSON.parse(localStorage.getItem('clay-settings')).OTP_seed)\n //console.log('-- seed:' + JSON.parse(localStorage.getItem('clay-settings')).OTP_seed)\n //console.log('-- key:' + key)\n var epoch = Math.round(new Date().getTime() / 1000.0);\n var time = leftpad(dec2hex(Math.floor(epoch / 30)), 16, '0');\n // updated for jsSHA v2.0.0 - http://caligatio.github.io/jsSHA/\n var shaObj = new jsSHA(\"SHA-1\", \"HEX\");\n shaObj.setHMACKey(key, \"HEX\");\n shaObj.update(time);\n var hmac = shaObj.getHMAC(\"HEX\");\n //console.log('-- hmac:' + hmac)\n var offset = hex2dec(hmac.substring(hmac.length - 1));\n //console.log('--offset:' + offset)\n var otp = (hex2dec(hmac.substr(offset * 2, 8)) & hex2dec('7fffffff')) + '';\n otp = (otp).substr(otp.length - 6, 6);\n return otp\n}\n\nfunction xhr_to_syno(method, url_path, onload_function, max_retry) {\n console.log('------xhr start')\n status = \"\";\n if (JSON.parse(localStorage.getItem('clay-settings')).server) {\n var server = JSON.parse(localStorage.getItem('clay-settings')).server\n url = server + url_path;\n var xhr = new XMLHttpRequest();\n xhr.timeout = 6000; // time in milliseconds\n\n xhr.open(method, url, true);\n console.log('------xhr opened')\n xhr.onload = function () {\n console.log('------xhr onload')\n if (xhr.readyState === 4) {\n retry = 1;\n console.log('------xhr request returned');\n if (xhr.status == 200) {\n onload_function(xhr);\n return true;\n } else {\n console.log('------xhr request returned error code ' + xhr.status);\n message = \"Error (XHR\"+xhr.status+\")\";\n // Build message\n var dict = {\n 'status': message,\n };\n\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n return false;\n }\n }\n };\n\n xhr.ontimeout = function (e) {\n retry++;\n if (retry < max_retry) {\n console.log('------xhr timed out retrying another time ');\n //send back \"timeout\" to watch\n message = \"Time out, retrying...\";\n\n // Build message\n var dict = {\n 'status': message,\n };\n\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n xhr_to_syno(method, url_path, onload_function, max_retry);\n } else {\n console.log('------xhr timed out ' + retry + ' times');\n //send back \"timeout\" to watch\n message = \"Time out too many times, verify settings and connectivity\";\n\n // Build message\n var dict = {\n 'status': message,\n };\n\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n return false;\n }\n };\n xhr.send(null);\n\n } else {\n Pebble.showSimpleNotificationOnPebble(\"DSCam H-S\", \"You need to set your Synology account and server.\");\n }\n\n}\n\n\nfunction authenticate() {\n var response;\n sid = \"\";\n console.log('---- authenticate');\n if (JSON.parse(localStorage.getItem('clay-settings')).username && JSON.parse(localStorage.getItem('clay-settings')).password) {\n var username = JSON.parse(localStorage.getItem('clay-settings')).username;\n var password = JSON.parse(localStorage.getItem('clay-settings')).password;\n console.log('-- username:' + username);\n console.log('-- password:' + password.substring(0, 1) + '...');\n var url_path = \"/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=6&account=\" + username + \"&passwd=\" + password + \"&session=SurveillanceStation&format=sid\";\n if (JSON.parse(localStorage.getItem('clay-settings')).OTP_enabled) {\n var otp_code = getOtp()\n console.log('-- otp_code is :' + otp_code)\n url_path = url_path + \"&otp_code=\" + otp_code\n }\n var method = \"GET\";\n onload_function = function (xhr) {\n response = JSON.parse(xhr.responseText);\n if (response.success == true) {\n sid = response.data.sid;\n console.log('------Authentication succeeded');\n if (sid != \"\") {\n message = \"Welcome to Syno Cam Switch ! ready & authenticated\";\n // Build message\n var dict = {\n 'auth': message,\n };\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n get_status();\n } else {\n console.log('------Unexpected error : authentication is OK but no SID retrieved');\n message = \"Auth error, no SID\";\n // Build message\n var dict = {\n 'auth': message,\n };\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n }\n } else {\n console.log('------Authentication failed : ' + JSON.stringify(response));\n message = \"Authentication failed\";\n // Build message\n var dict = {\n 'auth': message,\n };\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n }\n };\n max_retry = 10;\n xhr_to_syno(method, url_path, onload_function, max_retry);\n } else {\n console.log(\"--- failed to get settings\");\n Pebble.showSimpleNotificationOnPebble(\"DSCam H-S\", \"You need to set your Synology account and server.\");\n }\n\n\n}\n\n\nfunction get_status() {\n var response;\n\n if (sid != \"\") {\n status = \"\";\n console.log('---- get_status');\n\n var url_path = \"/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid=\" + sid;\n var method = \"GET\";\n\n onload_function = function (xhr) {\n response = JSON.parse(xhr.responseText);\n if (response.success == true) {\n status = response.data.on;\n var message;\n switch (status) {\n case true:\n message = \"Home mode is ON (camera is off)\";\n break;\n case false:\n message = \"Home mode is OFF (camera is on)\";\n break;\n default:\n message = \"something happened, try again ! (IMPOSSIBLE)\";\n }\n }else{\n message = \"something happened, try again ! (G200)\";\n }\n // Build message\n var dict = {\n 'status': message,\n };\n\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n }\n\n max_retry = 10;\n xhr_to_syno(method, url_path, onload_function, max_retry);\n\n } else {\n authenticate();\n get_status();\n }\n\n}\n\n\nfunction timed_switch_home(duration) {\n var response;\n console.log('---- authenticate');\n if (sid != \"\") {\n var epoch = Math.round(new Date().getTime() / 1000.0);\n var start_ts = epoch + 10\n var end_ts = duration + start_ts\n console.log('---- switching home mode for ' + duration + 'seconds');\n url_path = \"/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=SaveOneTimeSwitch&onetime_enable_on=true&onetime_disable_on=true&onetime_enable_time=\" + start_ts + \"&onetime_disable_time=\" + end_ts + \"&_sid=\" + sid;\n method = \"GET\"\n onload_switch_function = function (xhr) {\n response = JSON.parse(xhr.responseText);\n if (response.success == true) {\n message = \"Home mode is ON for \"+duration+\" seconds\";\n }else{\n message = \"something happened, try again ! (S200)\";\n }\n // Build message\n dict = {\n 'status': message,\n };\n\n // Send the message Home mode is ON for 900 seconds\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent \\\"'+message+'\\\"');\n }, function () {\n console.log('failed');\n });\n }\n max_retry = 10;\n xhr_to_syno(method, url_path, onload_switch_function, max_retry);\n\n\n } else {\n authenticate();\n switch_home(bool);\n }\n\n}\n\nfunction switch_home(bool) {\n var response;\n console.log('---- authenticate');\n if (sid != \"\") {\n console.log('---- switching home mode to ' + bool);\n url_path = \"/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=\" + bool + \"&_sid=\" + sid;\n method = \"GET\"\n onload_switch_function = function (xhr) {\n response = JSON.parse(xhr.responseText);\n if (response.success == true) {\n switch (bool) {\n case true:\n message = \"Home mode is ON (camera is off)\";\n break;\n case false:\n message = \"Home mode is OFF (camera is on)\";\n break;\n default:\n message = \"something happened, try again ! (IMPOSSIBLE)\";\n }\n }else{\n message = \"something happened, try again ! (S200)\";\n }\n // Build message\n dict = {\n 'status': message,\n };\n\n // Send the message\n Pebble.sendAppMessage(dict, function (e) {\n console.log('sent');\n }, function () {\n console.log('failed');\n });\n }\n max_retry = 10;\n xhr_to_syno(method, url_path, onload_switch_function, max_retry);\n\n\n } else {\n authenticate();\n switch_home(bool);\n }\n\n}\n\n// Get JS readiness events\nPebble.addEventListener('ready', function (e) {\n console.log(\"---- local storage:\");\n console.log(\"user \" + JSON.parse(localStorage.getItem('clay-settings')).username);\n console.log('PebbleKit JS is ready');\n // Update Watch on this\n Pebble.sendAppMessage({ 'JSReady': 1 });\n});\n\n// Get AppMessage events\nPebble.addEventListener('appmessage', function (e) {\n // Get the dictionary from the message\n var dict = e.payload;\n console.log(dict[0].toString());\n switch (dict[0]) {\n case 'auth':\n authenticate();\n break;\n case 'get':\n get_status();\n break;\n case 'home_on':\n //switch_home(true);\n timed_switch_home(15*60)\n break;\n case 'home_off':\n switch_home(false);\n break;\n default:\n console.log('Sorry. I don\\'t understand your request :' + dict[0]);\n }\n\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pkjs/index.js\n// module id = 2\n// module chunks = 0","/* Clay - https://github.com/pebble/clay - Version: 1.0.4 - Build Date: 2016-11-21T20:14:28.839Z */\n!function(t){if(\"object\"==typeof exports&&\"undefined\"!=typeof module)module.exports=t();else if(\"function\"==typeof define&&define.amd)define([],t);else{var e;e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:this,e.pebbleClay=t()}}(function(){var t;return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c=\"function\"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var l=new Error(\"Cannot find module '\"+a+\"'\");throw l.code=\"MODULE_NOT_FOUND\",l}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i=\"function\"==typeof require&&require,a=0;a0)throw new Error(\"Invalid string. Length must be a multiple of 4\");return\"=\"===t[e-2]?2:\"=\"===t[e-1]?1:0}function o(t){return 3*t.length/4-r(t)}function i(t){var e,n,o,i,a,s,c=t.length;a=r(t),s=new f(3*c/4-a),o=a>0?c-4:c;var l=0;for(e=0,n=0;e>16&255,s[l++]=i>>8&255,s[l++]=255&i;return 2===a?(i=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,s[l++]=255&i):1===a&&(i=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,s[l++]=i>>8&255,s[l++]=255&i),s}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function s(t,e,n){for(var r,o=[],i=e;iu?u:c+a));return 1===r?(e=t[n-1],o+=l[e>>2],o+=l[e<<4&63],o+=\"==\"):2===r&&(e=(t[n-2]<<8)+t[n-1],o+=l[e>>10],o+=l[e>>4&63],o+=l[e<<2&63],o+=\"=\"),i.push(o),i.join(\"\")}n.byteLength=o,n.toByteArray=i,n.fromByteArray=c;for(var l=[],u=[],f=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,p=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",d=0,h=p.length;d \n * @license MIT\n */\n\"use strict\";function r(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function o(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(o()=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function g(t){return+t!=t&&(t=0),a.alloc(+t)}function b(t,e){if(a.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return n;case\"utf8\":case\"utf-8\":case void 0:return W(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*n;case\"hex\":return n>>>1;case\"base64\":return U(t).length;default:if(r)return W(t).length;e=(\"\"+e).toLowerCase(),r=!0}}function y(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return\"\";if(n>>>=0,e>>>=0,n<=e)return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return D(this,e,n);case\"utf8\":case\"utf-8\":return E(this,e,n);case\"ascii\":return B(this,e,n);case\"latin1\":case\"binary\":return S(this,e,n);case\"base64\":return O(this,e,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return N(this,e,n);default:if(r)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function A(t,e,n,r,o){if(0===t.length)return-1;if(\"string\"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if(\"string\"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:w(t,e,n,r,o);if(\"number\"==typeof e)return e=255&e,a.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,r,o);throw new TypeError(\"val must be string, number or Buffer\")}function w(t,e,n,r,o){function i(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,s=t.length,c=e.length;if(void 0!==r&&(r=String(r).toLowerCase(),\"ucs2\"===r||\"ucs-2\"===r||\"utf16le\"===r||\"utf-16le\"===r)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,n/=2}var l;if(o){var u=-1;for(l=n;ls&&(n=s-c),l=n;l>=0;l--){for(var f=!0,p=0;po&&(r=o)):r=o;var i=e.length;if(i%2!==0)throw new TypeError(\"Invalid hex string\");r>i/2&&(r=i/2);for(var a=0;a239?4:i>223?3:i>191?2:1;if(o+s<=n){var c,l,u,f;switch(s){case 1:i<128&&(a=i);break;case 2:c=t[o+1],128===(192&c)&&(f=(31&i)<<6|63&c,f>127&&(a=f));break;case 3:c=t[o+1],l=t[o+2],128===(192&c)&&128===(192&l)&&(f=(15&i)<<12|(63&c)<<6|63&l,f>2047&&(f<55296||f>57343)&&(a=f));break;case 4:c=t[o+1],l=t[o+2],u=t[o+3],128===(192&c)&&128===(192&l)&&128===(192&u)&&(f=(15&i)<<18|(63&c)<<12|(63&l)<<6|63&u,f>65535&&f<1114112&&(a=f))}}null===a?(a=65533,s=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),o+=s}return j(r)}function j(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n=\"\",r=0;rr)&&(n=r);for(var o=\"\",i=e;in)throw new RangeError(\"Trying to access beyond buffer length\")}function F(t,e,n,r,o,i){if(!a.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError(\"Index out of range\")}function z(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o>>8*(r?o:1-o)}function I(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o>>8*(r?o:3-o)&255}function L(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"Index out of range\")}function K(t,e,n,r,o){return o||L(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(t,e,n,r,23,4),n+4}function G(t,e,n,r,o){return o||L(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(t,e,n,r,52,8),n+8}function C(t){if(t=X(t).replace(et,\"\"),t.length<2)return\"\";for(;t.length%4!==0;)t+=\"=\";return t}function X(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function V(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function W(t,e){e=e||1/0;for(var n,r=t.length,o=null,i=[],a=0;a55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Z(t){for(var e=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function U(t){return Q.toByteArray(C(t))}function q(t,e,n,r){for(var o=0;o=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function H(t){return t!==t}var Q=t(\"base64-js\"),$=t(\"ieee754\"),_=t(\"isarray\");n.Buffer=a,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=o(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,n){return s(null,t,e,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,n){return l(null,t,e,n)},a.allocUnsafe=function(t){return u(null,t)},a.allocUnsafeSlow=function(t){return u(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError(\"Arguments must be Buffers\");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);o0&&(t=this.toString(\"hex\",0,e).match(/.{2}/g).join(\" \"),this.length>e&&(t+=\" ... \")),\"\"},a.prototype.compare=function(t,e,n,r,o){if(!a.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError(\"out of range index\");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;for(var i=o-r,s=n-e,c=Math.min(i,s),l=this.slice(r,o),u=t.slice(e,n),f=0;fo)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");r||(r=\"utf8\");for(var i=!1;;)switch(r){case\"hex\":return k(this,t,e,n);case\"utf8\":case\"utf-8\":return x(this,t,e,n);case\"ascii\":return M(this,t,e,n);case\"latin1\":case\"binary\":return T(this,t,e,n);case\"base64\":return R(this,t,e,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return P(this,t,e,n);default:if(i)throw new TypeError(\"Unknown encoding: \"+r);r=(\"\"+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e0&&(o*=256);)r+=this[t+--e]*o;return r},a.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,n){t=0|t,e=0|e,n||Y(t,e,this.length);for(var r=this[t],o=1,i=0;++i=o&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,n){t=0|t,e=0|e,n||Y(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e=0|e,n=0|n,!r){var o=Math.pow(2,8*n)-1;F(this,t,e,n,o,0)}var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+n},a.prototype.writeUInt8=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):z(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):z(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);F(this,t,e,n,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+n},a.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);F(this,t,e,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},a.prototype.writeInt8=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):z(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):z(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,n){return t=+t,e=0|e,n||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,n){return K(this,t,e,!0,n)},a.prototype.writeFloatBE=function(t,e,n){return K(this,t,e,!1,n)},a.prototype.writeDoubleLE=function(t,e,n){return G(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return G(this,t,e,!1,n)},a.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError(\"sourceStart out of bounds\");if(r<0)throw new RangeError(\"sourceEnd out of bounds\");r>this.length&&(r=this.length),t.length-e=0;--o)t[o+e]=this[o+n];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var i;if(\"number\"==typeof t)for(i=e;in;++n)if(i=t[n],i===e||i!==i&&e!==e)return n;return-1}n.__esModule=!0;var o=Object.prototype.toString,i=\"undefined\"!=typeof e?function(t){return e.isBuffer(t)}:function(){return!1},a=\"function\"==typeof Object.keys?function(t){return Object.keys(t)}:function(t){var e=typeof t;if(null===t||\"function\"!==e&&\"object\"!==e)throw new TypeError(\"obj must be an Object\");var n=[],r=void 0;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.push(r);return n},s=\"function\"==typeof Symbol?function(t){return Object.getOwnPropertySymbols(t)}:function(){return[]};n.getKeys=a,n.getSymbols=s,n.indexOf=r,n.isBuffer=i},function(t,n,r){\"use strict\";function o(t,e){var n=a(t);return null!==n?n:i(t,e)}function i(t,n){if(\"function\"!=typeof n)throw new TypeError(\"customizer is must be a Function\");if(\"function\"==typeof t){var r=String(t);return/^\\s*function\\s*\\S*\\([^\\)]*\\)\\s*{\\s*\\[native code\\]\\s*}/.test(r)?t:new Function(\"return \"+String(r))()}var o=c.call(t);if(\"[object Array]\"===o)return[];if(\"[object Object]\"===o&&t.constructor===Object)return{};if(\"[object Date]\"===o)return new Date(t.getTime());if(\"[object RegExp]\"===o){var i=String(t),a=i.lastIndexOf(\"/\");return new RegExp(i.slice(1,a),i.slice(a+1))}if((0,s.isBuffer)(t)){var l=new e(t.length);return t.copy(l),l}var u=n(t);return void 0!==u?u:null}function a(t){var e=typeof t;return null!==t&&\"object\"!==e&&\"function\"!==e?t:null}n.__esModule=!0,n.copyValue=n.copyCollection=n.copy=void 0;var s=r(1),c=Object.prototype.toString;n.copy=o,n.copyCollection=i,n.copyValue=a},function(t,e,n){\"use strict\";function r(t){}function o(t){var e=arguments.length<=1||void 0===arguments[1]?r:arguments[1];if(null===t)return null;var n=(0,a.copyValue)(t);if(null!==n)return n;var o=(0,a.copyCollection)(t,e),s=null!==o?o:t,c=[t],l=[s];return i(t,e,s,c,l)}function i(t,e,n,r,o){if(null===t)return null;var c=(0,a.copyValue)(t);if(null!==c)return c;var l=(0,s.getKeys)(t).concat((0,s.getSymbols)(t)),u=void 0,f=void 0,p=void 0,d=void 0,h=void 0,m=void 0,g=void 0,b=void 0;for(u=0,f=l.length;f>u;++u)p=l[u],d=t[p],h=(0,s.indexOf)(r,d),m=void 0,g=void 0,b=void 0,-1===h?(m=(0,a.copy)(d,e),g=null!==m?m:d,null!==d&&/^(?:function|object)$/.test(typeof d)&&(r.push(d),o.push(g))):b=o[h],n[p]=b||i(d,e,g,r,o);return n}e.__esModule=!0;var a=n(2),s=n(1);e[\"default\"]=o,t.exports=e[\"default\"]}])})}).call(this,e(\"buffer\").Buffer)},{buffer:2}],4:[function(t,e,n){n.read=function(t,e,n,r,o){var i,a,s=8*o-r-1,c=(1<>1,u=-7,f=n?o-1:0,p=n?-1:1,d=t[e+f];for(f+=p,i=d&(1<<-u)-1,d>>=-u,u+=s;u>0;i=256*i+t[e+f],f+=p,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+t[e+f],f+=p,u-=8);if(0===i)i=1-l;else{if(i===c)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,r),i-=l}return(d?-1:1)*a*Math.pow(2,i-r)},n.write=function(t,e,n,r,o,i){var a,s,c,l=8*i-o-1,u=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,h=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),e+=a+f>=1?p/c:p*Math.pow(2,1-f),e*c>=2&&(a++,c/=2),a+f>=u?(s=0,a=u):a+f>=1?(s=(e*c-1)*Math.pow(2,o),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;t[n+d]=255&s,d+=h,s/=256,o-=8);for(a=a<0;t[n+d]=255&a,d+=h,a/=256,l-=8);t[n+d-h]|=128*m}},{}],5:[function(t,e,n){var r={}.toString;e.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)}},{}],6:[function(t,e,n){function r(t){return/^[a-z_$][0-9a-z_$]*$/gi.test(t)&&!i.test(t)}function o(t){if(a)return t.toString();var e=t.source.replace(/\\//g,function(t,e,n){return 0===e||\"\\\\\"!==n[e-1]?\"\\\\/\":\"/\"}),n=(t.global&&\"g\"||\"\")+(t.ignoreCase&&\"i\"||\"\")+(t.multiline&&\"m\"||\"\");return\"/\"+e+\"/\"+n}/* toSource by Marcello Bastea-Forte - zlib license */\ne.exports=function(t,e,n,i){function a(t,e,n,i,s){function c(t){return n.slice(1)+t.join(\",\"+(n&&\"\\n\")+l)+(n?\" \":\"\")}var l=i+n;switch(t=e?e(t):t,typeof t){case\"string\":return JSON.stringify(t);case\"boolean\":case\"number\":case\"undefined\":return\"\"+t;case\"function\":return t.toString()}if(null===t)return\"null\";if(t instanceof RegExp)return o(t);if(t instanceof Date)return\"new Date(\"+t.getTime()+\")\";var u=s.indexOf(t)+1;if(u>0)return\"{$circularReference:\"+u+\"}\";if(s.push(t),Array.isArray(t))return\"[\"+c(t.map(function(t){return a(t,e,n,l,s.slice())}))+\"]\";var f=Object.keys(t);return f.length?\"{\"+c(f.map(function(o){return(r(o)?o:JSON.stringify(o))+\":\"+a(t[o],e,n,l,s.slice())}))+\"}\":\"{}\"}var s=[];return a(t,e,void 0===n?\" \":n||\"\",i||\"\",s)};var i=/^(abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|undefined|var|void|volatile|while|with)$/,a=\"\\\\/\"===new RegExp(\"/\").source},{}],7:[function(t,e,n){e.exports={name:\"pebble-clay\",version:\"1.0.4\",description:\"Pebble Config Framework\",scripts:{\"test-travis\":\"./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run --browsers chromeTravisCI && ./node_modules/.bin/eslint ./\",\"test-debug\":\"(export DEBUG=true && ./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --no-single-run)\",test:\"./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run\",lint:\"./node_modules/.bin/eslint ./\",build:\"gulp\",dev:\"gulp dev\",\"pebble-clean\":\"rm -rf tmp src/js/index.js && pebble clean\",\"pebble-publish\":\"npm run pebble-clean && npm run build && pebble build && pebble package publish && npm run pebble-clean\",\"pebble-build\":\"npm run build && pebble build\"},repository:{type:\"git\",url:\"git+https://github.com/pebble/clay.git\"},keywords:[\"pebble\",\"config\",\"configuration\",\"pebble-package\"],author:\"Pebble Technology\",license:\"MIT\",bugs:{url:\"https://github.com/pebble/clay/issues\"},pebble:{projectType:\"package\",sdkVersion:\"3\",targetPlatforms:[\"aplite\",\"basalt\",\"chalk\",\"diorite\",\"emery\"],resources:{media:[]},capabilities:[\"configurable\"]},homepage:\"https://github.com/pebble/clay#readme\",devDependencies:{autoprefixer:\"^6.3.1\",bourbon:\"^4.2.6\",browserify:\"^13.0.0\",\"browserify-istanbul\":\"^0.2.1\",chai:\"^3.4.1\",deamdify:\"^0.2.0\",deepcopy:\"^0.6.1\",del:\"^2.0.2\",eslint:\"^1.5.1\",\"eslint-config-pebble\":\"^1.2.0\",\"eslint-plugin-standard\":\"^1.3.1\",gulp:\"^3.9.0\",\"gulp-autoprefixer\":\"^3.1.0\",\"gulp-htmlmin\":\"^1.3.0\",\"gulp-inline\":\"0.0.15\",\"gulp-insert\":\"^0.5.0\",\"gulp-sass\":\"^2.1.1\",\"gulp-sourcemaps\":\"^1.6.0\",\"gulp-uglify\":\"^1.5.2\",joi:\"^6.10.1\",karma:\"^0.13.19\",\"karma-browserify\":\"^5.0.1\",\"karma-chrome-launcher\":\"^0.2.2\",\"karma-coverage\":\"^0.5.3\",\"karma-mocha\":\"^0.2.1\",\"karma-mocha-reporter\":\"^1.1.5\",\"karma-source-map-support\":\"^1.1.0\",\"karma-threshold-reporter\":\"^0.1.15\",mocha:\"^2.3.4\",postcss:\"^5.0.14\",\"require-from-string\":\"^1.1.0\",sassify:\"^0.9.1\",sinon:\"^1.17.3\",stringify:\"^3.2.0\",through:\"^2.3.8\",tosource:\"^1.0.0\",\"vinyl-buffer\":\"^1.0.0\",\"vinyl-source-stream\":\"^1.1.0\",watchify:\"^3.7.0\"},dependencies:{}}},{}],8:[function(t,e,n){\"use strict\";e.exports={name:\"button\",template:t(\"../../templates/components/button.tpl\"),style:t(\"../../styles/clay/components/button.scss\"),manipulator:\"button\",defaults:{primary:!1,attributes:{},description:\"\"}}},{\"../../styles/clay/components/button.scss\":21,\"../../templates/components/button.tpl\":30}],9:[function(t,e,n){\"use strict\";e.exports={name:\"checkboxgroup\",template:t(\"../../templates/components/checkboxgroup.tpl\"),style:t(\"../../styles/clay/components/checkboxgroup.scss\"),manipulator:\"checkboxgroup\",defaults:{label:\"\",options:[],description:\"\"}}},{\"../../styles/clay/components/checkboxgroup.scss\":22,\"../../templates/components/checkboxgroup.tpl\":31}],10:[function(t,e,n){\"use strict\";e.exports={name:\"color\",template:t(\"../../templates/components/color.tpl\"),style:t(\"../../styles/clay/components/color.scss\"),manipulator:\"color\",defaults:{label:\"\",description:\"\"},initialize:function(t,e){function n(t){if(\"number\"==typeof t)t=t.toString(16);else if(!t)return\"transparent\";return t=r(t),\"#\"+(f?p[t]:t)}function r(t){for(t=t.toLowerCase();t.length<6;)t=\"0\"+t;return t}function o(t){switch(typeof t){case\"number\":return r(t.toString(16));case\"string\":return t.replace(/^#|^0x/,\"\");default:return t}}function i(t){return t.reduce(function(t,e){return t.concat(e)},[])}function a(t){t=t.replace(/^#|^0x/,\"\");var e=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,r=parseInt(t.slice(4),16)/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;var o=(.4124*e+.3576*n+.1805*r)/.95047,i=(.2126*e+.7152*n+.0722*r)/1,a=(.0193*e+.1192*n+.9505*r)/1.08883;return o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,[116*i-16,500*(o-i),200*(i-a)]}function s(t,e){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.sqrt(Math.pow(n,2)+Math.pow(r,2)+Math.pow(o,2))}function c(){return!e.meta.activeWatchInfo||2===e.meta.activeWatchInfo.firmware.major||[\"aplite\",\"diorite\"].indexOf(e.meta.activeWatchInfo.platform)>-1&&!u.config.allowGray?d.BLACK_WHITE:[\"aplite\",\"diorite\"].indexOf(e.meta.activeWatchInfo.platform)>-1&&u.config.allowGray?d.GRAY:d.COLOR}var l=t.HTML,u=this;u.roundColorToLayout=function(t){var e=o(t);if(m.indexOf(e)===-1){var n=a(e),r=m.map(function(t){var e=a(o(t));return s(n,e)}),i=Math.min.apply(Math,r),c=r.indexOf(i);e=m[c]}return parseInt(e,16)};var f=u.config.sunlight!==!1,p={\"000000\":\"000000\",\"000055\":\"001e41\",\"0000aa\":\"004387\",\"0000ff\":\"0068ca\",\"005500\":\"2b4a2c\",\"005555\":\"27514f\",\"0055aa\":\"16638d\",\"0055ff\":\"007dce\",\"00aa00\":\"5e9860\",\"00aa55\":\"5c9b72\",\"00aaaa\":\"57a5a2\",\"00aaff\":\"4cb4db\",\"00ff00\":\"8ee391\",\"00ff55\":\"8ee69e\",\"00ffaa\":\"8aebc0\",\"00ffff\":\"84f5f1\",550000:\"4a161b\",550055:\"482748\",\"5500aa\":\"40488a\",\"5500ff\":\"2f6bcc\",555500:\"564e36\",555555:\"545454\",\"5555aa\":\"4f6790\",\"5555ff\":\"4180d0\",\"55aa00\":\"759a64\",\"55aa55\":\"759d76\",\"55aaaa\":\"71a6a4\",\"55aaff\":\"69b5dd\",\"55ff00\":\"9ee594\",\"55ff55\":\"9de7a0\",\"55ffaa\":\"9becc2\",\"55ffff\":\"95f6f2\",aa0000:\"99353f\",aa0055:\"983e5a\",aa00aa:\"955694\",aa00ff:\"8f74d2\",aa5500:\"9d5b4d\",aa5555:\"9d6064\",aa55aa:\"9a7099\",aa55ff:\"9587d5\",aaaa00:\"afa072\",aaaa55:\"aea382\",aaaaaa:\"ababab\",ffffff:\"ffffff\",aaaaff:\"a7bae2\",aaff00:\"c9e89d\",aaff55:\"c9eaa7\",aaffaa:\"c7f0c8\",aaffff:\"c3f9f7\",ff0000:\"e35462\",ff0055:\"e25874\",ff00aa:\"e16aa3\",ff00ff:\"de83dc\",ff5500:\"e66e6b\",ff5555:\"e6727c\",ff55aa:\"e37fa7\",ff55ff:\"e194df\",ffaa00:\"f1aa86\",ffaa55:\"f1ad93\",ffaaaa:\"efb5b8\",ffaaff:\"ecc3eb\",ffff00:\"ffeeab\",ffff55:\"fff1b5\",ffffaa:\"fff6d3\"},d={COLOR:[[!1,!1,\"55ff00\",\"aaff55\",!1,\"ffff55\",\"ffffaa\",!1,!1],[!1,\"aaffaa\",\"55ff55\",\"00ff00\",\"aaff00\",\"ffff00\",\"ffaa55\",\"ffaaaa\",!1],[\"55ffaa\",\"00ff55\",\"00aa00\",\"55aa00\",\"aaaa55\",\"aaaa00\",\"ffaa00\",\"ff5500\",\"ff5555\"],[\"aaffff\",\"00ffaa\",\"00aa55\",\"55aa55\",\"005500\",\"555500\",\"aa5500\",\"ff0000\",\"ff0055\"],[!1,\"55aaaa\",\"00aaaa\",\"005555\",\"ffffff\",\"000000\",\"aa5555\",\"aa0000\",!1],[\"55ffff\",\"00ffff\",\"00aaff\",\"0055aa\",\"aaaaaa\",\"555555\",\"550000\",\"aa0055\",\"ff55aa\"],[\"55aaff\",\"0055ff\",\"0000ff\",\"0000aa\",\"000055\",\"550055\",\"aa00aa\",\"ff00aa\",\"ffaaff\"],[!1,\"5555aa\",\"5555ff\",\"5500ff\",\"5500aa\",\"aa00ff\",\"ff00ff\",\"ff55ff\",!1],[!1,!1,!1,\"aaaaff\",\"aa55ff\",\"aa55aa\",!1,!1,!1]],GRAY:[[\"000000\",\"aaaaaa\",\"ffffff\"]],BLACK_WHITE:[[\"000000\",\"ffffff\"]]},h=u.config.layout||c();\"string\"==typeof h&&(h=d[h]),Array.isArray(h[0])||(h=[h]);var m=i(h).map(function(t){return o(t)}).filter(function(t){return t}),g=\"\",b=h.length,y=0;h.forEach(function(t){y=t.length>y?t.length:y});for(var v=100/y,A=100/b,w=u.$element,k=0;k'}var j=0;3===y&&(j=5),2===y&&(j=8);var B=j*v/A+\"%\",S=j+\"%\";w.select(\".color-box-container\").add(l(g)).set(\"$paddingTop\",B).set(\"$paddingRight\",S).set(\"$paddingBottom\",B).set(\"$paddingLeft\",S),w.select(\".color-box-wrap\").set(\"$paddingBottom\",v/A*100+\"%\");var D=w.select(\".value\"),N=w.select(\".picker-wrap\"),Y=u.$manipulatorTarget.get(\"disabled\");w.select(\"label\").on(\"click\",function(){Y||N.set(\"show\")}),u.on(\"change\",function(){var t=u.get();D.set(\"$background-color\",n(t)),w.select(\".color-box\").set(\"-selected\"),w.select('.color-box[data-value=\"'+t+'\"]').set(\"+selected\")}),w.select(\".color-box.selectable\").on(\"click\",function(t){u.set(parseInt(t.target.dataset.value,10)),N.set(\"-show\")}),N.on(\"click\",function(){N.set(\"-show\")}),u.on(\"disabled\",function(){Y=!0}),u.on(\"enabled\",function(){Y=!1}),u._layout=h}}},{\"../../styles/clay/components/color.scss\":23,\"../../templates/components/color.tpl\":32}],11:[function(t,e,n){\"use strict\";e.exports={name:\"footer\",template:t(\"../../templates/components/footer.tpl\"),manipulator:\"html\"}},{\"../../templates/components/footer.tpl\":33}],12:[function(t,e,n){\"use strict\";e.exports={name:\"heading\",template:t(\"../../templates/components/heading.tpl\"),manipulator:\"html\",defaults:{size:4}}},{\"../../templates/components/heading.tpl\":34}],13:[function(t,e,n){\"use strict\";e.exports={color:t(\"./color\"),footer:t(\"./footer\"),heading:t(\"./heading\"),input:t(\"./input\"),select:t(\"./select\"),submit:t(\"./submit\"),text:t(\"./text\"),toggle:t(\"./toggle\"),radiogroup:t(\"./radiogroup\"),checkboxgroup:t(\"./checkboxgroup\"),button:t(\"./button\"),slider:t(\"./slider\")}},{\"./button\":8,\"./checkboxgroup\":9,\"./color\":10,\"./footer\":11,\"./heading\":12,\"./input\":14,\"./radiogroup\":15,\"./select\":16,\"./slider\":17,\"./submit\":18,\"./text\":19,\"./toggle\":20}],14:[function(t,e,n){\"use strict\";e.exports={name:\"input\",template:t(\"../../templates/components/input.tpl\"),style:t(\"../../styles/clay/components/input.scss\"),manipulator:\"val\",defaults:{label:\"\",description:\"\",attributes:{}}}},{\"../../styles/clay/components/input.scss\":24,\"../../templates/components/input.tpl\":35}],15:[function(t,e,n){\"use strict\";e.exports={name:\"radiogroup\",template:t(\"../../templates/components/radiogroup.tpl\"),style:t(\"../../styles/clay/components/radiogroup.scss\"),manipulator:\"radiogroup\",defaults:{label:\"\",options:[],description:\"\",attributes:{}}}},{\"../../styles/clay/components/radiogroup.scss\":25,\"../../templates/components/radiogroup.tpl\":36}],16:[function(t,e,n){\"use strict\";e.exports={name:\"select\",template:t(\"../../templates/components/select.tpl\"),style:t(\"../../styles/clay/components/select.scss\"),manipulator:\"val\",defaults:{label:\"\",options:[],description:\"\",attributes:{}},initialize:function(){function t(){var t=e.$manipulatorTarget.get(\"selectedIndex\"),r=e.$manipulatorTarget.select(\"option\"),o=r[t]&&r[t].innerHTML;n.set(\"innerHTML\",o)}var e=this,n=e.$element.select(\".value\");t(),e.on(\"change\",t)}}},{\"../../styles/clay/components/select.scss\":26,\"../../templates/components/select.tpl\":37}],17:[function(t,e,n){\"use strict\";e.exports={name:\"slider\",template:t(\"../../templates/components/slider.tpl\"),style:t(\"../../styles/clay/components/slider.scss\"),manipulator:\"slider\",defaults:{label:\"\",description:\"\",min:0,max:100,step:1,attributes:{}},initialize:function(){function t(){var t=e.get().toFixed(e.precision);n.set(\"value\",t),r.set(\"innerHTML\",t)}var e=this,n=e.$element.select(\".value\"),r=e.$element.select(\".value-pad\"),o=e.$manipulatorTarget,i=o.get(\"step\");i=i.toString(10).split(\".\")[1],e.precision=i?i.length:0,e.on(\"change\",t),o.on(\"|input\",t),t(),n.on(\"|input\",function(){r.set(\"innerHTML\",this.get(\"value\"))}),n.on(\"|change\",function(){e.set(this.get(\"value\")),t()})}}},{\"../../styles/clay/components/slider.scss\":27,\"../../templates/components/slider.tpl\":38}],18:[function(t,e,n){\"use strict\";e.exports={name:\"submit\",template:t(\"../../templates/components/submit.tpl\"),style:t(\"../../styles/clay/components/submit.scss\"),manipulator:\"button\",defaults:{attributes:{}}}},{\"../../styles/clay/components/submit.scss\":28,\"../../templates/components/submit.tpl\":39}],19:[function(t,e,n){\"use strict\";e.exports={name:\"text\",template:t(\"../../templates/components/text.tpl\"),manipulator:\"html\"}},{\"../../templates/components/text.tpl\":40}],20:[function(t,e,n){\"use strict\";e.exports={name:\"toggle\",template:t(\"../../templates/components/toggle.tpl\"),style:t(\"../../styles/clay/components/toggle.scss\"),manipulator:\"checked\",defaults:{label:\"\",description:\"\",attributes:{}}}},{\"../../styles/clay/components/toggle.scss\":29,\"../../templates/components/toggle.tpl\":41}],21:[function(t,e,n){e.exports=\".component-button { text-align: center; }\\n\\n.section .component-button { padding-bottom: 0; }\\n\\n.component-button .description { padding-left: 0; padding-right: 0; }\\n\"},{}],22:[function(t,e,n){e.exports=\".component-checkbox { display: block; }\\n\\n.section .component-checkbox { padding-right: 0.375rem; }\\n\\n.component-checkbox > .label { display: block; padding-bottom: 0.35rem; }\\n\\n.component-checkbox .checkbox-group { padding-bottom: 0.35rem; }\\n\\n.component-checkbox .checkbox-group label { padding: 0.35rem 0.375rem; }\\n\\n.component-checkbox .checkbox-group .label { font-size: 0.9em; }\\n\\n.component-checkbox .checkbox-group input { opacity: 0; position: absolute; }\\n\\n.component-checkbox .checkbox-group i { display: block; position: relative; border-radius: 0.25rem; width: 1.4rem; height: 1.4rem; border: 0.11765rem solid #767676; -webkit-flex-shrink: 0; flex-shrink: 0; }\\n\\n.component-checkbox .checkbox-group input:checked + i { border-color: #ff4700; background: #ff4700; }\\n\\n.component-checkbox .checkbox-group input:checked + i:after { content: ''; box-sizing: border-box; -webkit-transform: rotate(45deg); transform: rotate(45deg); position: absolute; left: 0.35rem; top: -0.05rem; display: block; width: 0.5rem; height: 1rem; border: 0 solid #ffffff; border-right-width: 0.11765rem; border-bottom-width: 0.11765rem; }\\n\\n.component-checkbox .description { padding-left: 0; padding-right: 0; }\\n\"},{}],23:[function(t,e,n){e.exports=\".section .component-color { padding: 0; }\\n\\n.component-color .value { width: 2.2652rem; height: 1.4rem; border-radius: 0.7rem; box-shadow: 0 0.1rem 0.1rem #2f2f2f; display: block; background: #000; }\\n\\n.component-color .picker-wrap { left: 0; top: 0; right: 0; bottom: 0; position: fixed; padding: 0.7rem 0.375rem; background: rgba(0, 0, 0, 0.65); opacity: 0; -webkit-transition: opacity 100ms ease-in 175ms; transition: opacity 100ms ease-in 175ms; pointer-events: none; z-index: 100; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; flex-direction: column; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }\\n\\n.component-color .picker-wrap .picker { padding: 0.7rem 0.75rem; background: #484848; box-shadow: 0 0.17647rem 0.88235rem rgba(0, 0, 0, 0.4); border-radius: 0.25rem; width: 100%; max-width: 26rem; overflow: auto; }\\n\\n.component-color .picker-wrap.show { -webkit-transition-delay: 0ms; transition-delay: 0ms; pointer-events: auto; opacity: 1; }\\n\\n.component-color .color-box-wrap { box-sizing: border-box; position: relative; height: 0; width: 100%; padding: 0 0 100% 0; }\\n\\n.component-color .color-box-wrap .color-box-container { position: absolute; height: 99.97%; width: 100%; left: 0; top: 0; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box { float: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box.rounded-tl { border-top-left-radius: 0.25rem; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box.rounded-tr { border-top-right-radius: 0.25rem; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box.rounded-bl { border-bottom-left-radius: 0.25rem; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box.rounded-br { border-bottom-right-radius: 0.25rem; }\\n\\n.component-color .color-box-wrap .color-box-container .color-box.selected { -webkit-transform: scale(1.1); transform: scale(1.1); border-radius: 0.25rem; box-shadow: #111 0 0 0.24rem; position: relative; z-index: 100; }\\n\"},{}],24:[function(t,e,n){e.exports=\".section .component-input { padding: 0; }\\n\\n.component-input label { display: block; }\\n\\n.component-input .label { padding-bottom: 0.7rem; }\\n\\n.component-input .input { position: relative; min-width: 100%; margin-top: 0.7rem; margin-left: 0; }\\n\\n.component-input input { display: block; width: 100%; background: #333333; border-radius: 0.25rem; padding: 0.35rem 0.375rem; border: none; vertical-align: baseline; color: #ffffff; font-size: inherit; -webkit-appearance: none; appearance: none; min-height: 2.1rem; }\\n\\n.component-input input::-webkit-input-placeholder { color: #858585; }\\n\\n.component-input input::-moz-placeholder { color: #858585; }\\n\\n.component-input input:-moz-placeholder { color: #858585; }\\n\\n.component-input input:-ms-input-placeholder { color: #858585; }\\n\\n.component-input input:focus { border: none; box-shadow: none; }\\n\\n.component-input input:focus::-webkit-input-placeholder { color: #666666; }\\n\\n.component-input input:focus::-moz-placeholder { color: #666666; }\\n\\n.component-input input:focus:-moz-placeholder { color: #666666; }\\n\\n.component-input input:focus:-ms-input-placeholder { color: #666666; }\\n\"},{}],25:[function(t,e,n){e.exports=\".component-radio { display: block; }\\n\\n.section .component-radio { padding-right: 0.375rem; }\\n\\n.component-radio > .label { display: block; padding-bottom: 0.35rem; }\\n\\n.component-radio .radio-group { padding-bottom: 0.35rem; }\\n\\n.component-radio .radio-group label { padding: 0.35rem 0.375rem; }\\n\\n.component-radio .radio-group .label { font-size: 0.9em; }\\n\\n.component-radio .radio-group input { opacity: 0; position: absolute; }\\n\\n.component-radio .radio-group i { display: block; position: relative; border-radius: 1.4rem; width: 1.4rem; height: 1.4rem; border: 2px solid #767676; -webkit-flex-shrink: 0; flex-shrink: 0; }\\n\\n.component-radio .radio-group input:checked + i { border-color: #ff4700; }\\n\\n.component-radio .radio-group input:checked + i:after { content: ''; display: block; position: absolute; left: 15%; right: 15%; top: 15%; bottom: 15%; border-radius: 1.4rem; background: #ff4700; }\\n\\n.component-radio .description { padding-left: 0; padding-right: 0; }\\n\"},{}],26:[function(t,e,n){e.exports='.section .component-select { padding: 0; }\\n\\n.component-select label { position: relative; }\\n\\n.component-select .value { position: relative; padding-right: 1.1rem; display: block; }\\n\\n.component-select .value:after { content: \"\"; position: absolute; right: 0; top: 50%; margin-top: -0.1rem; height: 0; width: 0; border-left: 0.425rem solid transparent; border-right: 0.425rem solid transparent; border-top: 0.425rem solid #ff4700; }\\n\\n.component-select select { opacity: 0; position: absolute; display: block; left: 0; right: 0; top: 0; bottom: 0; width: 100%; border: none; margin: 0; padding: 0; }\\n'},{}],27:[function(t,e,n){e.exports=\".section .component-slider { padding: 0; }\\n\\n.component-slider label { display: block; }\\n\\n.component-slider .label-container { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; width: 100%; padding-bottom: 0.7rem; }\\n\\n.component-slider .label { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; min-width: 1rem; display: block; padding-right: 0.75rem; }\\n\\n.component-slider .value-wrap { display: block; position: relative; }\\n\\n.component-slider .value, .component-slider .value-pad { display: block; background: #333333; border-radius: 0.25rem; padding: 0.35rem 0.375rem; border: none; vertical-align: baseline; color: #ffffff; text-align: right; margin: 0; min-width: 1rem; }\\n\\n.component-slider .value-pad { visibility: hidden; }\\n\\n.component-slider .value-pad:before { content: ' '; display: inline-block; }\\n\\n.component-slider .value { max-width: 100%; position: absolute; left: 0; top: 0; }\\n\\n.component-slider .input-wrap { padding: 0 0.75rem 0.7rem; }\\n\\n.component-slider .input { display: block; position: relative; min-width: 100%; height: 1.4rem; overflow: hidden; margin-left: 0; }\\n\\n.component-slider .input:before { content: ''; display: block; position: absolute; height: 0.17647rem; background: #666666; width: 100%; top: 0.61176rem; }\\n\\n.component-slider .input .slider { display: block; width: 100%; -webkit-appearance: none; appearance: none; position: relative; height: 1.4rem; margin: 0; background-color: transparent; }\\n\\n.component-slider .input .slider:focus { outline: none; }\\n\\n.component-slider .input .slider::-webkit-slider-runnable-track { border: none; height: 1.4rem; width: 100%; background-color: transparent; }\\n\\n.component-slider .input .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; position: relative; height: 1.4rem; width: 1.4rem; background-color: #ff4700; border-radius: 50%; }\\n\\n.component-slider .input .slider::-webkit-slider-thumb:before { content: \\\"\\\"; position: absolute; left: -1000px; top: 0.61176rem; height: 0.17647rem; width: 1001px; background: #ff4700; }\\n\"},{}],28:[function(t,e,n){e.exports=\".component-submit { text-align: center; }\\n\"},{}],29:[function(t,e,n){e.exports=\".section .component-toggle { padding: 0; }\\n\\n.component-toggle input { display: none; }\\n\\n.component-toggle .graphic { display: inline-block; position: relative; }\\n\\n.component-toggle .graphic .slide { display: block; border-radius: 1.05rem; height: 1.05rem; width: 2.2652rem; background: #2f2f2f; -webkit-transition: background-color 150ms linear; transition: background-color 150ms linear; }\\n\\n.component-toggle .graphic .marker { background: #ececec; width: 1.4rem; height: 1.4rem; border-radius: 1.4rem; position: absolute; left: 0; display: block; top: -0.175rem; -webkit-transition: -webkit-transform 150ms linear; transition: -webkit-transform 150ms linear; transition: transform 150ms linear; transition: transform 150ms linear, -webkit-transform 150ms linear; box-shadow: 0 0.1rem 0.1rem #2f2f2f; }\\n\\n.component-toggle input:checked + .graphic .slide { background: #993d19; }\\n\\n.component-toggle input:checked + .graphic .marker { background: #ff4700; -webkit-transform: translateX(0.8652rem); transform: translateX(0.8652rem); }\\n\"},{}],30:[function(t,e,n){e.exports='
\\n \\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],31:[function(t,e,n){e.exports='
\\n {{{label}}}\\n
\\n {{each options}}\\n \\n {{/each}}\\n
\\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],32:[function(t,e,n){e.exports='
\\n \\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n'},{}],33:[function(t,e,n){e.exports='
\\n'},{}],34:[function(t,e,n){e.exports='
\\n \\n
\\n'},{}],35:[function(t,e,n){e.exports='
\\n \\n\\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],36:[function(t,e,n){e.exports='
\\n {{{label}}}\\n
\\n {{each options}}\\n \\n {{/each}}\\n
\\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],37:[function(t,e,n){e.exports='
\\n \\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],38:[function(t,e,n){e.exports='
\\n \\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],39:[function(t,e,n){e.exports='
\\n \\n
\\n'},{}],40:[function(t,e,n){e.exports='
\\n

\\n
\\n'},{}],41:[function(t,e,n){e.exports='
\\n \\n {{if description}}\\n
{{{description}}}
\\n {{/if}}\\n
\\n'},{}],42:[function(t,e,n){e.exports='
';\n},{}],\"pebble-clay\":[function(t,e,n){\"use strict\";function r(t,e,n){function r(){i.meta={activeWatchInfo:Pebble.getActiveWatchInfo&&Pebble.getActiveWatchInfo(),accountToken:Pebble.getAccountToken(),watchToken:Pebble.getWatchToken(),userData:s(n.userData||{})}}function o(t,e,n){Array.isArray(t)?t.forEach(function(t){o(t,e,n)}):\"section\"===t.type?o(t.items,e,n):e(t)&&n(t)}var i=this;if(!Array.isArray(t))throw new Error(\"config must be an Array\");if(e&&\"function\"!=typeof e)throw new Error('customFn must be a function or \"null\"');n=n||{},i.config=s(t),i.customFn=e||function(){},i.components={},i.meta={activeWatchInfo:null,accountToken:\"\",watchToken:\"\",userData:{}},i.version=c,n.autoHandleEvents!==!1&&\"undefined\"!=typeof Pebble?(Pebble.addEventListener(\"showConfiguration\",function(){r(),Pebble.openURL(i.generateUrl())}),Pebble.addEventListener(\"webviewclosed\",function(t){t&&t.response&&Pebble.sendAppMessage(i.getSettings(t.response),function(){console.log(\"Sent config data to Pebble\")},function(t){console.log(\"Failed to send config data!\"),console.log(JSON.stringify(t))})})):\"undefined\"!=typeof Pebble&&Pebble.addEventListener(\"ready\",function(){r()}),o(i.config,function(t){return a[t.type]},function(t){i.registerComponent(a[t.type])}),o(i.config,function(t){return t.appKey},function(){throw new Error(\"appKeys are no longer supported. Please follow the migration guide to upgrade your project\")})}var o=t(\"./tmp/config-page.html\"),i=t(\"tosource\"),a=t(\"./src/scripts/components\"),s=t(\"deepcopy/build/deepcopy.min\"),c=t(\"./package.json\").version,l=t(\"message_keys\");r.prototype.registerComponent=function(t){this.components[t.name]=t},r.prototype.generateUrl=function(){var t={},e=!Pebble||\"pypkjs\"===Pebble.platform,n=e?\"$$$RETURN_TO$$$\":\"pebblejs://close#\";try{t=JSON.parse(localStorage.getItem(\"clay-settings\"))||{}}catch(a){console.error(a.toString())}var s=o.replace(\"$$RETURN_TO$$\",n).replace(\"$$CUSTOM_FN$$\",i(this.customFn)).replace(\"$$CONFIG$$\",i(this.config)).replace(\"$$SETTINGS$$\",i(t)).replace(\"$$COMPONENTS$$\",i(this.components)).replace(\"$$META$$\",i(this.meta));return e?r.encodeDataUri(s,\"http://clay.pebble.com.s3-website-us-west-2.amazonaws.com/#\"):r.encodeDataUri(s)},r.prototype.getSettings=function(t,e){var n={};t=t.match(/^\\{/)?t:decodeURIComponent(t);try{n=JSON.parse(t)}catch(o){throw new Error(\"The provided response was not valid JSON\")}var i={};return Object.keys(n).forEach(function(t){\"object\"==typeof n[t]&&n[t]?i[t]=n[t].value:i[t]=n[t]}),localStorage.setItem(\"clay-settings\",JSON.stringify(i)),e===!1?n:r.prepareSettingsForAppMessage(n)},r.prototype.setSettings=function(t,e){var n={};try{n=JSON.parse(localStorage.getItem(\"clay-settings\"))||{}}catch(r){console.error(r.toString())}if(\"object\"==typeof t){var o=t;Object.keys(o).forEach(function(t){n[t]=o[t]})}else n[t]=e;localStorage.setItem(\"clay-settings\",JSON.stringify(n))},r.encodeDataUri=function(t,e){return e=\"undefined\"!=typeof e?e:\"data:text/html;charset=utf-8,\",e+encodeURIComponent(t)},r.prepareForAppMessage=function(t){function e(t,e){return Math.floor(t*Math.pow(10,e||0))}var n;return Array.isArray(t)?(n=[],t.forEach(function(t,e){n[e]=r.prepareForAppMessage(t)})):n=\"object\"==typeof t&&t?\"number\"==typeof t.value?e(t.value,t.precision):Array.isArray(t.value)?t.value.map(function(n){return\"number\"==typeof n?e(n,t.precision):n}):r.prepareForAppMessage(t.value):\"boolean\"==typeof t?t?1:0:t,n},r.prepareSettingsForAppMessage=function(t){var e={};Object.keys(t).forEach(function(n){var r=t[n],o=n.match(/(.+?)(?:\\[(\\d*)\\])?$/);if(!o[2])return void(e[n]=r);var i=parseInt(o[2],10);n=o[1],\"undefined\"==typeof e[n]&&(e[n]=[]),e[n][i]=r});var n={};return Object.keys(e).forEach(function(t){var o=l[t],i=r.prepareForAppMessage(e[t]);i=Array.isArray(i)?i:[i],i.forEach(function(t,e){n[o+e]=t})}),Object.keys(n).forEach(function(t){if(Array.isArray(n[t]))throw new Error('Clay does not support 2 dimensional arrays for item values. Make sure you are not attempting to use array syntax (eg: \"myMessageKey[2]\") in the messageKey for components that return an array, such as a checkboxgroup')}),n},e.exports=r},{\"./package.json\":7,\"./src/scripts/components\":13,\"./tmp/config-page.html\":42,\"deepcopy/build/deepcopy.min\":3,message_keys:void 0,tosource:6}]},{},[\"pebble-clay\"])(\"pebble-clay\")});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/pebble-clay/dist/js/index.js\n// module id = 3\n// module chunks = 0","module.exports = function(module) {\n switch(module) {\n case \"message_keys\": return require(\"message_keys\");\n }\n throw new Error('Module not found: ' + module);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/louis/.pebble-sdk/SDKs/4.3/sdk-core/pebble/common/include/_message_key_wrapper.js\n// module id = 4\n// module chunks = 0","module.exports = {\"JSReady\":10005,\"auth\":10000,\"password\":10004,\"server\":10002,\"status\":10001,\"username\":10003}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./build/js/message_keys.json\n// module id = 5\n// module chunks = 0","module.exports = [\n {\n \"type\": \"heading\",\n \"defaultValue\": \"DSCam Home Swtich Configuration\"\n },\n {\n \"type\": \"text\",\n \"defaultValue\": \"Set your Synology account and server.\"\n },\n {\n \"type\": \"section\",\n \"items\":\n [\n {\n \"type\": \"heading\",\n \"defaultValue\": \"Your synology account\"\n }, {\n \"type\": \"input\",\n \"messageKey\": \"server\",\n \"label\": \"Your DSM Server\",\n \"attributes\":\n {\n \"type\": \"url\",\n \"maxlength\": 255\n }\n },\n {\n \"type\": \"input\",\n \"messageKey\": \"username\",\n \"label\": \"Your DSM Username\",\n \"attributes\":\n {\n \"maxlength\":40\n }\n },\n {\n \"type\": \"input\",\n \"messageKey\": \"password\",\n \"label\": \"Your DSM Password\",\n \"attributes\":\n {\n \"type\": \"password\",\n \"maxlength\":40\n }\n },\n {\n \"type\": \"toggle\",\n \"messageKey\": \"OTP_enabled\",\n \"label\": \"toggle on if 2FA enabled on user\"\n },\n {\n \"type\": \"input\",\n \"messageKey\": \"OTP_seed\",\n \"label\": \"seed provided by DSM for the user\"\n }\n ]\n },\n {\n \"type\": \"submit\",\n \"defaultValue\": \"Save Settings\"\n }\n];\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pkjs/config.js\n// module id = 6\n// module chunks = 0","/*\n A JavaScript implementation of the SHA family of hashes, as\n defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding\n HMAC implementation as defined in FIPS PUB 198a\n\n Copyright Brian Turek 2008-2017\n Distributed under the BSD License\n See http://caligatio.github.com/jsSHA/ for more information\n\n Several functions taken from Paul Johnston\n*/\n'use strict';(function(Y){function C(c,a,b){var e=0,h=[],n=0,g,l,d,f,m,q,u,r,I=!1,v=[],w=[],t,y=!1,z=!1,x=-1;b=b||{};g=b.encoding||\"UTF8\";t=b.numRounds||1;if(t!==parseInt(t,10)||1>t)throw Error(\"numRounds must a integer >= 1\");if(\"SHA-1\"===c)m=512,q=K,u=Z,f=160,r=function(a){return a.slice()};else if(0===c.lastIndexOf(\"SHA-\",0))if(q=function(a,b){return L(a,b,c)},u=function(a,b,h,e){var k,f;if(\"SHA-224\"===c||\"SHA-256\"===c)k=(b+65>>>9<<4)+15,f=16;else if(\"SHA-384\"===c||\"SHA-512\"===c)k=(b+129>>>10<<\n5)+31,f=32;else throw Error(\"Unexpected error in SHA-2 implementation\");for(;a.length<=k;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+h;a[k]=b&4294967295;a[k-1]=b/4294967296|0;h=a.length;for(b=0;be;e+=1)c[e]=a[e].slice();return c};x=1;if(\"SHA3-224\"===\nc)m=1152,f=224;else if(\"SHA3-256\"===c)m=1088,f=256;else if(\"SHA3-384\"===c)m=832,f=384;else if(\"SHA3-512\"===c)m=576,f=512;else if(\"SHAKE128\"===c)m=1344,f=-1,F=31,z=!0;else if(\"SHAKE256\"===c)m=1088,f=-1,F=31,z=!0;else throw Error(\"Chosen SHA variant is not supported\");u=function(a,c,e,b,h){e=m;var k=F,f,g=[],n=e>>>5,l=0,d=c>>>5;for(f=0;f=e;f+=n)b=D(a.slice(f,f+n),b),c-=e;a=a.slice(f);for(c%=e;a.length>>3;a[f>>2]^=k<=h)break;g.push(a.a);l+=1;0===64*l%e&&D(null,b)}return g}}else throw Error(\"Chosen SHA variant is not supported\");d=M(a,g,x);l=A(c);this.setHMACKey=function(a,b,h){var k;if(!0===I)throw Error(\"HMAC key already set\");if(!0===y)throw Error(\"Cannot set HMAC key after calling update\");if(!0===z)throw Error(\"SHAKE is not supported for HMAC\");g=(h||{}).encoding||\"UTF8\";b=M(b,g,x)(a);a=b.binLen;b=b.value;k=m>>>3;h=k/4-1;if(k
a/8){for(;b.length<=h;)b.push(0);b[h]&=4294967040}for(a=0;a<=h;a+=1)v[a]=b[a]^909522486,w[a]=b[a]^1549556828;l=q(v,l);e=m;I=!0};this.update=function(a){var c,b,k,f=0,g=m>>>5;c=d(a,h,n);a=c.binLen;b=c.value;c=a>>>5;for(k=0;k>>5);n=a%m;y=!0};this.getHash=function(a,b){var k,g,d,m;if(!0===I)throw Error(\"Cannot call getHash after setting HMAC key\");d=N(b);if(!0===z){if(-1===d.shakeLen)throw Error(\"shakeLen must be specified in options\");\nf=d.shakeLen}switch(a){case \"HEX\":k=function(a){return O(a,f,x,d)};break;case \"B64\":k=function(a){return P(a,f,x,d)};break;case \"BYTES\":k=function(a){return Q(a,f,x)};break;case \"ARRAYBUFFER\":try{g=new ArrayBuffer(0)}catch(p){throw Error(\"ARRAYBUFFER not supported by this environment\");}k=function(a){return R(a,f,x)};break;default:throw Error(\"format must be HEX, B64, BYTES, or ARRAYBUFFER\");}m=u(h.slice(),n,e,r(l),f);for(g=1;g>>24-f%32),m=u(m,f,\n0,A(c),f);return k(m)};this.getHMAC=function(a,b){var k,g,d,p;if(!1===I)throw Error(\"Cannot call getHMAC without first setting HMAC key\");d=N(b);switch(a){case \"HEX\":k=function(a){return O(a,f,x,d)};break;case \"B64\":k=function(a){return P(a,f,x,d)};break;case \"BYTES\":k=function(a){return Q(a,f,x)};break;case \"ARRAYBUFFER\":try{k=new ArrayBuffer(0)}catch(v){throw Error(\"ARRAYBUFFER not supported by this environment\");}k=function(a){return R(a,f,x)};break;default:throw Error(\"outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER\");\n}g=u(h.slice(),n,e,r(l),f);p=q(w,A(c));p=u(g,f,m,p,f);return k(p)}}function b(c,a){this.a=c;this.b=a}function O(c,a,b,e){var h=\"\";a/=8;var n,g,d;d=-1===b?3:0;for(n=0;n>>2]>>>8*(d+n%4*b),h+=\"0123456789abcdef\".charAt(g>>>4&15)+\"0123456789abcdef\".charAt(g&15);return e.outputUpper?h.toUpperCase():h}function P(c,a,b,e){var h=\"\",n=a/8,g,d,p,f;f=-1===b?3:0;for(g=0;g>>2]:0,p=g+2>>2]:0,p=(c[g>>>2]>>>8*(f+g%4*b)&255)<<16|(d>>>8*(f+(g+1)%4*b)&255)<<8|p>>>8*(f+\n(g+2)%4*b)&255,d=0;4>d;d+=1)8*g+6*d<=a?h+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".charAt(p>>>6*(3-d)&63):h+=e.b64Pad;return h}function Q(c,a,b){var e=\"\";a/=8;var h,d,g;g=-1===b?3:0;for(h=0;h>>2]>>>8*(g+h%4*b)&255,e+=String.fromCharCode(d);return e}function R(c,a,b){a/=8;var e,h=new ArrayBuffer(a),d,g;g=new Uint8Array(h);d=-1===b?3:0;for(e=0;e>>2]>>>8*(d+e%4*b)&255;return h}function N(c){var a={outputUpper:!1,b64Pad:\"=\",shakeLen:-1};c=c||{};\na.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty(\"b64Pad\")&&(a.b64Pad=c.b64Pad);if(!0===c.hasOwnProperty(\"shakeLen\")){if(0!==c.shakeLen%8)throw Error(\"shakeLen must be a multiple of 8\");a.shakeLen=c.shakeLen}if(\"boolean\"!==typeof a.outputUpper)throw Error(\"Invalid outputUpper formatting option\");if(\"string\"!==typeof a.b64Pad)throw Error(\"Invalid b64Pad formatting option\");return a}function M(c,a,b){switch(a){case \"UTF8\":case \"UTF16BE\":case \"UTF16LE\":break;default:throw Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\");\n}switch(c){case \"HEX\":c=function(a,c,d){var g=a.length,l,p,f,m,q,u;if(0!==g%2)throw Error(\"String of HEX type must be in byte increments\");c=c||[0];d=d||0;q=d>>>3;u=-1===b?3:0;for(l=0;l>>1)+q;for(f=m>>>2;c.length<=f;)c.push(0);c[f]|=p<<8*(u+m%4*b)}return{value:c,binLen:4*g+d}};break;case \"TEXT\":c=function(c,h,d){var g,l,p=0,f,m,q,u,r,t;h=h||[0];d=d||0;q=d>>>3;if(\"UTF8\"===a)for(t=-1===\nb?3:0,f=0;fg?l.push(g):2048>g?(l.push(192|g>>>6),l.push(128|g&63)):55296>g||57344<=g?l.push(224|g>>>12,128|g>>>6&63,128|g&63):(f+=1,g=65536+((g&1023)<<10|c.charCodeAt(f)&1023),l.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),m=0;m>>2;h.length<=u;)h.push(0);h[u]|=l[m]<<8*(t+r%4*b);p+=1}else if(\"UTF16BE\"===a||\"UTF16LE\"===a)for(t=-1===b?2:0,l=\"UTF16LE\"===a&&1!==b||\"UTF16LE\"!==a&&1===b,f=0;f>>8);r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=g<<8*(t+r%4*b);p+=2}return{value:h,binLen:8*p+d}};break;case \"B64\":c=function(a,c,d){var g=0,l,p,f,m,q,u,r,t;if(-1===a.search(/^[a-zA-Z0-9=+\\/]+$/))throw Error(\"Invalid character in base-64 string\");p=a.indexOf(\"=\");a=a.replace(/\\=/g,\"\");if(-1!==p&&p  ԿI yD"𮼨 I yDI yDI yD@3fF LJ|DzD"``8IKyD "{D#hIKd yD"{DKI{DhyD I KyD "{DX l Y d  p d FйJKzD{D`8IKyD "{D K I{DhyDr I KyD "{D`A d D FйJKzD{D`X8IKyD t"{D K I{DhyD6 I KyD z"{D$ J M  x l pF F)F:0"; 0"# 0! ` ho?H&hxDF0F hF(F hFhF` h>` hmF!p@ѻ! RFйJKzD{D`L8IKyD "{DKI{DhyDIKyD "{D K I{DhyD. 1 P IssNsK~DF1F{D "m F0nKoM{D`nK}DX FhqhkK"{DpiK 1FOr{DPfK FXh\FcN1~D<"0FaK1F{DhC_I0FyD\I\K yD@{DZIZK yD@{D"WK FXh.FpTN1~D("0FmRK1F{DhPI0FyDVwLI0FyDMbII0FyDD_FIFK yDOr{DDIDK yDOr{DAK FXhF>N1~D("0F-;I;K yDOr{D8K FXhF5N1~D("0F1I2K yD@3{D.K FXhF+L1|D" F(I(K yDOr{D|b_4 * $ / . !* 'X8HE w &  -O@ FEHxDHDxDHxDHxDF!F0FN p;vJDzD` 3sKsM{D` +}D!h(`(hh! (h!(h bK  {D`F)FPFOs0(Fd)F FD?(F!F&p FO p FAF FF FDQFCIyDAJzDR;ph(Fv8M9I}DyD(`7H.hxDF0F~!(h(hkF F/L|D(h!! h ~(KY0`F);%I yD#I$KyDOr {DME(h8K{Dh!K{Dhd h  ` t t@ 8I|IIII0ITIII|(Iv8IpDIjdIdhI^lIXIRILIFI@,I:4I48I.<I(@I"LIXI|II IIIIIIIIںIԺIκIȺIºI8I<IDILIPI\I`IdII0I4Iz@It InP main.cMessage send failed. Reason: %dMessage sent. Message dropped. Reason: %d%H:%M%I:%Mhome_offError sending the outbox: %dSending to the outbox: %sSent...Error preparing the outbox: %dhome_ongetRESOURCE_ID_GOTHIC_18_BOLDauthAuthenticating...New message! received jsready message on watch... Authentication failedAuth message received ... not auth message... Home mode is ON (camera is off)Home mode is OFF (camera is on)Time out too many times, verify settingsstatus message received ... not status message... new username in settings... %snew password in settings... %snew server in settings... %sWelcome to Syno Cam Switch !RESOURCE_ID_GOTHIC_24_BOLDJust pushed a window!''''''PKV4YJJaplite/app_resources.pbpackb@prDUrDVD>VaD>??>~>>|0 0p0000000??0 0pÀ34 120000??PKXW5{Xooaplite/manifest.json{"manifestVersion": 2, "generatedBy": "DESKTOP-PSQDLD8", "generatedAt": 1703325903, "application": {"timestamp": 1703325901, "sdk_version": {"major": 5, "minor": 78}, "crc": 2812611548, "name": "pebble-app.bin", "size": 3836}, "debug": {}, "type": "application", "resources": {"timestamp": 1703325901, "crc": 2818326884, "name": "app_resources.pbpack", "size": 4426}}PKVhy appinfo.jsonPKXW