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,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,UAAY,WAC9B,MAAM,EAAiB,KAAK,sBAAsB,mBAElD,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,UAAY,SAAU,GACxC,MAAM,EAAiB,KAAK,eAAe,WAAY,CACrD,OAAU,IAGZ,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,YAAc,WAChC,MAAM,EAAiB,KAAK,sBAAsB,wBAElD,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,eAAiB,WACnC,MAAM,EAAiB,KAAK,sBAAsB,kCAElD,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,iBAAmB,WACrC,MAAM,EAAiB,KAAK,sBAAsB,uBAElD,OAAO,KAAK,UAAU,EACxB,EAEA,UAAU,UAAU,SAAW,WAC7B,MAAM,EAAiB,KAAK,eAAe,aAE3C,OAAO,KAAK,UAAU,EACxB","file":"/npm/nanoleaf-aurora-client@1.2.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/nanoleaf-aurora-client@1.2.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst fs = require('fs'),\n  http   = require('http');\n\nvar AuroraApi = module.exports = function (options) {\n  var self = this;\n\n  if (!options) {\n    throw new Error('Missing options');\n  }\n\n  if (!options.host) {\n    throw new Error('Missing \\'host\\' property');\n  }\n\n  if (!options.base) {\n    throw new Error('Missing \\'base\\' property');\n  }\n\n  if (!options.accessToken) {\n    throw new Error('Missing \\'accessToken\\' property');\n  }\n\n  this.protocol    = options.protocol || 'http:';\n  this.host        = options.host;\n  this.port        = options.port || null;\n  this.base        = options.base;\n  this.accessToken = options.accessToken;\n  this.timeout     = options.timeout || 2000;\n\n  this.makeOptions = function (pathname, method) {\n    var options = {\n      protocol: this.protocol,\n      hostname: this.host,\n      port: this.port,\n      path: `${this.base}${this.accessToken}${pathname}`,\n      method: method\n    };\n\n    return options;\n  };\n\n  this.makeGetRequestOptions = function (pathname) {\n    var options = this.makeOptions(pathname, 'GET');\n\n    var requestOptions = {\n      options: options\n    };\n\n    return requestOptions;\n  };\n\n  this.makePutRequest = function (pathname, body) {\n    var options = this.makeOptions(pathname, 'PUT');\n\n    var requestOptions = {\n      options: options\n    };\n\n    if (body) {\n      var bodyJSON = JSON.stringify(body);\n\n      options.headers = {\n        'Content-Type': 'application/json',\n        'Content-Length': bodyJSON.length\n      };\n\n      requestOptions.body = bodyJSON;\n    }\n\n    return requestOptions;\n  };\n\n  this.doRequest = function (requestOptions) {\n    return new Promise((resolve, reject) => {\n      var request = http.request(requestOptions.options, (response) => {\n        var chunkedData = '';\n\n        response.on('data', (chunk) => {\n          chunkedData += chunk;\n        });\n\n        response.on('end', () => {\n          resolve(chunkedData);\n        });\n\n      });\n\n      if (requestOptions.body) {\n        request.write(requestOptions.body);\n      }\n\n      request.end();\n\n      request.on('response', function (res) {\n        if (res.statusCode < 200 || res.statusCode > 299) {\n          reject(res.statusCode);\n        }\n      });\n\n      request.on('error', function (error) {\n        reject(error);\n      });\n\n    });\n\n  };\n\n  this.rgb2hsv = function  () {\n    var rr, gg, bb,\n    r = arguments[0] / 255,\n    g = arguments[1] / 255,\n    b = arguments[2] / 255,\n    h, s,\n    v = Math.max(r, g, b),\n    diff = v - Math.min(r, g, b),\n    diffc = function(c){\n      return (v - c) / 6 / diff + 1 / 2;\n    };\n\n    if (diff == 0) {\n      h = s = 0;\n    } else {\n      s = diff / v;\n      rr = diffc(r);\n      gg = diffc(g);\n      bb = diffc(b);\n\n      if (r === v) {\n        h = bb - gg;\n      }else if (g === v) {\n        h = (1 / 3) + rr - bb;\n      }else if (b === v) {\n        h = (2 / 3) + gg - rr;\n      }\n      if (h < 0) {\n        h += 1;\n      }else if (h > 1) {\n        h -= 1;\n      }\n    }\n    return {\n      h: Math.round(h * 360),\n      s: Math.round(s * 100),\n      v: Math.round(v * 100)\n    };\n  };\n};\n\n\n\nAuroraApi.prototype.getInfo = function () {\n  const requestOptions = this.makeGetRequestOptions('/');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getPowerStatus = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/on');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.turnOn = function () {\n  const requestOptions = this.makePutRequest('/state', {\n    on: {\n\t\t\tvalue: true\n\t\t}\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.turnOff = function () {\n  const requestOptions = this.makePutRequest('/state', {\n    on: {\n\t\t\tvalue: false\n\t\t}\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getBrightness = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/brightness');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setBrightness = function (value) {\n  const requestOptions = this.makePutRequest('/state', {\n    brightness: value\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getHue = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/hue');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setHue = function (value) {\n  const requestOptions = this.makePutRequest('/state', {\n    hue: value\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getSat = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/sat');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setSat = function (value) {\n  const requestOptions = this.makePutRequest('/state', {\n    sat: value\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setHSV = function (h,s,v) {\n  const requestOptions = this.makePutRequest('/state', {\n    sat: s,\n    hue: h,\n    brightness: v\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setRGB = function (r,g,b) {\n  var hsv = this.rgb2hsv(r,g,b);\n  const requestOptions = this.makePutRequest('/state', {\n    sat: hsv.s,\n    hue: hsv.h,\n    brightness: hsv.v\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getColourTemperature = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/ct');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setColourTemperature = function (value) {\n  const requestOptions = this.makePutRequest('/state', {\n    ct: value\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getColourMode = function () {\n  const requestOptions = this.makeGetRequestOptions('/state/colorMode');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getEffect = function () {\n  const requestOptions = this.makeGetRequestOptions('/effects/select');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.setEffect = function (effect) {\n  const requestOptions = this.makePutRequest('/effects', {\n    'select': effect\n  });\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.listEffects = function () {\n  const requestOptions = this.makeGetRequestOptions('/effects/effectsList');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getOrientation = function () {\n  const requestOptions = this.makeGetRequestOptions('/panelLayout/globalOrientation');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.getLayoutOptions = function () {\n  const requestOptions = this.makeGetRequestOptions('/panelLayout/layout');\n\n  return this.doRequest(requestOptions);\n};\n\nAuroraApi.prototype.identify = function () {\n  const requestOptions = this.makePutRequest('/identify');\n\n  return this.doRequest(requestOptions);\n};\n"]}