mini_program_gizwits_sdk 3.0.0-beta-1 → 3.0.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,15 @@
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
7
  {
8
- "type": "pwa-chrome",
8
+ "type": "node",
9
9
  "request": "launch",
10
- "name": "Launch Chrome against localhost",
10
+ "name": "Mocha Tests",
11
11
  "url": "http://localhost:8080",
12
- "webRoot": "${workspaceFolder}"
12
+ "webRoot": "${workspaceFolder}",
13
+ "skipFiles": [
14
+ "<node_internals>/**"
15
+ ],
16
+ "program":"${workspaceFolder}/node_modules/mocha/bin/_mocha -r ts-node/register tests/bleConfig/sdk.ble.spec.ts -file ./tests/setup-wx.js -timeout 60s"
13
17
  }
14
18
  ]
15
19
  }
package/README.md CHANGED
@@ -1,49 +1,103 @@
1
1
  <a href='https://coveralls.io/github/gizwits/mini_program_gizwits_sdk?branch=master'><img src='https://coveralls.io/repos/github/gizwits/mini_program_gizwits_sdk/badge.svg?branch=master' alt='Coverage Status' /></a><img alt="npm" src="https://img.shields.io/npm/v/mini_program_gizwits_sdk">[![Build Status](https://travis-ci.org/gizwits/mini_program_gizwits_sdk.svg?branch=master)](https://travis-ci.org/gizwits/mini_program_gizwits_sdk)
2
2
 
3
- # 小程序配网SDK
4
-
5
- ### 安装
6
-
7
- `yarn add mini_program_gizwits_sdk`
8
-
9
- ### 使用方法
10
-
11
- ```javascript
12
- import GizwitsSdk, { errorCode } from 'mini_program_gizwits_sdk';
13
-
14
- const sdk = new GizwitsSdk({
15
- appID: '8f187b1deb9e44b6aa1374b8f13bccb1',
16
- appSecret: 'd73fa6d6d7c04d37b6b2cc13a18a9f37',
17
- specialProductKeys: ['00e7e327afa74a3d8ff1cc190bad78c0'],
18
- specialProductKeySecrets: ['aa3d301fa291466fbed20e4204609abc'],
19
- token: token,
20
- uid: uid,
21
- cloudServiceInfo: null,
22
- });
23
-
24
- try {
25
- const data = await sdk.setDeviceOnboardingDeploy({
26
- ssid: SSID,
27
- password: password,
28
- timeout: 60,
29
- softAPSSIDPrefix: 'XPG-GAgent-',
30
- });
31
- } catch (error) {
32
- console.log(error)
33
- }
3
+ # 机智云小程序 SDK
4
+
5
+ ## 🔧 安装
6
+
7
+ ```bash
8
+ yarn add mini_program_gizwits_sdk
34
9
  ```
35
10
 
36
- 其中`data`代表配网成功的设备。
11
+ ## 🏍 初始化 Sdk
12
+
13
+ ```ts
14
+ import GizwitsSdk from 'mini_program_gizwits_sdk';
15
+ import { Component } from 'react';
16
+ import { View } from '@tarojs/components';
37
17
 
38
- 如果失败的话会返回数据
18
+ export default class Index extends Component {
19
+ private gizSdk: GizwitsSdk;
39
20
 
40
- ```javascript
41
- {
42
- success: false,
43
- err: {
44
- errorCode: 'code',
45
- errorMessage: 'message',
21
+ componentDidMount() {
22
+ this.gizSdk = new GizwitsSdk({
23
+ appID: 'appID',
24
+ appSecret: 'appSecret',
25
+ productInfo: [
26
+ {
27
+ productKey: 'productKey',
28
+ productSecrets: 'productSecrets',
29
+ },
30
+ ],
31
+ uid: 'giz_uid',// 必填
32
+ token: 'giz_token', // 必填
33
+ });
34
+ }
35
+
36
+ render() {
37
+ return <View>hello</View>;
46
38
  }
47
39
  }
48
40
  ```
49
41
 
42
+ ## 📖 API
43
+
44
+ ### sdk.initBle()
45
+
46
+ 初始化 sdk 蓝牙能力。
47
+
48
+ ### sdk.addEventListener(type:K,func:TListenerType[K])
49
+
50
+ 注册事件监听。事件种类见下表。
51
+ | 事件种类 type | 回调参数类型 | 回调参数描述 |
52
+ | ---------- | ------ | ------------------ |
53
+ | "OnScanListChange" | IDevice[] | 扫描设备列表 |
54
+ | "TDeviceStatusNotifications" | IDeviceStatusNoti | 设备状态变更通知 |
55
+ | "TDeviceAttrsNotifications" | IDeviceAttrsNoti | 设备数据点变更通知 |
56
+ | "OnBleHandleError" | IError | ble 错误通知 |
57
+
58
+ ### sdk.removeEventListener(type:K,func:TListenerType[K])
59
+ 销毁事件监听。
60
+
61
+ ### sdk.scanBleDevice(delay:number)
62
+
63
+ 搜索蓝牙设备。搜索到的蓝牙设备会被`OnScanListChange`监听。
64
+
65
+ #### 参数
66
+
67
+ - delay: 超时时间。
68
+
69
+ ### sdk.deviceSafetyRegister(Object object)
70
+
71
+ 安全注册目标设备,否则无法发起设备绑定。返回值中可以拿到注册结果。
72
+
73
+ #### 参数
74
+
75
+ - Object object
76
+
77
+ | 属性 | 类型 | 描述 |
78
+ | ---------- | ------ | ------------------ |
79
+ | mac | string | 待注册设备 mac |
80
+ | productKey | string | 待注册设备所属产品 |
81
+
82
+ ### sdk.bindRemoteDevice(Object object)
83
+
84
+ 绑定远程设备,否则无法发起设备订阅。返回值中可以拿到绑定结果。
85
+
86
+ #### 参数
87
+
88
+ - Object object
89
+
90
+ | 属性 | 类型 | 描述 |
91
+ | ---------- | ------ | ------------------ |
92
+ | mac | string | 待绑定设备 mac |
93
+ | productKey | string | 待绑定设备所属产品 |
94
+
95
+ ### sdk.subscribe(device:IDevice)
96
+
97
+ 订阅目标设备,订阅成功后可控制设备。返回值中可以拿到订阅结果。
98
+ ### sdk.write(cmd:{[key]:value})
99
+ 控制设备。 其中`key`为数据点名称,value为数据点的值。
100
+
101
+ ### sdk.unSubscribe(device:IDevice)
102
+
103
+ 取消订阅目标设备。蓝牙设备会断开连接。返回值中可拿到取消订阅结果。
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports=function(e){var t={};function i(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(r,s,function(t){return e[t]}.bind(null,s));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=24)}([function(e,t,i){(function(t){var r;e.exports=(r=r||function(e,r){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&void 0!==t&&t.crypto&&(s=t.crypto),!s)try{s=i(34)}catch(e){}var n=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),o={},c=o.lib={},l=c.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=l.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,s=e.sigBytes;if(this.clamp(),r%4)for(var n=0;n<s;n++){var a=i[n>>>2]>>>24-n%4*8&255;t[r+n>>>2]|=a<<24-(r+n)%4*8}else for(var o=0;o<s;o+=4)t[r+o>>>2]=i[o>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(n());return new u.init(t,e)}}),d=o.enc={},h=d.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(i,t/2)}},f=d.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(i,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},v=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i,r=this._data,s=r.words,n=r.sigBytes,a=this.blockSize,o=n/(4*a),c=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,l=e.min(4*c,n);if(c){for(var d=0;d<c;d+=a)this._doProcessBlock(s,d);i=s.splice(0,c),r.sigBytes-=l}return new u.init(i,l)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(c.Hasher=v.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new g.HMAC.init(e,i).finalize(t)}}}),o.algo={});return o}(Math),r)}).call(this,i(33))},function(e,t,i){var r,s,n,a,o,c,l,u,d,h,f,p,v,g,y,_,D,m,w;e.exports=(r=i(0),i(3),void(r.lib.Cipher||(s=r,n=s.lib,a=n.Base,o=n.WordArray,c=n.BufferedBlockAlgorithm,l=s.enc,l.Utf8,u=l.Base64,d=s.algo.EvpKDF,h=n.Cipher=c.extend({cfg:a.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){c.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?w:D}return function(t){return{encrypt:function(i,r,s){return e(r).encrypt(t,i,r,s)},decrypt:function(i,r,s){return e(r).decrypt(t,i,r,s)}}}}()}),n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),f=s.mode={},p=n.BlockCipherMode=a.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),v=f.CBC=function(){var e=p.extend();function t(e,t,i){var r,s=this._iv;s?(r=s,this._iv=void 0):r=this._prevBlock;for(var n=0;n<i;n++)e[t+n]^=r[n]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s),r.encryptBlock(e,i),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);r.decryptBlock(e,i),t.call(this,e,i,s),this._prevBlock=n}}),e}(),g=(s.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,r=i-e.sigBytes%i,s=r<<24|r<<16|r<<8|r,n=[],a=0;a<r;a+=4)n.push(s);var c=o.create(n,r);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:v,padding:g}),reset:function(){var e;h.reset.call(this);var t=this.cfg,i=t.iv,r=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(r,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),y=n.CipherParams=a.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(s.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;return(i?o.create([1398893684,1701076831]).concat(i).concat(t):t).toString(u)},parse:function(e){var t,i=u.parse(e),r=i.words;return 1398893684==r[0]&&1701076831==r[1]&&(t=o.create(r.slice(2,4)),r.splice(0,4),i.sigBytes-=16),y.create({ciphertext:i,salt:t})}},D=n.SerializableCipher=a.extend({cfg:a.extend({format:_}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var s=e.createEncryptor(i,r),n=s.finalize(t),a=s.cfg;return y.create({ciphertext:n,key:i,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(s.kdf={}).OpenSSL={execute:function(e,t,i,r){r||(r=o.random(8));var s=d.create({keySize:t+i}).compute(e,r),n=o.create(s.words.slice(t),4*i);return s.sigBytes=4*t,y.create({key:s,iv:n,salt:r})}},w=n.PasswordBasedCipher=D.extend({cfg:D.cfg.extend({kdf:m}),encrypt:function(e,t,i,r){var s=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=s.iv;var n=D.encrypt.call(this,e,t,s.key,r);return n.mixIn(s),n},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var s=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=s.iv,D.decrypt.call(this,e,t,s.key,r)}}))))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.checkHeader=e=>{let t=0;return 0===e[0]&&0===e[1]&&0===e[2]&&3===e[3]&&(t=4,4)};t.getProtocolLen=e=>{let t=0;for(;t<e.length&&"1"===r(e[t].toString(2),8)[0];t++);return t+1},t.arrayToString=function(e){let t="";return e.map(e=>(t+=r(e.toString(16),2),null)),t};const r=(e,t,i=!1)=>{const r=t-e.length,s=new Array(r).fill(0).join("");return i?e+=s:e=s+e,e};t.fillString=r;t.string2Bytes=e=>{const t=[];for(let i=0;i<e.length;i++)t.push(e.charCodeAt(i));return t};t.hexStrint2byte=e=>{const t=Math.ceil(e.length/2),i=[];for(let r=0;r<t;r++){const t=2*r,s=t+2,n=e.substring(t,s);i.push(parseInt(n,16))}return i};const s=e=>{const t=encodeURI(e);return-1!==t.indexOf("%")&&"%"!==e?t.split("%").filter(e=>""!==e).map(e=>parseInt(e,16)):[t.charCodeAt(0)]};t.formatCode=s;t.formatCodesFromStr=e=>{const t=[0,0];let i=[];for(let r=0;r<e.length;r++){const n=s(e[r]);t[1]+=n.length,i=i.concat(n)}return[i,t]}},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(14),i(15),s=(r=u).lib,n=s.Base,a=s.WordArray,o=r.algo,c=o.MD5,l=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,r=this.cfg,s=r.hasher.create(),n=a.create(),o=n.words,c=r.keySize,l=r.iterations;o.length<c;){i&&s.update(i),i=s.update(e).finalize(t),s.reset();for(var u=1;u<l;u++)i=s.finalize(i),s.reset();n.concat(i)}return n.sigBytes=4*c,n}}),r.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},u.EvpKDF)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var s=[],n=0;n<i;n+=3)for(var a=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,o=0;o<4&&n+.75*o<i;o++)s.push(r.charAt(a>>>6*(3-o)&63));var c=r.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var n=0;n<i.length;n++)r[i.charCodeAt(n)]=n}var a=i.charAt(64);if(a){var o=e.indexOf(a);-1!==o&&(t=o)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2,c=i[e.charCodeAt(a)]>>>6-a%4*2,l=o|c;r[n>>>2]|=l<<24-n%4*8,n++}return s.create(r,n)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[];!function(){for(var t=0;t<64;t++)o[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,a=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],v=e[t+4],g=e[t+5],y=e[t+6],_=e[t+7],D=e[t+8],m=e[t+9],w=e[t+10],S=e[t+11],b=e[t+12],B=e[t+13],I=e[t+14],k=e[t+15],C=n[0],A=n[1],x=n[2],P=n[3];C=l(C,A,x,P,a,7,o[0]),P=l(P,C,A,x,c,12,o[1]),x=l(x,P,C,A,f,17,o[2]),A=l(A,x,P,C,p,22,o[3]),C=l(C,A,x,P,v,7,o[4]),P=l(P,C,A,x,g,12,o[5]),x=l(x,P,C,A,y,17,o[6]),A=l(A,x,P,C,_,22,o[7]),C=l(C,A,x,P,D,7,o[8]),P=l(P,C,A,x,m,12,o[9]),x=l(x,P,C,A,w,17,o[10]),A=l(A,x,P,C,S,22,o[11]),C=l(C,A,x,P,b,7,o[12]),P=l(P,C,A,x,B,12,o[13]),x=l(x,P,C,A,I,17,o[14]),C=u(C,A=l(A,x,P,C,k,22,o[15]),x,P,c,5,o[16]),P=u(P,C,A,x,y,9,o[17]),x=u(x,P,C,A,S,14,o[18]),A=u(A,x,P,C,a,20,o[19]),C=u(C,A,x,P,g,5,o[20]),P=u(P,C,A,x,w,9,o[21]),x=u(x,P,C,A,k,14,o[22]),A=u(A,x,P,C,v,20,o[23]),C=u(C,A,x,P,m,5,o[24]),P=u(P,C,A,x,I,9,o[25]),x=u(x,P,C,A,p,14,o[26]),A=u(A,x,P,C,D,20,o[27]),C=u(C,A,x,P,B,5,o[28]),P=u(P,C,A,x,f,9,o[29]),x=u(x,P,C,A,_,14,o[30]),C=d(C,A=u(A,x,P,C,b,20,o[31]),x,P,g,4,o[32]),P=d(P,C,A,x,D,11,o[33]),x=d(x,P,C,A,S,16,o[34]),A=d(A,x,P,C,I,23,o[35]),C=d(C,A,x,P,c,4,o[36]),P=d(P,C,A,x,v,11,o[37]),x=d(x,P,C,A,_,16,o[38]),A=d(A,x,P,C,w,23,o[39]),C=d(C,A,x,P,B,4,o[40]),P=d(P,C,A,x,a,11,o[41]),x=d(x,P,C,A,p,16,o[42]),A=d(A,x,P,C,y,23,o[43]),C=d(C,A,x,P,m,4,o[44]),P=d(P,C,A,x,b,11,o[45]),x=d(x,P,C,A,k,16,o[46]),C=h(C,A=d(A,x,P,C,f,23,o[47]),x,P,a,6,o[48]),P=h(P,C,A,x,_,10,o[49]),x=h(x,P,C,A,I,15,o[50]),A=h(A,x,P,C,g,21,o[51]),C=h(C,A,x,P,b,6,o[52]),P=h(P,C,A,x,p,10,o[53]),x=h(x,P,C,A,w,15,o[54]),A=h(A,x,P,C,c,21,o[55]),C=h(C,A,x,P,D,6,o[56]),P=h(P,C,A,x,k,10,o[57]),x=h(x,P,C,A,y,15,o[58]),A=h(A,x,P,C,B,21,o[59]),C=h(C,A,x,P,v,6,o[60]),P=h(P,C,A,x,S,10,o[61]),x=h(x,P,C,A,f,15,o[62]),A=h(A,x,P,C,m,21,o[63]),n[0]=n[0]+C|0,n[1]=n[1]+A|0,n[2]=n[2]+x|0,n[3]=n[3]+P|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;i[s>>>5]|=128<<24-s%32;var n=e.floor(r/4294967296),a=r;i[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),i[14+(s+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(i.length+1),this._process();for(var o=this._hash,c=o.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return o},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,i,r,s,n,a){var o=e+(t&i|~t&r)+s+a;return(o<<n|o>>>32-n)+t}function u(e,t,i,r,s,n,a){var o=e+(t&r|i&~r)+s+a;return(o<<n|o>>>32-n)+t}function d(e,t,i,r,s,n,a){var o=e+(t^i^r)+s+a;return(o<<n|o>>>32-n)+t}function h(e,t,i,r,s,n,a){var o=e+(i^(t|~r))+s+a;return(o<<n|o>>>32-n)+t}t.MD5=n._createHelper(c),t.HmacMD5=n._createHmacHelper(c)}(Math),r.MD5)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(2);t.default=class{constructor(e){this.header="",this.len=0,this.flag=[0],this.cmd="",this.content=[],this.formatP0=e=>{let t=r.checkHeader(e);if(!1===t)throw new Error("Header Error");this.header=r.arrayToString(e.slice(0,t));const i=e.slice(t,e.length),s=r.getProtocolLen(i);this.len=parseInt(r.arrayToString(i.slice(0,s)),16),t+=s,this.flag=e.slice(t,t+1),t+=1,this.cmd=r.arrayToString(e.slice(t,t+2)),t+=2,this.content=e.slice(t,e.length)},e&&e.length>0&&this.formatP0(e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={GIZ_OPENAPI_DEVICE_NOT_BOUND:{errorCode:9017,errorMessage:"not bind"},GIZ_SDK_HTTP_REQUEST_FAILED:{errorCode:8099,errorMessage:"网络请求失败"},GIZ_SDK_SDK_NOT_INITIALIZED:{errorCode:8300,errorMessage:"not init"},CONFIG_TIME_OUT:{errorCode:8023,errorMessage:"Config Timeout"},WECHAT_ERROR:{errorCode:1e4,errorMessage:"wechat error"},GIZ_SDK_ONBOARDING_STOPPED:{errorCode:8318,errorMessage:"配网中断"},GIZ_SDK_DEVICE_CONFIG_IS_RUNNING:{errorCode:8022,errorMessage:"配置正在进行中"},GIZ_OPENAPI_TOKEN_INVALID:{errorCode:9004,errorMessage:"token 失效"},GIZ_SDK_BIND_DEVICE_FAILED:{errorCode:8039,errorMessage:"设备绑定失败"},GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON:{errorCode:8281,errorMessage:"蓝牙未启用"},GIZ_SDK_OTHERWISE:{errorCode:8100,errorMessage:""},GIZ_SDK_DEVICE_NOT_SUBSCRIBED:{errorCode:8029,errorMessage:"设备还未订阅"},GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY:{errorCode:8250,errorMessage:"产品类型不在指定范围内"}}},function(e,t,i){var r;e.exports=(r=i(0),i(9),i(35),i(36),i(4),i(37),i(5),i(14),i(22),i(38),i(23),i(39),i(40),i(41),i(15),i(42),i(3),i(1),i(43),i(44),i(45),i(46),i(47),i(48),i(49),i(50),i(51),i(52),i(53),i(54),i(55),i(56),i(57),i(58),r)},function(e,t,i){var r,s,n,a,o,c;e.exports=(c=i(0),s=(r=c).lib,n=s.Base,a=s.WordArray,(o=r.x64={}).Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),o.WordArray=n.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var s=e[r];i.push(s.high),i.push(s.low)}return a.create(i,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}}),c)},function(e,t,i){"use strict";function r(e){return Array.prototype.map.call(new Uint8Array(e),(function(e){return("00"+e.toString(16)).slice(-2)})).join("")}Object.defineProperty(t,"__esModule",{value:!0}),t.ab2hex=r,t.compareWXSDKVersion=function(e,t){const i=e.split("."),r=t.split("."),s=Math.max(e.length,t.length);for(;i.length<s;)i.push("0");for(;r.length<s;)r.push("0");for(let i=0;i<s;i++){const r=parseInt(e[i]),s=parseInt(t[i]);if(r>s)return 1;if(r<s)return-1}return 0},t.isError=e=>null!=e&&"symbol"==typeof e.errorCode,t.wrapErrorInfo=e=>({errorCode:e,errorMessage:e}),t.unionBy=(e,t)=>e.reduce((e,i)=>{const r=i[t];return e.some(e=>e[t]===r)||e.push(i),e},[]),t.isWXDevicesResult=function(e){return e.success&&"[object Array]"===Object.prototype.toString.call(e.bleDevices)},t.str2Buf=function(e){var t=e.length,i=new ArrayBuffer(t+2),r=new DataView(i);for(let i=0;i<t;i++)r.setUint8(i,parseInt(e[i],16));return i},t.numberArray2Uint8Array=e=>{const t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let r=0;r<t.byteLength;r++)i[r]=e[r];return i},t.advertisData2PkAndMac=(e,t)=>{let i=e.slice(e.byteLength-16),s=e.slice(0,e.byteLength-16),n=r(i);if(t.find(e=>e===n)){const e=r(s);return{productKey:n,mac:e}}{i=e.slice(0,16),s=e.slice(16),n=r(i);const t=r(s);return{productKey:n,mac:t}}},t.isSameDevice=(e,t)=>e.mac===t.mac&&e.productKey===t.productKey,t.merageBleLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?(r.isBleOnline=!0,r.bleDeviceID=i.bleDeviceID):e.push(i)}),e),t.merageLanLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?r.isLanOnline=!0:e.push(i)}),e),t.BTDevice2GDevice=(e,i)=>{const{productKey:r,mac:s}=t.advertisData2PkAndMac(e.advertisData,i);return{mac:s,did:"",connectType:"NONE",isBleOnline:!0,isLanOnline:!1,isOnline:!1,productKey:r,name:e.name,isBind:!1,bleDeviceID:e.deviceId}},t.getFirstConnectType=(e,t)=>{if(t){if("WAN"===t)return"WAN";switch(t){case"BLE":return e.isBleOnline?"BLE":"NONE";case"LAN":return e.isLanOnline?"LAN":"NONE"}}else{if(e.isLanOnline)return"LAN";if(e.isBleOnline)return"BLE"}return"WAN"},t.getProductInfoThroughPK=(e,t)=>t.find(t=>t.productKey===e)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=e=>new Promise(t=>setTimeout(()=>t(),e))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13);const s=new class{constructor(){this.data={},this.key="dataPointConfig",this.init=async()=>{const e=await wx.getStorageSync(this.key)||"{}";let t={};try{t=JSON.parse(e)}catch(e){}this.data=t},this.getConfigFile=async e=>{var t;if(!this.data[e]){const i=`/v2/datapoint?product_key=${e}`,s=await r.siteApiRequest(`${i}`,{method:"GET"});if(!s.success||!(null===(t=s.data)||void 0===t?void 0:t.entities))return null;this.data[e]=s.data,wx.setStorageSync(this.key,JSON.stringify(this.data))}return this.data[e]}}};s.init(),t.default=s},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(30),s=i(16),n=i(7);t.siteApiRequest=async(e,t)=>{const i=Object.assign({},t);i.header=Object.assign(Object.assign({},{"Content-Type":"application/json"}),t.headers),delete i.headers;const a=(s.getGlobalData("cloudServiceInfo")||{}).siteInfo||"site.gizwits.com",o=await r.default("http://"+a+e,i);if(o.statusCode>=200&&o.statusCode<300)return{success:!0,data:o.data};let c={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{c={success:!1,err:{errorCode:o.data.error_code,errorMessage:o.data.error_message}}}catch(e){}return c},t.default=async(e,t,i=!0)=>{const a=Object.assign({},t),o={"Content-Type":"application/json","X-Gizwits-Application-Id":s.getGlobalData("appID")};i&&(o["X-Gizwits-User-token"]=s.getGlobalData("token")),a.header=Object.assign(Object.assign({},o),t.headers),delete a.headers;const c=s.getGlobalData("cloudServiceInfo").openAPIInfo,l=await r.default("https://"+c+e,a);if(l.statusCode>=200&&l.statusCode<300)return{success:!0,data:l.data};let u={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{u={success:!1,err:{errorCode:l.data.error_code,errorMessage:l.data.error_message}}}catch(e){}return u}},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),s=(r=u).lib,n=s.WordArray,a=s.Hasher,o=r.algo,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],l=0;l<80;l++){if(l<16)c[l]=0|e[t+l];else{var u=c[l-3]^c[l-8]^c[l-14]^c[l-16];c[l]=u<<1|u>>>31}var d=(r<<5|r>>>27)+o+c[l];d+=l<20?1518500249+(s&n|~s&a):l<40?1859775393+(s^n^a):l<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,o=a,a=n,n=s<<30|s>>>2,s=r,r=d}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=a._createHelper(l),r.HmacSHA1=a._createHmacHelper(l),u.SHA1)},function(e,t,i){var r,s,n,a;e.exports=(r=i(0),n=(s=r).lib.Base,a=s.enc.Utf8,void(s.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),n=this._iKey=t.clone(),o=s.words,c=n.words,l=0;l<i;l++)o[l]^=1549556828,c[l]^=909522486;s.sigBytes=n.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={};t.setGlobalData=function(e,t){r[e]=t},t.getGlobalData=function(e){return r[e]}},function(e,t,i){"use strict";var r=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(i[r[s]]=e[r[s]])}return i};Object.defineProperty(t,"__esModule",{value:!0});const s=i(10),n=i(18),a=i(27),o=i(2),c=i(6),l=i(28),u=i(29);t.BleHandle=class{constructor(e=[],t={serviceUUIDSuffix:"abf0",characteristicUUIDSuffix:"abf7"}){this.connectedList=[],this.pks=[],this.tmpBleData="",this.tmpDataNum=0,this.listenerMap={},this.handleOnBLECharacteristicValueChange=e=>{console.log("handleOnBLECharacteristicValueChange",s.ab2hex(e.value));const t=s.ab2hex(e.value);try{const i=new c.default(o.hexStrint2byte(t));console.log("ProtocolBase",i.len,e.value.byteLength),this.tmpBleData=t,this.tmpDataNum=i.len-e.value.byteLength+4+Math.ceil(i.len.toString(2).length/8)}catch(i){this.tmpBleData&&(this.tmpBleData+=t,this.tmpDataNum-=e.value.byteLength)}this.tmpDataNum>0||!this.tmpBleData||(console.log("ProtocolBase",this.tmpBleData,this.tmpDataNum),this.listenerMap[e.deviceId]&&this.listenerMap[e.deviceId].map(t=>{t(e,this.tmpBleData)}),this.listenerMap.ALL&&(console.log("ProtocolBase1"),this.listenerMap.ALL.map(t=>{console.log("ProtocolBase2"),t(e,this.tmpBleData)})),this.tmpBleData="",this.tmpDataNum=0)},this.checkPermission=async()=>{const e=await wx.getBluetoothAdapterState(),{errMsg:t,available:i}=e,n=r(e,["errMsg","available"]);return{data:Object.assign({},n),err:s.wrapErrorInfo(t),success:i}},this.getDeviceStatus=async(e,t,i,r)=>{const n=await u.default.pack(t,i,r);return n?(console.log("getDeviceStatus",n),await this.write(e,s.numberArray2Uint8Array(n).buffer)):{success:!1}},this.startScan=async(e,t=5e3)=>new Promise(async i=>{const r=[];wx.onBluetoothDeviceFound(t=>{const i=t.devices.filter(e=>{const{advertisData:t}=e,i=s.ab2hex(t);return this.pks.some(e=>i.includes(e))});if(i.length>0){const t=i.map(e=>s.BTDevice2GDevice(e,this.pks));r.push(...t),e(r)}}),await wx.startBluetoothDevicesDiscovery({powerLevel:"high"}),setTimeout(()=>{this.stopScan(),i({scanList:r})},t)}),this.stopScan=async()=>{const{errMsg:e,errCode:t}=await wx.stopBluetoothDevicesDiscovery();return{errMsg:e,errCode:t}},this.connectDevice=async e=>{var t;await wx.createBLEConnection({deviceId:e});const{services:i}=await wx.getBLEDeviceServices({deviceId:e});console.log("获取设备服务成功",i);const r=null===(t=i.find(e=>e.isPrimary&&e.uuid.toLowerCase().includes(this.serviceUUIDSuffix)))||void 0===t?void 0:t.uuid;if(!r)return{message:"can not find valid serviceId",success:!1};const{characteristics:n}=await wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:r});console.log("获取服务特征值成功",n);const o=n[0].uuid;this.connectedList.every(t=>t.deviceId!==e)&&this.connectedList.push({deviceId:e,serviceId:r,characteristicId:o}),await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:r,characteristicId:o,state:!0,type:"notification"}),console.log("监听特征值变化成功"),this.write(e,s.numberArray2Uint8Array(a.default.pack()).buffer);const c=await this.handleBindReq(e);if(c.success){this.write(e,s.numberArray2Uint8Array(l.default.pack({passcode:c.data})).buffer);const t=await this.handleLoginReq(e);if(console.log("loginData",t),t.success)return{success:!0,message:"ok"}}return{success:!1,message:"ok"}},this.handleBindReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new a.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),n.passcode?t({success:!0,data:n.passcode}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.handleLoginReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new l.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),!0===n.result?t({success:!0,data:n.did}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.removeDeviceListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{message:"ok",success:!0}}return{message:"invalid function",success:!1}},this.addDeviceListener=async(e,t)=>{"ALL"===e&&(this.listenerMap.ALL||(this.listenerMap.ALL=[]),this.listenerMap.ALL.push(t));const{serviceId:i,characteristicId:r,errMsg:s}=this.getTargetDevice(e);return s?{success:!1,message:s}:(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:i,characteristicId:r,state:!0,type:"notification"}),console.log(`监听设备 ${e} 成功!`),{message:"ok",success:!0})},this.write=async(e,t)=>{const{serviceId:i,characteristicId:r}=this.getTargetDevice(e);i&&r&&await n.unpackWriteBLECharacteristicValue(e,i,r,t)},this.disConnectDevice=async e=>{const{errMsg:t}=await wx.closeBLEConnection({deviceId:e});return{err:s.wrapErrorInfo(t)}},this.getTargetDevice=e=>{const t=this.connectedList.find(t=>e===t.deviceId);return t||{errMsg:"Unable get this device,maybe you forgot to connect it."}};const{serviceUUIDSuffix:i}=t;this.serviceUUIDSuffix=i,this.pks=e;try{wx.openBluetoothAdapter()}catch(e){console.error(e)}wx.onBLECharacteristicValueChange(this.handleOnBLECharacteristicValueChange)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11);function s(e,t,i,r){return new Promise(s=>{console.log("writeBLECharacteristicValue"),wx.writeBLECharacteristicValue({deviceId:e,serviceId:t,characteristicId:i,value:r,complete:s})})}t.openBluetoothAdapter=function(){return new Promise((e,t)=>{wx.openBluetoothAdapter({success:e,fail:t})})},t.getBluetoothAdapterState=function(){return new Promise((e,t)=>{wx.getBluetoothAdapterState({success:e,fail:t})})},t.startBluetoothDevicesDiscovery=function(){return new Promise((e,t)=>{wx.startBluetoothDevicesDiscovery({success:e,fail:t,interval:100})})},t.getBluetoothDevices=function(){return new Promise((e,t)=>{wx.getBluetoothDevices({success:({devices:t})=>e(t),fail:t})})},t.createBLEConnection=function(e,t){return new Promise((i,r)=>{wx.createBLEConnection({deviceId:e,timeout:t,success:e=>i(e),fail:e=>{-1===e.errCode?i(e):r(e)}})})},t.getBLEDeviceServices=function(e){return new Promise((t,i)=>{wx.getBLEDeviceServices({deviceId:e,success:({services:e})=>t(e),fail:i})})},t.getBLEDeviceCharacteristics=function(e,t){return new Promise((i,r)=>{wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:t,success:({characteristics:e})=>i(e),fail:r})})},t.notifyBLECharacteristicValueChange=function(e,t,i,r=!0){return new Promise((s,n)=>{wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:t,characteristicId:i,state:r,success:s,fail:n})})},t.writeBLECharacteristicValue=s,t.unpackWriteBLECharacteristicValue=function(e,t,i,n){if(0===n.byteLength)throw new Error("value is not empty");return new Promise(async(a,o)=>{let c,l=0,u=n.byteLength;for(;u>0;){await r.default(30);const a=n.slice(l,l+20);if(l+=20,u-=20,c=await s(e,t,i,a),console.log("unpackWriteBLECharacteristicValue",l/20,c),0!==c.errCode)break}0!==c.errCode?o(c):a(c)})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e)}}n.pack=(e,t)=>{const i=[],[r,n]=s.formatCodesFromStr(e),[a,o]=s.formatCodesFromStr(t),c=[0].concat([0,1],n,r,o,a);let l=c.length;for(;l>0;)i.push(l),l-=255;const u=[0,0,0,3].concat(i).concat(c),d=new ArrayBuffer(u.length),h=new Uint8Array(d);for(let e=0;e<d.byteLength;e++)h[e]=u[e];return h},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11),s=i(7),n=i(21);t.default=class{constructor(e,t,i,a){this.ssid="",this.password="",this.specialProductKeys=[],this.disableSearchDevice=!1,this.specialProductKeySecrets=[],this.timeoutHandler=null,this.setDeviceOnboardingDeployRej=()=>{},this.cleanTimeout=()=>{this.disableSearchDevice=!0,this.timeoutHandler&&clearTimeout(this.timeoutHandler)},this.stopDeviceOnboardingDeploy=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:s.default.GIZ_SDK_ONBOARDING_STOPPED}),this.cleanTimeout()},this.hasTimeoutHandler=e=>!!this.timeoutHandler&&(e&&e({success:!1,err:s.default.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING}),!0),this.handleTimeout=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:{errorCode:s.default.CONFIG_TIME_OUT,errorMessage:"time out"}})},this.searchDevice=({ssid:e,password:t})=>new Promise((i,a)=>{console.debug("GIZ_SDK: 开始大循环搜索设备");const o=async()=>{var c;try{const l=await n.checkDeviceRegister({SSID:e,password:t,productKeys:this.specialProductKeys});if((null===(c=l.err)||void 0===c?void 0:c.errorCode)===s.default.GIZ_OPENAPI_TOKEN_INVALID.errorCode)return void a({success:!1,err:s.default.GIZ_OPENAPI_TOKEN_INVALID});l.err||0===l.data.length?(console.debug("GIZ_SDK: 大循环没有发现设备"),await r.default(1500),!this.disableSearchDevice&&o()):(console.debug("GIZ_SDK: 大循环搜索到设备",l),i({success:!0,data:l.data}))}catch(e){await r.default(3e3),!this.disableSearchDevice&&o()}};o()}),this.initDeviceOnboardingDeploy=(e,t)=>{this.setDeviceOnboardingDeployRej=t,this.disableSearchDevice=!1},this.startTimeoutTimer=e=>{this.timeoutHandler=setTimeout(this.handleTimeout,1e3*e)},this.bindDevices=e=>(console.log("GIZ_SDK: start bind device"),new Promise(async(t,i)=>{const r=e.map(e=>{const t=this.specialProductKeys.findIndex(t=>e.productKey===t);if(-1===t)return;const i=this.specialProductKeySecrets[t];return n.bindMac({mac:e.mac,productKey:e.productKey,productSecret:i})});try{const n=await Promise.all(r),a=e.filter((e,t)=>{const i=n[t];return i&&i.success});a.length>0?(console.log("GIZ_SDK: bind device success",a),t({success:!0,data:a})):(console.log("GIZ_SDK: bind device error",n),i({success:!1,data:e,err:s.default.GIZ_SDK_BIND_DEVICE_FAILED}))}catch(e){i(e)}})),this.ssid=e,this.password=t,this.specialProductKeys=i,this.specialProductKeySecrets=a}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13),s=i(32),n=i(59),a=i(8);t.getBindingList=async()=>{const e=await r.default("/app/bindings?show_disabled=0&limit=1000&skip=0",{method:"GET"});if(e.success){return{success:!0,data:e.data.devices.map(e=>({productKey:e.product_key,mac:e.mac,did:e.did,isBleOnline:!1,isLanOnline:!1,connectType:"NONE",name:e.dev_alias,isBind:!0,isOnline:e.is_online}))}}return{success:!1,err:e.err}},t.bindMac=async function({mac:e,productKey:t,productSecret:i,alias:s,beOwner:a}){const o={mac:e,product_key:t,dev_alias:s,set_owner:a},{Signature:c,timestamp:l}=n.psKeySign(i);return await r.default("/app/bind_mac",{method:"POST",data:o,headers:{"X-Gizwits-Signature":c,"X-Gizwits-Timestamp":l}})},t.unbindDevice=async function({devices:e}){return await r.default("/app/bindings",{method:"DELETE",data:{devices:e.map(e=>({did:e.did}))}})},t.checkDeviceRegister=async function({SSID:e,password:t,productKeys:i}){const n=s.default({SSID:e,password:t,pks:i});let a="";return n.map(e=>{a+=`${e},`}),a=a.substring(0,a.length-1),await r.default(`/app/device_register?random_codes=${a}`,{method:"get"})},t.safeRegister=async function({productKey:e,productSecret:t,mac:i,passcode:s,gwDid:n,isReset:o}){let c=`is_reset=${o?1:0}&mac=${i}&passcode=${s}`;n&&(c+=`&gw_did=${n}`);const l=a.enc.Hex.parse(t),u=a.enc.Hex.parse(""),d=a.enc.Utf8.parse(c),h=a.AES.encrypt(d,l,{iv:u,mode:a.mode.ECB,padding:a.pad.Pkcs7}).ciphertext.toString().toUpperCase(),f=await r.default(`/dev/${e}/device`,{method:"POST",data:{data:h},headers:{"content-type":"application/x-www-form-urlencoded"}},!1);return f.success?{success:!0,data:{successDevices:[],failedDevices:[]}}:{success:!1,err:f.err}}},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[],c=[];!function(){function t(t){for(var i=e.sqrt(t),r=2;r<=i;r++)if(!(t%r))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var r=2,s=0;s<64;)t(r)&&(s<8&&(o[s]=i(e.pow(r,.5))),c[s]=i(e.pow(r,1/3)),s++),r++}();var l=[],u=a.SHA256=n.extend({_doReset:function(){this._hash=new s.init(o.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=0;f<64;f++){if(f<16)l[f]=0|e[t+f];else{var p=l[f-15],v=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=l[f-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[f]=v+l[f-7]+y+l[f-16]}var _=r&s^r&n^s&n,D=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),m=h+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&d)+c[f]+l[f];h=d,d=u,u=o,o=a+m|0,a=n,n=s,s=r,r=m+(D+_)|0}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0,i[5]=i[5]+u|0,i[6]=i[6]+d|0,i[7]=i[7]+h|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;return i[s>>>5]|=128<<24-s%32,i[14+(s+64>>>9<<4)]=e.floor(r/4294967296),i[15+(s+64>>>9<<4)]=r,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(u),t.HmacSHA256=n._createHmacHelper(u)}(Math),r.SHA256)},function(e,t,i){var r;e.exports=(r=i(0),i(9),function(){var e=r,t=e.lib.Hasher,i=e.x64,s=i.Word,n=i.WordArray,a=e.algo;function o(){return s.create.apply(s,arguments)}var c=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],l=[];!function(){for(var e=0;e<80;e++)l[e]=o()}();var u=a.SHA512=t.extend({_doReset:function(){this._hash=new n.init([new s.init(1779033703,4089235720),new s.init(3144134277,2227873595),new s.init(1013904242,4271175723),new s.init(2773480762,1595750129),new s.init(1359893119,2917565137),new s.init(2600822924,725511199),new s.init(528734635,4215389547),new s.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=r.high,p=r.low,v=s.high,g=s.low,y=n.high,_=n.low,D=a.high,m=a.low,w=o.high,S=o.low,b=u.high,B=u.low,I=d.high,k=d.low,C=h.high,A=h.low,x=f,P=p,O=v,E=g,L=y,M=_,H=D,T=m,K=w,R=S,N=b,U=B,z=I,j=k,G=C,F=A,W=0;W<80;W++){var Z,V,X=l[W];if(W<16)V=X.high=0|e[t+2*W],Z=X.low=0|e[t+2*W+1];else{var $=l[W-15],q=$.high,Y=$.low,J=(q>>>1|Y<<31)^(q>>>8|Y<<24)^q>>>7,Q=(Y>>>1|q<<31)^(Y>>>8|q<<24)^(Y>>>7|q<<25),ee=l[W-2],te=ee.high,ie=ee.low,re=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,se=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),ne=l[W-7],ae=ne.high,oe=ne.low,ce=l[W-16],le=ce.high,ue=ce.low;V=(V=(V=J+ae+((Z=Q+oe)>>>0<Q>>>0?1:0))+re+((Z+=se)>>>0<se>>>0?1:0))+le+((Z+=ue)>>>0<ue>>>0?1:0),X.high=V,X.low=Z}var de,he=K&N^~K&z,fe=R&U^~R&j,pe=x&O^x&L^O&L,ve=P&E^P&M^E&M,ge=(x>>>28|P<<4)^(x<<30|P>>>2)^(x<<25|P>>>7),ye=(P>>>28|x<<4)^(P<<30|x>>>2)^(P<<25|x>>>7),_e=(K>>>14|R<<18)^(K>>>18|R<<14)^(K<<23|R>>>9),De=(R>>>14|K<<18)^(R>>>18|K<<14)^(R<<23|K>>>9),me=c[W],we=me.high,Se=me.low,be=G+_e+((de=F+De)>>>0<F>>>0?1:0),Be=ye+ve;G=z,F=j,z=N,j=U,N=K,U=R,K=H+(be=(be=(be=be+he+((de+=fe)>>>0<fe>>>0?1:0))+we+((de+=Se)>>>0<Se>>>0?1:0))+V+((de+=Z)>>>0<Z>>>0?1:0))+((R=T+de|0)>>>0<T>>>0?1:0)|0,H=L,T=M,L=O,M=E,O=x,E=P,x=be+(ge+pe+(Be>>>0<ye>>>0?1:0))+((P=de+Be|0)>>>0<de>>>0?1:0)|0}p=r.low=p+P,r.high=f+x+(p>>>0<P>>>0?1:0),g=s.low=g+E,s.high=v+O+(g>>>0<E>>>0?1:0),_=n.low=_+M,n.high=y+L+(_>>>0<M>>>0?1:0),m=a.low=m+T,a.high=D+H+(m>>>0<T>>>0?1:0),S=o.low=S+R,o.high=w+K+(S>>>0<R>>>0?1:0),B=u.low=B+U,u.high=b+N+(B>>>0<U>>>0?1:0),k=d.low=k+j,d.high=I+z+(k>>>0<j>>>0?1:0),A=h.low=A+F,h.high=C+G+(A>>>0<F>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(r+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(u),e.HmacSHA512=t._createHmacHelper(u)}(),r.SHA512)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i(25);const r=i(26),s=i(7);t.errorCode=s.default;const n=i(17);t.BleHandle=n.BleHandle,t.default=r.default},function(e,t){},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(16),s=i(17),n=i(31),a=i(60),o=i(61),c=i(62),l=i(21),u=i(10),d=i(12),h=i(63),f=i(2);t.default=class{constructor({appID:e,appSecret:t,productInfo:i,cloudServiceInfo:p,token:v,uid:g}){this.version="1.0.0",this.listenerMap={},this._deviceList=[],this._bleDevices=[],this._udpDevices=[],this.productInfo=[],this.autoScanInterval=null,this.handleBleDeviceData=async(e,t)=>{const i=this.allDevices.find(t=>t.bleDeviceID===e.deviceId);if(console.log("ProtocolBase",i),i){const e=await h.unpack(f.hexStrint2byte(t),i.productKey);console.log("handleBleDeviceData",e),(null==e?void 0:e.kvData)&&this.listenerMap.GizDeviceAttrsNotifications&&this.listenerMap.GizDeviceAttrsNotifications.map(t=>{t(i,null==e?void 0:e.kvData)})}},this.notiDeviveList=()=>{this.listenerMap.GizDeviceListNotifications&&this.listenerMap.GizDeviceListNotifications.map(e=>{e(this.allDevices)})},this.startAutoScan=()=>{this.autoScanInterval&&clearInterval(this.autoScanInterval),this.autoScanInterval=setInterval(async()=>{const e=await this.bleHandle.startScan(()=>{},4e3);this.bleDevices=e.scanList},6e3)},this.getVersion=()=>({success:!0,data:this.version}),this.initBle=async()=>{const e=await this.bleHandle.checkPermission();return e.success?(setTimeout(()=>{this.scanBleDevice()},500),this.startAutoScan(),this.bleHandle.addDeviceListener("ALL",this.handleBleDeviceData),console.debug("init BLE succcess",e),{success:!0}):(console.error("init BLE Error",e),{success:!1,err:o.errorCode.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON})},this.scanBleDevice=async()=>({success:!0,data:(await this.bleHandle.startScan(e=>{this.bleDevices=e})).scanList}),this.write=async(e,t)=>{if(e&&e.connectType&&"NONE"!==e.connectType)switch(e.connectType){case"BLE":{const i=await h.pack(t,e.productKey);i&&(console.log("write cmd",i,t),this.bleHandle.write(e.bleDeviceID,u.numberArray2Uint8Array(i).buffer));break}}},this.getProductConfig=async e=>{const t=await d.default.getConfigFile(e);return t?{success:!0,data:t}:{success:!1}},this.stopScanBleDevice=()=>{this.bleHandle.stopScan()},this.login=async e=>{var t,i;const s=await c.AnonymousLogin({uid:e});return s.success&&(r.setGlobalData("token",null===(t=s.data)||void 0===t?void 0:t.token),r.setGlobalData("uid",null===(i=s.data)||void 0===i?void 0:i.uid)),s},this.setDomain=e=>{const t=e&&e.openAPIInfo||"api.gizwits.com",i=e&&e.siteInfo||"site.gizwits.com",s=Object.assign(Object.assign({},e||{}),{openAPIInfo:t,siteInfo:i});r.setGlobalData("cloudServiceInfo",s)},this.getDeviceStatus=async(e,t)=>{const i=this.allDevices.find(t=>u.isSameDevice(t,e));if(i)switch(i.connectType){case"BLE":return await this.bleHandle.getDeviceStatus(i.bleDeviceID,i.productKey,i.rootDeviceId,t)}},this.subscribe=async(e,t,i=!0)=>{switch(u.getFirstConnectType(e,t)){case"BLE":{const t=this.bleDevices.find(t=>u.isSameDevice(t,e));if(t){const e=await this.bleHandle.connectDevice(t.bleDeviceID);return e.success&&setTimeout(()=>{this.getDeviceStatus(t)},500),console.log("subscribe",e),e}}}return{success:!1}},this.unSubscribe=async e=>{switch(e.connectType){case"BLE":return await this.bleHandle.disConnectDevice(e.bleDeviceID)}return{success:!1}},this.bindRemoteDevice=async({mac:e,productKey:t,alias:i,beOwner:r})=>{const s=u.getProductInfoThroughPK(t,this.productInfo);if(s){const n=await l.bindMac({mac:e,productKey:t,productSecret:s.productSecrets,alias:i,beOwner:r});return this.getBindingList(),n}return{success:!1,err:o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY}},this.unbindDevice=async({devices:e})=>{const t=await l.unbindDevice({devices:e});return t.success&&this.getBindingList(),t},this.deviceSafetyApi=async({mac:e,productKey:t,isReset:i})=>{const r=u.getProductInfoThroughPK(t,this.productInfo);return r?await l.safeRegister({productKey:t,productSecret:r.productSecrets,mac:e,isReset:i,passcode:"1234567890"}):{success:!1,err:o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY}},this.deviceSafetyRegister=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!1}),this.deviceSafetyUnbind=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!0}),this.setDeviceOnboardingDeploy=async({ssid:e,password:t,mode:i=0,timeout:r,isBind:s=!0,softAPSSIDPrefix:c})=>{if(this.currentWifiConfigHandle)return{success:!1,err:o.errorCode.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING};try{switch(i){case 0:{this.currentWifiConfigHandle=new n.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});return this.currentWifiConfigHandle=null,i}case 3:{this.currentWifiConfigHandle=new a.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});return this.currentWifiConfigHandle=null,i}}}catch(e){return console.error(e),e.err&&e.err.errorCode?e:{success:!1,err:o.errorCode.GIZ_SDK_OTHERWISE}}finally{this.currentWifiConfigHandle=null}},this.getBindingList=async()=>{const e=await l.getBindingList();this.devieList=e.data||[]},this.getDevices=async()=>(await this.getBindingList(),{success:!0,data:this.allDevices}),this.stopDeviceOnboardingDeploy=()=>{this.currentWifiConfigHandle&&(this.currentWifiConfigHandle.stopDeviceOnboardingDeploy(),this.currentWifiConfigHandle=null)},this.removeEventListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{success:!0}}return{success:!1}},this.addEventListener=async(e,t)=>(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),{success:!0}),this.productInfo=i,r.setGlobalData("appID",e),r.setGlobalData("appSecret",t),r.setGlobalData("productInfo",i),r.setGlobalData("token",v),r.setGlobalData("uid",g),this.bleHandle=new s.BleHandle(this.specialProductKeys),this.setDomain(p),console.debug(`init sdk success, current version: ${this.version}`)}get devieList(){return this._deviceList}set devieList(e){this._deviceList=e,this.notiDeviveList()}get bleDevices(){return this._bleDevices}set bleDevices(e){this._bleDevices=e,this.notiDeviveList()}get udpDevices(){return this._udpDevices}set udpDevices(e){this._udpDevices=e,this.notiDeviveList()}get allDevices(){let e=u.merageBleLocalDevices([...this.devieList],this.bleDevices);return e=u.merageLanLocalDevices(e,this.udpDevices),this.bleHandle.connectedList.map(t=>{const i=e.findIndex(e=>e.bleDeviceID===t.deviceId);-1!==i&&(e[i].connectType="BLE")}),e}get specialProductKeys(){return this.productInfo.map(e=>e.productKey||"")}get specialProductKeySecrets(){return this.productInfo.map(e=>e.productSecrets||"")}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.passcode="";let t=0;const i=parseInt(s.arrayToString(this.content.slice(t,t+2)),16);t+=2;let r="";this.content.slice(t,t+i).map(e=>{r+=String.fromCharCode(e)}),this.passcode=r}}n.pack=()=>[0,0,0,3,3,0,0,6],t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.result=!1,this.didLength=0,this.did="";let t=0;if(this.result=0===this.content[0],t++,1===this.flag[0]){this.didLength=parseInt(s.arrayToString(this.content.slice(t,t+2)),16),t+=2;let e="";this.content.slice(t,this.content.length).map(t=>{e+=String.fromCharCode(t)}),this.did=e}}}n.pack=({passcode:e})=>{let t=[0];const i=s.hexStrint2byte(s.fillString(e.length.toString(16),4)),r=s.string2Bytes(e),n=[0].concat([0,8]).concat(i).concat(r);return t=s.hexStrint2byte(n.length.toString(16)),[0,0,0,3].concat(t).concat(n)},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12),s=i(6),n=i(2);class a extends s.default{}a.pack=async(e,t,i)=>{const s=await r.default.getConfigFile(e);if(s){const e="var_len"===s.protocolType,r=[0,0,0,3],a=[0];let o=[0];const c=[0,147];let l=[0],u=[2];if(t){o=[1];const e=n.fillString(t.length.toString(16),4),i=n.hexStrint2byte(e),r=n.string2Bytes(t);l=l.concat(i).concat(r)}if(e){u=[18];let e="";i?s.entities[0].attrs.map(t=>{e=void 0!==i[t.name]?`1${e}`:`0${e}`}):s.entities[0].attrs.map(()=>{e=`1${e}`}),e=n.fillString(e,8*Math.ceil(e.length/8)),u=u.concat(n.hexStrint2byte(parseInt(e,2).toString(16)))}const d=o.concat(c).concat(l).concat(u);return a[0]=d.length,r.concat(a).concat(d)}return null},t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new Promise((i,r)=>{wx.request(Object.assign(Object.assign({url:e,timeout:3e3},t),{success:e=>{i(e)},fail:e=>{r(e)}}))})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(19),n=i(20);class a extends n.default{constructor(){super(...arguments),this.disableSendUDP=!1,this.sendMessageInterval=null,this.UDPSocketHandler=null,this.destroy=()=>{this.cleanTimeout(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.sendMessageInterval=null,this.UDPSocketHandler&&(this.UDPSocketHandler.offError(),this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.close())},this.configDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise((n,a)=>{console.debug("GIZ_SDK: start config device");let o=!1,c=0;const l=s.default.pack(e,t);this.UDPSocketHandler=wx.createUDPSocket(),this.UDPSocketHandler.bind(),this.disableSendUDP=!1;const u=()=>{try{!this.disableSendUDP&&this.UDPSocketHandler.send({address:"10.10.100.254",port:12414,message:l,offset:0,length:l.byteLength})}catch(e){}};this.sendMessageInterval=setInterval(()=>{u()},2e3),this.UDPSocketHandler.onError(e=>{c+=1,c>2&&(this.destroy(),a({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:e.errMsg}}))});const d=async()=>{if(!o){this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.offError(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.disableSendUDP=!0,o=!0;try{const i=await this.searchDevice({ssid:e,password:t});n(i)}catch(e){a(e)}}};this.UDPSocketHandler.onMessage(e=>{d()}),wx.onNetworkStatusChange(async()=>{!o&&wx.getConnectedWifi({success:async e=>{-1===e.wifi.SSID.indexOf(i)&&d()}})})}),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>{const r=this.ssid,s=this.password;return new Promise(async(n,a)=>{this.destroy(),this.initDeviceOnboardingDeploy(n,a),this.startTimeoutTimer(e);try{const e=((await this.configDevice({ssid:r,password:s,softAPSSIDPrefix:i})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));if(t)try{n(await this.bindDevices(e))}catch(e){a(e)}else n({success:!0,data:e})}catch(e){a(e)}finally{this.destroy()}})}}}t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8),s=i(8),n=({SSID:e,password:t,pk:i})=>{let n=r.MD5(e+t).toString();n=s.enc.Hex.parse(n);let a=s.enc.Utf8.parse(i),o=s.AES.encrypt(a,n,{iv:n,mode:s.mode.ECB,padding:s.pad.ZeroPadding});return r.MD5(o.ciphertext).toString()};t.default=({SSID:e,password:t,pks:i})=>{const r=[];return i.map(i=>{const s=n({SSID:e,password:t,pk:i});r.push(s)}),r}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){},function(e,t,i){var r;e.exports=(r=i(0),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,r=[],s=0;s<i;s++)r[s>>>2]|=e[s]<<24-s%4*8;t.call(this,r,i)}else t.apply(this,arguments)}).prototype=e}}(),r.lib.WordArray)},function(e,t,i){var r;e.exports=(r=i(0),function(){var e=r,t=e.lib.WordArray,i=e.enc;function s(e){return e<<8&4278255360|e>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s+=2){var n=t[s>>>2]>>>16-s%4*8&65535;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var i=e.length,r=[],s=0;s<i;s++)r[s>>>1]|=e.charCodeAt(s)<<16-s%2*16;return t.create(r,2*i)}},i.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var a=s(t[n>>>2]>>>16-n%4*8&65535);r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var i=e.length,r=[],n=0;n<i;n++)r[n>>>1]|=s(e.charCodeAt(n)<<16-n%2*16);return t.create(r,2*i)}}}(),r.enc.Utf16)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64url={stringify:function(e,t=!0){var i=e.words,r=e.sigBytes,s=t?this._safe_map:this._map;e.clamp();for(var n=[],a=0;a<r;a+=3)for(var o=(i[a>>>2]>>>24-a%4*8&255)<<16|(i[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|i[a+2>>>2]>>>24-(a+2)%4*8&255,c=0;c<4&&a+.75*c<r;c++)n.push(s.charAt(o>>>6*(3-c)&63));var l=s.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(e,t=!0){var i=e.length,r=t?this._safe_map:this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var a=0;a<r.length;a++)n[r.charCodeAt(a)]=a}var o=r.charAt(64);if(o){var c=e.indexOf(o);-1!==c&&(i=c)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2,c=i[e.charCodeAt(a)]>>>6-a%4*2,l=o|c;r[n>>>2]|=l<<24-n%4*8,n++}return s.create(r,n)}(e,i,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},n.enc.Base64url)},function(e,t,i){var r,s,n,a,o,c;e.exports=(c=i(0),i(22),s=(r=c).lib.WordArray,n=r.algo,a=n.SHA256,o=n.SHA224=a.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=a._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=a._createHelper(o),r.HmacSHA224=a._createHmacHelper(o),c.SHA224)},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(9),i(23),s=(r=u).x64,n=s.Word,a=s.WordArray,o=r.algo,c=o.SHA512,l=o.SHA384=c.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),r.SHA384=c._createHelper(l),r.HmacSHA384=c._createHmacHelper(l),u.SHA384)},function(e,t,i){var r;e.exports=(r=i(0),i(9),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.x64.Word,o=t.algo,c=[],l=[],u=[];!function(){for(var e=1,t=0,i=0;i<24;i++){c[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)l[e+5*t]=t+(2*e+3*t)%5*5;for(var s=1,n=0;n<24;n++){for(var o=0,d=0,h=0;h<7;h++){if(1&s){var f=(1<<h)-1;f<32?d^=1<<f:o^=1<<f-32}128&s?s=s<<1^113:s<<=1}u[n]=a.create(o,d)}}();var d=[];!function(){for(var e=0;e<25;e++)d[e]=a.create()}();var h=o.SHA3=n.extend({cfg:n.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new a.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,s=0;s<r;s++){var n=e[t+2*s],a=e[t+2*s+1];n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),(A=i[s]).high^=a,A.low^=n}for(var o=0;o<24;o++){for(var h=0;h<5;h++){for(var f=0,p=0,v=0;v<5;v++)f^=(A=i[h+5*v]).high,p^=A.low;var g=d[h];g.high=f,g.low=p}for(h=0;h<5;h++){var y=d[(h+4)%5],_=d[(h+1)%5],D=_.high,m=_.low;for(f=y.high^(D<<1|m>>>31),p=y.low^(m<<1|D>>>31),v=0;v<5;v++)(A=i[h+5*v]).high^=f,A.low^=p}for(var w=1;w<25;w++){var S=(A=i[w]).high,b=A.low,B=c[w];B<32?(f=S<<B|b>>>32-B,p=b<<B|S>>>32-B):(f=b<<B-32|S>>>64-B,p=S<<B-32|b>>>64-B);var I=d[l[w]];I.high=f,I.low=p}var k=d[0],C=i[0];for(k.high=C.high,k.low=C.low,h=0;h<5;h++)for(v=0;v<5;v++){var A=i[w=h+5*v],x=d[w],P=d[(h+1)%5+5*v],O=d[(h+2)%5+5*v];A.high=x.high^~P.high&O.high,A.low=x.low^~P.low&O.low}A=i[0];var E=u[o];A.high^=E.high,A.low^=E.low}},_doFinalize:function(){var t=this._data,i=t.words,r=(this._nDataBytes,8*t.sigBytes),n=32*this.blockSize;i[r>>>5]|=1<<24-r%32,i[(e.ceil((r+1)/n)*n>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var a=this._state,o=this.cfg.outputLength/8,c=o/8,l=[],u=0;u<c;u++){var d=a[u],h=d.high,f=d.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),l.push(f),l.push(h)}return new s.init(l,o)},clone:function(){for(var e=n.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=n._createHelper(h),t.HmacSHA3=n._createHmacHelper(h)}(Math),r.SHA3)},function(e,t,i){var r;e.exports=(r=i(0),
1
+ module.exports=function(e){var t={};function i(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(r,s,function(t){return e[t]}.bind(null,s));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=16)}([function(e,t,i){(function(t){var r;e.exports=(r=r||function(e,r){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&void 0!==t&&t.crypto&&(s=t.crypto),!s)try{s=i(34)}catch(e){}var n=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),o={},c=o.lib={},l=c.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=l.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,s=e.sigBytes;if(this.clamp(),r%4)for(var n=0;n<s;n++){var a=i[n>>>2]>>>24-n%4*8&255;t[r+n>>>2]|=a<<24-(r+n)%4*8}else for(var o=0;o<s;o+=4)t[r+o>>>2]=i[o>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(n());return new u.init(t,e)}}),d=o.enc={},h=d.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(i,t/2)}},f=d.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(i,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},v=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i,r=this._data,s=r.words,n=r.sigBytes,a=this.blockSize,o=n/(4*a),c=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,l=e.min(4*c,n);if(c){for(var d=0;d<c;d+=a)this._doProcessBlock(s,d);i=s.splice(0,c),r.sigBytes-=l}return new u.init(i,l)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(c.Hasher=v.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new g.HMAC.init(e,i).finalize(t)}}}),o.algo={});return o}(Math),r)}).call(this,i(33))},function(e,t,i){var r,s,n,a,o,c,l,u,d,h,f,p,v,g,y,_,D,m,w;e.exports=(r=i(0),i(3),void(r.lib.Cipher||(s=r,n=s.lib,a=n.Base,o=n.WordArray,c=n.BufferedBlockAlgorithm,l=s.enc,l.Utf8,u=l.Base64,d=s.algo.EvpKDF,h=n.Cipher=c.extend({cfg:a.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){c.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?w:D}return function(t){return{encrypt:function(i,r,s){return e(r).encrypt(t,i,r,s)},decrypt:function(i,r,s){return e(r).decrypt(t,i,r,s)}}}}()}),n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),f=s.mode={},p=n.BlockCipherMode=a.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),v=f.CBC=function(){var e=p.extend();function t(e,t,i){var r,s=this._iv;s?(r=s,this._iv=void 0):r=this._prevBlock;for(var n=0;n<i;n++)e[t+n]^=r[n]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s),r.encryptBlock(e,i),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);r.decryptBlock(e,i),t.call(this,e,i,s),this._prevBlock=n}}),e}(),g=(s.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,r=i-e.sigBytes%i,s=r<<24|r<<16|r<<8|r,n=[],a=0;a<r;a+=4)n.push(s);var c=o.create(n,r);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:v,padding:g}),reset:function(){var e;h.reset.call(this);var t=this.cfg,i=t.iv,r=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(r,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),y=n.CipherParams=a.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(s.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;return(i?o.create([1398893684,1701076831]).concat(i).concat(t):t).toString(u)},parse:function(e){var t,i=u.parse(e),r=i.words;return 1398893684==r[0]&&1701076831==r[1]&&(t=o.create(r.slice(2,4)),r.splice(0,4),i.sigBytes-=16),y.create({ciphertext:i,salt:t})}},D=n.SerializableCipher=a.extend({cfg:a.extend({format:_}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var s=e.createEncryptor(i,r),n=s.finalize(t),a=s.cfg;return y.create({ciphertext:n,key:i,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(s.kdf={}).OpenSSL={execute:function(e,t,i,r){r||(r=o.random(8));var s=d.create({keySize:t+i}).compute(e,r),n=o.create(s.words.slice(t),4*i);return s.sigBytes=4*t,y.create({key:s,iv:n,salt:r})}},w=n.PasswordBasedCipher=D.extend({cfg:D.cfg.extend({kdf:m}),encrypt:function(e,t,i,r){var s=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=s.iv;var n=D.encrypt.call(this,e,t,s.key,r);return n.mixIn(s),n},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var s=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=s.iv,D.decrypt.call(this,e,t,s.key,r)}}))))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.checkHeader=e=>{let t=0;return 0===e[0]&&0===e[1]&&0===e[2]&&3===e[3]&&(t=4,4)};t.getProtocolLen=e=>{let t=0;for(;t<e.length&&"1"===r(e[t].toString(2),8)[0];t++);return t+1},t.arrayToString=function(e){let t="";return e.map(e=>(t+=r(e.toString(16),2),null)),t};const r=(e,t,i=!1)=>{const r=t-e.length,s=new Array(r).fill(0).join("");return i?e+=s:e=s+e,e};t.fillString=r;t.string2Bytes=e=>{const t=[];for(let i=0;i<e.length;i++)t.push(e.charCodeAt(i));return t};t.hexStrint2byte=e=>{const t=Math.ceil(e.length/2),i=[];for(let r=0;r<t;r++){const t=2*r,s=t+2,n=e.substring(t,s);i.push(parseInt(n,16))}return i};const s=e=>{const t=encodeURI(e);return-1!==t.indexOf("%")&&"%"!==e?t.split("%").filter(e=>""!==e).map(e=>parseInt(e,16)):[t.charCodeAt(0)]};t.formatCode=s;t.formatCodesFromStr=e=>{const t=[0,0];let i=[];for(let r=0;r<e.length;r++){const n=s(e[r]);t[1]+=n.length,i=i.concat(n)}return[i,t]}},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(14),i(15),s=(r=u).lib,n=s.Base,a=s.WordArray,o=r.algo,c=o.MD5,l=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,r=this.cfg,s=r.hasher.create(),n=a.create(),o=n.words,c=r.keySize,l=r.iterations;o.length<c;){i&&s.update(i),i=s.update(e).finalize(t),s.reset();for(var u=1;u<l;u++)i=s.finalize(i),s.reset();n.concat(i)}return n.sigBytes=4*c,n}}),r.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},u.EvpKDF)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var s=[],n=0;n<i;n+=3)for(var a=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,o=0;o<4&&n+.75*o<i;o++)s.push(r.charAt(a>>>6*(3-o)&63));var c=r.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var n=0;n<i.length;n++)r[i.charCodeAt(n)]=n}var a=i.charAt(64);if(a){var o=e.indexOf(a);-1!==o&&(t=o)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2,c=i[e.charCodeAt(a)]>>>6-a%4*2,l=o|c;r[n>>>2]|=l<<24-n%4*8,n++}return s.create(r,n)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[];!function(){for(var t=0;t<64;t++)o[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,a=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],v=e[t+4],g=e[t+5],y=e[t+6],_=e[t+7],D=e[t+8],m=e[t+9],w=e[t+10],S=e[t+11],b=e[t+12],B=e[t+13],I=e[t+14],k=e[t+15],C=n[0],A=n[1],x=n[2],E=n[3];C=l(C,A,x,E,a,7,o[0]),E=l(E,C,A,x,c,12,o[1]),x=l(x,E,C,A,f,17,o[2]),A=l(A,x,E,C,p,22,o[3]),C=l(C,A,x,E,v,7,o[4]),E=l(E,C,A,x,g,12,o[5]),x=l(x,E,C,A,y,17,o[6]),A=l(A,x,E,C,_,22,o[7]),C=l(C,A,x,E,D,7,o[8]),E=l(E,C,A,x,m,12,o[9]),x=l(x,E,C,A,w,17,o[10]),A=l(A,x,E,C,S,22,o[11]),C=l(C,A,x,E,b,7,o[12]),E=l(E,C,A,x,B,12,o[13]),x=l(x,E,C,A,I,17,o[14]),C=u(C,A=l(A,x,E,C,k,22,o[15]),x,E,c,5,o[16]),E=u(E,C,A,x,y,9,o[17]),x=u(x,E,C,A,S,14,o[18]),A=u(A,x,E,C,a,20,o[19]),C=u(C,A,x,E,g,5,o[20]),E=u(E,C,A,x,w,9,o[21]),x=u(x,E,C,A,k,14,o[22]),A=u(A,x,E,C,v,20,o[23]),C=u(C,A,x,E,m,5,o[24]),E=u(E,C,A,x,I,9,o[25]),x=u(x,E,C,A,p,14,o[26]),A=u(A,x,E,C,D,20,o[27]),C=u(C,A,x,E,B,5,o[28]),E=u(E,C,A,x,f,9,o[29]),x=u(x,E,C,A,_,14,o[30]),C=d(C,A=u(A,x,E,C,b,20,o[31]),x,E,g,4,o[32]),E=d(E,C,A,x,D,11,o[33]),x=d(x,E,C,A,S,16,o[34]),A=d(A,x,E,C,I,23,o[35]),C=d(C,A,x,E,c,4,o[36]),E=d(E,C,A,x,v,11,o[37]),x=d(x,E,C,A,_,16,o[38]),A=d(A,x,E,C,w,23,o[39]),C=d(C,A,x,E,B,4,o[40]),E=d(E,C,A,x,a,11,o[41]),x=d(x,E,C,A,p,16,o[42]),A=d(A,x,E,C,y,23,o[43]),C=d(C,A,x,E,m,4,o[44]),E=d(E,C,A,x,b,11,o[45]),x=d(x,E,C,A,k,16,o[46]),C=h(C,A=d(A,x,E,C,f,23,o[47]),x,E,a,6,o[48]),E=h(E,C,A,x,_,10,o[49]),x=h(x,E,C,A,I,15,o[50]),A=h(A,x,E,C,g,21,o[51]),C=h(C,A,x,E,b,6,o[52]),E=h(E,C,A,x,p,10,o[53]),x=h(x,E,C,A,w,15,o[54]),A=h(A,x,E,C,c,21,o[55]),C=h(C,A,x,E,D,6,o[56]),E=h(E,C,A,x,k,10,o[57]),x=h(x,E,C,A,y,15,o[58]),A=h(A,x,E,C,B,21,o[59]),C=h(C,A,x,E,v,6,o[60]),E=h(E,C,A,x,S,10,o[61]),x=h(x,E,C,A,f,15,o[62]),A=h(A,x,E,C,m,21,o[63]),n[0]=n[0]+C|0,n[1]=n[1]+A|0,n[2]=n[2]+x|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;i[s>>>5]|=128<<24-s%32;var n=e.floor(r/4294967296),a=r;i[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),i[14+(s+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(i.length+1),this._process();for(var o=this._hash,c=o.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return o},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,i,r,s,n,a){var o=e+(t&i|~t&r)+s+a;return(o<<n|o>>>32-n)+t}function u(e,t,i,r,s,n,a){var o=e+(t&r|i&~r)+s+a;return(o<<n|o>>>32-n)+t}function d(e,t,i,r,s,n,a){var o=e+(t^i^r)+s+a;return(o<<n|o>>>32-n)+t}function h(e,t,i,r,s,n,a){var o=e+(i^(t|~r))+s+a;return(o<<n|o>>>32-n)+t}t.MD5=n._createHelper(c),t.HmacMD5=n._createHmacHelper(c)}(Math),r.MD5)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(2);t.default=class{constructor(e){this.header="",this.len=0,this.flag=[0],this.cmd="",this.content=[],this.formatP0=e=>{let t=r.checkHeader(e);if(!1===t)throw new Error("Header Error");this.header=r.arrayToString(e.slice(0,t));const i=e.slice(t,e.length),s=r.getProtocolLen(i);this.len=parseInt(r.arrayToString(i.slice(0,s)),16),t+=s,this.flag=e.slice(t,t+1),t+=1,this.cmd=r.arrayToString(e.slice(t,t+2)),t+=2,this.content=e.slice(t,e.length)},e&&e.length>0&&this.formatP0(e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={GIZ_OPENAPI_DEVICE_NOT_BOUND:{errorCode:9017,errorMessage:"not bind"},GIZ_SDK_HTTP_REQUEST_FAILED:{errorCode:8099,errorMessage:"网络请求失败"},GIZ_SDK_SDK_NOT_INITIALIZED:{errorCode:8300,errorMessage:"not init"},CONFIG_TIME_OUT:{errorCode:8023,errorMessage:"Config Timeout"},WECHAT_ERROR:{errorCode:1e4,errorMessage:"wechat error"},GIZ_SDK_ONBOARDING_STOPPED:{errorCode:8318,errorMessage:"配网中断"},GIZ_SDK_DEVICE_CONFIG_IS_RUNNING:{errorCode:8022,errorMessage:"配置正在进行中"},GIZ_OPENAPI_TOKEN_INVALID:{errorCode:9004,errorMessage:"token 失效"},GIZ_SDK_BIND_DEVICE_FAILED:{errorCode:8039,errorMessage:"设备绑定失败"},GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON:{errorCode:8281,errorMessage:"蓝牙未启用"},GIZ_SDK_OTHERWISE:{errorCode:8100,errorMessage:""},GIZ_SDK_DEVICE_NOT_SUBSCRIBED:{errorCode:8029,errorMessage:"设备还未订阅"},GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY:{errorCode:8250,errorMessage:"产品类型不在指定范围内"}}},function(e,t,i){var r,s,n,a,o,c;e.exports=(c=i(0),s=(r=c).lib,n=s.Base,a=s.WordArray,(o=r.x64={}).Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),o.WordArray=n.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var s=e[r];i.push(s.high),i.push(s.low)}return a.create(i,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}}),c)},function(e,t,i){"use strict";function r(e){return Array.prototype.map.call(new Uint8Array(e),(function(e){return("00"+e.toString(16)).slice(-2)})).join("")}Object.defineProperty(t,"__esModule",{value:!0}),t.ab2hex=r,t.compareWXSDKVersion=function(e,t){const i=e.split("."),r=t.split("."),s=Math.max(e.length,t.length);for(;i.length<s;)i.push("0");for(;r.length<s;)r.push("0");for(let i=0;i<s;i++){const r=parseInt(e[i]),s=parseInt(t[i]);if(r>s)return 1;if(r<s)return-1}return 0},t.isError=e=>null!=e&&"symbol"==typeof e.errorCode,t.wrapErrorInfo=e=>({errorCode:e,errorMessage:e}),t.unionBy=(e,t)=>e.reduce((e,i)=>{const r=i[t];return e.some(e=>e[t]===r)||e.push(i),e},[]),t.isWXDevicesResult=function(e){return e.success&&"[object Array]"===Object.prototype.toString.call(e.bleDevices)},t.str2Buf=function(e){var t=e.length,i=new ArrayBuffer(t+2),r=new DataView(i);for(let i=0;i<t;i++)r.setUint8(i,parseInt(e[i],16));return i},t.numberArray2Uint8Array=e=>{const t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let r=0;r<t.byteLength;r++)i[r]=e[r];return i},t.advertisData2PkAndMac=(e,t)=>{let i=e.slice(e.byteLength-16),s=e.slice(0,e.byteLength-16),n=r(i);if(t.find(e=>e===n)){const e=r(s);return{productKey:n,mac:e}}{i=e.slice(0,16),s=e.slice(16),n=r(i);const t=r(s);return{productKey:n,mac:t}}},t.isSameDevice=(e,t)=>e.mac===t.mac&&e.productKey===t.productKey,t.merageBleLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?(r.isBleOnline=!0,r.bleDeviceID=i.bleDeviceID):e.push(i)}),e),t.merageLanLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?r.isLanOnline=!0:e.push(i)}),e),t.BTDevice2GDevice=(e,i)=>{const{productKey:r,mac:s}=t.advertisData2PkAndMac(e.advertisData,i);return{mac:s,did:"",connectType:"NONE",isBleOnline:!0,isLanOnline:!1,isOnline:!1,productKey:r,name:e.name,isBind:!1,bleDeviceID:e.deviceId}},t.getFirstConnectType=(e,t)=>{if(t){if("WAN"===t)return"WAN";switch(t){case"BLE":return e.isBleOnline?"BLE":"NONE";case"LAN":return e.isLanOnline?"LAN":"NONE"}}else{if(e.isLanOnline)return"LAN";if(e.isBleOnline)return"BLE"}return"WAN"},t.getProductInfoThroughPK=(e,t)=>t.find(t=>t.productKey===e),t.mergeObject=(e,t)=>{for(let i in t)null!=t[i]&&""!==t[i]&&(e[i]=t[i]);return e},t.hex2ab=function(e){const t=[];for(let r=0;r<e.length;r+=2){var i=e.slice(r,r+2);t.push(parseInt(i,16))}return new Uint8Array(t)}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=e=>new Promise(t=>setTimeout(()=>t(),e))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12);const s=new class{constructor(){this.data={},this.key="dataPointConfig",this.init=async()=>{const e=await wx.getStorageSync(this.key)||"{}";let t={};try{t=JSON.parse(e)}catch(e){}this.data=t},this.getConfigFile=async e=>{var t;if(!this.data[e]){const i=`/v2/datapoint?product_key=${e}`,s=await r.siteApiRequest(`${i}`,{method:"GET"});if(!s.success||!(null===(t=s.data)||void 0===t?void 0:t.entities))return null;this.data[e]=s.data,wx.setStorageSync(this.key,JSON.stringify(this.data))}return this.data[e]}}};s.init(),t.default=s},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(30),s=i(17),n=i(7);t.siteApiRequest=async(e,t)=>{const i=Object.assign({},t);i.header=Object.assign(Object.assign({},{"Content-Type":"application/json"}),t.headers),delete i.headers;const a=(s.getGlobalData("cloudServiceInfo")||{}).siteInfo||"site.gizwits.com",o=await r.default("http://"+a+e,i);if(o.statusCode>=200&&o.statusCode<300)return{success:!0,data:o.data};let c={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{c={success:!1,err:{errorCode:o.data.error_code,errorMessage:o.data.error_message}}}catch(e){}return c},t.default=async(e,t,i=!0)=>{const a=Object.assign({},t),o={"Content-Type":"application/json","X-Gizwits-Application-Id":s.getGlobalData("appID")};i&&(o["X-Gizwits-User-token"]=s.getGlobalData("token")),a.header=Object.assign(Object.assign({},o),t.headers),delete a.headers;const c=s.getGlobalData("cloudServiceInfo").openAPIInfo,l=await r.default("https://"+c+e,a);if(l.statusCode>=200&&l.statusCode<300)return{success:!0,data:l.data};let u={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{u={success:!1,err:{errorCode:l.data.error_code,errorMessage:l.data.error_message}}}catch(e){}return u}},function(e,t,i){var r;e.exports=(r=i(0),i(8),i(35),i(36),i(4),i(37),i(5),i(14),i(23),i(38),i(24),i(39),i(40),i(41),i(15),i(42),i(3),i(1),i(43),i(44),i(45),i(46),i(47),i(48),i(49),i(50),i(51),i(52),i(53),i(54),i(55),i(56),i(57),i(58),r)},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),s=(r=u).lib,n=s.WordArray,a=s.Hasher,o=r.algo,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],l=0;l<80;l++){if(l<16)c[l]=0|e[t+l];else{var u=c[l-3]^c[l-8]^c[l-14]^c[l-16];c[l]=u<<1|u>>>31}var d=(r<<5|r>>>27)+o+c[l];d+=l<20?1518500249+(s&n|~s&a):l<40?1859775393+(s^n^a):l<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,o=a,a=n,n=s<<30|s>>>2,s=r,r=d}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=a._createHelper(l),r.HmacSHA1=a._createHmacHelper(l),u.SHA1)},function(e,t,i){var r,s,n,a;e.exports=(r=i(0),n=(s=r).lib.Base,a=s.enc.Utf8,void(s.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),n=this._iKey=t.clone(),o=s.words,c=n.words,l=0;l<i;l++)o[l]^=1549556828,c[l]^=909522486;s.sigBytes=n.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i(25);const r=i(26),s=i(7);t.errorCode=s.default;const n=i(18);t.BleHandle=n.BleHandle,t.default=r.default},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={};t.setGlobalData=function(e,t){r[e]=t},t.getGlobalData=function(e){return r[e]}},function(e,t,i){"use strict";var r=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(i[r[s]]=e[r[s]])}return i};Object.defineProperty(t,"__esModule",{value:!0});const s=i(9),n=i(19),a=i(27),o=i(2),c=i(6),l=i(28),u=i(29);t.BleHandle=class{constructor({pks:e=[],bleHandleParams:t={serviceUUIDSuffix:"abf0",characteristicUUIDSuffix:"abf7"},globalListenerMap:i}){this.connectedList=[],this.pks=[],this.tmpBleData="",this.tmpDataNum=0,this.listenerMap={},this.globalListenerMap={},this.scanList=[],this.handleOnBLECharacteristicValueChange=e=>{const t=s.ab2hex(e.value);try{const i=new c.default(o.hexStrint2byte(t));console.log("ProtocolBase",i.len,e.value.byteLength),this.tmpBleData=t,this.tmpDataNum=i.len-e.value.byteLength+4+Math.ceil(i.len.toString(2).length/8)}catch(i){this.tmpBleData&&(this.tmpBleData+=t,this.tmpDataNum-=e.value.byteLength)}this.tmpDataNum>0||!this.tmpBleData||(console.log("ProtocolBase",this.tmpBleData,this.tmpDataNum),this.listenerMap[e.deviceId]&&this.listenerMap[e.deviceId].map(t=>{t(e,this.tmpBleData)}),this.listenerMap.ALL&&(console.log("ProtocolBase1"),this.listenerMap.ALL.map(t=>{console.log("ProtocolBase2"),t(e,this.tmpBleData)})),this.tmpBleData="",this.tmpDataNum=0)},this.notifyError=e=>{var t;null===(t=this.globalListenerMap.onBleHandleError)||void 0===t||t.map(t=>{t(e)})},this.listenConnection=e=>{wx.onBLEConnectionStateChange(t=>{const i=this.connectedList.map(e=>e.deviceId).includes(e)&&t.deviceId===e&&!1===t.connected;console.log("蓝牙状态变化",{connectedList:this.connectedList,res:t,deviceId:e}),i&&this.connectDevice(e)})},this.checkPermission=async()=>{const e=await wx.getBluetoothAdapterState(),{errMsg:t,available:i}=e,n=r(e,["errMsg","available"]);return{data:Object.assign({},n),err:s.wrapErrorInfo(t),success:i}},this.getDeviceStatus=async(e,t,i,r)=>{const n=await u.default.pack(t,i,r);return n?await this.write(e,s.numberArray2Uint8Array(n).buffer):{success:!1}},this.handleBluetoothDeviceFound=(e,t)=>{const i=e.devices.filter(e=>{const{advertisData:t}=e,i=s.ab2hex(t);return this.pks.some(e=>i.includes(e))});if(i.length>0){const e=i.map(e=>s.BTDevice2GDevice(e,this.pks));this.scanList.push(...e),t(this.scanList)}},this.startScan=async(e,t=5e3)=>new Promise(async i=>{wx.onBluetoothDeviceFound(t=>{this.handleBluetoothDeviceFound(t,e)}),await wx.startBluetoothDevicesDiscovery({powerLevel:"high"}),setTimeout(()=>{this.stopScan(),i({scanList:this.scanList})},t)}),this.stopScan=async()=>{const{errMsg:e,errCode:t}=await wx.stopBluetoothDevicesDiscovery();return{errMsg:e,errCode:t}},this.connectDevice=async e=>{var t;const i=await wx.createBLEConnection({deviceId:e}).catch(t=>{this.removeDevById(e),this.notifyError(t)});if("createBLEConnection:ok"!==i.errMsg)return{success:!1,message:null==i?void 0:i.errMsg};this.listenConnection(e);const r=await wx.getBLEDeviceServices({deviceId:e}).catch(e=>this.notifyError(e)),n=null===(t=null==r?void 0:r.services.find(e=>e.isPrimary&&e.uuid.toLowerCase().includes(this.serviceUUIDSuffix)))||void 0===t?void 0:t.uuid;if(!n)return{message:"can not find valid serviceId",success:!1};const o=await wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:n}).catch(e=>this.notifyError(e));console.log({getCharRes:o});const c=null==o?void 0:o.characteristics[0].uuid;this.connectedList.every(t=>t.deviceId!==e)&&this.connectedList.push({deviceId:e,serviceId:n,characteristicId:c});await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:n,characteristicId:c,state:!0,type:"notification"}).catch(e=>this.notifyError(e));this.write(e,s.numberArray2Uint8Array(a.default.pack()).buffer);const u=await this.handleBindReq(e);if(u.success){this.write(e,s.numberArray2Uint8Array(l.default.pack({passcode:u.data})).buffer);const t=await this.handleLoginReq(e).catch(e=>this.notifyError(e));if(console.log("loginData",t),null==t?void 0:t.success)return{success:!0,message:"ok"}}return{success:!1,message:"ok"}},this.handleBindReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new a.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),n.passcode?t({success:!0,data:n.passcode}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.handleLoginReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new l.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),!0===n.result?t({success:!0,data:n.did}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.removeDeviceListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{message:"ok",success:!0}}return{message:"invalid function",success:!1}},this.addDeviceListener=async(e,t)=>{"ALL"===e&&(this.listenerMap.ALL||(this.listenerMap.ALL=[]),this.listenerMap.ALL.push(t));const{serviceId:i,characteristicId:r,errMsg:s}=this.getTargetDevice(e);return s?{success:!1,message:s}:(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:i,characteristicId:r,state:!0,type:"notification"}).catch(e=>this.notifyError(e)),console.log(`监听设备 ${e} 成功!`),{message:"ok",success:!0})},this.write=async(e,t)=>{console.log("app => dev:",s.ab2hex(t));const{serviceId:i,characteristicId:r}=this.getTargetDevice(e);if(i&&r){return await n.unpackWriteBLECharacteristicValue(e,i,r,t)}return{success:!1,message:"serviceId or characteristicId is unvalid!",errbody:{serviceId:i,characteristicId:r}}},this.disConnectDevice=async e=>{this.removeDevById(e);const{errMsg:t}=await wx.closeBLEConnection({deviceId:e});return"closeBLEConnection:ok"===t?{err:t,success:!0}:{err:t,success:!1}},this.removeDevById=e=>{const t=this.connectedList.findIndex(t=>t.deviceId===e);this.connectedList.splice(t,1)},this.getTargetDevice=e=>{const t=this.connectedList.find(t=>e===t.deviceId);return t||{errMsg:"Unable get this device,maybe you forgot to connect it."}};const{serviceUUIDSuffix:d}=t;this.serviceUUIDSuffix=d,this.pks=e,this.globalListenerMap=i;try{wx.openBluetoothAdapter()}catch(e){console.error(e)}wx.onBLECharacteristicValueChange(this.handleOnBLECharacteristicValueChange)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(10);function s(e,t,i,r){return new Promise(s=>{console.log("writeBLECharacteristicValue"),wx.writeBLECharacteristicValue({deviceId:e,serviceId:t,characteristicId:i,value:r,complete:s})})}t.openBluetoothAdapter=function(){return new Promise((e,t)=>{wx.openBluetoothAdapter({success:e,fail:t})})},t.getBluetoothAdapterState=function(){return new Promise((e,t)=>{wx.getBluetoothAdapterState({success:e,fail:t})})},t.startBluetoothDevicesDiscovery=function(){return new Promise((e,t)=>{wx.startBluetoothDevicesDiscovery({success:e,fail:t,interval:100})})},t.getBluetoothDevices=function(){return new Promise((e,t)=>{wx.getBluetoothDevices({success:({devices:t})=>e(t),fail:t})})},t.createBLEConnection=function(e,t){return new Promise((i,r)=>{wx.createBLEConnection({deviceId:e,timeout:t,success:e=>i(e),fail:e=>{-1===e.errCode?i(e):r(e)}})})},t.getBLEDeviceServices=function(e){return new Promise((t,i)=>{wx.getBLEDeviceServices({deviceId:e,success:({services:e})=>t(e),fail:i})})},t.getBLEDeviceCharacteristics=function(e,t){return new Promise((i,r)=>{wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:t,success:({characteristics:e})=>i(e),fail:r})})},t.notifyBLECharacteristicValueChange=function(e,t,i,r=!0){return new Promise((s,n)=>{wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:t,characteristicId:i,state:r,success:s,fail:n})})},t.writeBLECharacteristicValue=s,t.unpackWriteBLECharacteristicValue=function(e,t,i,n){if(0===n.byteLength)throw new Error("value is not empty");return new Promise(async(a,o)=>{let c,l=0,u=n.byteLength;for(;u>0;){await r.default(30);const a=n.slice(l,l+20);if(l+=20,u-=20,c=await s(e,t,i,a),console.log("unpackWriteBLECharacteristicValue",l/20,c),0!==c.errCode)break}0!==c.errCode?o(c):a(c)})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e)}}n.pack=(e,t)=>{const i=[],[r,n]=s.formatCodesFromStr(e),[a,o]=s.formatCodesFromStr(t),c=[0].concat([0,1],n,r,o,a);let l=c.length;for(;l>0;)i.push(l),l-=255;const u=[0,0,0,3].concat(i).concat(c),d=new ArrayBuffer(u.length),h=new Uint8Array(d);for(let e=0;e<d.byteLength;e++)h[e]=u[e];return h},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(10),s=i(7),n=i(22);t.default=class{constructor(e,t,i,a){this.ssid="",this.password="",this.specialProductKeys=[],this.disableSearchDevice=!1,this.specialProductKeySecrets=[],this.timeoutHandler=null,this.setDeviceOnboardingDeployRej=()=>{},this.cleanTimeout=()=>{this.disableSearchDevice=!0,this.timeoutHandler&&clearTimeout(this.timeoutHandler)},this.stopDeviceOnboardingDeploy=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:s.default.GIZ_SDK_ONBOARDING_STOPPED}),this.cleanTimeout()},this.hasTimeoutHandler=e=>!!this.timeoutHandler&&(e&&e({success:!1,err:s.default.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING}),!0),this.handleTimeout=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:{errorCode:s.default.CONFIG_TIME_OUT,errorMessage:"time out"}})},this.searchDevice=({ssid:e,password:t})=>new Promise((i,a)=>{console.debug("GIZ_SDK: 开始大循环搜索设备");const o=async()=>{var c;try{const l=await n.checkDeviceRegister({SSID:e,password:t,productKeys:this.specialProductKeys});if((null===(c=l.err)||void 0===c?void 0:c.errorCode)===s.default.GIZ_OPENAPI_TOKEN_INVALID.errorCode)return void a({success:!1,err:s.default.GIZ_OPENAPI_TOKEN_INVALID});l.err||0===l.data.length?(console.debug("GIZ_SDK: 大循环没有发现设备"),await r.default(1500),!this.disableSearchDevice&&o()):(console.debug("GIZ_SDK: 大循环搜索到设备",l),i({success:!0,data:l.data}))}catch(e){await r.default(3e3),!this.disableSearchDevice&&o()}};o()}),this.initDeviceOnboardingDeploy=(e,t)=>{this.setDeviceOnboardingDeployRej=t,this.disableSearchDevice=!1},this.startTimeoutTimer=e=>{this.timeoutHandler=setTimeout(this.handleTimeout,1e3*e)},this.bindDevices=e=>(console.log("GIZ_SDK: start bind device"),new Promise(async(t,i)=>{const r=e.map(e=>{const t=this.specialProductKeys.findIndex(t=>e.productKey===t);if(-1===t)return;const i=this.specialProductKeySecrets[t];return n.bindMac({mac:e.mac,productKey:e.productKey,productSecret:i})});try{const n=await Promise.all(r),a=e.filter((e,t)=>{const i=n[t];return i&&i.success});a.length>0?(console.log("GIZ_SDK: bind device success",a),t({success:!0,data:a})):(console.log("GIZ_SDK: bind device error",n),i({success:!1,data:e,err:s.default.GIZ_SDK_BIND_DEVICE_FAILED}))}catch(e){i(e)}})),this.ssid=e,this.password=t,this.specialProductKeys=i,this.specialProductKeySecrets=a}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12),s=i(32),n=i(59),a=i(13);t.getBindingList=async()=>{const e=await r.default("/app/bindings?show_disabled=0&limit=1000&skip=0",{method:"GET"});if(e.success){return{success:!0,data:e.data.devices.map(e=>({productKey:e.product_key,mac:e.mac,did:e.did,isBleOnline:!1,isLanOnline:!1,connectType:"NONE",name:e.dev_alias,isBind:!0,isOnline:e.is_online}))}}return{success:!1,err:e.err}},t.bindMac=async function({mac:e,productKey:t,productSecret:i,alias:s,beOwner:a}){const o={mac:e,product_key:t,dev_alias:s,set_owner:a},{Signature:c,timestamp:l}=n.psKeySign(i);return await r.default("/app/bind_mac",{method:"POST",data:o,headers:{"X-Gizwits-Signature":c,"X-Gizwits-Timestamp":l}})},t.unbindDevice=async function({devices:e}){return await r.default("/app/bindings",{method:"DELETE",data:{devices:e.map(e=>({did:e.did}))}})},t.checkDeviceRegister=async function({SSID:e,password:t,productKeys:i}){const n=s.default({SSID:e,password:t,pks:i});let a="";return n.map(e=>{a+=`${e},`}),a=a.substring(0,a.length-1),await r.default(`/app/device_register?random_codes=${a}`,{method:"get"})},t.safeRegister=async function({productKey:e,productSecret:t,mac:i,passcode:s,gwDid:n,isReset:o}){let c=`is_reset=${o?1:0}&mac=${i}&passcode=${s}`;n&&(c+=`&gw_did=${n}`);const l=a.enc.Hex.parse(t),u=a.enc.Hex.parse(""),d=a.enc.Utf8.parse(c),h=a.AES.encrypt(d,l,{iv:u,mode:a.mode.ECB,padding:a.pad.Pkcs7}).ciphertext.toString().toUpperCase(),f=await r.default(`/dev/${e}/device`,{method:"POST",data:{data:h},headers:{"content-type":"application/x-www-form-urlencoded"}},!1);return f.success?{success:!0,data:{successDevices:[],failedDevices:[]}}:{success:!1,err:f.err}}},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[],c=[];!function(){function t(t){for(var i=e.sqrt(t),r=2;r<=i;r++)if(!(t%r))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var r=2,s=0;s<64;)t(r)&&(s<8&&(o[s]=i(e.pow(r,.5))),c[s]=i(e.pow(r,1/3)),s++),r++}();var l=[],u=a.SHA256=n.extend({_doReset:function(){this._hash=new s.init(o.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=0;f<64;f++){if(f<16)l[f]=0|e[t+f];else{var p=l[f-15],v=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=l[f-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[f]=v+l[f-7]+y+l[f-16]}var _=r&s^r&n^s&n,D=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),m=h+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&d)+c[f]+l[f];h=d,d=u,u=o,o=a+m|0,a=n,n=s,s=r,r=m+(D+_)|0}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0,i[5]=i[5]+u|0,i[6]=i[6]+d|0,i[7]=i[7]+h|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;return i[s>>>5]|=128<<24-s%32,i[14+(s+64>>>9<<4)]=e.floor(r/4294967296),i[15+(s+64>>>9<<4)]=r,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(u),t.HmacSHA256=n._createHmacHelper(u)}(Math),r.SHA256)},function(e,t,i){var r;e.exports=(r=i(0),i(8),function(){var e=r,t=e.lib.Hasher,i=e.x64,s=i.Word,n=i.WordArray,a=e.algo;function o(){return s.create.apply(s,arguments)}var c=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],l=[];!function(){for(var e=0;e<80;e++)l[e]=o()}();var u=a.SHA512=t.extend({_doReset:function(){this._hash=new n.init([new s.init(1779033703,4089235720),new s.init(3144134277,2227873595),new s.init(1013904242,4271175723),new s.init(2773480762,1595750129),new s.init(1359893119,2917565137),new s.init(2600822924,725511199),new s.init(528734635,4215389547),new s.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=r.high,p=r.low,v=s.high,g=s.low,y=n.high,_=n.low,D=a.high,m=a.low,w=o.high,S=o.low,b=u.high,B=u.low,I=d.high,k=d.low,C=h.high,A=h.low,x=f,E=p,P=v,L=g,O=y,M=_,T=D,H=m,K=w,R=S,N=b,U=B,G=I,z=k,j=C,F=A,W=0;W<80;W++){var Z,V,X=l[W];if(W<16)V=X.high=0|e[t+2*W],Z=X.low=0|e[t+2*W+1];else{var $=l[W-15],q=$.high,Y=$.low,J=(q>>>1|Y<<31)^(q>>>8|Y<<24)^q>>>7,Q=(Y>>>1|q<<31)^(Y>>>8|q<<24)^(Y>>>7|q<<25),ee=l[W-2],te=ee.high,ie=ee.low,re=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,se=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),ne=l[W-7],ae=ne.high,oe=ne.low,ce=l[W-16],le=ce.high,ue=ce.low;V=(V=(V=J+ae+((Z=Q+oe)>>>0<Q>>>0?1:0))+re+((Z+=se)>>>0<se>>>0?1:0))+le+((Z+=ue)>>>0<ue>>>0?1:0),X.high=V,X.low=Z}var de,he=K&N^~K&G,fe=R&U^~R&z,pe=x&P^x&O^P&O,ve=E&L^E&M^L&M,ge=(x>>>28|E<<4)^(x<<30|E>>>2)^(x<<25|E>>>7),ye=(E>>>28|x<<4)^(E<<30|x>>>2)^(E<<25|x>>>7),_e=(K>>>14|R<<18)^(K>>>18|R<<14)^(K<<23|R>>>9),De=(R>>>14|K<<18)^(R>>>18|K<<14)^(R<<23|K>>>9),me=c[W],we=me.high,Se=me.low,be=j+_e+((de=F+De)>>>0<F>>>0?1:0),Be=ye+ve;j=G,F=z,G=N,z=U,N=K,U=R,K=T+(be=(be=(be=be+he+((de+=fe)>>>0<fe>>>0?1:0))+we+((de+=Se)>>>0<Se>>>0?1:0))+V+((de+=Z)>>>0<Z>>>0?1:0))+((R=H+de|0)>>>0<H>>>0?1:0)|0,T=O,H=M,O=P,M=L,P=x,L=E,x=be+(ge+pe+(Be>>>0<ye>>>0?1:0))+((E=de+Be|0)>>>0<de>>>0?1:0)|0}p=r.low=p+E,r.high=f+x+(p>>>0<E>>>0?1:0),g=s.low=g+L,s.high=v+P+(g>>>0<L>>>0?1:0),_=n.low=_+M,n.high=y+O+(_>>>0<M>>>0?1:0),m=a.low=m+H,a.high=D+T+(m>>>0<H>>>0?1:0),S=o.low=S+R,o.high=w+K+(S>>>0<R>>>0?1:0),B=u.low=B+U,u.high=b+N+(B>>>0<U>>>0?1:0),k=d.low=k+z,d.high=I+G+(k>>>0<z>>>0?1:0),A=h.low=A+F,h.high=C+j+(A>>>0<F>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(r+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(u),e.HmacSHA512=t._createHmacHelper(u)}(),r.SHA512)},function(e,t){},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(17),s=i(18),n=i(31),a=i(60),o=i(16),c=i(61),l=i(22),u=i(9),d=i(11),h=i(62),f=i(2);t.default=class{constructor({appID:e,appSecret:t,productInfo:i,cloudServiceInfo:p,token:v,uid:g}){this.version="1.0.0",this.listenerMap={},this._deviceList=[],this._bleDevices=[],this._udpDevices=[],this.productInfo=[],this.autoScanInterval=null,this.handleBleDeviceData=async(e,t)=>{const i=this.allDevices.find(t=>t.bleDeviceID===e.deviceId);if(i){const e=await h.unpack(f.hexStrint2byte(t),i.productKey);(null==e?void 0:e.kvData)&&this.listenerMap.GizDeviceAttrsNotifications&&this.listenerMap.GizDeviceAttrsNotifications.map(t=>{t({device:i,data:null==e?void 0:e.kvData})})}},this.notiDeviveList=()=>{var e,t;null===(e=this.listenerMap.GizDeviceListNotifications)||void 0===e||e.map(e=>{e(this.allDevices)}),null===(t=this.listenerMap.onScanListChange)||void 0===t||t.map(e=>{console.log("this.scanBleDevice",this.bleScanDevice),e(this.bleScanDevice)})},this.startAutoScan=()=>{this.autoScanInterval&&clearInterval(this.autoScanInterval),this.autoScanInterval=setInterval(async()=>{const e=await this.bleHandle.startScan(()=>{},4e3);this.bleDevices=e.scanList},6e3)},this.stopAutoScan=()=>{this.autoScanInterval&&clearInterval(this.autoScanInterval)},this.setDeviceMeta=(e,t,i)=>{this.allDevices.find(t=>t.mac===e.mac)[t]=i,this.notiDeviveList()},this.getVersion=()=>({success:!0,data:this.version}),this.initBle=async()=>{const e=await this.bleHandle.checkPermission();return e.success?(this.bleHandle.addDeviceListener("ALL",this.handleBleDeviceData),console.debug("init BLE succcess",e),{success:!0}):(console.error("init BLE Error",e),{success:!1,err:o.errorCode.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON})},this.scanBleDevice=async e=>{console.debug("start scanBleDevice");const t=await this.bleHandle.startScan(e=>{this.bleDevices=e},e);return console.debug("scanBleDevice",t),{success:!0,data:t.scanList}},this.write=async(e,t)=>{if(e&&e.connectType&&"NONE"!==e.connectType)switch(e.connectType){case"BLE":{const i=await h.pack(t,e.productKey);i&&(console.log("write cmd",i,t),this.bleHandle.write(e.bleDeviceID,u.numberArray2Uint8Array(i).buffer));break}}},this.getProductConfig=async e=>{const t=await d.default.getConfigFile(e);return t?{success:!0,data:t}:{success:!1}},this.stopScanBleDevice=()=>{this.bleHandle.stopScan()},this.login=async e=>{var t,i;const s=await c.AnonymousLogin({uid:e});return s.success&&(r.setGlobalData("token",null===(t=s.data)||void 0===t?void 0:t.token),r.setGlobalData("uid",null===(i=s.data)||void 0===i?void 0:i.uid)),s},this.getDeviceStatus=async(e,t)=>{const i=this.allDevices.find(t=>u.isSameDevice(t,e));if(i)switch(i.connectType){case"BLE":return await this.bleHandle.getDeviceStatus(i.bleDeviceID,i.productKey,i.rootDeviceId,t)}return{success:!1,message:"target is undefind"}},this.subscribe=async(e,t,i=!0)=>{switch(u.getFirstConnectType(e,t)){case"BLE":{const t=this.bleDevices.find(t=>u.isSameDevice(t,e));if(t){const e=await this.bleHandle.connectDevice(t.bleDeviceID);return e.success&&setTimeout(()=>{this.setDeviceMeta(t,"connectType","BLE"),this.getDeviceStatus(t)},500),e}}}return{success:!1}},this.unSubscribe=async e=>{switch(e.connectType){case"BLE":{const t=await this.bleHandle.disConnectDevice(e.bleDeviceID);return t.success&&this.setDeviceMeta(e,"connectType","NONE"),t}}return{success:!1}},this.bindRemoteDevice=async({mac:e,productKey:t,alias:i,beOwner:r})=>{const s=u.getProductInfoThroughPK(t,this.productInfo);if(s){const n=await l.bindMac({mac:e,productKey:t,productSecret:s.productSecrets,alias:i,beOwner:r});return this.getBindingList(),n}return{success:!1,err:o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY}},this.unbindDevice=async({devices:e})=>{const t=await l.unbindDevice({devices:e});return t.success&&this.getBindingList(),t},this.deviceSafetyRegister=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!1}),this.deviceSafetyUnbind=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!0}),this.setDeviceOnboardingDeploy=async({ssid:e,password:t,mode:i=0,timeout:r,isBind:s=!0,softAPSSIDPrefix:c})=>{if(this.currentWifiConfigHandle)return{success:!1,err:o.errorCode.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING};const l=(new Date).getTime();console.debug("GIZ_SDK: 配网开始时间:"+l);try{switch(i){case 0:{this.currentWifiConfigHandle=new n.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});this.currentWifiConfigHandle=null;const a=(new Date).getTime();return console.debug("GIZ_SDK: 配网结束时间:"+a),console.debug("GIZ_SDK: 配网用时:"+(a-l)),i}case 3:{this.currentWifiConfigHandle=new a.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});this.currentWifiConfigHandle=null;const n=(new Date).getTime();return console.debug("GIZ_SDK: 配网结束时间:"+n),console.debug("GIZ_SDK: 配网用时:"+(n-l)),i}}}catch(e){return console.error(e),e.err&&e.err.errorCode?e:{success:!1,err:o.errorCode.GIZ_SDK_OTHERWISE}}finally{this.currentWifiConfigHandle=null}},this.setDomain=e=>{const t=e&&e.openAPIInfo||"api.gizwits.com",i=e&&e.siteInfo||"site.gizwits.com",s=Object.assign(Object.assign({},e||{}),{openAPIInfo:t,siteInfo:i});r.setGlobalData("cloudServiceInfo",s)},this.deviceSafetyApi=async({mac:e,productKey:t,isReset:i})=>{const r=u.getProductInfoThroughPK(t,this.productInfo);return r?await l.safeRegister({productKey:t,productSecret:r.productSecrets,mac:e,isReset:i,passcode:"1234567890"}):{success:!1,err:o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY}},this.getBindingList=async()=>{const e=await l.getBindingList();this.devieList=e.data||[]},this.getDevices=async()=>(await this.getBindingList(),{success:!0,data:this.allDevices}),this.stopDeviceOnboardingDeploy=()=>{this.currentWifiConfigHandle&&(this.currentWifiConfigHandle.stopDeviceOnboardingDeploy(),this.currentWifiConfigHandle=null)},this.removeEventListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{success:!0}}return{success:!1}},this.addEventListener=async(e,t)=>(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),{success:!0}),this.productInfo=i,r.setGlobalData("appID",e),r.setGlobalData("appSecret",t),r.setGlobalData("productInfo",i),r.setGlobalData("token",v),r.setGlobalData("uid",g),this.bleHandle=new s.BleHandle({pks:this.specialProductKeys,globalListenerMap:this.listenerMap}),this.setDomain(p),console.debug(`init sdk success, current version: ${this.version}`)}get devieList(){return this._deviceList}set devieList(e){this._deviceList=e,this.notiDeviveList()}get bleDevices(){return this._bleDevices}set bleDevices(e){this._bleDevices=e,this.notiDeviveList()}get udpDevices(){return this._udpDevices}set udpDevices(e){this._udpDevices=e,this.notiDeviveList()}get allDevices(){let e=u.merageBleLocalDevices([...this.devieList],this.bleDevices);return e=u.merageLanLocalDevices(e,this.udpDevices),this.bleHandle.connectedList.map(t=>{const i=e.findIndex(e=>e.bleDeviceID===t.deviceId);-1!==i&&(e[i].connectType="BLE")}),e}set allDevice(e){this.allDevice=e,this.notiDeviveList()}get bleScanDevice(){return this.bleDevices.filter(e=>!0===e.isBleOnline)}get specialProductKeys(){return this.productInfo.map(e=>{var t;return null!==(t=e.productKey)&&void 0!==t?t:""})}get specialProductKeySecrets(){return this.productInfo.map(e=>{var t;return null!==(t=e.productSecrets)&&void 0!==t?t:""})}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.passcode="";let t=0;const i=parseInt(s.arrayToString(this.content.slice(t,t+2)),16);t+=2;let r="";this.content.slice(t,t+i).map(e=>{r+=String.fromCharCode(e)}),this.passcode=r}}n.pack=()=>[0,0,0,3,3,0,0,6],t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.result=!1,this.didLength=0,this.did="";let t=0;if(this.result=0===this.content[0],t++,1===this.flag[0]){this.didLength=parseInt(s.arrayToString(this.content.slice(t,t+2)),16),t+=2;let e="";this.content.slice(t,this.content.length).map(t=>{e+=String.fromCharCode(t)}),this.did=e}}}n.pack=({passcode:e})=>{let t=[0];const i=s.hexStrint2byte(s.fillString(e.length.toString(16),4)),r=s.string2Bytes(e),n=[0].concat([0,8]).concat(i).concat(r);return t=s.hexStrint2byte(n.length.toString(16)),[0,0,0,3].concat(t).concat(n)},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11),s=i(6),n=i(2);class a extends s.default{}a.pack=async(e,t,i)=>{const s=await r.default.getConfigFile(e);if(s){const e="var_len"===s.protocolType,r=[0,0,0,3],a=[0];let o=[0];const c=[0,147];let l=[0,0,0,0],u=[2];if(t){o=[1];const e=n.fillString(t.length.toString(16),4),i=n.hexStrint2byte(e),r=n.string2Bytes(t);l=l.concat(i).concat(r)}if(e){u=[18];let e="";i?s.entities[0].attrs.map(t=>{e=void 0!==i[t.name]?`1${e}`:`0${e}`}):s.entities[0].attrs.map(()=>{e=`1${e}`}),e=n.fillString(e,8*Math.ceil(e.length/8)),u=u.concat(n.hexStrint2byte(parseInt(e,2).toString(16)))}const d=o.concat(c).concat(l).concat(u);return a[0]=d.length,r.concat(a).concat(d)}return null},t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new Promise((i,r)=>{wx.request(Object.assign(Object.assign({url:e,timeout:3e3},t),{success:e=>{i(e)},fail:e=>{r(e)}}))})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(20),n=i(21);class a extends n.default{constructor(){super(...arguments),this.disableSendUDP=!1,this.sendMessageInterval=null,this.UDPSocketHandler=null,this.destroy=()=>{this.cleanTimeout(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.sendMessageInterval=null,this.UDPSocketHandler&&(this.UDPSocketHandler.offError(),this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.close())},this.configDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise((n,a)=>{console.debug("GIZ_SDK: start config device");let o=!1,c=0;const l=s.default.pack(e,t);this.UDPSocketHandler=wx.createUDPSocket(),this.UDPSocketHandler.bind(),this.disableSendUDP=!1;const u=()=>{try{!this.disableSendUDP&&this.UDPSocketHandler.send({address:"10.10.100.254",port:12414,message:l,offset:0,length:l.byteLength})}catch(e){}};this.sendMessageInterval=setInterval(()=>{u()},2e3),this.UDPSocketHandler.onError(e=>{c+=1,c>2&&(this.destroy(),a({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:e.errMsg}}))});const d=async()=>{if(!o){this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.offError(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.disableSendUDP=!0,o=!0;try{const i=await this.searchDevice({ssid:e,password:t});n(i)}catch(e){a(e)}}};this.UDPSocketHandler.onMessage(e=>{d()}),wx.onNetworkStatusChange(async()=>{!o&&wx.getConnectedWifi({success:async e=>{-1===e.wifi.SSID.indexOf(i)&&d()}})})}),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>{const r=this.ssid,s=this.password;return new Promise(async(n,a)=>{this.destroy(),this.initDeviceOnboardingDeploy(n,a),this.startTimeoutTimer(e);try{const e=((await this.configDevice({ssid:r,password:s,softAPSSIDPrefix:i})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));if(t)try{n(await this.bindDevices(e))}catch(e){a(e)}else n({success:!0,data:e})}catch(e){a(e)}finally{this.destroy()}})}}}t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13),s=({SSID:e,password:t,pk:i})=>{let s=r.MD5(e+t).toString();s=r.enc.Hex.parse(s);let n=r.enc.Utf8.parse(i),a=r.AES.encrypt(n,s,{iv:s,mode:r.mode.ECB,padding:r.pad.ZeroPadding});return r.MD5(a.ciphertext).toString()};t.default=({SSID:e,password:t,pks:i})=>{const r=[];return i.map(i=>{const n=s({SSID:e,password:t,pk:i});r.push(n)}),r}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){},function(e,t,i){var r;e.exports=(r=i(0),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,r=[],s=0;s<i;s++)r[s>>>2]|=e[s]<<24-s%4*8;t.call(this,r,i)}else t.apply(this,arguments)}).prototype=e}}(),r.lib.WordArray)},function(e,t,i){var r;e.exports=(r=i(0),function(){var e=r,t=e.lib.WordArray,i=e.enc;function s(e){return e<<8&4278255360|e>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s+=2){var n=t[s>>>2]>>>16-s%4*8&65535;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var i=e.length,r=[],s=0;s<i;s++)r[s>>>1]|=e.charCodeAt(s)<<16-s%2*16;return t.create(r,2*i)}},i.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var a=s(t[n>>>2]>>>16-n%4*8&65535);r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var i=e.length,r=[],n=0;n<i;n++)r[n>>>1]|=s(e.charCodeAt(n)<<16-n%2*16);return t.create(r,2*i)}}}(),r.enc.Utf16)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64url={stringify:function(e,t=!0){var i=e.words,r=e.sigBytes,s=t?this._safe_map:this._map;e.clamp();for(var n=[],a=0;a<r;a+=3)for(var o=(i[a>>>2]>>>24-a%4*8&255)<<16|(i[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|i[a+2>>>2]>>>24-(a+2)%4*8&255,c=0;c<4&&a+.75*c<r;c++)n.push(s.charAt(o>>>6*(3-c)&63));var l=s.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(e,t=!0){var i=e.length,r=t?this._safe_map:this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var a=0;a<r.length;a++)n[r.charCodeAt(a)]=a}var o=r.charAt(64);if(o){var c=e.indexOf(o);-1!==c&&(i=c)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2,c=i[e.charCodeAt(a)]>>>6-a%4*2,l=o|c;r[n>>>2]|=l<<24-n%4*8,n++}return s.create(r,n)}(e,i,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},n.enc.Base64url)},function(e,t,i){var r,s,n,a,o,c;e.exports=(c=i(0),i(23),s=(r=c).lib.WordArray,n=r.algo,a=n.SHA256,o=n.SHA224=a.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=a._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=a._createHelper(o),r.HmacSHA224=a._createHmacHelper(o),c.SHA224)},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(8),i(24),s=(r=u).x64,n=s.Word,a=s.WordArray,o=r.algo,c=o.SHA512,l=o.SHA384=c.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),r.SHA384=c._createHelper(l),r.HmacSHA384=c._createHmacHelper(l),u.SHA384)},function(e,t,i){var r;e.exports=(r=i(0),i(8),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.x64.Word,o=t.algo,c=[],l=[],u=[];!function(){for(var e=1,t=0,i=0;i<24;i++){c[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)l[e+5*t]=t+(2*e+3*t)%5*5;for(var s=1,n=0;n<24;n++){for(var o=0,d=0,h=0;h<7;h++){if(1&s){var f=(1<<h)-1;f<32?d^=1<<f:o^=1<<f-32}128&s?s=s<<1^113:s<<=1}u[n]=a.create(o,d)}}();var d=[];!function(){for(var e=0;e<25;e++)d[e]=a.create()}();var h=o.SHA3=n.extend({cfg:n.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new a.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,s=0;s<r;s++){var n=e[t+2*s],a=e[t+2*s+1];n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),(A=i[s]).high^=a,A.low^=n}for(var o=0;o<24;o++){for(var h=0;h<5;h++){for(var f=0,p=0,v=0;v<5;v++)f^=(A=i[h+5*v]).high,p^=A.low;var g=d[h];g.high=f,g.low=p}for(h=0;h<5;h++){var y=d[(h+4)%5],_=d[(h+1)%5],D=_.high,m=_.low;for(f=y.high^(D<<1|m>>>31),p=y.low^(m<<1|D>>>31),v=0;v<5;v++)(A=i[h+5*v]).high^=f,A.low^=p}for(var w=1;w<25;w++){var S=(A=i[w]).high,b=A.low,B=c[w];B<32?(f=S<<B|b>>>32-B,p=b<<B|S>>>32-B):(f=b<<B-32|S>>>64-B,p=S<<B-32|b>>>64-B);var I=d[l[w]];I.high=f,I.low=p}var k=d[0],C=i[0];for(k.high=C.high,k.low=C.low,h=0;h<5;h++)for(v=0;v<5;v++){var A=i[w=h+5*v],x=d[w],E=d[(h+1)%5+5*v],P=d[(h+2)%5+5*v];A.high=x.high^~E.high&P.high,A.low=x.low^~E.low&P.low}A=i[0];var L=u[o];A.high^=L.high,A.low^=L.low}},_doFinalize:function(){var t=this._data,i=t.words,r=(this._nDataBytes,8*t.sigBytes),n=32*this.blockSize;i[r>>>5]|=1<<24-r%32,i[(e.ceil((r+1)/n)*n>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var a=this._state,o=this.cfg.outputLength/8,c=o/8,l=[],u=0;u<c;u++){var d=a[u],h=d.high,f=d.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),l.push(f),l.push(h)}return new s.init(l,o)},clone:function(){for(var e=n.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=n._createHelper(h),t.HmacSHA3=n._createHmacHelper(h)}(Math),r.SHA3)},function(e,t,i){var r;e.exports=(r=i(0),
2
2
  /** @preserve
3
3
  (c) 2012 by Cédric Mesnil. All rights reserved.
4
4
 
@@ -9,27 +9,10 @@ module.exports=function(e){var t={};function i(r){if(t[r])return t[r].exports;va
9
9
 
10
10
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
11
  */
12
- function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=s.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=s.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=s.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=s.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=s.create([0,1518500249,1859775393,2400959708,2840853838]),h=s.create([1352829926,1548603684,1836072691,2053994217,0]),f=a.RIPEMD160=n.extend({_doReset:function(){this._hash=s.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n,a,f,m,w,S,b,B,I,k,C,A=this._hash.words,x=d.words,P=h.words,O=o.words,E=c.words,L=l.words,M=u.words;for(S=n=A[0],b=a=A[1],B=f=A[2],I=m=A[3],k=w=A[4],i=0;i<80;i+=1)C=n+e[t+O[i]]|0,C+=i<16?p(a,f,m)+x[0]:i<32?v(a,f,m)+x[1]:i<48?g(a,f,m)+x[2]:i<64?y(a,f,m)+x[3]:_(a,f,m)+x[4],C=(C=D(C|=0,L[i]))+w|0,n=w,w=m,m=D(f,10),f=a,a=C,C=S+e[t+E[i]]|0,C+=i<16?_(b,B,I)+P[0]:i<32?y(b,B,I)+P[1]:i<48?g(b,B,I)+P[2]:i<64?v(b,B,I)+P[3]:p(b,B,I)+P[4],C=(C=D(C|=0,M[i]))+k|0,S=k,k=I,I=D(B,10),B=b,b=C;C=A[1]+f+I|0,A[1]=A[2]+m+k|0,A[2]=A[3]+w+S|0,A[3]=A[4]+n+b|0,A[4]=A[0]+a+B|0,A[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,n=s.words,a=0;a<5;a++){var o=n[a];n[a]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}return s},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,i){return e^t^i}function v(e,t,i){return e&t|~e&i}function g(e,t,i){return(e|~t)^i}function y(e,t,i){return e&i|t&~i}function _(e,t,i){return e^(t|~i)}function D(e,t){return e<<t|e>>>32-t}t.RIPEMD160=n._createHelper(f),t.HmacRIPEMD160=n._createHmacHelper(f)}(Math),r.RIPEMD160)},function(e,t,i){var r,s,n,a,o,c,l,u,d;e.exports=(d=i(0),i(14),i(15),s=(r=d).lib,n=s.Base,a=s.WordArray,o=r.algo,c=o.SHA1,l=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=l.create(i.hasher,e),s=a.create(),n=a.create([1]),o=s.words,c=n.words,u=i.keySize,d=i.iterations;o.length<u;){var h=r.update(t).finalize(n);r.reset();for(var f=h.words,p=f.length,v=h,g=1;g<d;g++){v=r.finalize(v),r.reset();for(var y=v.words,_=0;_<p;_++)f[_]^=y[_]}s.concat(h),c[0]++}return s.sigBytes=4*u,s}}),r.PBKDF2=function(e,t,i){return u.create(i).compute(e,t)},d.PBKDF2)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.mode.CFB=function(){var e=r.lib.BlockCipherMode.extend();function t(e,t,i,r){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,r.encryptBlock(s,0);for(var a=0;a<i;a++)e[t+a]^=s[a]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s,r),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);t.call(this,e,i,s,r),this._prevBlock=n}}),e}(),r.mode.CFB)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.CTR=(r=n.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._counter;s&&(n=this._counter=s.slice(0),this._iv=void 0);var a=n.slice(0);i.encryptBlock(a,0),n[r-1]=n[r-1]+1|0;for(var o=0;o<r;o++)e[t+o]^=a[o]}}),r.Decryptor=s,r),n.mode.CTR)},function(e,t,i){var r;e.exports=(r=i(0),i(1),
12
+ function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=s.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=s.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=s.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=s.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=s.create([0,1518500249,1859775393,2400959708,2840853838]),h=s.create([1352829926,1548603684,1836072691,2053994217,0]),f=a.RIPEMD160=n.extend({_doReset:function(){this._hash=s.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n,a,f,m,w,S,b,B,I,k,C,A=this._hash.words,x=d.words,E=h.words,P=o.words,L=c.words,O=l.words,M=u.words;for(S=n=A[0],b=a=A[1],B=f=A[2],I=m=A[3],k=w=A[4],i=0;i<80;i+=1)C=n+e[t+P[i]]|0,C+=i<16?p(a,f,m)+x[0]:i<32?v(a,f,m)+x[1]:i<48?g(a,f,m)+x[2]:i<64?y(a,f,m)+x[3]:_(a,f,m)+x[4],C=(C=D(C|=0,O[i]))+w|0,n=w,w=m,m=D(f,10),f=a,a=C,C=S+e[t+L[i]]|0,C+=i<16?_(b,B,I)+E[0]:i<32?y(b,B,I)+E[1]:i<48?g(b,B,I)+E[2]:i<64?v(b,B,I)+E[3]:p(b,B,I)+E[4],C=(C=D(C|=0,M[i]))+k|0,S=k,k=I,I=D(B,10),B=b,b=C;C=A[1]+f+I|0,A[1]=A[2]+m+k|0,A[2]=A[3]+w+S|0,A[3]=A[4]+n+b|0,A[4]=A[0]+a+B|0,A[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,n=s.words,a=0;a<5;a++){var o=n[a];n[a]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}return s},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,i){return e^t^i}function v(e,t,i){return e&t|~e&i}function g(e,t,i){return(e|~t)^i}function y(e,t,i){return e&i|t&~i}function _(e,t,i){return e^(t|~i)}function D(e,t){return e<<t|e>>>32-t}t.RIPEMD160=n._createHelper(f),t.HmacRIPEMD160=n._createHmacHelper(f)}(Math),r.RIPEMD160)},function(e,t,i){var r,s,n,a,o,c,l,u,d;e.exports=(d=i(0),i(14),i(15),s=(r=d).lib,n=s.Base,a=s.WordArray,o=r.algo,c=o.SHA1,l=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=l.create(i.hasher,e),s=a.create(),n=a.create([1]),o=s.words,c=n.words,u=i.keySize,d=i.iterations;o.length<u;){var h=r.update(t).finalize(n);r.reset();for(var f=h.words,p=f.length,v=h,g=1;g<d;g++){v=r.finalize(v),r.reset();for(var y=v.words,_=0;_<p;_++)f[_]^=y[_]}s.concat(h),c[0]++}return s.sigBytes=4*u,s}}),r.PBKDF2=function(e,t,i){return u.create(i).compute(e,t)},d.PBKDF2)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.mode.CFB=function(){var e=r.lib.BlockCipherMode.extend();function t(e,t,i,r){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,r.encryptBlock(s,0);for(var a=0;a<i;a++)e[t+a]^=s[a]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s,r),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);t.call(this,e,i,s,r),this._prevBlock=n}}),e}(),r.mode.CFB)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.CTR=(r=n.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._counter;s&&(n=this._counter=s.slice(0),this._iv=void 0);var a=n.slice(0);i.encryptBlock(a,0),n[r-1]=n[r-1]+1|0;for(var o=0;o<r;o++)e[t+o]^=a[o]}}),r.Decryptor=s,r),n.mode.CTR)},function(e,t,i){var r;e.exports=(r=i(0),i(1),
13
13
  /** @preserve
14
14
  * Counter block mode compatible with Dr Brian Gladman fileenc.c
15
15
  * derived from CryptoJS.mode.CTR
16
16
  * Jan Hruby jhruby.web@gmail.com
17
17
  */
18
- r.mode.CTRGladman=function(){var e=r.lib.BlockCipherMode.extend();function t(e){if(255==(e>>24&255)){var t=e>>16&255,i=e>>8&255,r=255&e;255===t?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r}else e+=1<<24;return e}var i=e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=this._iv,a=this._counter;n&&(a=this._counter=n.slice(0),this._iv=void 0),function(e){0===(e[0]=t(e[0]))&&(e[1]=t(e[1]))}(a);var o=a.slice(0);r.encryptBlock(o,0);for(var c=0;c<s;c++)e[i+c]^=o[c]}});return e.Decryptor=i,e}(),r.mode.CTRGladman)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.OFB=(r=n.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._keystream;s&&(n=this._keystream=s.slice(0),this._iv=void 0),i.encryptBlock(n,0);for(var a=0;a<r;a++)e[t+a]^=n[a]}}),r.Decryptor=s,r),n.mode.OFB)},function(e,t,i){var r,s;e.exports=(s=i(0),i(1),s.mode.ECB=((r=s.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),r.Decryptor=r.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),r),s.mode.ECB)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,r=4*t,s=r-i%r,n=i+s-1;e.clamp(),e.words[n>>>2]|=s<<24-n%4*8,e.sigBytes+=s},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Ansix923)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso10126={pad:function(e,t){var i=4*t,s=i-e.sigBytes%i;e.concat(r.lib.WordArray.random(s-1)).concat(r.lib.WordArray.create([s<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Iso10126)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t)},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--}},r.pad.Iso97971)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){var t=e.words,i=e.sigBytes-1;for(i=e.sigBytes-1;i>=0;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},r.pad.ZeroPadding)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)},function(e,t,i){var r,s,n,a;e.exports=(a=i(0),i(1),s=(r=a).lib.CipherParams,n=r.enc.Hex,r.format.Hex={stringify:function(e){return e.ciphertext.toString(n)},parse:function(e){var t=n.parse(e);return s.create({ciphertext:t})}},a.format.Hex)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.BlockCipher,i=e.algo,s=[],n=[],a=[],o=[],c=[],l=[],u=[],d=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,r=0;for(t=0;t<256;t++){var p=r^r<<1^r<<2^r<<3^r<<4;p=p>>>8^255&p^99,s[i]=p,n[p]=i;var v=e[i],g=e[v],y=e[g],_=257*e[p]^16843008*p;a[i]=_<<24|_>>>8,o[i]=_<<16|_>>>16,c[i]=_<<8|_>>>24,l[i]=_,_=16843009*y^65537*g^257*v^16843008*i,u[p]=_<<24|_>>>8,d[p]=_<<16|_>>>16,h[p]=_<<8|_>>>24,f[p]=_,i?(i=v^e[e[e[y^v]]],r^=e[e[r]]):i=r=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],v=i.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*((this._nRounds=i+6)+1),n=this._keySchedule=[],a=0;a<r;a++)a<i?n[a]=t[a]:(l=n[a-1],a%i?i>6&&a%i==4&&(l=s[l>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l]):(l=s[(l=l<<8|l>>>24)>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l],l^=p[a/i|0]<<24),n[a]=n[a-i]^l);for(var o=this._invKeySchedule=[],c=0;c<r;c++){if(a=r-c,c%4)var l=n[a];else l=n[a-4];o[c]=c<4||a<=4?l:u[s[l>>>24]]^d[s[l>>>16&255]]^h[s[l>>>8&255]]^f[s[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,o,c,l,s)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,u,d,h,f,n),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,s,n,a,o){for(var c=this._nRounds,l=e[t]^i[0],u=e[t+1]^i[1],d=e[t+2]^i[2],h=e[t+3]^i[3],f=4,p=1;p<c;p++){var v=r[l>>>24]^s[u>>>16&255]^n[d>>>8&255]^a[255&h]^i[f++],g=r[u>>>24]^s[d>>>16&255]^n[h>>>8&255]^a[255&l]^i[f++],y=r[d>>>24]^s[h>>>16&255]^n[l>>>8&255]^a[255&u]^i[f++],_=r[h>>>24]^s[l>>>16&255]^n[u>>>8&255]^a[255&d]^i[f++];l=v,u=g,d=y,h=_}v=(o[l>>>24]<<24|o[u>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^i[f++],g=(o[u>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^i[f++],y=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&u])^i[f++],_=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[u>>>8&255]<<8|o[255&d])^i[f++],e[t]=v,e[t+1]=g,e[t+2]=y,e[t+3]=_},keySize:8});e.AES=t._createHelper(v)}(),r.AES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib,i=t.WordArray,s=t.BlockCipher,n=e.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=n.DES=s.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=a[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var s=this._subKeys=[],n=0;n<16;n++){var l=s[n]=[],u=c[n];for(i=0;i<24;i++)l[i/6|0]|=t[(o[i]-1+u)%28]<<31-i%6,l[4+(i/6|0)]|=t[28+(o[i+24]-1+u)%28]<<31-i%6;for(l[0]=l[0]<<1|l[0]>>>31,i=1;i<7;i++)l[i]=l[i]>>>4*(i-1)+3;l[7]=l[7]<<5|l[7]>>>27}var d=this._invSubKeys=[];for(i=0;i<16;i++)d[i]=s[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),h.call(this,1,1431655765);for(var r=0;r<16;r++){for(var s=i[r],n=this._lBlock,a=this._rBlock,o=0,c=0;c<8;c++)o|=l[c][((a^s[c])&u[c])>>>0];this._lBlock=a,this._rBlock=n^o}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,h.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function f(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=s._createHelper(d);var p=n.TripleDES=s.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),r=e.length<4?e.slice(0,2):e.slice(2,4),s=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=d.createEncryptor(i.create(t)),this._des2=d.createEncryptor(i.create(r)),this._des3=d.createEncryptor(i.create(s))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=s._createHelper(p)}(),r.TripleDES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=i.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],s=0;s<256;s++)r[s]=s;s=0;for(var n=0;s<256;s++){var a=s%i,o=t[a>>>2]>>>24-a%4*8&255;n=(n+r[s]+o)%256;var c=r[s];r[s]=r[n],r[n]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var e=this._S,t=this._i,i=this._j,r=0,s=0;s<4;s++){i=(i+e[t=(t+1)%256])%256;var n=e[t];e[t]=e[i],e[i]=n,r|=e[(e[t]+e[i])%256]<<24-8*s}return this._i=t,this._j=i,r}e.RC4=t._createHelper(s);var a=i.RC4Drop=s.extend({cfg:s.cfg.extend({drop:192}),_doReset:function(){s._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)n.call(this)}});e.RC4Drop=t._createHelper(a)}(),r.RC4)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],s=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)s[i]^=r[i+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(s[0]^=l,s[1]^=d,s[2]^=u,s[3]^=h,s[4]^=l,s[5]^=d,s[6]^=u,s[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.Rabbit=t._createHelper(o)}(),r.Rabbit)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)r[s]^=i[s+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(r[0]^=l,r[1]^=d,r[2]^=u,r[3]^=h,r[4]^=l,r[5]^=d,r[6]^=u,r[7]^=h,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.RabbitLegacy=t._createHelper(o)}(),r.RabbitLegacy)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8);t.psKeySign=e=>{const t=Math.round((new Date).getTime()/1e3),i=e+t;return{Signature:r.MD5(i).toString(),timestamp:t}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(10),n=i(18),a=i(11),o=i(20),c=i(19);function l({bleDeviceId:e,arrayBuffer:t,serviceUUIDSuffix:i="abf0",characteristicUUIDSuffix:r="abf7"}){return new Promise(async(s,a)=>{try{await n.createBLEConnection(e,1e4);const a=await n.getBLEDeviceServices(e),o=a.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(i));if(!o)return console.debug("GIZ_SDK: get ble device services fail",e,a),void s(!1);const c=await n.getBLEDeviceCharacteristics(e,o.uuid),l=c.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(r));if(!l)return console.debug("GIZ_SDK: get ble device characteristics fail",e,c),void s(!1);if(!l.properties.notify&&!l.properties.indicate)return console.debug("GIZ_SDK: the ble device characteristic not support notify or indicate",e,l),void s(!1);await n.notifyBLECharacteristicValueChange(e,o.uuid,l.uuid);const u=()=>{console.log("发送蓝牙指令成功"),wx.offBLECharacteristicValueChange(u),s(!0)};wx.onBLECharacteristicValueChange(u),await n.unpackWriteBLECharacteristicValue(e,o.uuid,l.uuid,t)}catch(e){a(e)}}).catch(e=>(console.debug("GIZ_SDK: sendBLEConfigCmd error",e),!1)).finally(()=>{wx.closeBLEConnection({deviceId:e})})}t.sendBLEConfigCmd=l;class u extends o.default{constructor(){super(...arguments),this.destroy=()=>{this.cleanTimeout()},this.isValidBleDevice=(e,t)=>{if(!e||!e.advertisData)return!1;const{productKey:i,mac:r}=s.advertisData2PkAndMac(e.advertisData,this.specialProductKeys);return!!this.specialProductKeys.includes(i)&&(console.debug(`GIZ_SDK: isValidBleDevice mac: ${r} pk: ${i}`),!t||e.name&&e.name.startsWith(t))},this.enableBluetoothDevicesDescovery=async()=>{try{await n.openBluetoothAdapter()}catch(e){}return(await n.getBluetoothAdapterState()).available?(await n.startBluetoothDevicesDiscovery(),{success:!0}):{success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON.errorCode,errorMessage:"蓝牙状态不可用"}}},this.enableAndGetBluetoothDevices=async e=>{const t=await this.enableBluetoothDevicesDescovery();return t.success?(console.debug("GIZ_SDK: start enableAndGetBluetoothDevices"),{success:!0,bleDevices:(await n.getBluetoothDevices()).filter(t=>this.isValidBleDevice(t,e))}):t},this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>(console.log("setDeviceOnboardingDeploy BLE"),new Promise(async(r,s)=>{const n=this.ssid,a=this.password;this.destroy(),this.initDeviceOnboardingDeploy(r,s),this.startTimeoutTimer(e);try{console.log("setDeviceOnboardingDeploy configBLEDevice");const s=((await this.configBLEDevice({ssid:n,password:a,timeout:1e3*e,softAPSSIDPrefix:i})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));r(t?await this.bindDevices(s):{success:!0,data:s})}catch(e){s(e)}finally{this.destroy()}})),this.configBLEDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise(async(o,u)=>{console.debug("GIZ_SDK: start config ble device");const d=await this.enableAndGetBluetoothDevices(i).catch(e=>({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:JSON.stringify(e)}}));if(!s.isWXDevicesResult(d))return u(d);console.debug("GIZ_SDK: enableAndGetBluetoothDevices success");const{bleDevices:h}=d,f=async({devices:e})=>{this.hasTimeoutHandler()?Array.prototype.push.apply(h,e.filter(e=>this.isValidBleDevice(e,i))):wx.offBluetoothDeviceFound(f)};wx.onBluetoothDeviceFound(f);const p=c.default.pack(e,t),v=async()=>{if(!this.hasTimeoutHandler())return;const i=h.shift();if(!(i&&await l({bleDeviceId:i.deviceId,arrayBuffer:p.buffer})))return await a.default(100),await n.startBluetoothDevicesDiscovery(),await v(),void console.debug("GIZ_SDK: search ble device");wx.offBluetoothDeviceFound(f);try{const i=await this.searchDevice({ssid:e,password:t});o(i)}catch(e){u(e)}};await v()})}}t.default=u},function(e,t){e.exports=function(e){var t={};function i(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(r,s,function(t){return e[t]}.bind(null,s));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=16)}([function(e,t,i){(function(t){var r;e.exports=r=r||function(e,r){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&void 0!==t&&t.crypto&&(s=t.crypto),!s)try{s=i(34)}catch(e){}var n=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),o={},c=o.lib={},l=c.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=l.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,s=e.sigBytes;if(this.clamp(),r%4)for(var n=0;n<s;n++){var a=i[n>>>2]>>>24-n%4*8&255;t[r+n>>>2]|=a<<24-(r+n)%4*8}else for(var o=0;o<s;o+=4)t[r+o>>>2]=i[o>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(n());return new u.init(t,e)}}),d=o.enc={},h=d.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(i,t/2)}},f=d.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s++){var n=t[s>>>2]>>>24-s%4*8&255;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(i,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},v=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i,r=this._data,s=r.words,n=r.sigBytes,a=this.blockSize,o=n/(4*a),c=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,l=e.min(4*c,n);if(c){for(var d=0;d<c;d+=a)this._doProcessBlock(s,d);i=s.splice(0,c),r.sigBytes-=l}return new u.init(i,l)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(c.Hasher=v.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new g.HMAC.init(e,i).finalize(t)}}}),o.algo={});return o}(Math)}).call(this,i(33))},function(e,t,i){var r,s,n,a,o,c,l,u,d,h,f,p,v,g,y,_,D,m,w;e.exports=(r=i(0),i(3),void(r.lib.Cipher||(s=r,n=s.lib,a=n.Base,o=n.WordArray,c=n.BufferedBlockAlgorithm,l=s.enc,l.Utf8,u=l.Base64,d=s.algo.EvpKDF,h=n.Cipher=c.extend({cfg:a.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){c.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?w:D}return function(t){return{encrypt:function(i,r,s){return e(r).encrypt(t,i,r,s)},decrypt:function(i,r,s){return e(r).decrypt(t,i,r,s)}}}}()}),n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),f=s.mode={},p=n.BlockCipherMode=a.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),v=f.CBC=function(){var e=p.extend();function t(e,t,i){var r,s=this._iv;s?(r=s,this._iv=void 0):r=this._prevBlock;for(var n=0;n<i;n++)e[t+n]^=r[n]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s),r.encryptBlock(e,i),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);r.decryptBlock(e,i),t.call(this,e,i,s),this._prevBlock=n}}),e}(),g=(s.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,r=i-e.sigBytes%i,s=r<<24|r<<16|r<<8|r,n=[],a=0;a<r;a+=4)n.push(s);var c=o.create(n,r);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:v,padding:g}),reset:function(){var e;h.reset.call(this);var t=this.cfg,i=t.iv,r=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(r,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),y=n.CipherParams=a.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(s.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;return(i?o.create([1398893684,1701076831]).concat(i).concat(t):t).toString(u)},parse:function(e){var t,i=u.parse(e),r=i.words;return 1398893684==r[0]&&1701076831==r[1]&&(t=o.create(r.slice(2,4)),r.splice(0,4),i.sigBytes-=16),y.create({ciphertext:i,salt:t})}},D=n.SerializableCipher=a.extend({cfg:a.extend({format:_}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var s=e.createEncryptor(i,r),n=s.finalize(t),a=s.cfg;return y.create({ciphertext:n,key:i,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(s.kdf={}).OpenSSL={execute:function(e,t,i,r){r||(r=o.random(8));var s=d.create({keySize:t+i}).compute(e,r),n=o.create(s.words.slice(t),4*i);return s.sigBytes=4*t,y.create({key:s,iv:n,salt:r})}},w=n.PasswordBasedCipher=D.extend({cfg:D.cfg.extend({kdf:m}),encrypt:function(e,t,i,r){var s=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=s.iv;var n=D.encrypt.call(this,e,t,s.key,r);return n.mixIn(s),n},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var s=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=s.iv,D.decrypt.call(this,e,t,s.key,r)}}))))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkHeader=e=>{let t=0;return 0===e[0]&&0===e[1]&&0===e[2]&&3===e[3]&&(4,4)},t.getProtocolLen=e=>{let t=0;for(;t<e.length&&"1"===r(e[t].toString(2),8)[0];t++);return t+1},t.arrayToString=function(e){let t="";return e.map(e=>(t+=r(e.toString(16),2),null)),t};const r=(e,t,i=!1)=>{const r=t-e.length,s=new Array(r).fill(0).join("");return i?e+=s:e=s+e,e};t.fillString=r,t.string2Bytes=e=>{const t=[];for(let i=0;i<e.length;i++)t.push(e.charCodeAt(i));return t},t.hexStrint2byte=e=>{const t=Math.ceil(e.length/2),i=[];for(let r=0;r<t;r++){const t=2*r,s=t+2,n=e.substring(t,s);i.push(parseInt(n,16))}return i};const s=e=>{const t=encodeURI(e);return-1!==t.indexOf("%")&&"%"!==e?t.split("%").filter(e=>""!==e).map(e=>parseInt(e,16)):[t.charCodeAt(0)]};t.formatCode=s,t.formatCodesFromStr=e=>{const t=[0,0];let i=[];for(let r=0;r<e.length;r++){const n=s(e[r]);t[1]+=n.length,i=i.concat(n)}return[i,t]}},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(14),i(15),n=(s=(r=u).lib).Base,a=s.WordArray,c=(o=r.algo).MD5,l=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,r=this.cfg,s=r.hasher.create(),n=a.create(),o=n.words,c=r.keySize,l=r.iterations;o.length<c;){i&&s.update(i),i=s.update(e).finalize(t),s.reset();for(var u=1;u<l;u++)i=s.finalize(i),s.reset();n.concat(i)}return n.sigBytes=4*c,n}}),r.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},u.EvpKDF)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var s=[],n=0;n<i;n+=3)for(var a=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,o=0;o<4&&n+.75*o<i;o++)s.push(r.charAt(a>>>6*(3-o)&63));var c=r.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var n=0;n<i.length;n++)r[i.charCodeAt(n)]=n}var a=i.charAt(64);if(a){var o=e.indexOf(a);-1!==o&&(t=o)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2|i[e.charCodeAt(a)]>>>6-a%4*2;r[n>>>2]|=o<<24-n%4*8,n++}return s.create(r,n)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[];!function(){for(var t=0;t<64;t++)o[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,a=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],v=e[t+4],g=e[t+5],y=e[t+6],_=e[t+7],D=e[t+8],m=e[t+9],w=e[t+10],S=e[t+11],b=e[t+12],B=e[t+13],I=e[t+14],k=e[t+15],C=n[0],A=n[1],x=n[2],P=n[3];C=l(C,A,x,P,a,7,o[0]),P=l(P,C,A,x,c,12,o[1]),x=l(x,P,C,A,f,17,o[2]),A=l(A,x,P,C,p,22,o[3]),C=l(C,A,x,P,v,7,o[4]),P=l(P,C,A,x,g,12,o[5]),x=l(x,P,C,A,y,17,o[6]),A=l(A,x,P,C,_,22,o[7]),C=l(C,A,x,P,D,7,o[8]),P=l(P,C,A,x,m,12,o[9]),x=l(x,P,C,A,w,17,o[10]),A=l(A,x,P,C,S,22,o[11]),C=l(C,A,x,P,b,7,o[12]),P=l(P,C,A,x,B,12,o[13]),x=l(x,P,C,A,I,17,o[14]),C=u(C,A=l(A,x,P,C,k,22,o[15]),x,P,c,5,o[16]),P=u(P,C,A,x,y,9,o[17]),x=u(x,P,C,A,S,14,o[18]),A=u(A,x,P,C,a,20,o[19]),C=u(C,A,x,P,g,5,o[20]),P=u(P,C,A,x,w,9,o[21]),x=u(x,P,C,A,k,14,o[22]),A=u(A,x,P,C,v,20,o[23]),C=u(C,A,x,P,m,5,o[24]),P=u(P,C,A,x,I,9,o[25]),x=u(x,P,C,A,p,14,o[26]),A=u(A,x,P,C,D,20,o[27]),C=u(C,A,x,P,B,5,o[28]),P=u(P,C,A,x,f,9,o[29]),x=u(x,P,C,A,_,14,o[30]),C=d(C,A=u(A,x,P,C,b,20,o[31]),x,P,g,4,o[32]),P=d(P,C,A,x,D,11,o[33]),x=d(x,P,C,A,S,16,o[34]),A=d(A,x,P,C,I,23,o[35]),C=d(C,A,x,P,c,4,o[36]),P=d(P,C,A,x,v,11,o[37]),x=d(x,P,C,A,_,16,o[38]),A=d(A,x,P,C,w,23,o[39]),C=d(C,A,x,P,B,4,o[40]),P=d(P,C,A,x,a,11,o[41]),x=d(x,P,C,A,p,16,o[42]),A=d(A,x,P,C,y,23,o[43]),C=d(C,A,x,P,m,4,o[44]),P=d(P,C,A,x,b,11,o[45]),x=d(x,P,C,A,k,16,o[46]),C=h(C,A=d(A,x,P,C,f,23,o[47]),x,P,a,6,o[48]),P=h(P,C,A,x,_,10,o[49]),x=h(x,P,C,A,I,15,o[50]),A=h(A,x,P,C,g,21,o[51]),C=h(C,A,x,P,b,6,o[52]),P=h(P,C,A,x,p,10,o[53]),x=h(x,P,C,A,w,15,o[54]),A=h(A,x,P,C,c,21,o[55]),C=h(C,A,x,P,D,6,o[56]),P=h(P,C,A,x,k,10,o[57]),x=h(x,P,C,A,y,15,o[58]),A=h(A,x,P,C,B,21,o[59]),C=h(C,A,x,P,v,6,o[60]),P=h(P,C,A,x,S,10,o[61]),x=h(x,P,C,A,f,15,o[62]),A=h(A,x,P,C,m,21,o[63]),n[0]=n[0]+C|0,n[1]=n[1]+A|0,n[2]=n[2]+x|0,n[3]=n[3]+P|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;i[s>>>5]|=128<<24-s%32;var n=e.floor(r/4294967296),a=r;i[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),i[14+(s+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(i.length+1),this._process();for(var o=this._hash,c=o.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return o},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,i,r,s,n,a){var o=e+(t&i|~t&r)+s+a;return(o<<n|o>>>32-n)+t}function u(e,t,i,r,s,n,a){var o=e+(t&r|i&~r)+s+a;return(o<<n|o>>>32-n)+t}function d(e,t,i,r,s,n,a){var o=e+(t^i^r)+s+a;return(o<<n|o>>>32-n)+t}function h(e,t,i,r,s,n,a){var o=e+(i^(t|~r))+s+a;return(o<<n|o>>>32-n)+t}t.MD5=n._createHelper(c),t.HmacMD5=n._createHmacHelper(c)}(Math),r.MD5)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(2);t.default=class{constructor(e){this.header="",this.len=0,this.flag=[0],this.cmd="",this.content=[],this.formatP0=e=>{let t=r.checkHeader(e);if(!1===t)throw new Error("Header Error");this.header=r.arrayToString(e.slice(0,t));const i=e.slice(t,e.length),s=r.getProtocolLen(i);this.len=parseInt(r.arrayToString(i.slice(0,s)),16),t+=s,this.flag=e.slice(t,t+1),t+=1,this.cmd=r.arrayToString(e.slice(t,t+2)),t+=2,this.content=e.slice(t,e.length)},e&&e.length>0&&this.formatP0(e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={GIZ_OPENAPI_DEVICE_NOT_BOUND:{errorCode:9017,errorMessage:"not bind"},GIZ_SDK_HTTP_REQUEST_FAILED:{errorCode:8099,errorMessage:"网络请求失败"},GIZ_SDK_SDK_NOT_INITIALIZED:{errorCode:8300,errorMessage:"not init"},CONFIG_TIME_OUT:{errorCode:8023,errorMessage:"Config Timeout"},WECHAT_ERROR:{errorCode:1e4,errorMessage:"wechat error"},GIZ_SDK_ONBOARDING_STOPPED:{errorCode:8318,errorMessage:"配网中断"},GIZ_SDK_DEVICE_CONFIG_IS_RUNNING:{errorCode:8022,errorMessage:"配置正在进行中"},GIZ_OPENAPI_TOKEN_INVALID:{errorCode:9004,errorMessage:"token 失效"},GIZ_SDK_BIND_DEVICE_FAILED:{errorCode:8039,errorMessage:"设备绑定失败"},GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON:{errorCode:8281,errorMessage:"蓝牙未启用"},GIZ_SDK_OTHERWISE:{errorCode:8100,errorMessage:""},GIZ_SDK_DEVICE_NOT_SUBSCRIBED:{errorCode:8029,errorMessage:"设备还未订阅"},GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY:{errorCode:8250,errorMessage:"产品类型不在指定范围内"}}},function(e,t,i){var r;e.exports=(r=i(0),i(9),i(35),i(36),i(4),i(37),i(5),i(14),i(23),i(38),i(24),i(39),i(40),i(41),i(15),i(42),i(3),i(1),i(43),i(44),i(45),i(46),i(47),i(48),i(49),i(50),i(51),i(52),i(53),i(54),i(55),i(56),i(57),i(58),r)},function(e,t,i){var r,s,n,a,o,c;e.exports=(s=(r=c=i(0)).lib,n=s.Base,a=s.WordArray,(o=r.x64={}).Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),o.WordArray=n.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var s=e[r];i.push(s.high),i.push(s.low)}return a.create(i,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}}),c)},function(e,t,i){"use strict";function r(e){return Array.prototype.map.call(new Uint8Array(e),(function(e){return("00"+e.toString(16)).slice(-2)})).join("")}Object.defineProperty(t,"__esModule",{value:!0}),t.ab2hex=r,t.compareWXSDKVersion=function(e,t){const i=e.split("."),r=t.split("."),s=Math.max(e.length,t.length);for(;i.length<s;)i.push("0");for(;r.length<s;)r.push("0");for(let i=0;i<s;i++){const r=parseInt(e[i]),s=parseInt(t[i]);if(r>s)return 1;if(r<s)return-1}return 0},t.isError=e=>null!=e&&"symbol"==typeof e.errorCode,t.wrapErrorInfo=e=>({errorCode:Symbol(e),errorMessage:e}),t.unionBy=(e,t)=>e.reduce((e,i)=>{const r=i[t];return e.some(e=>e[t]===r)||e.push(i),e},[]),t.isWXDevicesResult=function(e){return e.success&&"[object Array]"===Object.prototype.toString.call(e.bleDevices)},t.str2Buf=function(e){var t=e.length,i=new ArrayBuffer(t+2),r=new DataView(i);for(let i=0;i<t;i++)r.setUint8(i,parseInt(e[i],16));return i},t.numberArray2Uint8Array=e=>{const t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let r=0;r<t.byteLength;r++)i[r]=e[r];return i},t.advertisData2PkAndMac=e=>{const t=e.slice(e.byteLength-16),i=e.slice(0,e.byteLength-16);return{productKey:r(t),mac:r(i)}},t.isSameDevice=(e,t)=>e.mac===t.mac&&e.productKey===t.productKey,t.merageBleLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?(r.isBleOnline=!0,r.bleDeviceID=i.bleDeviceID):e.push(i)}),e),t.merageLanLocalDevices=(e,i)=>(i.map(i=>{const r=e.find(e=>t.isSameDevice(e,i));r?r.isLanOnline=!0:e.push(i)}),e),t.BTDevice2GDevice=e=>{const{productKey:i,mac:r}=t.advertisData2PkAndMac(e.advertisData);return{mac:r,did:"",connectType:"NONE",isBleOnline:!0,isLanOnline:!1,isOnline:!1,productKey:i,name:e.name,isBind:!1,bleDeviceID:e.deviceId}},t.getFirstConnectType=(e,t)=>{if(t){if("WAN"===t)return"WAN";switch(t){case"BLE":return e.isBleOnline?"BLE":"NONE";case"LAN":return e.isLanOnline?"LAN":"NONE"}}else{if(e.isLanOnline)return"LAN";if(e.isBleOnline)return"BLE"}return"WAN"},t.getProductInfoThroughPK=(e,t)=>t.find(t=>t.productKey===e)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=e=>new Promise(t=>setTimeout(()=>t(),e))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13),s=new class{constructor(){this.data={},this.key="dataPointConfig",this.init=async()=>{const e=await wx.getStorageSync(this.key)||"{}";let t={};try{t=JSON.parse(e)}catch(e){}this.data=t},this.getConfigFile=async e=>{var t;if(!this.data[e]){const i=`/v2/datapoint?product_key=${e}`,s=await r.siteApiRequest(`${i}`,{method:"GET"});s.success&&(null===(t=s.data)||void 0===t?void 0:t.entities)&&(this.data[e]=s.data,wx.setStorageSync(this.key,JSON.stringify(this.data)))}return this.data[e]}}};s.init(),t.default=s},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(30),s=i(17),n=i(7);t.siteApiRequest=async(e,t)=>{const i=Object.assign({},t);i.header=Object.assign(Object.assign({},{"Content-Type":"application/json"}),t.headers),delete i.headers;const a=(s.getGlobalData("cloudServiceInfo")||{}).siteInfo||"site.gizwits.com",o=await r.default("http://"+a+e,i);if(console.log("siteApiRequest res",o),o.statusCode>=200&&o.statusCode<300)return{success:!0,data:o.data};let c={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{c={success:!1,err:{errorCode:o.data.error_code,errorMessage:o.data.error_message}}}catch(e){}return c},t.default=async(e,t,i=!0)=>{const a=Object.assign({},t),o={"Content-Type":"application/json","X-Gizwits-Application-Id":s.getGlobalData("appID")};i&&(o["X-Gizwits-User-token"]=s.getGlobalData("token")),a.header=Object.assign(Object.assign({},o),t.headers),delete a.headers;const c=s.getGlobalData("cloudServiceInfo").openAPIInfo,l=await r.default("https://"+c+e,a);if(l.statusCode>=200&&l.statusCode<300)return{success:!0,data:l.data};let u={success:!1,err:{errorCode:n.default.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,errorMessage:""}};try{u={success:!1,err:{errorCode:l.data.error_code,errorMessage:l.data.error_message}}}catch(e){}return u}},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(s=(r=u=i(0)).lib,n=s.WordArray,a=s.Hasher,o=r.algo,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],l=0;l<80;l++){if(l<16)c[l]=0|e[t+l];else{var u=c[l-3]^c[l-8]^c[l-14]^c[l-16];c[l]=u<<1|u>>>31}var d=(r<<5|r>>>27)+o+c[l];d+=l<20?1518500249+(s&n|~s&a):l<40?1859775393+(s^n^a):l<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,o=a,a=n,n=s<<30|s>>>2,s=r,r=d}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=a._createHelper(l),r.HmacSHA1=a._createHmacHelper(l),u.SHA1)},function(e,t,i){var r,s,n;e.exports=(s=(r=i(0)).lib.Base,n=r.enc.Utf8,void(r.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=n.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),a=this._iKey=t.clone(),o=s.words,c=a.words,l=0;l<i;l++)o[l]^=1549556828,c[l]^=909522486;s.sigBytes=a.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i(25);const r=i(26),s=i(7);t.errorCode=s.default;const n=i(18);t.BleHandle=n.BleHandle,t.default=r.default},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={};t.setGlobalData=function(e,t){r[e]=t},t.getGlobalData=function(e){return r[e]}},function(e,t,i){"use strict";var r=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(i[r[s]]=e[r[s]])}return i};Object.defineProperty(t,"__esModule",{value:!0});const s=i(10),n=i(19),a=i(27),o=i(2),c=i(6),l=i(28),u=i(29);t.BleHandle=class{constructor(e=[],t={serviceUUIDSuffix:"abf0",characteristicUUIDSuffix:"abf7"}){this.connectedList=[],this.pks=[],this.tmpBleData="",this.tmpDataNum=0,this.listenerMap={},this.handleOnBLECharacteristicValueChange=e=>{console.log("handleOnBLECharacteristicValueChange",s.ab2hex(e.value));const t=s.ab2hex(e.value);try{const i=new c.default(o.hexStrint2byte(t));console.log("ProtocolBase",i.len,e.value.byteLength),this.tmpBleData=t,this.tmpDataNum=i.len-e.value.byteLength+4+Math.ceil(i.len.toString(2).length/8)}catch(i){this.tmpBleData&&(this.tmpBleData+=t,this.tmpDataNum-=e.value.byteLength)}this.tmpDataNum>0||!this.tmpBleData||(console.log("ProtocolBase",this.tmpBleData,this.tmpDataNum),this.listenerMap[e.deviceId]&&this.listenerMap[e.deviceId].map(t=>{t(e,this.tmpBleData)}),this.listenerMap.ALL&&(console.log("ProtocolBase1"),this.listenerMap.ALL.map(t=>{console.log("ProtocolBase2"),t(e,this.tmpBleData)})),this.tmpBleData="",this.tmpDataNum=0)},this.checkPermission=async()=>{const e=await wx.getBluetoothAdapterState(),{errMsg:t,available:i}=e,n=r(e,["errMsg","available"]);return{data:Object.assign({},n),err:s.wrapErrorInfo(t),success:i}},this.getDeviceStatus=async(e,t,i,r)=>{const n=await u.default.pack(t,i,r);return console.log("getDeviceStatus",n),await this.write(e,s.numberArray2Uint8Array(n).buffer)},this.startScan=async(e,t=5e3)=>new Promise(async i=>{const r=[];wx.onBluetoothDeviceFound(t=>{const i=t.devices.filter(e=>{const{advertisData:t}=e,i=s.ab2hex(t);return this.pks.some(e=>i.includes(e))});if(i.length>0){const t=i.map(e=>s.BTDevice2GDevice(e));r.push(...t),e(r)}}),await wx.startBluetoothDevicesDiscovery({powerLevel:"high"}),setTimeout(()=>{this.stopScan(),i({scanList:r})},t)}),this.stopScan=async()=>{const{errMsg:e,errCode:t}=await wx.stopBluetoothDevicesDiscovery();return{errMsg:e,errCode:t}},this.connectDevice=async e=>{var t;await wx.createBLEConnection({deviceId:e});const{services:i}=await wx.getBLEDeviceServices({deviceId:e});console.log("获取设备服务成功",i);const r=null===(t=i.find(e=>e.isPrimary&&e.uuid.toLowerCase().includes(this.serviceUUIDSuffix)))||void 0===t?void 0:t.uuid;if(!r)return{message:"can not find valid serviceId",success:!1};const{characteristics:n}=await wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:r});console.log("获取服务特征值成功",n);const o=n[0].uuid;this.connectedList.every(t=>t.deviceId!==e)&&this.connectedList.push({deviceId:e,serviceId:r,characteristicId:o}),await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:r,characteristicId:o,state:!0,type:"notification"}),console.log("监听特征值变化成功"),this.write(e,s.numberArray2Uint8Array(a.default.pack()).buffer);const c=await this.handleBindReq(e);if(c.success){this.write(e,s.numberArray2Uint8Array(l.default.pack({passcode:c.data})).buffer);const t=await this.handleLoginReq(e);if(console.log("loginData",t),t.success)return{success:!0,message:"ok"}}return{success:!1,message:"ok"}},this.handleBindReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new a.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),n.passcode?t({success:!0,data:n.passcode}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.handleLoginReq=e=>new Promise(t=>{const i=(r,s)=>{const n=new l.default(o.hexStrint2byte(s));this.removeDeviceListener(e,i),!0===n.result?t({success:!0,data:n.did}):t({success:!1,data:""})};this.addDeviceListener(e,i)}),this.removeDeviceListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{message:"ok",success:!0}}return{message:"invalid function",success:!1}},this.addDeviceListener=async(e,t)=>{"ALL"===e&&(this.listenerMap.ALL||(this.listenerMap.ALL=[]),this.listenerMap.ALL.push(t));const{serviceId:i,characteristicId:r,errMsg:s}=this.getTargetDevice(e);return s?{success:!1,message:s}:(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),await wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:i,characteristicId:r,state:!0,type:"notification"}),console.log(`监听设备 ${e} 成功!`),{message:"ok",success:!0})},this.write=async(e,t)=>{const{serviceId:i,characteristicId:r}=this.getTargetDevice(e);i&&r&&await n.unpackWriteBLECharacteristicValue(e,i,r,t)},this.disConnectDevice=async e=>{const{errMsg:t}=await wx.closeBLEConnection({deviceId:e});return{err:s.wrapErrorInfo(t)}},this.getTargetDevice=e=>this.connectedList.find(t=>e===t.deviceId)||{errMsg:"Unable get this device,maybe you forgot to connect it."};const{serviceUUIDSuffix:i}=t;this.serviceUUIDSuffix=i,this.pks=e;try{wx.openBluetoothAdapter()}catch(e){console.error(e)}wx.onBLECharacteristicValueChange(this.handleOnBLECharacteristicValueChange)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11);function s(e,t,i,r){return new Promise(s=>{console.log("writeBLECharacteristicValue"),wx.writeBLECharacteristicValue({deviceId:e,serviceId:t,characteristicId:i,value:r,complete:s})})}t.openBluetoothAdapter=function(){return new Promise((e,t)=>{wx.openBluetoothAdapter({success:e,fail:t})})},t.getBluetoothAdapterState=function(){return new Promise((e,t)=>{wx.getBluetoothAdapterState({success:e,fail:t})})},t.startBluetoothDevicesDiscovery=function(){return new Promise((e,t)=>{wx.startBluetoothDevicesDiscovery({success:e,fail:t,interval:100})})},t.getBluetoothDevices=function(){return new Promise((e,t)=>{wx.getBluetoothDevices({success:({devices:t})=>e(t),fail:t})})},t.createBLEConnection=function(e,t){return new Promise((i,r)=>{wx.createBLEConnection({deviceId:e,timeout:t,success:e=>i(e),fail:e=>{-1===e.errCode?i(e):r(e)}})})},t.getBLEDeviceServices=function(e){return new Promise((t,i)=>{wx.getBLEDeviceServices({deviceId:e,success:({services:e})=>t(e),fail:i})})},t.getBLEDeviceCharacteristics=function(e,t){return new Promise((i,r)=>{wx.getBLEDeviceCharacteristics({deviceId:e,serviceId:t,success:({characteristics:e})=>i(e),fail:r})})},t.notifyBLECharacteristicValueChange=function(e,t,i,r=!0){return new Promise((s,n)=>{wx.notifyBLECharacteristicValueChange({deviceId:e,serviceId:t,characteristicId:i,state:r,success:s,fail:n})})},t.writeBLECharacteristicValue=s,t.unpackWriteBLECharacteristicValue=function(e,t,i,n){if(0===n.byteLength)throw new Error("value is not empty");return new Promise(async(a,o)=>{let c,l=0,u=n.byteLength;for(;u>0;){await r.default(30);const a=n.slice(l,l+20);if(l+=20,u-=20,c=await s(e,t,i,a),console.log("unpackWriteBLECharacteristicValue",l/20,c),0!==c.errCode)break}0!==c.errCode?o(c):a(c)})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e)}}n.pack=(e,t)=>{const i=[],[r,n]=s.formatCodesFromStr(e),[a,o]=s.formatCodesFromStr(t),c=[0].concat([0,1],n,r,o,a);let l=c.length;for(;l>0;)i.push(l),l-=255;const u=[0,0,0,3].concat(i).concat(c),d=new ArrayBuffer(u.length),h=new Uint8Array(d);for(let e=0;e<d.byteLength;e++)h[e]=u[e];return h},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11),s=i(7),n=i(22);t.default=class{constructor(e,t,i,a){this.ssid="",this.password="",this.specialProductKeys=[],this.disableSearchDevice=!1,this.specialProductKeySecrets=[],this.timeoutHandler=null,this.setDeviceOnboardingDeployRej=()=>{},this.cleanTimeout=()=>{this.disableSearchDevice=!0,this.timeoutHandler&&clearTimeout(this.timeoutHandler)},this.stopDeviceOnboardingDeploy=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:s.default.GIZ_SDK_ONBOARDING_STOPPED}),this.cleanTimeout()},this.hasTimeoutHandler=e=>!!this.timeoutHandler&&(e&&e({success:!1,err:s.default.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING}),!0),this.handleTimeout=()=>{this.setDeviceOnboardingDeployRej&&this.setDeviceOnboardingDeployRej({success:!1,err:{errorCode:s.default.CONFIG_TIME_OUT,errorMessage:"time out"}})},this.searchDevice=({ssid:e,password:t})=>new Promise((i,a)=>{const o=async()=>{var c;try{const l=await n.checkDeviceRegister({SSID:e,password:t,productKeys:this.specialProductKeys});if(console.log("GIZ_SDK: try get device random codes",l),(null===(c=l.err)||void 0===c?void 0:c.errorCode)===s.default.GIZ_OPENAPI_TOKEN_INVALID.errorCode)return void a({success:!1,err:s.default.GIZ_OPENAPI_TOKEN_INVALID});l.err||0===l.data.length?(await r.default(1500),!this.disableSearchDevice&&o()):(console.log("GIZ_SDK: config device success",l),i({success:!0,data:l.data}))}catch(e){await r.default(3e3),!this.disableSearchDevice&&o(),console.debug("GIZ_SDK: random codes error",e)}};o()}),this.initDeviceOnboardingDeploy=(e,t)=>{this.setDeviceOnboardingDeployRej=t,this.disableSearchDevice=!1},this.startTimeoutTimer=e=>{this.timeoutHandler=setTimeout(this.handleTimeout,1e3*e)},this.bindDevices=e=>(console.log("GIZ_SDK: start bind device"),new Promise(async(t,i)=>{const r=e.map(e=>{const t=this.specialProductKeys.findIndex(t=>e.productKey===t);if(-1===t)return;const i=this.specialProductKeySecrets[t];return n.bindMac({mac:e.mac,productKey:e.productKey,productSecret:i})});try{const n=await Promise.all(r),a=e.filter((e,t)=>{const i=n[t];return i&&i.success});a.length>0?(console.log("GIZ_SDK: bind device success",a),t({success:!0,data:a})):(console.log("GIZ_SDK: bind device error",n),i({success:!1,err:{errorCode:s.default.BIND_FAIL.errorCode,errorMessage:JSON.stringify(n),devices:e}}))}catch(e){i(e)}})),this.ssid=e,this.password=t,this.specialProductKeys=i,this.specialProductKeySecrets=a}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13),s=i(32),n=i(59),a=i(8);t.getBindingList=async()=>{const e=await r.default("/app/bindings?show_disabled=0&limit=1000&skip=0",{method:"GET"});return e.success?{success:!0,data:e.data.devices.map(e=>({productKey:e.product_key,mac:e.mac,did:e.did,isBleOnline:!1,isLanOnline:!1,connectType:"NONE",name:e.dev_alias,isBind:!0,isOnline:e.is_online}))}:{success:!1,err:e.err}},t.bindMac=async function({mac:e,productKey:t,productSecret:i,alias:s,beOwner:a}){const o={mac:e,product_key:t,dev_alias:s,set_owner:a},{Signature:c,timestamp:l}=n.psKeySign(i);return await r.default("/app/bind_mac",{method:"POST",data:o,headers:{"X-Gizwits-Signature":c,"X-Gizwits-Timestamp":l}})},t.unbindDevice=async function({devices:e}){return await r.default("/app/bindings",{method:"DELETE",data:{devices:e.map(e=>({did:e.did}))}})},t.checkDeviceRegister=async function({SSID:e,password:t,productKeys:i}){const n=s.default({SSID:e,password:t,pks:i});let a="";return n.map(e=>{a+=`${e},`}),a=a.substring(0,a.length-1),console.log("codeStrcodeStr",a),await r.default(`/app/device_register?random_codes=${a}`,{method:"get"})},t.safeRegister=async function({productKey:e,productSecret:t,mac:i,passcode:s,gwDid:n,isReset:o}){let c=`is_reset=${o?1:0}&mac=${i}&passcode=${s}`;n&&(c+=`&gw_did=${n}`);const l=a.enc.Hex.parse(t),u=a.enc.Hex.parse(""),d=a.enc.Utf8.parse(c),h=a.AES.encrypt(d,l,{iv:u,mode:a.mode.ECB,padding:a.pad.Pkcs7}).ciphertext.toString().toUpperCase(),f=await r.default(`/dev/${e}/device`,{method:"POST",data:{data:h},headers:{"content-type":"application/x-www-form-urlencoded"}},!1);return f.success?{success:!0,data:{successDevices:[],failedDevices:[]}}:{success:!1,err:f.err}}},function(e,t,i){var r;e.exports=(r=i(0),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=[],c=[];!function(){function t(t){for(var i=e.sqrt(t),r=2;r<=i;r++)if(!(t%r))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var r=2,s=0;s<64;)t(r)&&(s<8&&(o[s]=i(e.pow(r,.5))),c[s]=i(e.pow(r,1/3)),s++),r++}();var l=[],u=a.SHA256=n.extend({_doReset:function(){this._hash=new s.init(o.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=0;f<64;f++){if(f<16)l[f]=0|e[t+f];else{var p=l[f-15],v=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=l[f-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[f]=v+l[f-7]+y+l[f-16]}var _=r&s^r&n^s&n,D=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),m=h+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&d)+c[f]+l[f];h=d,d=u,u=o,o=a+m|0,a=n,n=s,s=r,r=m+(D+_)|0}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+n|0,i[3]=i[3]+a|0,i[4]=i[4]+o|0,i[5]=i[5]+u|0,i[6]=i[6]+d|0,i[7]=i[7]+h|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,s=8*t.sigBytes;return i[s>>>5]|=128<<24-s%32,i[14+(s+64>>>9<<4)]=e.floor(r/4294967296),i[15+(s+64>>>9<<4)]=r,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=n._createHelper(u),t.HmacSHA256=n._createHmacHelper(u)}(Math),r.SHA256)},function(e,t,i){var r;e.exports=(r=i(0),i(9),function(){var e=r,t=e.lib.Hasher,i=e.x64,s=i.Word,n=i.WordArray,a=e.algo;function o(){return s.create.apply(s,arguments)}var c=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],l=[];!function(){for(var e=0;e<80;e++)l[e]=o()}();var u=a.SHA512=t.extend({_doReset:function(){this._hash=new n.init([new s.init(1779033703,4089235720),new s.init(3144134277,2227873595),new s.init(1013904242,4271175723),new s.init(2773480762,1595750129),new s.init(1359893119,2917565137),new s.init(2600822924,725511199),new s.init(528734635,4215389547),new s.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],s=i[1],n=i[2],a=i[3],o=i[4],u=i[5],d=i[6],h=i[7],f=r.high,p=r.low,v=s.high,g=s.low,y=n.high,_=n.low,D=a.high,m=a.low,w=o.high,S=o.low,b=u.high,B=u.low,I=d.high,k=d.low,C=h.high,A=h.low,x=f,P=p,O=v,E=g,L=y,M=_,H=D,T=m,K=w,R=S,N=b,U=B,z=I,j=k,G=C,F=A,W=0;W<80;W++){var Z,V,X=l[W];if(W<16)V=X.high=0|e[t+2*W],Z=X.low=0|e[t+2*W+1];else{var $=l[W-15],q=$.high,Y=$.low,J=(q>>>1|Y<<31)^(q>>>8|Y<<24)^q>>>7,Q=(Y>>>1|q<<31)^(Y>>>8|q<<24)^(Y>>>7|q<<25),ee=l[W-2],te=ee.high,ie=ee.low,re=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,se=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),ne=l[W-7],ae=ne.high,oe=ne.low,ce=l[W-16],le=ce.high,ue=ce.low;V=(V=(V=J+ae+((Z=Q+oe)>>>0<Q>>>0?1:0))+re+((Z+=se)>>>0<se>>>0?1:0))+le+((Z+=ue)>>>0<ue>>>0?1:0),X.high=V,X.low=Z}var de,he=K&N^~K&z,fe=R&U^~R&j,pe=x&O^x&L^O&L,ve=P&E^P&M^E&M,ge=(x>>>28|P<<4)^(x<<30|P>>>2)^(x<<25|P>>>7),ye=(P>>>28|x<<4)^(P<<30|x>>>2)^(P<<25|x>>>7),_e=(K>>>14|R<<18)^(K>>>18|R<<14)^(K<<23|R>>>9),De=(R>>>14|K<<18)^(R>>>18|K<<14)^(R<<23|K>>>9),me=c[W],we=me.high,Se=me.low,be=G+_e+((de=F+De)>>>0<F>>>0?1:0),Be=ye+ve;G=z,F=j,z=N,j=U,N=K,U=R,K=H+(be=(be=(be=be+he+((de+=fe)>>>0<fe>>>0?1:0))+we+((de+=Se)>>>0<Se>>>0?1:0))+V+((de+=Z)>>>0<Z>>>0?1:0))+((R=T+de|0)>>>0<T>>>0?1:0)|0,H=L,T=M,L=O,M=E,O=x,E=P,x=be+(ge+pe+(Be>>>0<ye>>>0?1:0))+((P=de+Be|0)>>>0<de>>>0?1:0)|0}p=r.low=p+P,r.high=f+x+(p>>>0<P>>>0?1:0),g=s.low=g+E,s.high=v+O+(g>>>0<E>>>0?1:0),_=n.low=_+M,n.high=y+L+(_>>>0<M>>>0?1:0),m=a.low=m+T,a.high=D+H+(m>>>0<T>>>0?1:0),S=o.low=S+R,o.high=w+K+(S>>>0<R>>>0?1:0),B=u.low=B+U,u.high=b+N+(B>>>0<U>>>0?1:0),k=d.low=k+j,d.high=I+z+(k>>>0<j>>>0?1:0),A=h.low=A+F,h.high=C+G+(A>>>0<F>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(r+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(u),e.HmacSHA512=t._createHmacHelper(u)}(),r.SHA512)},function(e,t){},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(17),s=i(18),n=i(31),a=i(60),o=i(16),c=i(61),l=i(22),u=i(10),d=i(12),h=i(62),f=i(2);t.default=class{constructor({appID:e,appSecret:t,productInfo:i,cloudServiceInfo:p,token:v,uid:g}){this.listenerMap={},this._deviceList=[],this._bleDevices=[],this._udpDevices=[],this.productInfo=[],this.autoScanInterval=null,this.handleBleDeviceData=async(e,t)=>{const i=this.allDevices.find(t=>t.bleDeviceID===e.deviceId);if(console.log("ProtocolBase",i),i){const e=await h.unpack(f.hexStrint2byte(t),i.productKey);console.log("handleBleDeviceData",e),(null==e?void 0:e.kvData)&&this.listenerMap.GizDeviceAttrsNotifications&&this.listenerMap.GizDeviceAttrsNotifications.map(t=>{t(i,null==e?void 0:e.kvData)})}},this.notiDeviveList=()=>{this.listenerMap.GizDeviceListNotifications&&this.listenerMap.GizDeviceListNotifications.map(e=>{e(this.allDevices)})},this.startAutoScan=()=>{this.autoScanInterval&&clearInterval(this.autoScanInterval),this.autoScanInterval=setInterval(async()=>{const e=await this.bleHandle.startScan(()=>{},4e3);this.bleDevices=e.scanList},6e3)},this.scanBleDevice=async()=>await this.bleHandle.startScan(e=>{this.bleDevices=e}),this.write=async(e,t)=>{if(e&&e.connectType&&"NONE"!==e.connectType)switch(e.connectType){case"BLE":{const i=await h.pack(t,e.productKey);console.log("write cmd",i,t),this.bleHandle.write(e.bleDeviceID,u.numberArray2Uint8Array(i).buffer);break}}},this.getProductConfig=async e=>await d.default.getConfigFile(e),this.stopScanBleDevice=()=>{this.bleHandle.stopScan()},this.login=async e=>{var t,i;const s=await c.AnonymousLogin({uid:e});return r.setGlobalData("token",null===(t=s.data)||void 0===t?void 0:t.token),r.setGlobalData("uid",null===(i=s.data)||void 0===i?void 0:i.uid),s},this.setDomain=e=>{const t=e&&e.openAPIInfo||"api.gizwits.com",i=e&&e.siteInfo||"site.gizwits.com",s=Object.assign(Object.assign({},e||{}),{openAPIInfo:t,siteInfo:i});r.setGlobalData("cloudServiceInfo",s)},this.getDeviceStatus=async(e,t)=>{const i=this.allDevices.find(t=>u.isSameDevice(t,e));if(i)switch(i.connectType){case"BLE":return await this.bleHandle.getDeviceStatus(i.bleDeviceID,i.productKey,i.rootDeviceId,t)}},this.subscribe=async(e,t,i=!0)=>{switch(u.getFirstConnectType(e,t)){case"BLE":{const t=this.bleDevices.find(t=>u.isSameDevice(t,e));if(t){const e=await this.bleHandle.connectDevice(t.bleDeviceID);return e.success&&setTimeout(()=>{this.getDeviceStatus(t)},500),console.log("subscribe",e),e}}}return{success:!1}},this.unSubscribe=e=>{},this.bindRemoteDevice=async({mac:e,productKey:t,alias:i,beOwner:r})=>{const s=u.getProductInfoThroughPK(t,this.productInfo);if(s){const n=await l.bindMac({mac:e,productKey:t,productSecret:s.productSecrets,alias:i,beOwner:r});return this.getBindingList(),n}return o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY},this.unbindDevice=async({devices:e})=>{const t=await l.unbindDevice({devices:e});return this.getBindingList(),t},this.deviceSafetyApi=async({mac:e,productKey:t,isReset:i})=>{const r=u.getProductInfoThroughPK(t,this.productInfo);return r?await l.safeRegister({productKey:t,productSecret:r.productSecrets,mac:e,isReset:i,passcode:"1234567890"}):o.errorCode.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY},this.deviceSafetyRegister=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!1}),this.deviceSafetyUnbind=async({mac:e,productKey:t})=>await this.deviceSafetyApi({mac:e,productKey:t,isReset:!0}),this.setDeviceOnboardingDeploy=async({ssid:e,password:t,mode:i=0,timeout:r,isBind:s=!0,softAPSSIDPrefix:c})=>{if(this.currentWifiConfigHandle)return{success:!1,err:o.errorCode.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING};try{switch(i){case 0:{this.currentWifiConfigHandle=new n.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});return this.currentWifiConfigHandle=null,i}case 3:{this.currentWifiConfigHandle=new a.default(e,t,this.specialProductKeys,this.specialProductKeySecrets);const i=await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({timeout:r,isBind:s,softAPSSIDPrefix:c});return this.currentWifiConfigHandle=null,i}}}catch(e){return e}finally{this.currentWifiConfigHandle=null}},this.getBindingList=async()=>{const e=await l.getBindingList();this.devieList=e.data||[]},this.getDevices=async()=>(await this.getBindingList(),this.allDevices),this.stopDeviceOnboardingDeploy=()=>{this.currentWifiConfigHandle&&(this.currentWifiConfigHandle.stopDeviceOnboardingDeploy(),this.currentWifiConfigHandle=null)},this.removeEventListener=(e,t)=>{if(this.listenerMap[e]){const i=this.listenerMap[e].indexOf(t);if(-1!==i)return this.listenerMap[e].splice(i,1),{success:!0}}return{success:!1}},this.addEventListener=async(e,t)=>(this.listenerMap[e]||(this.listenerMap[e]=[]),-1===this.listenerMap[e].indexOf(t)&&this.listenerMap[e].push(t),{success:!0}),this.productInfo=i,r.setGlobalData("appID",e),r.setGlobalData("appSecret",t),r.setGlobalData("productInfo",i),r.setGlobalData("token",v),r.setGlobalData("uid",g),this.bleHandle=new s.BleHandle(this.specialProductKeys),this.setDomain(p),setTimeout(()=>{this.scanBleDevice()},2e3),this.startAutoScan(),this.bleHandle.addDeviceListener("ALL",this.handleBleDeviceData)}get devieList(){return this._deviceList}set devieList(e){this._deviceList=e,this.notiDeviveList()}get bleDevices(){return this._bleDevices}set bleDevices(e){this._bleDevices=e,this.notiDeviveList()}get udpDevices(){return this._udpDevices}set udpDevices(e){this._udpDevices=e,this.notiDeviveList()}get allDevices(){let e=u.merageBleLocalDevices([...this.devieList],this.bleDevices);return e=u.merageLanLocalDevices(e,this.udpDevices),this.bleHandle.connectedList.map(t=>{const i=e.findIndex(e=>e.bleDeviceID===t.deviceId);-1!==i&&(e[i].connectType="BLE")}),e}get specialProductKeys(){return this.productInfo.map(e=>e.productKey||"")}get specialProductKeySecrets(){return this.productInfo.map(e=>e.productSecrets||"")}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.passcode="";let t=0;const i=parseInt(s.arrayToString(this.content.slice(t,t+2)),16);t+=2;let r="";this.content.slice(t,t+i).map(e=>{r+=String.fromCharCode(e)}),this.passcode=r}}n.pack=()=>[0,0,0,3,3,0,0,6],t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(6),s=i(2);class n extends r.default{constructor(e){super(e),this.result=!1,this.didLength=0,this.did="";let t=0;if(this.result=0===this.content[0],t++,1===this.flag[0]){this.didLength=parseInt(s.arrayToString(this.content.slice(t,t+2)),16),t+=2;let e="";this.content.slice(t,this.content.length).map(t=>{e+=String.fromCharCode(t)}),this.did=e}}}n.pack=({passcode:e})=>{let t=[0];const i=s.hexStrint2byte(s.fillString(e.length.toString(16),4)),r=s.string2Bytes(e),n=[0].concat([0,8]).concat(i).concat(r);return t=s.hexStrint2byte(n.length.toString(16)),[0,0,0,3].concat(t).concat(n)},t.default=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12),s=i(6),n=i(2);class a extends s.default{}a.pack=async(e,t,i)=>{const s=await r.default.getConfigFile(e),a="var_len"===s.protocolType,o=[0];let c=[0],l=[0],u=[2];if(t){c=[1];const e=n.fillString(t.length.toString(16),4),i=n.hexStrint2byte(e),r=n.string2Bytes(t);l=l.concat(i).concat(r)}if(a){u=[18];let e="";i?s.entities[0].attrs.map(t=>{e=void 0!==i[t.name]?`1${e}`:`0${e}`}):s.entities[0].attrs.map(()=>{e=`1${e}`}),e=n.fillString(e,8*Math.ceil(e.length/8)),u=u.concat(n.hexStrint2byte(parseInt(e,2).toString(16)))}const d=c.concat([0,147]).concat(l).concat(u);return o[0]=d.length,[0,0,0,3].concat(o).concat(d)},t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new Promise((i,r)=>{wx.request(Object.assign(Object.assign({url:e,timeout:3e3},t),{success:e=>{i(e)},fail:e=>{r(e)}}))})}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(20),n=i(21);class a extends n.default{constructor(){super(...arguments),this.disableSendUDP=!1,this.sendMessageInterval=null,this.UDPSocketHandler=null,this.destroy=()=>{this.cleanTimeout(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.sendMessageInterval=null,this.UDPSocketHandler&&(this.UDPSocketHandler.offError(),this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.close())},this.configDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise((n,a)=>{console.debug("GIZ_SDK: start config device");let o=!1,c=0;const l=s.default.pack(e,t);this.UDPSocketHandler=wx.createUDPSocket(),this.UDPSocketHandler.bind(),this.disableSendUDP=!1;const u=()=>{try{!this.disableSendUDP&&this.UDPSocketHandler.send({address:"10.10.100.254",port:12414,message:l,offset:0,length:l.byteLength})}catch(e){}};this.sendMessageInterval=setInterval(()=>{u()},2e3),this.UDPSocketHandler.onError(e=>{console.log("on udp Error",e),c+=1,c>2&&(this.destroy(),a({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:e.errMsg}}))});const d=async()=>{if(!o){this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.offError(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.disableSendUDP=!0,o=!0;try{const i=await this.searchDevice({ssid:e,password:t});n(i)}catch(e){a(e)}}};this.UDPSocketHandler.onMessage(()=>{d()}),wx.onNetworkStatusChange(async()=>{!o&&wx.getConnectedWifi({success:async e=>{-1===e.wifi.SSID.indexOf(i)&&d()}})})}),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>{const r=this.ssid,s=this.password;return new Promise(async(n,a)=>{this.destroy(),this.initDeviceOnboardingDeploy(n,a),this.startTimeoutTimer(e);try{const e=((await this.configDevice({ssid:r,password:s,softAPSSIDPrefix:i})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));if(t)try{n(await this.bindDevices(e))}catch(e){a(e)}else n({success:!0,data:e})}catch(e){a(e)}finally{this.destroy()}})}}}t.default=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8),s=i(8),n=({SSID:e,password:t,pk:i})=>{let n=r.MD5(e+t).toString();n=s.enc.Hex.parse(n);let a=s.enc.Utf8.parse(i),o=s.AES.encrypt(a,n,{iv:n,mode:s.mode.ECB,padding:s.pad.ZeroPadding});return r.MD5(o.ciphertext).toString()};t.default=({SSID:e,password:t,pks:i})=>{const r=[];return i.map(i=>{const s=n({SSID:e,password:t,pk:i});r.push(s)}),r}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){},function(e,t,i){var r;e.exports=(r=i(0),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,r=[],s=0;s<i;s++)r[s>>>2]|=e[s]<<24-s%4*8;t.call(this,r,i)}else t.apply(this,arguments)}).prototype=e}}(),r.lib.WordArray)},function(e,t,i){var r;e.exports=(r=i(0),function(){var e=r,t=e.lib.WordArray,i=e.enc;function s(e){return e<<8&4278255360|e>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],s=0;s<i;s+=2){var n=t[s>>>2]>>>16-s%4*8&65535;r.push(String.fromCharCode(n))}return r.join("")},parse:function(e){for(var i=e.length,r=[],s=0;s<i;s++)r[s>>>1]|=e.charCodeAt(s)<<16-s%2*16;return t.create(r,2*i)}},i.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var a=s(t[n>>>2]>>>16-n%4*8&65535);r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var i=e.length,r=[],n=0;n<i;n++)r[n>>>1]|=s(e.charCodeAt(n)<<16-n%2*16);return t.create(r,2*i)}}}(),r.enc.Utf16)},function(e,t,i){var r,s,n;e.exports=(n=i(0),s=(r=n).lib.WordArray,r.enc.Base64url={stringify:function(e,t=!0){var i=e.words,r=e.sigBytes,s=t?this._safe_map:this._map;e.clamp();for(var n=[],a=0;a<r;a+=3)for(var o=(i[a>>>2]>>>24-a%4*8&255)<<16|(i[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|i[a+2>>>2]>>>24-(a+2)%4*8&255,c=0;c<4&&a+.75*c<r;c++)n.push(s.charAt(o>>>6*(3-c)&63));var l=s.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(e,t=!0){var i=e.length,r=t?this._safe_map:this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var a=0;a<r.length;a++)n[r.charCodeAt(a)]=a}var o=r.charAt(64);if(o){var c=e.indexOf(o);-1!==c&&(i=c)}return function(e,t,i){for(var r=[],n=0,a=0;a<t;a++)if(a%4){var o=i[e.charCodeAt(a-1)]<<a%4*2|i[e.charCodeAt(a)]>>>6-a%4*2;r[n>>>2]|=o<<24-n%4*8,n++}return s.create(r,n)}(e,i,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},n.enc.Base64url)},function(e,t,i){var r,s,n,a,o,c;e.exports=(c=i(0),i(23),s=(r=c).lib.WordArray,n=r.algo,a=n.SHA256,o=n.SHA224=a.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=a._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=a._createHelper(o),r.HmacSHA224=a._createHmacHelper(o),c.SHA224)},function(e,t,i){var r,s,n,a,o,c,l,u;e.exports=(u=i(0),i(9),i(24),s=(r=u).x64,n=s.Word,a=s.WordArray,o=r.algo,c=o.SHA512,l=o.SHA384=c.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),r.SHA384=c._createHelper(l),r.HmacSHA384=c._createHmacHelper(l),u.SHA384)},function(e,t,i){var r;e.exports=(r=i(0),i(9),function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.x64.Word,o=t.algo,c=[],l=[],u=[];!function(){for(var e=1,t=0,i=0;i<24;i++){c[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)l[e+5*t]=t+(2*e+3*t)%5*5;for(var s=1,n=0;n<24;n++){for(var o=0,d=0,h=0;h<7;h++){if(1&s){var f=(1<<h)-1;f<32?d^=1<<f:o^=1<<f-32}128&s?s=s<<1^113:s<<=1}u[n]=a.create(o,d)}}();var d=[];!function(){for(var e=0;e<25;e++)d[e]=a.create()}();var h=o.SHA3=n.extend({cfg:n.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new a.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,s=0;s<r;s++){var n=e[t+2*s],a=e[t+2*s+1];n=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),(A=i[s]).high^=a,A.low^=n}for(var o=0;o<24;o++){for(var h=0;h<5;h++){for(var f=0,p=0,v=0;v<5;v++)f^=(A=i[h+5*v]).high,p^=A.low;var g=d[h];g.high=f,g.low=p}for(h=0;h<5;h++){var y=d[(h+4)%5],_=d[(h+1)%5],D=_.high,m=_.low;for(f=y.high^(D<<1|m>>>31),p=y.low^(m<<1|D>>>31),v=0;v<5;v++)(A=i[h+5*v]).high^=f,A.low^=p}for(var w=1;w<25;w++){var S=(A=i[w]).high,b=A.low,B=c[w];B<32?(f=S<<B|b>>>32-B,p=b<<B|S>>>32-B):(f=b<<B-32|S>>>64-B,p=S<<B-32|b>>>64-B);var I=d[l[w]];I.high=f,I.low=p}var k=d[0],C=i[0];for(k.high=C.high,k.low=C.low,h=0;h<5;h++)for(v=0;v<5;v++){var A=i[w=h+5*v],x=d[w],P=d[(h+1)%5+5*v],O=d[(h+2)%5+5*v];A.high=x.high^~P.high&O.high,A.low=x.low^~P.low&O.low}A=i[0];var E=u[o];A.high^=E.high,A.low^=E.low}},_doFinalize:function(){var t=this._data,i=t.words,r=(this._nDataBytes,8*t.sigBytes),n=32*this.blockSize;i[r>>>5]|=1<<24-r%32,i[(e.ceil((r+1)/n)*n>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var a=this._state,o=this.cfg.outputLength/8,c=o/8,l=[],u=0;u<c;u++){var d=a[u],h=d.high,f=d.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),l.push(f),l.push(h)}return new s.init(l,o)},clone:function(){for(var e=n.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=n._createHelper(h),t.HmacSHA3=n._createHmacHelper(h)}(Math),r.SHA3)},function(e,t,i){var r;e.exports=(r=i(0),
19
- /** @preserve
20
- (c) 2012 by Cédric Mesnil. All rights reserved.
21
-
22
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
23
-
24
- - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
25
- - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
26
-
27
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
29
- function(e){var t=r,i=t.lib,s=i.WordArray,n=i.Hasher,a=t.algo,o=s.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=s.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=s.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=s.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=s.create([0,1518500249,1859775393,2400959708,2840853838]),h=s.create([1352829926,1548603684,1836072691,2053994217,0]),f=a.RIPEMD160=n.extend({_doReset:function(){this._hash=s.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,s=e[r];e[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n,a,f,m,w,S,b,B,I,k,C,A=this._hash.words,x=d.words,P=h.words,O=o.words,E=c.words,L=l.words,M=u.words;for(S=n=A[0],b=a=A[1],B=f=A[2],I=m=A[3],k=w=A[4],i=0;i<80;i+=1)C=n+e[t+O[i]]|0,C+=i<16?p(a,f,m)+x[0]:i<32?v(a,f,m)+x[1]:i<48?g(a,f,m)+x[2]:i<64?y(a,f,m)+x[3]:_(a,f,m)+x[4],C=(C=D(C|=0,L[i]))+w|0,n=w,w=m,m=D(f,10),f=a,a=C,C=S+e[t+E[i]]|0,C+=i<16?_(b,B,I)+P[0]:i<32?y(b,B,I)+P[1]:i<48?g(b,B,I)+P[2]:i<64?v(b,B,I)+P[3]:p(b,B,I)+P[4],C=(C=D(C|=0,M[i]))+k|0,S=k,k=I,I=D(B,10),B=b,b=C;C=A[1]+f+I|0,A[1]=A[2]+m+k|0,A[2]=A[3]+w+S|0,A[3]=A[4]+n+b|0,A[4]=A[0]+a+B|0,A[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,n=s.words,a=0;a<5;a++){var o=n[a];n[a]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}return s},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,i){return e^t^i}function v(e,t,i){return e&t|~e&i}function g(e,t,i){return(e|~t)^i}function y(e,t,i){return e&i|t&~i}function _(e,t,i){return e^(t|~i)}function D(e,t){return e<<t|e>>>32-t}t.RIPEMD160=n._createHelper(f),t.HmacRIPEMD160=n._createHmacHelper(f)}(Math),r.RIPEMD160)},function(e,t,i){var r,s,n,a,o,c,l,u,d;e.exports=(d=i(0),i(14),i(15),n=(s=(r=d).lib).Base,a=s.WordArray,c=(o=r.algo).SHA1,l=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=l.create(i.hasher,e),s=a.create(),n=a.create([1]),o=s.words,c=n.words,u=i.keySize,d=i.iterations;o.length<u;){var h=r.update(t).finalize(n);r.reset();for(var f=h.words,p=f.length,v=h,g=1;g<d;g++){v=r.finalize(v),r.reset();for(var y=v.words,_=0;_<p;_++)f[_]^=y[_]}s.concat(h),c[0]++}return s.sigBytes=4*u,s}}),r.PBKDF2=function(e,t,i){return u.create(i).compute(e,t)},d.PBKDF2)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.mode.CFB=function(){var e=r.lib.BlockCipherMode.extend();function t(e,t,i,r){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,r.encryptBlock(s,0);for(var a=0;a<i;a++)e[t+a]^=s[a]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize;t.call(this,e,i,s,r),this._prevBlock=e.slice(i,i+s)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=e.slice(i,i+s);t.call(this,e,i,s,r),this._prevBlock=n}}),e}(),r.mode.CFB)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.CTR=(s=(r=n.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._counter;s&&(n=this._counter=s.slice(0),this._iv=void 0);var a=n.slice(0);i.encryptBlock(a,0),n[r-1]=n[r-1]+1|0;for(var o=0;o<r;o++)e[t+o]^=a[o]}}),r.Decryptor=s,r),n.mode.CTR)},function(e,t,i){var r;e.exports=(r=i(0),i(1),
30
- /** @preserve
31
- * Counter block mode compatible with Dr Brian Gladman fileenc.c
32
- * derived from CryptoJS.mode.CTR
33
- * Jan Hruby jhruby.web@gmail.com
34
- */
35
- r.mode.CTRGladman=function(){var e=r.lib.BlockCipherMode.extend();function t(e){if(255==(e>>24&255)){var t=e>>16&255,i=e>>8&255,r=255&e;255===t?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r}else e+=1<<24;return e}var i=e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=this._iv,a=this._counter;n&&(a=this._counter=n.slice(0),this._iv=void 0),function(e){0===(e[0]=t(e[0]))&&(e[1]=t(e[1]))}(a);var o=a.slice(0);r.encryptBlock(o,0);for(var c=0;c<s;c++)e[i+c]^=o[c]}});return e.Decryptor=i,e}(),r.mode.CTRGladman)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.OFB=(s=(r=n.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._keystream;s&&(n=this._keystream=s.slice(0),this._iv=void 0),i.encryptBlock(n,0);for(var a=0;a<r;a++)e[t+a]^=n[a]}}),r.Decryptor=s,r),n.mode.OFB)},function(e,t,i){var r,s;e.exports=(s=i(0),i(1),s.mode.ECB=((r=s.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),r.Decryptor=r.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),r),s.mode.ECB)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,r=4*t,s=r-i%r,n=i+s-1;e.clamp(),e.words[n>>>2]|=s<<24-n%4*8,e.sigBytes+=s},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Ansix923)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso10126={pad:function(e,t){var i=4*t,s=i-e.sigBytes%i;e.concat(r.lib.WordArray.random(s-1)).concat(r.lib.WordArray.create([s<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Iso10126)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t)},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--}},r.pad.Iso97971)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){var t=e.words,i=e.sigBytes-1;for(i=e.sigBytes-1;i>=0;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},r.pad.ZeroPadding)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)},function(e,t,i){var r,s,n,a;e.exports=(a=i(0),i(1),s=(r=a).lib.CipherParams,n=r.enc.Hex,r.format.Hex={stringify:function(e){return e.ciphertext.toString(n)},parse:function(e){var t=n.parse(e);return s.create({ciphertext:t})}},a.format.Hex)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.BlockCipher,i=e.algo,s=[],n=[],a=[],o=[],c=[],l=[],u=[],d=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,r=0;for(t=0;t<256;t++){var p=r^r<<1^r<<2^r<<3^r<<4;p=p>>>8^255&p^99,s[i]=p,n[p]=i;var v=e[i],g=e[v],y=e[g],_=257*e[p]^16843008*p;a[i]=_<<24|_>>>8,o[i]=_<<16|_>>>16,c[i]=_<<8|_>>>24,l[i]=_,_=16843009*y^65537*g^257*v^16843008*i,u[p]=_<<24|_>>>8,d[p]=_<<16|_>>>16,h[p]=_<<8|_>>>24,f[p]=_,i?(i=v^e[e[e[y^v]]],r^=e[e[r]]):i=r=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],v=i.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*((this._nRounds=i+6)+1),n=this._keySchedule=[],a=0;a<r;a++)a<i?n[a]=t[a]:(l=n[a-1],a%i?i>6&&a%i==4&&(l=s[l>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l]):(l=s[(l=l<<8|l>>>24)>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l],l^=p[a/i|0]<<24),n[a]=n[a-i]^l);for(var o=this._invKeySchedule=[],c=0;c<r;c++){if(a=r-c,c%4)var l=n[a];else l=n[a-4];o[c]=c<4||a<=4?l:u[s[l>>>24]]^d[s[l>>>16&255]]^h[s[l>>>8&255]]^f[s[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,o,c,l,s)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,u,d,h,f,n),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,s,n,a,o){for(var c=this._nRounds,l=e[t]^i[0],u=e[t+1]^i[1],d=e[t+2]^i[2],h=e[t+3]^i[3],f=4,p=1;p<c;p++){var v=r[l>>>24]^s[u>>>16&255]^n[d>>>8&255]^a[255&h]^i[f++],g=r[u>>>24]^s[d>>>16&255]^n[h>>>8&255]^a[255&l]^i[f++],y=r[d>>>24]^s[h>>>16&255]^n[l>>>8&255]^a[255&u]^i[f++],_=r[h>>>24]^s[l>>>16&255]^n[u>>>8&255]^a[255&d]^i[f++];l=v,u=g,d=y,h=_}v=(o[l>>>24]<<24|o[u>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^i[f++],g=(o[u>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^i[f++],y=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&u])^i[f++],_=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[u>>>8&255]<<8|o[255&d])^i[f++],e[t]=v,e[t+1]=g,e[t+2]=y,e[t+3]=_},keySize:8});e.AES=t._createHelper(v)}(),r.AES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib,i=t.WordArray,s=t.BlockCipher,n=e.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=n.DES=s.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=a[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var s=this._subKeys=[],n=0;n<16;n++){var l=s[n]=[],u=c[n];for(i=0;i<24;i++)l[i/6|0]|=t[(o[i]-1+u)%28]<<31-i%6,l[4+(i/6|0)]|=t[28+(o[i+24]-1+u)%28]<<31-i%6;for(l[0]=l[0]<<1|l[0]>>>31,i=1;i<7;i++)l[i]=l[i]>>>4*(i-1)+3;l[7]=l[7]<<5|l[7]>>>27}var d=this._invSubKeys=[];for(i=0;i<16;i++)d[i]=s[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),h.call(this,1,1431655765);for(var r=0;r<16;r++){for(var s=i[r],n=this._lBlock,a=this._rBlock,o=0,c=0;c<8;c++)o|=l[c][((a^s[c])&u[c])>>>0];this._lBlock=a,this._rBlock=n^o}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,h.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function f(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=s._createHelper(d);var p=n.TripleDES=s.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),r=e.length<4?e.slice(0,2):e.slice(2,4),s=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=d.createEncryptor(i.create(t)),this._des2=d.createEncryptor(i.create(r)),this._des3=d.createEncryptor(i.create(s))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=s._createHelper(p)}(),r.TripleDES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=i.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],s=0;s<256;s++)r[s]=s;s=0;for(var n=0;s<256;s++){var a=s%i,o=t[a>>>2]>>>24-a%4*8&255;n=(n+r[s]+o)%256;var c=r[s];r[s]=r[n],r[n]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var e=this._S,t=this._i,i=this._j,r=0,s=0;s<4;s++){i=(i+e[t=(t+1)%256])%256;var n=e[t];e[t]=e[i],e[i]=n,r|=e[(e[t]+e[i])%256]<<24-8*s}return this._i=t,this._j=i,r}e.RC4=t._createHelper(s);var a=i.RC4Drop=s.extend({cfg:s.cfg.extend({drop:192}),_doReset:function(){s._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)n.call(this)}});e.RC4Drop=t._createHelper(a)}(),r.RC4)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],s=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)s[i]^=r[i+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(s[0]^=l,s[1]^=d,s[2]^=u,s[3]^=h,s[4]^=l,s[5]^=d,s[6]^=u,s[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.Rabbit=t._createHelper(o)}(),r.Rabbit)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)r[s]^=i[s+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(r[0]^=l,r[1]^=d,r[2]^=u,r[3]^=h,r[4]^=l,r[5]^=d,r[6]^=u,r[7]^=h,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.RabbitLegacy=t._createHelper(o)}(),r.RabbitLegacy)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8);t.psKeySign=e=>{const t=Math.round((new Date).getTime()/1e3),i=e+t;return{Signature:r.MD5(i).toString(),timestamp:t}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(10),n=i(19),a=i(11),o=i(21),c=i(20);function l({bleDeviceId:e,arrayBuffer:t,serviceUUIDSuffix:i="abf0",characteristicUUIDSuffix:r="abf7"}){return new Promise(async(s,a)=>{try{await n.createBLEConnection(e,1e4);const a=await n.getBLEDeviceServices(e),o=a.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(i));if(!o)return console.debug("GIZ_SDK: get ble device services fail",e,a),void s(!1);const c=await n.getBLEDeviceCharacteristics(e,o.uuid),l=c.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(r));if(!l)return console.debug("GIZ_SDK: get ble device characteristics fail",e,c),void s(!1);if(!l.properties.notify&&!l.properties.indicate)return console.debug("GIZ_SDK: the ble device characteristic not support notify or indicate",e,l),void s(!1);await n.notifyBLECharacteristicValueChange(e,o.uuid,l.uuid);const u=()=>{wx.offBLECharacteristicValueChange(u),s(!0)};wx.onBLECharacteristicValueChange(u),await n.unpackWriteBLECharacteristicValue(e,o.uuid,l.uuid,t)}catch(e){a(e)}}).catch(e=>(console.debug("GIZ_SDK: sendBLEConfigCmd error",e),!1)).finally(()=>{wx.closeBLEConnection({deviceId:e})})}t.sendBLEConfigCmd=l;class u extends o.default{constructor(){super(...arguments),this.destroy=()=>{this.cleanTimeout()},this.isValidBleDevice=(e,t)=>{if(!e||!e.advertisData)return!1;const{productKey:i}=s.advertisData2PkAndMac(e.advertisData);return!!this.specialProductKeys.includes(i)&&(!t||e.name&&e.name.startsWith(t))},this.enableBluetoothDevicesDescovery=async()=>{try{await n.openBluetoothAdapter()}catch(e){}return(await n.getBluetoothAdapterState()).available?(await n.startBluetoothDevicesDiscovery(),{success:!0}):{success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON.errorCode,errorMessage:"蓝牙状态不可用"}}},this.enableAndGetBluetoothDevices=async e=>{const t=await this.enableBluetoothDevicesDescovery();return t.success?{success:!0,bleDevices:(await n.getBluetoothDevices()).filter(t=>this.isValidBleDevice(t,e))}:t},this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>(console.log("setDeviceOnboardingDeploy BLE"),new Promise(async(r,s)=>{const n=this.ssid,a=this.password;this.destroy(),this.initDeviceOnboardingDeploy(r,s),this.startTimeoutTimer(e);try{const s=await this.configBLEDevice({ssid:n,password:a,timeout:1e3*e,softAPSSIDPrefix:i});console.log("configBLEDevice",s);const o=(s.data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));r(t?await this.bindDevices(o):{success:!0,data:o})}catch(e){s(e)}finally{this.destroy()}})),this.configBLEDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise(async(n,o)=>{console.debug("GIZ_SDK: start config ble device");const u=await this.enableAndGetBluetoothDevices(i).catch(e=>({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:JSON.stringify(e)}}));if(!s.isWXDevicesResult(u))return o(u);const{bleDevices:d}=u,h=async({devices:e})=>{this.hasTimeoutHandler()?Array.prototype.push.apply(d,e.filter(e=>this.isValidBleDevice(e,i))):wx.offBluetoothDeviceFound(h)};wx.onBluetoothDeviceFound(h);const f=c.default.pack(e,t),p=async()=>{if(!this.hasTimeoutHandler())return;const i=d.shift();if(!i||!await l({bleDeviceId:i.deviceId,arrayBuffer:f.buffer}))return await a.default(100),void await p();wx.offBluetoothDeviceFound(h);try{const i=await this.searchDevice({ssid:e,password:t});n(i)}catch(e){o(e)}};await p()})}}t.default=u},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13);t.AnonymousLogin=async function({uid:e}){return r.default("/app/users",{data:{phone_id:e},method:"POST"},!1)}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12),s=i(2),n=e=>{const t=s.fillString(e,8*Math.ceil(e.length/8)),i=[];for(let e=0;e<t.length;e+=8)i.push(parseInt(t.substring(e,e+8),2));return i},a=e=>-1!==e.indexOf("uint")?"number":e,o=(e,t,i)=>{let r="";switch(e){case"bool":r=`${!0===t[i.name]?1:0}`;break;case"enum":{const e=i.enum.findIndex(e=>t[i.name]===e),n=-1===e?0:e;r=s.fillString(n.toString(2),i.position.len);break}case"number":{const e=Math.round((t[i.name]-i.uint_spec.addition)/i.uint_spec.ratio);r=s.fillString(e.toString(2),8*i.position.len);break}case"binary":{const e=t[i.name],n=s.fillString(e,2*i.position.len,!0);for(let e=0;e<n.length/2;e++){const t=2*e,i=n[t]+n[t+1];r+=s.fillString(parseInt(i,16).toString(2),8)}break}}const n=i.position.len*("byte"===i.position.unit?8:1)-r.length;if(n>0)for(let e=0;e<n;e++)r=`0${r}`;return`${r}`},c=(e,t,i)=>{switch(e){case"bool":return"1"===t;case"enum":{const e=parseInt(t,2);return i.enum[e]}case"binary":{const e=i.position.len;let r="";for(let e=0;e<t.length/8;e++){const i=8*e,n=t.substring(i,i+8);r+=s.fillString(parseInt(n,2).toString(16),2)}return s.fillString(r,2*e,!0)}case"number":return parseInt(t,2)/(1/i.uint_spec.ratio)+i.uint_spec.addition;default:return""}},l=({config:e,data:t,isAdaptiveDatapoint:i})=>{let r=e;const c=[0,0,0,3];let l=[1];if(i){l=[17];let e="";const i=[];r.map(r=>{void 0!==t[r.name]?(e=`1${e}`,i.push(r)):e=`0${e}`}),r=i,e=s.fillString(e,8*Math.ceil(e.length/8));for(let t=0;t<e.length/8;t++)l.push(parseInt(e.substring(8*t,8*(t+1)),2))}let u,d="";try{u=r[0]}catch(e){}r.map(e=>{"bool"===e.data_type||"enum"===e.data_type?(u.type!==e.type&&(l=l.concat(n(d)),d=""),d=((e,i)=>{const r=a(e.data_type);return o(r,t,e)+i})(e,d)):(d.length>0&&(l=l.concat(n(d)),d=""),l=((e,i)=>{const r=a(e.data_type),s=o(r,t,e);return i.concat(n(s))})(e,l)),u=e}),d.length>0&&(l=l.concat(n(d)),d="");const h=[0].concat([0,147]).concat([0,0,0,0]).concat(l),f=h.length.toString(2),p=[];for(let e=f.length;e>0;e-=7){const t=e-7,i=e;let r=f.substring(t,i);r=`${t>0?"1":"0"}${r}`,p.push(parseInt(r,2))}return c.push(...p),c.concat(h)};function u(e,t){return e===t||"ALL"===e}function d({attrs:e,activeAttrs:t,flagString:i,cmdData:r,accumulate:s}){let n=0,a={},o=0;return["status_writable","status_readonly","alert","fault"].map(c=>{const l=e.filter(e=>u(c,e.type)).length,{cmd:d,cmdDataLength:f}=h({type:c,attrs:e.slice(o,o+l),activeAttrs:t,flagString:i.substring(o,o+l),cmdData:r.slice(n,r.length),accumulate:s});return n+=f,a=Object.assign(Object.assign({},a),d),o+=l,null}),a}function h({type:e,attrs:t,activeAttrs:i,cmdData:r,flagString:n,accumulate:o}){let l=0,d=0,h=0;return i.map(t=>{if(u(e,t.type)){const e=t.position.len*("bit"===t.position.unit?1:8);"bool"===t.data_type||"enum"===t.data_type?d+=e:h+=e}return null}),l=Math.ceil(h/8)+Math.ceil(d/8),{cmdDataLength:l,cmd:function({attrs:e,flagString:t,boolEnumLength:i,cmdData:r,accumulate:n}){const o={};let l=0;for(let u=0;u<t.length;u++)if(e[u]&&"1"===t[u]){const{data_type:t,position:{len:n}}=e[u];let d="";if("bool"===t||"enum"===t){let e="";r.slice(0,i).map(t=>(e+=s.fillString(t.toString(2),8),null));const t=e.length-l;d=e.substring(t-n,t),l+=n}else{const e=i,t=i+n;r.slice(e,t).map(e=>(d+=s.fillString(e.toString(2),8),null)),i+=n}const h=a(t);o[e[u].name]=c(h,d,e[u])}else if(n){const t=e[u]||{position:{len:0}};"byte"===t.position.unit?i+=t.position.len:l+=t.position.len}return o}({attrs:t,flagString:n,boolEnumLength:Math.ceil(d/8),cmdData:r,accumulate:o})}}t.unpack=async(e,t)=>{const i=await r.default.getConfigFile(t);return function({config:e=[],data:t}){let i,r,n="";const a={header:s.arrayToString(t.slice(0,4)),flag:"",len:"",cmd:"",sn:"",action:"",payload:""},o=e;let c=s.checkHeader(t);if(!1===c)return;const l=t.slice(c,t.length),u=s.getProtocolLen(l);c+=u,a.len=s.arrayToString(l.slice(0,u)),c+=1,a.flag=s.arrayToString(t.slice(c-1,c)),c+=2,a.cmd=s.arrayToString(t.slice(c-2,c)),a.sn="","0093"!==a.cmd&&"0094"!==a.cmd||(a.sn=s.arrayToString(t.slice(c,c+4)),c+=4),a.action=s.arrayToString(t.slice(c,c+1)),i=t[c],c+=1,a.payload=s.arrayToString(t.slice(c,t.length));const f=t.slice(c,t.length);let p=o;1===i&&(p=o.filter(e=>"status_writable"===e.type));const v=JSON.parse(JSON.stringify(p)),g=Math.ceil(p.length/8);let y=f.slice(0,g),_=f.slice(g,f.length);3!==i&&4!==i||(y=new Array(g).fill(255),_=f);let D="";y.map(e=>(D+=s.fillString(e.toString(2),8),null)),i>=17&&i<=20&&(p=p.filter((e,t)=>{const i=D.length-1-t;return"1"===D[i]})),"0090"===a.cmd||"0093"===a.cmd?(n="App 透传数据到 Dev",r="APP2DEV"):"0091"===a.cmd||"0094"===a.cmd?(n="Dev 收到控制命令后应答到 App",r="DEV2APP"):(n="非法数据",r="UNKNOW");let m={};switch(i){case 1:n="App 下发数据到 Dev",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 2:return n="App 下发查询指令到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 3:n="Dev 回复查询指令到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 4:n="Dev 上报状态到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 5:return n="App 透传数据到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 6:return n="Dev 透传数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 7:return n="App 下发控制子设备",{kvData:null,rawData:a,message:n,messageType:r};case 8:return n="App 读取子设备数据",{kvData:null,rawData:a,message:n,messageType:r};case 9:return n="Dev 中控回复ACK",{kvData:null,rawData:a,message:n,messageType:r};case 10:return n="子设备上报状态到 App",{kvData:null,rawData:a,message:n,messageType:r};case 11:return n="App 下发添加子设备指令",{kvData:null,rawData:a,message:n,messageType:r};case 12:return n="App 下发删除子设备",{kvData:null,rawData:a,message:n,messageType:r};case 13:return n="App 获取中控子设备列表",{kvData:null,rawData:a,message:n,messageType:r};case 14:return n="中控响应字设备查询到 App",{kvData:null,rawData:a,message:n,messageType:r};case 15:return n="子设备列表变更通知到 App",{kvData:null,rawData:a,message:n,messageType:r};case 16:return n="Dev 子设备上下线状态变更通知",{kvData:null,rawData:a,message:n,messageType:r};case 17:n="App 下发变长数据到 Dev",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 18:return n="App 下发变长查询到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 19:n="Dev 变长回复查询指令到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 20:n="Dev 变长上报状态到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 114:return n="App 向网关发送数据",{kvData:null,rawData:a,message:n,messageType:r};case 115:return n="Dev 网关上报数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 116:return n="App 通知网关删除子设备",{kvData:null,rawData:a,message:n,messageType:r};default:return{kvData:null,rawData:a,message:n,messageType:r}}return 0===o.length?{kvData:null,rawData:a,message:n,messageType:r}:{kvData:m,rawData:a,message:n,messageType:r}}({config:(await i).entities[0].attrs,data:e})},t.pack=async(e,t)=>{const i=await r.default.getConfigFile(t),s="var_len"===i.protocolType;return l({data:e,config:(await i).entities[0].attrs,isAdaptiveDatapoint:s})}}])},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13);t.AnonymousLogin=async function({uid:e}){return r.default("/app/users",{data:{phone_id:e},method:"POST"},!1)}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12),s=i(2),n=e=>{const t=s.fillString(e,8*Math.ceil(e.length/8)),i=[];for(let e=0;e<t.length;e+=8)i.push(parseInt(t.substring(e,e+8),2));return i},a=e=>-1!==e.indexOf("uint")?"number":e,o=(e,t,i)=>{let r="";switch(e){case"bool":r=`${!0===t[i.name]?1:0}`;break;case"enum":{const e=i.enum.findIndex(e=>t[i.name]===e),n=-1===e?0:e;r=s.fillString(n.toString(2),i.position.len);break}case"number":{const e=Math.round((t[i.name]-i.uint_spec.addition)/i.uint_spec.ratio);r=s.fillString(e.toString(2),8*i.position.len);break}case"binary":{const e=t[i.name],n=s.fillString(e,2*i.position.len,!0);for(let e=0;e<n.length/2;e++){const t=2*e,i=n[t]+n[t+1];r+=s.fillString(parseInt(i,16).toString(2),8)}break}}const n=i.position.len*("byte"===i.position.unit?8:1)-r.length;if(n>0)for(let e=0;e<n;e++)r=`0${r}`;return`${r}`},c=(e,t,i)=>{switch(e){case"bool":return"1"===t;case"enum":{const e=parseInt(t,2);return i.enum[e]}case"binary":{const e=i.position.len;let r="";for(let e=0;e<t.length/8;e++){const i=8*e,n=t.substring(i,i+8);r+=s.fillString(parseInt(n,2).toString(16),2)}return s.fillString(r,2*e,!0)}case"number":return parseInt(t,2)/(1/i.uint_spec.ratio)+i.uint_spec.addition;default:return""}},l=({config:e,data:t,isAdaptiveDatapoint:i})=>{let r=e;const c=[0,0,0,3];let l=[1];if(i){l=[17];let e="";const i=[];r.map(r=>{void 0!==t[r.name]?(e=`1${e}`,i.push(r)):e=`0${e}`}),r=i,e=s.fillString(e,8*Math.ceil(e.length/8));for(let t=0;t<e.length/8;t++)l.push(parseInt(e.substring(8*t,8*(t+1)),2))}let u,d="";try{u=r[0]}catch(e){}r.map(e=>{"bool"===e.data_type||"enum"===e.data_type?(u.type!==e.type&&(l=l.concat(n(d)),d=""),d=((e,i)=>{const r=a(e.data_type);return i=o(r,t,e)+i})(e,d)):(d.length>0&&(l=l.concat(n(d)),d=""),l=((e,i)=>{const r=a(e.data_type),s=o(r,t,e);return i=i.concat(n(s))})(e,l)),u=e}),d.length>0&&(l=l.concat(n(d)),d="");const h=[0].concat([0,147]).concat([0,0,0,0]).concat(l),f=h.length.toString(2),p=[];for(let e=f.length;e>0;e-=7){const t=e-7,i=e;let r=f.substring(t,i);r=`${t>0?"1":"0"}${r}`,p.push(parseInt(r,2))}return c.push(...p),c.concat(h)};function u(e,t){return e===t||"ALL"===e}function d({attrs:e,activeAttrs:t,flagString:i,cmdData:r,accumulate:s}){let n=0,a={},o=0;return["status_writable","status_readonly","alert","fault"].map(c=>{const l=e.filter(e=>u(c,e.type)).length,{cmd:d,cmdDataLength:f}=h({type:c,attrs:e.slice(o,o+l),activeAttrs:t,flagString:i.substring(o,o+l),cmdData:r.slice(n,r.length),accumulate:s});return n+=f,a=Object.assign(Object.assign({},a),d),o+=l,null}),a}function h({type:e,attrs:t,activeAttrs:i,cmdData:r,flagString:n,accumulate:o}){let l=0,d=0,h=0;return i.map(t=>{if(u(e,t.type)){const e=t.position.len*("bit"===t.position.unit?1:8);"bool"===t.data_type||"enum"===t.data_type?d+=e:h+=e}return null}),l=Math.ceil(h/8)+Math.ceil(d/8),{cmdDataLength:l,cmd:function({attrs:e,flagString:t,boolEnumLength:i,cmdData:r,accumulate:n}){const o={};let l=0;for(let u=0;u<t.length;u++)if(e[u]&&"1"===t[u]){const{data_type:t,position:{len:n}}=e[u];let d="";if("bool"===t||"enum"===t){let e="";r.slice(0,i).map(t=>(e+=s.fillString(t.toString(2),8),null));const t=e.length-l;d=e.substring(t-n,t),l+=n}else{const e=i,t=i+n;r.slice(e,t).map(e=>(d+=s.fillString(e.toString(2),8),null)),i+=n}const h=a(t);o[e[u].name]=c(h,d,e[u])}else if(n){const t=e[u]||{position:{len:0}};"byte"===t.position.unit?i+=t.position.len:l+=t.position.len}return o}({attrs:t,flagString:n,boolEnumLength:Math.ceil(d/8),cmdData:r,accumulate:o})}}t.unpack=async(e,t)=>{const i=await r.default.getConfigFile(t);return i?function({config:e=[],data:t}){let i,r,n="";const a={header:s.arrayToString(t.slice(0,4)),flag:"",len:"",cmd:"",sn:"",action:"",payload:""},o=e;let c=s.checkHeader(t);if(!1===c)return;const l=t.slice(c,t.length),u=s.getProtocolLen(l);c+=u,a.len=s.arrayToString(l.slice(0,u)),c+=1,a.flag=s.arrayToString(t.slice(c-1,c)),c+=2,a.cmd=s.arrayToString(t.slice(c-2,c)),a.sn="","0093"!==a.cmd&&"0094"!==a.cmd||(a.sn=s.arrayToString(t.slice(c,c+4)),c+=4),a.action=s.arrayToString(t.slice(c,c+1)),i=t[c],c+=1,a.payload=s.arrayToString(t.slice(c,t.length));const f=t.slice(c,t.length);let p=o;1===i&&(p=o.filter(e=>"status_writable"===e.type));const v=JSON.parse(JSON.stringify(p)),g=Math.ceil(p.length/8);let y=f.slice(0,g),_=f.slice(g,f.length);3!==i&&4!==i||(y=new Array(g).fill(255),_=f);let D="";y.map(e=>(D+=s.fillString(e.toString(2),8),null)),i>=17&&i<=20&&(p=p.filter((e,t)=>{const i=D.length-1-t;return"1"===D[i]})),"0090"===a.cmd||"0093"===a.cmd?(n="App 透传数据到 Dev",r="APP2DEV"):"0091"===a.cmd||"0094"===a.cmd?(n="Dev 收到控制命令后应答到 App",r="DEV2APP"):(n="非法数据",r="UNKNOW");let m={};switch(i){case 1:n="App 下发数据到 Dev",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 2:return n="App 下发查询指令到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 3:n="Dev 回复查询指令到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 4:n="Dev 上报状态到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 5:return n="App 透传数据到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 6:return n="Dev 透传数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 7:return n="App 下发控制子设备",{kvData:null,rawData:a,message:n,messageType:r};case 8:return n="App 读取子设备数据",{kvData:null,rawData:a,message:n,messageType:r};case 9:return n="Dev 中控回复ACK",{kvData:null,rawData:a,message:n,messageType:r};case 10:return n="子设备上报状态到 App",{kvData:null,rawData:a,message:n,messageType:r};case 11:return n="App 下发添加子设备指令",{kvData:null,rawData:a,message:n,messageType:r};case 12:return n="App 下发删除子设备",{kvData:null,rawData:a,message:n,messageType:r};case 13:return n="App 获取中控子设备列表",{kvData:null,rawData:a,message:n,messageType:r};case 14:return n="中控响应字设备查询到 App",{kvData:null,rawData:a,message:n,messageType:r};case 15:return n="子设备列表变更通知到 App",{kvData:null,rawData:a,message:n,messageType:r};case 16:return n="Dev 子设备上下线状态变更通知",{kvData:null,rawData:a,message:n,messageType:r};case 17:n="App 下发变长数据到 Dev",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 18:return n="App 下发变长查询到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 19:n="Dev 变长回复查询指令到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 20:n="Dev 变长上报状态到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 114:return n="App 向网关发送数据",{kvData:null,rawData:a,message:n,messageType:r};case 115:return n="Dev 网关上报数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 116:return n="App 通知网关删除子设备",{kvData:null,rawData:a,message:n,messageType:r};default:return{kvData:null,rawData:a,message:n,messageType:r}}return 0===o.length?{kvData:null,rawData:a,message:n,messageType:r}:{kvData:m,rawData:a,message:n,messageType:r}}({config:(await i).entities[0].attrs,data:e}):null};t.pack=async(e,t)=>{const i=await r.default.getConfigFile(t);if(i){const t="var_len"===i.protocolType;return l({data:e,config:(await i).entities[0].attrs,isAdaptiveDatapoint:t})}return null}}]);
18
+ r.mode.CTRGladman=function(){var e=r.lib.BlockCipherMode.extend();function t(e){if(255==(e>>24&255)){var t=e>>16&255,i=e>>8&255,r=255&e;255===t?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r}else e+=1<<24;return e}var i=e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,s=r.blockSize,n=this._iv,a=this._counter;n&&(a=this._counter=n.slice(0),this._iv=void 0),function(e){0===(e[0]=t(e[0]))&&(e[1]=t(e[1]))}(a);var o=a.slice(0);r.encryptBlock(o,0);for(var c=0;c<s;c++)e[i+c]^=o[c]}});return e.Decryptor=i,e}(),r.mode.CTRGladman)},function(e,t,i){var r,s,n;e.exports=(n=i(0),i(1),n.mode.OFB=(r=n.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,s=this._iv,n=this._keystream;s&&(n=this._keystream=s.slice(0),this._iv=void 0),i.encryptBlock(n,0);for(var a=0;a<r;a++)e[t+a]^=n[a]}}),r.Decryptor=s,r),n.mode.OFB)},function(e,t,i){var r,s;e.exports=(s=i(0),i(1),s.mode.ECB=((r=s.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),r.Decryptor=r.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),r),s.mode.ECB)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,r=4*t,s=r-i%r,n=i+s-1;e.clamp(),e.words[n>>>2]|=s<<24-n%4*8,e.sigBytes+=s},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Ansix923)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso10126={pad:function(e,t){var i=4*t,s=i-e.sigBytes%i;e.concat(r.lib.WordArray.random(s-1)).concat(r.lib.WordArray.create([s<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Iso10126)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t)},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--}},r.pad.Iso97971)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){var t=e.words,i=e.sigBytes-1;for(i=e.sigBytes-1;i>=0;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},r.pad.ZeroPadding)},function(e,t,i){var r;e.exports=(r=i(0),i(1),r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)},function(e,t,i){var r,s,n,a;e.exports=(a=i(0),i(1),s=(r=a).lib.CipherParams,n=r.enc.Hex,r.format.Hex={stringify:function(e){return e.ciphertext.toString(n)},parse:function(e){var t=n.parse(e);return s.create({ciphertext:t})}},a.format.Hex)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.BlockCipher,i=e.algo,s=[],n=[],a=[],o=[],c=[],l=[],u=[],d=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,r=0;for(t=0;t<256;t++){var p=r^r<<1^r<<2^r<<3^r<<4;p=p>>>8^255&p^99,s[i]=p,n[p]=i;var v=e[i],g=e[v],y=e[g],_=257*e[p]^16843008*p;a[i]=_<<24|_>>>8,o[i]=_<<16|_>>>16,c[i]=_<<8|_>>>24,l[i]=_,_=16843009*y^65537*g^257*v^16843008*i,u[p]=_<<24|_>>>8,d[p]=_<<16|_>>>16,h[p]=_<<8|_>>>24,f[p]=_,i?(i=v^e[e[e[y^v]]],r^=e[e[r]]):i=r=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],v=i.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*((this._nRounds=i+6)+1),n=this._keySchedule=[],a=0;a<r;a++)a<i?n[a]=t[a]:(l=n[a-1],a%i?i>6&&a%i==4&&(l=s[l>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l]):(l=s[(l=l<<8|l>>>24)>>>24]<<24|s[l>>>16&255]<<16|s[l>>>8&255]<<8|s[255&l],l^=p[a/i|0]<<24),n[a]=n[a-i]^l);for(var o=this._invKeySchedule=[],c=0;c<r;c++){if(a=r-c,c%4)var l=n[a];else l=n[a-4];o[c]=c<4||a<=4?l:u[s[l>>>24]]^d[s[l>>>16&255]]^h[s[l>>>8&255]]^f[s[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,o,c,l,s)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,u,d,h,f,n),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,s,n,a,o){for(var c=this._nRounds,l=e[t]^i[0],u=e[t+1]^i[1],d=e[t+2]^i[2],h=e[t+3]^i[3],f=4,p=1;p<c;p++){var v=r[l>>>24]^s[u>>>16&255]^n[d>>>8&255]^a[255&h]^i[f++],g=r[u>>>24]^s[d>>>16&255]^n[h>>>8&255]^a[255&l]^i[f++],y=r[d>>>24]^s[h>>>16&255]^n[l>>>8&255]^a[255&u]^i[f++],_=r[h>>>24]^s[l>>>16&255]^n[u>>>8&255]^a[255&d]^i[f++];l=v,u=g,d=y,h=_}v=(o[l>>>24]<<24|o[u>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^i[f++],g=(o[u>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^i[f++],y=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&u])^i[f++],_=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[u>>>8&255]<<8|o[255&d])^i[f++],e[t]=v,e[t+1]=g,e[t+2]=y,e[t+3]=_},keySize:8});e.AES=t._createHelper(v)}(),r.AES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib,i=t.WordArray,s=t.BlockCipher,n=e.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=n.DES=s.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=a[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var s=this._subKeys=[],n=0;n<16;n++){var l=s[n]=[],u=c[n];for(i=0;i<24;i++)l[i/6|0]|=t[(o[i]-1+u)%28]<<31-i%6,l[4+(i/6|0)]|=t[28+(o[i+24]-1+u)%28]<<31-i%6;for(l[0]=l[0]<<1|l[0]>>>31,i=1;i<7;i++)l[i]=l[i]>>>4*(i-1)+3;l[7]=l[7]<<5|l[7]>>>27}var d=this._invSubKeys=[];for(i=0;i<16;i++)d[i]=s[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),h.call(this,1,1431655765);for(var r=0;r<16;r++){for(var s=i[r],n=this._lBlock,a=this._rBlock,o=0,c=0;c<8;c++)o|=l[c][((a^s[c])&u[c])>>>0];this._lBlock=a,this._rBlock=n^o}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,h.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function f(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=s._createHelper(d);var p=n.TripleDES=s.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),r=e.length<4?e.slice(0,2):e.slice(2,4),s=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=d.createEncryptor(i.create(t)),this._des2=d.createEncryptor(i.create(r)),this._des3=d.createEncryptor(i.create(s))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=s._createHelper(p)}(),r.TripleDES)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=i.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],s=0;s<256;s++)r[s]=s;s=0;for(var n=0;s<256;s++){var a=s%i,o=t[a>>>2]>>>24-a%4*8&255;n=(n+r[s]+o)%256;var c=r[s];r[s]=r[n],r[n]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var e=this._S,t=this._i,i=this._j,r=0,s=0;s<4;s++){i=(i+e[t=(t+1)%256])%256;var n=e[t];e[t]=e[i],e[i]=n,r|=e[(e[t]+e[i])%256]<<24-8*s}return this._i=t,this._j=i,r}e.RC4=t._createHelper(s);var a=i.RC4Drop=s.extend({cfg:s.cfg.extend({drop:192}),_doReset:function(){s._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)n.call(this)}});e.RC4Drop=t._createHelper(a)}(),r.RC4)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],s=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)s[i]^=r[i+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(s[0]^=l,s[1]^=d,s[2]^=u,s[3]^=h,s[4]^=l,s[5]^=d,s[6]^=u,s[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.Rabbit=t._createHelper(o)}(),r.Rabbit)},function(e,t,i){var r;e.exports=(r=i(0),i(4),i(5),i(3),i(1),function(){var e=r,t=e.lib.StreamCipher,i=e.algo,s=[],n=[],a=[],o=i.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)r[s]^=i[s+4&7];if(t){var n=t.words,a=n[0],o=n[1],l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(r[0]^=l,r[1]^=d,r[2]^=u,r[3]^=h,r[4]^=l,r[5]^=d,r[6]^=u,r[7]^=h,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),s[0]=i[0]^i[5]>>>16^i[3]<<16,s[1]=i[2]^i[7]>>>16^i[5]<<16,s[2]=i[4]^i[1]>>>16^i[7]<<16,s[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)s[r]=16711935&(s[r]<<8|s[r]>>>24)|4278255360&(s[r]<<24|s[r]>>>8),e[t+r]^=s[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)n[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<n[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<n[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<n[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<n[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<n[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<n[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<n[6]>>>0?1:0)|0,this._b=t[7]>>>0<n[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],s=65535&r,o=r>>>16,c=((s*s>>>17)+s*o>>>15)+o*o,l=((4294901760&r)*r|0)+((65535&r)*r|0);a[i]=c^l}e[0]=a[0]+(a[7]<<16|a[7]>>>16)+(a[6]<<16|a[6]>>>16)|0,e[1]=a[1]+(a[0]<<8|a[0]>>>24)+a[7]|0,e[2]=a[2]+(a[1]<<16|a[1]>>>16)+(a[0]<<16|a[0]>>>16)|0,e[3]=a[3]+(a[2]<<8|a[2]>>>24)+a[1]|0,e[4]=a[4]+(a[3]<<16|a[3]>>>16)+(a[2]<<16|a[2]>>>16)|0,e[5]=a[5]+(a[4]<<8|a[4]>>>24)+a[3]|0,e[6]=a[6]+(a[5]<<16|a[5]>>>16)+(a[4]<<16|a[4]>>>16)|0,e[7]=a[7]+(a[6]<<8|a[6]>>>24)+a[5]|0}e.RabbitLegacy=t._createHelper(o)}(),r.RabbitLegacy)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(13);t.psKeySign=e=>{const t=Math.round((new Date).getTime()/1e3),i=e+t;return{Signature:r.MD5(i).toString(),timestamp:t}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(7),s=i(9),n=i(19),a=i(10),o=i(21),c=i(20);function l({bleDeviceId:e,arrayBuffer:t,serviceUUIDSuffix:i="abf0",characteristicUUIDSuffix:r="abf7"}){return new Promise(async(s,a)=>{try{await n.createBLEConnection(e,1e4);const a=await n.getBLEDeviceServices(e),o=a.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(i));if(!o)return console.debug("GIZ_SDK: get ble device services fail",e,a),void s(!1);const c=await n.getBLEDeviceCharacteristics(e,o.uuid),l=c.find(e=>e.uuid.split("-")[0].toLowerCase().endsWith(r));if(!l)return console.debug("GIZ_SDK: get ble device characteristics fail",e,c),void s(!1);if(!l.properties.notify&&!l.properties.indicate)return console.debug("GIZ_SDK: the ble device characteristic not support notify or indicate",e,l),void s(!1);await n.notifyBLECharacteristicValueChange(e,o.uuid,l.uuid);const u=()=>{wx.offBLECharacteristicValueChange(u),s(!0)};wx.onBLECharacteristicValueChange(u),await n.unpackWriteBLECharacteristicValue(e,o.uuid,l.uuid,t)}catch(e){a(e)}}).catch(e=>(console.debug("GIZ_SDK: sendBLEConfigCmd error",e),!1)).finally(()=>{wx.closeBLEConnection({deviceId:e})})}t.sendBLEConfigCmd=l;class u extends o.default{constructor(){super(...arguments),this.destroy=()=>{this.cleanTimeout()},this.isValidBleDevice=(e,t)=>{if(!e||!e.advertisData)return!1;const{productKey:i,mac:r}=s.advertisData2PkAndMac(e.advertisData,this.specialProductKeys);return!!this.specialProductKeys.includes(i)&&(console.debug(`GIZ_SDK: isValidBleDevice mac: ${r} pk: ${i}`),!t||e.name&&e.name.startsWith(t))},this.enableBluetoothDevicesDescovery=async()=>{try{await n.openBluetoothAdapter()}catch(e){}return(await n.getBluetoothAdapterState()).available?(await n.startBluetoothDevicesDiscovery(),{success:!0}):{success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON.errorCode,errorMessage:"蓝牙状态不可用"}}},this.enableAndGetBluetoothDevices=async e=>{const t=await this.enableBluetoothDevicesDescovery();return t.success?(console.debug("GIZ_SDK: start enableAndGetBluetoothDevices"),{success:!0,bleDevices:(await n.getBluetoothDevices()).filter(t=>this.isValidBleDevice(t,e))}):t},this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i})=>new Promise(async(r,s)=>{const n=this.ssid,a=this.password;this.destroy(),this.initDeviceOnboardingDeploy(r,s),this.startTimeoutTimer(e);try{const s=((await this.configBLEDevice({ssid:n,password:a,timeout:1e3*e,softAPSSIDPrefix:i})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));r(t?await this.bindDevices(s):{success:!0,data:s})}catch(e){s(e)}finally{this.destroy()}}),this.configBLEDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>new Promise(async(o,u)=>{console.debug("GIZ_SDK: start config ble device");const d=await this.enableAndGetBluetoothDevices(i).catch(e=>({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:JSON.stringify(e)}}));if(!s.isWXDevicesResult(d))return u(d);console.debug("GIZ_SDK: enableAndGetBluetoothDevices success");const{bleDevices:h}=d,f=async({devices:e})=>{this.hasTimeoutHandler()?Array.prototype.push.apply(h,e.filter(e=>this.isValidBleDevice(e,i))):wx.offBluetoothDeviceFound(f)};wx.onBluetoothDeviceFound(f);const p=c.default.pack(e,t),v=async()=>{if(!this.hasTimeoutHandler())return;const i=h.shift();if(!(i&&await l({bleDeviceId:i.deviceId,arrayBuffer:p.buffer})))return await a.default(100),await n.startBluetoothDevicesDiscovery(),await v(),void console.debug("GIZ_SDK: search ble device");wx.offBluetoothDeviceFound(f);try{const i=await this.searchDevice({ssid:e,password:t});o(i)}catch(e){u(e)}};await v()})}}t.default=u},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(12);t.AnonymousLogin=async function({uid:e}){return r.default("/app/users",{data:{phone_id:e},method:"POST"},!1)}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(11),s=i(2),n=e=>{const t=s.fillString(e,8*Math.ceil(e.length/8)),i=[];for(let e=0;e<t.length;e+=8)i.push(parseInt(t.substring(e,e+8),2));return i},a=e=>-1!==e.indexOf("uint")?"number":e,o=(e,t,i)=>{let r="";switch(e){case"bool":r=`${!0===t[i.name]?1:0}`;break;case"enum":{const e=i.enum.findIndex(e=>t[i.name]===e),n=-1===e?0:e;r=s.fillString(n.toString(2),i.position.len);break}case"number":{let e=0;null!=t[i.name]&&(e=Math.round((t[i.name]-i.uint_spec.addition)/i.uint_spec.ratio)),r=s.fillString(e.toString(2),8*i.position.len);break}case"binary":{const e=t[i.name]||"",n=s.fillString(e,2*i.position.len,!0);for(let e=0;e<n.length/2;e++){const t=2*e,i=n[t]+n[t+1];r+=s.fillString(parseInt(i,16).toString(2),8)}break}}const n=i.position.len*("byte"===i.position.unit?8:1)-r.length;if(n>0)for(let e=0;e<n;e++)r=`0${r}`;return`${r}`},c=(e,t,i)=>{switch(e){case"bool":return"1"===t;case"enum":return parseInt(t,2);case"binary":{const e=i.position.len;let r="";for(let e=0;e<t.length/8;e++){const i=8*e,n=t.substring(i,i+8);r+=s.fillString(parseInt(n,2).toString(16),2)}return s.fillString(r,2*e,!0)}case"number":return parseInt(t,2)/(1/i.uint_spec.ratio)+i.uint_spec.addition;default:return""}},l=({config:e,data:t,isAdaptiveDatapoint:i})=>{let r=e;const c=[0,0,0,3];let l=[1],u="";const d=[];i||(r=r.filter(e=>"status_writable"===e.type)),r.map(e=>{void 0!==t[e.name]?(u=`1${u}`,d.push(e)):u=`0${u}`}),i&&(l=[17],r=d),u=s.fillString(u,8*Math.ceil(u.length/8));for(let e=0;e<u.length/8;e++)l.push(parseInt(u.substring(8*e,8*(e+1)),2));let h,f="";try{h=r[0]}catch(e){}r.map(e=>{"bool"===e.data_type||"enum"===e.data_type?(h.type!==e.type&&(l=l.concat(n(f)),f=""),f=((e,i)=>{const r=a(e.data_type);return i=o(r,t,e)+i})(e,f)):(f.length>0&&(l=l.concat(n(f)),f=""),l=((e,i)=>{const r=a(e.data_type),s=o(r,t,e);return i=i.concat(n(s))})(e,l)),h=e}),f.length>0&&(l=l.concat(n(f)),f="");const p=[0].concat([0,147]).concat([0,0,0,0]).concat(l),v=p.length.toString(2),g=[];for(let e=v.length;e>0;e-=7){const t=e-7,i=e;let r=v.substring(t,i);r=`${t>0?"1":"0"}${r}`,g.push(parseInt(r,2))}return c.push(...g),c.concat(p)};function u(e,t){return e===t||"ALL"===e}function d({attrs:e,activeAttrs:t,flagString:i,cmdData:r,accumulate:s}){let n=0,a={},o=0;return["status_writable","status_readonly","alert","fault"].map(c=>{const l=e.filter(e=>u(c,e.type)).length,{cmd:d,cmdDataLength:f}=h({type:c,attrs:e.slice(o,o+l),activeAttrs:t,flagString:i.substring(o,o+l),cmdData:r.slice(n,r.length),accumulate:s});return n+=f,a=Object.assign(Object.assign({},a),d),o+=l,null}),a}function h({type:e,attrs:t,activeAttrs:i,cmdData:r,flagString:n,accumulate:o}){let l=0,d=0,h=0;return i.map(t=>{if(u(e,t.type)){const e=t.position.len*("bit"===t.position.unit?1:8);"bool"===t.data_type||"enum"===t.data_type?d+=e:h+=e}return null}),l=Math.ceil(h/8)+Math.ceil(d/8),{cmdDataLength:l,cmd:function({attrs:e,flagString:t,boolEnumLength:i,cmdData:r,accumulate:n}){const o={};let l=0;for(let u=0;u<t.length;u++)if(e[u]&&"1"===t[u]){const{data_type:t,position:{len:n}}=e[u];let d="";if("bool"===t||"enum"===t){let e="";r.slice(0,i).map(t=>(e+=s.fillString(t.toString(2),8),null));const t=e.length-l;d=e.substring(t-n,t),l+=n}else{const e=i,t=i+n;r.slice(e,t).map(e=>(d+=s.fillString(e.toString(2),8),null)),i+=n}const h=a(t);o[e[u].name]=c(h,d,e[u])}else if(n){const t=e[u]||{position:{len:0}};"byte"===t.position.unit?i+=t.position.len:l+=t.position.len}return o}({attrs:t,flagString:n,boolEnumLength:Math.ceil(d/8),cmdData:r,accumulate:o})}}t.unpack=async(e,t)=>{const i=await r.default.getConfigFile(t);return i?function({config:e=[],data:t}){let i,r,n="";const a={header:s.arrayToString(t.slice(0,4)),flag:"",len:"",cmd:"",sn:"",action:"",payload:""},o=e;let c=s.checkHeader(t);if(!1===c)return;const l=t.slice(c,t.length),u=s.getProtocolLen(l);c+=u,a.len=s.arrayToString(l.slice(0,u)),c+=1,a.flag=s.arrayToString(t.slice(c-1,c)),c+=2,a.cmd=s.arrayToString(t.slice(c-2,c)),a.sn="","0093"!==a.cmd&&"0094"!==a.cmd||(a.sn=s.arrayToString(t.slice(c,c+4)),c+=4),a.action=s.arrayToString(t.slice(c,c+1)),i=t[c],c+=1,a.payload=s.arrayToString(t.slice(c,t.length));const f=t.slice(c,t.length);let p=o;1===i&&(p=o.filter(e=>"status_writable"===e.type));const v=JSON.parse(JSON.stringify(p)),g=Math.ceil(p.length/8);let y=f.slice(0,g),_=f.slice(g,f.length);3!==i&&4!==i||(y=new Array(g).fill(255),_=f);let D="";y.map(e=>(D+=s.fillString(e.toString(2),8),null)),i>=17&&i<=20&&(p=p.filter((e,t)=>{const i=D.length-1-t;return"1"===D[i]})),"0090"===a.cmd||"0093"===a.cmd?(n="App 透传数据到 Dev",r="APP2DEV"):"0091"===a.cmd||"0094"===a.cmd?(n="Dev 收到控制命令后应答到 App",r="DEV2APP"):(n="非法数据",r="UNKNOW");let m={};switch(i){case 1:n="App 下发数据到 Dev",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 2:return n="App 下发查询指令到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 3:n="Dev 回复查询指令到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 4:n="Dev 上报状态到 App",m=d({attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_,accumulate:!0});break;case 5:return n="App 透传数据到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 6:return n="Dev 透传数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 7:return n="App 下发控制子设备",{kvData:null,rawData:a,message:n,messageType:r};case 8:return n="App 读取子设备数据",{kvData:null,rawData:a,message:n,messageType:r};case 9:return n="Dev 中控回复ACK",{kvData:null,rawData:a,message:n,messageType:r};case 10:return n="子设备上报状态到 App",{kvData:null,rawData:a,message:n,messageType:r};case 11:return n="App 下发添加子设备指令",{kvData:null,rawData:a,message:n,messageType:r};case 12:return n="App 下发删除子设备",{kvData:null,rawData:a,message:n,messageType:r};case 13:return n="App 获取中控子设备列表",{kvData:null,rawData:a,message:n,messageType:r};case 14:return n="中控响应字设备查询到 App",{kvData:null,rawData:a,message:n,messageType:r};case 15:return n="子设备列表变更通知到 App",{kvData:null,rawData:a,message:n,messageType:r};case 16:return n="Dev 子设备上下线状态变更通知",{kvData:null,rawData:a,message:n,messageType:r};case 17:n="App 下发变长数据到 Dev",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 18:return n="App 下发变长查询到 Dev",{kvData:null,rawData:a,message:n,messageType:r};case 19:n="Dev 变长回复查询指令到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 20:n="Dev 变长上报状态到 App",m=h({type:"ALL",attrs:v,activeAttrs:p,flagString:D.split("").reverse().join(""),cmdData:_}).cmd;break;case 114:return n="App 向网关发送数据",{kvData:null,rawData:a,message:n,messageType:r};case 115:return n="Dev 网关上报数据到 App",{kvData:null,rawData:a,message:n,messageType:r};case 116:return n="App 通知网关删除子设备",{kvData:null,rawData:a,message:n,messageType:r};default:return{kvData:null,rawData:a,message:n,messageType:r}}return 0===o.length?{kvData:null,rawData:a,message:n,messageType:r}:{kvData:m,rawData:a,message:n,messageType:r}}({config:(await i).entities[0].attrs,data:e}):null};t.pack=async(e,t)=>{const i=await r.default.getConfigFile(t);if(i){const t="var_len"===i.protocolType;return l({data:e,config:(await i).entities[0].attrs,isAdaptiveDatapoint:t})}return null}}]);
package/main.js ADDED
@@ -0,0 +1,15 @@
1
+ var somevar = false;
2
+ var PTest = function () {
3
+ return new Promise(function (resolve, reject) {
4
+ if (somevar === true) resolve();
5
+ else reject();
6
+ });
7
+ };
8
+ var myfunc = PTest();
9
+ myfunc
10
+ .then(function () {
11
+ console.log('Promise Resolved');
12
+ })
13
+ .catch(function () {
14
+ console.log('Promise Rejected');
15
+ });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.0.0-beta-1",
4
- "description": "增加蓝牙功能",
3
+ "version": "3.0.0-beta-2",
4
+ "description": "修正获取设备数据点协议",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
8
8
  "testMy": "node_modules/mocha/bin/_mocha -r ts-node/register tests/utils/productConfigFileManage.spec.ts -file ./tests/setup-wx.js -timeout 60s",
9
+ "testBle": "node_modules/mocha/bin/_mocha -r ts-node/register tests/bleConfig/sdk.ble.spec.ts -file ./tests/setup-wx.js -timeout 60s",
9
10
  "build": "webpack",
10
11
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
11
12
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
@@ -22,6 +23,7 @@
22
23
  "devDependencies": {
23
24
  "@babel/plugin-transform-modules-commonjs": "^7.12.1",
24
25
  "@types/chai": "^4.2.11",
26
+ "@types/crypto-js": "^4.0.2",
25
27
  "@types/mocha": "^7.0.2",
26
28
  "@types/node": "^12.12.14",
27
29
  "chai": "^4.2.0",
@@ -33,9 +35,10 @@
33
35
  "ts-loader": "^6.2.2",
34
36
  "ts-node": "^8.8.1",
35
37
  "typescript": "^3.8.3",
38
+ "uglifyjs-webpack-plugin": "^2.2.0",
36
39
  "webpack": "^4.42.1",
37
- "webpack-cli": "^3.3.11",
38
- "@types/crypto-js": "^4.0.2"
40
+ "webpack-bundle-analyzer": "^4.5.0",
41
+ "webpack-cli": "^3.3.11"
39
42
  },
40
43
  "author": "gizwits",
41
44
  "license": "ISC",
@@ -44,6 +47,7 @@
44
47
  },
45
48
  "homepage": "https://github.com/gizwits/mini_program_gizwits_sdk#readme",
46
49
  "dependencies": {
50
+ "@types/sinon": "^10.0.6",
47
51
  "crypto-js": "^4.1.1"
48
52
  }
49
53
  }